From d26e9da6c4738a6d3fc43b344f0d2475c7ec3751 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Fri, 3 Feb 2017 07:59:13 +0800 Subject: [PATCH 1/5] add some restrictions --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 37 +++++++++---------- projects/mtg/src/MTGAbility.cpp | 38 ++++++++++++++++++++ 2 files changed, 57 insertions(+), 18 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 5c84d17ab..2a80f218e 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -11944,9 +11944,10 @@ type=Sorcery [/card] [card] name=Blood Tribute +target=opponent +auto=life:-halfdownopponentlifetotal targetedplayer +auto=alternative life:opponentlifetotal controller text=Kicker - Tap an untapped Vampire you control. (You may tap a Vampire you control in addition to any other costs as you cast this spell.) -- Target opponent loses half his or her life, rounded up. If Blood Tribute was kicked, you gain life equal to the life lost this way. -auto=life:-halfdownopponentlifetotal opponent -auto=life:opponentlifetotal controller mana={4}{B}{B} other={4}{b}{b}{t(vampire|mybattlefield)} name(Pay Kicker) type=Sorcery @@ -23970,7 +23971,7 @@ type=Instant name=Crypt of Agadeem auto=tap(noevent) auto={T}:Add{B} -auto={2}{T}:foreach(creature[black]|mygraveyard) Add{B} +auto={2}{T}:name(foreach add black mana) foreach(creature[black]|mygraveyard) Add{B} text=Crypt of Agadeem enters the battlefield tapped. -- {T}: Add {B} to your mana pool. -- {2}, {T}: Add {B} to your mana pool for each black creature card in your graveyard. type=Land [/card] @@ -46940,8 +46941,8 @@ toughness=1 [/card] [card] name=Goblin Goon -auto=@each my attackers:if type(creature|opponentbattlefield)~morethan~type(creature|mybattlefield) then transforms((,cantattack)) ueot -auto=@each my blockers:if type(creature|opponentbattlefield)~morethan~type(creature|mybattlefield) then transforms((,cantblock)) ueot +auto=while(restriction{lessorequalcreatures}) cantattack +auto=while(restriction{lessorequalcreatures}) cantblock text=Goblin Goon can't attack unless you control more creatures than defending player. -- Goblin Goon can't block unless you control more creatures than attacking player. mana={3}{R} type=Creature @@ -60999,7 +61000,7 @@ toughness=2 [/card] [card] name=Keeper of the Flame -auto={R}{T}:if compare(lifetotal)~lessthan~compare(opponentlifetotal) then damage:2 opponent +auto={R}{T}:damage:2 opponent restriction{compare(lifetotal)~lessthan~compare(opponentlifetotal)} text={R}, {T}: Choose target opponent who had more life than you did as you activated this ability. Keeper of the Flame deals 2 damage to him or her. mana={R}{R} type=Creature @@ -61009,7 +61010,7 @@ toughness=2 [/card] [card] name=Keeper of the Light -auto={W}{T}:if compare(lifetotal)~lessthan~compare(opponentlifetotal) then life:3 controller +auto={W}{T}:life:3 controller restriction{compare(lifetotal)~lessthan~compare(opponentlifetotal)} text={W}, {T}: Choose target opponent who had more life than you did as you activated this ability. You gain 3 life. mana={W}{W} type=Creature @@ -67744,8 +67745,8 @@ subtype=Aura [card] name=Lurker abilities=shroud -auto=@combat(attacking) source(this):name(loses shroud) -shroud ueot -auto=@combat(blocking) source(this):name(loses shroud) -shroud ueot +auto=while(restriction{didblock}) transforms((,newability[-shroud])) ueot +auto=while(restriction{didattack}) transforms((,newability[-shroud])) ueot text=Lurker can't be the target of spells unless it attacked or blocked this turn. mana={2}{G} type=Creature @@ -73930,8 +73931,8 @@ toughness=3 [/card] [card] name=Mogg Toady -auto=@each my attackers:if type(creature|opponentbattlefield)~morethan~type(creature|mybattlefield) then transforms((,cantattack)) ueot -auto=@each my blockers:if type(creature|opponentbattlefield)~morethan~type(creature|mybattlefield) then transforms((,cantblock)) ueot +auto=while(restriction{lessorequalcreatures}) cantattack +auto=while(restriction{lessorequalcreatures}) cantblock text=Mogg Toady can't attack unless you control more creatures than defending player. -- Mogg Toady can't block unless you control more creatures than attacking player. mana={1}{R} type=Creature @@ -74460,8 +74461,8 @@ type=Sorcery [/card] [card] name=Monstrous Hound -auto=@each my attackers:if type(land|opponentbattlefield)~morethan~type(land|mybattlefield) then transforms((,cantattack)) ueot -auto=@each my blockers:if type(land|opponentbattlefield)~morethan~type(land|mybattlefield) then transforms((,cantblock)) ueot +auto=while(restriction{lessorequallands}) cantattack +auto=while(restriction{lessorequallands}) cantblock text=Monstrous Hound can't attack unless you control more lands than defending player. -- Monstrous Hound can't block unless you control more lands than attacking player. mana={3}{R} type=Creature @@ -89051,7 +89052,7 @@ type=Instant [/card] [card] name=Rackling -auto=@each opponent upkeep:damage:0 && if type(*|opponenthand)~equalto~2 then damage:1 opponent && if type(*|opponenthand)~equalto~1 then damage:2 opponent && if type(*|opponenthand)~equalto~0 then damage:3 opponent +auto=@each opponent upkeep:damage:3minustype:*:opponenthandminusend opponent text=At the beginning of each opponent's upkeep, Rackling deals X damage to that player, where X is 3 minus the number of cards in his or her hand. mana={4} type=Artifact Creature @@ -111831,8 +111832,8 @@ toughness=3 [/card] [card] name=Storm World -auto=@each opponent upkeep:damage:0 && if type(*|opponenthand)~equalto~3 then damage:1 opponent && if type(*|opponenthand)~equalto~2 then damage:2 opponent && if type(*|opponenthand)~equalto~1 then damage:3 opponent && if type(*|opponenthand)~equalto~0 then damage:4 opponent -auto=@each my upkeep:damage:0 && if type(*|myhand)~equalto~3 then damage:1 controller && if type(*|myhand)~equalto~2 then damage:2 controller && if type(*|myhand)~equalto~1 then damage:3 controller && if type(*|myhand)~equalto~0 then damage:4 controller +auto=@each opponent upkeep:damage:4minustype:*:opponenthandminusend opponent +auto=@each my upkeep:damage:damage:4minustype:*:opponenthandminusend opponent auto=@movedTo(other enchantment[world]|battlefield):sacrifice all(this) text=At the beginning of each player's upkeep, Storm World deals X damage to that player, where X is 4 minus the number of cards in his or her hand. mana={R} @@ -117417,7 +117418,7 @@ toughness=5 [card] name=The Rack auto=name(choose opponent) notatarget(opponent) deplete:0 -auto=@each targetedplayer upkeep:damage:0 && if type(*|targetedpersonshand)~equalto~2 then damage:1 targetedplayer && if type(*|targetedpersonshand)~equalto~1 then damage:2 targetedplayer && if type(*|targetedpersonshand)~equalto~0 then damage:3 targetedplayer +auto=@each targetedplayer upkeep:damage:3minustype:*:targetedpersonshandminusend targetedplayer text=As The Rack enters the battlefield, choose an opponent. -- At the beginning of the chosen player's upkeep, The Rack deals X damage to that player, where X is 3 minus the number of cards in his or her hand. mana={1} type=Artifact @@ -130601,7 +130602,7 @@ type=Sorcery [/card] [card] name=Wheel of Torture -auto=@each opponent upkeep:damage:0 && if type(*|opponenthand)~equalto~2 then damage:1 opponent && if type(*|opponenthand)~equalto~1 then damage:2 opponent && if type(*|opponenthand)~equalto~0 then damage:3 opponent +auto=@each opponent upkeep:damage:3minustype:*:opponenthandminusend opponent text=At the beginning of each opponent's upkeep, Wheel of Torture deals X damage to that player, where X is 3 minus the number of cards in his or her hand. type=Artifact mana={3} diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index f0a4446b3..76b289166 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -581,6 +581,22 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe return 0; } + check = restriction[i].find("lessorequalcreatures"); + if(check != string::npos) + { + bool condition = (card->controller()->opponent()->inPlay()->countByType("creature") >= card->controller()->inPlay()->countByType("creature")); + if(!condition) + return 0; + } + + check = restriction[i].find("lessorequallands"); + if(check != string::npos) + { + bool condition = (card->controller()->opponent()->inPlay()->countByType("land") >= card->controller()->inPlay()->countByType("land")); + if(!condition) + return 0; + } + check = restriction[i].find("outnumbered");//opponent controls atleast 4 or more creatures than you if(check != string::npos) { @@ -596,6 +612,13 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe return 0; } + check = restriction[i].find("didblock"); + if(check != string::npos) + { + if(!card->didblocked) + return 0; + } + check = restriction[i].find("didattack"); if(check != string::npos) { @@ -687,6 +710,21 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe { restriction.push_back("type(creature|mybattlefield)~lessthan~type(creature|opponentbattlefield)"); } + check = restriction[i].find("control less lands"); + if(check != string::npos) + { + restriction.push_back("type(land|mybattlefield)~lessthan~type(land|opponentbattlefield)"); + } + check = restriction[i].find("control more creatures"); + if(check != string::npos) + { + restriction.push_back("type(creature|mybattlefield)~morethan~type(creature|opponentbattlefield)"); + } + check = restriction[i].find("control more lands"); + if(check != string::npos) + { + restriction.push_back("type(land|mybattlefield)~morethan~type(land|opponentbattlefield)"); + } check = restriction[i].find("paid("); if(check != string::npos) From dc696a0f4581b8297faa65149e2c929e72a943dd Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Fri, 3 Feb 2017 10:30:14 +0800 Subject: [PATCH 2/5] fix random segmentation fault should fix the crash -> rain of filth in test suite --- projects/mtg/include/AllAbilities.h | 38 ++++++++++++++--------------- projects/mtg/src/GameObserver.cpp | 30 ++++++++++++----------- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 453d544ff..03ddae5a6 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -781,53 +781,53 @@ private: } else if (s == "olandg") { - intValue = countManaProducedby(Constants::MTG_COLOR_GREEN, target->controller()->opponent()); + intValue = countManaProducedby(Constants::MTG_COLOR_GREEN, target, target->controller()->opponent()); } else if (s == "olandu") { - intValue = countManaProducedby(Constants::MTG_COLOR_BLUE, target->controller()->opponent()); + intValue = countManaProducedby(Constants::MTG_COLOR_BLUE, target, target->controller()->opponent()); } else if (s == "olandr") { - intValue = countManaProducedby(Constants::MTG_COLOR_RED, target->controller()->opponent()); + intValue = countManaProducedby(Constants::MTG_COLOR_RED, target, target->controller()->opponent()); } else if (s == "olandb") { - intValue = countManaProducedby(Constants::MTG_COLOR_BLACK, target->controller()->opponent()); + intValue = countManaProducedby(Constants::MTG_COLOR_BLACK, target, target->controller()->opponent()); } else if (s == "olandw") { - intValue = countManaProducedby(Constants::MTG_COLOR_WHITE, target->controller()->opponent()); + intValue = countManaProducedby(Constants::MTG_COLOR_WHITE, target, target->controller()->opponent()); } else if (s == "olandc") { - intValue = countManaProducedby(Constants::MTG_COLOR_ARTIFACT, target->controller()->opponent()) + - countManaProducedby(Constants::MTG_COLOR_WASTE, target->controller()->opponent()); + intValue = countManaProducedby(Constants::MTG_COLOR_ARTIFACT, target, target->controller()->opponent()) + + countManaProducedby(Constants::MTG_COLOR_WASTE, target, target->controller()->opponent()); } else if (s == "plandg") { - intValue = countManaProducedby(Constants::MTG_COLOR_GREEN, target->controller()); + intValue = countManaProducedby(Constants::MTG_COLOR_GREEN, target, target->controller()); } else if (s == "plandu") { - intValue = countManaProducedby(Constants::MTG_COLOR_BLUE, target->controller()); + intValue = countManaProducedby(Constants::MTG_COLOR_BLUE, target, target->controller()); } else if (s == "plandr") { - intValue = countManaProducedby(Constants::MTG_COLOR_RED, target->controller()); + intValue = countManaProducedby(Constants::MTG_COLOR_RED, target, target->controller()); } else if (s == "plandb") { - intValue = countManaProducedby(Constants::MTG_COLOR_BLACK, target->controller()); + intValue = countManaProducedby(Constants::MTG_COLOR_BLACK, target, target->controller()); } else if (s == "plandw") { - intValue = countManaProducedby(Constants::MTG_COLOR_WHITE, target->controller()); + intValue = countManaProducedby(Constants::MTG_COLOR_WHITE, target, target->controller()); } else if (s == "plandc") { - intValue = countManaProducedby(Constants::MTG_COLOR_ARTIFACT, target->controller()) + - countManaProducedby(Constants::MTG_COLOR_WASTE, target->controller()); + intValue = countManaProducedby(Constants::MTG_COLOR_ARTIFACT, target, target->controller()) + + countManaProducedby(Constants::MTG_COLOR_WASTE, target, target->controller()); } else if (s == "cantargetmycre")// can target my creature { @@ -1122,7 +1122,7 @@ public: return count; } - /*int countManaProducedby(int color, MTGCardInstance * target, Player * player) + int countManaProducedby(int color, MTGCardInstance * target, Player * player) { int count = 0; for (size_t i = 0; i < target->getObserver()->mLayers->actionLayer()->manaObjects.size(); i++) @@ -1134,9 +1134,9 @@ public: count += 1; } return count; - }*/ + } - int countManaProducedby(int color, Player * player) + /*int countManaProducedby(int color, Player * player) { int count = 0; for (int i = 0; i < player->game->battlefield->nb_cards; i++) @@ -1155,7 +1155,7 @@ public: count += 1; } return count; - } + }*/ WParsedInt(int value = 0) { @@ -2066,7 +2066,7 @@ class AACopier: public ActivatedAbility { public: bool isactivated; - vector currentAbilities; + //vector currentAbilities; MTGAbility * andAbility; AACopier(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL); int resolve(); diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index fbc671f99..bd2428cd2 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -711,25 +711,27 @@ void GameObserver::gameStateBasedEffects() card->myPair = NULL; } ///set basic land mana objects canproduce - for (size_t gg = 0; gg < mLayers->actionLayer()->manaObjects.size(); gg++) + /*for (size_t gg = 0; gg < mLayers->actionLayer()->manaObjects.size(); gg++) { MTGAbility * aa = ((MTGAbility *) mLayers->actionLayer()->manaObjects[gg]); //AManaProducer * amp = dynamic_cast (aa); - - if (dynamic_cast (aa) && (dynamic_cast (aa))->source->isLand() && (dynamic_cast (aa))->source == card) + if(aa != NULL) { - if (card->hasType("forest") && ((AManaProducer*)aa)->output->hasColor(Constants::MTG_COLOR_GREEN)) - card->canproduceG = 1; - if (card->hasType("island") && ((AManaProducer*)aa)->output->hasColor(Constants::MTG_COLOR_BLUE)) - card->canproduceU = 1; - if (card->hasType("mountain") && ((AManaProducer*)aa)->output->hasColor(Constants::MTG_COLOR_RED)) - card->canproduceR = 1; - if (card->hasType("swamp") && ((AManaProducer*)aa)->output->hasColor(Constants::MTG_COLOR_BLACK)) - card->canproduceB = 1; - if (card->hasType("plains") && ((AManaProducer*)aa)->output->hasColor(Constants::MTG_COLOR_WHITE)) - card->canproduceW = 1; + if (dynamic_cast (aa) && (dynamic_cast (aa))->source->isLand() && (dynamic_cast (aa))->source == card) + { + if (card->hasType("forest") && ((AManaProducer*)aa)->output->hasColor(Constants::MTG_COLOR_GREEN)) + card->canproduceG = 1; + if (card->hasType("island") && ((AManaProducer*)aa)->output->hasColor(Constants::MTG_COLOR_BLUE)) + card->canproduceU = 1; + if (card->hasType("mountain") && ((AManaProducer*)aa)->output->hasColor(Constants::MTG_COLOR_RED)) + card->canproduceR = 1; + if (card->hasType("swamp") && ((AManaProducer*)aa)->output->hasColor(Constants::MTG_COLOR_BLACK)) + card->canproduceB = 1; + if (card->hasType("plains") && ((AManaProducer*)aa)->output->hasColor(Constants::MTG_COLOR_WHITE)) + card->canproduceW = 1; + } } - } + }*/ ///clear imprints if(isInPlay(card) && card->imprintedCards.size()) { From 942c95e736e2253f52e0557ff153f1d962793c8d Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Fri, 3 Feb 2017 10:31:10 +0800 Subject: [PATCH 3/5] revised copier copied abilities the clone should copy original abilities only --- projects/mtg/include/MTGCardInstance.h | 1 + projects/mtg/src/AllAbilities.cpp | 8 ++++---- projects/mtg/src/MTGCardInstance.cpp | 12 ++++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index 8c64487de..c4af0024c 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -48,6 +48,7 @@ public: vectorparentCards; vectorchildrenCards; vectorcardsAbilities; + vectorcardsAbilitiesFilter; int setAttacker(int value); int setDefenser(MTGCardInstance * c); diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 2de381334..635c0e8fa 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -1610,7 +1610,7 @@ int AACopier::resolve() if(source->isACopier) { source->GrantedAndAbility = andAbility; - AbilityFactory af(game); + //AbilityFactory af(game); for(unsigned int i = 0;i < source->cardsAbilities.size();i++) { MTGAbility * a = dynamic_cast(source->cardsAbilities[i]); @@ -1620,10 +1620,10 @@ int AACopier::resolve() source->cardsAbilities.clear(); source->magicText = _target->magicText; - af.getAbilities(¤tAbilities, NULL, source); - for (size_t i = 0; i < currentAbilities.size(); ++i) + //af.getAbilities(¤tAbilities, NULL, source); + for (size_t i = 0; i < source->cardsAbilitiesFilter.size(); ++i) { - MTGAbility * a = currentAbilities[i]; + MTGAbility * a = source->cardsAbilitiesFilter[i]; a->source = (MTGCardInstance *) source; if (a) { diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 1f0e7962d..1dd74579b 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -141,6 +141,17 @@ void MTGCardInstance::copy(MTGCardInstance * card) int castMethodBackUP = this->castMethod; mtgid = source->getId(); MTGCardInstance * oldStored = this->storedSourceCard; + //test copy filtered + cardsAbilitiesFilter.clear(); + for(unsigned int i = 0;i < card->cardsAbilities.size();i++) + { + MTGAbility * a = dynamic_cast(card->cardsAbilities[i]); + if(a && a->source == card) + { + cardsAbilitiesFilter.push_back(a); + } + } + // /*if(!isPhased) { Spell * spell = NEW Spell(observer, this); @@ -297,6 +308,7 @@ void MTGCardInstance::initMTGCI() exileEffects = false; currentZone = NULL; cardsAbilities = vector(); + cardsAbilitiesFilter = vector(); data = this; //an MTGCardInstance point to itself for data, allows to update it without killing the underlying database item if (observer && basicAbilities[(int)Constants::CHANGELING]) From 9104afdef7f78c3fb489ada975412fc45e84e3bb Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Fri, 3 Feb 2017 10:39:45 +0800 Subject: [PATCH 4/5] Cleanup --- projects/mtg/include/AllAbilities.h | 22 ---------------------- projects/mtg/src/AllAbilities.cpp | 3 +-- projects/mtg/src/GameObserver.cpp | 22 ---------------------- projects/mtg/src/MTGCardInstance.cpp | 9 --------- 4 files changed, 1 insertion(+), 55 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 03ddae5a6..bda614e49 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -1136,27 +1136,6 @@ public: return count; } - /*int countManaProducedby(int color, Player * player) - { - int count = 0; - for (int i = 0; i < player->game->battlefield->nb_cards; i++) - { - if(((MTGCardInstance *)player->game->battlefield->cards[i])->isLand() && ((MTGCardInstance *)player->game->battlefield->cards[i])->canproduceC && (color == Constants::MTG_COLOR_ARTIFACT || color == Constants::MTG_COLOR_WASTE)) - count += 1; - if(((MTGCardInstance *)player->game->battlefield->cards[i])->isLand() && ((MTGCardInstance *)player->game->battlefield->cards[i])->canproduceG && color == Constants::MTG_COLOR_GREEN) - count += 1; - if(((MTGCardInstance *)player->game->battlefield->cards[i])->isLand() && ((MTGCardInstance *)player->game->battlefield->cards[i])->canproduceU && color == Constants::MTG_COLOR_BLUE) - count += 1; - if(((MTGCardInstance *)player->game->battlefield->cards[i])->isLand() && ((MTGCardInstance *)player->game->battlefield->cards[i])->canproduceR && color == Constants::MTG_COLOR_RED) - count += 1; - if(((MTGCardInstance *)player->game->battlefield->cards[i])->isLand() && ((MTGCardInstance *)player->game->battlefield->cards[i])->canproduceB && color == Constants::MTG_COLOR_BLACK) - count += 1; - if(((MTGCardInstance *)player->game->battlefield->cards[i])->isLand() && ((MTGCardInstance *)player->game->battlefield->cards[i])->canproduceW && color == Constants::MTG_COLOR_WHITE) - count += 1; - } - return count; - }*/ - WParsedInt(int value = 0) { intValue = value; @@ -2066,7 +2045,6 @@ class AACopier: public ActivatedAbility { public: bool isactivated; - //vector currentAbilities; MTGAbility * andAbility; AACopier(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL); int resolve(); diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 635c0e8fa..0b4811d00 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -1610,7 +1610,7 @@ int AACopier::resolve() if(source->isACopier) { source->GrantedAndAbility = andAbility; - //AbilityFactory af(game); + for(unsigned int i = 0;i < source->cardsAbilities.size();i++) { MTGAbility * a = dynamic_cast(source->cardsAbilities[i]); @@ -1620,7 +1620,6 @@ int AACopier::resolve() source->cardsAbilities.clear(); source->magicText = _target->magicText; - //af.getAbilities(¤tAbilities, NULL, source); for (size_t i = 0; i < source->cardsAbilitiesFilter.size(); ++i) { MTGAbility * a = source->cardsAbilitiesFilter[i]; diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index bd2428cd2..05f8f7344 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -710,28 +710,6 @@ void GameObserver::gameStateBasedEffects() card->myPair->myPair = NULL; card->myPair = NULL; } - ///set basic land mana objects canproduce - /*for (size_t gg = 0; gg < mLayers->actionLayer()->manaObjects.size(); gg++) - { - MTGAbility * aa = ((MTGAbility *) mLayers->actionLayer()->manaObjects[gg]); - //AManaProducer * amp = dynamic_cast (aa); - if(aa != NULL) - { - if (dynamic_cast (aa) && (dynamic_cast (aa))->source->isLand() && (dynamic_cast (aa))->source == card) - { - if (card->hasType("forest") && ((AManaProducer*)aa)->output->hasColor(Constants::MTG_COLOR_GREEN)) - card->canproduceG = 1; - if (card->hasType("island") && ((AManaProducer*)aa)->output->hasColor(Constants::MTG_COLOR_BLUE)) - card->canproduceU = 1; - if (card->hasType("mountain") && ((AManaProducer*)aa)->output->hasColor(Constants::MTG_COLOR_RED)) - card->canproduceR = 1; - if (card->hasType("swamp") && ((AManaProducer*)aa)->output->hasColor(Constants::MTG_COLOR_BLACK)) - card->canproduceB = 1; - if (card->hasType("plains") && ((AManaProducer*)aa)->output->hasColor(Constants::MTG_COLOR_WHITE)) - card->canproduceW = 1; - } - } - }*/ ///clear imprints if(isInPlay(card) && card->imprintedCards.size()) { diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 1dd74579b..3357e42a8 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -151,15 +151,6 @@ void MTGCardInstance::copy(MTGCardInstance * card) cardsAbilitiesFilter.push_back(a); } } - // - /*if(!isPhased) - { - Spell * spell = NEW Spell(observer, this); - observer = card->observer; - AbilityFactory af(observer); - af.addAbilities(observer->mLayers->actionLayer()->getMaxId(), spell); - delete spell; - }*/ if(observer->players[1]->playMode == Player::MODE_TEST_SUITE) mtgid = backupid; // there must be a way to get the token id... From 3fa52e7ac55f3a2981722389af6f5a56aa99e206 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Fri, 3 Feb 2017 14:26:26 +0800 Subject: [PATCH 5/5] corrections --- projects/mtg/include/AllAbilities.h | 1 + projects/mtg/src/AllAbilities.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index bda614e49..bd11ac26c 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -2045,6 +2045,7 @@ class AACopier: public ActivatedAbility { public: bool isactivated; + vector currentAbilities; MTGAbility * andAbility; AACopier(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL); int resolve(); diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 0b4811d00..2de381334 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -1610,7 +1610,7 @@ int AACopier::resolve() if(source->isACopier) { source->GrantedAndAbility = andAbility; - + AbilityFactory af(game); for(unsigned int i = 0;i < source->cardsAbilities.size();i++) { MTGAbility * a = dynamic_cast(source->cardsAbilities[i]); @@ -1620,9 +1620,10 @@ int AACopier::resolve() source->cardsAbilities.clear(); source->magicText = _target->magicText; - for (size_t i = 0; i < source->cardsAbilitiesFilter.size(); ++i) + af.getAbilities(¤tAbilities, NULL, source); + for (size_t i = 0; i < currentAbilities.size(); ++i) { - MTGAbility * a = source->cardsAbilitiesFilter[i]; + MTGAbility * a = currentAbilities[i]; a->source = (MTGCardInstance *) source; if (a) {