From 9bcc54c56c9278ae831cad3dae355ae5ad3b99d9 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 25 Aug 2016 02:45:51 +0800 Subject: [PATCH] add "recent" & "raidcount" the recent attribute is to parse new cards entered play, then turns itself to 0 if some stuff happened since it's already in play... --- projects/mtg/include/AllAbilities.h | 9 +++++++++ projects/mtg/include/CardDescriptor.h | 1 + projects/mtg/include/MTGCardInstance.h | 1 + projects/mtg/src/AllAbilities.cpp | 1 + projects/mtg/src/CardDescriptor.cpp | 10 ++++++++++ projects/mtg/src/CardGui.cpp | 11 +++++++++++ projects/mtg/src/GameObserver.cpp | 1 + projects/mtg/src/MTGCardInstance.cpp | 1 + projects/mtg/src/MTGRules.cpp | 1 + projects/mtg/src/TargetChooser.cpp | 11 +++++++++++ 10 files changed, 47 insertions(+) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 2349eadb9..d3ffc0f56 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -551,6 +551,14 @@ private: intValue +=1; } } + else if (s == "praidcount") + { + intValue = card->controller()->raidcount; + } + else if (s == "oraidcount") + { + intValue = card->controller()->opponent()->raidcount; + } else if (s == "countallspell") { intValue = card->controller()->game->stack->seenThisTurn("*", Constants::CAST_ALL) + card->controller()->opponent()->game->stack->seenThisTurn("*", Constants::CAST_ALL); @@ -3803,6 +3811,7 @@ public: spell->source->owner = tokenReciever; spell->source->isToken = 1; spell->source->fresh = 1; + spell->source->entersBattlefield = 1; if(aLivingWeapon) { livingWeaponToken(spell->source); diff --git a/projects/mtg/include/CardDescriptor.h b/projects/mtg/include/CardDescriptor.h index 81f803beb..a9e9ac453 100644 --- a/projects/mtg/include/CardDescriptor.h +++ b/projects/mtg/include/CardDescriptor.h @@ -44,6 +44,7 @@ class CardDescriptor: public MTGCardInstance CardDescriptor(); void unsecureSetTapped(int i); void unsecuresetfresh(int k); + void unsecuresetrecent(int j); void setisMultiColored(int w); void setNegativeSubtype( string value); int counterPower; diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index 06028107c..1e031f525 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -283,6 +283,7 @@ public: int canproduceB; int canproduceW; int canproduceC; + int entersBattlefield; string currentimprintName; vectorimprintedNames; diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 774859a12..816d7a1d7 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -4008,6 +4008,7 @@ int AACloner::resolve() spell->source->isToken = 1; spell->resolve(); spell->source->fresh = 1; + spell->source->entersBattlefield = 1; spell->source->model = spell->source; spell->source->model->data = spell->source; //if the token doesn't have cda/dynamic pt then allow this... diff --git a/projects/mtg/src/CardDescriptor.cpp b/projects/mtg/src/CardDescriptor.cpp index b62b7499e..032f721bc 100644 --- a/projects/mtg/src/CardDescriptor.cpp +++ b/projects/mtg/src/CardDescriptor.cpp @@ -57,6 +57,11 @@ void CardDescriptor::unsecuresetfresh(int k) fresh = k; } +void CardDescriptor::unsecuresetrecent(int j) +{ + entersBattlefield = j; +} + void CardDescriptor::setisMultiColored(int w) { isMultiColored = w; @@ -218,6 +223,11 @@ MTGCardInstance * CardDescriptor::match(MTGCardInstance * card) { match = NULL; } + + if ((entersBattlefield == -1 && card->entersBattlefield) || (entersBattlefield == 1 && !card->entersBattlefield)) + { + match = NULL; + } if ((CDgeared == -1 && card->equipment > 0) || (CDgeared == 1 && card->equipment < 1)) { diff --git a/projects/mtg/src/CardGui.cpp b/projects/mtg/src/CardGui.cpp index 501261e18..6fc544d15 100644 --- a/projects/mtg/src/CardGui.cpp +++ b/projects/mtg/src/CardGui.cpp @@ -1362,6 +1362,17 @@ bool CardGui::FilterCard(MTGCard * _card,string filter) cd.unsecuresetfresh(1); } } + else if (attribute.find("recent") != string::npos) + { + if (minus) + { + cd.unsecuresetrecent(-1); + } + else + { + cd.unsecuresetrecent(1); + } + } else if (attribute.find("geared") != string::npos) { if (minus) diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 50b5fdcbe..9cfc26385 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -690,6 +690,7 @@ void GameObserver::gameStateBasedEffects() for (int j = zone->nb_cards - 1; j >= 0; j--) { MTGCardInstance * card = zone->cards[j]; + card->entersBattlefield = 0; card->LKIpower = card->power; card->LKItoughness = card->toughness; card->LKIbasicAbilities = card->basicAbilities; diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 77aa6ee9b..70d64c07c 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -258,6 +258,7 @@ void MTGCardInstance::initMTGCI() canproduceB = 0; canproduceW = 0; canproduceC = 0; + entersBattlefield = 0; currentimprintName = ""; imprintedNames.clear(); CountedObjects = 0; diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 222f37c72..f33f2ea25 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -3131,6 +3131,7 @@ int MTGUnearthRule::receiveEvent(WEvent * event) if (e->to == e->card->controller()->game->battlefield) { e->card->fresh = 1; + e->card->entersBattlefield = 1; } if (card && card->basicAbilities[(int)Constants::UNEARTH]) diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index 49dec7968..a57a36f17 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -486,6 +486,17 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta cd->unsecuresetfresh(1); } } + else if (attribute.find("recent") != string::npos) + { + if (minus) + { + cd->unsecuresetrecent(-1); + } + else + { + cd->unsecuresetrecent(1); + } + } else if (attribute.find("geared") != string::npos) { if (minus)