Merge pull request #680 from kevlahnota/master
Morph, Overload and PayZero costs changes
This commit is contained in:
@@ -255,7 +255,8 @@ public:
|
|||||||
bool isTargetter();
|
bool isTargetter();
|
||||||
int cardistargetter;
|
int cardistargetter;
|
||||||
int myconvertedcost;
|
int myconvertedcost;
|
||||||
ManaCost * computeNewCost(MTGCardInstance * card,ManaCost * oldCost, ManaCost * refCost,bool onlyTrinisphere = false);
|
ManaCost * computeNewCost(MTGCardInstance * card,ManaCost * oldCost, ManaCost * refCost,bool noTrinisphere = false);
|
||||||
|
int countTrini;
|
||||||
|
|
||||||
void eventattacked();
|
void eventattacked();
|
||||||
void eventattackedAlone();
|
void eventattackedAlone();
|
||||||
|
|||||||
@@ -1305,25 +1305,15 @@ int GenericPaidAbility::resolve()
|
|||||||
{
|
{
|
||||||
must = true;
|
must = true;
|
||||||
//cost increase - reduce + trinisphere effect ability todo...
|
//cost increase - reduce + trinisphere effect ability todo...
|
||||||
if(((MTGCardInstance *)target)->getIncreasedManaCost()->getConvertedCost())
|
optionalCost = ((MTGCardInstance *)target)->computeNewCost(((MTGCardInstance *)target),optionalCost,optionalCost);
|
||||||
optionalCost->add(((MTGCardInstance *)target)->getIncreasedManaCost());
|
if(optionalCost->extraCosts)
|
||||||
if(((MTGCardInstance *)target)->getReducedManaCost()->getConvertedCost())
|
|
||||||
optionalCost->remove(((MTGCardInstance *)target)->getReducedManaCost());
|
|
||||||
//trinisphere effect must be hardcoded...here..
|
|
||||||
/*if(((MTGCardInstance *)target)->has(Constants::TRINISPHERE))
|
|
||||||
{
|
{
|
||||||
if(optionalCost->getConvertedCost() == 2)
|
for(unsigned int i = 0; i < optionalCost->extraCosts->costs.size();i++)
|
||||||
optionalCost->add(Constants::MTG_COLOR_ARTIFACT, 1);
|
optionalCost->extraCosts->costs[i]->setSource(((MTGCardInstance *)target));
|
||||||
else if(optionalCost->getConvertedCost() == 1)
|
}
|
||||||
optionalCost->add(Constants::MTG_COLOR_ARTIFACT, 2);
|
|
||||||
else if(optionalCost->getConvertedCost() < 1)
|
|
||||||
optionalCost->add(Constants::MTG_COLOR_ARTIFACT, 3);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
if(asAlternate && nomenu && optionalCost->getConvertedCost() < 1)
|
if(asAlternate && nomenu && optionalCost->getConvertedCost() < 1)
|
||||||
{
|
|
||||||
nomenuAbility->resolve();
|
nomenuAbility->resolve();
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MenuAbility * a1 = NEW MenuAbility(game, this->GetId(), target, source, must, selection, NULL, newName);
|
MenuAbility * a1 = NEW MenuAbility(game, this->GetId(), target, source, must, selection, NULL, newName);
|
||||||
|
|||||||
@@ -1137,6 +1137,25 @@ void GameObserver::Affinity()
|
|||||||
card->getManaCost()->remove(color,1);
|
card->getManaCost()->remove(color,1);
|
||||||
}
|
}
|
||||||
}//end3
|
}//end3
|
||||||
|
//trinisphere... now how to implement kicker recomputation
|
||||||
|
|
||||||
|
if(card->has(Constants::TRINISPHERE))
|
||||||
|
{
|
||||||
|
for(int jj = card->getManaCost()->getConvertedCost(); jj < 3; jj++)
|
||||||
|
{
|
||||||
|
card->getManaCost()->add(Constants::MTG_COLOR_ARTIFACT, 1);
|
||||||
|
card->countTrini++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(card->countTrini)
|
||||||
|
{
|
||||||
|
card->getManaCost()->remove(Constants::MTG_COLOR_ARTIFACT, card->countTrini);
|
||||||
|
card->countTrini=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SAFE_DELETE(original);
|
SAFE_DELETE(original);
|
||||||
}//end
|
}//end
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -198,6 +198,7 @@ void MTGCardInstance::initMTGCI()
|
|||||||
storedSourceCard = NULL;
|
storedSourceCard = NULL;
|
||||||
myPair = NULL;
|
myPair = NULL;
|
||||||
miracle = false;
|
miracle = false;
|
||||||
|
countTrini = 0;
|
||||||
|
|
||||||
for (int i = 0; i < ManaCost::MANA_PAID_WITH_SUSPEND +1; i++)
|
for (int i = 0; i < ManaCost::MANA_PAID_WITH_SUSPEND +1; i++)
|
||||||
alternateCostPaid[i] = 0;
|
alternateCostPaid[i] = 0;
|
||||||
@@ -922,12 +923,11 @@ JQuadPtr MTGCardInstance::getIcon()
|
|||||||
return WResourceManager::Instance()->RetrieveCard(this, CACHE_THUMB);
|
return WResourceManager::Instance()->RetrieveCard(this, CACHE_THUMB);
|
||||||
}
|
}
|
||||||
|
|
||||||
ManaCost * MTGCardInstance::computeNewCost(MTGCardInstance * card,ManaCost * newCost, ManaCost * refCost, bool onlyTrinisphere)
|
ManaCost * MTGCardInstance::computeNewCost(MTGCardInstance * card,ManaCost * newCost, ManaCost * refCost, bool noTrinisphere)
|
||||||
{
|
{
|
||||||
if(!card)
|
if(!card)
|
||||||
return NULL;
|
return NULL;
|
||||||
if(!onlyTrinisphere)
|
|
||||||
{
|
|
||||||
if(card->getIncreasedManaCost()->getConvertedCost())
|
if(card->getIncreasedManaCost()->getConvertedCost())
|
||||||
newCost->add(card->getIncreasedManaCost());
|
newCost->add(card->getIncreasedManaCost());
|
||||||
if(card->getReducedManaCost()->getConvertedCost())
|
if(card->getReducedManaCost()->getConvertedCost())
|
||||||
@@ -1013,11 +1013,27 @@ ManaCost * MTGCardInstance::computeNewCost(MTGCardInstance * card,ManaCost * new
|
|||||||
newCost->remove(color,1);
|
newCost->remove(color,1);
|
||||||
}//end3
|
}//end3
|
||||||
SAFE_DELETE(original);
|
SAFE_DELETE(original);
|
||||||
|
|
||||||
|
if(!noTrinisphere)
|
||||||
|
{
|
||||||
|
//trinisphere... now how to implement kicker recomputation
|
||||||
|
if(card->has(Constants::TRINISPHERE))
|
||||||
|
{
|
||||||
|
for(int jj = newCost->getConvertedCost(); jj < 3; jj++)
|
||||||
|
{
|
||||||
|
newCost->add(Constants::MTG_COLOR_ARTIFACT, 1);
|
||||||
|
card->countTrini++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(card->countTrini)
|
||||||
|
{
|
||||||
|
newCost->remove(Constants::MTG_COLOR_ARTIFACT, card->countTrini);
|
||||||
|
card->countTrini=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*//trinisphere must be here below//
|
|
||||||
if(card->has(Constants::TRINISPHERE))
|
|
||||||
for(int jj = newCost->getConvertedCost(); jj < 3; jj++)
|
|
||||||
newCost->add(Constants::MTG_COLOR_ARTIFACT, 1);*/
|
|
||||||
|
|
||||||
return newCost;
|
return newCost;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -1216,10 +1234,12 @@ int MTGPayZeroRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
|||||||
return 0;
|
return 0;
|
||||||
Player * player = game->currentlyActing();
|
Player * player = game->currentlyActing();
|
||||||
ManaCost * cost = NEW ManaCost(ManaCost::parseManaCost("{0}",NULL,NULL));
|
ManaCost * cost = NEW ManaCost(ManaCost::parseManaCost("{0}",NULL,NULL));
|
||||||
if(card->getIncreasedManaCost()->getConvertedCost())
|
ManaCost * newCost = card->computeNewCost(card,cost,cost);
|
||||||
cost->add(card->getIncreasedManaCost());
|
if(newCost->extraCosts)
|
||||||
if(card->getReducedManaCost()->getConvertedCost())
|
for(unsigned int i = 0; i < newCost->extraCosts->costs.size();i++)
|
||||||
cost->remove(card->getReducedManaCost());
|
{
|
||||||
|
newCost->extraCosts->costs[i]->setSource(card);
|
||||||
|
}
|
||||||
|
|
||||||
if(card->isLand())
|
if(card->isLand())
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1234,7 +1254,7 @@ int MTGPayZeroRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
|||||||
else
|
else
|
||||||
CustomName = "Zero Cast From Anywhere";
|
CustomName = "Zero Cast From Anywhere";
|
||||||
|
|
||||||
return MTGAlternativeCostRule::isReactingToClick(card, mana, cost);
|
return MTGAlternativeCostRule::isReactingToClick(card, mana, newCost);
|
||||||
}
|
}
|
||||||
|
|
||||||
int MTGPayZeroRule::reactToClick(MTGCardInstance * card)
|
int MTGPayZeroRule::reactToClick(MTGCardInstance * card)
|
||||||
@@ -1243,14 +1263,16 @@ int MTGPayZeroRule::reactToClick(MTGCardInstance * card)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ManaCost * cost = NEW ManaCost(ManaCost::parseManaCost("{0}",NULL,NULL));
|
ManaCost * cost = NEW ManaCost(ManaCost::parseManaCost("{0}",NULL,NULL));
|
||||||
if(card->getIncreasedManaCost()->getConvertedCost())
|
ManaCost * newCost = card->computeNewCost(card,cost,cost);
|
||||||
cost->add(card->getIncreasedManaCost());
|
if(newCost->extraCosts)
|
||||||
if(card->getReducedManaCost()->getConvertedCost())
|
for(unsigned int i = 0; i < newCost->extraCosts->costs.size();i++)
|
||||||
cost->remove(card->getReducedManaCost());
|
{
|
||||||
|
newCost->extraCosts->costs[i]->setSource(card);
|
||||||
|
}
|
||||||
|
|
||||||
card->paymenttype = MTGAbility::PAYZERO_COST;
|
card->paymenttype = MTGAbility::PAYZERO_COST;
|
||||||
|
|
||||||
return MTGAlternativeCostRule::reactToClick(card, cost, ManaCost::MANA_PAID);
|
return MTGAlternativeCostRule::reactToClick(card, newCost, ManaCost::MANA_PAID);
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream& MTGPayZeroRule::toString(ostream& out) const
|
ostream& MTGPayZeroRule::toString(ostream& out) const
|
||||||
@@ -1276,10 +1298,12 @@ int MTGOverloadRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
|||||||
return 0;
|
return 0;
|
||||||
Player * player = game->currentlyActing();
|
Player * player = game->currentlyActing();
|
||||||
ManaCost * cost = NEW ManaCost(card->model->data->getManaCost()->getAlternative());
|
ManaCost * cost = NEW ManaCost(card->model->data->getManaCost()->getAlternative());
|
||||||
if(card->getIncreasedManaCost()->getConvertedCost())
|
ManaCost * newCost = card->computeNewCost(card,cost,cost);
|
||||||
cost->add(card->getIncreasedManaCost());
|
if(newCost->extraCosts)
|
||||||
if(card->getReducedManaCost()->getConvertedCost())
|
for(unsigned int i = 0; i < newCost->extraCosts->costs.size();i++)
|
||||||
cost->remove(card->getReducedManaCost());
|
{
|
||||||
|
newCost->extraCosts->costs[i]->setSource(card);
|
||||||
|
}
|
||||||
|
|
||||||
if (card->isLand())
|
if (card->isLand())
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1288,7 +1312,7 @@ int MTGOverloadRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
|||||||
if ((!card->has(Constants::CANPLAYFROMGRAVEYARD) && player->game->graveyard->hasCard(card))||(!card->has(Constants::CANPLAYFROMEXILE) && player->game->exile->hasCard(card)))
|
if ((!card->has(Constants::CANPLAYFROMGRAVEYARD) && player->game->graveyard->hasCard(card))||(!card->has(Constants::CANPLAYFROMEXILE) && player->game->exile->hasCard(card)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return MTGAlternativeCostRule::isReactingToClick(card, mana, cost);
|
return MTGAlternativeCostRule::isReactingToClick(card, mana, newCost);
|
||||||
}
|
}
|
||||||
|
|
||||||
int MTGOverloadRule::reactToClick(MTGCardInstance * card)
|
int MTGOverloadRule::reactToClick(MTGCardInstance * card)
|
||||||
@@ -1297,14 +1321,16 @@ int MTGOverloadRule::reactToClick(MTGCardInstance * card)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ManaCost * cost = NEW ManaCost(card->model->data->getManaCost()->getAlternative());
|
ManaCost * cost = NEW ManaCost(card->model->data->getManaCost()->getAlternative());
|
||||||
if(card->getIncreasedManaCost()->getConvertedCost())
|
ManaCost * newCost = card->computeNewCost(card,cost,cost);
|
||||||
cost->add(card->getIncreasedManaCost());
|
if(newCost->extraCosts)
|
||||||
if(card->getReducedManaCost()->getConvertedCost())
|
for(unsigned int i = 0; i < newCost->extraCosts->costs.size();i++)
|
||||||
cost->remove(card->getReducedManaCost());
|
{
|
||||||
|
newCost->extraCosts->costs[i]->setSource(card);
|
||||||
|
}
|
||||||
|
|
||||||
card->paymenttype = MTGAbility::OVERLOAD_COST;
|
card->paymenttype = MTGAbility::OVERLOAD_COST;
|
||||||
|
|
||||||
return MTGAlternativeCostRule::reactToClick(card, cost, ManaCost::MANA_PAID_WITH_OVERLOAD, true);
|
return MTGAlternativeCostRule::reactToClick(card, newCost, ManaCost::MANA_PAID_WITH_OVERLOAD, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream& MTGOverloadRule::toString(ostream& out) const
|
ostream& MTGOverloadRule::toString(ostream& out) const
|
||||||
|
|||||||
Reference in New Issue
Block a user