added support for {X}{X} in cost, added support for token(creature, X/X or XX/XX)*XX or X or #. added discard card at random as cost type {d}

This commit is contained in:
omegablast2002@yahoo.com
2010-09-12 16:15:24 +00:00
parent 6063ddcf55
commit c408e5d588
11 changed files with 122 additions and 8 deletions
+1
View File
@@ -82,6 +82,7 @@ class Spell: public Interruptible {
ManaCost * cost;
int payResult;
int computeX(MTGCardInstance * card);
int computeXX(MTGCardInstance * card);
Spell(MTGCardInstance* _source);
Spell(int id, MTGCardInstance* _source, TargetChooser *_tc, ManaCost * _cost, int payResult);
~Spell();
+6 -1
View File
@@ -35,6 +35,10 @@ public:
if (spell) return spell->computeX(card);
return 1; //this should only hapen when the ai calls the ability. This is to give it an idea of the "direction" of X (positive/negative)
}
int computeXX(Spell * spell, MTGCardInstance * card){
if (spell) return spell->computeXX(card);
return 1; //this should only hapen when the ai calls the ability. This is to give it an idea of the "direction" of X (positive/negative)
}
WParsedInt(int value = 0){
intValue = value;
}
@@ -49,6 +53,8 @@ public:
}
if (s == "x" || s == "X"){
intValue = computeX(spell,card);
}else if (s == "xx" || s == "XX"){
intValue = computeXX(spell,card);
}else if (s == "manacost"){
intValue = target->getManaCost()->getConvertedCost();
}else if (s == "lifetotal"){
@@ -834,7 +840,6 @@ public:
name = sname;
tokenId = 0;
if(!multiplier) this->multiplier = NEW WParsedInt(1);
//TODO this is a copy/past of other code that's all around the place, everything should be in a dedicated parser class;
for (int j = 0; j < Constants::NB_BASIC_ABILITIES; j++){
+13 -1
View File
@@ -68,7 +68,19 @@ public:
virtual int setSource(MTGCardInstance * _source);
virtual LifeCost * clone() const;
};
//Discard a random card cost
class DiscardRandomCost: public ExtraCost{
public:
MTGCardInstance * target;
DiscardRandomCost(TargetChooser *_tc = NULL);
virtual int setPayment(MTGCardInstance * card);
virtual int isPaymentSet();
virtual int canPay();
virtual int doPay();
virtual void Render();
virtual int setSource(MTGCardInstance * _source);
virtual DiscardRandomCost * clone() const;
};
//tap other cost
class TapTargetCost: public ExtraCost{
public:
+2 -1
View File
@@ -271,12 +271,13 @@ class AbilityFactory{
int parseRestriction(string s);
public:
Counter * parseCounter(string s, MTGCardInstance * target, Spell * spell = NULL);
int parsePowerToughness(string s, int *power, int *toughness);
int parsePowerToughness(string s, int *power, int *toughness);
int getAbilities(vector<MTGAbility *> * v, Spell * spell, MTGCardInstance * card = NULL, int id = 0,MTGGameZone * dest = NULL);
MTGAbility * parseMagicLine(string s, int id, Spell * spell, MTGCardInstance *card, int activated = 0, int forceUEOT = 0,int oneShot = 0,int forceForever = 0, MTGGameZone * dest = NULL);
int abilityEfficiency(MTGAbility * a, Player * p, int mode = MODE_ABILITY, TargetChooser * tc = NULL);
int magicText(int id, Spell * spell, MTGCardInstance * card = NULL, int mode = MODE_PUTINTOPLAY, TargetChooser * tc = NULL, MTGGameZone * dest = NULL);
static int computeX(Spell * spell, MTGCardInstance * card);
static int computeXX(Spell * spell, MTGCardInstance * card);
static MTGAbility * getCoreAbility(MTGAbility * a);
int destroyAllInPlay(TargetChooser * tc, int bury = 0);
int moveAll(TargetChooser * tc, string destinationZone);
+1
View File
@@ -44,6 +44,7 @@ class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable {
MTGGameZone * currentZone;
Pos* view;
int X;
int XX;
int boughtback;
int flashedback;
int paymenttype;