added functionality to may and choice ability so that it can check a "restriction{}" like a activated ability with cost, that can keep a menu option from appearing if the restriction is not met
auto=choice damage:1 target(creature) restriction{type(creature[blue])~morethan~1}
this choice menu will only appear is there is more than one blue creature inplay
This commit is contained in:
@@ -1074,11 +1074,12 @@ class MayAbility: public MTGAbility, public NestedAbility
|
|||||||
public:
|
public:
|
||||||
int triggered;
|
int triggered;
|
||||||
bool must;
|
bool must;
|
||||||
|
string Cond;
|
||||||
Player * previousInterrupter;
|
Player * previousInterrupter;
|
||||||
MTGAbility * mClone;
|
MTGAbility * mClone;
|
||||||
ManaCost * optionalCost;
|
ManaCost * optionalCost;
|
||||||
|
|
||||||
MayAbility(GameObserver* observer, int _id, MTGAbility * _ability, MTGCardInstance * _source, bool must = false);
|
MayAbility(GameObserver* observer, int _id, MTGAbility * _ability, MTGCardInstance * _source, bool must = false, string restriction = "");
|
||||||
|
|
||||||
void Update(float dt);
|
void Update(float dt);
|
||||||
|
|
||||||
|
|||||||
@@ -3077,8 +3077,8 @@ IfThenAbility::~IfThenAbility()
|
|||||||
//
|
//
|
||||||
|
|
||||||
//May Abilities
|
//May Abilities
|
||||||
MayAbility::MayAbility(GameObserver* observer, int _id, MTGAbility * _ability, MTGCardInstance * _source, bool must) :
|
MayAbility::MayAbility(GameObserver* observer, int _id, MTGAbility * _ability, MTGCardInstance * _source, bool must,string _cond) :
|
||||||
MTGAbility(observer, _id, _source), NestedAbility(_ability), must(must)
|
MTGAbility(observer, _id, _source), NestedAbility(_ability), must(must), Cond(_cond)
|
||||||
{
|
{
|
||||||
triggered = 0;
|
triggered = 0;
|
||||||
mClone = NULL;
|
mClone = NULL;
|
||||||
@@ -3093,6 +3093,15 @@ void MayAbility::Update(float dt)
|
|||||||
triggered = 1;
|
triggered = 1;
|
||||||
if(optionalCost && !source->controller()->getManaPool()->canAfford(optionalCost))
|
if(optionalCost && !source->controller()->getManaPool()->canAfford(optionalCost))
|
||||||
return;
|
return;
|
||||||
|
if(Cond.size())
|
||||||
|
{
|
||||||
|
AbilityFactory af(game);
|
||||||
|
int checkCond = af.parseCastRestrictions(source,source->controller(),Cond);
|
||||||
|
if(!checkCond)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (TargetAbility * ta = dynamic_cast<TargetAbility *>(ability))
|
if (TargetAbility * ta = dynamic_cast<TargetAbility *>(ability))
|
||||||
{
|
{
|
||||||
if (!ta->getActionTc()->validTargetsExist())
|
if (!ta->getActionTc()->validTargetsExist())
|
||||||
|
|||||||
@@ -1164,6 +1164,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
if (splitRest.size())
|
if (splitRest.size())
|
||||||
castRestriction = splitRest[1];
|
castRestriction = splitRest[1];
|
||||||
}
|
}
|
||||||
|
if (s.find("restriction{{") != string::npos)
|
||||||
|
{
|
||||||
|
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())
|
||||||
@@ -1364,7 +1370,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
a1 = NEW GenericTargetAbility(observer, newName,castRestriction,id, card, tc, a1);
|
a1 = NEW GenericTargetAbility(observer, newName,castRestriction,id, card, tc, a1);
|
||||||
else
|
else
|
||||||
a1 = NEW GenericActivatedAbility(observer, newName,castRestriction,id, card, a1, NULL);
|
a1 = NEW GenericActivatedAbility(observer, newName,castRestriction,id, card, a1, NULL);
|
||||||
MayAbility * mainAbility = NEW MayAbility(observer, id, a1, card,mayMust[i]);
|
MayAbility * mainAbility = NEW MayAbility(observer, id, a1, card,mayMust[i],castRestriction);
|
||||||
if(mayCost)
|
if(mayCost)
|
||||||
mainAbility->optionalCost = mayCost;
|
mainAbility->optionalCost = mayCost;
|
||||||
return mainAbility;
|
return mainAbility;
|
||||||
|
|||||||
Reference in New Issue
Block a user