diff options
author | Timothée Floure | 2016-03-08 23:16:12 +0100 |
---|---|---|
committer | Timothée Floure | 2016-03-08 23:16:12 +0100 |
commit | b0356d4ff6694ccc7f8fae1766b73b0e99c78ed9 (patch) | |
tree | 3e0400dc79c1a4cbae4e000f6642bf3d316953f2 /test/ch | |
parent | 5309cf4c441571a94e6c0033765ec43a3dc67ec8 (diff) | |
download | xblast-b0356d4ff6694ccc7f8fae1766b73b0e99c78ed9.tar.gz |
Import NameCheck04 and GaneStatePrinter (given files for the week 4)
Diffstat (limited to 'test/ch')
-rw-r--r-- | test/ch/epfl/xblast/namecheck/NameCheck04.java | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/test/ch/epfl/xblast/namecheck/NameCheck04.java b/test/ch/epfl/xblast/namecheck/NameCheck04.java new file mode 100644 index 0000000..b6adc8c --- /dev/null +++ b/test/ch/epfl/xblast/namecheck/NameCheck04.java | |||
@@ -0,0 +1,81 @@ | |||
1 | package ch.epfl.xblast.namecheck; | ||
2 | |||
3 | import java.util.List; | ||
4 | import java.util.Optional; | ||
5 | |||
6 | import ch.epfl.cs108.Sq; | ||
7 | import ch.epfl.xblast.Cell; | ||
8 | import ch.epfl.xblast.Lists; | ||
9 | import ch.epfl.xblast.PlayerID; | ||
10 | import ch.epfl.xblast.Time; | ||
11 | import ch.epfl.xblast.server.Block; | ||
12 | import ch.epfl.xblast.server.Board; | ||
13 | import ch.epfl.xblast.server.Bomb; | ||
14 | import ch.epfl.xblast.server.Bonus; | ||
15 | import ch.epfl.xblast.server.GameState; | ||
16 | import ch.epfl.xblast.server.Player; | ||
17 | import ch.epfl.xblast.server.Ticks; | ||
18 | |||
19 | /** | ||
20 | * Classe abstraite utilisant tous les éléments de l'étape 4, pour essayer de | ||
21 | * garantir que ceux-ci ont le bon nom et les bons types. Attention, ceci n'est | ||
22 | * pas un test unitaire, et n'a pas pour but d'être exécuté! | ||
23 | */ | ||
24 | |||
25 | abstract class NameCheck04 { | ||
26 | void checkLists() { | ||
27 | List<Integer> l1 = null; | ||
28 | List<List<Integer>> p1 = Lists.permutations(l1); | ||
29 | List<List<List<Integer>>> p2 = Lists.permutations(p1); | ||
30 | System.out.println(p2); | ||
31 | } | ||
32 | |||
33 | void checkBonus(boolean x) { | ||
34 | Bonus b = x ? Bonus.INC_BOMB : Bonus.INC_RANGE; | ||
35 | Player p = null; | ||
36 | p = b.applyTo(p); | ||
37 | } | ||
38 | |||
39 | void checkBlock(Block b) { | ||
40 | b = b.isBonus() ? Block.BONUS_BOMB : Block.BONUS_RANGE; | ||
41 | Bonus s = b.associatedBonus(); | ||
42 | System.out.println(s); | ||
43 | } | ||
44 | |||
45 | void checkTime() { | ||
46 | Optional<Integer> o; | ||
47 | o = Optional.of(Time.S_PER_MIN); | ||
48 | o = Optional.of(Time.MS_PER_S); | ||
49 | o = Optional.of(Time.US_PER_S); | ||
50 | o = Optional.of(Time.NS_PER_S); | ||
51 | System.out.println(o); | ||
52 | } | ||
53 | |||
54 | void checkTicks() { | ||
55 | Optional<Integer> o; | ||
56 | o = Optional.of(Ticks.TICKS_PER_SECOND); | ||
57 | o = Optional.of(Ticks.TICK_NANOSECOND_DURATION); | ||
58 | o = Optional.of(Ticks.TOTAL_TICKS); | ||
59 | System.out.println(o); | ||
60 | } | ||
61 | |||
62 | void checkGameState() { | ||
63 | int ts = 0; | ||
64 | Board b = null; | ||
65 | List<Player> ps = null; | ||
66 | List<Bomb> bs = null; | ||
67 | List<Sq<Sq<Cell>>> es = null; | ||
68 | List<Sq<Cell>> xs = null; | ||
69 | GameState s = new GameState(ts, b, ps, bs, es, xs); | ||
70 | s = new GameState(b, ps); | ||
71 | ts = s.ticks(); | ||
72 | if (s.isGameOver()) { | ||
73 | Optional<Double> t = Optional.of(s.remainingTime()); | ||
74 | System.out.println(t.get()); | ||
75 | } | ||
76 | Optional<PlayerID> w = s.winner(); | ||
77 | b = s.board(); | ||
78 | ps = s.isGameOver() ? s.alivePlayers() : s.players(); | ||
79 | System.out.println(w); | ||
80 | } | ||
81 | } | ||