-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hero.cs
83 lines (73 loc) · 2.26 KB
/
Hero.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
namespace Battle
{
public class Hero
{
public string name;
public bool isAgil;
public int strenght;
public int agility;
public int armor;
public int baseHealth;
public int baseDamage;
public int regen;
public double currentHealth;
public Hero(string name, bool isAgil, int strenght, int agility, int armor, int baseDamage, int regen)
{
this.name = name;
this.isAgil = isAgil;
this.strenght = strenght;
this.agility = agility;
this.armor = armor;
this.baseDamage = baseDamage;
this.regen = regen;
baseHealth = strenght * 30;
currentHealth = baseHealth;
}
public Hero(string name, bool isAgil, int strenght, int agility, int armor, int baseDamage, int regen, double currentHealth)
{
this.name = name;
this.isAgil = isAgil;
this.strenght = strenght;
this.agility = agility;
this.armor = armor;
this.baseDamage = baseDamage;
this.regen = regen;
baseHealth = strenght * 30;
this.currentHealth = currentHealth;
}
public void Run(bool isSecondRun)
{
if(isSecondRun)
{
if (new Random().Next(2) == 0)
{
currentHealth += 5 * regen;
if (currentHealth > baseHealth) currentHealth = baseDamage;
}
}
else
{
currentHealth -= baseHealth * 0.01;
}
}
public void Attack(Hero hero)
{
hero.currentHealth -= armor * agility / 5.0 + baseDamage * strenght / 5.0;
currentHealth -= baseDamage * strenght / 20.0;
}
public override string ToString()
{
int a;
if (isAgil) a = 1;
else
{
a = 0;
}
return name + "," + a + "," +
strenght + "," + agility + "," +
armor + "," + baseDamage + "," +
regen +"," + currentHealth;
}
}
}