Пример #1
0
  public void startTurn(Deck deckPlayer0, Deck deckPlayer1) throws HSException {
    this.resetHand();
    this.resetMinions();

    for (Minion targetMinion : p0_minions_) {
      try {
        targetMinion.startTurn(0, this, deckPlayer0, deckPlayer1);
      } catch (HSInvalidPlayerIndexException e) {
        e.printStackTrace();
      }
    }
    for (Minion targetMinion : p1_minions_) {
      try {
        targetMinion.startTurn(1, this, deckPlayer0, deckPlayer1);
      } catch (HSInvalidPlayerIndexException e) {
        e.printStackTrace();
      }
    }
    ArrayList<Minion> toRemove = new ArrayList<Minion>();
    for (Minion targetMinion : p0_minions_) {
      if (targetMinion.getTotalHealth() <= 0) toRemove.add(targetMinion);
    }
    for (Minion minion : toRemove) p0_minions_.remove(minion);

    toRemove.clear();
    for (Minion targetMinion : p1_minions_) {
      if (targetMinion.getTotalHealth() <= 0) toRemove.add(targetMinion);
    }
    for (Minion minion : toRemove) p1_minions_.remove(minion);
  }
Пример #2
0
  @Before
  public void setup() {
    board = new HearthTreeNode(new BoardState());

    Minion minion0_0 = new BoulderfistOgre();
    Minion minion0_1 = new RaidLeader();
    Minion minion1_0 = new BoulderfistOgre();
    Minion minion1_1 = new RaidLeader();
    Minion minion1_2 = new ScarletCrusader();

    board.data_.placeCard_hand_p0(minion0_0);
    board.data_.placeCard_hand_p0(minion0_1);

    board.data_.placeCard_hand_p1(minion1_0);
    board.data_.placeCard_hand_p1(minion1_1);
    board.data_.placeCard_hand_p1(minion1_2);

    Card cards[] = new Card[10];
    for (int index = 0; index < 10; ++index) {
      cards[index] = new TheCoin();
    }

    deck = new Deck(cards);

    Card fb = new ScarletCrusader();
    board.data_.placeCard_hand_p0(fb);

    board.data_.setMana_p0((byte) 8);
    board.data_.setMana_p1((byte) 8);

    board.data_.setMaxMana_p0((byte) 8);
    board.data_.setMaxMana_p1((byte) 8);

    HearthTreeNode tmpBoard = new HearthTreeNode(board.data_.flipPlayers());
    try {
      tmpBoard.data_.getCard_hand_p0(0).useOn(0, 0, 1, tmpBoard, deck, null);
      tmpBoard.data_.getCard_hand_p0(0).useOn(0, 0, 1, tmpBoard, deck, null);
      tmpBoard.data_.getCard_hand_p0(0).useOn(0, 0, 1, tmpBoard, deck, null);
    } catch (HSInvalidPlayerIndexException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    board = new HearthTreeNode(tmpBoard.data_.flipPlayers());
    try {
      board.data_.getCard_hand_p0(0).useOn(0, 0, 1, board, deck, null);
      board.data_.getCard_hand_p0(0).useOn(0, 0, 1, board, deck, null);
    } catch (HSInvalidPlayerIndexException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    board.data_.resetMana();
    board.data_.resetMinions();
  }
Пример #3
0
  @Test
  public void test2() throws HSException {

    Card theCard = board.data_.getCard_hand_p0(0);
    HearthTreeNode res;

    try {
      Minion target = board.data_.getCharacter(0, 1);
      res = theCard.useOn(0, target, board, null, null);
      assertFalse(res == null);
      assertTrue(res.data_.getMana_p0() == 2);
      assertTrue(res.data_.getNumCards_hand() == 0);
      assertTrue(res.data_.getMinion_p0(0).getHealth() == health0);
      assertTrue(res.data_.getMinion_p0(0).getTotalAttack() == attack0);
      assertTrue(res.data_.getMinion_p0(0).getMaxHealth() == health0);
      assertTrue(res.data_.getMinion_p0(0).getTaunt());
    } catch (HSInvalidPlayerIndexException e) {
      e.printStackTrace();
      assertTrue(false);
    }
  }
Пример #4
0
  @Test
  public void test0() throws HSException {

    Card theCard = board.data_.getCard_hand_p0(0);
    HearthTreeNode res;

    try {
      Minion target = board.data_.getCharacter(0, 0);
      res = theCard.useOn(0, target, board, null, null);
      assertTrue(res == null);
    } catch (HSInvalidPlayerIndexException e) {
      e.printStackTrace();
      assertTrue(false);
    }

    try {
      Minion target = board.data_.getCharacter(1, 0);
      res = theCard.useOn(1, target, board, null, null);
      assertTrue(res == null);
    } catch (HSInvalidPlayerIndexException e) {
      e.printStackTrace();
      assertTrue(false);
    }
  }