diff options
author | Pacien TRAN-GIRARD | 2016-03-26 13:44:46 +0100 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2016-03-26 13:44:46 +0100 |
commit | 552d82f34ee4b60785164bc40d6dd5b5d8923609 (patch) | |
tree | 1c85c722e095d7498d7c2ab3c73141d7a0153675 /src/ch/epfl | |
parent | fa66073ed8bb68b144c3e7397ef95ce0d8442ae8 (diff) | |
download | xblast-552d82f34ee4b60785164bc40d6dd5b5d8923609.tar.gz |
Implement random event live simulation
Diffstat (limited to 'src/ch/epfl')
-rw-r--r-- | src/ch/epfl/xblast/server/GameState.java | 12 | ||||
-rw-r--r-- | src/ch/epfl/xblast/server/Player.java | 11 | ||||
-rw-r--r-- | src/ch/epfl/xblast/server/debug/GameStatePrinter.java | 15 |
3 files changed, 34 insertions, 4 deletions
diff --git a/src/ch/epfl/xblast/server/GameState.java b/src/ch/epfl/xblast/server/GameState.java index 1abe17a..4b00c3e 100644 --- a/src/ch/epfl/xblast/server/GameState.java +++ b/src/ch/epfl/xblast/server/GameState.java | |||
@@ -477,4 +477,16 @@ public final class GameState { | |||
477 | .collect(Collectors.toList()); | 477 | .collect(Collectors.toList()); |
478 | } | 478 | } |
479 | 479 | ||
480 | @Override | ||
481 | public String toString() { | ||
482 | return "GameState{" + | ||
483 | "ticks=" + ticks + | ||
484 | ", board=" + board + | ||
485 | ", players=" + players + | ||
486 | ", bombs=" + bombs + | ||
487 | ", explosions=" + explosions + | ||
488 | ", blasts=" + blasts + | ||
489 | '}'; | ||
490 | } | ||
491 | |||
480 | } | 492 | } |
diff --git a/src/ch/epfl/xblast/server/Player.java b/src/ch/epfl/xblast/server/Player.java index 094d395..d2f7b88 100644 --- a/src/ch/epfl/xblast/server/Player.java +++ b/src/ch/epfl/xblast/server/Player.java | |||
@@ -329,4 +329,15 @@ public final class Player { | |||
329 | return new Bomb(this.id(), this.position().containingCell(), Ticks.BOMB_FUSE_TICKS, this.bombRange()); | 329 | return new Bomb(this.id(), this.position().containingCell(), Ticks.BOMB_FUSE_TICKS, this.bombRange()); |
330 | } | 330 | } |
331 | 331 | ||
332 | @Override | ||
333 | public String toString() { | ||
334 | return "Player{" + | ||
335 | "id=" + id + | ||
336 | ", lifeStates=" + lifeStates + | ||
337 | ", directedPos=" + directedPos + | ||
338 | ", maxBombs=" + maxBombs + | ||
339 | ", bombRange=" + bombRange + | ||
340 | '}'; | ||
341 | } | ||
342 | |||
332 | } | 343 | } |
diff --git a/src/ch/epfl/xblast/server/debug/GameStatePrinter.java b/src/ch/epfl/xblast/server/debug/GameStatePrinter.java index ea8b360..d4d91e5 100644 --- a/src/ch/epfl/xblast/server/debug/GameStatePrinter.java +++ b/src/ch/epfl/xblast/server/debug/GameStatePrinter.java | |||
@@ -12,6 +12,7 @@ import java.util.List; | |||
12 | * Game state printer utility class that outputs the board to the terminal. | 12 | * Game state printer utility class that outputs the board to the terminal. |
13 | * | 13 | * |
14 | * @author EPFL | 14 | * @author EPFL |
15 | * @author Pacien TRAN-GIRARD (261948) | ||
15 | */ | 16 | */ |
16 | public final class GameStatePrinter { | 17 | public final class GameStatePrinter { |
17 | 18 | ||
@@ -19,9 +20,15 @@ public final class GameStatePrinter { | |||
19 | } | 20 | } |
20 | 21 | ||
21 | public static void printGameState(GameState s) { | 22 | public static void printGameState(GameState s) { |
22 | List<Player> ps = s.alivePlayers(); | 23 | printStats(s); |
23 | Board board = s.board(); | 24 | printBoard(s.board(), s.alivePlayers()); |
25 | } | ||
26 | |||
27 | private static void printStats(GameState s) { | ||
28 | System.out.println(s); | ||
29 | } | ||
24 | 30 | ||
31 | private static void printBoard(Board b, List<Player> ps) { | ||
25 | for (int y = 0; y < Cell.ROWS; ++y) { | 32 | for (int y = 0; y < Cell.ROWS; ++y) { |
26 | xLoop: | 33 | xLoop: |
27 | for (int x = 0; x < Cell.COLUMNS; ++x) { | 34 | for (int x = 0; x < Cell.COLUMNS; ++x) { |
@@ -32,8 +39,8 @@ public final class GameStatePrinter { | |||
32 | continue xLoop; | 39 | continue xLoop; |
33 | } | 40 | } |
34 | } | 41 | } |
35 | Block b = board.blockAt(c); | 42 | Block block = b.blockAt(c); |
36 | System.out.print(stringForBlock(b)); | 43 | System.out.print(stringForBlock(block)); |
37 | } | 44 | } |
38 | System.out.println(); | 45 | System.out.println(); |
39 | } | 46 | } |