Morph
This commit is contained in:
@@ -1095,7 +1095,9 @@ int MTGMorphCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
|
|||||||
|
|
||||||
Player * player = game->currentlyActing();
|
Player * player = game->currentlyActing();
|
||||||
//Player * currentPlayer = game->currentPlayer;
|
//Player * currentPlayer = game->currentPlayer;
|
||||||
if (!player->game->hand->hasCard(card))
|
if (!player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card) && !player->game->hand->hasCard(card))
|
||||||
|
return 0;
|
||||||
|
if ((!card->has(Constants::CANPLAYFROMGRAVEYARD) && player->game->graveyard->hasCard(card))||(!card->has(Constants::CANPLAYFROMEXILE) && player->game->exile->hasCard(card)))
|
||||||
return 0;
|
return 0;
|
||||||
if (!card->getManaCost()->getMorph())
|
if (!card->getManaCost()->getMorph())
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1109,7 +1111,12 @@ int MTGMorphCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
|
|||||||
if (card->controller()->game->playRestrictions->canPutIntoZone(card, card->controller()->game->stack) == PlayRestriction::CANT_PLAY)
|
if (card->controller()->game->playRestrictions->canPutIntoZone(card, card->controller()->game->stack) == PlayRestriction::CANT_PLAY)
|
||||||
return 0;
|
return 0;
|
||||||
ManaCost * playerMana = player->getManaPool();
|
ManaCost * playerMana = player->getManaPool();
|
||||||
ManaCost * morph = card->getManaCost()->getMorph();
|
ManaCost * morph = card->computeNewCost(card,NEW ManaCost(card->model->data->getManaCost()->getMorph()),card->getManaCost()->getMorph());
|
||||||
|
if(morph->extraCosts)
|
||||||
|
for(unsigned int i = 0; i < morph->extraCosts->costs.size();i++)
|
||||||
|
{
|
||||||
|
morph->extraCosts->costs[i]->setSource(card);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
ManaCost * cost = card->getManaCost();
|
ManaCost * cost = card->getManaCost();
|
||||||
@@ -1117,7 +1124,7 @@ int MTGMorphCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//cost of card.
|
//cost of card.
|
||||||
if (morph && playerMana->canAfford(morph))
|
if (playerMana->canAfford(morph))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -1132,8 +1139,13 @@ int MTGMorphCostRule::reactToClick(MTGCardInstance * card)
|
|||||||
return 0;
|
return 0;
|
||||||
Player * player = game->currentlyActing();
|
Player * player = game->currentlyActing();
|
||||||
ManaCost * cost = card->getManaCost();
|
ManaCost * cost = card->getManaCost();
|
||||||
ManaCost * morph = card->getManaCost()->getMorph();
|
|
||||||
ManaCost * playerMana = player->getManaPool();
|
ManaCost * playerMana = player->getManaPool();
|
||||||
|
ManaCost * morph = card->computeNewCost(card,NEW ManaCost(card->model->data->getManaCost()->getMorph()),card->getManaCost()->getMorph());
|
||||||
|
if(morph->extraCosts)
|
||||||
|
for(unsigned int i = 0; i < morph->extraCosts->costs.size();i++)
|
||||||
|
{
|
||||||
|
morph->extraCosts->costs[i]->setSource(card);
|
||||||
|
}
|
||||||
//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(morph))
|
if (playerMana->canAfford(morph))
|
||||||
{
|
{
|
||||||
@@ -1155,7 +1167,7 @@ int MTGMorphCostRule::reactToClick(MTGCardInstance * card)
|
|||||||
}
|
}
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
ManaCost * previousManaPool = NEW ManaCost(player->getManaPool());
|
ManaCost * previousManaPool = NEW ManaCost(player->getManaPool());
|
||||||
player->getManaPool()->pay(card->getManaCost()->getMorph());
|
player->getManaPool()->pay(morph);
|
||||||
card->getManaCost()->getMorph()->doPayExtra();
|
card->getManaCost()->getMorph()->doPayExtra();
|
||||||
int payResult = ManaCost::MANA_PAID_WITH_MORPH;
|
int payResult = ManaCost::MANA_PAID_WITH_MORPH;
|
||||||
//if morph has a extra payment thats set, this code pays it.the if statement is 100% needed as it would cause a crash on cards that dont have the morph cost.
|
//if morph has a extra payment thats set, this code pays it.the if statement is 100% needed as it would cause a crash on cards that dont have the morph cost.
|
||||||
@@ -1169,6 +1181,12 @@ int MTGMorphCostRule::reactToClick(MTGCardInstance * card)
|
|||||||
card->morphed = true;
|
card->morphed = true;
|
||||||
card->isMorphed = true;
|
card->isMorphed = true;
|
||||||
MTGCardInstance * copy = player->game->putInZone(card, card->currentZone, player->game->stack);
|
MTGCardInstance * copy = player->game->putInZone(card, card->currentZone, player->game->stack);
|
||||||
|
copy->getManaCost()->resetCosts();//Morph has no ManaCost on stack
|
||||||
|
copy->setColor(0,1);
|
||||||
|
copy->types.clear();
|
||||||
|
string cre = "Creature";
|
||||||
|
copy->setType(cre.c_str());
|
||||||
|
copy->basicAbilities.reset();
|
||||||
Spell * spell = NULL;
|
Spell * spell = NULL;
|
||||||
spell = game->mLayers->stackLayer()->addSpell(copy, NULL, spellCost, payResult, 0);
|
spell = game->mLayers->stackLayer()->addSpell(copy, NULL, spellCost, payResult, 0);
|
||||||
spell->source->morphed = true;
|
spell->source->morphed = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user