From 552d82f34ee4b60785164bc40d6dd5b5d8923609 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sat, 26 Mar 2016 13:44:46 +0100 Subject: Implement random event live simulation --- src/ch/epfl/xblast/server/GameState.java | 12 ++++++++++++ src/ch/epfl/xblast/server/Player.java | 11 +++++++++++ src/ch/epfl/xblast/server/debug/GameStatePrinter.java | 15 +++++++++++---- 3 files changed, 34 insertions(+), 4 deletions(-) (limited to 'src') 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 { .collect(Collectors.toList()); } + @Override + public String toString() { + return "GameState{" + + "ticks=" + ticks + + ", board=" + board + + ", players=" + players + + ", bombs=" + bombs + + ", explosions=" + explosions + + ", blasts=" + blasts + + '}'; + } + } 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 { return new Bomb(this.id(), this.position().containingCell(), Ticks.BOMB_FUSE_TICKS, this.bombRange()); } + @Override + public String toString() { + return "Player{" + + "id=" + id + + ", lifeStates=" + lifeStates + + ", directedPos=" + directedPos + + ", maxBombs=" + maxBombs + + ", bombRange=" + bombRange + + '}'; + } + } 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; * Game state printer utility class that outputs the board to the terminal. * * @author EPFL + * @author Pacien TRAN-GIRARD (261948) */ public final class GameStatePrinter { @@ -19,9 +20,15 @@ public final class GameStatePrinter { } public static void printGameState(GameState s) { - List ps = s.alivePlayers(); - Board board = s.board(); + printStats(s); + printBoard(s.board(), s.alivePlayers()); + } + + private static void printStats(GameState s) { + System.out.println(s); + } + private static void printBoard(Board b, List ps) { for (int y = 0; y < Cell.ROWS; ++y) { xLoop: for (int x = 0; x < Cell.COLUMNS; ++x) { @@ -32,8 +39,8 @@ public final class GameStatePrinter { continue xLoop; } } - Block b = board.blockAt(c); - System.out.print(stringForBlock(b)); + Block block = b.blockAt(c); + System.out.print(stringForBlock(block)); } System.out.println(); } -- cgit v1.2.3