From 193d7accb4c6e4b970b57ec09cced9d785ae17e4 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 28 Jul 2016 06:42:47 +0800 Subject: [PATCH 1/4] revised legendary --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 1 + projects/mtg/include/GameObserver.h | 2 - projects/mtg/include/MTGRules.h | 1 + projects/mtg/src/GameObserver.cpp | 44 -------------------- projects/mtg/src/MTGRules.cpp | 29 +++++++------ 5 files changed, 19 insertions(+), 58 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 6d950a954..c2a276b18 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -68962,6 +68962,7 @@ toughness=1 [/card] [card] name=Mirror Gallery +abilities=nolegend auto=lord(*|battlefield) nolegend text=The "legend rule" doesn't apply. mana={5} diff --git a/projects/mtg/include/GameObserver.h b/projects/mtg/include/GameObserver.h index 6d451a392..2f520043c 100644 --- a/projects/mtg/include/GameObserver.h +++ b/projects/mtg/include/GameObserver.h @@ -126,8 +126,6 @@ class GameObserver{ void Affinity(); bool AffinityNeedsUpdate; void addObserver(MTGAbility * observer); - void checkLegendary(MTGCardInstance * card); - map cards; bool removeObserver(ActionElement * observer); void startGame(GameType, Rules * rules); void untapPhase(); diff --git a/projects/mtg/include/MTGRules.h b/projects/mtg/include/MTGRules.h index 92eacfc07..18ed916b4 100644 --- a/projects/mtg/include/MTGRules.h +++ b/projects/mtg/include/MTGRules.h @@ -434,6 +434,7 @@ public: int added(MTGCardInstance * card); int removed(MTGCardInstance * card); int testDestroy(); + void checkLegendary(MTGCardInstance * card); virtual ostream& toString(ostream& out) const; virtual MTGLegendRule * clone() const; }; diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 9892a118d..19d2f2e5a 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -897,13 +897,6 @@ void GameObserver::gameStateBasedEffects() int nbcards = z->nb_cards; //------------------------------ p->nomaxhandsize = (z->hasAbility(Constants::NOMAXHAND)); - //legendary - for (int cl = 0; cl < nbcards; cl++) - { - MTGCardInstance * c = z->cards[cl]; - if(!c->isPhased && c->hasType(Subtypes::TYPE_LEGENDARY) && !c->has(Constants::NOLEGEND)) - checkLegendary(c); - } ///////////////////////////////////////////////// //handle end of turn effects while we're at it.// ///////////////////////////////////////////////// @@ -1027,43 +1020,6 @@ void GameObserver::gameStateBasedEffects() } } -void GameObserver::checkLegendary(MTGCardInstance * card) -{ - map::iterator it; - int destroy = 0; - - vectoroldCards; - for (it = cards.begin(); it != cards.end(); it++) - { - MTGCardInstance * comparison = (*it).first; - if (comparison != card && comparison->controller() == card->controller() && !(comparison->getName().compare(card->getName()))) - { - oldCards.push_back(comparison); - destroy = 1; - } - } - if(destroy) - { - vectorselection; - MultiAbility * multi = NEW MultiAbility(this, this->mLayers->actionLayer()->getMaxId(), card, card, NULL); - for(unsigned int i = 0;i < oldCards.size();i++) - { - AAMover *a = NEW AAMover(this, this->mLayers->actionLayer()->getMaxId(), card, oldCards[i],"ownergraveyard","Keep New"); - a->oneShot = true; - multi->Add(a); - } - multi->oneShot = 1; - MTGAbility * a1 = multi; - selection.push_back(a1); - AAMover *b = NEW AAMover(this, this->mLayers->actionLayer()->getMaxId(), card, card,"ownergraveyard","Keep Old"); - b->oneShot = true; - MTGAbility * b1 = b; - selection.push_back(b1); - MTGAbility * menuChoice = NEW MenuAbility(this, this->mLayers->actionLayer()->getMaxId(), card, card,true,selection,card->controller(),"Legendary Rule"); - menuChoice->addToGame(); - } -} - void GameObserver::enchantmentStatus() { for (int i = 0; i < 2; i++) diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 4a210d44a..78ce1cae9 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -3187,7 +3187,7 @@ int MTGLegendRule::canBeInList(MTGCardInstance * card) return 0; if (card->hasType(Subtypes::TYPE_LEGENDARY) && card->controller()->game->inPlay->hasCard(card)) { - if(card->has(Constants::NOLEGEND)||card->controller()->opponent()->inPlay()->hasName("Mirror Gallery")||card->controller()->inPlay()->hasName("Mirror Gallery")) + if(card->has(Constants::NOLEGEND)||card->controller()->game->inPlay->hasAbility(Constants::NOLEGEND)||card->controller()->opponent()->game->inPlay->hasAbility(Constants::NOLEGEND)) return 0; else return 1; @@ -3196,6 +3196,22 @@ int MTGLegendRule::canBeInList(MTGCardInstance * card) } int MTGLegendRule::added(MTGCardInstance * card) +{ + checkLegendary(card); + return 1; +} + +int MTGLegendRule::removed(MTGCardInstance *) +{ + return 0; +} + +int MTGLegendRule::testDestroy() +{ + return 0; +} + +void MTGLegendRule::checkLegendary(MTGCardInstance * card) { map::iterator it; int destroy = 0; @@ -3230,17 +3246,6 @@ int MTGLegendRule::added(MTGCardInstance * card) MTGAbility * menuChoice = NEW MenuAbility(game, game->mLayers->actionLayer()->getMaxId(), card, card,true,selection,card->controller(),"Legendary Rule"); menuChoice->addToGame(); } - return 1; -} - -int MTGLegendRule::removed(MTGCardInstance *) -{ - return 0; -} - -int MTGLegendRule::testDestroy() -{ - return 0; } ostream& MTGLegendRule::toString(ostream& out) const From 2a33c0c375a85b37e27e74de945a5a80a7d331e4 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 28 Jul 2016 10:26:25 +0800 Subject: [PATCH 2/4] moved sac event --- projects/mtg/src/AllAbilities.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 63de1d89f..06f809ce2 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -2717,14 +2717,11 @@ int AASacrificeCard::resolve() { Player * p = _target->controller(); MTGCardInstance * beforeCard = _target; - WEvent * e; - if(!_target->isToken) - e = NEW WEventCardSacrifice(beforeCard,_target); - else - e = NEW WEventCardSacrifice(beforeCard,_target,true); p->game->putInGraveyard(_target); while(_target->next) _target = _target->next; + bool istoken = _target->isToken?true:false; + WEvent * e = NEW WEventCardSacrifice(beforeCard,_target,istoken); game->receiveEvent(e); if(andAbility) { From f168702aadd089b4ba8482e61d6689eb89370339 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 28 Jul 2016 10:28:27 +0800 Subject: [PATCH 3/4] Revert "moved sac event" This reverts commit 2a33c0c375a85b37e27e74de945a5a80a7d331e4. --- projects/mtg/src/AllAbilities.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 06f809ce2..63de1d89f 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -2717,11 +2717,14 @@ int AASacrificeCard::resolve() { Player * p = _target->controller(); MTGCardInstance * beforeCard = _target; + WEvent * e; + if(!_target->isToken) + e = NEW WEventCardSacrifice(beforeCard,_target); + else + e = NEW WEventCardSacrifice(beforeCard,_target,true); p->game->putInGraveyard(_target); while(_target->next) _target = _target->next; - bool istoken = _target->isToken?true:false; - WEvent * e = NEW WEventCardSacrifice(beforeCard,_target,istoken); game->receiveEvent(e); if(andAbility) { From 7bd940ddb38ef68f5673da2fa1776e07645e2f1b Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 28 Jul 2016 10:28:54 +0800 Subject: [PATCH 4/4] Revert "revised legendary" This reverts commit 193d7accb4c6e4b970b57ec09cced9d785ae17e4. --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 1 - projects/mtg/include/GameObserver.h | 2 + projects/mtg/include/MTGRules.h | 1 - projects/mtg/src/GameObserver.cpp | 44 ++++++++++++++++++++ projects/mtg/src/MTGRules.cpp | 29 ++++++------- 5 files changed, 58 insertions(+), 19 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index c2a276b18..6d950a954 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -68962,7 +68962,6 @@ toughness=1 [/card] [card] name=Mirror Gallery -abilities=nolegend auto=lord(*|battlefield) nolegend text=The "legend rule" doesn't apply. mana={5} diff --git a/projects/mtg/include/GameObserver.h b/projects/mtg/include/GameObserver.h index 2f520043c..6d451a392 100644 --- a/projects/mtg/include/GameObserver.h +++ b/projects/mtg/include/GameObserver.h @@ -126,6 +126,8 @@ class GameObserver{ void Affinity(); bool AffinityNeedsUpdate; void addObserver(MTGAbility * observer); + void checkLegendary(MTGCardInstance * card); + map cards; bool removeObserver(ActionElement * observer); void startGame(GameType, Rules * rules); void untapPhase(); diff --git a/projects/mtg/include/MTGRules.h b/projects/mtg/include/MTGRules.h index 18ed916b4..92eacfc07 100644 --- a/projects/mtg/include/MTGRules.h +++ b/projects/mtg/include/MTGRules.h @@ -434,7 +434,6 @@ public: int added(MTGCardInstance * card); int removed(MTGCardInstance * card); int testDestroy(); - void checkLegendary(MTGCardInstance * card); virtual ostream& toString(ostream& out) const; virtual MTGLegendRule * clone() const; }; diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 19d2f2e5a..9892a118d 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -897,6 +897,13 @@ void GameObserver::gameStateBasedEffects() int nbcards = z->nb_cards; //------------------------------ p->nomaxhandsize = (z->hasAbility(Constants::NOMAXHAND)); + //legendary + for (int cl = 0; cl < nbcards; cl++) + { + MTGCardInstance * c = z->cards[cl]; + if(!c->isPhased && c->hasType(Subtypes::TYPE_LEGENDARY) && !c->has(Constants::NOLEGEND)) + checkLegendary(c); + } ///////////////////////////////////////////////// //handle end of turn effects while we're at it.// ///////////////////////////////////////////////// @@ -1020,6 +1027,43 @@ void GameObserver::gameStateBasedEffects() } } +void GameObserver::checkLegendary(MTGCardInstance * card) +{ + map::iterator it; + int destroy = 0; + + vectoroldCards; + for (it = cards.begin(); it != cards.end(); it++) + { + MTGCardInstance * comparison = (*it).first; + if (comparison != card && comparison->controller() == card->controller() && !(comparison->getName().compare(card->getName()))) + { + oldCards.push_back(comparison); + destroy = 1; + } + } + if(destroy) + { + vectorselection; + MultiAbility * multi = NEW MultiAbility(this, this->mLayers->actionLayer()->getMaxId(), card, card, NULL); + for(unsigned int i = 0;i < oldCards.size();i++) + { + AAMover *a = NEW AAMover(this, this->mLayers->actionLayer()->getMaxId(), card, oldCards[i],"ownergraveyard","Keep New"); + a->oneShot = true; + multi->Add(a); + } + multi->oneShot = 1; + MTGAbility * a1 = multi; + selection.push_back(a1); + AAMover *b = NEW AAMover(this, this->mLayers->actionLayer()->getMaxId(), card, card,"ownergraveyard","Keep Old"); + b->oneShot = true; + MTGAbility * b1 = b; + selection.push_back(b1); + MTGAbility * menuChoice = NEW MenuAbility(this, this->mLayers->actionLayer()->getMaxId(), card, card,true,selection,card->controller(),"Legendary Rule"); + menuChoice->addToGame(); + } +} + void GameObserver::enchantmentStatus() { for (int i = 0; i < 2; i++) diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 78ce1cae9..4a210d44a 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -3187,7 +3187,7 @@ int MTGLegendRule::canBeInList(MTGCardInstance * card) return 0; if (card->hasType(Subtypes::TYPE_LEGENDARY) && card->controller()->game->inPlay->hasCard(card)) { - if(card->has(Constants::NOLEGEND)||card->controller()->game->inPlay->hasAbility(Constants::NOLEGEND)||card->controller()->opponent()->game->inPlay->hasAbility(Constants::NOLEGEND)) + if(card->has(Constants::NOLEGEND)||card->controller()->opponent()->inPlay()->hasName("Mirror Gallery")||card->controller()->inPlay()->hasName("Mirror Gallery")) return 0; else return 1; @@ -3196,22 +3196,6 @@ int MTGLegendRule::canBeInList(MTGCardInstance * card) } int MTGLegendRule::added(MTGCardInstance * card) -{ - checkLegendary(card); - return 1; -} - -int MTGLegendRule::removed(MTGCardInstance *) -{ - return 0; -} - -int MTGLegendRule::testDestroy() -{ - return 0; -} - -void MTGLegendRule::checkLegendary(MTGCardInstance * card) { map::iterator it; int destroy = 0; @@ -3246,6 +3230,17 @@ void MTGLegendRule::checkLegendary(MTGCardInstance * card) MTGAbility * menuChoice = NEW MenuAbility(game, game->mLayers->actionLayer()->getMaxId(), card, card,true,selection,card->controller(),"Legendary Rule"); menuChoice->addToGame(); } + return 1; +} + +int MTGLegendRule::removed(MTGCardInstance *) +{ + return 0; +} + +int MTGLegendRule::testDestroy() +{ + return 0; } ostream& MTGLegendRule::toString(ostream& out) const