fix to previous checkin. adding new parameter to specify originating zone of card

This commit is contained in:
techdragon.nguyen@gmail.com
2011-01-21 18:46:13 +00:00
parent 0e49775f27
commit b836c97a1b
2 changed files with 12 additions and 10 deletions
+1 -1
View File
@@ -40,7 +40,7 @@ public:
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
int isReactingToClick(MTGCardInstance * card, ManaCost * mana, ManaCost *alternateManaCost); int isReactingToClick(MTGCardInstance * card, ManaCost * mana, ManaCost *alternateManaCost);
int reactToClick(MTGCardInstance * card, ManaCost * alternateManaCost, int paymentType = ManaCost::MANA_PAID); int reactToClick(MTGCardInstance * card, ManaCost * alternateManaCost, MTGGameZone * originatingZone, int paymentType = ManaCost::MANA_PAID);
int reactToClick(MTGCardInstance * card); int reactToClick(MTGCardInstance * card);
int testDestroy(); int testDestroy();
+11 -9
View File
@@ -317,10 +317,10 @@ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card)
if (playerMana->canAfford( alternateCost ) ) if (playerMana->canAfford( alternateCost ) )
card->paymenttype = MTGAbility::ALTERNATIVE_COST; card->paymenttype = MTGAbility::ALTERNATIVE_COST;
return reactToClick(card, card->getManaCost()->alternative, ManaCost::MANA_PAID_WITH_ALTERNATIVE); return reactToClick(card, card->getManaCost()->alternative, player->game->hand, ManaCost::MANA_PAID_WITH_ALTERNATIVE);
} }
int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card, ManaCost *alternateCost, int alternateCostType){ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card, ManaCost *alternateCost, MTGGameZone * originatingZone, int alternateCostType){
Player * player = game->currentlyActing(); Player * player = game->currentlyActing();
ManaCost * playerMana = player->getManaPool(); ManaCost * playerMana = player->getManaPool();
@@ -368,7 +368,7 @@ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card, ManaCost *alter
else else
{ {
ManaCost *spellCost = previousManaPool->Diff(player->getManaPool()); ManaCost *spellCost = previousManaPool->Diff(player->getManaPool());
MTGCardInstance * copy = player->game->putInZone(card, player->game->graveyard, player->game->stack); MTGCardInstance * copy = player->game->putInZone(card, originatingZone, player->game->stack);
copy->alternateCostPaid[alternateCostType] = 1; copy->alternateCostPaid[alternateCostType] = 1;
spell = game->mLayers->stackLayer()->addSpell(copy, game->targetChooser, spellCost, payResult, 0); spell = game->mLayers->stackLayer()->addSpell(copy, game->targetChooser, spellCost, payResult, 0);
game->targetChooser = NULL; game->targetChooser = NULL;
@@ -441,14 +441,15 @@ int MTGBuyBackRule::reactToClick(MTGCardInstance * card)
if (!isReactingToClick(card)) if (!isReactingToClick(card))
return 0; return 0;
ManaCost * playerMana = game->currentlyActing()->getManaPool(); Player *player = game->currentlyActing();
ManaCost * playerMana = player->getManaPool();
ManaCost * alternateCost = card->getManaCost()->BuyBack; ManaCost * alternateCost = card->getManaCost()->BuyBack;
//this handles extra cost payments at the moment a card is played. //this handles extra cost payments at the moment a card is played.
if (playerMana->canAfford(alternateCost)) if (playerMana->canAfford(alternateCost))
card->paymenttype = MTGAbility::BUYBACK_COST; card->paymenttype = MTGAbility::BUYBACK_COST;
return MTGAlternativeCostRule::reactToClick(card, alternateCost, ManaCost::MANA_PAID_WITH_BUYBACK); return MTGAlternativeCostRule::reactToClick(card, alternateCost, player->game->hand, ManaCost::MANA_PAID_WITH_BUYBACK);
} }
@@ -491,6 +492,7 @@ int MTGFlashBackRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
int MTGFlashBackRule::reactToClick(MTGCardInstance * card) int MTGFlashBackRule::reactToClick(MTGCardInstance * card)
{ {
Player *player = game->currentlyActing();
ManaCost * alternateCost = card->getManaCost()->FlashBack; ManaCost * alternateCost = card->getManaCost()->FlashBack;
ManaCost * playerMana = game->currentlyActing()->getManaPool(); ManaCost * playerMana = game->currentlyActing()->getManaPool();
if (!isReactingToClick(card)) if (!isReactingToClick(card))
@@ -499,7 +501,7 @@ int MTGFlashBackRule::reactToClick(MTGCardInstance * card)
if ( playerMana->canAfford(alternateCost) ) if ( playerMana->canAfford(alternateCost) )
card->paymenttype = MTGAbility::FLASHBACK_COST; card->paymenttype = MTGAbility::FLASHBACK_COST;
return MTGAlternativeCostRule::reactToClick(card, alternateCost, ManaCost::MANA_PAID_WITH_FLASHBACK); return MTGAlternativeCostRule::reactToClick(card, alternateCost, player->game->graveyard, ManaCost::MANA_PAID_WITH_FLASHBACK);
} }
@@ -549,15 +551,15 @@ int MTGRetraceRule::reactToClick(MTGCardInstance * card)
{ {
if (!isReactingToClick(card)) if (!isReactingToClick(card))
return 0; return 0;
Player *player = game->currentlyActing();
ManaCost * playerMana = game->currentlyActing()->getManaPool(); ManaCost * playerMana = player->getManaPool();
ManaCost * alternateCost = card->getManaCost()->Retrace; ManaCost * alternateCost = card->getManaCost()->Retrace;
//this handles extra cost payments at the moment a card is played. //this handles extra cost payments at the moment a card is played.
if (playerMana->canAfford(alternateCost)) if (playerMana->canAfford(alternateCost))
card->paymenttype = MTGAbility::RETRACE_COST; card->paymenttype = MTGAbility::RETRACE_COST;
return MTGAlternativeCostRule::reactToClick(card, alternateCost, ManaCost::MANA_PAID_WITH_RETRACE); return MTGAlternativeCostRule::reactToClick(card, alternateCost, player->game->graveyard, ManaCost::MANA_PAID_WITH_RETRACE);
} }