diff --git a/projects/mtg/bin/Res/sets/EVE/_cards.dat b/projects/mtg/bin/Res/sets/EVE/_cards.dat index f63cfbc41..a5238098d 100644 --- a/projects/mtg/bin/Res/sets/EVE/_cards.dat +++ b/projects/mtg/bin/Res/sets/EVE/_cards.dat @@ -607,6 +607,7 @@ toughness=2 text=When Rise of the Hobgoblins comes into play, you may pay {X}. If you do, put X 1/1 red and white Goblin Soldier creature tokens into play. {RW}: Red creatures and white creatures you control gain first strike until end of turn. id=151114 auto={RW}:lord(creature[white;red]|myinplay) first strike +auto=Token(Goblin Soldier,Creature Goblin Soldier,1/1,red white)*x name=Rise of the Hobgoblins rarity=R type=Enchantment diff --git a/projects/mtg/bin/Res/sets/USG/_cards.dat b/projects/mtg/bin/Res/sets/USG/_cards.dat index f18aa705e..25cd9f136 100644 --- a/projects/mtg/bin/Res/sets/USG/_cards.dat +++ b/projects/mtg/bin/Res/sets/USG/_cards.dat @@ -546,6 +546,7 @@ toughness=1 text=Put X 1/1 red Goblin creature tokens onto the battlefield. id=8818 name=Goblin Offensive +auto=token(Goblin,Creature Goblin,1/1,red)*x rarity=U mana={X}{1}{R}{R} type=Sorcery diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index 4ade5da35..b86f3d2a0 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -117,6 +117,7 @@ gnarled_effigy.txt goblin_balloon_brigade.txt goblin_balloon_brigade2.txt goblin_king.txt +goblin_offensive.txt gravedigger.txt #hammerfist_giant.txt hannas_custody.txt diff --git a/projects/mtg/bin/Res/test/goblin_offensive.txt b/projects/mtg/bin/Res/test/goblin_offensive.txt new file mode 100644 index 000000000..009ad0bf9 --- /dev/null +++ b/projects/mtg/bin/Res/test/goblin_offensive.txt @@ -0,0 +1,16 @@ +#Test: X for tokens +[INIT] +FIRSTMAIN +[PLAYER1] +manapool:{5}{1}{R}{R} +hand:goblin offensive +[PLAYER2] +[DO] +goblin offensive +[ASSERT] +FIRSTMAIN +[PLAYER1] +inplay:*,*,*,*,* +graveyard:goblin offensive +[PLAYER2] +[END] \ No newline at end of file diff --git a/projects/mtg/bin/daily_build/template.exe b/projects/mtg/bin/daily_build/template.exe index a368e30e3..60ee0acde 100644 Binary files a/projects/mtg/bin/daily_build/template.exe and b/projects/mtg/bin/daily_build/template.exe differ diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 4679684a8..1f2b3f5bd 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -35,8 +35,8 @@ public: delete c; return x; } - WParsedInt(){ - intValue = 0; + WParsedInt(int value = 0){ + intValue = value; } WParsedInt(string s, Spell * spell, MTGCardInstance * card){ @@ -517,12 +517,12 @@ public: listcolors; int power, toughness; string name; - int multiplier; - ATokenCreator(int _id,MTGCardInstance * _source,ManaCost * _cost, string sname, string stypes,int _power,int _toughness, string sabilities, int _doTap, int _multiplier = 1):ActivatedAbility(_id,_source,_cost,0,_doTap){ + WParsedInt * multiplier; + ATokenCreator(int _id,MTGCardInstance * _source,ManaCost * _cost, string sname, string stypes,int _power,int _toughness, string sabilities, int _doTap, WParsedInt * multiplier = NULL):ActivatedAbility(_id,_source,_cost,0,_doTap), multiplier(multiplier){ power = _power; toughness = _toughness; name = sname; - multiplier = _multiplier; + 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; @@ -556,7 +556,7 @@ public: } int resolve(){ - for (int i = 0; i < multiplier; ++i){ + for (int i = 0; i < multiplier->getValue(); ++i){ Token * myToken = NEW Token(name,source,power,toughness); list::iterator it; for ( it=types.begin() ; it != types.end(); it++ ){ @@ -594,6 +594,12 @@ public: return a; } + ~ATokenCreator(){ + if (!isClone){ + delete(multiplier); + } + } + }; class AAMover:public ActivatedAbility{ diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 7907949a1..186ab71fd 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -367,9 +367,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG int power, toughness; parsePowerToughness(spt,&power, &toughness); string sabilities = s.substr(end+1); - int multiplier = 1; + WParsedInt * multiplier = NULL; found = s.find("*"); - if (found != string::npos)multiplier = atoi(s.substr(found+1).c_str()); + if (found != string::npos)multiplier = NEW WParsedInt(s.substr(found+1),spell,card); ATokenCreator * tok = NEW ATokenCreator(id,card,NULL,sname,stypes,power,toughness,sabilities,0, multiplier); tok->oneShot = 1; return tok; @@ -1453,20 +1453,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){ } break; } - - -//-- addon Urza Saga--- - case 8818: //Goblin Offensive - { - int x = computeX(spell,card); - ATokenCreator * tok = NEW ATokenCreator(id,card,NEW ManaCost(),"Goblin","creature Goblin",1,1,"Red",0); - for (int i=0; i < x; i++){ - tok->resolve(); - } - delete(tok); - break; - } - + //-- addon 10E--- case 129710: //Angelic Chorus @@ -1557,7 +1544,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){ } // --- addon Invasion--- - case 23195: //Artifact Mutation + case 23195: //Artifact Mutation { card->target->controller()->game->putInGraveyard(card->target); int x = card->target->getManaCost()->getConvertedCost(); @@ -1568,18 +1555,6 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){ delete(tok); break; } -//--- addon Eventide ---- - - case 151114: //Rise of the Hobgoblins - { - int x = computeX(spell,card); - ATokenCreator * tok = NEW ATokenCreator(id,card,NEW ManaCost(),"Goblin Soldier","creature Goblin Soldier",1,1,"red white",0); - for (int i=0; i < x; i++){ - tok->resolve(); - } - delete(tok); - break; - } // --- addon Ravnica---