Browse Source

fixed test for VisualizerPlainText

remotes/origin/player
fdai7910 11 months ago
parent
commit
bd9559e5d0
  1. 7
      src/main/java/pacmanGame/VisualizerPlainText.java
  2. 2
      src/test/java/pacmanTests/VisualizerPlainTextTest.java

7
src/main/java/pacmanGame/VisualizerPlainText.java

@ -6,6 +6,7 @@ public class VisualizerPlainText implements Visualizer {
private String output; private String output;
public final GameManager gameManager; public final GameManager gameManager;
public boolean showScore = true;
public HashMap<String, String> sprites = new HashMap<String,String>(){{ public HashMap<String, String> sprites = new HashMap<String,String>(){{
this.put("empty", " "); this.put("empty", " ");
@ -28,7 +29,13 @@ public class VisualizerPlainText implements Visualizer {
@Override @Override
public void Update() { public void Update() {
if(showScore) {
output = "Score: " + gameManager.score + "\n"; output = "Score: " + gameManager.score + "\n";
}
else {
output = "";
}
Map map = gameManager.map; Map map = gameManager.map;
for(int y = 0; y < map.size.y; y++) { for(int y = 0; y < map.size.y; y++) {

2
src/test/java/pacmanTests/VisualizerPlainTextTest.java

@ -22,6 +22,7 @@ class VisualizerPlainTextTest {
GameManager gameManager = new GameManager(); GameManager gameManager = new GameManager();
gameManager.map = new Map(mapTest, gameManager); gameManager.map = new Map(mapTest, gameManager);
VisualizerPlainText vpt = new VisualizerPlainText(gameManager); VisualizerPlainText vpt = new VisualizerPlainText(gameManager);
vpt.showScore = false;
String expected = "" String expected = ""
+ "[]. []\n" + "[]. []\n"
@ -46,6 +47,7 @@ class VisualizerPlainTextTest {
GameManager gameManager = new GameManager(); GameManager gameManager = new GameManager();
gameManager.map = new Map(mapTest, gameManager); gameManager.map = new Map(mapTest, gameManager);
VisualizerPlainText vpt = new VisualizerPlainText(gameManager); VisualizerPlainText vpt = new VisualizerPlainText(gameManager);
vpt.showScore = false;
gameManager.ghosts[0].position = new Vector2(1, 1); gameManager.ghosts[0].position = new Vector2(1, 1);

Loading…
Cancel
Save