diff options
author | Timothée Floure | 2016-03-07 15:16:38 +0100 |
---|---|---|
committer | Timothée Floure | 2016-03-07 15:16:38 +0100 |
commit | b2271f5f8355f74fb1e7c23357fb22059aa02701 (patch) | |
tree | 93ed89cf189964ca6605c02bc827d76177d7d226 /test/ch | |
parent | 2165f60e83fa4e36183c2821955dbd77d86af3f0 (diff) | |
download | xblast-b2271f5f8355f74fb1e7c23357fb22059aa02701.tar.gz |
Add NameCheck03
Diffstat (limited to 'test/ch')
-rw-r--r-- | test/ch/epfl/xblast/namecheck/NameCheck03.java | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/test/ch/epfl/xblast/namecheck/NameCheck03.java b/test/ch/epfl/xblast/namecheck/NameCheck03.java new file mode 100644 index 0000000..d4faaeb --- /dev/null +++ b/test/ch/epfl/xblast/namecheck/NameCheck03.java | |||
@@ -0,0 +1,90 @@ | |||
1 | package ch.epfl.xblast.namecheck; | ||
2 | |||
3 | import java.util.List; | ||
4 | |||
5 | import ch.epfl.cs108.Sq; | ||
6 | import ch.epfl.xblast.ArgumentChecker; | ||
7 | import ch.epfl.xblast.Cell; | ||
8 | import ch.epfl.xblast.Direction; | ||
9 | import ch.epfl.xblast.PlayerID; | ||
10 | import ch.epfl.xblast.SubCell; | ||
11 | import ch.epfl.xblast.server.Bomb; | ||
12 | import ch.epfl.xblast.server.Player; | ||
13 | |||
14 | /** | ||
15 | * Classe abstraite utilisant tous les éléments de l'étape 3, pour essayer de | ||
16 | * garantir que ceux-ci ont le bon nom et les bons types. Attention, ceci n'est | ||
17 | * pas un test unitaire, et n'a pas pour but d'être exécuté! | ||
18 | */ | ||
19 | |||
20 | abstract class NameCheck03 { | ||
21 | void checkArgumentChecker() { | ||
22 | ArgumentChecker.requireNonNegative(10); | ||
23 | } | ||
24 | |||
25 | void checkPlayerID() { | ||
26 | ArgumentChecker.requireNonNegative(PlayerID.PLAYER_1.ordinal()); | ||
27 | ArgumentChecker.requireNonNegative(PlayerID.PLAYER_2.ordinal()); | ||
28 | ArgumentChecker.requireNonNegative(PlayerID.PLAYER_3.ordinal()); | ||
29 | ArgumentChecker.requireNonNegative(PlayerID.PLAYER_4.ordinal()); | ||
30 | } | ||
31 | |||
32 | void checkPlayerState() { | ||
33 | ArgumentChecker.requireNonNegative(Player.LifeState.State.INVULNERABLE.ordinal()); | ||
34 | ArgumentChecker.requireNonNegative(Player.LifeState.State.VULNERABLE.ordinal()); | ||
35 | ArgumentChecker.requireNonNegative(Player.LifeState.State.DYING.ordinal()); | ||
36 | ArgumentChecker.requireNonNegative(Player.LifeState.State.DEAD.ordinal()); | ||
37 | Player.LifeState.State k = null; | ||
38 | Player.LifeState t = new Player.LifeState(-1, k); | ||
39 | k = t.state(); | ||
40 | int l = t.lives(); | ||
41 | System.out.println(t.canMove() ? l : ""); | ||
42 | } | ||
43 | |||
44 | void checkPlayerDirectedPosition() { | ||
45 | Player.DirectedPosition p = null; | ||
46 | Sq<Player.DirectedPosition> s = Player.DirectedPosition.stopped(p); | ||
47 | Sq<Player.DirectedPosition> m = Player.DirectedPosition.moving(p); | ||
48 | SubCell c = m.head().position(); | ||
49 | Direction d = s.head().direction(); | ||
50 | p = new Player.DirectedPosition(c, d); | ||
51 | p = s.head().withDirection(d); | ||
52 | p = m.head().withPosition(c); | ||
53 | } | ||
54 | |||
55 | void checkPlayer() { | ||
56 | PlayerID pid = null; | ||
57 | Sq<Player.LifeState> s = null; | ||
58 | Sq<Player.DirectedPosition> d = null; | ||
59 | Player p = new Player(pid, s, d, -1, -1); | ||
60 | Cell c = null; | ||
61 | p = new Player(pid, -1, c, -1, -1); | ||
62 | pid = p.id(); | ||
63 | s = p.lifeStates(); | ||
64 | Player.LifeState s1 = p.lifeState(); | ||
65 | s = p.statesForNextLife(); | ||
66 | int l = p.lives() + p.maxBombs() + p.bombRange(); | ||
67 | if (p.isAlive() || l > 2 || s1 != null) | ||
68 | ++l; | ||
69 | p = p.withBombRange(-1).withMaxBombs(-1); | ||
70 | Bomb b = p.newBomb(); | ||
71 | d = p.directedPositions(); | ||
72 | Direction d2 = p.direction(); | ||
73 | SubCell pos = p.position(); | ||
74 | System.out.println(b.toString() + d2 + pos); | ||
75 | } | ||
76 | |||
77 | void checkBomb() { | ||
78 | PlayerID pid = null; | ||
79 | Cell c = null; | ||
80 | Sq<Integer> s = null; | ||
81 | Bomb b = new Bomb(pid, c, s, -1); | ||
82 | b = new Bomb(pid, c, -1, -1); | ||
83 | pid = b.ownerId(); | ||
84 | c = b.position(); | ||
85 | int t = b.fuseLength() + b.range(); | ||
86 | s = b.fuseLengths(); | ||
87 | List<Sq<Sq<Cell>>> x = b.explosion(); | ||
88 | System.out.println(String.valueOf(t) + x); | ||
89 | } | ||
90 | } | ||