diff --git a/projects/mtg/bin/Res/sets/RAV/_cards.dat b/projects/mtg/bin/Res/sets/RAV/_cards.dat index 58c572adf..3811b0010 100644 --- a/projects/mtg/bin/Res/sets/RAV/_cards.dat +++ b/projects/mtg/bin/Res/sets/RAV/_cards.dat @@ -511,7 +511,7 @@ abilities=mountainwalk [card] text=Whenever a nontoken creature you control is put into a graveyard from the battlefield, put a 1/1 green Saproling creature token onto the battlefield. id=89069 -auto=@movedto(creature|graveyard) from(myBattlefield):token(Saproling,creature saproling, 1/1,green) +auto=@movedto(creature[-token]|graveyard) from(myBattlefield):token(Saproling,creature saproling, 1/1,green) name=Golgari Germination rarity=U type=Enchantment diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index b00ffa25d..4746f1001 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -165,6 +165,7 @@ death_ward.txt deja_vu.txt delusions_of_mediocrity.txt dingus_egg.txt +dingus_staff_i153.txt divergent_growth.txt doomed_necromancer.txt double_strike_i145.txt @@ -230,6 +231,7 @@ goblin_lackey2.txt goblin_lackey3.txt goblin_lackey4.txt goblin_offensive.txt +golgari_germination_i153.txt gravedigger.txt great_defender.txt hannas_custody.txt diff --git a/projects/mtg/bin/Res/test/dingus_staff_i153.txt b/projects/mtg/bin/Res/test/dingus_staff_i153.txt new file mode 100644 index 000000000..18c7e8306 --- /dev/null +++ b/projects/mtg/bin/Res/test/dingus_staff_i153.txt @@ -0,0 +1,21 @@ +#Bug: Tokens don't go to the graveyard +#see: http://code.google.com/p/wagic/issues/detail?id=153 +[INIT] +FIRSTMAIN +[PLAYER1] +inplay:1138,dingus staff +hand:shock +manapool:{5}{R} +[PLAYER2] +[DO] +1138 +shock +-1138 +[ASSERT] +FIRSTMAIN +[PLAYER1] +life:18 +inplay:1138,dingus staff +graveyard:shock +[PLAYER2] +[END] \ No newline at end of file diff --git a/projects/mtg/bin/Res/test/golgari_germination_i153.txt b/projects/mtg/bin/Res/test/golgari_germination_i153.txt new file mode 100644 index 000000000..9aadcae4e --- /dev/null +++ b/projects/mtg/bin/Res/test/golgari_germination_i153.txt @@ -0,0 +1,21 @@ +#Bug: Tokens and graveyard +#see http://code.google.com/p/wagic/issues/detail?id=153 +[INIT] +FIRSTMAIN +[PLAYER1] +inplay:grizzly bears,89069 +manapool:{R}{R} +hand:lightning bolt,shock +[PLAYER2] +[DO] +lightning bolt +grizzly bears +shock +-89069 +[ASSERT] +FIRSTMAIN +[PLAYER1] +graveyard:lightning bolt,grizzly bears,shock +inplay:89069 +[PLAYER2] +[END] \ No newline at end of file diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index 413ba8df6..0c2fb39e7 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -47,7 +47,7 @@ class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable { MTGGameZone * currentZone; Pos* view; int regenerateTokens; - bool isToken; + int isToken; int stillInUse(); Player * lastController; MTGGameZone * getCurrentZone(); diff --git a/projects/mtg/include/MTGRules.h b/projects/mtg/include/MTGRules.h index 319f9a85a..fcf940dd4 100644 --- a/projects/mtg/include/MTGRules.h +++ b/projects/mtg/include/MTGRules.h @@ -64,6 +64,16 @@ class MTGPersistRule:public MTGAbility{ }; +class MTGTokensCleanup:public MTGAbility{ + public: + vector list; + MTGTokensCleanup(int _id); + int receiveEvent(WEvent * event); + int testDestroy(); + void Update(float dt); + virtual MTGTokensCleanup * clone() const; +}; + /* * Rule 420.5e (Legend Rule) * If two or more legendary permanents with the same name are in play, all are put into their diff --git a/projects/mtg/src/CardDescriptor.cpp b/projects/mtg/src/CardDescriptor.cpp index 2b8d31a07..bf3a3cf29 100644 --- a/projects/mtg/src/CardDescriptor.cpp +++ b/projects/mtg/src/CardDescriptor.cpp @@ -150,7 +150,9 @@ MTGCardInstance * CardDescriptor::match(MTGCardInstance * card){ match = NULL; } - + if ((isToken== -1 && card->isToken) || (isToken == 1 && !card->isToken)){ + match = NULL; + } if (attacker == 1){ if (defenser == &AnyCard){ diff --git a/projects/mtg/src/DuelLayers.cpp b/projects/mtg/src/DuelLayers.cpp index 1cda5b9a1..18299adef 100644 --- a/projects/mtg/src/DuelLayers.cpp +++ b/projects/mtg/src/DuelLayers.cpp @@ -28,6 +28,7 @@ void DuelLayers::init(){ action->Add(NEW MTGLifelinkRule(-1)); action->Add(NEW MTGDeathtouchRule(-1)); action->Add(NEW OtherAbilitiesEventReceiver(-1)); + action->Add(NEW MTGTokensCleanup(-1)); //Other display elements action->Add(NEW HUDDisplay(-1)); diff --git a/projects/mtg/src/MTGGameZones.cpp b/projects/mtg/src/MTGGameZones.cpp index 9e443ccba..e273dcb3c 100644 --- a/projects/mtg/src/MTGGameZones.cpp +++ b/projects/mtg/src/MTGGameZones.cpp @@ -148,12 +148,12 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone } MTGCardInstance * ret = copy; - if (card->isToken){ + /*if (card->isToken){ if (to != g->players[0]->game->inPlay && to != g->players[1]->game->inPlay){ to = garbage; ret = NULL; } - } + }*/ to->addCard(copy); copy->changedZoneRecently = 1.f; @@ -211,13 +211,21 @@ MTGCardInstance * MTGGameZone::removeCard(MTGCardInstance * card, int createCopy nb_cards--; cards.erase(cards.begin()+i); MTGCardInstance * copy = card; - if (card->isToken) //TODO better than this ? - return card; + //if (card->isToken) //TODO better than this ? + // return card; //card->lastController = card->controller(); if (createCopy) { copy = NEW MTGCardInstance(card->model,card->owner->game); copy->previous = card; copy->view = card->view; + copy->isToken = card->isToken; + + //stupid bug with tokens... + if (card->model == card) + copy->model = copy; + if (card->data == card) + copy->data = copy; + card->next = copy; } copy->previousZone = this; diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 815f2ab4b..7e4b631aa 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -516,6 +516,36 @@ HUDDisplay::~HUDDisplay(){ } + MTGTokensCleanup::MTGTokensCleanup(int _id):MTGAbility(_id, NULL){} + + int MTGTokensCleanup::receiveEvent(WEvent * e){ + if (WEventZoneChange* event = dynamic_cast(e)){ + if (!event->card->isToken) return 0; + if (event->to == game->players[0]->game->inPlay || event->to == game->players[1]->game->inPlay) return 0; + if (event->to == game->players[0]->game->garbage || event->to == game->players[1]->game->garbage) return 0; + list.push_back(event->card); + return 1; + } + return 0; + } + + int MTGTokensCleanup::testDestroy(){return 0;} + + void MTGTokensCleanup::Update(float dt){ + MTGAbility::Update(dt); + for(size_t i= 0; i < list.size(); ++i){ + MTGCardInstance * c = list[i]; + c->controller()->game->putInZone(c,c->currentZone, c->controller()->game->garbage); + } + list.clear(); + } + + MTGTokensCleanup * MTGTokensCleanup::clone() const{ + MTGTokensCleanup * a = NEW MTGTokensCleanup(*this); + a->isClone = 1; + return a; + } + /* Legend Rule */ MTGLegendRule::MTGLegendRule(int _id):ListMaintainerAbility(_id){}; diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index d97ffc85b..f3e53a194 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -176,6 +176,13 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta }else{ cd->unsecureSetTapped(1); } + //Token + }else if (attribute.find("token") != string::npos){ + if (minus){ + cd->isToken = -1; + }else{ + cd->isToken = 1; + } //Power restrictions }else if (attribute.find("power") != string::npos){ cd->setPower(comparisonCriterion); diff --git a/projects/mtg/src/Token.cpp b/projects/mtg/src/Token.cpp index bd9e3e5c8..1ce39da84 100644 --- a/projects/mtg/src/Token.cpp +++ b/projects/mtg/src/Token.cpp @@ -12,6 +12,7 @@ Token::Token(string _name, MTGCardInstance * source, int _power, int _toughness) setMTGId(- source->getMTGId()); setId = source->setId; model = this; + data=this; owner = source->owner; belongs_to=source->controller()->game; attacker = 0;