Fixed Treasure token, added boast trigger event, added new keyword "hascnt" to retrieve the amount of specific counter type on a card (e.g. hascntloyalty).

This commit is contained in:
Vittorio Alfieri
2021-01-24 20:37:14 +01:00
parent f6199719fd
commit 4bdc1fdfe1
7 changed files with 127 additions and 6 deletions
+36
View File
@@ -1061,6 +1061,42 @@ AAExploresEvent::~AAExploresEvent()
{
}
//AA Boast Event
AABoastEvent::AABoastEvent(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, ManaCost * _cost,
int who) :
ActivatedAbilityTP(observer, _id, _source, _target, _cost, who), card(_source)
{
}
int AABoastEvent::resolve()
{
Damageable * _target = (Damageable *) getTarget();
if (_target)
{
Player * pTarget = (Player*)_target;
if(pTarget)
{
WEvent * e = NEW WEventCardBoasted(card);
game->receiveEvent(e);
}
}
return 0;
}
const string AABoastEvent::getMenuText()
{
return "Boast event called";
}
AABoastEvent * AABoastEvent::clone() const
{
return NEW AABoastEvent(*this);
}
AABoastEvent::~AABoastEvent()
{
}
//AA Surveil Event
AASurveilEvent::AASurveilEvent(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, ManaCost * _cost,
int who) :
+14
View File
@@ -1224,6 +1224,10 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell
if (TargetChooser * tc = parseSimpleTC(s, "mutated", card))
return NEW TrCardMutated(observer, id, card, tc, once, limitOnceATurn);
//boast has been performed from a card
if (TargetChooser * tc = parseSimpleTC(s, "boasted", card))
return NEW TrCardBoasted(observer, id, card, tc, once, limitOnceATurn);
//Surveil has been performed from a card
if (TargetChooser * tc = parseSimpleTC(s, "surveiled", card))
return NEW TrCardSurveiled(observer, id, card, tc, once, limitOnceATurn);
@@ -3555,6 +3559,16 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
card->mutation += atoi(splitMutatedUnder[1].c_str());
}
//perform boast
found = s.find("doboast");
if (found != string::npos)
{
Targetable * t = spell ? spell->getNextTarget() : NULL;
MTGAbility * a = NEW AABoastEvent(observer, id, card, t, NULL, who);
a->oneShot = 1;
return a;
}
//perform surveil
found = s.find("surveil");
if (found != string::npos)
+11
View File
@@ -292,6 +292,11 @@ WEventplayerMonarch::WEventplayerMonarch(Player * player) :
{
}
WEventCardBoasted::WEventCardBoasted(MTGCardInstance * card) :
WEventCardUpdate(card)
{
}
WEventCardSurveiled::WEventCardSurveiled(MTGCardInstance * card) :
WEventCardUpdate(card)
{
@@ -535,6 +540,12 @@ Targetable * WEventCardMutated::getTarget(int target)
return NULL;
}
Targetable * WEventCardBoasted::getTarget(int target)
{
if (target) return card;
return NULL;
}
Targetable * WEventCardSurveiled::getTarget(int target)
{
if (target) return card;
+14
View File
@@ -578,6 +578,20 @@ void WParsedInt::init(string s, Spell * spell, MTGCardInstance * card)
if(Constants::MTGBasicAbilities[i] == s.substr(10))
intValue = card->basicAbilities[i];
}
else if (s.find("hascnt") != string::npos) //Return the amount of specific counters on card
{
intValue = 0;
if (card->counters){
Counters * counters = card->counters;
for(size_t i = 0; i < counters->counters.size(); ++i){
Counter * counter = counters->counters[i];
if(counter->name == s.substr(6)){
intValue = counter->nb;
break;
}
}
}
}
else if (s == "manacost") //Return the converted manacost
{
intValue = (target->currentZone == target->controller()->game->stack)?(target->myconvertedcost + target->castX):target->myconvertedcost;//X is 0 except if it's on the stack