Esempio n. 1
0
  public BoardState flipPlayers() {
    BoardState newState = (BoardState) this.deepCopy();
    MinionList p0_minions = newState.getMinions_p0();
    MinionList p1_minions = newState.getMinions_p1();
    int p0_mana = newState.getMana_p0();
    int p1_mana = newState.getMana_p1();
    int p0_maxMana = newState.getMaxMana_p0();
    int p1_maxMana = newState.getMaxMana_p1();

    newState.p0_hero_ = p1_hero_;
    newState.p1_hero_ = p0_hero_;
    newState.setMinions_p0(p1_minions);
    newState.setMinions_p1(p0_minions);
    newState.setMana_p0(p1_mana);
    newState.setMana_p1(p0_mana);
    newState.setMaxMana_p0(p1_maxMana);
    newState.setMaxMana_p1(p0_maxMana);
    newState.p0_hand_ = p1_hand_;
    newState.p1_hand_ = p0_hand_;
    newState.p0_deckPos_ = p1_deckPos_;
    newState.p1_deckPos_ = p0_deckPos_;
    newState.p0_fatigueDamage_ = p1_fatigueDamage_;
    newState.p1_fatigueDamage_ = p0_fatigueDamage_;
    newState.p0_spellDamage_ = p1_spellDamage_;
    newState.p1_spellDamage_ = p0_spellDamage_;

    for (MinionPlayerIDPair minionIdPair : newState.allMinionsFIFOList_) {
      minionIdPair.playerIndex_ = minionIdPair.playerIndex_ == 0 ? 1 : 0;
    }
    return newState;
  }
Esempio n. 2
0
  public Object deepCopy() {
    BoardState newBoard = new BoardState();
    for (Iterator<Minion> iter = p0_minions_.iterator(); iter.hasNext(); ) {
      Minion tc = (Minion) (iter.next()).deepCopy();
      newBoard.p0_minions_.add(tc);
    }
    for (Iterator<Minion> iter = p1_minions_.iterator(); iter.hasNext(); ) {
      Minion tc = (Minion) (iter.next()).deepCopy();
      newBoard.p1_minions_.add(tc);
    }
    for (final Card card : p0_hand_) {
      Card tc = (Card) card.deepCopy();
      newBoard.placeCard_hand_p0(tc);
    }
    for (final Card card : p1_hand_) {
      Card tc = (Card) card.deepCopy();
      newBoard.placeCard_hand_p1(tc);
    }

    newBoard.setHero_p0((Hero) this.p0_hero_.deepCopy());
    newBoard.setHero_p1((Hero) this.p1_hero_.deepCopy());

    newBoard.p0_deckPos_ = this.p0_deckPos_;
    newBoard.p1_deckPos_ = this.p1_deckPos_;
    newBoard.p0_fatigueDamage_ = this.p0_fatigueDamage_;
    newBoard.p1_fatigueDamage_ = this.p1_fatigueDamage_;
    newBoard.p0_mana_ = this.p0_mana_;
    newBoard.p1_mana_ = this.p1_mana_;
    newBoard.p0_maxMana_ = this.p0_maxMana_;
    newBoard.p1_maxMana_ = this.p1_maxMana_;
    newBoard.p0_spellDamage_ = this.p0_spellDamage_;
    newBoard.p1_spellDamage_ = this.p1_spellDamage_;

    for (MinionPlayerIDPair minionIdPair : allMinionsFIFOList_) {
      if (minionIdPair.playerIndex_ == 0) {
        int minionIndex = p0_minions_.indexOf(minionIdPair.minion_);
        newBoard.allMinionsFIFOList_.add(
            new MinionPlayerIDPair(newBoard.p0_minions_.get(minionIndex), 0));
      } else if (minionIdPair.playerIndex_ == 1) {
        int minionIndex = p1_minions_.indexOf(minionIdPair.minion_);
        newBoard.allMinionsFIFOList_.add(
            new MinionPlayerIDPair(newBoard.p1_minions_.get(minionIndex), 1));
      }
    }
    return newBoard;
  }