From fb9b0b8166fad3d276c7afb9b3944d506845fd9a Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Sat, 12 Sep 2015 19:37:35 +0800 Subject: [PATCH 01/14] Added Konda's Banner --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 635d12de9..79db499c3 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -52665,6 +52665,15 @@ power=3 toughness=3 [/card] [card] +name=Konda's Banner +auto={2}:equip target(creature[legendary]|mybattlefield) +auto=teach(creature) transforms((,newability[lord(creature[share!color!]) 1/1],newability[lord(creature[share!types!]) 1/1])) +text=Konda's Banner can be attached only to a legendary creature. -- Creatures that share a color with equipped creature get +1/+1. -- Creatures that share a creature type with equipped creature get +1/+1. -- Equip {2} +mana={2} +type=Legendary Artifact +subtype=Equipment +[/card] +[card] name=Konda's Hatamoto auto=bushido(1/1) auto=aslongas(samurai[legendary]|mybattlefield) 1/2 From 59792b3456f4836f222954d467a078f449a54dcb Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Sat, 12 Sep 2015 19:58:09 +0800 Subject: [PATCH 02/14] X in manacost is always 0 except on the stack --- projects/mtg/include/AllAbilities.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 6bf905528..4c9d88e33 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -170,7 +170,10 @@ private: } else if (s == "manacost") { - intValue = target->getManaCost()->getConvertedCost(); + if (target->currentZone == target->controller()->game->stack)//X is 0 except if it's on the stack + intValue = target->getManaCost()->getConvertedCost() + target->castX; + else + intValue = target->getManaCost()->getConvertedCost(); } else if (s == "azorius")//devotion blue white { From 72aaa18a35a17b344166c09a24e9128196dbc841 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Tue, 15 Sep 2015 06:35:07 +0800 Subject: [PATCH 03/14] CDA CDA works by using "cdaactive" keyword on PT changes. Instead of granting bonus, we modify the orig power and toughness since they are dynamic PT. cdaactive are for cards like maro, tarmogoyf, etc. To Follow/To Do: Additional Tests and other bug fix --- projects/mtg/include/AllAbilities.h | 131 +++++++++++++++++++++++---- projects/mtg/src/MTGAbility.cpp | 9 +- projects/mtg/src/MTGCardInstance.cpp | 10 +- 3 files changed, 124 insertions(+), 26 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 4c9d88e33..a3ec7c5f3 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -642,6 +642,81 @@ private: { intValue = target->controller()->opponent()->game->hand->nb_cards; } + else if (s == "pgbzombie")//Soulless One + { + intValue = 0; + for (int i = 0; i < 2; i++) + { + Player * p = card->getObserver()->players[i]; + for (int j = p->game->graveyard->nb_cards - 1; j >= 0; --j) + { + if (p->game->graveyard->cards[j]->hasType("zombie")) + { + intValue += 1; + } + } + for (int j = p->game->inPlay->nb_cards - 1; j >= 0; --j) + { + if (p->game->inPlay->cards[j]->hasType("zombie")) + { + intValue += 1; + } + } + } + } + else if (s == "pginstantsorcery")//Spellheart Chimera + { + intValue = 0; + for (int j = card->controller()->game->graveyard->nb_cards - 1; j >= 0; --j) + { + if (card->controller()->game->graveyard->cards[j]->hasType(Subtypes::TYPE_INSTANT) + ||card->controller()->game->graveyard->cards[j]->hasType(Subtypes::TYPE_SORCERY)) + { + intValue += 1; + } + } + } + else if (s == "gravecardtypes")//Tarmogoyf + { + intValue = 0; + bool art, cre, enc, ins, lnd, sor, trb, pwk = false; + for (int i = 0; i < 2; i++) + { + Player * p = card->getObserver()->players[i]; + if(p->game->graveyard->hasType("planeswalker")) + pwk = true; + if(p->game->graveyard->hasType("tribal")) + trb = true; + if(p->game->graveyard->hasType("sorcery")) + sor = true; + if(p->game->graveyard->hasType("land")) + lnd = true; + if(p->game->graveyard->hasType("instant")) + ins = true; + if(p->game->graveyard->hasType("enchantment")) + enc = true; + if(p->game->graveyard->hasType("creature")) + cre = true; + if(p->game->graveyard->hasType("artifact")) + art = true; + } + if (art) + intValue += 1; + if (cre) + intValue += 1; + if (enc) + intValue += 1; + if (ins) + intValue += 1; + if (lnd) + intValue += 1; + if (sor) + intValue += 1; + if (trb) + intValue += 1; + if (pwk) + intValue += 1; + } else if (s == "morethanfourcards") { if(card->playerTarget) @@ -2253,30 +2328,37 @@ public: WParsedPT * wppt; string PT; bool nonstatic; + bool cda; APowerToughnessModifier(GameObserver* observer, int id, MTGCardInstance * _source, MTGCardInstance * _target, WParsedPT * wppt,string PT,bool nonstatic) : MTGAbility(observer, id, _source, _target), wppt(wppt),PT(PT),nonstatic(nonstatic) { aType = MTGAbility::STANDARD_PUMP; - } - - void Update(float) + cda = PT.find("cdaactive") != string::npos; + } + void Update(float) + { + if(!nonstatic) + return; + if(!((MTGCardInstance *) target)->isSettingBase) { - if(!nonstatic) - return; - ((MTGCardInstance *) target)->pbonus -= wppt->power.getValue(); - ((MTGCardInstance *) target)->tbonus -= wppt->toughness.getValue(); - ((MTGCardInstance *) target)->applyPTL(); + ((MTGCardInstance *) target)->power -= wppt->power.getValue(); + ((MTGCardInstance *) target)->addToToughness(-wppt->toughness.getValue()); if(PT.size()) { SAFE_DELETE(wppt); wppt = NEW WParsedPT(PT,NULL,(MTGCardInstance *) source); } MTGCardInstance * _target = (MTGCardInstance *) target; - _target->pbonus += wppt->power.getValue(); - _target->tbonus += wppt->toughness.getValue(); - _target->applyPTL(); + _target->power += wppt->power.getValue(); + _target->addToToughness(wppt->toughness.getValue()); + //update + if(cda) + {//7a update wppt + _target->origpower = wppt->power.getValue(); + _target->origtoughness = wppt->toughness.getValue(); + } } - + } int addToGame() { MTGCardInstance * _target = (MTGCardInstance *) target; @@ -2285,21 +2367,36 @@ public: SAFE_DELETE(wppt); wppt = NEW WParsedPT(PT,NULL,(MTGCardInstance *) source); } - _target->pbonus += wppt->power.getValue(); - _target->tbonus += wppt->toughness.getValue(); - _target->applyPTL(); + if(cda) + {//Characteristic-defining abilities + _target->origpower = wppt->power.getValue(); + _target->origtoughness = wppt->toughness.getValue(); + _target->applyPTL(); + } + else + { + _target->pbonus += wppt->power.getValue(); + _target->tbonus += wppt->toughness.getValue(); + _target->applyPTL(); + } if(_target->has(Constants::INDESTRUCTIBLE) && wppt->toughness.getValue() < 0 && _target->toughness <= 0) { _target->controller()->game->putInGraveyard(_target); } return MTGAbility::addToGame(); } - int destroy() { + if(cda) + { + ; + } + else + { ((MTGCardInstance *) target)->pbonus -= wppt->power.getValue(); ((MTGCardInstance *) target)->tbonus -= wppt->toughness.getValue(); ((MTGCardInstance *) target)->applyPTL(); + } return 1; } const string getMenuText() @@ -2318,12 +2415,10 @@ public: a->wppt = NEW WParsedPT(*(a->wppt)); return a; } - ~APowerToughnessModifier() { delete (wppt); } - }; class GenericInstantAbility: public InstantAbility, public NestedAbility diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 0c0e2dd00..68afc32f0 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -2629,7 +2629,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG int MaxOpponent = atoi(rampageParameters[1].c_str()); return NEW ARampageAbility(observer, id, card, power, toughness, MaxOpponent); } - + //evole if (s.find("evolve") != string::npos) { @@ -2924,7 +2924,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG { return NEW PTInstant(observer, id, card, target, wppt,s,nonstatic); } - return NEW APowerToughnessModifier(observer, id, card, target, wppt,s,nonstatic); + else if(s.find("cdaactive") != string::npos) + { + 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); } diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 373c2d85a..6901738f5 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -68,7 +68,7 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to void MTGCardInstance::applyPTL() { - //7a ??how to add cda(Characteristic Defining Ability)?? + //7a ??(Characteristic Defining Ability)?? power = origpower; toughness = origtoughness; //7b @@ -80,17 +80,15 @@ void MTGCardInstance::applyPTL() //7c - 7d shared? power += pbonus; toughness += tbonus; - life = toughness; //7e switch is last if (isPTswitch) { oldP = power; oldT = toughness; - this->addToToughness(oldP); - this->addToToughness(-oldT); - this->power = oldT; + toughness = oldP; + power = oldT; } - /* end */ + life = toughness; doDamageTest = 1; } From 6aab17d0b35d5409c79a62c10f25dea6c8a4c21f Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Wed, 16 Sep 2015 06:42:02 +0800 Subject: [PATCH 04/14] CDA complete This fixes the bug I introduced lst time. The damage was not taking into account, but this time the damage reflects... TODO/TOFOLLOW: update test and update all cards that uses CDA :) --- projects/mtg/include/AllAbilities.h | 115 +++++++++++++------------ projects/mtg/include/MTGCardInstance.h | 5 -- projects/mtg/src/AllAbilities.cpp | 30 ++++--- projects/mtg/src/Counters.cpp | 10 ++- projects/mtg/src/MTGAbility.cpp | 16 ++-- projects/mtg/src/MTGCardInstance.cpp | 28 ------ 6 files changed, 94 insertions(+), 110 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index a3ec7c5f3..49d29f760 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -679,43 +679,28 @@ private: else if (s == "gravecardtypes")//Tarmogoyf { intValue = 0; - bool art, cre, enc, ins, lnd, sor, trb, pwk = false; + int art, cre, enc, ins, lnd, sor, trb, pwk = 0; for (int i = 0; i < 2; i++) { Player * p = card->getObserver()->players[i]; if(p->game->graveyard->hasType("planeswalker")) - pwk = true; + pwk = 1; if(p->game->graveyard->hasType("tribal")) - trb = true; + trb = 1; if(p->game->graveyard->hasType("sorcery")) - sor = true; + sor = 1; if(p->game->graveyard->hasType("land")) - lnd = true; + lnd = 1; if(p->game->graveyard->hasType("instant")) - ins = true; + ins = 1; if(p->game->graveyard->hasType("enchantment")) - enc = true; + enc = 1; if(p->game->graveyard->hasType("creature")) - cre = true; + cre = 1; if(p->game->graveyard->hasType("artifact")) - art = true; + art = 1; } - if (art) - intValue += 1; - if (cre) - intValue += 1; - if (enc) - intValue += 1; - if (ins) - intValue += 1; - if (lnd) - intValue += 1; - if (sor) - intValue += 1; - if (trb) - intValue += 1; - if (pwk) - intValue += 1; + intValue = art + cre + enc + ins + lnd + sor + trb + pwk; } else if (s == "morethanfourcards") { @@ -2339,24 +2324,28 @@ public: { if(!nonstatic) return; - if(!((MTGCardInstance *) target)->isSettingBase) + if(!cda) { ((MTGCardInstance *) target)->power -= wppt->power.getValue(); ((MTGCardInstance *) target)->addToToughness(-wppt->toughness.getValue()); if(PT.size()) - { - SAFE_DELETE(wppt); - wppt = NEW WParsedPT(PT,NULL,(MTGCardInstance *) source); - } + { + SAFE_DELETE(wppt); + wppt = NEW WParsedPT(PT,NULL,(MTGCardInstance *) source); + } MTGCardInstance * _target = (MTGCardInstance *) target; _target->power += wppt->power.getValue(); _target->addToToughness(wppt->toughness.getValue()); - //update - if(cda) - {//7a update wppt - _target->origpower = wppt->power.getValue(); - _target->origtoughness = wppt->toughness.getValue(); - } + } + else + {//CDA 7a update wppt + if(PT.size()) + { + SAFE_DELETE(wppt); + wppt = NEW WParsedPT(PT,NULL,(MTGCardInstance *) source); + } + ((MTGCardInstance *) target)->origpower = wppt->power.getValue(); + ((MTGCardInstance *) target)->origtoughness = wppt->toughness.getValue(); } } int addToGame() @@ -2369,15 +2358,23 @@ public: } if(cda) {//Characteristic-defining abilities - _target->origpower = wppt->power.getValue(); - _target->origtoughness = wppt->toughness.getValue(); - _target->applyPTL(); + _target->origpower = wppt->power.getValue();//set orig pt + _target->origtoughness = wppt->toughness.getValue(); + _target->power -= _target->pbonus;//remove current bonuses + _target->addToToughness(-_target->tbonus); + _target->setPower(_target->origpower);//update PT + _target->setToughness(_target->origtoughness); + _target->power += _target->pbonus;//add new bonus + _target->addToToughness(_target->tbonus); } else { - _target->pbonus += wppt->power.getValue(); + _target->power -= _target->pbonus;//remove current bonuses + _target->addToToughness(-_target->tbonus); + _target->pbonus += wppt->power.getValue();//update bonus _target->tbonus += wppt->toughness.getValue(); - _target->applyPTL(); + _target->power += _target->pbonus;//add new bonus + _target->addToToughness(_target->tbonus); } if(_target->has(Constants::INDESTRUCTIBLE) && wppt->toughness.getValue() < 0 && _target->toughness <= 0) { @@ -2393,9 +2390,12 @@ public: } else { + ((MTGCardInstance *) target)->power -= ((MTGCardInstance *) target)->pbonus; + ((MTGCardInstance *) target)->addToToughness(-((MTGCardInstance *) target)->tbonus); ((MTGCardInstance *) target)->pbonus -= wppt->power.getValue(); ((MTGCardInstance *) target)->tbonus -= wppt->toughness.getValue(); - ((MTGCardInstance *) target)->applyPTL(); + ((MTGCardInstance *) target)->power += ((MTGCardInstance *) target)->pbonus; + ((MTGCardInstance *) target)->addToToughness(((MTGCardInstance *) target)->tbonus); } return 1; } @@ -4129,6 +4129,8 @@ string menu; class ASwapPT: public InstantAbility { public: + int oldP; + int oldT; ASwapPT(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target) : InstantAbility(observer, _id, _source, _target) { @@ -4143,12 +4145,11 @@ public: while (_target->next) _target = _target->next; //This is for cards such as rampant growth - if(_target->isPTswitch) - _target->isPTswitch = false; - else - _target->isPTswitch = true; - - _target->applyPTL(); + oldP = _target->power; + oldT = _target->toughness; + _target->addToToughness(oldP); + _target->addToToughness(-oldT); + _target->setPower(oldT); } return 1; } @@ -4161,9 +4162,11 @@ public: while (_target->next) _target = _target->next; //This is for cards such as rampant growth - _target->isPTswitch = false; - - _target->applyPTL(); + oldP = _target->power; + oldT = _target->toughness; + _target->addToToughness(oldP); + _target->addToToughness(-oldT); + _target->setPower(oldT); } return 1; @@ -5745,17 +5748,23 @@ public: { nbOpponents = source->blockers.size(); if (nbOpponents <= MaxOpponent) return 0; + source->power -= source->pbonus; + source->addToToughness(-source->tbonus); source->pbonus += PowerModifier * (nbOpponents - MaxOpponent); source->tbonus += ToughnessModifier * (nbOpponents - MaxOpponent); - source->applyPTL(); + source->power += source->pbonus; + source->addToToughness(source->tbonus); } else if (WEventPhaseChange* pe = dynamic_cast(event)) { if (MTG_PHASE_AFTER_EOT == pe->to->id && nbOpponents > MaxOpponent) { + source->power -= source->pbonus; + source->addToToughness(-source->tbonus); source->pbonus -= PowerModifier * (nbOpponents - MaxOpponent); source->tbonus -= ToughnessModifier * (nbOpponents - MaxOpponent); - source->applyPTL(); + source->power += source->pbonus; + source->addToToughness(source->tbonus); nbOpponents = 0; } } diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index fa7ad35e6..0ecd3b749 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -186,11 +186,6 @@ public: int addToToughness(int value); int setToughness(int value); - bool isSettingBase; - bool isPTswitch; - int oldP; - int oldT; - void applyPTL(); vectorprotections; int addProtection(TargetChooser * tc); diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index f5d54aae1..0e6f192d8 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -4181,19 +4181,23 @@ for (it = types.begin(); it != types.end(); it++) } } if(newpowerfound ) - {//setting p/t only overrides base p/t as of M15 changes + { WParsedInt * val = NEW WParsedInt(newpower,NULL, source); _target->basepower = val->getValue(); - _target->isSettingBase = true; - _target->applyPTL(); + _target->power -= _target->pbonus; + _target->power = (_target->power + _target->basepower) - _target->power; + _target->power += _target->pbonus; delete val; } if(newtoughnessfound ) - {//setting p/t only overrides base p/t as of M15 changes + {//we should consider the damage if there is, if you have a 5/5 creature with 1 damage, + //and you turn it into 1/1, the 1 damage is still there and the creature must die... + //the toughness is intact but what we see in the game is the life... WParsedInt * val = NEW WParsedInt(newtoughness,NULL, source); _target->basetoughness = val->getValue(); - _target->isSettingBase = true; - _target->applyPTL(); + _target->addToToughness(-_target->tbonus); + _target->addToToughness(_target->basetoughness - _target->toughness); + _target->addToToughness(_target->tbonus); delete val; } @@ -4279,16 +4283,20 @@ int ATransformer::destroy() } if(newpowerfound ) - {//override since we changed tha base, the bonus must have changed - _target->isSettingBase = false; + { + _target->power -= _target->pbonus; + _target->power += _target->origpower; + _target->power -= _target->basepower; + _target->power += _target->pbonus; _target->basepower = _target->origpower; - _target->applyPTL(); } if(newtoughnessfound ) { - _target->isSettingBase = false; + _target->addToToughness(-_target->tbonus); + _target->addToToughness(_target->origtoughness); + _target->addToToughness(-_target->basetoughness); + _target->addToToughness(_target->tbonus); _target->basetoughness = _target->origtoughness; - _target->applyPTL(); } if(newAbilityFound) { diff --git a/projects/mtg/src/Counters.cpp b/projects/mtg/src/Counters.cpp index bd76e6ff0..25f1f90a5 100644 --- a/projects/mtg/src/Counters.cpp +++ b/projects/mtg/src/Counters.cpp @@ -56,9 +56,12 @@ int Counter::added() { if (power != 0 || toughness != 0) { + target->power -= target->pbonus; + target->addToToughness(-target->tbonus); target->pbonus += power; target->tbonus += toughness; - target->applyPTL(); + target->power += target->pbonus; + target->addToToughness(target->pbonus); } return 1; } @@ -67,9 +70,12 @@ int Counter::removed() { if (power != 0 || toughness != 0) { + target->power -= target->pbonus; + target->addToToughness(-target->tbonus); target->pbonus -= power; target->tbonus -= toughness; - target->applyPTL(); + target->power += target->pbonus; + target->addToToughness(target->pbonus); } return 1; } diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 68afc32f0..653104756 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -3602,9 +3602,9 @@ int AbilityFactory::getAbilities(vector * v, Spell * spell, MTGCar if(card->previous && card->previous->morphed && !card->turningOver) { magicText = card->magicTexts["facedown"]; - card->basepower = 2; + card->power = 2; card->life = 2; - card->basetoughness = 2; + card->toughness = 2; card->setColor(0,1); card->name = "Morph"; card->types.clear(); @@ -3612,17 +3612,12 @@ int AbilityFactory::getAbilities(vector * v, Spell * spell, MTGCar card->setType(cre.c_str()); card->basicAbilities.reset(); card->getManaCost()->resetCosts(); - card->isSettingBase = true; - card->applyPTL(); } else if(card && !card->morphed && card->turningOver) { - card->isSettingBase = false; - card->power = card->origpower; - card->basepower = card->origpower; - card->life = card->origtoughness; - card->toughness = card->origtoughness; - card->basetoughness = card->origtoughness; + card->power += card->origpower-2; + card->life += card->origtoughness-2; + card->toughness += card->origtoughness-2; card->setColor(0,1); card->name = card->model->data->name; card->types = card->model->data->types; @@ -3636,7 +3631,6 @@ int AbilityFactory::getAbilities(vector * v, Spell * spell, MTGCar string faceupC= card->magicTexts["faceup"]; magicText.append("\n"); magicText.append(faceupC); - card->applyPTL(); } else if(card && card->hasType(Subtypes::TYPE_EQUIPMENT) && card->target) diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 6901738f5..da3e4e666 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -53,8 +53,6 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to thatmuch = 0; flanked = 0; castMethod = Constants::NOT_CAST; - isSettingBase = false; - isPTswitch = false; } MTGCardInstance * MTGCardInstance::createSnapShot() @@ -66,32 +64,6 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to return snapShot; } -void MTGCardInstance::applyPTL() -{ - //7a ??(Characteristic Defining Ability)?? - power = origpower; - toughness = origtoughness; - //7b - if (isSettingBase) - { - power = basepower; - toughness = basetoughness; - } - //7c - 7d shared? - power += pbonus; - toughness += tbonus; - //7e switch is last - if (isPTswitch) - { - oldP = power; - oldT = toughness; - toughness = oldP; - power = oldT; - } - life = toughness; - doDamageTest = 1; -} - void MTGCardInstance::copy(MTGCardInstance * card) { MTGCard * source = card->model; From db649ddc96e0fc020b4c1b75b42630a04ee0538e Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Wed, 16 Sep 2015 09:34:32 +0800 Subject: [PATCH 05/14] Added Update on CDA This controls whether to update Power and Toughness if we are setting base PT or not. If we are setting base PT update the CDA but it will not be applied since we have an effect that sets PT to a default base. If there are no effect that sets base PT, apply it on CDA using current/updated PT. The buffs are not affected. Yeah... --- projects/mtg/include/AllAbilities.h | 14 +++++++------- projects/mtg/include/MTGCardInstance.h | 1 + projects/mtg/src/AllAbilities.cpp | 5 +++++ projects/mtg/src/MTGCardInstance.cpp | 1 + 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 49d29f760..f502bffae 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -2324,7 +2324,7 @@ public: { if(!nonstatic) return; - if(!cda) + if(!cda || (cda && (((MTGCardInstance *) target)->isSettingBase < 1))) { ((MTGCardInstance *) target)->power -= wppt->power.getValue(); ((MTGCardInstance *) target)->addToToughness(-wppt->toughness.getValue()); @@ -2337,8 +2337,8 @@ public: _target->power += wppt->power.getValue(); _target->addToToughness(wppt->toughness.getValue()); } - else - {//CDA 7a update wppt + if(cda) + {//update but not apply if(PT.size()) { SAFE_DELETE(wppt); @@ -2385,11 +2385,11 @@ public: int destroy() { if(cda) - { - ; + { + ; } - else - { + else + { ((MTGCardInstance *) target)->power -= ((MTGCardInstance *) target)->pbonus; ((MTGCardInstance *) target)->addToToughness(-((MTGCardInstance *) target)->tbonus); ((MTGCardInstance *) target)->pbonus -= wppt->power.getValue(); diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index 0ecd3b749..38a4a5cd0 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -186,6 +186,7 @@ public: int addToToughness(int value); int setToughness(int value); + int isSettingBase; vectorprotections; int addProtection(TargetChooser * tc); diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 0e6f192d8..354e45608 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -4180,6 +4180,8 @@ for (it = types.begin(); it != types.end(); it++) } } } + if(newpowerfound || newtoughnessfound) + _target->isSettingBase += 1; if(newpowerfound ) { WParsedInt * val = NEW WParsedInt(newpower,NULL, source); @@ -4281,6 +4283,9 @@ int ATransformer::destroy() { _target->setColor(*it); } + + if(newpowerfound || newtoughnessfound) + _target->isSettingBase -= 1; if(newpowerfound ) { diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index da3e4e666..6a9a7d8a0 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -53,6 +53,7 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to thatmuch = 0; flanked = 0; castMethod = Constants::NOT_CAST; + isSettingBase = 0; } MTGCardInstance * MTGCardInstance::createSnapShot() From 8e057379cea1e4f8e3ad6bb1511def1f4ba54e49 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Wed, 16 Sep 2015 10:45:43 +0800 Subject: [PATCH 06/14] Finally Fixed... :) The issue last commit was the toughness is refreshed and the damage is not reflected. This commit fixes the bug. Yey... --- projects/mtg/include/AllAbilities.h | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index f502bffae..7f5435397 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -2345,7 +2345,7 @@ public: wppt = NEW WParsedPT(PT,NULL,(MTGCardInstance *) source); } ((MTGCardInstance *) target)->origpower = wppt->power.getValue(); - ((MTGCardInstance *) target)->origtoughness = wppt->toughness.getValue(); + ((MTGCardInstance *) target)->origtoughness = (wppt->toughness.getValue() + ((MTGCardInstance *) target)->life)-((MTGCardInstance *) target)->life;//what? } } int addToGame() @@ -2359,9 +2359,7 @@ public: if(cda) {//Characteristic-defining abilities _target->origpower = wppt->power.getValue();//set orig pt - _target->origtoughness = wppt->toughness.getValue(); - _target->power -= _target->pbonus;//remove current bonuses - _target->addToToughness(-_target->tbonus); + _target->origtoughness = wppt->toughness.getValue(); _target->setPower(_target->origpower);//update PT _target->setToughness(_target->origtoughness); _target->power += _target->pbonus;//add new bonus @@ -2386,16 +2384,16 @@ public: { if(cda) { - ; + /*??Do Nothing??*/; } else { - ((MTGCardInstance *) target)->power -= ((MTGCardInstance *) target)->pbonus; - ((MTGCardInstance *) target)->addToToughness(-((MTGCardInstance *) target)->tbonus); - ((MTGCardInstance *) target)->pbonus -= wppt->power.getValue(); - ((MTGCardInstance *) target)->tbonus -= wppt->toughness.getValue(); - ((MTGCardInstance *) target)->power += ((MTGCardInstance *) target)->pbonus; - ((MTGCardInstance *) target)->addToToughness(((MTGCardInstance *) target)->tbonus); + ((MTGCardInstance *) target)->power -= ((MTGCardInstance *) target)->pbonus; + ((MTGCardInstance *) target)->addToToughness(-((MTGCardInstance *) target)->tbonus); + ((MTGCardInstance *) target)->pbonus -= wppt->power.getValue(); + ((MTGCardInstance *) target)->tbonus -= wppt->toughness.getValue(); + ((MTGCardInstance *) target)->power += ((MTGCardInstance *) target)->pbonus; + ((MTGCardInstance *) target)->addToToughness(((MTGCardInstance *) target)->tbonus); } return 1; } From 425b51de0805ec7dd9f359a428ffd80ad3807981 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Wed, 16 Sep 2015 20:36:58 +0800 Subject: [PATCH 07/14] Fix for token cloning Some tokens when cloned produces miscalculated PT(Using foreach, aslongas and others that needs CDA). This should fix the issue. TODO: add tests and updated mtg.txt ... --- projects/mtg/include/AllAbilities.h | 32 ++++++++++++++++++++++++----- projects/mtg/src/AllAbilities.cpp | 5 +++-- projects/mtg/src/Token.cpp | 12 ++++++++++- 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 7f5435397..3f7b552fa 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -2319,7 +2319,17 @@ public: { aType = MTGAbility::STANDARD_PUMP; cda = PT.find("cdaactive") != string::npos; - } + } + string ReplaceString(string subject, const string& search, const string& replace) + { + size_t pos = 0; + while ((pos = subject.find(search, pos)) != string::npos) + { + subject.replace(pos, search.length(), replace); + pos += replace.length(); + } + return subject; + } void Update(float) { if(!nonstatic) @@ -2331,7 +2341,10 @@ public: if(PT.size()) { SAFE_DELETE(wppt); - wppt = NEW WParsedPT(PT,NULL,(MTGCardInstance *) source); + if(cda) + wppt = NEW WParsedPT(ReplaceString(PT, "cdaactive", ""),NULL,(MTGCardInstance *) source); + else + wppt = NEW WParsedPT(ReplaceString(PT, "nonstatic", ""),NULL,(MTGCardInstance *) source); } MTGCardInstance * _target = (MTGCardInstance *) target; _target->power += wppt->power.getValue(); @@ -2342,7 +2355,10 @@ public: if(PT.size()) { SAFE_DELETE(wppt); - wppt = NEW WParsedPT(PT,NULL,(MTGCardInstance *) source); + if(cda) + wppt = NEW WParsedPT(ReplaceString(PT, "cdaactive", ""),NULL,(MTGCardInstance *) source); + else + wppt = NEW WParsedPT(ReplaceString(PT, "nonstatic", ""),NULL,(MTGCardInstance *) source); } ((MTGCardInstance *) target)->origpower = wppt->power.getValue(); ((MTGCardInstance *) target)->origtoughness = (wppt->toughness.getValue() + ((MTGCardInstance *) target)->life)-((MTGCardInstance *) target)->life;//what? @@ -2354,7 +2370,10 @@ public: if(PT.size()) { SAFE_DELETE(wppt); - wppt = NEW WParsedPT(PT,NULL,(MTGCardInstance *) source); + if(cda) + wppt = NEW WParsedPT(ReplaceString(PT, "cdaactive", ""),NULL,(MTGCardInstance *) source); + else + wppt = NEW WParsedPT(ReplaceString(PT, "nonstatic", ""),NULL,(MTGCardInstance *) source); } if(cda) {//Characteristic-defining abilities @@ -2402,7 +2421,10 @@ public: if(PT.size()) { SAFE_DELETE(wppt); - wppt = NEW WParsedPT(PT,NULL,(MTGCardInstance *) source); + if(cda) + wppt = NEW WParsedPT(ReplaceString(PT, "cdaactive", ""),NULL,(MTGCardInstance *) source); + else + wppt = NEW WParsedPT(ReplaceString(PT, "nonstatic", ""),NULL,(MTGCardInstance *) source); } sprintf(menuText, "%i/%i", wppt->power.getValue(), wppt->toughness.getValue()); return menuText; diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 354e45608..1bb059a35 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -2536,12 +2536,13 @@ int AACloner::resolve() spell->source->fresh = 1; spell->source->model = spell->source; spell->source->model->data = spell->source; - if(_target->isToken) + //commenting this out fixes some problems when duplicating tokens 9/16/2015 + /*if(_target->isToken) { spell->source->power = _target->origpower; spell->source->toughness = _target->origtoughness; spell->source->life = _target->origtoughness; - } + }*/ list::iterator it; for (it = awith.begin(); it != awith.end(); it++) { diff --git a/projects/mtg/src/Token.cpp b/projects/mtg/src/Token.cpp index 1e9eeae50..a63bb9167 100644 --- a/projects/mtg/src/Token.cpp +++ b/projects/mtg/src/Token.cpp @@ -13,6 +13,8 @@ Token::Token(string _name, MTGCardInstance * source, int _power, int _toughness) lifeOrig = life; origpower = _power; origtoughness = _toughness; + basepower = power; + basetoughness = toughness; rarity = Constants::RARITY_T; name = _name; if (name.size() && name[0] >= 97 && name[0] <= 122) name[0] -= 32; //Poor man's camelcase. We assume strings we get are either Camelcased or lowercase @@ -25,6 +27,9 @@ Token::Token(string _name, MTGCardInstance * source, int _power, int _toughness) attacker = 0; defenser = NULL; banding = NULL; + pbonus = 0; + tbonus = 0; + isSettingBase = 0; } Token::Token(int id) : @@ -45,7 +50,11 @@ Token::Token(const Token& source) : life = source.life; lifeOrig = source.life; origpower = source.origpower; - origtoughness = source.origpower; + origtoughness = source.origtoughness; + basepower = source.origpower; + basetoughness = source.origpower; + pbonus = source.pbonus; + tbonus = source.tbonus; rarity = source.rarity; name = source.name; setId = source.setId; @@ -56,6 +65,7 @@ Token::Token(const Token& source) : attacker = source.attacker; defenser = source.defenser; banding = source.banding; + isSettingBase = source.isSettingBase; } From 6cba14181d93af14d8d62fddc0d8849857269eb3 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 17 Sep 2015 11:16:29 +0800 Subject: [PATCH 08/14] support "other" in type:* parsing if a card with a cleric subtype has an autoline like this: othertype:cleric:battlefield, means that the targetchooser excludes that card, only the other "cleric" are counted. --- projects/mtg/include/AllAbilities.h | 23 +++++++++++++++++++++++ projects/mtg/include/Wagic_Version.h | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 3f7b552fa..eec795a76 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -68,6 +68,7 @@ private: bool plusone = false; bool plustwo = false; bool plusthree = false; + bool other = false;//othertype:[subtype] if (!target) target = card; int multiplier = 1; if (s[0] == '-') @@ -134,6 +135,12 @@ private: size_t pThree = s.find("plusthree"); s.erase(pThree,pThree + 9); } + if(s.find("othertype") != string::npos) + { + other = true; + size_t oth = s.find("othertype"); + s.erase(oth,oth + 5); + } if(s == "prex") { ManaCost * cX = card->controller()->getManaPool()->Diff(card->getManaCost()); @@ -395,6 +402,7 @@ private: } TargetChooserFactory tf(card->getObserver()); TargetChooser * tc = tf.createTargetChooser(theType.c_str(),NULL); + tc->other = other; for (int i = 0; i < 2; i++) { Player * p = card->getObserver()->players[i]; @@ -642,6 +650,21 @@ private: { intValue = target->controller()->opponent()->game->hand->nb_cards; } + else if (s == "myname")//Plague Rats and others + { + intValue = 0; + for (int i = 0; i < 2; i++) + { + Player * p = card->getObserver()->players[i]; + for (int j = p->game->battlefield->nb_cards - 1; j >= 0; --j) + { + if (p->game->battlefield->cards[j]->name == card->name) + { + intValue += 1; + } + } + } + } else if (s == "pgbzombie")//Soulless One { intValue = 0; diff --git a/projects/mtg/include/Wagic_Version.h b/projects/mtg/include/Wagic_Version.h index 82d9d8d4b..58f7175d4 100644 --- a/projects/mtg/include/Wagic_Version.h +++ b/projects/mtg/include/Wagic_Version.h @@ -12,8 +12,8 @@ Author: Michael Nguyen /* Wagic versions */ #define WAGIC_VERSION_MAJOR 0 -#define WAGIC_VERSION_MEDIUM 19 -#define WAGIC_VERSION_MINOR 2 +#define WAGIC_VERSION_MEDIUM 20 +#define WAGIC_VERSION_MINOR 1 #define VERSION_DOT(a, b, c) a ##.## b ##.## c #define VERSION_WITHOUT_DOT(a, b, c) a ## b ## c From e097d3834720524d9353a5a6ef5a2dfc298124c6 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 17 Sep 2015 18:39:33 +0800 Subject: [PATCH 09/14] Updated CDA cards --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 230 ++++++++----------- projects/mtg/include/AllAbilities.h | 57 ++++- 2 files changed, 157 insertions(+), 130 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 79db499c3..b7ef62287 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -2,7 +2,7 @@ #Please keep these card alphabetized, and try to have the "name=" line at the top of each card [card] name=Aeon Chronicler -auto=phandcount/phandcount nonstatic +auto=phandcount/phandcount cdaactive autoexile=@counterremoved(0/0,1,Time) from(sourcecard) suspended:draw:1 suspend(0)={X}{3}{U} text=Aeon Chronicler's power and toughness are each equal to the number of cards in your hand. -- Suspend X - {X}{3}{U}. X can't be 0. (Rather than cast this card from your hand, you may pay {X}{3}{U} and exile it with X time counters on it. At the beginning of your upkeep, remove a time counter. When the last is removed, cast it without paying its mana cost. It has haste.) -- Whenever a time counter is removed from Aeon Chronicler while it's exiled, draw a card. @@ -867,7 +867,7 @@ type=Instant [/card] [card] name=Adamaro, First to Desire -auto=foreach(*|opponenthand) 1/1 +auto=type:*:opponenthand/type:*:opponenthand cdaactive text=Adamaro, First to Desire's power and toughness are each equal to the number of cards in the hand of the opponent with the most cards in hand. mana={1}{R}{R} type=Legendary Creature @@ -1464,7 +1464,7 @@ subtype=Ajani [/card] [card] name=Avatar Token -auto=thisforeach(controllerlife) 1/1 +auto=controllerlife/controllerlife cdaactive type=Creature subtype=Avatar power=* @@ -2287,7 +2287,7 @@ toughness=2 [card] name=Altar Golem abilities=trample,doesnotuntap -auto=foreach(creature|battlefield) 1/1 +auto=type:creature:battlefield/type:creature:battlefield cdaactive auto={T(creature|myBattlefield)}{T(creature|myBattlefield)}{T(creature|myBattlefield)}{T(creature|myBattlefield)}{T(creature|myBattlefield)}:untap text=Trample -- Altar Golem's power and toughness are each equal to the number of creatures on the battlefield. -- Altar Golem doesn't untap during your untap step. -- Tap five untapped creatures you control: Untap Altar Golem. mana={7} @@ -2853,22 +2853,7 @@ toughness=3 [/card] [card] name=Ancient Ooze -auto=foreach(other creature[manacost=1]|mybattlefield) 1/1 -auto=foreach(other creature[manacost=2]|mybattlefield) 2/2 -auto=foreach(other creature[manacost=3]|mybattlefield) 3/3 -auto=foreach(other creature[manacost=4]|mybattlefield) 4/4 -auto=foreach(other creature[manacost=5]|mybattlefield) 5/5 -auto=foreach(other creature[manacost=6]|mybattlefield) 6/6 -auto=foreach(other creature[manacost=7]|mybattlefield) 7/7 -auto=foreach(other creature[manacost=8]|mybattlefield) 8/8 -auto=foreach(other creature[manacost=9]|mybattlefield) 9/9 -auto=foreach(other creature[manacost=10]|mybattlefield) 10/10 -auto=foreach(other creature[manacost=11]|mybattlefield) 11/11 -auto=foreach(other creature[manacost=12]|mybattlefield) 12/12 -auto=foreach(other creature[manacost=13]|mybattlefield) 13/13 -auto=foreach(other creature[manacost=14]|mybattlefield) 14/14 -auto=foreach(other creature[manacost=15]|mybattlefield) 15/15 -auto=foreach(other creature[manacost=16]|mybattlefield) 16/16 +auto=pancientooze/pancientooze cdaactive text=Ancient Ooze's power and toughness are each equal to the total converted mana cost of other creatures you control. mana={5}{G}{G} type=Creature @@ -7909,7 +7894,7 @@ toughness=2 [card] name=Battle Squadron abilities=flying -auto=foreach(creature|myBattlefield) 1/1 +auto=type:creature:myBattlefield/type:creature:myBattlefield cdaactive text=Flying -- Battle Squadron's power and toughness are each equal to the number of creatures you control. mana={3}{R}{R} type=Creature @@ -8222,7 +8207,7 @@ type=Enchantment [/card] [card] name=Beast of Burden -auto=foreach(creature|Battlefield) 1/1 +auto=type:creature:Battlefield/type:creature:Battlefield cdaactive text=Beast of Burden's power and toughness are each equal to the number of creatures on the battlefield. mana={6} type=Artifact Creature @@ -8512,7 +8497,7 @@ toughness=2 [/card] [card] name=Benalish Commander -auto=type:soldier:mybattlefield/type:soldier:mybattlefield nonstatic +auto=type:soldier:mybattlefield/type:soldier:mybattlefield cdaactive autoexile=@counterremoved(0/0,1,Time) from(sourcecard) suspended:token(Soldier,Creature Soldier,1/1,white) suspend(0)={X}{W}{W} text=Benalish Commander's power and toughness are each equal to the number of Soldiers you control. -- Suspend X - {X}{W}{W}. X can't be 0. (Rather than cast this card from your hand, you may pay {X}{W}{W} and exile it with X time counters on it. At the beginning of your upkeep, remove a time counter. When the last is removed, cast it without paying its mana cost. It has haste.) -- Whenever a time counter is removed from Benalish Commander while it's exiled, put a 1/1 white Soldier creature token onto the battlefield. @@ -11356,7 +11341,7 @@ toughness=2 [/card] [card] name=Boneyard Wurm -auto=foreach(creature|mygraveyard) 1/1 +auto=type:creature:mygraveyard/type:creature:mygraveyard cdaactive text=Boneyard Wurm's power and toughness are each equal to the number of creature cards in your graveyard. mana={1}{G} type=Creature @@ -12639,7 +12624,7 @@ toughness=4 [card] name=Broodstar abilities=affinityartifacts,flying -auto=foreach(artifact|mybattlefield) 1/1 +auto=type:artifact:mybattlefield/type:artifact:mybattlefield cdaactive text=Affinity for artifacts (This spell costs {1} less to cast for each artifact you control.) -- Flying -- Broodstar's power and toughness are each equal to the number of artifacts you control. mana={8}{U}{U} type=Creature @@ -13633,6 +13618,7 @@ subtype=Elf power=2 toughness=2 [/card] +#chosentype and chosencolor not compatible with cdaactive... [card] name=Caller of the Hunt auto=chooseatype foreach(creature[chosentype]|battlefield) 1/1 chooseend @@ -13788,7 +13774,7 @@ type=Sorcery [card] name=Cantivore abilities=vigilance -auto=foreach(enchantment|graveyard) 1/1 +auto=type:enchantment:graveyard/type:enchantment:graveyard cdaactive text=Vigilance -- Cantivore's power and toughness are each equal to the number of enchantment cards in all graveyards. mana={1}{W}{W} type=Creature @@ -15399,7 +15385,11 @@ toughness=4 [/card] [card] name=Chameleon Spirit -auto=chooseacolor foreach(*[chosencolor]|opponentBattlefield) 1/1 chooseend +auto=choice name(green) activate type:*[green]:opponentBattlefield/type:*[green]:opponentBattlefield cdaactive +auto=choice name(red) activate type:*[red]:opponentBattlefield/type:*[red]:opponentBattlefield cdaactive +auto=choice name(blue) activate type:*[blue]:opponentBattlefield/type:*[blue]:opponentBattlefield cdaactive +auto=choice name(white) activate type:*[white]:opponentBattlefield/type:*[white]:opponentBattlefield cdaactive +auto=choice name(black) activate type:*[black]:opponentBattlefield/type:*[black]:opponentBattlefield cdaactive text=As Chameleon Spirit enters the battlefield, choose a color. -- Chameleon Spirit's power and toughness are each equal to the number of permanents of the chosen color your opponents control. mana={3}{U} type=Creature @@ -17666,7 +17656,7 @@ type=Instant [card] name=Cognivore abilities=flying -auto=foreach(instant|graveyard) 1/1 +auto=type:instant:graveyard/type:instant:graveyard cdaactive text=Flying -- Cognivore's power and toughness are each equal to the number of instant cards in all graveyards. mana={6}{U}{U} type=Creature @@ -17686,7 +17676,7 @@ toughness=1 [/card] [card] name=Coiling Woodworm -auto=foreach(forest|battlefield) 1/0 +auto=type:forest:battlefield/1 cdaactive text=Coiling Woodworm's power is equal to the number of Forests on the battlefield. mana={2}{G} type=Creature @@ -19763,7 +19753,7 @@ toughness=4 [card] name=Crowd of Cinders abilities=fear -auto=foreach(*[black]|myBattlefield) 1/1 +auto=type:*[black]:myBattlefield/type:*[black]:myBattlefield cdaactive text=Fear (This creature can't be blocked except by artifact creatures and/or black creatures.) -- Crowd of Cinders's power and toughness are each equal to the number of black permanents you control. mana={3}{B} type=Creature @@ -19968,7 +19958,7 @@ type=Enchantment [/card] [card] name=Crusader of Odric -auto=foreach(creature|mybattlefield) 1/1 +auto=type:creature:mybattlefield/type:creature:mybattlefield cdaactive text=Crusader of Odric's power and toughness are each equal to the number of creatures you control. mana={2}{W} type=Creature @@ -20858,7 +20848,7 @@ subtype=Aura [/card] [card] name=Dakkon Blackblade -auto=foreach(land|myBattlefield) 1/1 +auto=type:land:myBattlefield/type:land:myBattlefield cdaactive text=Dakkon Blackblade's power and toughness are each equal to the number of lands you control. mana={2}{W}{U}{U}{B} type=Legendary Creature @@ -20921,7 +20911,7 @@ toughness=1 [/card] [card] name=Dakmor Sorceress -auto=foreach(swamp|myBattlefield) 1/0 +auto=type:swamp:myBattlefield/4 cdaactive text=Dakmor Sorceress's power is equal to the number of Swamps you control. mana={5}{B} type=Creature @@ -21419,7 +21409,7 @@ type=Artifact [card] name=Darksteel Juggernaut abilities=mustattack,indestructible -auto=foreach(artifact|mybattlefield) 1/1 +auto=type:artifact:mybattlefield/type:artifact:mybattlefield cdaactive text=Darksteel Juggernaut's power and toughness are equal to the number of artifacts you control. -- Darksteel Juggernaut is indestructible and attacks each turn if able. mana={5} type=Artifact Creature @@ -21615,8 +21605,7 @@ toughness=3 [/card] [card] name=Dauntless Dourbark -auto=foreach(forest|myBattlefield) 1/1 -auto=foreach(treefolk|myBattlefield) 1/1 +auto=pdauntless/pdauntless cdaactive auto=aslongas(other treefolk|myBattlefield) trample text=Dauntless Dourbark's power and toughness are each equal to the number of Forests you control plus the number of Treefolk you control. -- Dauntless Dourbark has trample as long as you control another Treefolk. mana={3}{G} @@ -21749,7 +21738,7 @@ toughness=1 [card] name=Dauthi Warlord abilities=shadow -auto=foreach(creature[shadow]|battlefield) 1/0 +auto=type:creature[shadow]:battlefield/1 cdaactive text=Shadow (This creature can block or be blocked by only creatures with shadow.) -- Dauthi Warlord's power is equal to the number of creatures with shadow on the battlefield. mana={1}{B} type=Creature @@ -23831,7 +23820,7 @@ text=Destroy target artifact with converted mana cost X. It can't be regenerated [/card] [card] name=Detritivore -auto=type:land[-basic]:opponentgraveyard/type:land[-basic]:opponentgraveyard nonstatic +auto=type:land[-basic]:opponentgraveyard/type:land[-basic]:opponentgraveyard cdaactive autoexile=@counterremoved(0/0,1,Time) from(sourcecard) suspended:destroy target(land[-basic]) suspend(0)={X}{3}{R} text=Detritivore's power and toughness are each equal to the number of nonbasic land cards in your opponents' graveyards. -- Suspend X - {X}{3}{R}. X can't be 0. (Rather than cast this card from your hand, you may pay {X}{3}{R} and exile it with X time counters on it. At the beginning of your upkeep, remove a time counter. When the last is removed, cast it without paying its mana cost. It has haste.) -- Whenever a time counter is removed from Detritivore while it's exiled, destroy target nonbasic land. @@ -25292,7 +25281,7 @@ type=Artifact [card] name=Doubtless One auto=spiritlink -auto=foreach(cleric) 1/1 +auto=type:cleric:battlefield/type:cleric:battlefield cdaactive text=Doubtless One's power and toughness are each equal to the number of Clerics on the battlefield. -- Whenever Doubtless One deals damage, you gain that much life. mana={3}{W} type=Creature @@ -26421,7 +26410,7 @@ toughness=5 [card] name=Drift of the Dead abilities=defender -auto=foreach(land[snow]|myBattlefield) 1/1 +auto=type:land[snow]:myBattlefield/type:land[snow]:myBattlefield cdaactive text=Defender (This creature can't attack.) -- Drift of the Dead's power and toughness are each equal to the number of snow lands you control. mana={3}{B} type=Creature @@ -26781,7 +26770,7 @@ toughness=1 [card] name=Drove of Elves abilities=opponentshroud -auto=foreach(*[green]|myBattlefield) 1/1 +auto=type:*[green]:myBattlefield/type:*[green]:myBattlefield cdaactive text=Drove of Elves's power and toughness are each equal to the number of green permanents you control. -- Drove of Elves can't be the target of spells or abilities your opponents control. mana={3}{G} type=Creature @@ -27132,7 +27121,7 @@ toughness=1 [card] name=Dungrove Elder abilities=opponentshroud -auto=foreach(forest|mybattlefield) 1/1 +auto=type:forest:mybattlefield/type:forest:mybattlefield cdaactive text=Hexproof (This creature can't be the target of spells or abilities your opponents control.) -- Dungrove Elder's power and toughness are each equal to the number of Forests you control. mana={2}{G} type=Creature @@ -28466,7 +28455,7 @@ type=Sorcery name=Elephant T1 type=Creature subtype=Elephant -auto=foreach(creature|mygraveyard) 1/1 +auto=type:creature:mygraveyard/type:creature:mygraveyard cdaactive text=This creature's power and toughness are each equal to the number of creature cards in its controller's graveyard. power=* toughness=* @@ -30000,7 +29989,7 @@ toughness=2 [/card] [card] name=Entropic Specter -auto=foreach(*|opponenthand) 1/1 +auto=type:*:opponenthand/type:*:opponenthand cdaactive auto=@damaged(controller) from(this):ability$!name(discard) target(*|myhand) reject!$ controller auto=@damaged(opponent) from(this):ability$!name(discard) target(*|myhand) reject!$ opponent text=Flying -- As Entropic Specter enters the battlefield, choose an opponent. -- Entropic Specter's power and toughness are each equal to the number of cards in the chosen player's hand. -- Whenever Entropic Specter deals damage to a player, that player discards a card. @@ -31590,7 +31579,7 @@ toughness=1 [card] name=Faerie Swarm abilities=flying -auto=foreach(*[blue]|myBattlefield) 1/1 +auto=type:*[blue]:myBattlefield/type:*[blue]:myBattlefield cdaactive text=Flying -- Faerie Swarm's power and toughness are each equal to the number of blue permanents you control. mana={3}{U} type=Creature @@ -37037,7 +37026,7 @@ type=Instant name=Geist-Honored Monk abilities=vigilance auto=token(Spirit,Creature Spirit,1/1,white,flying)*2 -auto=foreach(creature|mybattlefield) 1/1 +auto=type:creature:mybattlefield/type:creature:mybattlefield cdaactive text=Vigilance -- Geist-Honored Monk's power and toughness are each equal to the number of creatures you control. -- When Geist-Honored Monk enters the battlefield, put two 1/1 white Spirit creature tokens with flying onto the battlefield. mana={3}{W}{W} type=Creature @@ -44009,7 +43998,7 @@ subtype=Arcane [card] name=Heedless One abilities=trample -auto=foreach(elf) 1/1 +auto=type:elf:battlefield/type:elf:battlefield cdaactive text=Trample -- Heedless One's power and toughness are each equal to the number of Elves on the battlefield. mana={3}{G} type=Creature @@ -48996,7 +48985,7 @@ toughness=4 [/card] [card] name=Jagged-Scar Archers -auto=foreach(elf|myBattlefield) 1/1 +auto=type:elf:myBattlefield/type:elf:myBattlefield cdaactive auto={T}:target(creature[flying]) dynamicability text=Jagged-Scar Archers's power and toughness are each equal to the number of Elves you control. -- {T}: Jagged-Scar Archers deals damage equal to its power to target creature with flying. mana={1}{G}{G} @@ -50252,8 +50241,8 @@ abilities=defender [/card] [card] name=Kagemaro, First to Suffer -auto=foreach(*|myhand) 1/1 -auto={B}{S}:foreach(*|myhand) -1/-1 all(creature) +auto=type:*:myhand/type:*:myhand cdaactive +auto={B}{S}:-type:*:myhand/-type:*:myhand all(creature) text=Kagemaro, First to Suffer's power and toughness are each equal to the number of cards in your hand. -- {B}, Sacrifice Kagemaro: All creatures get -X/-X until end of turn, where X is the number of cards in your hand. mana={3}{B}{B} type=Legendary Creature @@ -51342,7 +51331,7 @@ toughness=1 [/card] [card] name=Keldon Warlord -auto=foreach(creature[-wall]|myBattlefield) 1/1 +auto=type:creature[-wall]:myBattlefield/type:creature[-wall]:myBattlefield cdaactive text=Keldon Warlord's power and toughness are each equal to the number of non-Wall creatures you control. mana={2}{R}{R} type=Creature @@ -51991,7 +51980,7 @@ toughness=2 [card] name=Kithkin Rabble abilities=vigilance -auto=foreach(*[white]|myBattlefield) 1/1 +auto=type:*[white]:myBattlefield/type:*[white]:myBattlefield cdaactive text=Vigilance -- Kithkin Rabble's power and toughness are each equal to the number of white permanents you control. mana={3}{W} type=Creature @@ -52115,7 +52104,7 @@ toughness=1 [/card] [card] name=Kiyomaro, First to Stand -auto=foreach(*|myhand) 1/1 +auto=type:*:myhand/type:*:myhand cdaactive auto=aslongas(*|myhand) vigilance >3 auto=@damaged(player) from(this) restriction{type(*|myhand)~morethan~6}:life:7 controller >6 auto=@damaged(creature) from(this) restriction{type(*|myhand)~morethan~6}:life:7 controller >6 @@ -52609,7 +52598,7 @@ toughness=1 [card] name=Kolaghan Forerunners abilities=trample -auto=foreach(creature|mybattlefield) 1/0 +auto=type:creature:mybattlefield/3 cdaactive other={R}{2} name(Dash) auto=if paid(alternative) then transforms((,newability[haste],newability[phaseaction[endofturn sourceinplay] moveto(ownerhand) all(this)])) forever text=Trample -- Kolaghan Forerunners's power is equal to the number of creatures you control. -- Dash {2}{R} (You may cast this spell for its dash cost. If you do, it gains haste, and it's returned from the battlefield to its owner's hand at the beginning of the next end step.) @@ -52843,7 +52832,7 @@ toughness=1 [card] name=Korlash Heir to Blackblade auto={discard(korlash heir to blackblade|myhand)}:moveto(mybattlefield) and!(tap)! target(swamp|mylibrary) -auto=foreach(swamp|mybattlefield) 1/1 +auto=type:swamp:mybattlefield/type:swamp:mybattlefield cdaactive auto={1}{B}:regenerate text=Korlash, Heir to Blackblade's power and toughness are each equal to the number of Swamps you control. -- {1}{B}: Regenerate Korlash. -- Grandeur - Discard another card named Korlash, Heir to Blackblade: Search your library for up to two Swamp cards, put them onto the battlefield tapped, then shuffle your library. mana={2}{B}{B} @@ -53276,7 +53265,7 @@ subtype=Aura [card] name=Krovikan Mist abilities=flying -auto=foreach(illusion|battlefield) 1/1 +auto=type:illusion:battlefield/type:illusion:battlefield cdaactive text=Flying -- Krovikan Mist's power and toughness are each equal to the number of Illusions on the battlefield. mana={1}{U} type=Creature @@ -54868,7 +54857,7 @@ toughness=5 [/card] [card] name=Lhurgoyf -auto=foreach(creature|graveyard) 1/1 +auto=type:creature:graveyard/plusonetype:creature:graveyard cdaactive text=Lhurgoyf's power is equal to the number of creature cards in all graveyards and its toughness is equal to that number plus 1. mana={2}{G}{G} type=Creature @@ -56197,7 +56186,7 @@ toughness=2 [/card] [card] name=Lord of Extinction -auto=foreach(*|graveyard) 1/1 +auto=type:*:graveyard/type:*:graveyard cdaactive text=Lord of Extinction's power and toughness are each equal to the number of cards in all graveyards. mana={3}{B}{G} type=Creature @@ -57509,7 +57498,7 @@ toughness=6 [card] name=Magnivore abilities=haste -auto=foreach(sorcery|graveyard) 1/1 +auto=type:sorcery:graveyard/type:sorcery:graveyard cdaactive text=Haste (This creature can attack the turn it comes under your control.) -- Magnivore's power and toughness are each equal to the number of sorcery cards in all graveyards. mana={2}{R}{R} type=Creature @@ -58300,9 +58289,7 @@ toughness=3 [/card] [card] name=Maraxus of Keld -auto=foreach(artifact[-tapped]|myBattlefield) 1/1 -auto=foreach(creature[-tapped]|myBattlefield) 1/1 -auto=foreach(land[-tapped]|myBattlefield) 1/1 +auto=type:*[-tapped&-enchantment;-tapped&-planeswalker]/type:*[-tapped&-enchantment;-tapped&-planeswalker] cdaactive text=Maraxus of Keld's power and toughness are each equal to the number of untapped artifacts, creatures, and lands you control. mana={4}{R}{R} type=Legendary Creature @@ -58677,7 +58664,7 @@ toughness=4 [/card] [card] name=Maro -auto=foreach(*|myhand) 1/1 +auto=type:*:myhand/type:*:myhand cdaactive text=Maro's power and toughness are each equal to the number of cards in your hand. mana={2}{G}{G} type=Creature @@ -59210,7 +59197,7 @@ toughness=2 [card] name=Master of Etherium auto=lord(other creature[artifact]|mybattlefield) 1/1 -auto=foreach(artifact|mybattlefield) 1/1 +auto=type:artifact:mybattlefield/type:artifact:mybattlefield cdaactive text=Master of Etherium's power and toughness are each equal to the number of artifacts you control. -- Other artifact creatures you control get +1/+1. mana={2}{U} type=Artifact Creature @@ -59315,7 +59302,7 @@ toughness=4 [/card] [card] name=Masumaro, First to Live -auto=foreach(*|myhand) 2/2 +auto=twicetype:*:myhand/twicetype:*:myhand cdaactive text=Masumaro, First to Live's power and toughness are each equal to twice the number of cards in your hand. mana={3}{G}{G}{G} type=Legendary Creature @@ -59325,11 +59312,7 @@ toughness=* [/card] [card] name=Matca Rioters -auto=aslongas(forest|myBattlefield) 1/1 -auto=aslongas(island|myBattlefield) 1/1 -auto=aslongas(plains|myBattlefield) 1/1 -auto=aslongas(mountain|myBattlefield) 1/1 -auto=aslongas(swamp|myBattlefield) 1/1 +auto=pbasiclandtypes/pbasiclandtypes cdaactive text=Domain - Matca Rioters's power and toughness are each equal to the number of basic land types among lands you control. mana={2}{G} type=Creature @@ -62302,7 +62285,7 @@ toughness=8 [card] name=Molimo, Maro-Sorcerer abilities=trample -auto=foreach(land|myBattlefield) 1/1 +auto=type:land:myBattlefield/type:land:myBattlefield cdaactive text=Trample (If this creature would deal enough damage to its blockers to destroy them, you may have it deal the rest of its damage to defending player or planeswalker.) -- Molimo, Maro-Sorcerer's power and toughness are each equal to the number of lands you control. mana={4}{G}{G}{G} type=Legendary Creature @@ -63180,7 +63163,7 @@ toughness=2 [card] name=Mortivore auto={B}:regenerate -auto=foreach(creature|graveyard) 1/1 +auto=type:creature:graveyard/type:creature:graveyard cdaactive text=Mortivore's power and toughness are each equal to the number of creature cards in all graveyards. -- {B}: Regenerate Mortivore. (The next time this creature would be destroyed this turn, it isn't. Instead tap it, remove all damage from it, and remove it from combat.) mana={2}{B}{B} type=Creature @@ -63575,8 +63558,7 @@ toughness=2 [card] name=Multani, Maro-Sorcerer abilities=shroud -auto=foreach(*|myhand) 1/1 -auto=foreach(*|opponenthand) 1/1 +auto=type:*:hand/type:*:hand cdaactive text=Shroud (This permanent can't be the target of spells or abilities.) -- Multani's power and toughness are each equal to the total number of cards in all players' hands. mana={4}{G}{G} type=Legendary Creature @@ -64389,7 +64371,7 @@ subtype=Shapeshifter name=Nameless One facedown={3} autofacedown={2}{U}:morph -auto=foreach(wizard) 1/1 +auto=type:wizard:battlefield/type:wizard:battlefield cdaactive text=Nameless One's power and toughness are each equal to the number of Wizards on the battlefield. -- Morph {2}{U} (You may cast this face down as a 2/2 creature for {3}. Turn it face up any time for its morph cost.) mana={3}{U} type=Creature @@ -65793,7 +65775,7 @@ type=Sorcery [card] name=Nightmare abilities=flying -auto=foreach(swamp|myBattlefield) 1/1 +auto=type:swamp:mybattlefield/type:swamp:mybattlefield cdaactive text=Flying -- Nightmare's power and toughness are each equal to the number of Swamps you control. mana={5}{B} type=Creature @@ -65911,7 +65893,7 @@ toughness=4 [/card] [card] name=Nightstalker Engine -auto=foreach(creature|myGraveyard) 1/0 +auto=type:creature:myGraveyard/3 cdaactive text=Nightstalker Engine's power is equal to the number of creature cards in your graveyard. mana={4}{B} type=Creature @@ -68690,7 +68672,7 @@ toughness=2 [/card] [card] name=Overbeing of Myth -auto=foreach(*|myhand) 1/1 +auto=type:*:myhand/type:*:myhand cdaactive auto=@each my draw:draw:1 text=Overbeing of Myth's power and toughness are each equal to the number of cards in your hand. -- At the beginning of your draw step, draw an additional card. mana={GU}{GU}{GU}{GU}{GU} @@ -68943,7 +68925,7 @@ type=Sorcery [/card] [card] name=Pack Rat -auto=foreach(creature[rat]|mybattlefield) 1/1 +auto=type:rat:mybattlefield/type:rat:mybattlefield cdaactive auto={2}{B}{discard(*|myhand)}:token(253624) text=Pack Rat's power and toughness are each equal to the number of Rats you control. -- {2}{B}, Discard a card: Put a token onto the battlefield that's a copy of Pack Rat. mana={1}{B} @@ -69187,7 +69169,7 @@ toughness=4 [/card] [card] name=Pallimud -auto=foreach(land[tapped]|opponentBattlefield) 1/0 +auto=type:land[tapped]:opponentbattlefield/3 cdaactive text=As Pallimud enters the battlefield, choose an opponent. -- Pallimud's power is equal to the number of tapped lands the chosen player controls. mana={2}{R} type=Creature @@ -70317,7 +70299,7 @@ toughness=6 [/card] [card] name=Pestilence Rats -auto=foreach(other rat) 1/0 +auto=othertype:rat:battlefield/3 cdaactive text=Pestilence Rats's power is equal to the number of other Rats on the battlefield. (For example, as long as there are two other Rats on the battlefield, Pestilence Rats's power and toughness are 2/3.) mana={2}{B} type=Creature @@ -71781,7 +71763,7 @@ toughness=1 [/card] [card] name=Plague Rats -auto=foreach(plague rats) 1/1 +auto=myname/myname cdaactive text=Plague Rats's power and toughness are each equal to the number of creatures named Plague Rats on the battlefield. mana={2}{B} type=Creature @@ -72982,7 +72964,7 @@ subtype=Aura [card] name=Primalcrux abilities=trample -auto=thisforeach(variable{type:manag:mybattlefield}>0) 1/1 +auto=type:manag:mybattlefield/type:manag:mybattlefield cdaactive text=Trample -- Chroma - Primalcrux's power and toughness are each equal to the number of green mana symbols in the mana costs of permanents you control. mana={G}{G}{G}{G}{G}{G} type=Creature @@ -73655,7 +73637,7 @@ type=Enchantment [/card] [card] name=Psychosis Crawler -auto=foreach(*|myhand) 1/1 +auto=type:*:myhand/type:*:myhand cdaactive auto=@drawn(controller):life:-1 opponent text=Psychosis Crawler's power and toughness are each equal to the number of cards in your hand. - Whenever you draw a card, each opponent loses 1 life. mana={5} @@ -76649,7 +76631,7 @@ toughness=2 [card] name=Reckless One abilities=haste -auto=foreach(goblin) 1/1 +auto=type:goblin:battlefield/type:goblin:battlefield cdaactive text=Haste -- Reckless One's power and toughness are each equal to the number of Goblins on the battlefield. mana={3}{R} type=Creature @@ -77988,7 +77970,7 @@ type=Artifact [card] name=Revenant abilities=flying -auto=foreach(creature|mygraveyard) 1/1 +auto=type:creature:mygraveyard/type:creature:mygraveyard cdaactive text=Flying -- Revenant's power and toughness are each equal to the number of creature cards in your graveyard. mana={4}{B} type=Creature @@ -80001,7 +79983,7 @@ toughness=3 [/card] [card] name=Rubblehulk -auto=type:land:mybattlefield/type:land:mybattlefield nonstatic +auto=type:land:mybattlefield/type:land:mybattlefield cdaactive autohand={1}{R}{G}{discard}:name(bloodrush) target(creature[attacking]) type:land:mybattlefield/type:land:mybattlefield ueot text=Rubblehulk's power and toughness are each equal to the number of lands you control. -- Bloodrush — {1}{R}{G}, Discard Rubblehulk: Target attacking creature gets +X/+X until end of turn, where X is the number of lands you control. mana={4}{R}{G} @@ -80525,7 +80507,7 @@ type=Artifact [card] name=Rusting Golem auto=fading:5 -auto=thisforeach(counter{0/0.1.Fade}) 1/1 +auto=counter{0%0.1.Fade}/counter{0%0.1.Fade} cdaactive text=Fading 5 (This creature enters the battlefield with five fade counters on it. At the beginning of your upkeep, remove a fade counter from it. If you can't, sacrifice it.) -- Rusting Golem's power and toughness are each equal to the number of fade counters on it. mana={4} type=Artifact Creature @@ -82565,7 +82547,7 @@ toughness=1 [/card] [card] name=Scion of the Wild -auto=foreach(creature|myBattlefield) 1/1 +auto=type:creature:myBattlefield/type:creature:myBattlefield cdaactive text=Scion of the Wild's power and toughness are each equal to the number of creatures you control. mana={1}{G}{G} type=Creature @@ -84617,7 +84599,7 @@ toughness=3 name=Serpent of the Endless Sea abilities=cantattack auto=aslongas(island|opponentBattlefield) -cantattack -auto=foreach(island|myBattlefield) 1/1 +auto=type:island:myBattlefield/type:island:myBattlefield cdaactive text=Serpent of the Endless Sea's power and toughness are each equal to the number of Islands you control. -- Serpent of the Endless Sea can't attack unless defending player controls an Island. mana={4}{U} type=Creature @@ -84690,7 +84672,7 @@ toughness=1 [/card] [card] name=Serra Avatar -auto=thisforeach(controllerlife) 1/1 +auto=controllerlife/controllerlife cdaactive autograveyard=moveTo(ownerlibrary) && shuffle text=Serra Avatar's power and toughness are each equal to your life total. -- When Serra Avatar is put into a graveyard from anywhere, shuffle it into its owner's library. mana={4}{W}{W}{W} @@ -85006,8 +84988,8 @@ toughness=2 [/card] [card] name=Sewer Nemesis -auto=choice name(opponent) transforms((,newability[foreach(*|opponentgraveyard) 1/1],newability[@movedTo(*|opponentstack):deplete:1 opponent])) forever -auto=choice name(you) transforms((,newability[foreach(*|mygraveyard) 1/1],newability[@movedTo(*|mystack):deplete:1 controller])) forever +auto=choice name(opponent) transforms((,newability[type:*:opponentgraveyard/type:*:opponentgraveyard cdaactive],newability[@movedTo(*|opponentstack):deplete:1 opponent])) forever +auto=choice name(you) transforms((,newability[type:*:mygraveyard/type:*:mygraveyard cdaactive],newability[@movedTo(*|mystack):deplete:1 controller])) forever text=As Sewer Nemesis enters the battlefield, choose a player. -- Sewer Nemesis's power and toughness are each equal to the number of cards in the chosen player's graveyard. -- Whenever the chosen player casts a spell, that player puts the top card of his or her library into his or her graveyard. mana={3}{B} type=Creature @@ -87386,7 +87368,7 @@ toughness=5 [/card] [card] name=Sima Yi, Wei Field Marshal -auto=foreach(swamp|myBattlefield) 1/0 +auto=type:swamp:myBattlefield/4 cdaactive text=Sima Yi, Wei Field Marshal's power is equal to the number of Swamps you control. mana={5}{B} type=Legendary Creature @@ -88839,7 +88821,7 @@ toughness=3 [card] name=Skyshroud War Beast abilities=trample -auto=foreach(land[-basic]|opponentBattlefield) 1/1 +auto=type:land[-basic]:opponentBattlefield/type:land[-basic]:opponentBattlefield cdaactive text=Trample -- As Skyshroud War Beast enters the battlefield, choose an opponent. -- Skyshroud War Beast's power and toughness are each equal to the number of nonbasic lands the chosen player controls. mana={1}{G} type=Creature @@ -88913,7 +88895,7 @@ toughness=3 [/card] [card] name=Slag Fiend -auto=foreach(artifact|graveyard) 1/1 +auto=type:artifact:graveyard/type:artifact:graveyard cdaactive text=Slag Fiend's power and toughness are each equal to the number of artifact cards in all graveyards. mana={R} type=Creature @@ -90410,7 +90392,7 @@ toughness=1 [card] name=Soramaro, First to Dream abilities=flying -auto=foreach(*|myhand) 1/1 +auto=type:*:myhand/type:*:myhand cdaactive auto={4}{H(land|myBattlefield)}:draw:1 text=Flying -- Soramaro, First to Dream's power and toughness are each equal to the number of cards in your hand. -- {4}, Return a land you control to its owner's hand: Draw a card. mana={4}{U}{U} @@ -90926,8 +90908,7 @@ toughness=2 [/card] [card] name=Soulless One -auto=foreach(zombie|graveyard) 1/1 -auto=foreach(zombie) 1/1 +auto=pgbzombie/pgbzombie cdaactive text=Soulless One's power and toughness are each equal to the number of Zombies on the battlefield plus the number of Zombie cards in all graveyards. mana={3}{B} type=Creature @@ -90984,7 +90965,7 @@ type=Instant [card] name=Soulsurge Elemental abilities=first strike -auto=foreach(creature|myBattlefield) 1/0 +auto=type:creature:myBattlefield/1 cdaactive text=First strike -- Soulsurge Elemental's power is equal to the number of creatures you control. mana={3}{R} type=Creature @@ -91514,8 +91495,7 @@ toughness=1 [card] name=Spellheart Chimera abilities=flying,trample -auto=type:*[instant]:mygraveyard/0 nonstatic -auto=type:*[sorcery]:mygraveyard/0 nonstatic +auto=pginstantsorcery/3 cdaactive text=Flying. -- Trample. -- Spellheart Chimera's power is equal to the number of instant and sorcery cards in your graveyard. mana={1}{U}{R} type=Creature @@ -92502,7 +92482,7 @@ color=green [card] name=Splinterfright abilities=trample -auto=foreach(creature|mygraveyard) 1/1 +auto=type:creature:mygraveyard/type:creature:mygraveyard cdaactive auto=@each my upkeep:deplete:2 controller text=Trample -- Splinterfright's power and toughness are each equal to the number of creature cards in your graveyard -- At the beginning of your upkeep, put the top two cards of your library into your graveyard. mana={2}{G} @@ -92905,7 +92885,7 @@ type=Enchantment [/card] [card] name=Squelching Leeches -auto=foreach(swamp|myBattlefield) 1/1 +auto=type:swamp:myBattlefield/type:swamp:myBattlefield cdaactive text=Squelching Leeches's power and toughness are each equal to the number of Swamps you control. mana={2}{B}{B} type=Creature @@ -95064,7 +95044,7 @@ toughness=6 [card] name=Sturmgeist abilities=flying -auto=foreach(*|myhand) 1/1 +auto=type:*:myhand/type:*:myhand cdaactive auto=@combatdamaged(player) from(this):draw:1 controller text=Flying -- Sturmgeist's power and toughness are each equal to the number of cards in your hand. -- Whenever Sturmgeist deals combat damage to a player, draw a card. mana={3}{U}{U} @@ -96180,7 +96160,7 @@ toughness=0 [/card] [card] name=Swarm of Rats -auto=foreach(rat|myBattlefield) 1/0 +auto=type:rat:mybattlefield/1 cdaactive text=Swarm of Rats's power is equal to the number of Rats you control. mana={1}{B} type=Creature @@ -96647,7 +96627,7 @@ type=Sorcery [/card] [card] name=Sylvan Yeti -auto=foreach(*|myhand) 1/0 +auto=type:*:myhand/4 cdaactive text=Sylvan Yeti's power is equal to the number of cards in your hand. mana={2}{G}{G} type=Creature @@ -97496,14 +97476,7 @@ toughness=7 [/card] [card] name=Tarmogoyf -auto=aslongas(artifact|graveyard) 1/1 -auto=aslongas(creature|graveyard) 1/1 -auto=aslongas(enchantment|graveyard) 1/1 -auto=aslongas(instant|graveyard) 1/1 -auto=aslongas(land|graveyard) 1/1 -auto=aslongas(sorcery|graveyard) 1/1 -auto=aslongas(tribal|graveyard) 1/1 -auto=aslongas(planeswalker|graveyard) 1/1 +auto=gravecardtypes/plusonegravecardtypes cdaactive text=Tarmogoyf's power is equal to the number of card types among cards in all graveyards and its toughness is equal to that number plus 1. (The card types are artifact, creature, enchantment, instant, land, planeswalker, sorcery, and tribal.) mana={1}{G} type=Creature @@ -98535,7 +98508,7 @@ type=Artifact [card] name=Terravore abilities=trample -auto=foreach(land|graveyard) 1/1 +auto=type:land:graveyard/type:land:graveyard cdaactive text=Trample -- Terravore's power and toughness are each equal to the number of land cards in all graveyards. mana={1}{G}{G} type=Creature @@ -100385,8 +100358,8 @@ toughness=5 [/card] [card] name=Tidewalker -auto=foreach(island|myBattlefield) counter(0/0,1,Time) -auto=thisforeach(counter{0/0.1.Time}) 1/1 +auto=foreach(island|myBattlefield) counter(0/0,1,Time) oneshot +auto=counter{0%0.1.Time}/counter{0%0.1.Time} cdaactive auto=vanishing:0 text=Tidewalker enters the battlefield with a time counter on it for each Island you control. -- Vanishing (At the beginning of your upkeep, remove a time counter from this permanent. When the last is removed, sacrifice it.) -- Tidewalker's power and toughness are each equal to the number of time counters on it. mana={2}{U} @@ -103532,7 +103505,7 @@ toughness=2 [/card] [card] name=Uktabi Wildcats -auto=foreach(forest|myBattlefield) 1/1 +auto=type:forest:mybattlefield/type:forest:mybattlefield cdaactive auto={G}{S(forest|myBattlefield)}:regenerate text=Uktabi Wildcats's power and toughness are each equal to the number of Forests you control. -- {G}, Sacrifice a Forest: Regenerate Uktabi Wildcats. mana={4}{G} @@ -103577,16 +103550,16 @@ toughness=8 [/card] [card] name=Ulasht, the Hate Seed -auto=foreach(other creature[red]|myBattlefield) counter(1/1,1) -auto=foreach(other creature[green]|myBattlefield) counter(1/1,1) +auto=foreach(other creature[red]|myBattlefield) counter(1/1,1) oneshot +auto=foreach(other creature[green]|myBattlefield) counter(1/1,1) oneshot auto={1}{C(1/1,-1)}:damage:1 target(creature) auto={1}{C(1/1,-1)}:token(Saproling,Creature Saproling,1/1,green) text=Ulasht, the Hate Seed enters the battlefield with a +1/+1 counter on it for each other red creature you control and a +1/+1 counter on it for each other green creature you control. -- {1}, Remove a +1/+1 counter from Ulasht: Choose one - Ulasht deals 1 damage to target creature; or put a 1/1 green Saproling creature token onto the battlefield. mana={2}{R}{G} type=Legendary Creature subtype=Hellion Hydra -power=* -toughness=* +power=0 +toughness=0 [/card] [card] name=Ultimate Price @@ -103661,7 +103634,7 @@ type=Artifact [/card] [card] name=Umbra Stalker -auto=thisforeach(variable{type:manab:mygraveyard}>0) 1/1 +auto=type:manab:mygraveyard/type:manab:mygraveyard cdaactive text=Chroma - Umbra Stalker's power and toughness are each equal to the number of black mana symbols in the mana costs of cards in your graveyard. mana={4}{B}{B}{B} type=Creature @@ -107478,7 +107451,7 @@ toughness=2 name=Elemental type=Creature subtype=Elemental -auto=foreach(creature|mybattlefield) 1/1 +auto=type:creature:mybattlefield/type:creature:mybattlefield cdaactive text=This creature's power and toughness are each equal to the number of creature cards in its controller's battlefield. power=* toughness=* @@ -109682,7 +109655,7 @@ toughness=3 [/card] [card] name=Wayfaring Temple -auto=foreach(creature|mybattlefield) 1/1 +auto=type:creature:mybattlefield/type:creature:mybattlefield cdaactive auto=@combatdamaged(player) from(this) restriction{type(creature[token]|mybattlefield)~morethan~0}:name(populate) clone notatarget(creature[token]|mybattlefield) text=Wayfaring Temple's power and toughness are each equal to the number of creatures you control. -- Whenever Wayfaring Temple deals combat damage to a player, populate. (Put a token onto the battlefield that's a copy of a creature token you control.) mana={1}{G}{W} @@ -110732,7 +110705,7 @@ toughness=4 [card] name=Wilderness Elemental abilities=trample -auto=foreach(land[-basic]|opponentBattlefield) 1/0 +auto=type:land[-basic]:opponentbattlefield/3 cdaactive text=Trample -- Wilderness Elemental's power is equal to the number of nonbasic lands your opponents control. mana={1}{R}{G} type=Creature @@ -112791,8 +112764,7 @@ type=Legendary Land [/card] [card] name=Yavimaya Kavu -auto=foreach(creature[red]|battlefield) 1/0 -auto=foreach(creature[green]|battlefield) 0/1 +auto=type:creature[red]:battlefield/type:creature[green]:battlefield cdaactive text=Yavimaya Kavu's power is equal to the number of red creatures on the battlefield. -- Yavimaya Kavu's toughness is equal to the number of green creatures on the battlefield. mana={2}{R}{G} type=Creature diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index eec795a76..8e70d92c8 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -402,7 +402,7 @@ private: } TargetChooserFactory tf(card->getObserver()); TargetChooser * tc = tf.createTargetChooser(theType.c_str(),NULL); - tc->other = other; + tc->other = other; for (int i = 0; i < 2; i++) { Player * p = card->getObserver()->players[i]; @@ -650,6 +650,61 @@ private: { intValue = target->controller()->opponent()->game->hand->nb_cards; } + else if (s == "pancientooze")//Ancient Ooze + { + intValue = 0; + for (int j = card->controller()->game->inPlay->nb_cards - 1; j >= 0; --j) + { + if (card->controller()->game->inPlay->cards[j]->hasType(Subtypes::TYPE_CREATURE) && card->controller()->game->inPlay->cards[j] != card) + { + intValue += card->controller()->game->inPlay->cards[j]->getManaCost()->getConvertedCost(); + } + } + } + else if (s == "pdauntless")//Dauntless Dourbark + { + intValue = 0; + for (int j = card->controller()->game->battlefield->nb_cards - 1; j >= 0; --j) + { + if (card->controller()->game->battlefield->cards[j]->hasType("forest")) + { + intValue += 1; + } + if (card->controller()->game->battlefield->cards[j]->hasType("treefolk")) + { + intValue += 1; + } + } + } + else if (s == "pbasiclandtypes")//Basic Land types + { + intValue = 0; + int forest, plains, swamp, island, mountain = 0; + for (int j = card->controller()->game->battlefield->nb_cards - 1; j >= 0; --j) + { + if (card->controller()->game->battlefield->cards[j]->hasType("forest")) + { + forest = 1; + } + if (card->controller()->game->battlefield->cards[j]->hasType("plains")) + { + plains = 1; + } + if (card->controller()->game->battlefield->cards[j]->hasType("swamp")) + { + swamp = 1; + } + if (card->controller()->game->battlefield->cards[j]->hasType("island")) + { + island = 1; + } + if (card->controller()->game->battlefield->cards[j]->hasType("mountain")) + { + mountain = 1; + } + } + intValue = mountain + island + forest + swamp + plains; + } else if (s == "myname")//Plague Rats and others { intValue = 0; From 478dea6af427569f45ed77621dc7ed4e17f80806 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 17 Sep 2015 21:30:55 +0800 Subject: [PATCH 10/14] Tidy up a little... --- projects/mtg/include/AllAbilities.h | 51 ++++---------- projects/mtg/include/MTGCardInstance.h | 15 ++++ projects/mtg/src/AllAbilities.cpp | 22 ++---- projects/mtg/src/Counters.cpp | 14 +--- projects/mtg/src/MTGCardInstance.cpp | 95 ++++++++++++++++++++++++++ 5 files changed, 129 insertions(+), 68 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 8e70d92c8..17f62efe8 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -2420,9 +2420,9 @@ public: { SAFE_DELETE(wppt); if(cda) - wppt = NEW WParsedPT(ReplaceString(PT, "cdaactive", ""),NULL,(MTGCardInstance *) source); + wppt = NEW WParsedPT(ReplaceString(PT, " cdaactive", ""),NULL,(MTGCardInstance *) source); else - wppt = NEW WParsedPT(ReplaceString(PT, "nonstatic", ""),NULL,(MTGCardInstance *) source); + wppt = NEW WParsedPT(ReplaceString(PT, " nonstatic", ""),NULL,(MTGCardInstance *) source); } MTGCardInstance * _target = (MTGCardInstance *) target; _target->power += wppt->power.getValue(); @@ -2434,9 +2434,9 @@ public: { SAFE_DELETE(wppt); if(cda) - wppt = NEW WParsedPT(ReplaceString(PT, "cdaactive", ""),NULL,(MTGCardInstance *) source); + wppt = NEW WParsedPT(ReplaceString(PT, " cdaactive", ""),NULL,(MTGCardInstance *) source); else - wppt = NEW WParsedPT(ReplaceString(PT, "nonstatic", ""),NULL,(MTGCardInstance *) source); + wppt = NEW WParsedPT(ReplaceString(PT, " nonstatic", ""),NULL,(MTGCardInstance *) source); } ((MTGCardInstance *) target)->origpower = wppt->power.getValue(); ((MTGCardInstance *) target)->origtoughness = (wppt->toughness.getValue() + ((MTGCardInstance *) target)->life)-((MTGCardInstance *) target)->life;//what? @@ -2449,27 +2449,17 @@ public: { SAFE_DELETE(wppt); if(cda) - wppt = NEW WParsedPT(ReplaceString(PT, "cdaactive", ""),NULL,(MTGCardInstance *) source); + wppt = NEW WParsedPT(ReplaceString(PT, " cdaactive", ""),NULL,(MTGCardInstance *) source); else - wppt = NEW WParsedPT(ReplaceString(PT, "nonstatic", ""),NULL,(MTGCardInstance *) source); + wppt = NEW WParsedPT(ReplaceString(PT, " nonstatic", ""),NULL,(MTGCardInstance *) source); } if(cda) {//Characteristic-defining abilities - _target->origpower = wppt->power.getValue();//set orig pt - _target->origtoughness = wppt->toughness.getValue(); - _target->setPower(_target->origpower);//update PT - _target->setToughness(_target->origtoughness); - _target->power += _target->pbonus;//add new bonus - _target->addToToughness(_target->tbonus); + _target->cdaPT(wppt->power.getValue(),wppt->toughness.getValue()); } else { - _target->power -= _target->pbonus;//remove current bonuses - _target->addToToughness(-_target->tbonus); - _target->pbonus += wppt->power.getValue();//update bonus - _target->tbonus += wppt->toughness.getValue(); - _target->power += _target->pbonus;//add new bonus - _target->addToToughness(_target->tbonus); + _target->addptbonus(wppt->power.getValue(),wppt->toughness.getValue()); } if(_target->has(Constants::INDESTRUCTIBLE) && wppt->toughness.getValue() < 0 && _target->toughness <= 0) { @@ -2485,12 +2475,7 @@ public: } else { - ((MTGCardInstance *) target)->power -= ((MTGCardInstance *) target)->pbonus; - ((MTGCardInstance *) target)->addToToughness(-((MTGCardInstance *) target)->tbonus); - ((MTGCardInstance *) target)->pbonus -= wppt->power.getValue(); - ((MTGCardInstance *) target)->tbonus -= wppt->toughness.getValue(); - ((MTGCardInstance *) target)->power += ((MTGCardInstance *) target)->pbonus; - ((MTGCardInstance *) target)->addToToughness(((MTGCardInstance *) target)->tbonus); + ((MTGCardInstance *) target)->removeptbonus(wppt->power.getValue(),wppt->toughness.getValue()); } return 1; } @@ -2500,9 +2485,9 @@ public: { SAFE_DELETE(wppt); if(cda) - wppt = NEW WParsedPT(ReplaceString(PT, "cdaactive", ""),NULL,(MTGCardInstance *) source); + wppt = NEW WParsedPT(ReplaceString(PT, " cdaactive", ""),NULL,(MTGCardInstance *) source); else - wppt = NEW WParsedPT(ReplaceString(PT, "nonstatic", ""),NULL,(MTGCardInstance *) source); + wppt = NEW WParsedPT(ReplaceString(PT, " nonstatic", ""),NULL,(MTGCardInstance *) source); } sprintf(menuText, "%i/%i", wppt->power.getValue(), wppt->toughness.getValue()); return menuText; @@ -5846,23 +5831,13 @@ public: { nbOpponents = source->blockers.size(); if (nbOpponents <= MaxOpponent) return 0; - source->power -= source->pbonus; - source->addToToughness(-source->tbonus); - source->pbonus += PowerModifier * (nbOpponents - MaxOpponent); - source->tbonus += ToughnessModifier * (nbOpponents - MaxOpponent); - source->power += source->pbonus; - source->addToToughness(source->tbonus); + source->addptbonus(PowerModifier * (nbOpponents - MaxOpponent),ToughnessModifier * (nbOpponents - MaxOpponent)); } else if (WEventPhaseChange* pe = dynamic_cast(event)) { if (MTG_PHASE_AFTER_EOT == pe->to->id && nbOpponents > MaxOpponent) { - source->power -= source->pbonus; - source->addToToughness(-source->tbonus); - source->pbonus -= PowerModifier * (nbOpponents - MaxOpponent); - source->tbonus -= ToughnessModifier * (nbOpponents - MaxOpponent); - source->power += source->pbonus; - source->addToToughness(source->tbonus); + source->removeptbonus(PowerModifier * (nbOpponents - MaxOpponent),ToughnessModifier * (nbOpponents - MaxOpponent)); nbOpponents = 0; } } diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index 38a4a5cd0..45dd49439 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -220,6 +220,21 @@ public: void tap(); void attemptUntap(); + //cda and other func + void stripPTbonus(); + void minusPTbonus(int p = 0, int t = 0); + void plusPTbonus(int p = 0, int t = 0); + void applyPTbonus(); + void addcounter(int p = 0, int t = 0); + void removecounter(int p = 0, int t = 0); + void addptbonus(int p = 0, int t = 0); + void removeptbonus(int p = 0, int t = 0); + void addbaseP(int p = 0); + void addbaseT(int t = 0); + void revertbaseP(); + void revertbaseT(); + void cdaPT(int p = 0, int t = 0); + void eventattacked(); void eventattackedAlone(); void eventattackednotblocked(); diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 1bb059a35..7265690c7 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -4186,10 +4186,7 @@ for (it = types.begin(); it != types.end(); it++) if(newpowerfound ) { WParsedInt * val = NEW WParsedInt(newpower,NULL, source); - _target->basepower = val->getValue(); - _target->power -= _target->pbonus; - _target->power = (_target->power + _target->basepower) - _target->power; - _target->power += _target->pbonus; + _target->addbaseP(val->getValue()); delete val; } if(newtoughnessfound ) @@ -4197,10 +4194,7 @@ for (it = types.begin(); it != types.end(); it++) //and you turn it into 1/1, the 1 damage is still there and the creature must die... //the toughness is intact but what we see in the game is the life... WParsedInt * val = NEW WParsedInt(newtoughness,NULL, source); - _target->basetoughness = val->getValue(); - _target->addToToughness(-_target->tbonus); - _target->addToToughness(_target->basetoughness - _target->toughness); - _target->addToToughness(_target->tbonus); + _target->addbaseT(val->getValue()); delete val; } @@ -4290,19 +4284,11 @@ int ATransformer::destroy() if(newpowerfound ) { - _target->power -= _target->pbonus; - _target->power += _target->origpower; - _target->power -= _target->basepower; - _target->power += _target->pbonus; - _target->basepower = _target->origpower; + _target->revertbaseP(); } if(newtoughnessfound ) { - _target->addToToughness(-_target->tbonus); - _target->addToToughness(_target->origtoughness); - _target->addToToughness(-_target->basetoughness); - _target->addToToughness(_target->tbonus); - _target->basetoughness = _target->origtoughness; + _target->revertbaseT(); } if(newAbilityFound) { diff --git a/projects/mtg/src/Counters.cpp b/projects/mtg/src/Counters.cpp index 25f1f90a5..a1111c928 100644 --- a/projects/mtg/src/Counters.cpp +++ b/projects/mtg/src/Counters.cpp @@ -56,12 +56,7 @@ int Counter::added() { if (power != 0 || toughness != 0) { - target->power -= target->pbonus; - target->addToToughness(-target->tbonus); - target->pbonus += power; - target->tbonus += toughness; - target->power += target->pbonus; - target->addToToughness(target->pbonus); + target->addcounter(power, toughness); } return 1; } @@ -70,12 +65,7 @@ int Counter::removed() { if (power != 0 || toughness != 0) { - target->power -= target->pbonus; - target->addToToughness(-target->tbonus); - target->pbonus -= power; - target->tbonus -= toughness; - target->power += target->pbonus; - target->addToToughness(target->pbonus); + target->removecounter(power, toughness); } return 1; } diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 6a9a7d8a0..b64305392 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -599,6 +599,101 @@ int MTGCardInstance::setToughness(int value) return 1; } +void MTGCardInstance::stripPTbonus() +{ + power -= pbonus; + addToToughness(-tbonus); +} + +void MTGCardInstance::plusPTbonus(int p, int t) +{ + pbonus += p; + tbonus += t; +} + +void MTGCardInstance::minusPTbonus(int p, int t) +{ + pbonus -= p; + tbonus -= t; +} + +void MTGCardInstance::applyPTbonus() +{ + power += pbonus; + addToToughness(tbonus); +} + +void MTGCardInstance::addcounter(int p, int t) +{ + stripPTbonus(); + plusPTbonus(p,t); + applyPTbonus(); +} + +void MTGCardInstance::addptbonus(int p, int t) +{ + stripPTbonus(); + plusPTbonus(p,t); + applyPTbonus(); +} + +void MTGCardInstance::removecounter(int p, int t) +{ + stripPTbonus(); + minusPTbonus(p,t); + applyPTbonus(); +} + +void MTGCardInstance::removeptbonus(int p, int t) +{ + stripPTbonus(); + minusPTbonus(p,t); + applyPTbonus(); +} + +void MTGCardInstance::addbaseP(int p) +{ + basepower = p; + power -= pbonus; + power = p; + power += pbonus; +} + +void MTGCardInstance::addbaseT(int t) +{ + basetoughness = t; + addToToughness(-tbonus); + addToToughness(t - toughness); + addToToughness(tbonus); +} + +void MTGCardInstance::revertbaseP() +{ + power -= pbonus; + power += origpower; + power -= basepower; + power += pbonus; + basepower = origpower; +} + +void MTGCardInstance::revertbaseT() +{ + addToToughness(-tbonus); + addToToughness(origtoughness); + addToToughness(-basetoughness); + addToToughness(tbonus); + basetoughness = origtoughness; +} + +void MTGCardInstance::cdaPT(int p, int t) +{ + origpower = p; + origtoughness = t; + setPower(p); + setToughness(t); + applyPTbonus(); +} + int MTGCardInstance::canBlock() { if (tapped) From 53153b237c25d81c67af4a9c5f41a5c4af6f7a3b Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 17 Sep 2015 22:50:21 +0800 Subject: [PATCH 11/14] CDA test # 1 Testing layer 7a, 7b and 7c :) --- projects/mtg/bin/Res/test/CDA#1.txt | 46 +++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 projects/mtg/bin/Res/test/CDA#1.txt diff --git a/projects/mtg/bin/Res/test/CDA#1.txt b/projects/mtg/bin/Res/test/CDA#1.txt new file mode 100644 index 000000000..4c583a5e9 --- /dev/null +++ b/projects/mtg/bin/Res/test/CDA#1.txt @@ -0,0 +1,46 @@ +#Testing CDA Tarmogoyf vs Godhead of Awe +#Godhead of Awe makes other creatures 1/1 on layer 7b +#Tarmogoyf's CDA ability is on layer 7a so it will be overriden +#by Godhead of Awe. Giant Growth's ability is on layer 7c so +#the +3/+3 bonus is intact. :) +[INIT] +FIRSTMAIN +[PLAYER1] +inplay:Concordant Crossroads, Godhead of Awe, Forest +hand:Tarmogoyf, Giant Growth +graveyard:mountain, lightning bolt, grizzly bear +manapool:{1}{G} +[PLAYER2] +[DO] +Tarmogoyf +next +next +Tarmogoyf +next +eot +eot +#untap +next +#upkeep +next +#draw +next +#main1 +Forest +Giant Growth +Tarmogoyf +next +#combat begin +next +#attackers +Tarmogoyf +eot +[ASSERT] +UNTAP +[PLAYER1] +inplay:Concordant Crossroads, Godhead of Awe, Tarmogoyf, Forest +graveyard:mountain, lightning bolt, grizzly bear, Giant Growth +manapool:{0} +[PLAYER2] +life:15 +[END] From 7ce05fb4fce692a480cabd54eccac89fd8ed0f5b Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Fri, 18 Sep 2015 05:27:48 +0800 Subject: [PATCH 12/14] CDA test # 2 --- projects/mtg/bin/Res/test/CDA#2.txt | 38 +++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 projects/mtg/bin/Res/test/CDA#2.txt diff --git a/projects/mtg/bin/Res/test/CDA#2.txt b/projects/mtg/bin/Res/test/CDA#2.txt new file mode 100644 index 000000000..c1fca2d5b --- /dev/null +++ b/projects/mtg/bin/Res/test/CDA#2.txt @@ -0,0 +1,38 @@ +#Testing CDA Turn to Frog vs Krosan Cloudscraper +#Krosan Cloudscraper that is turned into frog with 1 damage +#from Lightning Dart must die because when you change +#the power and toughness into 1/1, the 1 point of damage +#is taken into account... +[INIT] +FIRSTMAIN +[PLAYER1] +inplay:Krosan Cloudscraper +[PLAYER2] +inplay:Mountain, Plains, Swamp, Island +hand:Lightning Dart, Turn to Frog +[DO] +next +next +Krosan Cloudscraper +next +no +yes +Mountain +Plains +Lightning Dart +Krosan Cloudscraper +Swamp +Island +Turn to Frog +Krosan Cloudscraper +endinterruption +eot +[ASSERT] +UNTAP +[PLAYER1] +graveyard:Krosan Cloudscraper +[PLAYER2] +inplay:Mountain, Plains, Swamp, Island +graveyard:Lightning Dart, Turn to Frog +life:20 +[END] From 8c9a98e3e9c33f15f527e270998c6c36be6d9938 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Fri, 18 Sep 2015 05:31:13 +0800 Subject: [PATCH 13/14] Update _tests.txt --- projects/mtg/bin/Res/test/_tests.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index eede5159b..34d5ed0d0 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -210,6 +210,8 @@ Call_to_Heel_1.txt Call_to_Heel_2.txt castle.txt cathodion.txt +CDA#1.txt +CDA#2.txt celestial_mantle.txt celestial_purge.txt celestial_sword.txt From 13bb6dbe9383c13cdf1a6656c0230e197f2b38ad Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Fri, 18 Sep 2015 06:03:53 +0800 Subject: [PATCH 14/14] Update Token.cpp Fix typo --- projects/mtg/src/Token.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/mtg/src/Token.cpp b/projects/mtg/src/Token.cpp index a63bb9167..bb303558f 100644 --- a/projects/mtg/src/Token.cpp +++ b/projects/mtg/src/Token.cpp @@ -52,7 +52,7 @@ Token::Token(const Token& source) : origpower = source.origpower; origtoughness = source.origtoughness; basepower = source.origpower; - basetoughness = source.origpower; + basetoughness = source.origtoughness; pbonus = source.pbonus; tbonus = source.tbonus; rarity = source.rarity;