added limiting of x to a color to fix Consume Spirit from being able to use any color..
{x:black}
{x:color}
creating a snapshot of a card instance in garbage for stored cards, the issue with previous version was it was using base model value instead of what the storedcard was actually at the time it was in battlefield. example, animal boneyard test was coming up 1 toughness short becuase the creature storedcard pointed to was sent to graveyard for the sacrifice.
changed myStored TargetChooser to use storedSourceCard instead, as this is supposed to point to the actual card and not a snapshot.
This commit is contained in:
@@ -2917,7 +2917,7 @@ public:
|
||||
setAbilityOwner();
|
||||
myDummy->setObserver(abilityReciever->getObserver());
|
||||
myDummy->owner = abilityReciever;
|
||||
myDummy->storedCard = source;
|
||||
myDummy->storedSourceCard = source;
|
||||
vector<string>magictextlines = split(sabilities,'_');
|
||||
if(magictextlines.size())
|
||||
{
|
||||
|
||||
@@ -155,6 +155,8 @@ public:
|
||||
int isAttacker();
|
||||
Targetable * isAttacking;
|
||||
MTGCardInstance * storedCard;
|
||||
MTGCardInstance * createSnapShot();
|
||||
MTGCardInstance * storedSourceCard;
|
||||
MTGCardInstance * isDefenser();
|
||||
int initAttackersDefensers();
|
||||
MTGCardInstance * getNextOpponent(MTGCardInstance * previous=NULL);
|
||||
|
||||
@@ -56,6 +56,9 @@ public:
|
||||
virtual void resetCosts();
|
||||
void x();
|
||||
int hasX();
|
||||
void specificX(int color = 0);
|
||||
int hasSpecificX();
|
||||
int xColor;
|
||||
int hasAnotherCost();
|
||||
ManaCost(std::vector<int8_t>& _cost, int nb_elems = 1);
|
||||
ManaCost();
|
||||
|
||||
@@ -186,7 +186,7 @@ int DiscardRandomCost::doPay()
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if (target)
|
||||
{
|
||||
source->storedCard = target;
|
||||
source->storedCard = target->createSnapShot();
|
||||
_target->controller()->game->discardRandom(_target->controller()->game->hand, source);
|
||||
target = NULL;
|
||||
if (tc)
|
||||
@@ -215,7 +215,7 @@ int DiscardCost::doPay()
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if (target)
|
||||
{
|
||||
source->storedCard = target;
|
||||
source->storedCard = target->createSnapShot();
|
||||
WEvent * e = NEW WEventCardDiscard(target);
|
||||
GameObserver * game = target->owner->getObserver();
|
||||
game->receiveEvent(e);
|
||||
@@ -279,7 +279,7 @@ int ToLibraryCost::doPay()
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if (target)
|
||||
{
|
||||
source->storedCard = target;
|
||||
source->storedCard = target->createSnapShot();
|
||||
_target->controller()->game->putInLibrary(target);
|
||||
target = NULL;
|
||||
if (tc)
|
||||
@@ -317,7 +317,7 @@ int MillCost::doPay()
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if (target)
|
||||
{
|
||||
source->storedCard = (MTGCardInstance*)_target->controller()->game->library->cards[_target->controller()->game->library->nb_cards - 1];
|
||||
source->storedCard = (MTGCardInstance*)_target->controller()->game->library->cards[_target->controller()->game->library->nb_cards - 1]->createSnapShot();
|
||||
_target->controller()->game->putInZone(
|
||||
_target->controller()->game->library->cards[_target->controller()->game->library->nb_cards - 1],
|
||||
_target->controller()->game->library, _target->controller()->game->graveyard);
|
||||
@@ -339,7 +339,7 @@ MillExileCost::MillExileCost(TargetChooser *_tc)
|
||||
int MillExileCost::doPay()
|
||||
{
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
source->storedCard = (MTGCardInstance*)_target->controller()->game->library->cards[_target->controller()->game->library->nb_cards - 1];
|
||||
source->storedCard = (MTGCardInstance*)_target->controller()->game->library->cards[_target->controller()->game->library->nb_cards - 1]->createSnapShot();
|
||||
if (target)
|
||||
{
|
||||
_target->controller()->game->putInZone(
|
||||
@@ -457,7 +457,7 @@ int TapTargetCost::isPaymentSet()
|
||||
int TapTargetCost::doPay()
|
||||
{
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
source->storedCard = target;
|
||||
source->storedCard = target->createSnapShot();
|
||||
if (target)
|
||||
{
|
||||
_target->tap();
|
||||
@@ -500,7 +500,7 @@ int UnTapTargetCost::isPaymentSet()
|
||||
int UnTapTargetCost::doPay()
|
||||
{
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
source->storedCard = target;
|
||||
source->storedCard = target->createSnapShot();
|
||||
if (target)
|
||||
{
|
||||
_target->untap();
|
||||
@@ -531,7 +531,7 @@ int ExileTargetCost::doPay()
|
||||
|
||||
if (target)
|
||||
{
|
||||
source->storedCard = target;
|
||||
source->storedCard = target->createSnapShot();
|
||||
target->controller()->game->putInExile(target);
|
||||
target = NULL;
|
||||
if (tc)
|
||||
@@ -560,7 +560,7 @@ int BounceTargetCost::doPay()
|
||||
|
||||
if (target)
|
||||
{
|
||||
source->storedCard = target;
|
||||
source->storedCard = target->createSnapShot();
|
||||
target->controller()->game->putInHand(target);
|
||||
target = NULL;
|
||||
if (tc)
|
||||
@@ -640,7 +640,7 @@ int SacrificeCost::doPay()
|
||||
if (target)
|
||||
{
|
||||
MTGCardInstance * beforeCard = target;
|
||||
source->storedCard = target;
|
||||
source->storedCard = target->createSnapShot();
|
||||
target->controller()->game->putInGraveyard(target);
|
||||
WEvent * e = NEW WEventCardSacrifice(beforeCard,target);
|
||||
GameObserver * game = target->owner->getObserver();
|
||||
@@ -882,7 +882,9 @@ int ExtraCosts::doPay()
|
||||
for (size_t i = 0; i < costs.size(); i++)
|
||||
{
|
||||
if(costs[i]->target)
|
||||
{
|
||||
costs[i]->target->isExtraCostTarget = false;
|
||||
}
|
||||
result += costs[i]->doPay();
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -3004,7 +3004,7 @@ int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode, Targ
|
||||
MTGCardInstance * testDummy = NEW MTGCardInstance();
|
||||
testDummy->setObserver(targetedPlyr->getObserver());
|
||||
testDummy->owner = targetedPlyr;
|
||||
testDummy->storedCard = atac->source;
|
||||
testDummy->storedSourceCard = atac->source;
|
||||
vector<string>magictextlines = split(atac->sabilities,'_');
|
||||
if(magictextlines.size())
|
||||
{
|
||||
|
||||
@@ -51,6 +51,15 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to
|
||||
castMethod = Constants::NOT_CAST;
|
||||
}
|
||||
|
||||
MTGCardInstance * MTGCardInstance::createSnapShot()
|
||||
{
|
||||
MTGCardInstance * snapShot = NEW MTGCardInstance(*this);
|
||||
snapShot->previous = NULL;
|
||||
snapShot->counters = NEW Counters(snapShot);
|
||||
controller()->game->garbage->addCard(snapShot);
|
||||
return snapShot;
|
||||
}
|
||||
|
||||
void MTGCardInstance::copy(MTGCardInstance * card)
|
||||
{
|
||||
MTGCard * source = card->model;
|
||||
@@ -81,7 +90,7 @@ void MTGCardInstance::copy(MTGCardInstance * card)
|
||||
int backupid = mtgid;
|
||||
int castMethodBackUP = this->castMethod;
|
||||
mtgid = source->getId();
|
||||
MTGCardInstance * oldStored = this->storedCard;
|
||||
MTGCardInstance * oldStored = this->storedSourceCard;
|
||||
Spell * spell = NEW Spell(observer, this);
|
||||
observer = card->observer;
|
||||
AbilityFactory af(observer);
|
||||
@@ -159,6 +168,7 @@ void MTGCardInstance::initMTGCI()
|
||||
coinSide = -1;
|
||||
isAttacking = NULL;
|
||||
storedCard = NULL;
|
||||
storedSourceCard = NULL;
|
||||
|
||||
for (int i = 0; i < ManaCost::MANA_PAID_WITH_RETRACE +1; i++)
|
||||
alternateCostPaid[i] = 0;
|
||||
|
||||
@@ -475,6 +475,7 @@ MTGCardInstance * MTGGameZone::removeCard(MTGCardInstance * card, int createCopy
|
||||
copy->castX = card->castX;
|
||||
copy->kicked = card->kicked;
|
||||
copy->storedCard = card->storedCard;
|
||||
copy->storedSourceCard = card->storedSourceCard;
|
||||
|
||||
//stupid bug with tokens...
|
||||
if (card->model == card)
|
||||
|
||||
@@ -25,6 +25,7 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
|
||||
{
|
||||
manaCost = NEW ManaCost();
|
||||
}
|
||||
manaCost->xColor = -1;
|
||||
int state = 0;
|
||||
size_t start = 0;
|
||||
size_t end = 0;
|
||||
@@ -91,8 +92,27 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
|
||||
switch (value[0])
|
||||
{
|
||||
case 'x':
|
||||
manaCost->x();
|
||||
if(value == "x")
|
||||
manaCost->x();
|
||||
else
|
||||
{
|
||||
vector<string>colorSplit = parseBetween(value,"x:"," ",false);
|
||||
if(colorSplit.size())
|
||||
{
|
||||
int color = -1;
|
||||
const string ColorStrings[] = { Constants::kManaColorless, Constants::kManaGreen, Constants::kManaBlue, Constants::kManaRed, Constants::kManaBlack, Constants::kManaWhite };
|
||||
for (unsigned int i = 0; i < sizeof(ColorStrings)/sizeof(ColorStrings[0]); ++i)
|
||||
{
|
||||
if (s.find(ColorStrings[i]) != string::npos)
|
||||
{
|
||||
color = i;
|
||||
}
|
||||
}
|
||||
manaCost->specificX(color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 't': //Tap
|
||||
if (value == "t")
|
||||
{
|
||||
@@ -296,6 +316,7 @@ ManaCost::ManaCost(ManaCost * manaCost)
|
||||
suspend = NEW ManaCost( manaCost->suspend );
|
||||
|
||||
extraCosts = manaCost->extraCosts ? manaCost->extraCosts->clone() : NULL;
|
||||
xColor = manaCost->xColor;
|
||||
}
|
||||
|
||||
// Copy Constructor
|
||||
@@ -322,6 +343,7 @@ ManaCost::ManaCost(const ManaCost& manaCost)
|
||||
suspend = NEW ManaCost( manaCost.suspend );
|
||||
|
||||
extraCosts = manaCost.extraCosts ? manaCost.extraCosts->clone() : NULL;
|
||||
xColor = manaCost.xColor;
|
||||
}
|
||||
|
||||
// operator=
|
||||
@@ -341,6 +363,7 @@ ManaCost & ManaCost::operator= (const ManaCost & manaCost)
|
||||
FlashBack = manaCost.FlashBack;
|
||||
morph = manaCost.morph;
|
||||
suspend = manaCost.suspend;
|
||||
xColor = manaCost.xColor;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -377,10 +400,34 @@ int ManaCost::hasX()
|
||||
DebugTrace("Seems ManaCost was not properly initialized");
|
||||
return 0;
|
||||
}
|
||||
if(xColor > 0)
|
||||
return 0;
|
||||
|
||||
return cost[Constants::NB_Colors];
|
||||
}
|
||||
|
||||
void ManaCost::specificX(int color)
|
||||
{
|
||||
if (cost.size() <= (size_t)Constants::NB_Colors)
|
||||
{
|
||||
DebugTrace("Seems ManaCost was not properly initialized");
|
||||
return;
|
||||
}
|
||||
xColor = color;
|
||||
cost[Constants::NB_Colors] = 1;
|
||||
}
|
||||
int ManaCost::hasSpecificX()
|
||||
{
|
||||
if (cost.size() <= (size_t)Constants::NB_Colors)
|
||||
{
|
||||
DebugTrace("Seems ManaCost was not properly initialized");
|
||||
return 0;
|
||||
}
|
||||
if(xColor > 0)
|
||||
return cost[Constants::NB_Colors];
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ManaCost::hasAnotherCost()
|
||||
{
|
||||
if (cost.size() <= (size_t)Constants::NB_Colors)
|
||||
@@ -501,6 +548,7 @@ void ManaCost::copy(ManaCost * _manaCost)
|
||||
suspend = NEW ManaCost();
|
||||
suspend->copy(_manaCost->suspend);
|
||||
}
|
||||
xColor = _manaCost->xColor;
|
||||
}
|
||||
|
||||
int ManaCost::getCost(int color)
|
||||
@@ -815,6 +863,16 @@ ManaCost * ManaCost::Diff(ManaCost * _cost)
|
||||
}
|
||||
}
|
||||
}
|
||||
//cost x where x is specific.
|
||||
if (_cost->hasSpecificX())
|
||||
{
|
||||
diff[Constants::NB_Colors * 2 + 1] = 0;
|
||||
if (diff[_cost->xColor * 2 + 1] > 0)
|
||||
{
|
||||
diff[Constants::NB_Colors * 2 + 1] += diff[_cost->xColor * 2 + 1];
|
||||
diff[_cost->xColor * 2 + 1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ManaCost * result = NEW ManaCost(diff, Constants::NB_Colors + 1);
|
||||
return result;
|
||||
|
||||
@@ -673,7 +673,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
}
|
||||
else if (typeName.compare("mystored") == 0)
|
||||
{
|
||||
return NEW CardTargetChooser(observer, card->storedCard, card, zones, nbzones);
|
||||
return NEW CardTargetChooser(observer, card->storedSourceCard, card, zones, nbzones);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user