From c7535e38dc1d5c4ed9cc066be2a7c4e3a4c35b10 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Sun, 18 Oct 2015 22:38:41 +0800 Subject: [PATCH 1/7] TrcardDrawn, TrDamaged, TrLifeGained Added trigger restriction for "@trigger(player) restriction{opponenttrigger/controllertrigger}" Restriction for: @drawn @damaged(combat and noncombat) @lifed/lifeloss Why? When using @drawn trigger like Underworld Dreams auto=@drawn(opponent):life:-1 opponent If you take control of Underworld Dreams from an opponent, the targetchooser for "opponent" is not updated and you are still the opponent of Underworld Dreams even you take control of it(It is right if you are the chosen opponent from cards like Black Vise, The Rack, etc... The chosen opponent never changes. But cards that don't define a chosen player an "opponent" like Underworld Dreams when an exchanged control happens, the opponent of the card is the opponent of the one who controls the card). :P The new correct code for Underworld Dreams: auto=@drawn(player) restriction{opponenttrigger}:life:-1 opponent --- projects/mtg/include/AllAbilities.h | 21 ++++++++++++++++++++- projects/mtg/include/MTGCardInstance.h | 2 ++ projects/mtg/src/GameObserver.cpp | 24 +++++++++++++++++------- projects/mtg/src/MTGAbility.cpp | 14 ++++++++++++++ projects/mtg/src/MTGCardInstance.cpp | 2 ++ 5 files changed, 55 insertions(+), 8 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 8465cb5d3..d4d1a6059 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -1207,7 +1207,10 @@ public: WEventcardDraw * e = dynamic_cast (event); if (!e) return 0; if (!tc->canTarget(e->player)) return 0; - + if(source->controller() == e->player) + source->controllerTrigger = 1; + else + source->opponentTrigger = 1; return 1; } @@ -1315,6 +1318,18 @@ public: if (type == 2 && e->damage->typeOfDamage == Damage::DAMAGE_COMBAT) return 0; e->damage->target->thatmuch = e->damage->damage; e->damage->source->thatmuch = e->damage->damage; + if (e->damage->target->type_as_damageable == Damageable::DAMAGEABLE_PLAYER) + { + Player * p = (Player *) e->damage->target; + if(p && p == source->controller()->opponent()) + { + source->opponentTrigger = 1; + } + else + { + source->controllerTrigger = 1; + } + } this->source->thatmuch = e->damage->damage; triggeredTurn = game->turn; @@ -1354,6 +1369,10 @@ public: if (type == 1 && (e->amount > 0)) return 0; if (type == 0 && (e->amount < 0)) return 0; e->player->thatmuch = abs(e->amount); + if(source->controller() == e->player) + source->controllerTrigger = 1; + else + source->opponentTrigger = 1; this->source->thatmuch = abs(e->amount); return 1; diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index 5146b4940..d14270c99 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -253,6 +253,8 @@ public: int cardistargetted; bool isTargetter(); int cardistargetter; + int opponentTrigger; + int controllerTrigger; void eventattacked(); void eventattackedAlone(); diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 72fcb8aca..e018016c1 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -593,15 +593,25 @@ void GameObserver::gameStateBasedEffects() ///////////////////////////////////// for (int d = 0; d < 2; d++) { - MTGGameZone * zone = players[d]->game->inPlay; - if (mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0) - { - for (int c = zone->nb_cards - 1; c >= 0; c--) + MTGGameZone * dzones[] = { players[d]->game->inPlay, players[d]->game->graveyard, players[d]->game->hand, players[d]->game->library }; + for (int k = 0; k < 4; k++) + { + MTGGameZone * zone = dzones[k]; + if (mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0) { - zone->cards[c]->cardistargetted = 0; - zone->cards[c]->cardistargetter = 0; + for (int c = zone->nb_cards - 1; c >= 0; c--) + { + zone->cards[c]->cardistargetted = 0; + zone->cards[c]->cardistargetter = 0; + } } - } + //clear trigger + for (int b = zone->nb_cards - 1; b >= 0; b--) + { + zone->cards[b]->controllerTrigger = 0; + zone->cards[b]->opponentTrigger = 0; + } + }//check for losers if its gameover call the statebased action players[d]->DeadLifeState(); } //////////////////////////////////// diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 34f142492..dcb775d84 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -411,6 +411,20 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe } } + check = restriction[i].find("opponenttrigger"); + if(check != string::npos) + { + if(!card->opponentTrigger) + return 0; + } + + check = restriction[i].find("controllertrigger"); + if(check != string::npos) + { + if(!card->controllerTrigger) + return 0; + } + check = restriction[i].find("discarded"); if(check != string::npos) { diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 140c4f5cf..5b12d88a1 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -65,6 +65,8 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to LKItoughness = toughness; cardistargetted = 0; cardistargetter = 0; + opponentTrigger = 0; + controllerTrigger = 0; } MTGCardInstance * MTGCardInstance::createSnapShot() From f90775153c1203bb85fa129a3b7245c424afceaf Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Mon, 19 Oct 2015 10:19:14 +0800 Subject: [PATCH 2/7] Revert "TrcardDrawn, TrDamaged, TrLifeGained" This reverts commit c7535e38dc1d5c4ed9cc066be2a7c4e3a4c35b10. --- projects/mtg/include/AllAbilities.h | 21 +-------------------- projects/mtg/include/MTGCardInstance.h | 2 -- projects/mtg/src/GameObserver.cpp | 24 +++++++----------------- projects/mtg/src/MTGAbility.cpp | 14 -------------- projects/mtg/src/MTGCardInstance.cpp | 2 -- 5 files changed, 8 insertions(+), 55 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index d4d1a6059..8465cb5d3 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -1207,10 +1207,7 @@ public: WEventcardDraw * e = dynamic_cast (event); if (!e) return 0; if (!tc->canTarget(e->player)) return 0; - if(source->controller() == e->player) - source->controllerTrigger = 1; - else - source->opponentTrigger = 1; + return 1; } @@ -1318,18 +1315,6 @@ public: if (type == 2 && e->damage->typeOfDamage == Damage::DAMAGE_COMBAT) return 0; e->damage->target->thatmuch = e->damage->damage; e->damage->source->thatmuch = e->damage->damage; - if (e->damage->target->type_as_damageable == Damageable::DAMAGEABLE_PLAYER) - { - Player * p = (Player *) e->damage->target; - if(p && p == source->controller()->opponent()) - { - source->opponentTrigger = 1; - } - else - { - source->controllerTrigger = 1; - } - } this->source->thatmuch = e->damage->damage; triggeredTurn = game->turn; @@ -1369,10 +1354,6 @@ public: if (type == 1 && (e->amount > 0)) return 0; if (type == 0 && (e->amount < 0)) return 0; e->player->thatmuch = abs(e->amount); - if(source->controller() == e->player) - source->controllerTrigger = 1; - else - source->opponentTrigger = 1; this->source->thatmuch = abs(e->amount); return 1; diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index d14270c99..5146b4940 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -253,8 +253,6 @@ public: int cardistargetted; bool isTargetter(); int cardistargetter; - int opponentTrigger; - int controllerTrigger; void eventattacked(); void eventattackedAlone(); diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index e018016c1..72fcb8aca 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -593,25 +593,15 @@ void GameObserver::gameStateBasedEffects() ///////////////////////////////////// for (int d = 0; d < 2; d++) { - MTGGameZone * dzones[] = { players[d]->game->inPlay, players[d]->game->graveyard, players[d]->game->hand, players[d]->game->library }; - for (int k = 0; k < 4; k++) - { - MTGGameZone * zone = dzones[k]; - if (mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0) + MTGGameZone * zone = players[d]->game->inPlay; + if (mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0) + { + for (int c = zone->nb_cards - 1; c >= 0; c--) { - for (int c = zone->nb_cards - 1; c >= 0; c--) - { - zone->cards[c]->cardistargetted = 0; - zone->cards[c]->cardistargetter = 0; - } + zone->cards[c]->cardistargetted = 0; + zone->cards[c]->cardistargetter = 0; } - //clear trigger - for (int b = zone->nb_cards - 1; b >= 0; b--) - { - zone->cards[b]->controllerTrigger = 0; - zone->cards[b]->opponentTrigger = 0; - } - }//check for losers if its gameover call the statebased action + } players[d]->DeadLifeState(); } //////////////////////////////////// diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index dcb775d84..34f142492 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -411,20 +411,6 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe } } - check = restriction[i].find("opponenttrigger"); - if(check != string::npos) - { - if(!card->opponentTrigger) - return 0; - } - - check = restriction[i].find("controllertrigger"); - if(check != string::npos) - { - if(!card->controllerTrigger) - return 0; - } - check = restriction[i].find("discarded"); if(check != string::npos) { diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 5b12d88a1..140c4f5cf 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -65,8 +65,6 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to LKItoughness = toughness; cardistargetted = 0; cardistargetter = 0; - opponentTrigger = 0; - controllerTrigger = 0; } MTGCardInstance * MTGCardInstance::createSnapShot() From b060c4205cb1f5fcd8ce82992a4daf4989296e6c Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Mon, 19 Oct 2015 11:10:49 +0800 Subject: [PATCH 3/7] targetter, targetted reset --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 2 +- projects/mtg/src/GameObserver.cpp | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index a7e28c751..77548df4c 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -69828,7 +69828,7 @@ toughness=1 name=Orgg abilities=trample auto=cantbeblockerof(creature[white;power>=3]) -auto=aslongas(creature[power>=3;-tapped]|opponentbattlefield]) cantattack +auto=aslongas(creature[power>=3;-tapped]|opponentbattlefield) cantattack text=Trample -- Orgg can't attack if defending player controls an untapped creature with power 3 or greater. -- Orgg can't block creatures with power 3 or greater. mana={3}{R}{R} type=Creature diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 72fcb8aca..22a90802a 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -593,15 +593,19 @@ void GameObserver::gameStateBasedEffects() ///////////////////////////////////// for (int d = 0; d < 2; d++) { - MTGGameZone * zone = players[d]->game->inPlay; - if (mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0) - { - for (int c = zone->nb_cards - 1; c >= 0; c--) + MTGGameZone * dzones[] = { players[d]->game->inPlay, players[d]->game->graveyard, players[d]->game->hand, players[d]->game->library }; + for (int k = 0; k < 4; k++) + { + MTGGameZone * zone = dzones[k]; + if (mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0) { - zone->cards[c]->cardistargetted = 0; - zone->cards[c]->cardistargetter = 0; + for (int c = zone->nb_cards - 1; c >= 0; c--) + { + zone->cards[c]->cardistargetted = 0; + zone->cards[c]->cardistargetter = 0; + } } - } + }//check for losers if its GAMEOVER clear the stack to allow gamestateeffects to continue players[d]->DeadLifeState(); } //////////////////////////////////// From 0d8b2f4a01b7e90cc65cc9fb4a1922661d15359d Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Mon, 19 Oct 2015 19:43:07 +0800 Subject: [PATCH 4/7] persist/undying fix persist/undying wont trigger when there is a replacement effect for cards that goes to graveyard like leyline of the void. support for anafenza the foremost. --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 2 +- projects/mtg/include/MTGDefinitions.h | 4 +++- projects/mtg/src/MTGDefinitions.cpp | 4 +++- projects/mtg/src/MTGGameZones.cpp | 2 ++ projects/mtg/src/MTGRules.cpp | 2 ++ 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 77548df4c..442522f77 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -2744,8 +2744,8 @@ toughness=2 [/card] [card] name=Anafenza, the Foremost +abilities=oppgcreatureexiler auto=@combat(attacking) source(this):counter(1/1,1) target(other creature[tapped]|mybattlefield) -auto=@movedTo(creature|opponentGraveyard):all(trigger[to]) moveTo(exile) text=When Anafenza, the Foremost attacks, put a +1/+1 counter on another target tapped creature you control. -- If a creature card would be put into an opponent's graveyard from anywhere, exile it instead. mana={W}{B}{G} type=Legendary Creature diff --git a/projects/mtg/include/MTGDefinitions.h b/projects/mtg/include/MTGDefinitions.h index 385dcc69b..6a0d398fe 100644 --- a/projects/mtg/include/MTGDefinitions.h +++ b/projects/mtg/include/MTGDefinitions.h @@ -232,7 +232,9 @@ class Constants AURAWARD = 114, MADNESS = 115, PROTECTIONFROMCOLOREDSPELLS = 116, - NB_BASIC_ABILITIES = 117, + MYGCREATUREEXILER = 117, + OPPGCREATUREEXILER = 118, + NB_BASIC_ABILITIES = 119, RARITY_S = 'S', //Special Rarity diff --git a/projects/mtg/src/MTGDefinitions.cpp b/projects/mtg/src/MTGDefinitions.cpp index 51ffc01d2..0dd76ef59 100644 --- a/projects/mtg/src/MTGDefinitions.cpp +++ b/projects/mtg/src/MTGDefinitions.cpp @@ -145,7 +145,9 @@ const char* Constants::MTGBasicAbilities[] = { "nolifegainopponent", "auraward", "madness", - "protectionfromcoloredspells" + "protectionfromcoloredspells", + "mygcreatureexiler", + "oppgcreatureexiler" }; map Constants::MTGBasicAbilitiesMap; diff --git a/projects/mtg/src/MTGGameZones.cpp b/projects/mtg/src/MTGGameZones.cpp index 2f0b7027c..4cea41c66 100644 --- a/projects/mtg/src/MTGGameZones.cpp +++ b/projects/mtg/src/MTGGameZones.cpp @@ -349,6 +349,8 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone for(int i = 0; i < 2; ++i) { if ((to == g->players[i]->game->graveyard) && ( + (g->players[i]->game->battlefield->hasAbility(Constants::MYGCREATUREEXILER) && card->isCreature()) || + (g->players[i]->opponent()->game->battlefield->hasAbility(Constants::OPPGCREATUREEXILER) && card->isCreature())|| g->players[i]->game->battlefield->hasAbility(Constants::MYGRAVEEXILER) || g->players[i]->opponent()->game->battlefield->hasAbility(Constants::OPPGRAVEEXILER))) { diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index d9628cf8b..362963ad0 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -2276,6 +2276,8 @@ int MTGPersistRule::receiveEvent(WEvent * event) if (e->from == p->game->inPlay) ok = 1; } + if ((card->owner->game->battlefield->hasAbility(Constants::MYGRAVEEXILER)||card->owner->opponent()->game->battlefield->hasAbility(Constants::OPPGRAVEEXILER)) || ((card->owner->game->battlefield->hasAbility(Constants::MYGCREATUREEXILER)||card->owner->opponent()->game->battlefield->hasAbility(Constants::OPPGCREATUREEXILER) && card->isCreature()))) + ok = 0; if (!ok) return 0; From 3bcb2985f9cffba7fad20ed3a291c9e5689fd5b2 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Mon, 19 Oct 2015 20:15:51 +0800 Subject: [PATCH 5/7] try to fix compile error on psp --- projects/mtg/src/MTGRules.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 362963ad0..210c9bcbc 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -2276,7 +2276,7 @@ int MTGPersistRule::receiveEvent(WEvent * event) if (e->from == p->game->inPlay) ok = 1; } - if ((card->owner->game->battlefield->hasAbility(Constants::MYGRAVEEXILER)||card->owner->opponent()->game->battlefield->hasAbility(Constants::OPPGRAVEEXILER)) || ((card->owner->game->battlefield->hasAbility(Constants::MYGCREATUREEXILER)||card->owner->opponent()->game->battlefield->hasAbility(Constants::OPPGCREATUREEXILER) && card->isCreature()))) + if ((card->owner->game->battlefield->hasAbility(Constants::MYGRAVEEXILER)||card->owner->opponent()->game->battlefield->hasAbility(Constants::OPPGRAVEEXILER)) || (card->owner->game->battlefield->hasAbility(Constants::MYGCREATUREEXILER)||card->owner->opponent()->game->battlefield->hasAbility(Constants::OPPGCREATUREEXILER) && (card->isCreature()))) ok = 0; if (!ok) return 0; From 9f8d2b2d46b2d0d6b985d916f291b678e15b6d98 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Mon, 19 Oct 2015 21:48:59 +0800 Subject: [PATCH 6/7] take 2 --- projects/mtg/src/MTGRules.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 210c9bcbc..9a9abbd00 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -2276,7 +2276,9 @@ int MTGPersistRule::receiveEvent(WEvent * event) if (e->from == p->game->inPlay) ok = 1; } - if ((card->owner->game->battlefield->hasAbility(Constants::MYGRAVEEXILER)||card->owner->opponent()->game->battlefield->hasAbility(Constants::OPPGRAVEEXILER)) || (card->owner->game->battlefield->hasAbility(Constants::MYGCREATUREEXILER)||card->owner->opponent()->game->battlefield->hasAbility(Constants::OPPGCREATUREEXILER) && (card->isCreature()))) + if (card->owner->game->battlefield->hasAbility(Constants::MYGRAVEEXILER)||card->owner->opponent()->game->battlefield->hasAbility(Constants::OPPGRAVEEXILER)) + ok = 0; + if ((card->owner->game->battlefield->hasAbility(Constants::MYGCREATUREEXILER)||card->owner->opponent()->game->battlefield->hasAbility(Constants::OPPGCREATUREEXILER))&&(card->isCreature())) ok = 0; if (!ok) return 0; From 7810c65862ca5f5a20fafb3ac3b83a637dff3c22 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Tue, 20 Oct 2015 11:09:57 +0800 Subject: [PATCH 7/7] added Raid support thisturn(creature[attacking]|mybattlefield)~morethan~0 only triggers once... use raid keyword... if raid then blah... --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 18 +++++++++--------- projects/mtg/include/Player.h | 1 + projects/mtg/src/GameObserver.cpp | 2 ++ projects/mtg/src/MTGAbility.cpp | 7 +++++++ projects/mtg/src/MTGRules.cpp | 1 + projects/mtg/src/Player.cpp | 1 + 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 442522f77..fd906ded1 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -8586,7 +8586,7 @@ toughness=3 [/card] [card] name=Bellowing Saddlebrute -auto=ifnot thisturn(creature[attacking]|mybattlefield)~morethan~0 then life:-4 controller +auto=ifnot raid then life:-4 controller text=Raid — When Bellowing Saddlebrute enters the battlefield, you lose 4 life unless you attacked with a creature this turn. mana={3}{B} type=Creature @@ -10685,7 +10685,7 @@ toughness=3 [card] name=Bloodsoaked Champion abilities=cantblock -autograveyard={1}{B}:moveTo(mybattlefield) restriction{thisturn(creature[attacking]|mybattlefield)~morethan~0} +autograveyard={1}{B}:moveTo(mybattlefield) restriction{raid} text=Bloodsoaked Champion can't block. -- Raid — {1}{B}: Return Bloodsoaked Champion from your graveyard to the battlefield. Activate this ability only if you attacked with a creature this turn. mana={B} type=Creature @@ -59747,7 +59747,7 @@ toughness=1 [/card] [card] name=Mardu Heart-Piercer -auto=if thisturn(creature[attacking]|mybattlefield)~morethan~0 then damage:2 target(creature,player) +auto=if raid then damage:2 target(creature,player) text=Raid -- When Mardu Heart-Piercer enters the battlefield, if you attacked with a creature this turn, Mardu Heart-Piercer deals 2 damage to target creature or player. mana={3}{R} type=Creature @@ -59757,7 +59757,7 @@ toughness=3 [/card] [card] name=Mardu Hordechief -auto=if thisturn(creature[attacking]|mybattlefield)~morethan~0 then token(Warrior,Creature Warrior,1/1,white) +auto=if raid then token(Warrior,Creature Warrior,1/1,white) text=Raid - When Mardu Hordechief enters the battlefield, if you attacked with a creature this turn, put a 1/1 white Warrior creature token onto the battlefield. mana={2}{W} type=Creature @@ -59811,7 +59811,7 @@ toughness=1 [card] name=Mardu Skullhunter auto=tap -auto=if thisturn(creature[attacking]|mybattlefield)~morethan~0 then target(opponent) ability$!name(discard) target(*|myhand) reject!$ targetedplayer +auto=if raid then target(opponent) ability$!name(discard) target(*|myhand) reject!$ targetedplayer text=Mardu Skullhunter enters the battlefield tapped. -- Raid - When Mardu Skullhunter enters the battlefield, if you attacked with a creature this turn, target opponent discards a card. mana={1}{B} type=Creature @@ -59833,7 +59833,7 @@ toughness=2 [/card] [card] name=Mardu Warshrieker -auto=if thisturn(creature[attacking]|mybattlefield)~morethan~0 then Add{R}{W}{B} +auto=if raid then Add{R}{W}{B} text=Raid - When Mardu Warshrieker enters the battlefield, if you attacked with a creature this turn, add {R}{W}{B} to your mana pool. mana={3}{R} type=Creature @@ -102844,7 +102844,7 @@ type=Sorcery [/card] [card] name=Timely Hordemate -auto=if thisturn(creature[attacking]|mybattlefield)~morethan~0 then moveTo(mybattlefield) target(creature[manacost<=2]|mygraveyard) +auto=if raid then moveTo(mybattlefield) target(creature[manacost<=2]|mygraveyard) text=Raid - When Timely Hordemate enters the battlefield, if you attacked with a creature this turn, return target creature card with converted mana cost 2 or less from your graveyard to the battlefield. mana={3}{W} type=Creature @@ -111460,7 +111460,7 @@ type=Instant [/card] [card] name=War-Name Aspirant -auto=if thisturn(creature[attacking]|mybattlefield)~morethan~0 then counter(1/1,1) +auto=if raid then counter(1/1,1) auto=cantbeblockedby(creature[power<=1]) text=Raid - War-Name Aspirant enters the battlefield with a +1/+1 counter on it if you attacked with a creature this turn. -- War-Name Aspirant can't be blocked by creatures with power 1 or less. mana={1}{R} @@ -113628,7 +113628,7 @@ toughness=1 [card] name=Wingmate Roc abilities=flying -auto=if thisturn(creature[attacking]|mybattlefield)~morethan~0 then token(Bird,Creature Bird,3/4,white,flying) +auto=if raid then token(Bird,Creature Bird,3/4,white,flying) auto=@combat(attacking) source(this):life:type:creature[attacking]:battlefield controller text=Flying. -- Raid - When Wingmate Roc enters the battlefield, if you attacked with a creature this turn, put a 3/4 white Bird creature token with flying onto the battlefield. -- Whenever Wingmate Roc attacks, you gain 1 life for each attacking creature. mana={3}{W}{W} diff --git a/projects/mtg/include/Player.h b/projects/mtg/include/Player.h index ae3e46007..eac30a20e 100644 --- a/projects/mtg/include/Player.h +++ b/projects/mtg/include/Player.h @@ -44,6 +44,7 @@ public: int drawCounter; int epic; int initLife; + int raidcount; vector prowledTypes; vectorcurses; Player(GameObserver *observer, string deckFile, string deckFileSmall, MTGDeck * deck = NULL); diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 22a90802a..4a0d6300b 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -204,6 +204,8 @@ void GameObserver::nextGamePhase() cleanupPhase(); currentPlayer->damageCount = 0; currentPlayer->drawCounter = 0; + currentPlayer->raidcount = 0; + currentPlayer->opponent()->raidcount = 0; currentPlayer->prowledTypes.clear(); currentPlayer->opponent()->damageCount = 0; //added to clear odcount currentPlayer->preventable = 0; diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 34f142492..cbb1afe01 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -418,6 +418,13 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe return 0; } + check = restriction[i].find("raid"); + if(check != string::npos) + { + if(card->controller()->raidcount < 1) + return 0; + } + check = restriction[i].find("ownerscontrol"); if(check != string::npos) { diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 9a9abbd00..3cb7ede58 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -1398,6 +1398,7 @@ int MTGCombatTriggersRule::receiveEvent(WEvent *e) if (card && card->isAttacker()) { card->eventattacked(); + card->controller()->raidcount += 1; } } } diff --git a/projects/mtg/src/Player.cpp b/projects/mtg/src/Player.cpp index 1efcc0b89..cd1a2c77a 100644 --- a/projects/mtg/src/Player.cpp +++ b/projects/mtg/src/Player.cpp @@ -34,6 +34,7 @@ Player::Player(GameObserver *observer, string file, string fileSmall, MTGDeck * extraTurn = 0; drawCounter = 0; epic = 0; + raidcount = 0; prowledTypes.clear(); doesntEmpty = NEW ManaCost(); poolDoesntEmpty = NEW ManaCost();