Exemplo n.º 1
0
 protected Card drawFromDeck(int index) {
   Card card = deck.drawCard(index);
   if (card == null) {
     return null;
   }
   card.setInHand(true);
   return card;
 }
Exemplo n.º 2
0
 @Override
 public int hashCode() {
   int hash = 1;
   hash = hash * 31 + (null == name ? 0 : name.hashCode());
   hash = hash * 31 + playerId;
   hash = hash * 31 + (null == hero ? 0 : hero.hashCode());
   hash = hash * 31 + (null == deck ? 0 : deck.hashCode());
   hash = hash * 31 + mana;
   hash = hash * 31 + maxMana;
   hash = hash * 31 + deckPos;
   hash = hash * 31 + fatigueDamage;
   hash = hash * 31 + (null == minions ? 0 : minions.hashCode());
   hash = hash * 31 + (null == hand ? 0 : hand.hashCode());
   hash = hash * 31 + overload;
   hash = hash * 31 + numCardsUsed;
   return hash;
 }
Exemplo n.º 3
0
 /**
  * Draw a card from a deck and place it in the hand
  *
  * <p>This function is intentionally only implemented for Player1. For Player0, it is almost
  * always correct to user CardDrawNode instead.
  *
  * @param deck Deck from which to draw.
  * @param numCards Number of cards to draw.
  * @throws HSInvalidPlayerIndexException
  */
 public void drawCardFromDeck_p1(Deck deck, int numCards) throws HSInvalidPlayerIndexException {
   // This minion is an enemy minion.  Let's draw a card for the enemy.  No need to use a StopNode
   // for enemy card draws.
   for (int indx = 0; indx < numCards; ++indx) {
     Card card = deck.drawCard(this.getDeckPos(1));
     if (card == null) {
       byte fatigueDamage = this.getFatigueDamage(1);
       this.setFatigueDamage(1, (byte) (fatigueDamage + 1));
       this.getHero(1).setHealth((byte) (this.getHero(1).getHealth() - fatigueDamage));
     } else {
       if (this.getNumCards_hand_p1() < 10) {
         this.placeCard_hand(1, card);
       }
       this.setDeckPos(1, this.getDeckPos(1) + 1);
     }
   }
 }
Exemplo n.º 4
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.º 5
0
 public void placeCardDeck(Card card) {
   deck.addCard(card);
 }