Affinity affects other costs
Affinity should affect other costs such as flashback, buyback, to cast since its also a cost reducer...
This commit is contained in:
@@ -255,7 +255,7 @@ public:
|
||||
bool isTargetter();
|
||||
int cardistargetter;
|
||||
int myconvertedcost;
|
||||
ManaCost * computeNewCost(MTGCardInstance * card,ManaCost * oldCost, ManaCost * refCost);
|
||||
ManaCost * computeNewCost(MTGCardInstance * card,ManaCost * oldCost, ManaCost * refCost,bool onlyTrinisphere = false);
|
||||
|
||||
void eventattacked();
|
||||
void eventattackedAlone();
|
||||
|
||||
@@ -1017,7 +1017,7 @@ void GameObserver::Affinity()
|
||||
ManaCost * original = NEW ManaCost();
|
||||
original->copy(card->model->data->getManaCost());
|
||||
if(card->getIncreasedManaCost()->getConvertedCost()||card->getReducedManaCost()->getConvertedCost())
|
||||
{
|
||||
{//start1
|
||||
if(card->getIncreasedManaCost()->getConvertedCost())
|
||||
original->add(card->getIncreasedManaCost());
|
||||
if(card->getReducedManaCost()->getConvertedCost())
|
||||
@@ -1031,11 +1031,11 @@ void GameObserver::Affinity()
|
||||
card->getManaCost()->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
}//end1
|
||||
int reducem = 0;
|
||||
bool resetCost = false;
|
||||
for(unsigned int na = 0; na < card->cardsAbilities.size();na++)
|
||||
{
|
||||
{//start2
|
||||
ANewAffinity * newAff = dynamic_cast<ANewAffinity*>(card->cardsAbilities[na]);
|
||||
if(newAff)
|
||||
{
|
||||
@@ -1073,7 +1073,7 @@ void GameObserver::Affinity()
|
||||
card->getManaCost()->remove(removingCost);
|
||||
SAFE_DELETE(removingCost);
|
||||
}
|
||||
}
|
||||
}//end2
|
||||
if(card->has(Constants::AFFINITYARTIFACTS)||
|
||||
card->has(Constants::AFFINITYFOREST)||
|
||||
card->has(Constants::AFFINITYGREENCREATURES)||
|
||||
@@ -1081,7 +1081,7 @@ void GameObserver::Affinity()
|
||||
card->has(Constants::AFFINITYMOUNTAIN)||
|
||||
card->has(Constants::AFFINITYPLAINS)||
|
||||
card->has(Constants::AFFINITYSWAMP))
|
||||
{
|
||||
{//start3
|
||||
if (card->has(Constants::AFFINITYARTIFACTS))
|
||||
{
|
||||
type = "artifact";
|
||||
@@ -1136,7 +1136,7 @@ void GameObserver::Affinity()
|
||||
if(card->getManaCost()->getCost(color) > 0)
|
||||
card->getManaCost()->remove(color,1);
|
||||
}
|
||||
}
|
||||
}//end3
|
||||
SAFE_DELETE(original);
|
||||
}//end
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
#include "Counters.h"
|
||||
#include "Subtypes.h"
|
||||
|
||||
|
||||
#include "AIPlayerBaka.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SUPPORT_OBJECT_ANALYTICS(MTGCardInstance)
|
||||
@@ -919,20 +922,102 @@ JQuadPtr MTGCardInstance::getIcon()
|
||||
return WResourceManager::Instance()->RetrieveCard(this, CACHE_THUMB);
|
||||
}
|
||||
|
||||
ManaCost * MTGCardInstance::computeNewCost(MTGCardInstance * card,ManaCost * newCost, ManaCost * refCost)
|
||||
ManaCost * MTGCardInstance::computeNewCost(MTGCardInstance * card,ManaCost * newCost, ManaCost * refCost, bool onlyTrinisphere)
|
||||
{
|
||||
if(!card)
|
||||
return NULL;
|
||||
if(!onlyTrinisphere)
|
||||
{
|
||||
if(card->getIncreasedManaCost()->getConvertedCost())
|
||||
newCost->add(card->getIncreasedManaCost());
|
||||
if(card->getReducedManaCost()->getConvertedCost())
|
||||
newCost->remove(card->getReducedManaCost());
|
||||
if(refCost->extraCosts)
|
||||
newCost->extraCosts = refCost->extraCosts;
|
||||
//trinisphere must be here below//
|
||||
//affinity
|
||||
int color = 0;
|
||||
string type = "";
|
||||
ManaCost * original = NEW ManaCost();
|
||||
original->copy(newCost);
|
||||
int reducem = 0;
|
||||
bool resetCost = false;
|
||||
for(unsigned int na = 0; na < card->cardsAbilities.size();na++)
|
||||
{//start2
|
||||
ANewAffinity * newAff = dynamic_cast<ANewAffinity*>(card->cardsAbilities[na]);
|
||||
if(newAff)
|
||||
{
|
||||
if(!resetCost)
|
||||
{
|
||||
resetCost = true;
|
||||
newCost->copy(original);
|
||||
}
|
||||
TargetChooserFactory tf(observer);
|
||||
TargetChooser * tcn = tf.createTargetChooser(newAff->tcString,card,NULL);
|
||||
|
||||
for (int w = 0; w < 2; ++w)
|
||||
{
|
||||
Player *p = observer->players[w];
|
||||
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack, p->game->exile };
|
||||
for (int k = 0; k < 6; k++)
|
||||
{
|
||||
MTGGameZone * z = zones[k];
|
||||
if (tcn->targetsZone(z))
|
||||
reducem += z->countByCanTarget(tcn);
|
||||
}
|
||||
}
|
||||
SAFE_DELETE(tcn);
|
||||
ManaCost * removingCost = ManaCost::parseManaCost(newAff->manaString);
|
||||
for(int j = 0; j < reducem; j++)
|
||||
newCost->remove(removingCost);
|
||||
SAFE_DELETE(removingCost);
|
||||
}
|
||||
}//end2
|
||||
if(card->has(Constants::AFFINITYARTIFACTS)||
|
||||
card->has(Constants::AFFINITYFOREST)||
|
||||
card->has(Constants::AFFINITYGREENCREATURES)||
|
||||
card->has(Constants::AFFINITYISLAND)||
|
||||
card->has(Constants::AFFINITYMOUNTAIN)||
|
||||
card->has(Constants::AFFINITYPLAINS)||
|
||||
card->has(Constants::AFFINITYSWAMP))
|
||||
{//start3
|
||||
if (card->has(Constants::AFFINITYARTIFACTS))
|
||||
type = "artifact";
|
||||
else if (card->has(Constants::AFFINITYSWAMP))
|
||||
type = "swamp";
|
||||
else if (card->has(Constants::AFFINITYMOUNTAIN))
|
||||
type = "mountain";
|
||||
else if (card->has(Constants::AFFINITYPLAINS))
|
||||
type = "plains";
|
||||
else if (card->has(Constants::AFFINITYISLAND))
|
||||
type = "island";
|
||||
else if (card->has(Constants::AFFINITYFOREST))
|
||||
type = "forest";
|
||||
else if (card->has(Constants::AFFINITYGREENCREATURES))
|
||||
{
|
||||
color = 1;
|
||||
type = "creature";
|
||||
}
|
||||
newCost->copy(original);
|
||||
int reduce = 0;
|
||||
if(card->has(Constants::AFFINITYGREENCREATURES))
|
||||
{
|
||||
TargetChooserFactory tf(observer);
|
||||
TargetChooser * tc = tf.createTargetChooser("creature[green]",NULL);
|
||||
reduce = card->controller()->game->battlefield->countByCanTarget(tc);
|
||||
SAFE_DELETE(tc);
|
||||
}
|
||||
else
|
||||
reduce = card->controller()->game->battlefield->countByType(type);
|
||||
for(int i = 0; i < reduce;i++)
|
||||
if(newCost->getCost(color) > 0)
|
||||
newCost->remove(color,1);
|
||||
}//end3
|
||||
SAFE_DELETE(original);
|
||||
}
|
||||
/*//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);
|
||||
newCost->add(Constants::MTG_COLOR_ARTIFACT, 1);*/
|
||||
|
||||
return newCost;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user