From 59d35ae34c4513f54decf056e944190d7e9926f0 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Tue, 15 Mar 2016 13:44:43 +0100 Subject: Reformat provided classes --- .../epfl/xblast/server/debug/GameStatePrinter.java | 56 +++++++++++++++------- 1 file changed, 40 insertions(+), 16 deletions(-) (limited to 'src/ch/epfl') diff --git a/src/ch/epfl/xblast/server/debug/GameStatePrinter.java b/src/ch/epfl/xblast/server/debug/GameStatePrinter.java index 240446b..ea8b360 100644 --- a/src/ch/epfl/xblast/server/debug/GameStatePrinter.java +++ b/src/ch/epfl/xblast/server/debug/GameStatePrinter.java @@ -1,24 +1,32 @@ package ch.epfl.xblast.server.debug; -import java.util.List; - import ch.epfl.xblast.Cell; import ch.epfl.xblast.server.Block; import ch.epfl.xblast.server.Board; import ch.epfl.xblast.server.GameState; import ch.epfl.xblast.server.Player; +import java.util.List; + +/** + * Game state printer utility class that outputs the board to the terminal. + * + * @author EPFL + */ public final class GameStatePrinter { - private GameStatePrinter() {} + + private GameStatePrinter() { + } public static void printGameState(GameState s) { List ps = s.alivePlayers(); Board board = s.board(); for (int y = 0; y < Cell.ROWS; ++y) { - xLoop: for (int x = 0; x < Cell.COLUMNS; ++x) { + xLoop: + for (int x = 0; x < Cell.COLUMNS; ++x) { Cell c = new Cell(x, y); - for (Player p: ps) { + for (Player p : ps) { if (p.position().containingCell().equals(c)) { System.out.print(stringForPlayer(p)); continue xLoop; @@ -35,23 +43,39 @@ public final class GameStatePrinter { StringBuilder b = new StringBuilder(); b.append(p.id().ordinal() + 1); switch (p.direction()) { - case N: b.append('^'); break; - case E: b.append('>'); break; - case S: b.append('v'); break; - case W: b.append('<'); break; + case N: + b.append('^'); + break; + case E: + b.append('>'); + break; + case S: + b.append('v'); + break; + case W: + b.append('<'); + break; } return b.toString(); } private static String stringForBlock(Block b) { switch (b) { - case FREE: return " "; - case INDESTRUCTIBLE_WALL: return "##"; - case DESTRUCTIBLE_WALL: return "??"; - case CRUMBLING_WALL: return "¿¿"; - case BONUS_BOMB: return "+b"; - case BONUS_RANGE: return "+r"; - default: throw new Error(); + case FREE: + return " "; + case INDESTRUCTIBLE_WALL: + return "##"; + case DESTRUCTIBLE_WALL: + return "??"; + case CRUMBLING_WALL: + return "¿¿"; + case BONUS_BOMB: + return "+b"; + case BONUS_RANGE: + return "+r"; + default: + throw new Error(); } } + } -- cgit v1.2.3