public boolean attemptCardPurchaseWithinCardList(ArrayList<Card> s, Point p) { for (Card c : s) { if (c.getLocation().contains(p)) { if (c.getType() == Card.Type.Monster) { if (this.turnState == TurnState.FreeCard) { executeCard(c); this.game.gameDeck.hand.remove(c); if (!c.getName().equals("Cultist")) { this.game.gameDeck.discard.add(c); this.game.gameDeck.drawCard(); if (this.VoidthirsterState) { this.player.incrementHonor(1); this.game.decrementHonor(1); this.VoidthirsterState = false; } } } else if (this.monsterPower > 0 && c.getCost() <= this.power + this.monsterPower) { for (int i = 0; i < c.getCost(); i++) { if (this.monsterPower > 0) { this.monsterPower--; } else { this.power--; } } } else if (c.getCost() <= this.power) { this.power -= c.getCost(); executeCard(c); this.game.gameDeck.hand.remove(c); if (!c.getName().equals("Cultist")) { this.game.gameDeck.discard.add(c); this.game.gameDeck.drawCard(); if (this.VoidthirsterState) { this.player.incrementHonor(1); this.game.decrementHonor(1); this.VoidthirsterState = false; } } if (this.VoidMesmerState) { this.turnState = TurnState.VoidMesmerState; this.turnStateMagnitude = c.getCost(); } } } else { if (this.turnState == TurnState.FreeCard) { this.game.gameDeck.hand.remove(c); if (this.testForMechana(c) && c.getType() == Card.Type.Construct && this.RocketCourierState > 0) { this.handleRocketCourier(c); } else { HeroTopOfDeckState = this.player.playerDeck.addNewCardToDiscard(c, HeroTopOfDeckState); } this.game.gameDeck.drawCard(); } else if (c.getType() == Card.Type.Construct && this.testForMechana(c) && c.getCost() <= (this.rune + this.constructRune + this.mechanaConstructRune)) { for (int i = 0; i < c.getCost(); i++) { if (this.mechanaConstructRune > 0) { this.mechanaConstructRune--; } else if (this.constructRune > 0) { this.constructRune--; } else { this.rune--; } } if (this.RocketCourierState > 0) { this.handleRocketCourier(c); } else { HeroTopOfDeckState = this.player.playerDeck.addNewCardToDiscard(new Card(c), HeroTopOfDeckState); } if (this.game.gameDeck.hand.contains(c)) { this.game.gameDeck.hand.remove(c); this.game.gameDeck.drawCard(); } } else if (c.getType() == Card.Type.Construct && c.getCost() <= (this.rune + this.constructRune)) { for (int i = 0; i < c.getCost(); i++) { if (this.constructRune > 0) { this.constructRune--; } else { this.rune--; } } if (this.testForMechana(c) && this.RocketCourierState > 0) { this.handleRocketCourier(c); } else { HeroTopOfDeckState = this.player.playerDeck.addNewCardToDiscard(new Card(c), HeroTopOfDeckState); } if (this.game.gameDeck.hand.contains(c)) { this.game.gameDeck.hand.remove(c); this.game.gameDeck.drawCard(); } } else if (this.AiyanaState && c.getType() == Card.Type.Hero && c.getHonorWorth() <= this.rune) { this.rune -= c.getHonorWorth(); HeroTopOfDeckState = this.player.playerDeck.addNewCardToDiscard(new Card(c), HeroTopOfDeckState); if (this.game.gameDeck.hand.contains(c)) { this.game.gameDeck.hand.remove(c); this.game.gameDeck.drawCard(); } } else if (this.heroRune > 0 && c.getType() == Card.Type.Hero && c.getCost() < this.rune + this.heroRune) { for (int i = 0; i < c.getCost(); i++) { if (this.heroRune > 0) { this.heroRune--; } else { this.rune--; } } HeroTopOfDeckState = this.player.playerDeck.addNewCardToDiscard(new Card(c), HeroTopOfDeckState); if (this.game.gameDeck.hand.contains(c)) { this.game.gameDeck.hand.remove(c); this.game.gameDeck.drawCard(); } } else if (c.getCost() <= this.rune) { this.rune -= c.getCost(); if (this.testForMechana(c) && c.getType() == Card.Type.Construct && this.RocketCourierState > 0) { this.handleRocketCourier(c); } else { HeroTopOfDeckState = this.player.playerDeck.addNewCardToDiscard(new Card(c), HeroTopOfDeckState); } if (this.game.gameDeck.hand.contains(c)) { this.game.gameDeck.hand.remove(c); this.game.gameDeck.drawCard(); } } } return true; } } return false; }
public synchronized void leftButtonClick(Point loc) { if (this.game.discardFrame.isVisible()) { handleDiscard(loc); return; } Rectangle end = new Rectangle(1460, 492, 91, 91); if (end.contains(loc)) { this.player.playerDeck.endTurn(); this.game.nextTurn(); return; } Rectangle discard = new Rectangle(1431, 692, 142, 108); if (discard.contains(loc)) { this.game.discardFrame.setVisible(true); return; } switch (turnState) { case Default: Rectangle playAllCardsInHand = new Rectangle(47, 493, 83, 100); if (playAllCardsInHand.contains(loc)) { playAll(); } Card c = this.player.playerDeck.handleClick(loc); this.game.repaint(); if (c != null) { executeCard(c); return; } if (attemptCardPurchaseWithinCardList(this.game.gameDeck.constructs, loc)) { return; } if (attemptCardPurchaseWithinCardList(this.game.gameDeck.hand, loc)) { return; } c = this.player.playerDeck.activateConstruct(loc); if (c != null) { if (!c.constructPlayed) { executeCard(c); c.constructPlayed = true; return; } return; } break; case Discard: if (this.player.playerDeck.attemptDiscard(loc) != null) { decrementTurnStateMagnitude(); } break; case AskaraDiscard: Card askaraDiscardCard = this.player.playerDeck.attemptDiscard(loc); if (askaraDiscardCard != null) { decrementTurnStateMagnitude(); if (askaraDiscardCard.getFaction() == Card.Faction.Enlightened && this.turnStateMagnitude > 0) { decrementTurnStateMagnitude(); } } break; case DeckBanish: Card banished = this.player.playerDeck.attemptDeckHandBanish(loc); if (banished != null) { decrementTurnStateMagnitude(); this.game.gameDeck.discard.add(banished); } break; case CenterBanish: if (this.game.gameDeck.attemptCenterBanish(loc)) { decrementTurnStateMagnitude(); } break; case AskaraCenterBanish: Card c1 = this.game.gameDeck.attemptAskaraCenterBanish(loc); if (c1 != null) { if (c1.getType() == Card.Type.Monster) { this.player.incrementHonor(3); this.game.decrementHonor(3); } decrementTurnStateMagnitude(); } break; case DefeatMonster: Card defeatedMonster = this.game.gameDeck.attemptDefeatMonster(loc, this.turnStateMagnitude); if (defeatedMonster != null) { executeCard(defeatedMonster); exitActiveWaitingState(); } break; case VoidMesmerState: Card aquHero = this.game.gameDeck.attemptGetHero(loc, this.turnStateMagnitude); if (aquHero != null) { executeCard(aquHero); exitActiveWaitingState(); } break; case FreeCard: if (attemptCardPurchaseWithinCardList(this.game.gameDeck.hand, loc)) { decrementTurnStateMagnitude(); } break; case FreeCardHero: Card e = this.game.gameDeck.getHeroFromCenter(loc); if (e != null) { this.game.gameDeck.hand.remove(e); this.game.gameDeck.drawCard(); HeroTopOfDeckState = this.player.playerDeck.addNewCardToDiscard(e, HeroTopOfDeckState); this.turnState = Turn.TurnState.Default; } break; case HandBanish: Card b = this.player.playerDeck.attemptDeckHandBanish(loc); if (b != null) { decrementTurnStateMagnitude(); this.game.gameDeck.discard.add(b); } break; case TwofoldAskara: Card d = this.player.playerDeck.getCardFromPlayed(loc); if (d != null) { this.executeCard(d); exitActiveWaitingState(); } break; case RajTurnState: Card cardForRajTurnState = this.player.playerDeck.attemptDeckHandBanish(loc); System.out.println(cardForRajTurnState); if (cardForRajTurnState != null) { this.turnStateMagnitude = cardForRajTurnState.getHonorWorth() + 2; this.turnState = Turn.TurnState.RajTurnState2; } break; case RajTurnState2: Card cardForRajTurnState2ToAcquire = this.game.gameDeck.attemptRajEffect(loc, this.turnStateMagnitude); if (cardForRajTurnState2ToAcquire != null) { this.player.playerDeck.hand.add(cardForRajTurnState2ToAcquire); this.player.playerDeck.resetHandLocation(); exitActiveWaitingState(); } break; case SeaTyrantTurnBegin: Card t = this.player.playerDeck.activateConstruct(loc); if (t != null) { // for(Card x: this.player.playerDeck.constructs){ // if(!(x.equals(t))){ // this.player.playerDeck.discard.add(x); // this.player.playerDeck.constructs.remove(x); // this.player.playerDeck.resetHandLocation(); // } // } for (Card x : this.player.playerDeck.constructs) { if (!x.equals(t)) { this.player.playerDeck.discard.add(x); } } ArrayList<Card> newConstructs = new ArrayList<Card>(); newConstructs.add(t); this.player.seaTyrant = false; this.player.playerDeck.constructs = newConstructs; this.turnState = Turn.TurnState.Default; this.turnStateMagnitude = 0; this.player.playerDeck.resetHandLocation(); } else { this.optionPane.showMessageDialog( this.game, game.descriptions.getString("ConstructToSave"), "", JOptionPane.PLAIN_MESSAGE); } break; case CorrosiveWidowTurnBegin: if (this.player.playerDeck.constructs.size() <= 0) { this.turnState = TurnState.Default; this.player.corrosiveWidow = 0; this.leftButtonClick(loc); break; } Card cWTBcard = this.player.playerDeck.activateConstruct(loc); if (cWTBcard != null) { for (int cWTBcounter = 0; cWTBcounter < this.player.playerDeck.constructs.size(); cWTBcounter++) { if (cWTBcard.equals(this.player.playerDeck.constructs.get(cWTBcounter))) { this.player.playerDeck.constructs.remove(cWTBcounter); this.player.corrosiveWidow--; if (this.player.corrosiveWidow <= 0) { this.turnState = TurnState.Default; } else { if (this.player.playerDeck.constructs.size() > 0) { this.optionPane.showMessageDialog( this.game, game.descriptions.getString("ConstructToDiscard"), "", JOptionPane.PLAIN_MESSAGE); } } this.player.playerDeck.resetHandLocation(); } } } else { this.optionPane.showMessageDialog( this.game, game.descriptions.getString("ConstructToDiscard"), "", JOptionPane.PLAIN_MESSAGE); } break; default: break; } }