Newer
Older
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
package fr.univamu.progav.td5;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class WizardTest {
@Test
void newWizard() {
Wizard wizard = new Wizard();
assertEquals(20,wizard.getHealth());
assertEquals(0,wizard.getShield());
assertTrue(wizard.isAlive());
}
@Test
void attack() {
Wizard wizard = new Wizard();
Blow b = wizard.attack();
assertEquals(4, b.magicalDamage());
assertEquals(0, b.physicalDamage());
wizard.specialAction();
b = wizard.attack();
assertEquals(4, b.magicalDamage());
assertEquals(0,b.physicalDamage());
}
@Test
void defend() {
Wizard wizard = new Wizard();
assertEquals(20,wizard.getHealth());
wizard.defend(new Blow(6,2));
assertEquals(15,wizard.getHealth(), "Wizard loses life on physical attack, but physical damage is reduced by half of magical damage");
wizard.defend(new Blow(0,10));
assertEquals(15,wizard.getHealth(), "Wizard does not gain life on magical attack.");
}
@Test
void specialAction() {
Wizard wizard = new Wizard();
wizard.specialAction();
assertEquals(20, wizard.getHealth());
wizard.defend(new Blow(6, 2));
assertEquals(20, wizard.getHealth(), "Wizard's shield absorbs physical damage");
assertEquals(2, wizard.getShield());
wizard.defend(new Blow(6, 2));
assertEquals(
17,
wizard.getHealth(),
"Wizard's shield absorbs physical damage until depleted, then normal rules apply"
);
assertEquals(0, wizard.getShield());
}
@Test
void maxShieldValue() {
Wizard wizard = new Wizard();
wizard.specialAction();
wizard.defend(new Blow(5,0));
wizard.specialAction();
wizard.defend(new Blow(5,0));
assertEquals(3, wizard.getShield(),"Wizard's special action sets shield to 8 (not an addition)");
}
}