-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRatCatcher.cs
62 lines (57 loc) · 1.8 KB
/
RatCatcher.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
using System;
using Enemies;
namespace Defenders
{
class RatCatcher : IDefender
{
protected readonly string name;
private bool hasRat;
public RatCatcher(string name)
{
this.name = name;
hasRat=false;
}
int IDefender.Attack(Rat e)
{
//#if DEBUG
// Console.WriteLine(e.GetType() + " " + e.Name + " approaches " + this.GetType() + " " + this.name + ".");
//#endif
if (hasRat)
{
Console.WriteLine(this.name + " ignores " + e.Name);
return 0;
}
else
{
Console.WriteLine(this.name + " catches " + e.Name);
hasRat = true;
return 99999999; //assuming that max health is less than 99999999 then the enemy will die for sure.
}
}
int IDefender.Attack(Giant e)
{
//#if DEBUG
// Console.WriteLine(e.GetType() + " " + e.Name + " approaches " + this.GetType() + " " + this.name + ".");
//#endif
Console.WriteLine(this.name + " ignores " + e.Name+'.');
return 0;
}
int IDefender.Attack(Ogre e)
{
//#if DEBUG
// Console.WriteLine(e.GetType() + " " + e.Name + " approaches " + this.GetType() + " " + this.name + ".");
//#endif
if (!hasRat)
{
Console.WriteLine(this.name + " ignores " + e.Name + '.');
return 0;
}
else
{
Console.WriteLine(this.name + " throws the rat it has on " + e.Name + " causing it to flee.");
hasRat = false;
return 99999999; //assuming that max health is less than 99999999 then the enemy will die for sure.
}
}
}
}