Separated PT Modifiers, Fixed Changeling, Modified Counter as a cost
CDA Todo
This commit is contained in:
@@ -2260,16 +2260,18 @@ public:
|
||||
{
|
||||
if(!nonstatic)
|
||||
return;
|
||||
((MTGCardInstance *) target)->power -= wppt->power.getValue();
|
||||
((MTGCardInstance *) target)->addToToughness(-wppt->toughness.getValue());
|
||||
((MTGCardInstance *) target)->pbonus -= wppt->power.getValue();
|
||||
((MTGCardInstance *) target)->tbonus -= wppt->toughness.getValue();
|
||||
((MTGCardInstance *) target)->applyPTL();
|
||||
if(PT.size())
|
||||
{
|
||||
SAFE_DELETE(wppt);
|
||||
wppt = NEW WParsedPT(PT,NULL,(MTGCardInstance *) source);
|
||||
}
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
_target->power += wppt->power.getValue();
|
||||
_target->addToToughness(wppt->toughness.getValue());
|
||||
_target->pbonus += wppt->power.getValue();
|
||||
_target->tbonus += wppt->toughness.getValue();
|
||||
_target->applyPTL();
|
||||
}
|
||||
|
||||
int addToGame()
|
||||
@@ -2280,8 +2282,9 @@ public:
|
||||
SAFE_DELETE(wppt);
|
||||
wppt = NEW WParsedPT(PT,NULL,(MTGCardInstance *) source);
|
||||
}
|
||||
_target->power += wppt->power.getValue();
|
||||
_target->addToToughness(wppt->toughness.getValue());
|
||||
_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);
|
||||
@@ -2291,8 +2294,9 @@ public:
|
||||
|
||||
int destroy()
|
||||
{
|
||||
((MTGCardInstance *) target)->power -= wppt->power.getValue();
|
||||
((MTGCardInstance *) target)->addToToughness(-wppt->toughness.getValue());
|
||||
((MTGCardInstance *) target)->pbonus -= wppt->power.getValue();
|
||||
((MTGCardInstance *) target)->tbonus -= wppt->toughness.getValue();
|
||||
((MTGCardInstance *) target)->applyPTL();
|
||||
return 1;
|
||||
}
|
||||
const string getMenuText()
|
||||
@@ -4027,8 +4031,6 @@ string menu;
|
||||
class ASwapPT: public InstantAbility
|
||||
{
|
||||
public:
|
||||
int oldpower;
|
||||
int oldtoughness;
|
||||
ASwapPT(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target) :
|
||||
InstantAbility(observer, _id, _source, _target)
|
||||
{
|
||||
@@ -4042,13 +4044,13 @@ public:
|
||||
{
|
||||
while (_target->next)
|
||||
_target = _target->next; //This is for cards such as rampant growth
|
||||
oldpower = _target->power;
|
||||
oldtoughness = _target->toughness;
|
||||
|
||||
_target->addToToughness(oldpower);
|
||||
_target->addToToughness(-oldtoughness);
|
||||
_target->power = oldtoughness;
|
||||
|
||||
if(_target->isPTswitch)
|
||||
_target->isPTswitch = false;
|
||||
else
|
||||
_target->isPTswitch = true;
|
||||
|
||||
_target->applyPTL();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -4060,12 +4062,10 @@ public:
|
||||
{
|
||||
while (_target->next)
|
||||
_target = _target->next; //This is for cards such as rampant growth
|
||||
oldpower = _target->power;
|
||||
oldtoughness = _target->toughness;
|
||||
|
||||
_target->isPTswitch = false;
|
||||
|
||||
_target->addToToughness(oldpower);
|
||||
_target->addToToughness(-oldtoughness);
|
||||
_target->power = oldtoughness;
|
||||
_target->applyPTL();
|
||||
|
||||
}
|
||||
return 1;
|
||||
@@ -4307,13 +4307,9 @@ public:
|
||||
|
||||
string newpower;
|
||||
bool newpowerfound;
|
||||
|
||||
int oldpower;
|
||||
int oldpowerbonus;
|
||||
string newtoughness;
|
||||
bool newtoughnessfound;
|
||||
int oldtoughness;
|
||||
int oldtoughnessbonus;
|
||||
|
||||
map<Damageable *, vector<MTGAbility *> > newAbilities;
|
||||
vector<string> newAbilitiesList;
|
||||
bool newAbilityFound;
|
||||
@@ -5651,15 +5647,17 @@ public:
|
||||
{
|
||||
nbOpponents = source->blockers.size();
|
||||
if (nbOpponents <= MaxOpponent) return 0;
|
||||
source->power += PowerModifier * (nbOpponents - MaxOpponent);
|
||||
source->addToToughness(ToughnessModifier * (nbOpponents - MaxOpponent));
|
||||
source->pbonus += PowerModifier * (nbOpponents - MaxOpponent);
|
||||
source->tbonus += ToughnessModifier * (nbOpponents - MaxOpponent);
|
||||
source->applyPTL();
|
||||
}
|
||||
else if (WEventPhaseChange* pe = dynamic_cast<WEventPhaseChange*>(event))
|
||||
{
|
||||
if (MTG_PHASE_AFTER_EOT == pe->to->id && nbOpponents > MaxOpponent)
|
||||
{
|
||||
source->power -= PowerModifier * (nbOpponents - MaxOpponent);
|
||||
source->addToToughness(-ToughnessModifier * (nbOpponents - MaxOpponent));
|
||||
source->pbonus -= PowerModifier * (nbOpponents - MaxOpponent);
|
||||
source->tbonus -= ToughnessModifier * (nbOpponents - MaxOpponent);
|
||||
source->applyPTL();
|
||||
nbOpponents = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,9 @@ public:
|
||||
MTGCardInstance * target;
|
||||
Counters(MTGCardInstance * _target);
|
||||
~Counters();
|
||||
int addCounter(const char * _name, int _power = 0, int _toughness = 0);
|
||||
int addCounter(const char * _name, int _power = 0, int _toughness = 0, bool _noevent = false);
|
||||
int addCounter(int _power, int _toughness);
|
||||
int addCounter(int _power, int _toughness, bool _noevent);
|
||||
int removeCounter(const char * _name, int _power = 0, int _toughness = 0);
|
||||
int removeCounter(int _power, int _toughness);
|
||||
Counter * hasCounter(const char * _name, int _power = 0, int _toughness = 0);
|
||||
|
||||
@@ -73,8 +73,10 @@ public:
|
||||
int isToken;
|
||||
int origpower;
|
||||
int basepower;//to keep origpower intact
|
||||
int pbonus;
|
||||
int origtoughness;
|
||||
int basetoughness;//to keep origtoughness intact
|
||||
int tbonus;
|
||||
int isMultiColored;
|
||||
int isLeveler;
|
||||
bool enchanted;
|
||||
@@ -184,6 +186,11 @@ public:
|
||||
|
||||
int addToToughness(int value);
|
||||
int setToughness(int value);
|
||||
bool isSettingBase;
|
||||
bool isPTswitch;
|
||||
int oldP;
|
||||
int oldT;
|
||||
void applyPTL();
|
||||
|
||||
vector<TargetChooser *>protections;
|
||||
int addProtection(TargetChooser * tc);
|
||||
|
||||
@@ -4183,23 +4183,17 @@ 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);
|
||||
oldpower = _target->power;
|
||||
oldpowerbonus = oldpower - _target->basepower;
|
||||
_target->setPower(oldpowerbonus + val->getValue());
|
||||
_target->basepower = val->getValue();
|
||||
//?effects that change pt outside this?
|
||||
//_target->power += reapplyCountersBonus(_target,false,true);
|
||||
_target->isSettingBase = true;
|
||||
_target->applyPTL();
|
||||
delete val;
|
||||
}
|
||||
if(newtoughnessfound )
|
||||
{//setting p/t only overrides base p/t as of M15 changes
|
||||
WParsedInt * val = NEW WParsedInt(newtoughness,NULL, source);
|
||||
oldtoughness = _target->toughness;
|
||||
oldtoughnessbonus = oldtoughness - _target->basetoughness;
|
||||
_target->setToughness(oldtoughnessbonus + val->getValue());
|
||||
_target->basetoughness = val->getValue();
|
||||
//_target->addToToughness(reapplyCountersBonus(_target,true,false));
|
||||
_target->life = _target->toughness;
|
||||
_target->isSettingBase = true;
|
||||
_target->applyPTL();
|
||||
delete val;
|
||||
}
|
||||
|
||||
@@ -4286,16 +4280,15 @@ int ATransformer::destroy()
|
||||
|
||||
if(newpowerfound )
|
||||
{//override since we changed tha base, the bonus must have changed
|
||||
oldpowerbonus = (_target->power - _target->basepower);//math hurts my head...it's all over the place :P
|
||||
_target->setPower(_target->origpower + oldpowerbonus);
|
||||
_target->basepower = _target->origpower;//revert
|
||||
_target->isSettingBase = false;
|
||||
_target->basepower = _target->origpower;
|
||||
_target->applyPTL();
|
||||
}
|
||||
if(newtoughnessfound )
|
||||
{//override since we changed tha base, the bonus must have changed
|
||||
oldtoughnessbonus = (_target->toughness - _target->basetoughness);
|
||||
_target->setToughness(_target->origtoughness + oldtoughnessbonus);
|
||||
_target->basetoughness = _target->origtoughness;//revert
|
||||
_target->life = _target->toughness;//update
|
||||
{
|
||||
_target->isSettingBase = false;
|
||||
_target->basetoughness = _target->origtoughness;
|
||||
_target->applyPTL();
|
||||
}
|
||||
if(newAbilityFound)
|
||||
{
|
||||
|
||||
@@ -56,8 +56,9 @@ int Counter::added()
|
||||
{
|
||||
if (power != 0 || toughness != 0)
|
||||
{
|
||||
target->power += power;
|
||||
target->addToToughness(toughness);
|
||||
target->pbonus += power;
|
||||
target->tbonus += toughness;
|
||||
target->applyPTL();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -66,8 +67,9 @@ int Counter::removed()
|
||||
{
|
||||
if (power != 0 || toughness != 0)
|
||||
{
|
||||
target->power -= power;
|
||||
target->addToToughness(-toughness);
|
||||
target->pbonus -= power;
|
||||
target->tbonus -= toughness;
|
||||
target->applyPTL();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -85,7 +87,7 @@ Counters::~Counters()
|
||||
}
|
||||
}
|
||||
|
||||
int Counters::addCounter(const char * _name, int _power, int _toughness)
|
||||
int Counters::addCounter(const char * _name, int _power, int _toughness, bool _noevent)
|
||||
{
|
||||
/*420.5n If a permanent has both a +1/+1 counter and a -1/-1 counter on it, N +1/+1 and N -1/-1 counters are removed from it, where N is the smaller of the number of +1/+1 and -1/-1 counters on it.*/
|
||||
GameObserver *g = target->getObserver();
|
||||
@@ -109,9 +111,12 @@ int Counters::addCounter(const char * _name, int _power, int _toughness)
|
||||
Counter * counter = NEW Counter(target, _name, _power, _toughness);
|
||||
counters.push_back(counter);
|
||||
counter->added();
|
||||
WEvent * w = NEW WEventCounters(this,_name,_power,_toughness,true,false);
|
||||
dynamic_cast<WEventCounters*>(w)->targetCard = this->target;
|
||||
g->receiveEvent(w);
|
||||
if (!_noevent)
|
||||
{
|
||||
WEvent * w = NEW WEventCounters(this,_name,_power,_toughness,true,false);
|
||||
dynamic_cast<WEventCounters*>(w)->targetCard = this->target;
|
||||
g->receiveEvent(w);
|
||||
}
|
||||
mCount++;
|
||||
this->target->doDamageTest = 1;
|
||||
this->target->afterDamage();
|
||||
@@ -122,7 +127,12 @@ int Counters::addCounter(const char * _name, int _power, int _toughness)
|
||||
|
||||
int Counters::addCounter(int _power, int _toughness)
|
||||
{
|
||||
return addCounter("", _power, _toughness);
|
||||
return addCounter("", _power, _toughness, false);
|
||||
}
|
||||
|
||||
int Counters::addCounter(int _power, int _toughness, bool _noevent)
|
||||
{
|
||||
return addCounter("", _power, _toughness, _noevent);
|
||||
}
|
||||
|
||||
int Counters::init()
|
||||
|
||||
@@ -949,8 +949,8 @@ int CounterCost::doPay()
|
||||
if (counter->nb >= 0)
|
||||
{ //Add counters as a cost
|
||||
for (int i = 0; i < counter->nb; i++)
|
||||
{
|
||||
target->counters->addCounter(counter->name.c_str(), counter->power, counter->toughness);
|
||||
{//send no event because its a cost not an effect... for doubling season
|
||||
target->counters->addCounter(counter->name.c_str(), counter->power, counter->toughness, true);
|
||||
}
|
||||
if (tc)
|
||||
tc->initTargets();
|
||||
|
||||
@@ -3597,9 +3597,9 @@ int AbilityFactory::getAbilities(vector<MTGAbility *> * v, Spell * spell, MTGCar
|
||||
if(card->previous && card->previous->morphed && !card->turningOver)
|
||||
{
|
||||
magicText = card->magicTexts["facedown"];
|
||||
card->power = 2;
|
||||
card->basepower = 2;
|
||||
card->life = 2;
|
||||
card->toughness = 2;
|
||||
card->basetoughness = 2;
|
||||
card->setColor(0,1);
|
||||
card->name = "Morph";
|
||||
card->types.clear();
|
||||
@@ -3607,12 +3607,17 @@ 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->power += card->origpower-2;
|
||||
card->life += card->origtoughness-2;
|
||||
card->toughness += card->origtoughness-2;
|
||||
card->isSettingBase = false;
|
||||
card->power = card->origpower;
|
||||
card->basepower = card->origpower;
|
||||
card->life = card->origtoughness;
|
||||
card->toughness = card->origtoughness;
|
||||
card->basetoughness = card->origtoughness;
|
||||
card->setColor(0,1);
|
||||
card->name = card->model->data->name;
|
||||
card->types = card->model->data->types;
|
||||
@@ -3626,6 +3631,7 @@ 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)
|
||||
|
||||
@@ -37,8 +37,10 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to
|
||||
lifeOrig = life;
|
||||
origpower = power;
|
||||
basepower = origpower;
|
||||
pbonus = 0;
|
||||
origtoughness = toughness;
|
||||
basetoughness = origtoughness;
|
||||
tbonus = 0;
|
||||
belongs_to = arg_belongs_to;
|
||||
owner = NULL;
|
||||
if (arg_belongs_to)
|
||||
@@ -51,6 +53,8 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to
|
||||
thatmuch = 0;
|
||||
flanked = 0;
|
||||
castMethod = Constants::NOT_CAST;
|
||||
isSettingBase = false;
|
||||
isPTswitch = false;
|
||||
}
|
||||
|
||||
MTGCardInstance * MTGCardInstance::createSnapShot()
|
||||
@@ -62,6 +66,34 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to
|
||||
return snapShot;
|
||||
}
|
||||
|
||||
void MTGCardInstance::applyPTL()
|
||||
{
|
||||
//7a ??how to add cda(Characteristic Defining Ability)??
|
||||
power = origpower;
|
||||
toughness = origtoughness;
|
||||
//7b
|
||||
if (isSettingBase)
|
||||
{
|
||||
power = basepower;
|
||||
toughness = basetoughness;
|
||||
}
|
||||
//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;
|
||||
}
|
||||
/* end */
|
||||
doDamageTest = 1;
|
||||
}
|
||||
|
||||
void MTGCardInstance::copy(MTGCardInstance * card)
|
||||
{
|
||||
MTGCard * source = card->model;
|
||||
|
||||
@@ -1078,7 +1078,13 @@ bool TypeTargetChooser::canTarget(Targetable * target,bool withoutProtections)
|
||||
{
|
||||
|
||||
if (card->hasSubtype(types[i])) return true;
|
||||
if (card->data->basicAbilities[(int)Constants::CHANGELING]) return true;//changelings can be targeted as any subtype.
|
||||
if (card->data->basicAbilities[(int)Constants::CHANGELING])
|
||||
{
|
||||
if (!MTGAllCards::isSubtypeOfType(i,Subtypes::TYPE_CREATURE))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
if(card->getLCName().size())
|
||||
{
|
||||
if (MTGAllCards::findType(card->getLCName()) == types[i])
|
||||
|
||||
Reference in New Issue
Block a user