Added MH2 set, improved Android downloader, added/fixed primitives, improved coin flip event trigger, improved discarded attribute, improved castcard keyword (now it's possible to specify the x value in cost), improved add/remove/mod counter trigger, improved the "spent" and "converge" keyword for spell still in the stack.
This commit is contained in:
@@ -488,7 +488,7 @@ int Spell::resolve()
|
||||
if(observer->getResourceManager())
|
||||
observer->getResourceManager()->PlaySample(source->getSample());
|
||||
}
|
||||
if(this->cost)
|
||||
if(this->cost && !source->getManaCost()->getManaUsedToCast())
|
||||
{
|
||||
source->getManaCost()->setManaUsedToCast(NEW ManaCost(this->cost));
|
||||
}
|
||||
|
||||
@@ -9234,8 +9234,8 @@ AEquip * AEquip::clone() const
|
||||
}
|
||||
|
||||
// casting a card for free, or casting a copy of a card.
|
||||
AACastCard::AACastCard(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target,bool _restricted,bool _copied,bool asNormal,string _namedCard,string _name,bool _noEvent,bool putinplay,bool madness, bool alternative, int kicked, bool flipped) :
|
||||
MTGAbility(observer, _id, _source),restricted(_restricted),asCopy(_copied),normal(asNormal),cardNamed(_namedCard),nameThis(_name),noEvent(_noEvent),putinplay(putinplay), asNormalMadness(madness), alternative(alternative), kicked(kicked), flipped(flipped)
|
||||
AACastCard::AACastCard(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target,bool _restricted,bool _copied,bool asNormal,string _namedCard,string _name,bool _noEvent,bool putinplay,bool madness, bool alternative, int kicked, int costx, bool flipped) :
|
||||
MTGAbility(observer, _id, _source),restricted(_restricted),asCopy(_copied),normal(asNormal),cardNamed(_namedCard),nameThis(_name),noEvent(_noEvent),putinplay(putinplay), asNormalMadness(madness), alternative(alternative), kicked(kicked), costx(costx), flipped(flipped)
|
||||
{
|
||||
target = _target;
|
||||
andAbility = NULL;
|
||||
@@ -9441,6 +9441,18 @@ int AACastCard::resolveSpell()
|
||||
Spell * spell = NULL;
|
||||
MTGCardInstance * copy = source->controller()->game->putInZone(theNamedCard, theNamedCard->currentZone, source->controller()->game->stack);
|
||||
|
||||
if(alternative)
|
||||
copy->alternateCostPaid[ManaCost::MANA_PAID_WITH_ALTERNATIVE] = 1;
|
||||
if(kicked > 0){
|
||||
copy->alternateCostPaid[ManaCost::MANA_PAID_WITH_KICKER] = 1;
|
||||
copy->kicked = kicked;
|
||||
}
|
||||
if(costx > 0){
|
||||
copy->castX = costx;
|
||||
copy->setX = costx;
|
||||
copy->X = costx;
|
||||
}
|
||||
|
||||
if (game->targetChooser)
|
||||
{
|
||||
game->targetChooser->Owner = source->controller();
|
||||
@@ -9464,8 +9476,10 @@ int AACastCard::resolveSpell()
|
||||
}
|
||||
if (!copy->has(Constants::STORM))
|
||||
{
|
||||
copy->X = 0;
|
||||
copy->castX = copy->X;
|
||||
if(costx <= 0){
|
||||
copy->X = 0;
|
||||
copy->castX = copy->X;
|
||||
}
|
||||
}
|
||||
if(andAbility)
|
||||
{
|
||||
@@ -9514,6 +9528,11 @@ int AACastCard::resolveSpell()
|
||||
copy->alternateCostPaid[ManaCost::MANA_PAID_WITH_KICKER] = 1;
|
||||
copy->kicked = kicked;
|
||||
}
|
||||
if(costx > 0){
|
||||
copy->castX = costx;
|
||||
copy->setX = costx;
|
||||
copy->X = costx;
|
||||
}
|
||||
if (game->targetChooser)
|
||||
{
|
||||
game->targetChooser->Owner = source->controller();
|
||||
@@ -9549,8 +9568,10 @@ int AACastCard::resolveSpell()
|
||||
}
|
||||
if (!copy->has(Constants::STORM))
|
||||
{
|
||||
copy->X = _target->X;
|
||||
copy->castX = copy->X;
|
||||
if(costx <= 0){
|
||||
copy->X = _target->X;
|
||||
copy->castX = copy->X;
|
||||
}
|
||||
}
|
||||
if(andAbility)
|
||||
{
|
||||
|
||||
@@ -32,6 +32,7 @@ CardDescriptor::CardDescriptor()
|
||||
CDcontrollerDamaged = 0;
|
||||
CDdamager = 0;
|
||||
CDgeared = 0;
|
||||
CDdiscarded = 0;
|
||||
CDattached = 0;
|
||||
CDblocked = 0;
|
||||
CDcanProduceC = 0;
|
||||
@@ -291,6 +292,11 @@ MTGCardInstance * CardDescriptor::match(MTGCardInstance * card)
|
||||
match = NULL;
|
||||
}
|
||||
|
||||
if ((CDdiscarded == -1 && card->discarded) || (CDdiscarded == 1 && !card->discarded))
|
||||
{
|
||||
match = NULL;
|
||||
}
|
||||
|
||||
if ((fresh == -1 && card->fresh) || (fresh == 1 && !card->fresh))
|
||||
{
|
||||
match = NULL;
|
||||
|
||||
@@ -1568,6 +1568,18 @@ bool CardGui::FilterCard(MTGCard * _card,string filter)
|
||||
cd.hasXCost = 1;
|
||||
}
|
||||
}
|
||||
//has been discarded
|
||||
else if (attribute.find("discarded") != string::npos)
|
||||
{
|
||||
if (minus)
|
||||
{
|
||||
cd.CDdiscarded = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
cd.CDdiscarded = 1;
|
||||
}
|
||||
}
|
||||
//put in its zone this turn
|
||||
else if (attribute.find("fresh") != string::npos)
|
||||
{
|
||||
|
||||
@@ -1035,6 +1035,7 @@ void GameObserver::gameStateBasedEffects()
|
||||
{
|
||||
MTGCardInstance * card = fg->cards[k];
|
||||
card->fresh = 0; // Remove fresh attribute to cards put in graveyard last turn
|
||||
card->discarded = false; // Remove discarded attribute to cards put in graveyard last turn
|
||||
}
|
||||
MTGGameZone * fe = p->game->exile;
|
||||
for (int k = 0; k < fe->nb_cards; k++)
|
||||
|
||||
@@ -1270,6 +1270,10 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell
|
||||
flipresult = 0;
|
||||
} else if(res.size() && (res[1] == "tails" || res[1] == "tail")){
|
||||
flipresult = 1;
|
||||
} else if(res.size() && res[1] == "won"){
|
||||
flipresult = 2;
|
||||
} else if(res.size() && res[1] == "lost"){
|
||||
flipresult = 3;
|
||||
}
|
||||
string playerName = "";
|
||||
vector<string>from = parseBetween(s, "from(",")");
|
||||
@@ -1452,9 +1456,9 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell
|
||||
TargetChooser * tc = parseSimpleTC(s, "from", card);
|
||||
TargetChooser *exception = parseSimpleTC(s, "except", card); // Added a new keyword except to specify a counter add/remove exception in order to avoid counter loop (eg. Doubling Season)
|
||||
if(exception)
|
||||
return NEW TrCounter(observer, id, card, counter, tc, 1, once, duplicate, exception->source);
|
||||
return NEW TrCounter(observer, id, card, counter, tc, 1, once, duplicate, limitOnceATurn, exception->source);
|
||||
else
|
||||
return NEW TrCounter(observer, id, card, counter, tc, 1, once, duplicate);
|
||||
return NEW TrCounter(observer, id, card, counter, tc, 1, once, duplicate, limitOnceATurn);
|
||||
}
|
||||
|
||||
if (s.find("counterremoved(") != string::npos)
|
||||
@@ -1469,9 +1473,23 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell
|
||||
TargetChooser * tc = parseSimpleTC(s, "from", card);
|
||||
TargetChooser *exception = parseSimpleTC(s, "except", card); // Added a new keyword except to specify a counter add/remove exception in order to avoid counter loop (eg. Doubling Season)
|
||||
if(exception)
|
||||
return NEW TrCounter(observer, id, card, counter, tc, 0, once, duplicate, exception->source);
|
||||
return NEW TrCounter(observer, id, card, counter, tc, 0, once, duplicate, limitOnceATurn, exception->source);
|
||||
else
|
||||
return NEW TrCounter(observer, id, card, counter, tc, 0, once, duplicate);
|
||||
return NEW TrCounter(observer, id, card, counter, tc, 0, once, duplicate, limitOnceATurn);
|
||||
}
|
||||
|
||||
if (s.find("countermod(") != string::npos)
|
||||
{
|
||||
vector<string>splitCounter = parseBetween(s,"countermod(",")");
|
||||
Counter * counter = NULL;
|
||||
if(s.find("(any)") == string::npos)
|
||||
counter = parseCounter(splitCounter[1],card,NULL);
|
||||
TargetChooser * tc = parseSimpleTC(s, "from", card);
|
||||
TargetChooser *exception = parseSimpleTC(s, "except", card); // Added a new keyword except to specify a counter add/remove exception in order to avoid counter loop (eg. Doubling Season)
|
||||
if(exception)
|
||||
return NEW TrCounter(observer, id, card, counter, tc, 2, once, false, limitOnceATurn, exception->source);
|
||||
else
|
||||
return NEW TrCounter(observer, id, card, counter, tc, 2, once, false, limitOnceATurn);
|
||||
}
|
||||
|
||||
int who = 0;
|
||||
@@ -3353,8 +3371,8 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
return a;
|
||||
}
|
||||
|
||||
//cast a card without paying it's manacost
|
||||
vector<string> splitCastCard = parseBetween(s, "castcard(", ")");
|
||||
//cast a card without paying it's manacost
|
||||
vector<string> splitCastCard = parseBetween(s, "castcard(", ")");
|
||||
if (splitCastCard.size())
|
||||
{
|
||||
string builtHow = splitCastCard[1];
|
||||
@@ -3381,10 +3399,21 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
vector<string> splitCastKicked = parseBetween(splitCastCard[1], "kicked!:", ":!");
|
||||
if(splitCastKicked.size())
|
||||
{
|
||||
kicked = atoi(splitCastKicked[1].c_str());
|
||||
WParsedInt * val = NEW WParsedInt(splitCastKicked[1], NULL, card);
|
||||
kicked = val->getValue();
|
||||
}
|
||||
}
|
||||
MTGAbility *a = NEW AACastCard(observer, id, card, target,withRestrictions,asCopy,asNormal,nameCard,newName,sendNoEvent,putinplay, asNormalMadness, alternative, kicked, flipped);
|
||||
int costx = 0;
|
||||
if(splitCastCard[1].find("costx!:") != string::npos)
|
||||
{
|
||||
vector<string> splitCastCostX = parseBetween(splitCastCard[1], "costx!:", ":!");
|
||||
if(splitCastCostX.size())
|
||||
{
|
||||
WParsedInt * val = NEW WParsedInt(splitCastCostX[1], NULL, card);
|
||||
costx = val->getValue();
|
||||
}
|
||||
}
|
||||
MTGAbility *a = NEW AACastCard(observer, id, card, target,withRestrictions,asCopy,asNormal,nameCard,newName,sendNoEvent,putinplay, asNormalMadness, alternative, kicked, costx, flipped);
|
||||
a->oneShot = false;
|
||||
if(splitCastCard[1].find("trigger[to]") != string::npos)
|
||||
{
|
||||
@@ -4360,37 +4389,6 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
}
|
||||
}
|
||||
|
||||
//Change Power/Toughness
|
||||
WParsedPT * wppt = NEW WParsedPT(s, spell, card);
|
||||
bool nonstatic = false;
|
||||
if (wppt->ok)
|
||||
{
|
||||
if(s.find("nonstatic") != string::npos)
|
||||
nonstatic = true;
|
||||
if (!activated)
|
||||
{
|
||||
if (card->hasType(Subtypes::TYPE_INSTANT) || card->hasType(Subtypes::TYPE_SORCERY) || forceUEOT)
|
||||
{
|
||||
return NEW PTInstant(observer, id, card, target, wppt,s,nonstatic);
|
||||
}
|
||||
else if(s.find("cdaactive") != string::npos)
|
||||
{
|
||||
MTGAbility * a = NEW APowerToughnessModifier(observer, id, card, target, wppt,s,true);
|
||||
a->forcedAlive = 1;
|
||||
//a->forceDestroy = -1;
|
||||
return a;
|
||||
//return NEW APowerToughnessModifier(observer, id, card, target, wppt,s,true);
|
||||
}
|
||||
else
|
||||
return NEW APowerToughnessModifier(observer, id, card, target, wppt,s,nonstatic);
|
||||
}
|
||||
return NEW PTInstant(observer, id, card, target, wppt,s,nonstatic);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete wppt;
|
||||
}
|
||||
|
||||
//Mana Producer
|
||||
found = s.find("add");
|
||||
if (found != string::npos)
|
||||
@@ -4505,7 +4503,36 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
//Change Power/Toughness
|
||||
WParsedPT * wppt = NEW WParsedPT(s, spell, card);
|
||||
bool nonstatic = false;
|
||||
if (wppt->ok)
|
||||
{
|
||||
if(s.find("nonstatic") != string::npos)
|
||||
nonstatic = true;
|
||||
if (!activated)
|
||||
{
|
||||
if (card->hasType(Subtypes::TYPE_INSTANT) || card->hasType(Subtypes::TYPE_SORCERY) || forceUEOT)
|
||||
{
|
||||
return NEW PTInstant(observer, id, card, target, wppt,s,nonstatic);
|
||||
}
|
||||
else if(s.find("cdaactive") != string::npos)
|
||||
{
|
||||
MTGAbility * a = NEW APowerToughnessModifier(observer, id, card, target, wppt,s,true);
|
||||
a->forcedAlive = 1;
|
||||
//a->forceDestroy = -1;
|
||||
return a;
|
||||
//return NEW APowerToughnessModifier(observer, id, card, target, wppt,s,true);
|
||||
}
|
||||
else
|
||||
return NEW APowerToughnessModifier(observer, id, card, target, wppt,s,nonstatic);
|
||||
}
|
||||
return NEW PTInstant(observer, id, card, target, wppt,s,nonstatic);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete wppt;
|
||||
}
|
||||
|
||||
//affinity based on targetchooser
|
||||
vector<string> splitNewAffinity = parseBetween(s, "affinity(", ")");
|
||||
|
||||
@@ -525,6 +525,12 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
|
||||
if (!(copy = from->removeCard(card, doCopy)))
|
||||
return NULL; //ERROR
|
||||
|
||||
// Set the mana value used to cast this spell
|
||||
if((to == g->players[0]->game->stack || to == g->players[1]->game->stack) && card->getManaCost() && card->getManaCost()->getManaUsedToCast()){
|
||||
copy->getManaCost()->setManaUsedToCast(NEW ManaCost());
|
||||
copy->getManaCost()->getManaUsedToCast()->copy(card->getManaCost()->getManaUsedToCast());
|
||||
}
|
||||
|
||||
if(!card->hasType(Subtypes::TYPE_LEGENDARY) && copy->hasType(Subtypes::TYPE_LEGENDARY)) // This fix issue when cloning a card with nolegend option (e.g. Double Major)
|
||||
copy->removeType(Subtypes::TYPE_LEGENDARY);
|
||||
|
||||
|
||||
@@ -571,6 +571,10 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card)
|
||||
else
|
||||
{
|
||||
Spell * spell = NULL;
|
||||
if (spellCost && !card->getManaCost()->getManaUsedToCast()){
|
||||
card->getManaCost()->setManaUsedToCast(NEW ManaCost());
|
||||
card->getManaCost()->getManaUsedToCast()->copy(spellCost);
|
||||
}
|
||||
MTGCardInstance * copy = player->game->putInZone(card, card->currentZone, player->game->stack);
|
||||
if (game->targetChooser)
|
||||
{
|
||||
@@ -744,6 +748,10 @@ int MTGKickerRule::reactToClick(MTGCardInstance * card)
|
||||
else
|
||||
{
|
||||
Spell * spell = NULL;
|
||||
if (spellCost && !card->getManaCost()->getManaUsedToCast()){
|
||||
card->getManaCost()->setManaUsedToCast(NEW ManaCost());
|
||||
card->getManaCost()->getManaUsedToCast()->copy(spellCost);
|
||||
}
|
||||
MTGCardInstance * copy = player->game->putInZone(card, card->currentZone, player->game->stack);
|
||||
if (game->targetChooser)
|
||||
{
|
||||
@@ -1040,7 +1048,11 @@ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card, ManaCost *alter
|
||||
SAFE_DELETE(spell);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
if (spellCost && !card->getManaCost()->getManaUsedToCast()){
|
||||
card->getManaCost()->setManaUsedToCast(NEW ManaCost());
|
||||
card->getManaCost()->getManaUsedToCast()->copy(spellCost);
|
||||
}
|
||||
MTGCardInstance * copy = player->game->putInZone(card, card->currentZone, player->game->stack);
|
||||
game->mLayers->stackLayer()->addSpell(copy, game->targetChooser, spellCost, alternateCostType, 0);
|
||||
game->targetChooser = NULL;
|
||||
@@ -1531,6 +1543,10 @@ int MTGMorphCostRule::reactToClick(MTGCardInstance * card)
|
||||
delete previousManaPool;
|
||||
card->morphed = true;
|
||||
card->isMorphed = true;
|
||||
if (spellCost && !card->getManaCost()->getManaUsedToCast()){
|
||||
card->getManaCost()->setManaUsedToCast(NEW ManaCost());
|
||||
card->getManaCost()->getManaUsedToCast()->copy(spellCost);
|
||||
}
|
||||
MTGCardInstance * copy = player->game->putInZone(card, card->currentZone, player->game->stack);
|
||||
copy->getManaCost()->resetCosts();//Morph has no ManaCost on stack
|
||||
copy->setColor(0,1);
|
||||
|
||||
@@ -614,6 +614,18 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
cd->hasXCost = 1;
|
||||
}
|
||||
}
|
||||
//has been discarded
|
||||
else if (attribute.find("discarded") != string::npos)
|
||||
{
|
||||
if (minus)
|
||||
{
|
||||
cd->CDdiscarded = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
cd->CDdiscarded = 1;
|
||||
}
|
||||
}
|
||||
//put in its zone this turn
|
||||
else if (attribute.find("fresh") != string::npos)
|
||||
{
|
||||
|
||||
+151
-34
@@ -374,8 +374,8 @@ void WParsedInt::init(string s, Spell * spell, MTGCardInstance * card)
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
Player * p = card->getObserver()->players[i];
|
||||
MTGGameZone * zones[] = { p->game->battlefield, p->game->graveyard, p->game->hand, p->game->library, p->game->exile };
|
||||
for (int k = 0; k < 5; k++)
|
||||
MTGGameZone * zones[] = { p->game->battlefield, p->game->graveyard, p->game->hand, p->game->library, p->game->exile, p->game->reveal };
|
||||
for (int k = 0; k < 6; k++)
|
||||
{
|
||||
MTGGameZone * zone = zones[k];
|
||||
if(tc->targetsZone(zone,target))
|
||||
@@ -877,32 +877,6 @@ void WParsedInt::init(string s, Spell * spell, MTGCardInstance * card)
|
||||
intValue += card->controller()->game->graveyard->cards[j]->myconvertedcost;
|
||||
}
|
||||
}
|
||||
else if (s == "gravecardtypes")//Tarmogoyf
|
||||
{
|
||||
intValue = 0;
|
||||
int pc = 0, tc = 0, sc = 0, lc = 0, ic = 0, ec = 0, cc = 0, ac = 0;
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
MTGGameZone * checkZone = card->getObserver()->players[j]->game->graveyard;
|
||||
if(cardHasTypeinZone("planeswalker",checkZone))
|
||||
pc = 1;
|
||||
if(cardHasTypeinZone("tribal",checkZone))
|
||||
tc = 1;
|
||||
if(cardHasTypeinZone("sorcery",checkZone))
|
||||
sc = 1;
|
||||
if(cardHasTypeinZone("land",checkZone))
|
||||
lc = 1;
|
||||
if(cardHasTypeinZone("instant",checkZone))
|
||||
ic = 1;
|
||||
if(cardHasTypeinZone("enchantment",checkZone))
|
||||
ec = 1;
|
||||
if(cardHasTypeinZone("creature",checkZone))
|
||||
cc = 1;
|
||||
if(cardHasTypeinZone("artifact",checkZone))
|
||||
ac = 1;
|
||||
}
|
||||
intValue = pc+tc+sc+lc+ic+ec+cc+ac;
|
||||
}
|
||||
else if (s == "powertotalinplay")//Count Total Power of Creatures you control... Formidable
|
||||
{
|
||||
intValue = 0;
|
||||
@@ -1035,10 +1009,6 @@ void WParsedInt::init(string s, Spell * spell, MTGCardInstance * card)
|
||||
else
|
||||
intValue = card->revealedLast->getManaCost()->getConvertedCost();
|
||||
}
|
||||
else if (s == "scryedcards")//returns how many card have been scryed from current card
|
||||
{
|
||||
intValue = card->scryedCards;
|
||||
}
|
||||
else if (s.find("findfirsttype") != string::npos)//find the index of first card with specified type in target player library
|
||||
{
|
||||
intValue = 0;
|
||||
@@ -1068,9 +1038,33 @@ void WParsedInt::init(string s, Spell * spell, MTGCardInstance * card)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(!intValue)//found nothing, try parsing a atoi
|
||||
else if (s == "scryedcards" || s == "numoftypes")//returns how many card have been scryed from current card -- returns the number of types of the card
|
||||
{
|
||||
intValue = atoi(s.c_str());
|
||||
if(s == "scryedcards")
|
||||
intValue = card->scryedCards;
|
||||
else {
|
||||
intValue = 0;
|
||||
if(card->hasType(Subtypes::TYPE_PLANESWALKER))
|
||||
intValue++;
|
||||
if(card->hasType(Subtypes::TYPE_TRIBAL))
|
||||
intValue++;
|
||||
if(card->hasType(Subtypes::TYPE_SORCERY))
|
||||
intValue++;
|
||||
if(card->hasType(Subtypes::TYPE_LAND))
|
||||
intValue++;
|
||||
if(card->hasType(Subtypes::TYPE_INSTANT))
|
||||
intValue++;
|
||||
if(card->hasType(Subtypes::TYPE_ENCHANTMENT))
|
||||
intValue++;
|
||||
if(card->hasType(Subtypes::TYPE_CREATURE))
|
||||
intValue++;
|
||||
if(card->hasType(Subtypes::TYPE_ARTIFACT))
|
||||
intValue++;
|
||||
}
|
||||
}
|
||||
else //Continue parsing in another method to avoid compiler C1061 error.
|
||||
{
|
||||
extendedParse(s, spell, card);
|
||||
}
|
||||
if (intValue > 0)//dont divide by 0 the rest are valid.
|
||||
{
|
||||
@@ -1111,6 +1105,129 @@ void WParsedInt::init(string s, Spell * spell, MTGCardInstance * card)
|
||||
intValue *= multiplier;
|
||||
}
|
||||
|
||||
void WParsedInt::extendedParse(string s, Spell * spell, MTGCardInstance * card)
|
||||
{
|
||||
if (s == "mybattlefieldcardtypes" || s == "oppbattlefieldcardtypes" || s == "allbattlefieldcardtypes")//Count number of card types on battlefield
|
||||
{
|
||||
intValue = 0;
|
||||
int pc = 0, tc = 0, sc = 0, lc = 0, ic = 0, ec = 0, cc = 0, ac = 0;
|
||||
if(s == "allbattlefieldcardtypes") {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
MTGGameZone * checkZone = card->getObserver()->players[j]->game->inPlay;
|
||||
if(cardHasTypeinZone("planeswalker",checkZone))
|
||||
pc = 1;
|
||||
if(cardHasTypeinZone("tribal",checkZone))
|
||||
tc = 1;
|
||||
if(cardHasTypeinZone("sorcery",checkZone))
|
||||
sc = 1;
|
||||
if(cardHasTypeinZone("land",checkZone))
|
||||
lc = 1;
|
||||
if(cardHasTypeinZone("instant",checkZone))
|
||||
ic = 1;
|
||||
if(cardHasTypeinZone("enchantment",checkZone))
|
||||
ec = 1;
|
||||
if(cardHasTypeinZone("creature",checkZone))
|
||||
cc = 1;
|
||||
if(cardHasTypeinZone("artifact",checkZone))
|
||||
ac = 1;
|
||||
}
|
||||
} else {
|
||||
MTGGameZone * checkZone = (s.find("oppbattlefieldcardtypes")!=string::npos)?card->getObserver()->opponent()->game->inPlay:card->controller()->game->inPlay;
|
||||
if(cardHasTypeinZone("planeswalker",checkZone))
|
||||
pc = 1;
|
||||
if(cardHasTypeinZone("tribal",checkZone))
|
||||
tc = 1;
|
||||
if(cardHasTypeinZone("sorcery",checkZone))
|
||||
sc = 1;
|
||||
if(cardHasTypeinZone("land",checkZone))
|
||||
lc = 1;
|
||||
if(cardHasTypeinZone("instant",checkZone))
|
||||
ic = 1;
|
||||
if(cardHasTypeinZone("enchantment",checkZone))
|
||||
ec = 1;
|
||||
if(cardHasTypeinZone("creature",checkZone))
|
||||
cc = 1;
|
||||
if(cardHasTypeinZone("artifact",checkZone))
|
||||
ac = 1;
|
||||
}
|
||||
intValue = pc+tc+sc+lc+ic+ec+cc+ac;
|
||||
}
|
||||
else if (s == "mygravecardtypes" || s == "oppgravecardtypes" || s == "allgravecardtypes")//Count number of card types in graveyards
|
||||
{
|
||||
intValue = 0;
|
||||
int pc = 0, tc = 0, sc = 0, lc = 0, ic = 0, ec = 0, cc = 0, ac = 0;
|
||||
if(s == "allgravecardtypes") {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
MTGGameZone * checkZone = card->getObserver()->players[j]->game->graveyard;
|
||||
if(cardHasTypeinZone("planeswalker",checkZone))
|
||||
pc = 1;
|
||||
if(cardHasTypeinZone("tribal",checkZone))
|
||||
tc = 1;
|
||||
if(cardHasTypeinZone("sorcery",checkZone))
|
||||
sc = 1;
|
||||
if(cardHasTypeinZone("land",checkZone))
|
||||
lc = 1;
|
||||
if(cardHasTypeinZone("instant",checkZone))
|
||||
ic = 1;
|
||||
if(cardHasTypeinZone("enchantment",checkZone))
|
||||
ec = 1;
|
||||
if(cardHasTypeinZone("creature",checkZone))
|
||||
cc = 1;
|
||||
if(cardHasTypeinZone("artifact",checkZone))
|
||||
ac = 1;
|
||||
}
|
||||
} else {
|
||||
MTGGameZone * checkZone = (s.find("oppgravecardtypes")!=string::npos)?card->getObserver()->opponent()->game->graveyard:card->controller()->game->graveyard;
|
||||
if(cardHasTypeinZone("planeswalker",checkZone))
|
||||
pc = 1;
|
||||
if(cardHasTypeinZone("tribal",checkZone))
|
||||
tc = 1;
|
||||
if(cardHasTypeinZone("sorcery",checkZone))
|
||||
sc = 1;
|
||||
if(cardHasTypeinZone("land",checkZone))
|
||||
lc = 1;
|
||||
if(cardHasTypeinZone("instant",checkZone))
|
||||
ic = 1;
|
||||
if(cardHasTypeinZone("enchantment",checkZone))
|
||||
ec = 1;
|
||||
if(cardHasTypeinZone("creature",checkZone))
|
||||
cc = 1;
|
||||
if(cardHasTypeinZone("artifact",checkZone))
|
||||
ac = 1;
|
||||
}
|
||||
intValue = pc+tc+sc+lc+ic+ec+cc+ac;
|
||||
}
|
||||
else if (s.find("totcnt") != string::npos) //Return the total amount of all specific counters on each card (use "anycnt" to count all of them e.g. Deepwood Denizen)
|
||||
{
|
||||
intValue = 0;
|
||||
for (int j = card->controller()->game->inPlay->nb_cards - 1; j >= 0; --j){
|
||||
if ((s.find("totcntcre") != string::npos || s.find("totcntall") != string::npos) && card->controller()->game->inPlay->cards[j]->hasType(Subtypes::TYPE_CREATURE)){
|
||||
if (card->controller()->game->inPlay->cards[j]->counters){
|
||||
Counters * counters = card->controller()->game->inPlay->cards[j]->counters;
|
||||
for(size_t i = 0; i < counters->counters.size(); ++i){
|
||||
Counter * counter = counters->counters[i];
|
||||
if(s.substr(9) == "anycnt"){
|
||||
intValue += counter->nb;
|
||||
} else if(counter->name == "" && (s.substr(9) == "11" || s.substr(9) == "-1-1")){
|
||||
if((counter->power == 1 && counter->toughness == 1 && s.substr(9) == "11") || (counter->power == -1 && counter->toughness == -1 && s.substr(9) == "-1-1")){
|
||||
intValue += counter->nb;
|
||||
break;
|
||||
}
|
||||
} else if(counter->name == s.substr(9)){
|
||||
intValue += counter->nb;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(!intValue)//found nothing, try parsing a atoi
|
||||
{
|
||||
intValue = atoi(s.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
int WParsedInt::countDevotionTo(MTGCardInstance * card, MTGGameZone * zone, int color1, int color2)
|
||||
{
|
||||
int counthybrid = 0;
|
||||
|
||||
Reference in New Issue
Block a user