Totem Armor

This commit is contained in:
Anthony Calosa
2017-03-14 03:40:29 +08:00
parent bef1f6d8b8
commit 0778b13e2b
11 changed files with 389 additions and 94 deletions

View File

@@ -7253,6 +7253,90 @@ public:
}
};
//------------------
//trigger regen
class ATriggerRegen: public InstantAbility
{
public:
ATriggerRegen(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target) :
InstantAbility(observer, _id, _source)
{
target = _target;
}
int resolve()
{
MTGCardInstance * card = (MTGCardInstance *) target;
if (card)
{
if (!card->regenerateTokens)
return 0;
if (card->has(Constants::CANTREGEN))
return 0;
card->regenerateTokens--;
card->tap();
if(card->isCreature())
{
card->life = card->toughness;
card->initAttackersDefensers();
if (card->life < 1)
return 0; //regeneration didn't work (wither ?)
}
}
return 1;
}
const string getMenuText()
{
return "Regenerate";
}
virtual ostream& toString(ostream& out) const
{
out << "AATriggerRegen ::: (";
return InstantAbility::toString(out) << ")";
}
ATriggerRegen * clone() const
{
return NEW ATriggerRegen(*this);
}
};
//trigger totem
class ATriggerTotem: public InstantAbility
{
public:
ATriggerTotem(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target) :
InstantAbility(observer, _id, _source)
{
target = _target;
}
int resolve()
{
MTGCardInstance * card = (MTGCardInstance *) target;
if (card)
{
card->destroy();
if(source->isCreature())
{
source->life = source->toughness;
if (source->life < 1)
return 0; //regeneration didn't work (wither ?)
}
}
return 1;
}
const string getMenuText()
{
return "Totem Armor";
}
virtual ostream& toString(ostream& out) const
{
out << "AATriggerTotem ::: (";
return InstantAbility::toString(out) << ")";
}
ATriggerTotem * clone() const
{
return NEW ATriggerTotem(*this);
}
};
// utility functions
void PopulateColorIndexVector(list<int>& colors, const string& colorsString, char delimiter = ',');

View File

@@ -139,6 +139,7 @@ public:
ManaCost * getReducedManaCost();
ManaCost * getIncreasedManaCost();
bool matchesCastFilter(int castMethod);
bool hasTotemArmor();
// The recommended method to test for summoning Sickness !
int hasSummoningSickness();
@@ -203,8 +204,10 @@ public:
Player * controller();
virtual ~MTGCardInstance();
int bury();
int totem( bool noregen = false );
int toGrave( bool forced = false );
int destroy();
int destroyNoRegen();
int addToToughness(int value);
int setToughness(int value);

View File

@@ -274,7 +274,8 @@ class Constants
CANPLAYINSTANTSORCERYTOPLIBRARY = 152,//instantorsorcery
SHOWFROMTOPLIBRARY = 153,
SHOWOPPONENTTOPLIBRARY = 154,
NB_BASIC_ABILITIES = 155,
TOTEMARMOR = 155,
NB_BASIC_ABILITIES = 156,
RARITY_S = 'S', //Special Rarity
RARITY_M = 'M', //Mythics

View File

@@ -377,4 +377,24 @@ public:
virtual bool equals(TargetChooser * tc);
~ChildrenChooser();
};
class TotemChooser: public TypeTargetChooser
{
public:
bool withoutProtections;
TotemChooser(GameObserver *observer, int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false, bool targetMin = false) :
TypeTargetChooser(observer, "*",_zones, _nbzones, card, _maxtargets, other, targetMin)
{
}
;
TotemChooser(GameObserver *observer, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false,bool targetMin = false) :
TypeTargetChooser(observer, "*", card, _maxtargets, other,targetMin)
{
}
;
virtual bool canTarget(Targetable * target, bool withoutProtections = false);
virtual TotemChooser * clone() const;
virtual bool equals(TargetChooser * tc);
~TotemChooser();
};
#endif