-
Notifications
You must be signed in to change notification settings - Fork 0
/
CombatTests.cs
147 lines (128 loc) · 4.1 KB
/
CombatTests.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TDnD;
namespace TDnDTests
{
[TestClass]
public class CombatTests
{
private ICharacter _attacker;
private ICharacter _strongMan;
private ICharacter _target;
private const int LowRoll = 8;
private const int EqualRoll = 10;
private const int HighRoll = 18;
private const int CritRoll = 20;
[TestInitialize]
public void Initialize()
{
_attacker = new BaseCharacter();
var abilities = new AbilityScores(12);
_strongMan = new BaseCharacter(abilities);
_target = new BaseCharacter();
}
[TestMethod]
public void AnAttackLessThanArmorClassMisses()
{
var hit = _attacker.Attack(LowRoll, _target);
Assert.IsFalse(hit);
}
[TestMethod]
public void AnAttackEqualToArmorClassMisses()
{
var hit =_attacker.Attack(EqualRoll, _target);
Assert.IsFalse(hit);
}
[TestMethod]
public void AnAttackGreaterThanArmorClassHits()
{
var hit = _attacker.Attack(HighRoll, _target);
Assert.IsTrue(hit);
}
[TestMethod]
public void AHitDealsOneDamage()
{
_attacker.Attack(HighRoll, _target);
Assert.AreEqual(1, _target.CurrentDamage);
}
[TestMethod]
public void AnAttackWithARollOfTwentyDealsTwoDamage()
{
_attacker.Attack(CritRoll, _target);
Assert.AreEqual(2, _target.CurrentDamage);
}
[TestMethod]
public void StrengthIsAddedToAttack()
{
var hit = _strongMan.Attack(EqualRoll, _target);
Assert.IsTrue(hit);
}
[TestMethod]
public void StrengthIsAddedToDamage()
{
_strongMan.Attack(HighRoll, _target);
Assert.AreEqual(2, _target.CurrentDamage);
}
[TestMethod]
public void StrengthDamageIsDoubledOnCrit()
{
_strongMan.Attack(CritRoll, _target);
Assert.AreEqual(4, _target.CurrentDamage);
}
[TestMethod]
public void MinimumDamageOnHitIsOne()
{
_attacker.Attack(HighRoll, _target);
Assert.AreEqual(1, _target.CurrentDamage);
}
[TestMethod]
public void CharactersAreDeadWhenTheirHitPointsAreZeroOrLess()
{
for (var i = 0; i < 4; i++)
{
_attacker.Attack(CritRoll, _target);
}
Assert.IsTrue(_target.IsDead);
}
[TestMethod]
public void ExperienceIsGainedWhenAttacksLand()
{
_attacker.Attack(HighRoll, _target);
Assert.AreEqual(10, _attacker.Experience);
}
[TestMethod]
public void AttackIncreasesOneEveryOtherLevel()
{
for (var i = 0; i < 200; i++)
{
_attacker.Attack(HighRoll, _target);
}
var hit = _attacker.Attack(EqualRoll, _target);
Assert.IsTrue(hit);
}
[TestMethod]
public void RoguesDoTripleDamageOnCrit()
{
_attacker = new Rogue(_attacker);
_attacker.Attack(CritRoll, _target);
Assert.AreEqual(3, _target.CurrentDamage);
}
[TestMethod]
public void RouguesIgnoreDexterityBonusToArmorClass()
{
var abilities = new AbilityScores(dexterity: 12);
var dexterousEnemy = new BaseCharacter(abilities);
_attacker = new Rogue(_attacker);
var hit = _attacker.Attack(EqualRoll + 1, dexterousEnemy);
Assert.IsTrue(hit);
}
[TestMethod]
public void RoguesAddDexInsteadOfStrengthToAttacks()
{
var abilities = new AbilityScores(dexterity: 12);
ICharacter attacker = new BaseCharacter(abilities);
attacker = new Rogue(attacker);
var hit = attacker.Attack(EqualRoll, _target);
Assert.IsTrue(hit);
}
}
}