Ejemplo n.º 1
0
  @Test(timeout = 10000)
  public void testPlayAny() throws InterruptedException, IOException {
    Predicate<ClientIO> opponentFilter = client -> client.getName().equals("AI Loser");
    server
        .getIncomingHandler()
        .perform(
            new StartGameRequest(-1, getTestMod()),
            server.getClients().values().stream().filter(opponentFilter).findAny().get());

    client1.send(new StartGameRequest(-1, getTestMod()));
    NewGameMessage gameMessage = client1.await(NewGameMessage.class);
    assertEquals(1, gameMessage.getGameId());
    ServerGame game = server.getGames().get(1);
    assertTrue(game.hasPlayer(server.getClients().get(userId)));
  }
Ejemplo n.º 2
0
 @Test(timeout = 50000)
 public void testStartGame() throws InterruptedException, IOException {
   client1.send(new StartGameRequest(2, getTestMod()));
   NewGameMessage gameMessage = client1.await(NewGameMessage.class);
   assertEquals(1, gameMessage.getGameId());
   client1.awaitUntil(PlayerConfigMessage.class);
   TCGGame game = (TCGGame) server.getGames().get(1);
   assertEquals(2, game.getGameModel().getEntitiesWithComponent(PlayerComponent.class).size());
   assertTrue(game.hasPlayer(server.getClients().get(userId)));
   assertTrue(game.hasPlayer(server.getClients().get(2)));
   game.incomingPlayerConfig(
       new PlayerConfigMessage(game.getId(), getTestMod(), new HashMap<>()),
       server.getClients().get(2));
   game.incomingPlayerConfig(
       new PlayerConfigMessage(game.getId(), getTestMod(), new HashMap<>()),
       server.getClients().get(userId));
   client1.awaitUntil(ResetAvailableActionsMessage.class);
   assertEquals(ECSGameState.RUNNING, game.getState());
 }