diff --git a/projects/mtg/bin/Res/sets/SHM/_cards.dat b/projects/mtg/bin/Res/sets/SHM/_cards.dat index 92c183c77..76844b240 100644 --- a/projects/mtg/bin/Res/sets/SHM/_cards.dat +++ b/projects/mtg/bin/Res/sets/SHM/_cards.dat @@ -468,6 +468,15 @@ subtype=Spider toughness=3 [/card] [card] +text={4}, {T}: Put a -1/-1 counter on target creature. +auto={4}{T}:counter(-1/-1) target(creature) +id=146015 +name=Gnarled Effigy +rarity=U +type=Artifact +mana={4} +[/card] +[card] text=Persist (When this creature is put into a graveyard from play, if it had no -1/-1 counters on it, return it to play under its owner's control with a -1/-1 counter on it.) abilities=persist id=141935 diff --git a/projects/mtg/bin/Res/sets/SHM/todo.dat b/projects/mtg/bin/Res/sets/SHM/todo.dat index b56930e89..7a506a243 100644 --- a/projects/mtg/bin/Res/sets/SHM/todo.dat +++ b/projects/mtg/bin/Res/sets/SHM/todo.dat @@ -493,14 +493,7 @@ rarity=C type=Instant mana={3}{G} [/card] -[card] -text={4}, {T}: Put a -1/-1 counter on target creature. -id=146015 -name=Gnarled Effigy -rarity=U -type=Artifact -mana={4} -[/card] + [card] text=Flying Other creatures are 1/1. id=142019 diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index 6b57eb62f..b86b12bc8 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -86,6 +86,7 @@ ghost_warden.txt giant_growth.txt giant_growth2.txt glimpse_the_unthinkable.txt +gnarled_effigy.txt goblin_balloon_brigade.txt goblin_balloon_brigade2.txt goblin_king.txt diff --git a/projects/mtg/bin/Res/test/gnarled_effigy.txt b/projects/mtg/bin/Res/test/gnarled_effigy.txt new file mode 100644 index 000000000..e8a1b6f3c --- /dev/null +++ b/projects/mtg/bin/Res/test/gnarled_effigy.txt @@ -0,0 +1,38 @@ +#text={4}, {T}: Put a -1/-1 counter on target creature. +[INIT] +SECONDMAIN +[PLAYER1] +inplay:gnarled effigy +manapool:{4} +[PLAYER2] +inplay:grizzly bears +[DO] +gnarled effigy +grizzly bears +eot +next +#upkeep +next +#draw +next +#firstmain +next +#begin +next +#attackers +grizzly bears +next +#blockers +next +#damage +next +#end +[ASSERT] +COMBATEND +[PLAYER1] +inplay:gnarled effigy +manapool:{0} +life:19 +[PLAYER2] +inplay:grizzly bears +[END] \ No newline at end of file diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 16c58c1a9..3badc3f59 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -57,6 +57,42 @@ public: }; +//counters +class AACounter: public ActivatedAbility{ + public: + int nb; + int power; + int toughness; + AACounter(int id, MTGCardInstance * _source, MTGCardInstance * _target, int _power, int _toughness, int nb,ManaCost * cost=NULL, int doTap = 1):ActivatedAbility(id,_source,cost,0,doTap),power(_power),toughness(_toughness),nb(nb){ + target=_target; + } + + + int resolve(){ + if (target){ + MTGCardInstance * _target = (MTGCardInstance *)target; + if (nb>0){ + for (int i=0; i < nb; i++){ + _target->counters->addCounter(power, toughness); + } + }else{ + for (int i=0; i < nb; i++){ + _target->counters->removeCounter(power, toughness); + } + } + return nb; + } + return 0; + } + + AACounter * clone() const{ + AACounter * a = NEW AACounter(*this); + a->isClone = 1; + return a; + } +}; + + class AAFizzler:public ActivatedAbility{ public: AAFizzler(int _id, MTGCardInstance * card, Spell * _target, ManaCost * _cost = NULL, int _tap = 1):ActivatedAbility(_id, card,_cost,0,_tap){ @@ -4207,30 +4243,7 @@ class ALifeModifierPutinplay: public ListMaintainerAbility{ /// Work in Progress also from no on all code could be removed... -//Draft for counters -class ACounters: public MTGAbility{ - public: - int counter; - int power; - int toughness; - ACounters(int id, MTGCardInstance * _source, MTGCardInstance * _target, int _power, int _toughness):MTGAbility(id,_source,_target),power(_power),toughness(_toughness){ - _target->counters->addCounter(power, toughness); - } - virtual ostream& toString(ostream& out) const - { - out << "ACounters ::: counter : " << counter - << " ; power : " << power - << " ; toughness : " << toughness - << " ("; - return MTGAbility::toString(out) << ")"; - } - ACounters * clone() const{ - ACounters * a = NEW ACounters(*this); - a->isClone = 1; - return a; - } -}; ///// Not working need to work on this one ///Abomination Kill blocking creature if white or green diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index ec794ba9f..9fdbebdd6 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -128,6 +128,7 @@ TriggeredAbility * AbilityFactory::parseTrigger(string magicText, int id, Spell + //Parses a string and returns the corresponding MTGAbility object // Returns NULL if parsing failed MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTGCardInstance *card, int activated){ @@ -497,25 +498,27 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG } return NULL; } -/* + //counter found = s.find("counter("); if (found != string::npos){ - int end = s.find(")", found); - string spt = s.substr(9,end - 1); + found+=8; + int nb = 1; + size_t end = s.find(")", found); + size_t separator = s.find(",", found); + if (separator != string::npos){ + nb = atoi(s.substr(found,separator-found).c_str()); + end = separator; + } + string spt = s.substr(found,end-found); int power, toughness; if ( parsePowerToughness(spt,&power, &toughness)){ - if(tc){ - //TODO - }else{ - return NEW ACounters(id,card,target,power,toughness); - } + return NEW AACounter(id,card,target,power,toughness,nb); } return NULL; } -*/ //Change Power/Toughness @@ -783,7 +786,7 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){ magicText = ""; } - MTGAbility * a = parseMagicLine(line, result, spell, card); + MTGAbility * a = parseMagicLine(line, result, spell, card); if (dryMode){ result = abilityEfficiency(a, card->controller(),MODE_PUTINTOPLAY); SAFE_DELETE(a);