Exemplo n.º 1
0
  public ArrayList<Minion> getMinionsAdjacentToCharacter(CharacterIndex characterIndex) {
    ArrayList<Minion> adjMinions = new ArrayList<>();

    if (characterIndex.getInt() >= this.getNumCharacters()) {
      return adjMinions;
    }

    if (characterIndex.getInt() > 1) {
      CharacterIndex leftIndex = CharacterIndex.fromInteger(characterIndex.getInt() - 1);
      adjMinions.add(this.getCharacter(leftIndex));
    }
    if (characterIndex.getInt() < (this.getNumCharacters() - 1)) {
      CharacterIndex rightIndex = CharacterIndex.fromInteger(characterIndex.getInt() + 1);
      adjMinions.add(this.getCharacter(rightIndex));
    }
    return adjMinions;
  }
Exemplo n.º 2
0
 public CharacterIndex getIndexForCharacter(Minion character) {
   if (this.hero.equals(character)) {
     return CharacterIndex.HERO;
   } else {
     int minionIndex = this.minions.indexOf(character);
     return minionIndex >= 0
         ? CharacterIndex.fromInteger(this.minions.indexOf(character) + 1)
         : CharacterIndex.UNKNOWN;
   }
 }
Exemplo n.º 3
0
 @Override
 public Minion next() {
   return this.target.getCharacter(CharacterIndex.fromInteger(++location));
 }
Exemplo n.º 4
0
 // used by the BoardModel master iterator
 public CharacterIndex getLocation() {
   return CharacterIndex.fromInteger(location);
 }
Exemplo n.º 5
0
  // TODO Unused?
  public HearthTreeNode perform(HearthTreeNode boardState) throws HSException {
    HearthTreeNode toRet = boardState;
    PlayerModel actingPlayer =
        actionPerformerPlayerSide != null
            ? boardState.data_.modelForSide(actionPerformerPlayerSide)
            : null;
    PlayerModel targetPlayer =
        targetPlayerSide != null ? boardState.data_.modelForSide(targetPlayerSide) : null;

    switch (verb_) {
      case USE_CARD:
        {
          Card card = actingPlayer.getHand().get(cardOrCharacterIndex_);
          toRet = card.useOn(targetPlayerSide, targetCharacterIndex, toRet);
        }
        break;
      case HERO_ABILITY:
        {
          Hero hero = actingPlayer.getHero();
          Minion target = targetPlayer.getCharacter(targetCharacterIndex);
          toRet = hero.useHeroAbility(targetPlayerSide, target, toRet);
        }
        break;
      case ATTACK:
        {
          Minion attacker =
              actingPlayer.getCharacter(CharacterIndex.fromInteger(cardOrCharacterIndex_));
          toRet = attacker.attack(targetPlayerSide, targetCharacterIndex, toRet);
        }
        break;
      case UNTARGETABLE_BATTLECRY:
        {
          Minion minion =
              actingPlayer.getCharacter(CharacterIndex.fromInteger(cardOrCharacterIndex_));
          toRet = minion.useUntargetableBattlecry(targetCharacterIndex, toRet);
          break;
        }
      case TARGETABLE_BATTLECRY:
        {
          Minion minion =
              actingPlayer.getCharacter(CharacterIndex.fromInteger(cardOrCharacterIndex_));
          toRet = minion.useTargetableBattlecry(targetPlayerSide, targetCharacterIndex, toRet);
          break;
        }
      case START_TURN:
        {
          toRet = new HearthTreeNode(Game.beginTurn(boardState.data_.deepCopy()));
          break;
        }
      case END_TURN:
        {
          toRet = new HearthTreeNode(Game.endTurn(boardState.data_.deepCopy()).flipPlayers());
          break;
        }
      case DO_NOT_USE_CARD:
        {
          for (Card c : actingPlayer.getHand()) {
            c.hasBeenUsed(true);
          }
          break;
        }
      case DO_NOT_ATTACK:
        {
          for (Minion minion : actingPlayer.getMinions()) {
            minion.hasAttacked(true);
          }
          actingPlayer.getHero().hasAttacked(true);
          break;
        }
      case DO_NOT_USE_HEROPOWER:
        {
          actingPlayer.getHero().hasBeenUsed(true);
          break;
        }
      case RNG:
        {
          // We need to perform the current state again if the children don't exist yet. This can
          // happen in certain replay scenarios.
          // Do not do this if the previous action was *also* RNG or we will end up in an infinite
          // loop.
          if (toRet.isLeaf() && boardState.getAction().verb_ != Verb.RNG) {
            boardState.data_.getCurrentPlayer().addNumCardsUsed((byte) -1); // do not double count
            toRet = boardState.getAction().perform(boardState);
          }
          // RNG has declared this child happened
          toRet = toRet.getChildren().get(cardOrCharacterIndex_);
          break;
        }
      case DRAW_CARDS:
        {
          // Note, this action only supports drawing cards from the deck. Cards like Ysera or
          // Webspinner need to be implemented using RNG children.
          for (int indx = 0; indx < cardOrCharacterIndex_; ++indx) {
            actingPlayer.drawNextCardFromDeck();
          }
          break;
        }
    }
    return toRet;
  }