示例#1
0
 @Override
 public int hashCode() {
   int hs = p0_hand_.size();
   if (hs < 0) hs = 0;
   int res = hs + p0_minions_.size() * 10 + p1_minions_.size() * 100;
   res += (p0_mana_ <= 0 ? 0 : (p0_mana_ - 1) * 1000);
   res += ((p0_hero_.getHealth() + p1_hero_.getHealth()) % 100) * 10000;
   int th = 0;
   if (hs > 0) {
     Card cc = p0_hand_.get(0);
     try {
       Minion mm = (Minion) cc;
       th += (cc.hasBeenUsed() ? 1 : 0) + mm.getAttack() + mm.getHealth() + cc.getMana();
     } catch (ClassCastException e) {
       th += (cc.hasBeenUsed() ? 1 : 0) + cc.getMana();
     }
   }
   if (hs > 1) {
     Card cc = p0_hand_.get(1);
     try {
       Minion mm = (Minion) cc;
       th += (cc.hasBeenUsed() ? 1 : 0) + mm.getAttack() + mm.getHealth() + cc.getMana();
     } catch (ClassCastException e) {
       th += (cc.hasBeenUsed() ? 1 : 0) + cc.getMana();
     }
   }
   res += (th % 10) * 1000000;
   int mh0 = 0;
   if (p0_minions_.size() > 0) {
     mh0 += p0_minions_.get(0).getHealth();
   }
   if (p0_minions_.size() > 1) {
     mh0 += p0_minions_.get(1).getHealth();
   }
   res += (mh0 % 100) * 10000000;
   int mh1 = 0;
   if (p1_minions_.size() > 0) {
     mh1 += p1_minions_.get(0).getHealth();
   }
   if (p1_minions_.size() > 1) {
     mh1 += p1_minions_.get(1).getHealth();
   }
   res += (mh1 % 20) * 100000000;
   return res;
 }
示例#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;
  }
示例#3
0
 public Card getCard_hand_p0(int index) {
   return p0_hand_.get(index);
 }
示例#4
0
 public Card getCard_hand_p1(int index) {
   return p1_hand_.get(index);
 }
示例#5
0
 public Card getCard_hand(int playerIndex, int index) throws HSInvalidPlayerIndexException {
   if (playerIndex == 0) return p0_hand_.get(index);
   else if (playerIndex == 1) return p1_hand_.get(index);
   else throw new HSInvalidPlayerIndexException();
 }