コード例 #1
0
  @Test
  public void testPerformAction() {
    context.setDecisionDelegate(
        new TestDecisionDelegate() {
          int count = 0;

          @Override
          public int decideCardInHand(GameContext context, String question, boolean canIgnore) {
            if (count == 4) {

              return GameContext.DecisionDelegate.CARD_IN_HAND_IGNORED;
            } else {
              count++;
              return 0;
            }
          }
        });
    context.getPlayer().getPlayerDeck().drawNumAndDiscardOldHand(5);
    List<Card> hand = context.getPlayer().getPlayerDeck().getHand();
    int handSize = hand.size();
    assertEquals(handSize, 5);

    Card chapel = Card.makeCard(Card.CARD_NAME_CHAPEL);
    chapel.performAction(context);

    assertEquals(1, hand.size());
  }
コード例 #2
0
  public TestGameEnvironment() {
    player = new Player("Test Player");
    opponent = new Player("Test Opponent");
    List<Card> cards =
        Arrays.asList(
            new Card[] {
              Card.makeCard(Card.CARD_NAME_FESTIVAL),
              Card.makeCard(Card.CARD_NAME_LABORATORY),
              Card.makeCard(Card.CARD_NAME_MARKET),
              Card.makeCard(Card.CARD_NAME_SMITHY),
              Card.makeCard(Card.CARD_NAME_VILLAGE),
              Card.makeCard(Card.CARD_NAME_WOODCUTTER)
            });
    supplyDeck = new SupplyDeck(cards);

    turnController = new TurnController(player, opponent, supplyDeck, null);
    context = new GameContext(turnController);
  }
コード例 #3
0
  @Override
  protected void setUp() {
    player = new Player("Test Player");

    List<Card> cards =
        Arrays.asList(
            new Card[] {
              Card.makeCard(Card.CARD_NAME_FESTIVAL),
              Card.makeCard(Card.CARD_NAME_LABORATORY),
              Card.makeCard(Card.CARD_NAME_MARKET),
              Card.makeCard(Card.CARD_NAME_SMITHY),
              Card.makeCard(Card.CARD_NAME_VILLAGE),
              Card.makeCard(Card.CARD_NAME_WOODCUTTER)
            });

    supplyDeck = new SupplyDeck(cards);
    controller = new TurnController(player, null, supplyDeck, null);
    context = new GameContext(controller);
  }