From 6f792e554606494eab34b82089b3c16828f4ea02 Mon Sep 17 00:00:00 2001 From: "omegablast2002@yahoo.com" Date: Tue, 22 Feb 2011 14:38:07 +0000 Subject: [PATCH] --- projects/mtg/include/AllAbilities.h | 24 ++++++++++---------- projects/mtg/src/AllAbilities.cpp | 24 +++++++++++++------- projects/mtg/src/MTGAbility.cpp | 34 ++++++++++++++--------------- 3 files changed, 45 insertions(+), 37 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index d99bcf8c1..5acfe6393 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -3869,15 +3869,15 @@ public: list oldtypes; bool remove; string menu; - int newpower; + string newpower; bool newpowerfound; int oldpower; - int newtoughness; + string newtoughness; bool newtoughnessfound; int oldtoughness; - ATransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,int newpower,bool newpowerfound,int newtoughness,bool newtoughnessfound); + ATransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound); int addToGame(); int destroy(); const char * getMenuText(); @@ -3893,15 +3893,15 @@ public: list types; list colors; string menu; - int newpower; + string newpower; bool newpowerfound; int oldpower; - int newtoughness; + string newtoughness; bool newtoughnessfound; int oldtoughness; bool remove; - AForeverTransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,int newpower,bool newpowerfound,int newtoughness,bool newtoughnessfound); + AForeverTransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound); int addToGame(); const char * getMenuText(); AForeverTransformer * clone() const; @@ -3913,12 +3913,12 @@ class ATransformerUEOT: public InstantAbility { public: ATransformer * ability; - int newpower; + string newpower; bool newpowerfound; - int newtoughness; + string newtoughness; bool newtoughnessfound; - ATransformerUEOT(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,int newpower,bool newpowerfound,int newtoughness,bool newtoughnessfound); + ATransformerUEOT(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound); int resolve(); const char * getMenuText(); ATransformerUEOT * clone() const; @@ -3930,12 +3930,12 @@ class ATransformerFOREVER: public InstantAbility { public: AForeverTransformer * ability; - int newpower; + string newpower; bool newpowerfound; - int newtoughness; + string newtoughness; bool newtoughnessfound; - ATransformerFOREVER(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,int newpower = 0,bool newpowerfound = false,int newtoughness = 0,bool newtoughnessfound = false); + ATransformerFOREVER(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower = "",bool newpowerfound = false,string newtoughness = "",bool newtoughnessfound = false); int resolve(); const char * getMenuText(); ATransformerFOREVER * clone() const; diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 41d164b2c..509fee777 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -2181,7 +2181,7 @@ AAlterCost::~AAlterCost() } // ATransformer -ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,int newpower,bool newpowerfound,int newtoughness,bool newtoughnessfound) : +ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound) : MTGAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound) { @@ -2276,15 +2276,19 @@ int ATransformer::addToGame() } if(newpowerfound ) { + WParsedInt * val = NEW WParsedInt(newpower,NULL, source); oldpower = _target->power; - _target->power += newpower; + _target->power += val->getValue(); _target->power -= oldpower; + delete val; } if(newtoughnessfound ) { + WParsedInt * val = NEW WParsedInt(newtoughness,NULL, source); oldtoughness = _target->toughness; - _target->addToToughness(newtoughness); + _target->addToToughness(val->getValue()); _target->addToToughness(-oldtoughness); + delete val; } } return MTGAbility::addToGame(); @@ -2355,7 +2359,7 @@ ATransformer::~ATransformer() // AForeverTransformer AForeverTransformer::AForeverTransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, - string sabilities,int newpower,bool newpowerfound, int newtoughness,bool newtoughnessfound) : + string sabilities,string newpower,bool newpowerfound, string newtoughness,bool newtoughnessfound) : MTGAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound) { aType = MTGAbility::STANDARD_BECOMES; @@ -2408,15 +2412,19 @@ int AForeverTransformer::addToGame() } if(newpowerfound ) { + WParsedInt * val = NEW WParsedInt(newpower,NULL, source); oldpower = _target->power -= oldpower; - _target->power += newpower; + _target->power += val->getValue(); _target->power -= oldpower; + delete val; } if(newtoughnessfound ) { + WParsedInt * val = NEW WParsedInt(newtoughness,NULL, source); oldtoughness = _target->toughness; - _target->addToToughness(newtoughness); + _target->addToToughness(val->getValue()); _target->addToToughness(-oldtoughness); + delete val; } } return MTGAbility::addToGame(); @@ -2440,7 +2448,7 @@ AForeverTransformer::~AForeverTransformer() } //ATransformerUEOT -ATransformerUEOT::ATransformerUEOT(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,int newpower,bool newpowerfound,int newtoughness,bool newtoughnessfound) : +ATransformerUEOT::ATransformerUEOT(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound) : InstantAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound) { ability = NEW ATransformer(id, source, target, types, abilities,newpower,newpowerfound,newtoughness,newtoughnessfound); @@ -2473,7 +2481,7 @@ ATransformerUEOT::~ATransformerUEOT() } // ATransformerFOREVER -ATransformerFOREVER::ATransformerFOREVER(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,int newpower,bool newpowerfound,int newtoughness,bool newtoughnessfound) : +ATransformerFOREVER::ATransformerFOREVER(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound) : InstantAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound) { ability = NEW AForeverTransformer(id, source, target, types, abilities,newpower,newpowerfound,newtoughness,newtoughnessfound); diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 6aec543c7..b01fa8ec1 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -2507,26 +2507,26 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG string sabilities = transformsParamsString.substr(stypes.length()); bool newpowerfound = false; - int newpower = 0; - size_t powerability = sabilities.find("setpower="); - if(sabilities.find(",setpower=") != string::npos) - { - newpowerfound = true; - int powerstart = s.find("setpower=", powerability); - int powerend = s.find(real_end, powerstart); - newpower = atoi(s.substr(powerstart + 9).c_str()); - } + string newpower = ""; bool newtoughnessfound = false; - int newtoughness = 0; - size_t toughnessability = sabilities.find("settoughness="); - if(sabilities.find(",settoughness=") != string::npos) + string newtoughness = ""; + vector abilities = split(sabilities, ','); + + for(unsigned int j = 0;j < abilities.size();j++) { - newtoughnessfound = true; - int toughnessstart = s.find("settoughness=", toughnessability); - int toughnessend = s.find(real_end, toughnessstart); - newtoughness = atoi(s.substr(toughnessstart + 13).c_str()); + if(abilities[j].find("setpower=") != string::npos) + { + newpowerfound = true; + int powerstart = abilities[j].find("setpower="); + newpower = abilities[j].substr(powerstart + 9).c_str(); + } + if(abilities[j].find("settoughness=") != string::npos) + { + newtoughnessfound = true; + int toughnessstart = abilities[j].find("settoughness="); + newtoughness = abilities[j].substr(toughnessstart + 13).c_str(); + } } - MTGAbility * a; if (forceFOREVER) {