-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSuperHero.cs
More file actions
106 lines (100 loc) · 2.74 KB
/
SuperHero.cs
File metadata and controls
106 lines (100 loc) · 2.74 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FightArena
{
class SuperHero
{
private string name;
private int hitPoints;
private bool stillStanding;
private byte highestDefence;
private byte lowestDefence;
private int highestAttack;
private int lowestAttack;
public string Name
{
get { return this.name; }
}
public int HitPoints
{
get { return this.hitPoints; }
set
{
this.hitPoints = value;
if(this.hitPoints <= 0)
{
this.stillStanding = false;
}
}
}
public bool StillStanding
{
get { return this.stillStanding; }
}
public SuperHero(string Name, byte HitPoints, byte LowestDefence, byte HighestDefence, int HighestAttack, int LowestAttack)
{
name = Name;
hitPoints = HitPoints;
highestDefence = HighestDefence;
lowestDefence = LowestDefence;
highestAttack = HighestAttack;
lowestAttack = LowestAttack;
stillStanding = true;
}
public virtual int Attack()
{
return Logic.random(this.lowestAttack, this.highestAttack);
}
public virtual void GetAttacked(int damage)
{
// Needs to be int or similar, for bytes don't go below 0.
int postDefence = damage - Logic.random(this.lowestDefence, this.highestDefence);
if(postDefence > 0)
{
this.HitPoints -= postDefence;
}
}
}
class SpeedyKarl : SuperHero
{
private bool rightHook;
public SpeedyKarl():base("Speedy Karl", 90, 3, 3, 5, 2)
{
rightHook = true;
}
public override int Attack()
{
if (this.rightHook)
{
this.rightHook = false;
return 5;
}
else
{
this.rightHook = true;
return 2;
}
}
}
class TigerTheCat : SuperHero
{
private byte lives;
public TigerTheCat() : base("Tiger The Cat", 35, 4, 4, 6, 3)
{
lives = 9;
}
public override void GetAttacked(int damage)
{
// It wouldn't be 9 lives if they didn't save it from getting knocked out in the first place.
if (lives > 0)
{
lives--;
this.HitPoints += 3;
}
base.GetAttacked(damage);
}
}
}