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 :)
This commit is contained in:
Anthony Calosa
2015-09-16 06:42:02 +08:00
parent 72aaa18a35
commit 6aab17d0b3
6 changed files with 94 additions and 110 deletions
+19 -11
View File
@@ -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)
{
+8 -2
View File
@@ -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;
}
+5 -11
View File
@@ -3602,9 +3602,9 @@ int AbilityFactory::getAbilities(vector<MTGAbility *> * 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<MTGAbility *> * 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<MTGAbility *> * 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)
-28
View File
@@ -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;