Improved foretell mechanics, added a trigger for foretold cards, added a new keyword "snowdiffmana" to compare snow mana pool and mana cost of a target card, improved phaseaction "checkexile" condition.

This commit is contained in:
Vittorio Alfieri
2021-01-22 19:37:09 +01:00
parent 5184132e8b
commit 2b7baf7fc8
6 changed files with 66 additions and 8 deletions

View File

@@ -646,6 +646,33 @@ public:
}
};
class TrCardForetold: public Trigger
{
public:
bool limitOnceATurn;
int triggeredTurn;
TrCardForetold(GameObserver* observer, int id, MTGCardInstance * source, TargetChooser * tc,bool once = false,bool limitOnceATurn = false) :
Trigger(observer, id, source,once, tc),limitOnceATurn(limitOnceATurn)
{
}
int triggerOnEventImpl(WEvent * event)
{
WEventCardForetold * e = dynamic_cast<WEventCardForetold *> (event);
if (!e) return 0;
if (limitOnceATurn && triggeredTurn == game->turn)
return 0;
if (!tc->canTarget(e->card)) return 0;
triggeredTurn = game->turn;
return 1;
}
TrCardForetold * clone() const
{
return NEW TrCardForetold(*this);
}
};
class TrCardScryed: public Trigger
{
public:

View File

@@ -366,6 +366,12 @@ struct WEventCardSurveiled : public WEventCardUpdate {
virtual Targetable * getTarget(int target);
};
//foretell event
struct WEventCardForetold : public WEventCardUpdate {
WEventCardForetold(MTGCardInstance * card);
virtual Targetable * getTarget(int target);
};
//scry event
struct WEventCardScryed : public WEventCardUpdate {
WEventCardScryed(MTGCardInstance * card);

View File

@@ -2110,12 +2110,15 @@ int AAForetell::resolve()
MTGCardInstance * _target = (MTGCardInstance *) target;
if (_target)
{
if(_target->mutation && _target->parentCards.size() > 0) return 0; // Mutated down cards cannot be foretell, they will follow the fate of top-card
if(_target->mutation && _target->parentCards.size() > 0) return 0; // Mutated down cards cannot be foretold, they will follow the fate of top-card
Player * p = _target->controller();
if(p){
MTGCardInstance * tmp = p->game->putInExile(_target);
if(tmp)
if(tmp){
tmp->foretellTurn = source->getObserver()->turn;
WEvent * e = NEW WEventCardForetold(tmp);
game->receiveEvent(e);
}
}
while(_target->next)
@@ -7847,7 +7850,8 @@ void APhaseAction::Update(float dt)
{
if(checkexile)
{
if(((MTGCardInstance *)target)->next->getCurrentZone() != ((MTGCardInstance *)target)->owner->game->exile)
MTGCardInstance* tocheck = (((MTGCardInstance *)target)->next)?((MTGCardInstance *)target)->next:((MTGCardInstance *)target);
if((tocheck->getCurrentZone() != ((MTGCardInstance *)target)->owner->game->exile) && (tocheck->getCurrentZone() != ((MTGCardInstance *)target)->owner->opponent()->game->exile))
{
this->forceDestroy = 1;
return;

View File

@@ -1228,6 +1228,10 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell
if (TargetChooser * tc = parseSimpleTC(s, "surveiled", card))
return NEW TrCardSurveiled(observer, id, card, tc, once, limitOnceATurn);
//Foretell has been performed from a card
if (TargetChooser * tc = parseSimpleTC(s, "foretold", card))
return NEW TrCardForetold(observer, id, card, tc, once, limitOnceATurn);
//Scry has been performed from a card
if (TargetChooser * tc = parseSimpleTC(s, "scryed", card))
return NEW TrCardScryed(observer, id, card, tc, once, limitOnceATurn);
@@ -3166,7 +3170,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
}
//foretell
found = s.find("foretell");
found = s.find("doforetell");
if (found != string::npos)
{
MTGAbility * a = NEW AAForetell(observer, id, card, target);

View File

@@ -297,6 +297,11 @@ WEventCardSurveiled::WEventCardSurveiled(MTGCardInstance * card) :
{
}
WEventCardForetold::WEventCardForetold(MTGCardInstance * card) :
WEventCardUpdate(card)
{
}
WEventCardScryed::WEventCardScryed(MTGCardInstance * card) :
WEventCardUpdate(card)
{
@@ -536,6 +541,12 @@ Targetable * WEventCardSurveiled::getTarget(int target)
return NULL;
}
Targetable * WEventCardForetold::getTarget(int target)
{
if (target) return card;
return NULL;
}
Targetable * WEventCardScryed::getTarget(int target)
{
if (target) return card;

View File

@@ -211,10 +211,6 @@ void WParsedInt::init(string s, Spell * spell, MTGCardInstance * card)
{
intValue = (s == "mutations")?target->mutation:target->countColors();
}
else if (s == "manacost")
{
intValue = (target->currentZone == target->controller()->game->stack)?(target->myconvertedcost + target->castX):target->myconvertedcost;//X is 0 except if it's on the stack
}
else if (s.find("type:") != string::npos)
{
size_t begins = s.find("type:");
@@ -571,6 +567,16 @@ void WParsedInt::init(string s, Spell * spell, MTGCardInstance * card)
{
intValue = card->isFlipped;
}
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
}
else if(s == "snowdiffmana") //Return 1 if the difference between snowpool and converted manacost is more than 0
{
int snowpool = target->controller()->snowManaG + target->controller()->snowManaU + target->controller()->snowManaR + target->controller()->snowManaB + target->controller()->snowManaW + target->controller()->snowManaC;
int manacost = (target->currentZone == target->controller()->game->stack)?(target->myconvertedcost + target->castX):target->myconvertedcost;//X is 0 except if it's on the stack
intValue = (snowpool >= manacost)?1:0;
}
else if (s == "mysnowpoolcount" || s == "opponentsnowpoolcount") // snowpoolcount is just to count the number of snow mana produced ...
{
intValue = (s == "mysnowpoolcount")?(target->controller()->snowManaG + target->controller()->snowManaU + target->controller()->snowManaR + target->controller()->snowManaB + target->controller()->snowManaW + target->controller()->snowManaC):(target->controller()->opponent()->snowManaG + target->controller()->opponent()->snowManaU + target->controller()->opponent()->snowManaR + target->controller()->opponent()->snowManaB + target->controller()->opponent()->snowManaW + target->controller()->opponent()->snowManaC);