From ec69aef186d8f2d91dfd7d0e5ac792cd9c0ea1c6 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 10 Apr 2016 10:50:52 +0200 Subject: Show when player is immobilized --- .../epfl/xblast/server/debug/GameStatePrinter.java | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/ch/epfl/xblast/server/debug/GameStatePrinter.java b/src/ch/epfl/xblast/server/debug/GameStatePrinter.java index 575b09a..33be70c 100644 --- a/src/ch/epfl/xblast/server/debug/GameStatePrinter.java +++ b/src/ch/epfl/xblast/server/debug/GameStatePrinter.java @@ -1,6 +1,7 @@ package ch.epfl.xblast.server.debug; import ch.epfl.xblast.Cell; +import ch.epfl.xblast.Direction; import ch.epfl.xblast.server.Block; import ch.epfl.xblast.server.GameState; import ch.epfl.xblast.server.Player; @@ -72,23 +73,25 @@ public final class GameStatePrinter { } private static String stringForPlayer(Player p) { - StringBuilder b = new StringBuilder(); - b.append(p.id().ordinal() + 1); - switch (p.direction()) { + return ANSIColor.CYAN.coloredText(String.format( + "%d%c", + p.id().ordinal() + 1, + p.lifeState().canMove() ? GameStatePrinter.charForDirection(p.direction()) : 'x')); + } + + private static char charForDirection(Direction d) { + switch (d) { case N: - b.append('^'); - break; + return '^'; case E: - b.append('>'); - break; + return '>'; case S: - b.append('v'); - break; + return 'v'; case W: - b.append('<'); - break; + return '<'; + default: + return ' '; } - return ANSIColor.CYAN.coloredText(b.toString()); } private static String stringForBlock(Block b) { -- cgit v1.2.3