diff --git a/src/main/java/pacmanGame/Player.java b/src/main/java/pacmanGame/Player.java index f84993c..b6bbbcb 100644 --- a/src/main/java/pacmanGame/Player.java +++ b/src/main/java/pacmanGame/Player.java @@ -32,8 +32,10 @@ public class Player { } public void processInput(char inputchar) { - - if(inputchar == 'w') { + if(inputchar == 'p') { + checkInput(new Vector2(0,0)); + } + else if(inputchar == 'w') { checkInput(new Vector2(0,1)); } diff --git a/src/test/java/pacmanTests/VisualizerPlainTextUltraTest.java b/src/test/java/pacmanTests/VisualizerPlainTextUltraTest.java new file mode 100644 index 0000000..e7e42e9 --- /dev/null +++ b/src/test/java/pacmanTests/VisualizerPlainTextUltraTest.java @@ -0,0 +1,70 @@ +package pacmanTests; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +import pacmanGame.*; + + +class VisualizerPlainTextUltraTest { + + @Test + void VisualizerPlainTextUtlra_mapCells_areVisualized() { + // arrange + String[] mapTest = { + "w.w", + "e.e", + "w.w" + }; + + GameManager gameManager = new GameManager(); + gameManager.map = new Map(mapTest, gameManager); + VisualizerPlainTextUltra vptu = new VisualizerPlainTextUltra(gameManager); + vptu.showScore = false; + + String expected = "" + + "|''| . |''|\n" + + "|__| |__|\n" + + " . \n" + + " \n" + + "|''| . |''|\n" + + "|__| |__|\n"; + // act + vptu.Update(); + String result = (String)vptu.GetOutput(); + // assert + assertThat(expected).isEqualTo(result); + } + + @Test + void VisualizerPlainTextUltra_ghosts_areVisualized() { + // arrange + String[] mapTest = { + "w.w", + "e.e", + "w.w" + }; + + GameManager gameManager = new GameManager(); + gameManager.map = new Map(mapTest, gameManager); + VisualizerPlainTextUltra vptu = new VisualizerPlainTextUltra(gameManager); + vptu.showScore = false; + + gameManager.ghosts[0].position = new Vector2(1, 1); + + String expected = "" + + "|''| . |''|\n" + + "|__| |__|\n" + + " /--\\ \n" + + " ~~~~ \n" + + "|''| . |''|\n" + + "|__| |__|\n"; + // act + vptu.Update(); + String result = (String)vptu.GetOutput(); + // assert + assertThat(expected).isEqualTo(result); + } +}