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;