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();
|
setAbilityOwner();
|
||||||
myDummy->setObserver(abilityReciever->getObserver());
|
myDummy->setObserver(abilityReciever->getObserver());
|
||||||
myDummy->owner = abilityReciever;
|
myDummy->owner = abilityReciever;
|
||||||
myDummy->storedCard = source;
|
myDummy->storedSourceCard = source;
|
||||||
vector<string>magictextlines = split(sabilities,'_');
|
vector<string>magictextlines = split(sabilities,'_');
|
||||||
if(magictextlines.size())
|
if(magictextlines.size())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -155,6 +155,8 @@ public:
|
|||||||
int isAttacker();
|
int isAttacker();
|
||||||
Targetable * isAttacking;
|
Targetable * isAttacking;
|
||||||
MTGCardInstance * storedCard;
|
MTGCardInstance * storedCard;
|
||||||
|
MTGCardInstance * createSnapShot();
|
||||||
|
MTGCardInstance * storedSourceCard;
|
||||||
MTGCardInstance * isDefenser();
|
MTGCardInstance * isDefenser();
|
||||||
int initAttackersDefensers();
|
int initAttackersDefensers();
|
||||||
MTGCardInstance * getNextOpponent(MTGCardInstance * previous=NULL);
|
MTGCardInstance * getNextOpponent(MTGCardInstance * previous=NULL);
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ public:
|
|||||||
virtual void resetCosts();
|
virtual void resetCosts();
|
||||||
void x();
|
void x();
|
||||||
int hasX();
|
int hasX();
|
||||||
|
void specificX(int color = 0);
|
||||||
|
int hasSpecificX();
|
||||||
|
int xColor;
|
||||||
int hasAnotherCost();
|
int hasAnotherCost();
|
||||||
ManaCost(std::vector<int8_t>& _cost, int nb_elems = 1);
|
ManaCost(std::vector<int8_t>& _cost, int nb_elems = 1);
|
||||||
ManaCost();
|
ManaCost();
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ int DiscardRandomCost::doPay()
|
|||||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
source->storedCard = target;
|
source->storedCard = target->createSnapShot();
|
||||||
_target->controller()->game->discardRandom(_target->controller()->game->hand, source);
|
_target->controller()->game->discardRandom(_target->controller()->game->hand, source);
|
||||||
target = NULL;
|
target = NULL;
|
||||||
if (tc)
|
if (tc)
|
||||||
@@ -215,7 +215,7 @@ int DiscardCost::doPay()
|
|||||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
source->storedCard = target;
|
source->storedCard = target->createSnapShot();
|
||||||
WEvent * e = NEW WEventCardDiscard(target);
|
WEvent * e = NEW WEventCardDiscard(target);
|
||||||
GameObserver * game = target->owner->getObserver();
|
GameObserver * game = target->owner->getObserver();
|
||||||
game->receiveEvent(e);
|
game->receiveEvent(e);
|
||||||
@@ -279,7 +279,7 @@ int ToLibraryCost::doPay()
|
|||||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
source->storedCard = target;
|
source->storedCard = target->createSnapShot();
|
||||||
_target->controller()->game->putInLibrary(target);
|
_target->controller()->game->putInLibrary(target);
|
||||||
target = NULL;
|
target = NULL;
|
||||||
if (tc)
|
if (tc)
|
||||||
@@ -317,7 +317,7 @@ int MillCost::doPay()
|
|||||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||||
if (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->putInZone(
|
||||||
_target->controller()->game->library->cards[_target->controller()->game->library->nb_cards - 1],
|
_target->controller()->game->library->cards[_target->controller()->game->library->nb_cards - 1],
|
||||||
_target->controller()->game->library, _target->controller()->game->graveyard);
|
_target->controller()->game->library, _target->controller()->game->graveyard);
|
||||||
@@ -339,7 +339,7 @@ MillExileCost::MillExileCost(TargetChooser *_tc)
|
|||||||
int MillExileCost::doPay()
|
int MillExileCost::doPay()
|
||||||
{
|
{
|
||||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
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)
|
if (target)
|
||||||
{
|
{
|
||||||
_target->controller()->game->putInZone(
|
_target->controller()->game->putInZone(
|
||||||
@@ -457,7 +457,7 @@ int TapTargetCost::isPaymentSet()
|
|||||||
int TapTargetCost::doPay()
|
int TapTargetCost::doPay()
|
||||||
{
|
{
|
||||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||||
source->storedCard = target;
|
source->storedCard = target->createSnapShot();
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
_target->tap();
|
_target->tap();
|
||||||
@@ -500,7 +500,7 @@ int UnTapTargetCost::isPaymentSet()
|
|||||||
int UnTapTargetCost::doPay()
|
int UnTapTargetCost::doPay()
|
||||||
{
|
{
|
||||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||||
source->storedCard = target;
|
source->storedCard = target->createSnapShot();
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
_target->untap();
|
_target->untap();
|
||||||
@@ -531,7 +531,7 @@ int ExileTargetCost::doPay()
|
|||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
source->storedCard = target;
|
source->storedCard = target->createSnapShot();
|
||||||
target->controller()->game->putInExile(target);
|
target->controller()->game->putInExile(target);
|
||||||
target = NULL;
|
target = NULL;
|
||||||
if (tc)
|
if (tc)
|
||||||
@@ -560,7 +560,7 @@ int BounceTargetCost::doPay()
|
|||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
source->storedCard = target;
|
source->storedCard = target->createSnapShot();
|
||||||
target->controller()->game->putInHand(target);
|
target->controller()->game->putInHand(target);
|
||||||
target = NULL;
|
target = NULL;
|
||||||
if (tc)
|
if (tc)
|
||||||
@@ -640,7 +640,7 @@ int SacrificeCost::doPay()
|
|||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
MTGCardInstance * beforeCard = target;
|
MTGCardInstance * beforeCard = target;
|
||||||
source->storedCard = target;
|
source->storedCard = target->createSnapShot();
|
||||||
target->controller()->game->putInGraveyard(target);
|
target->controller()->game->putInGraveyard(target);
|
||||||
WEvent * e = NEW WEventCardSacrifice(beforeCard,target);
|
WEvent * e = NEW WEventCardSacrifice(beforeCard,target);
|
||||||
GameObserver * game = target->owner->getObserver();
|
GameObserver * game = target->owner->getObserver();
|
||||||
@@ -882,7 +882,9 @@ int ExtraCosts::doPay()
|
|||||||
for (size_t i = 0; i < costs.size(); i++)
|
for (size_t i = 0; i < costs.size(); i++)
|
||||||
{
|
{
|
||||||
if(costs[i]->target)
|
if(costs[i]->target)
|
||||||
|
{
|
||||||
costs[i]->target->isExtraCostTarget = false;
|
costs[i]->target->isExtraCostTarget = false;
|
||||||
|
}
|
||||||
result += costs[i]->doPay();
|
result += costs[i]->doPay();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -3004,7 +3004,7 @@ int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode, Targ
|
|||||||
MTGCardInstance * testDummy = NEW MTGCardInstance();
|
MTGCardInstance * testDummy = NEW MTGCardInstance();
|
||||||
testDummy->setObserver(targetedPlyr->getObserver());
|
testDummy->setObserver(targetedPlyr->getObserver());
|
||||||
testDummy->owner = targetedPlyr;
|
testDummy->owner = targetedPlyr;
|
||||||
testDummy->storedCard = atac->source;
|
testDummy->storedSourceCard = atac->source;
|
||||||
vector<string>magictextlines = split(atac->sabilities,'_');
|
vector<string>magictextlines = split(atac->sabilities,'_');
|
||||||
if(magictextlines.size())
|
if(magictextlines.size())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,6 +51,15 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to
|
|||||||
castMethod = Constants::NOT_CAST;
|
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)
|
void MTGCardInstance::copy(MTGCardInstance * card)
|
||||||
{
|
{
|
||||||
MTGCard * source = card->model;
|
MTGCard * source = card->model;
|
||||||
@@ -81,7 +90,7 @@ void MTGCardInstance::copy(MTGCardInstance * card)
|
|||||||
int backupid = mtgid;
|
int backupid = mtgid;
|
||||||
int castMethodBackUP = this->castMethod;
|
int castMethodBackUP = this->castMethod;
|
||||||
mtgid = source->getId();
|
mtgid = source->getId();
|
||||||
MTGCardInstance * oldStored = this->storedCard;
|
MTGCardInstance * oldStored = this->storedSourceCard;
|
||||||
Spell * spell = NEW Spell(observer, this);
|
Spell * spell = NEW Spell(observer, this);
|
||||||
observer = card->observer;
|
observer = card->observer;
|
||||||
AbilityFactory af(observer);
|
AbilityFactory af(observer);
|
||||||
@@ -159,6 +168,7 @@ void MTGCardInstance::initMTGCI()
|
|||||||
coinSide = -1;
|
coinSide = -1;
|
||||||
isAttacking = NULL;
|
isAttacking = NULL;
|
||||||
storedCard = NULL;
|
storedCard = NULL;
|
||||||
|
storedSourceCard = NULL;
|
||||||
|
|
||||||
for (int i = 0; i < ManaCost::MANA_PAID_WITH_RETRACE +1; i++)
|
for (int i = 0; i < ManaCost::MANA_PAID_WITH_RETRACE +1; i++)
|
||||||
alternateCostPaid[i] = 0;
|
alternateCostPaid[i] = 0;
|
||||||
|
|||||||
@@ -475,6 +475,7 @@ MTGCardInstance * MTGGameZone::removeCard(MTGCardInstance * card, int createCopy
|
|||||||
copy->castX = card->castX;
|
copy->castX = card->castX;
|
||||||
copy->kicked = card->kicked;
|
copy->kicked = card->kicked;
|
||||||
copy->storedCard = card->storedCard;
|
copy->storedCard = card->storedCard;
|
||||||
|
copy->storedSourceCard = card->storedSourceCard;
|
||||||
|
|
||||||
//stupid bug with tokens...
|
//stupid bug with tokens...
|
||||||
if (card->model == card)
|
if (card->model == card)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
|
|||||||
{
|
{
|
||||||
manaCost = NEW ManaCost();
|
manaCost = NEW ManaCost();
|
||||||
}
|
}
|
||||||
|
manaCost->xColor = -1;
|
||||||
int state = 0;
|
int state = 0;
|
||||||
size_t start = 0;
|
size_t start = 0;
|
||||||
size_t end = 0;
|
size_t end = 0;
|
||||||
@@ -91,8 +92,27 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
|
|||||||
switch (value[0])
|
switch (value[0])
|
||||||
{
|
{
|
||||||
case 'x':
|
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;
|
break;
|
||||||
|
|
||||||
case 't': //Tap
|
case 't': //Tap
|
||||||
if (value == "t")
|
if (value == "t")
|
||||||
{
|
{
|
||||||
@@ -296,6 +316,7 @@ ManaCost::ManaCost(ManaCost * manaCost)
|
|||||||
suspend = NEW ManaCost( manaCost->suspend );
|
suspend = NEW ManaCost( manaCost->suspend );
|
||||||
|
|
||||||
extraCosts = manaCost->extraCosts ? manaCost->extraCosts->clone() : NULL;
|
extraCosts = manaCost->extraCosts ? manaCost->extraCosts->clone() : NULL;
|
||||||
|
xColor = manaCost->xColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy Constructor
|
// Copy Constructor
|
||||||
@@ -322,6 +343,7 @@ ManaCost::ManaCost(const ManaCost& manaCost)
|
|||||||
suspend = NEW ManaCost( manaCost.suspend );
|
suspend = NEW ManaCost( manaCost.suspend );
|
||||||
|
|
||||||
extraCosts = manaCost.extraCosts ? manaCost.extraCosts->clone() : NULL;
|
extraCosts = manaCost.extraCosts ? manaCost.extraCosts->clone() : NULL;
|
||||||
|
xColor = manaCost.xColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
// operator=
|
// operator=
|
||||||
@@ -341,6 +363,7 @@ ManaCost & ManaCost::operator= (const ManaCost & manaCost)
|
|||||||
FlashBack = manaCost.FlashBack;
|
FlashBack = manaCost.FlashBack;
|
||||||
morph = manaCost.morph;
|
morph = manaCost.morph;
|
||||||
suspend = manaCost.suspend;
|
suspend = manaCost.suspend;
|
||||||
|
xColor = manaCost.xColor;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -377,10 +400,34 @@ int ManaCost::hasX()
|
|||||||
DebugTrace("Seems ManaCost was not properly initialized");
|
DebugTrace("Seems ManaCost was not properly initialized");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if(xColor > 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return cost[Constants::NB_Colors];
|
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()
|
int ManaCost::hasAnotherCost()
|
||||||
{
|
{
|
||||||
if (cost.size() <= (size_t)Constants::NB_Colors)
|
if (cost.size() <= (size_t)Constants::NB_Colors)
|
||||||
@@ -501,6 +548,7 @@ void ManaCost::copy(ManaCost * _manaCost)
|
|||||||
suspend = NEW ManaCost();
|
suspend = NEW ManaCost();
|
||||||
suspend->copy(_manaCost->suspend);
|
suspend->copy(_manaCost->suspend);
|
||||||
}
|
}
|
||||||
|
xColor = _manaCost->xColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ManaCost::getCost(int color)
|
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);
|
ManaCost * result = NEW ManaCost(diff, Constants::NB_Colors + 1);
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -673,7 +673,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
|||||||
}
|
}
|
||||||
else if (typeName.compare("mystored") == 0)
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user