ReplayPlayerController implements PlayerController { @Override public void requestControl(Player player, Figure.Type type, int x, int y, TetrisJoystik joystick, List<Plot> plots, List<Figure.Type> futureFigures) throws IOException { new PlayerCommand(joystick, logFile.getCurrentResponse(), player).execute(); logger.debug("Executed player command: {}", logFile.getCurrentResponse()); } ReplayPlayerController(GameLogFile logFile); @Override void requestControl(Player player, Figure.Type type, int x, int y, TetrisJoystik joystick, List<Plot> plots, List<Figure.Type> futureFigures); @Override void registerPlayerTransport(Player player, TetrisJoystik joystick); @Override void unregisterPlayerTransport(Player player);  }
@Test public void shouldMoveJoystick() throws IOException, InterruptedException { logFile.log("some request", "left=1,right=2,rotate=3,drop"); logFile.readNextStep(); controller.requestControl(new Player("testUser", "REPLAY", null, null, null), Figure.Type.I, 123, 123, joystick, Collections.<Plot>emptyList(), Arrays.asList(Figure.Type.I)); assertEquals("left=1,right=2,rotate=3,drop", joystick.toString()); }
@Test public void shouldMoveJoystick2() throws IOException, InterruptedException { logFile.log("some request", "left=1,right=2,rotate=3,drop"); logFile.log("some request", "Left=3, Right=2, Rotate=1, Drop"); logFile.readNextStep(); logFile.readNextStep(); controller.requestControl(new Player("testUser", "REPLAY", null, null, null), Figure.Type.I, 123, 123, joystick, Collections.<Plot>emptyList(), Arrays.asList(Figure.Type.I, Figure.Type.J, Figure.Type.L, Figure.Type.O)); assertEquals("left=3,right=2,rotate=1,drop", joystick.toString()); }