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
This commit is contained in:
Anthony Calosa
2015-09-15 06:35:07 +08:00
parent 59792b3456
commit 72aaa18a35
3 changed files with 124 additions and 26 deletions
+113 -18
View File
@@ -642,6 +642,81 @@ private:
{ {
intValue = target->controller()->opponent()->game->hand->nb_cards; 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") else if (s == "morethanfourcards")
{ {
if(card->playerTarget) if(card->playerTarget)
@@ -2253,30 +2328,37 @@ public:
WParsedPT * wppt; WParsedPT * wppt;
string PT; string PT;
bool nonstatic; bool nonstatic;
bool cda;
APowerToughnessModifier(GameObserver* observer, int id, MTGCardInstance * _source, MTGCardInstance * _target, WParsedPT * wppt,string PT,bool nonstatic) : 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) MTGAbility(observer, id, _source, _target), wppt(wppt),PT(PT),nonstatic(nonstatic)
{ {
aType = MTGAbility::STANDARD_PUMP; aType = MTGAbility::STANDARD_PUMP;
} cda = PT.find("cdaactive") != string::npos;
}
void Update(float) void Update(float)
{
if(!nonstatic)
return;
if(!((MTGCardInstance *) target)->isSettingBase)
{ {
if(!nonstatic) ((MTGCardInstance *) target)->power -= wppt->power.getValue();
return; ((MTGCardInstance *) target)->addToToughness(-wppt->toughness.getValue());
((MTGCardInstance *) target)->pbonus -= wppt->power.getValue();
((MTGCardInstance *) target)->tbonus -= wppt->toughness.getValue();
((MTGCardInstance *) target)->applyPTL();
if(PT.size()) if(PT.size())
{ {
SAFE_DELETE(wppt); SAFE_DELETE(wppt);
wppt = NEW WParsedPT(PT,NULL,(MTGCardInstance *) source); wppt = NEW WParsedPT(PT,NULL,(MTGCardInstance *) source);
} }
MTGCardInstance * _target = (MTGCardInstance *) target; MTGCardInstance * _target = (MTGCardInstance *) target;
_target->pbonus += wppt->power.getValue(); _target->power += wppt->power.getValue();
_target->tbonus += wppt->toughness.getValue(); _target->addToToughness(wppt->toughness.getValue());
_target->applyPTL(); //update
if(cda)
{//7a update wppt
_target->origpower = wppt->power.getValue();
_target->origtoughness = wppt->toughness.getValue();
}
} }
}
int addToGame() int addToGame()
{ {
MTGCardInstance * _target = (MTGCardInstance *) target; MTGCardInstance * _target = (MTGCardInstance *) target;
@@ -2285,21 +2367,36 @@ public:
SAFE_DELETE(wppt); SAFE_DELETE(wppt);
wppt = NEW WParsedPT(PT,NULL,(MTGCardInstance *) source); wppt = NEW WParsedPT(PT,NULL,(MTGCardInstance *) source);
} }
_target->pbonus += wppt->power.getValue(); if(cda)
_target->tbonus += wppt->toughness.getValue(); {//Characteristic-defining abilities
_target->applyPTL(); _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) if(_target->has(Constants::INDESTRUCTIBLE) && wppt->toughness.getValue() < 0 && _target->toughness <= 0)
{ {
_target->controller()->game->putInGraveyard(_target); _target->controller()->game->putInGraveyard(_target);
} }
return MTGAbility::addToGame(); return MTGAbility::addToGame();
} }
int destroy() int destroy()
{ {
if(cda)
{
;
}
else
{
((MTGCardInstance *) target)->pbonus -= wppt->power.getValue(); ((MTGCardInstance *) target)->pbonus -= wppt->power.getValue();
((MTGCardInstance *) target)->tbonus -= wppt->toughness.getValue(); ((MTGCardInstance *) target)->tbonus -= wppt->toughness.getValue();
((MTGCardInstance *) target)->applyPTL(); ((MTGCardInstance *) target)->applyPTL();
}
return 1; return 1;
} }
const string getMenuText() const string getMenuText()
@@ -2318,12 +2415,10 @@ public:
a->wppt = NEW WParsedPT(*(a->wppt)); a->wppt = NEW WParsedPT(*(a->wppt));
return a; return a;
} }
~APowerToughnessModifier() ~APowerToughnessModifier()
{ {
delete (wppt); delete (wppt);
} }
}; };
class GenericInstantAbility: public InstantAbility, public NestedAbility class GenericInstantAbility: public InstantAbility, public NestedAbility
+7 -2
View File
@@ -2629,7 +2629,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
int MaxOpponent = atoi(rampageParameters[1].c_str()); int MaxOpponent = atoi(rampageParameters[1].c_str());
return NEW ARampageAbility(observer, id, card, power, toughness, MaxOpponent); return NEW ARampageAbility(observer, id, card, power, toughness, MaxOpponent);
} }
//evole //evole
if (s.find("evolve") != string::npos) 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 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); return NEW PTInstant(observer, id, card, target, wppt,s,nonstatic);
} }
+4 -6
View File
@@ -68,7 +68,7 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to
void MTGCardInstance::applyPTL() void MTGCardInstance::applyPTL()
{ {
//7a ??how to add cda(Characteristic Defining Ability)?? //7a ??(Characteristic Defining Ability)??
power = origpower; power = origpower;
toughness = origtoughness; toughness = origtoughness;
//7b //7b
@@ -80,17 +80,15 @@ void MTGCardInstance::applyPTL()
//7c - 7d shared? //7c - 7d shared?
power += pbonus; power += pbonus;
toughness += tbonus; toughness += tbonus;
life = toughness;
//7e switch is last //7e switch is last
if (isPTswitch) if (isPTswitch)
{ {
oldP = power; oldP = power;
oldT = toughness; oldT = toughness;
this->addToToughness(oldP); toughness = oldP;
this->addToToughness(-oldT); power = oldT;
this->power = oldT;
} }
/* end */ life = toughness;
doDamageTest = 1; doDamageTest = 1;
} }