removed a compile error, variables that were unreferenced.
small add with big impact:
added the useage of castrestriction on triggers and activated abilities.
this can be used to create such cards as library of alexandria.
{t}:draw:1 restriction{type(*|myhand)~equalto~7}
and replace instances were we were putting false triggers on the stack from abilities which contained nested aslongas...
meaning cards like epic struggle, won't need to be triggered every turn even if you have no creatures...
for epic struggle here is an example of how to replace it
@each myupkeep restriction{type(creature|mybattlefield)~morethan~19}:wingame controller
any of the current cast and other restrictions can be used. this includes turn:1 <===and various others such as phase based checking.
syntax is
restriction{ whatever casting/other restriction you want }
a nice quality of life fix for false triggers (which don't mean theyre incorrect, just annoying when they trigger when they will do nothing)
another example would be the triggers on cards like
skullcage.
auto=@each opponent upkeep:aslongas(*|opponenthand) damage:2 opponent >4
auto=@each opponent upkeep:aslongas(*|opponenthand) damage:2 opponent <3
becomes
auto=@each opponent upkeep restriction{type(*|opponenthand)~morethan~4}:damage:2 opponent
auto=@each opponent upkeep restriction{type(*|opponenthand)~lessthan~3}:damage:2 opponent
now instead of triggering every opponent upkeep even without a resolve...it will only triggers when the restriction requirement is met.
enjoy :)
note:all test pass.
This commit is contained in:
@@ -929,8 +929,9 @@ class GenericActivatedAbility: public ActivatedAbility, public NestedAbility
|
|||||||
public:
|
public:
|
||||||
MTGGameZone * activeZone;
|
MTGGameZone * activeZone;
|
||||||
string newName;
|
string newName;
|
||||||
|
string castRestriction;
|
||||||
|
|
||||||
GenericActivatedAbility(string newName,int _id, MTGCardInstance * card, MTGAbility * a, ManaCost * _cost, string limit = "",MTGAbility * sideEffects = NULL,string usesBeforeSideEffects = "",
|
GenericActivatedAbility(string newName,string castRestriction,int _id, MTGCardInstance * card, MTGAbility * a, ManaCost * _cost, string limit = "",MTGAbility * sideEffects = NULL,string usesBeforeSideEffects = "",
|
||||||
int restrictions = 0, MTGGameZone * dest = NULL);
|
int restrictions = 0, MTGGameZone * dest = NULL);
|
||||||
int resolve();
|
int resolve();
|
||||||
const char * getMenuText();
|
const char * getMenuText();
|
||||||
@@ -1040,8 +1041,9 @@ public:
|
|||||||
int counters;
|
int counters;
|
||||||
MTGGameZone * activeZone;
|
MTGGameZone * activeZone;
|
||||||
string newName;
|
string newName;
|
||||||
|
string castRestriction;
|
||||||
|
|
||||||
GenericTargetAbility(string newName,int _id, MTGCardInstance * _source, TargetChooser * _tc, MTGAbility * a, ManaCost * _cost = NULL, string limit = "",MTGAbility * sideEffects = NULL,string usesBeforeSideEffects = "", int restrictions = 0, MTGGameZone * dest = NULL);
|
GenericTargetAbility(string newName, string castRestriction, int _id, MTGCardInstance * _source, TargetChooser * _tc, MTGAbility * a, ManaCost * _cost = NULL, string limit = "",MTGAbility * sideEffects = NULL,string usesBeforeSideEffects = "", int restrictions = 0, MTGGameZone * dest = NULL);
|
||||||
const char * getMenuText();
|
const char * getMenuText();
|
||||||
~GenericTargetAbility();
|
~GenericTargetAbility();
|
||||||
GenericTargetAbility * clone() const;
|
GenericTargetAbility * clone() const;
|
||||||
|
|||||||
@@ -244,6 +244,7 @@ public:
|
|||||||
virtual int resolve() = 0;
|
virtual int resolve() = 0;
|
||||||
virtual TriggeredAbility* clone() const = 0;
|
virtual TriggeredAbility* clone() const = 0;
|
||||||
virtual ostream& toString(ostream& out) const;
|
virtual ostream& toString(ostream& out) const;
|
||||||
|
string castRestriction;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -333,8 +334,9 @@ public:
|
|||||||
MTGAbility* sa;
|
MTGAbility* sa;
|
||||||
string usesBeforeSideEffects;
|
string usesBeforeSideEffects;
|
||||||
int uses;
|
int uses;
|
||||||
|
string castRestriction;
|
||||||
|
|
||||||
ActivatedAbility(int id, MTGCardInstance* card, ManaCost* _cost = NULL, int _restrictions = NO_RESTRICTION, string limit = "", MTGAbility* sideEffect = NULL, string usesBeforeSideEffects = "");
|
ActivatedAbility(int id, MTGCardInstance* card, ManaCost* _cost = NULL, int _restrictions = NO_RESTRICTION, string limit = "", MTGAbility* sideEffect = NULL, string usesBeforeSideEffects = "",string castRestriction = "");
|
||||||
virtual ~ActivatedAbility();
|
virtual ~ActivatedAbility();
|
||||||
|
|
||||||
virtual void Update(float dt)
|
virtual void Update(float dt)
|
||||||
@@ -358,8 +360,8 @@ public:
|
|||||||
class TargetAbility : public ActivatedAbility, public NestedAbility
|
class TargetAbility : public ActivatedAbility, public NestedAbility
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TargetAbility(int id, MTGCardInstance * card, TargetChooser * _tc,ManaCost * _cost = NULL, int _playerturnonly = 0);
|
TargetAbility(int id, MTGCardInstance * card, TargetChooser * _tc,ManaCost * _cost = NULL, int _playerturnonly = 0, string castRestriction = "");
|
||||||
TargetAbility(int id, MTGCardInstance * card,ManaCost * _cost = NULL, int _playerturnonly = 0);
|
TargetAbility(int id, MTGCardInstance * card,ManaCost * _cost = NULL, int _playerturnonly = 0, string castRestriction = "");
|
||||||
~TargetAbility();
|
~TargetAbility();
|
||||||
|
|
||||||
virtual int reactToClick(MTGCardInstance * card);
|
virtual int reactToClick(MTGCardInstance * card);
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
//Activated Abilities
|
//Activated Abilities
|
||||||
|
|
||||||
//Generic Activated Abilities
|
//Generic Activated Abilities
|
||||||
GenericActivatedAbility::GenericActivatedAbility(string newName,int _id, MTGCardInstance * card, MTGAbility * a, ManaCost * _cost,
|
GenericActivatedAbility::GenericActivatedAbility(string newName, string castRestriction, int _id, MTGCardInstance * card, MTGAbility * a, ManaCost * _cost,
|
||||||
string limit,MTGAbility * sideEffects,string usesBeforeSideEffects, int restrictions, MTGGameZone * dest) :
|
string limit,MTGAbility * sideEffects,string usesBeforeSideEffects, int restrictions, MTGGameZone * dest) :
|
||||||
ActivatedAbility(_id, card, _cost, restrictions,limit,sideEffects,usesBeforeSideEffects), NestedAbility(a), activeZone(dest),newName(newName)
|
ActivatedAbility(_id, card, _cost, restrictions,limit,sideEffects,usesBeforeSideEffects,castRestriction), NestedAbility(a), activeZone(dest),newName(newName),castRestriction(castRestriction)
|
||||||
{
|
{
|
||||||
counters = 0;
|
counters = 0;
|
||||||
target = ability->target;
|
target = ability->target;
|
||||||
@@ -2468,9 +2468,9 @@ MultiAbility::~MultiAbility()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Generic Target Ability
|
//Generic Target Ability
|
||||||
GenericTargetAbility::GenericTargetAbility(string newName,int _id, MTGCardInstance * _source, TargetChooser * _tc, MTGAbility * a,
|
GenericTargetAbility::GenericTargetAbility(string newName, string castRestriction,int _id, MTGCardInstance * _source, TargetChooser * _tc, MTGAbility * a,
|
||||||
ManaCost * _cost, string limit,MTGAbility * sideEffects,string usesBeforeSideEffects, int restrictions, MTGGameZone * dest) :
|
ManaCost * _cost, string limit,MTGAbility * sideEffects,string usesBeforeSideEffects, int restrictions, MTGGameZone * dest) :
|
||||||
TargetAbility(_id, _source, _tc, _cost, restrictions), limit(limit), activeZone(dest),newName(newName)
|
TargetAbility(_id, _source, _tc, _cost, restrictions,castRestriction), limit(limit), activeZone(dest),newName(newName),castRestriction(castRestriction)
|
||||||
{
|
{
|
||||||
ability = a;
|
ability = a;
|
||||||
MTGAbility * core = AbilityFactory::getCoreAbility(a);
|
MTGAbility * core = AbilityFactory::getCoreAbility(a);
|
||||||
|
|||||||
@@ -176,7 +176,6 @@ void GameStateAwards::Update(float dt)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
JButton key = JGE_BTN_NONE;
|
JButton key = JGE_BTN_NONE;
|
||||||
int x, y;
|
|
||||||
while ((key = JGE::GetInstance()->ReadButton()))
|
while ((key = JGE::GetInstance()->ReadButton()))
|
||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
|
|||||||
@@ -761,6 +761,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
if (splitTrigger.size())
|
if (splitTrigger.size())
|
||||||
{
|
{
|
||||||
TriggeredAbility * trigger = parseTrigger(splitTrigger[1], s, id, spell, card, target);
|
TriggeredAbility * trigger = parseTrigger(splitTrigger[1], s, id, spell, card, target);
|
||||||
|
if (splitTrigger[1].find("restriction{") != string::npos)//using other/cast restrictions for abilities.
|
||||||
|
{
|
||||||
|
vector<string> splitRest = parseBetween(s,"restriction{","}");
|
||||||
|
if (splitRest.size())
|
||||||
|
trigger->castRestriction = splitRest[1];
|
||||||
|
}
|
||||||
//Dirty way to remove the trigger text (could get in the way)
|
//Dirty way to remove the trigger text (could get in the way)
|
||||||
if (trigger)
|
if (trigger)
|
||||||
{
|
{
|
||||||
@@ -793,7 +799,13 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
}
|
}
|
||||||
|
|
||||||
int restrictions = parseRestriction(s);
|
int restrictions = parseRestriction(s);
|
||||||
|
string castRestriction = "";
|
||||||
|
if (s.find("restriction{") != string::npos)//using other/cast restrictions for abilities.
|
||||||
|
{
|
||||||
|
vector<string> splitRest = parseBetween(s,"restriction{","}");
|
||||||
|
if (splitRest.size())
|
||||||
|
castRestriction = splitRest[1];
|
||||||
|
}
|
||||||
string newName = "";
|
string newName = "";
|
||||||
vector<string> splitName = parseBetween(s, "name(", ")");
|
vector<string> splitName = parseBetween(s, "name(", ")");
|
||||||
if (splitName.size())
|
if (splitName.size())
|
||||||
@@ -887,6 +899,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
amp->sideEffect = sideEffect;
|
amp->sideEffect = sideEffect;
|
||||||
amp->usesBeforeSideEffects = usesBeforeSideEffect;
|
amp->usesBeforeSideEffects = usesBeforeSideEffect;
|
||||||
amp->restrictions = restrictions;
|
amp->restrictions = restrictions;
|
||||||
|
amp->castRestriction = castRestriction;
|
||||||
return amp;
|
return amp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -905,9 +918,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
if (tc)
|
if (tc)
|
||||||
{
|
{
|
||||||
tc->belongsToAbility = sWithoutTc;
|
tc->belongsToAbility = sWithoutTc;
|
||||||
return NEW GenericTargetAbility(newName,id, card, tc, a, cost, limit,sideEffect,usesBeforeSideEffect, restrictions, dest);
|
return NEW GenericTargetAbility(newName,castRestriction,id, card, tc, a, cost, limit,sideEffect,usesBeforeSideEffect, restrictions, dest);
|
||||||
}
|
}
|
||||||
return NEW GenericActivatedAbility(newName,id, card, a, cost, limit,sideEffect,usesBeforeSideEffect,restrictions, dest);
|
return NEW GenericActivatedAbility(newName,castRestriction,id, card, a, cost, limit,sideEffect,usesBeforeSideEffect,restrictions, dest);
|
||||||
}
|
}
|
||||||
SAFE_DELETE(cost);
|
SAFE_DELETE(cost);
|
||||||
}
|
}
|
||||||
@@ -963,9 +976,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (tc)
|
if (tc)
|
||||||
a1 = NEW GenericTargetAbility(newName,id, card, tc, a1);
|
a1 = NEW GenericTargetAbility(newName,castRestriction,id, card, tc, a1);
|
||||||
else
|
else
|
||||||
a1 = NEW GenericActivatedAbility(newName,id, card, a1, NULL);
|
a1 = NEW GenericActivatedAbility(newName,castRestriction,id, card, a1, NULL);
|
||||||
return NEW MayAbility(id, a1, card,mayMust[i]);
|
return NEW MayAbility(id, a1, card,mayMust[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1333,7 +1346,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
DebugTrace("ABILITYFACTORY Error parsing: " << s);
|
DebugTrace("ABILITYFACTORY Error parsing: " << s);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
a = NEW GenericTargetAbility(newName,id, card, tc, a);
|
a = NEW GenericTargetAbility(newName,castRestriction,id, card, tc, a);
|
||||||
return NEW MayAbility(id, a, card, true);
|
return NEW MayAbility(id, a, card, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3527,8 +3540,8 @@ NestedAbility::NestedAbility(MTGAbility * _ability)
|
|||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
ActivatedAbility::ActivatedAbility(int id, MTGCardInstance * card, ManaCost * _cost, int restrictions,string limit,MTGAbility * sideEffect,string usesBeforeSideEffects) :
|
ActivatedAbility::ActivatedAbility(int id, MTGCardInstance * card, ManaCost * _cost, int restrictions,string limit,MTGAbility * sideEffect,string usesBeforeSideEffects,string castRestriction) :
|
||||||
MTGAbility(id, card), restrictions(restrictions), needsTapping(0),limit(limit),sideEffect(sideEffect),usesBeforeSideEffects(usesBeforeSideEffects)
|
MTGAbility(id, card), restrictions(restrictions), needsTapping(0),limit(limit),sideEffect(sideEffect),usesBeforeSideEffects(usesBeforeSideEffects),castRestriction(castRestriction)
|
||||||
{
|
{
|
||||||
counters = 0;
|
counters = 0;
|
||||||
setCost(_cost);
|
setCost(_cost);
|
||||||
@@ -3595,6 +3608,13 @@ int ActivatedAbility::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
|||||||
if (limitPerTurn && counters >= limitPerTurn)
|
if (limitPerTurn && counters >= limitPerTurn)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if(castRestriction.size())
|
||||||
|
{
|
||||||
|
AbilityFactory af;
|
||||||
|
int checkCond = af.parseCastRestrictions(card,card->controller(),castRestriction);
|
||||||
|
if(!checkCond)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (card == source && source->controller() == player && (!needsTapping || (!source->isTapped()
|
if (card == source && source->controller() == player && (!needsTapping || (!source->isTapped()
|
||||||
&& !source->hasSummoningSickness())))
|
&& !source->hasSummoningSickness())))
|
||||||
{
|
{
|
||||||
@@ -3752,14 +3772,14 @@ ostream& ActivatedAbility::toString(ostream& out) const
|
|||||||
return MTGAbility::toString(out) << ")";
|
return MTGAbility::toString(out) << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
TargetAbility::TargetAbility(int id, MTGCardInstance * card, TargetChooser * _tc, ManaCost * _cost, int _playerturnonly) :
|
TargetAbility::TargetAbility(int id, MTGCardInstance * card, TargetChooser * _tc, ManaCost * _cost, int _playerturnonly, string castRestriction) :
|
||||||
ActivatedAbility(id, card, _cost, _playerturnonly), NestedAbility(NULL)
|
ActivatedAbility(id, card, _cost, _playerturnonly, castRestriction), NestedAbility(NULL)
|
||||||
{
|
{
|
||||||
tc = _tc;
|
tc = _tc;
|
||||||
}
|
}
|
||||||
|
|
||||||
TargetAbility::TargetAbility(int id, MTGCardInstance * card, ManaCost * _cost, int _playerturnonly) :
|
TargetAbility::TargetAbility(int id, MTGCardInstance * card, ManaCost * _cost, int _playerturnonly, string castRestriction) :
|
||||||
ActivatedAbility(id, card, _cost, _playerturnonly), NestedAbility(NULL)
|
ActivatedAbility(id, card, _cost, _playerturnonly, castRestriction), NestedAbility(NULL)
|
||||||
{
|
{
|
||||||
tc = NULL;
|
tc = NULL;
|
||||||
}
|
}
|
||||||
@@ -3959,6 +3979,15 @@ int Trigger::triggerOnEvent(WEvent * event) {
|
|||||||
if(mOnce && mActiveTrigger)
|
if(mOnce && mActiveTrigger)
|
||||||
mActiveTrigger = false;
|
mActiveTrigger = false;
|
||||||
|
|
||||||
|
if(castRestriction.size())
|
||||||
|
{
|
||||||
|
if(!source)
|
||||||
|
return 1;//can't check these restrictions without a source aka:in a rule.txt
|
||||||
|
AbilityFactory af;
|
||||||
|
int checkCond = af.parseCastRestrictions(source,source->controller(),castRestriction);
|
||||||
|
if(!checkCond)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user