Tidy up a little...
This commit is contained in:
@@ -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<WEventPhaseChange*>(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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user