added an "ifnot|if then" ability, with the option to turn on kicker payment menu choice, it created issue with the cards which were using the "kicker" workaround to show that a card was cast...
the ability checks against any of the current cast restriction checks and is written in the following syntax
example phaige the untouchable is
auto=ifnot casted(this) then wingame opponent
if|ifnot condiation then ability
this can also be used in && abilities such as this card
pulse of the grid
auto=draw:2 && target(*|myhand) reject && if type(*|opponenthand)~morethan~type(*|myhand) then moveto(myhand) all(this)
this adds a few cards in its current state, though the aim for this ability was removing the use of "kicker" workaround for cards like the divinity creatures.
i plan to extend this to support such effects as "if spentmana({b}{u}) then effect....and other conditional checks currently not possible even with workarounds.
I'm committing these now since im working on abilities for kiaos mod and don't want to have a 20 page changelog.
also added missing text to binding grasp, it was thought that it was bugged becuase it simply "ended" its effect....however this is a confusion since the effect was ending due to upcost not being paid, however the card text did not reflect that it had a upcost....
This commit is contained in:
@@ -970,6 +970,19 @@ public:
|
||||
Generic classes
|
||||
*/
|
||||
|
||||
//if/ifnot Cond then EFFECT
|
||||
class IfThenAbility: public MTGAbility
|
||||
{
|
||||
public:
|
||||
string delayAbility;
|
||||
int type;
|
||||
string Cond;
|
||||
IfThenAbility(int _id,string delayAbility = "", MTGCardInstance * _source=NULL, int type = 1,string Cond = "");
|
||||
int resolve();
|
||||
const char * getMenuText();
|
||||
IfThenAbility * clone() const;
|
||||
};
|
||||
|
||||
//MayAbility: May do ...
|
||||
class MayAbility: public MTGAbility, public NestedAbility
|
||||
{
|
||||
|
||||
@@ -2065,6 +2065,48 @@ AAWinGame * AAWinGame::clone() const
|
||||
|
||||
//Generic Abilities
|
||||
|
||||
|
||||
//IfThenEffect
|
||||
IfThenAbility::IfThenAbility(int _id, string delayAbility, MTGCardInstance * _source, int type,string Cond) :
|
||||
MTGAbility(_id, _source),delayAbility(delayAbility), type(type),Cond(Cond)
|
||||
{
|
||||
}
|
||||
|
||||
int IfThenAbility::resolve()
|
||||
{
|
||||
MTGCardInstance * card = (MTGCardInstance*)source;
|
||||
AbilityFactory af;
|
||||
int checkCond = af.parseCastRestrictions(card,card->controller(),Cond);
|
||||
if((checkCond && type == 1)||(!checkCond && type == 2))
|
||||
{
|
||||
MTGAbility * a1 = af.parseMagicLine(delayAbility, this->GetId(), NULL, card);
|
||||
if (!a1)
|
||||
return 0;
|
||||
if(a1->oneShot)
|
||||
{
|
||||
a1->resolve();
|
||||
SAFE_DELETE(a1);
|
||||
}
|
||||
else
|
||||
a1->addToGame();
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * IfThenAbility::getMenuText()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
IfThenAbility * IfThenAbility::clone() const
|
||||
{
|
||||
IfThenAbility * a = NEW IfThenAbility(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
//
|
||||
|
||||
//May Abilities
|
||||
MayAbility::MayAbility(int _id, MTGAbility * _ability, MTGCardInstance * _source, bool must) :
|
||||
MTGAbility(_id, _source), NestedAbility(_ability), must(must)
|
||||
|
||||
@@ -906,6 +906,24 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
return parseMagicLine(s.substr(kAlternateCostKeywords[i].length()), id, spell, card);
|
||||
}
|
||||
}
|
||||
|
||||
//if/ifnot COND then DO EFFECT.
|
||||
const string ifKeywords[] = {"if ", "ifnot "};
|
||||
int checkIf[] = { 1, 2 };
|
||||
for (size_t i =0; i < sizeof(checkIf)/sizeof(checkIf[0]); ++i)
|
||||
{
|
||||
if (sWithoutTc.find(ifKeywords[i]) == 0)
|
||||
{
|
||||
string cond = sWithoutTc.substr(ifKeywords[i].length(),ifKeywords[i].length() + sWithoutTc.find(" then ")-6);
|
||||
string s1 = s.substr(s.find(" then ")+6);
|
||||
MTGAbility * a = NEW IfThenAbility(id, s1, card,checkIf[i],cond);
|
||||
a->canBeInterrupted = false;
|
||||
a->oneShot = true;
|
||||
if(tc)
|
||||
SAFE_DELETE(tc);
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
//When...comes into play, you may...
|
||||
//When...comes into play, choose one...
|
||||
|
||||
Reference in New Issue
Block a user