Exemplo n.º 1
0
  @Override
  public boolean equals(Object other) {

    if (other == null) return false;

    if (this.getClass() != other.getClass()) return false;

    PlayerModel otherPlayer = (PlayerModel) other;

    if (playerId != otherPlayer.playerId) return false;
    if (mana != otherPlayer.mana) return false;
    if (maxMana != otherPlayer.maxMana) return false;
    if (overload != otherPlayer.overload) return false;
    if (deckPos != otherPlayer.deckPos) return false;
    if (fatigueDamage != otherPlayer.fatigueDamage) return false;

    if (!name.equals(otherPlayer.name)) return false;
    if (!hero.equals(otherPlayer.hero)) return false;
    if (deck != null && !deck.equals(otherPlayer.deck)) return false;
    if (!minions.equals(otherPlayer.minions)) return false;
    if (!hand.equals(otherPlayer.hand)) return false;
    if (numCardsUsed != otherPlayer.numCardsUsed) return false;
    return true;
  }
Exemplo n.º 2
0
  public boolean equals(Object other) {
    if (other == null) {
      return false;
    }

    if (this.getClass() != other.getClass()) {
      return false;
    }

    if (p0_mana_ != ((BoardState) other).p0_mana_) return false;
    if (p1_mana_ != ((BoardState) other).p1_mana_) return false;
    if (p0_maxMana_ != ((BoardState) other).p0_maxMana_) return false;
    if (p1_maxMana_ != ((BoardState) other).p1_maxMana_) return false;

    if (!p0_hero_.equals(((BoardState) other).p0_hero_)) {
      return false;
    }

    if (!p1_hero_.equals(((BoardState) other).p1_hero_)) {
      return false;
    }

    if (p0_deckPos_ != ((BoardState) other).p0_deckPos_) return false;

    if (p1_deckPos_ != ((BoardState) other).p1_deckPos_) return false;

    if (p0_fatigueDamage_ != ((BoardState) other).p0_fatigueDamage_) return false;

    if (p1_fatigueDamage_ != ((BoardState) other).p1_fatigueDamage_) return false;

    if (p0_spellDamage_ != ((BoardState) other).p0_spellDamage_) return false;

    if (p1_spellDamage_ != ((BoardState) other).p1_spellDamage_) return false;

    if (p0_minions_.size() != ((BoardState) other).p0_minions_.size()) return false;
    if (p1_minions_.size() != ((BoardState) other).p1_minions_.size()) return false;
    if (p0_hand_.size() != ((BoardState) other).p0_hand_.size()) return false;

    for (int i = 0; i < p0_minions_.size(); ++i) {
      if (!p0_minions_.get(i).equals(((BoardState) other).p0_minions_.get(i))) {
        return false;
      }
    }

    for (int i = 0; i < p1_minions_.size(); ++i) {
      if (!p1_minions_.get(i).equals(((BoardState) other).p1_minions_.get(i))) {
        return false;
      }
    }

    for (int i = 0; i < p0_hand_.size(); ++i) {
      if (!p0_hand_.get(i).equals(((BoardState) other).p0_hand_.get(i))) {
        return false;
      }
    }

    for (int i = 0; i < p1_hand_.size(); ++i) {
      if (!p1_hand_.get(i).equals(((BoardState) other).p1_hand_.get(i))) {
        return false;
      }
    }

    // More logic here to be discuss below...
    return true;
  }