aboutsummaryrefslogtreecommitdiff
path: root/src/ch
diff options
context:
space:
mode:
Diffstat (limited to 'src/ch')
-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) {