aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2016-04-10 10:50:52 +0200
committerPacien TRAN-GIRARD2016-04-10 10:50:52 +0200
commitec69aef186d8f2d91dfd7d0e5ac792cd9c0ea1c6 (patch)
tree3d3932fe9ce8df8986c4b54bcea5102789d1109e
parent60366705c2e296f4b2db6664c3a6cb421976d294 (diff)
downloadxblast-ec69aef186d8f2d91dfd7d0e5ac792cd9c0ea1c6.tar.gz
Show when player is immobilized
-rw-r--r--src/ch/epfl/xblast/server/debug/GameStatePrinter.java27
1 files changed, 15 insertions, 12 deletions
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 @@
1package ch.epfl.xblast.server.debug; 1package ch.epfl.xblast.server.debug;
2 2
3import ch.epfl.xblast.Cell; 3import ch.epfl.xblast.Cell;
4import ch.epfl.xblast.Direction;
4import ch.epfl.xblast.server.Block; 5import ch.epfl.xblast.server.Block;
5import ch.epfl.xblast.server.GameState; 6import ch.epfl.xblast.server.GameState;
6import ch.epfl.xblast.server.Player; 7import ch.epfl.xblast.server.Player;
@@ -72,23 +73,25 @@ public final class GameStatePrinter {
72 } 73 }
73 74
74 private static String stringForPlayer(Player p) { 75 private static String stringForPlayer(Player p) {
75 StringBuilder b = new StringBuilder(); 76 return ANSIColor.CYAN.coloredText(String.format(
76 b.append(p.id().ordinal() + 1); 77 "%d%c",
77 switch (p.direction()) { 78 p.id().ordinal() + 1,
79 p.lifeState().canMove() ? GameStatePrinter.charForDirection(p.direction()) : 'x'));
80 }
81
82 private static char charForDirection(Direction d) {
83 switch (d) {
78 case N: 84 case N:
79 b.append('^'); 85 return '^';
80 break;
81 case E: 86 case E:
82 b.append('>'); 87 return '>';
83 break;
84 case S: 88 case S:
85 b.append('v'); 89 return 'v';
86 break;
87 case W: 90 case W:
88 b.append('<'); 91 return '<';
89 break; 92 default:
93 return ' ';
90 } 94 }
91 return ANSIColor.CYAN.coloredText(b.toString());
92 } 95 }
93 96
94 private static String stringForBlock(Block b) { 97 private static String stringForBlock(Block b) {