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