コード例 #1
0
  @Test
  public void testManantialesCheckConstriantsRelieved() throws InvalidMoveException, JMSException {
    ManantialesFicha ficha =
        new ManantialesFicha(4, 3, alice.getColor(), TokenType.MODERATE_PASTURE);
    ManantialesFicha ficha2 =
        new ManantialesFicha(4, 5, bob.getColor(), TokenType.MODERATE_PASTURE);
    ManantialesFicha ficha3 =
        new ManantialesFicha(3, 4, charlie.getColor(), TokenType.MODERATE_PASTURE);
    ManantialesFicha relief =
        new ManantialesFicha(4, 3, alice.getColor(), TokenType.MANAGED_FOREST);
    ManantialesFicha retrigger =
        new ManantialesFicha(4, 3, alice.getColor(), TokenType.MODERATE_PASTURE);
    ManantialesFicha terminate =
        new ManantialesFicha(5, 5, denise.getColor(), TokenType.MODERATE_PASTURE);
    SetIds(ficha, ficha2, ficha3, retrigger, terminate);
    ManantialesMove move = new ManantialesMove(alice, ficha);
    move.setMode(game.getMode());
    Move mv = game.move(move);
    assertEquals(MoveStatus.EVALUATED, mv.getStatus());
    bob.setTurn(true);
    move = new ManantialesMove(bob, ficha2);
    mv = game.move(move);
    assertEquals(MoveStatus.EVALUATED, mv.getStatus());
    charlie.setTurn(true);
    move = new ManantialesMove(charlie, ficha3);
    mv = game.move(move);
    assertEquals(MoveStatus.EVALUATED, mv.getStatus());
    List filtered = filterForEvent(GameEvent.CONDITION_RAISED);
    assertTrue(filtered.size() == 1);
    alice.setTurn(true);
    move = new ManantialesMove(alice, ficha, relief);
    game.move(move);
    filtered = filterForEvent(GameEvent.CONDITION_RESOLVED);
    assertTrue("Actual size of filtered (expected 1): " + filtered.size(), filtered.size() == 1);
    filtered = filterForEvent(GameEvent.CONDITION_TRIGGERED);
    assertTrue(filtered.size() == 0);

    /* retrigger condition */
    alice.setTurn(true);
    move = new ManantialesMove(alice, relief, retrigger);
    game.move(move);
    filtered = filterForEvent(GameEvent.CONDITION_RAISED);
    assertTrue("filter size is: " + filtered.size(), filtered.size() == 2);
    /* allow condition to terminate game, i.e., TRIGGER */
    denise.setTurn(true);
    move = new ManantialesMove(denise, terminate);
    game.move(move);
    filtered = filterForEvent(GameEvent.CONDITION_TRIGGERED);
    assertTrue(filtered.size() == 1);
    assertTrue(game.getState().equals(GameState.ENDED));
  }
コード例 #2
0
 /**
  * Test on ManantialesGame for setting check constraints
  *
  * @throws InvalidMoveException
  */
 @Test
 public void testManantialCheckConstraints() throws InvalidMoveException {
   ManantialesFicha ficha =
       new ManantialesFicha(4, 3, alice.getColor(), TokenType.MODERATE_PASTURE);
   ManantialesFicha ficha2 =
       new ManantialesFicha(4, 5, bob.getColor(), TokenType.MODERATE_PASTURE);
   ManantialesFicha ficha3 =
       new ManantialesFicha(3, 4, charlie.getColor(), TokenType.MODERATE_PASTURE);
   SetIds(ficha, ficha2, ficha3);
   ManantialesMove move = new ManantialesMove(alice, ficha);
   move.setMode(game.getMode());
   Move mv = game.move(move);
   assertEquals(MoveStatus.EVALUATED, mv.getStatus());
   bob.setTurn(true);
   move = new ManantialesMove(bob, ficha2);
   mv = game.move(move);
   assertEquals(MoveStatus.EVALUATED, mv.getStatus());
   charlie.setTurn(true);
   move = new ManantialesMove(charlie, ficha3);
   mv = game.move(move);
   assertEquals(MoveStatus.EVALUATED, mv.getStatus());
   assertEquals(1, game.getCheckConditions().size());
 }