diff --git a/projects/mtg/include/MTGDefinitions.h b/projects/mtg/include/MTGDefinitions.h index 59a6e8f3a..1dda3d4d7 100644 --- a/projects/mtg/include/MTGDefinitions.h +++ b/projects/mtg/include/MTGDefinitions.h @@ -219,8 +219,8 @@ class Constants ONLYMANA = 98, POISONDAMAGER = 99, soulbond = 100, - - NB_BASIC_ABILITIES = 101, + LURE = 101, + NB_BASIC_ABILITIES = 102, RARITY_S = 'S', //Special Rarity diff --git a/projects/mtg/include/MTGGameZones.h b/projects/mtg/include/MTGGameZones.h index e4d69fb09..0c6158fda 100644 --- a/projects/mtg/include/MTGGameZones.h +++ b/projects/mtg/include/MTGGameZones.h @@ -164,6 +164,7 @@ class MTGInPlay: public MTGGameZone { public: void untapAll(); MTGCardInstance * getNextAttacker(MTGCardInstance * previous); + MTGCardInstance * getNextLurer(MTGCardInstance * previous); virtual ostream& toString(ostream&) const; const char * getName(){return "battlefield";} }; diff --git a/projects/mtg/src/MTGDefinitions.cpp b/projects/mtg/src/MTGDefinitions.cpp index b4b2cd10b..2d03ec25d 100644 --- a/projects/mtg/src/MTGDefinitions.cpp +++ b/projects/mtg/src/MTGDefinitions.cpp @@ -129,7 +129,8 @@ const char* Constants::MTGBasicAbilities[] = { "nomanaability", "onlymanaability", "poisondamager",//deals damage to players as poison counters. - "soulbond" + "soulbond", + "lure" }; map Constants::MTGBasicAbilitiesMap; diff --git a/projects/mtg/src/MTGGameZones.cpp b/projects/mtg/src/MTGGameZones.cpp index 1224484f5..d0db2d3e1 100644 --- a/projects/mtg/src/MTGGameZones.cpp +++ b/projects/mtg/src/MTGGameZones.cpp @@ -761,6 +761,28 @@ MTGCardInstance * MTGInPlay::getNextAttacker(MTGCardInstance * previous) return NULL; } +MTGCardInstance * MTGInPlay::getNextLurer(MTGCardInstance * previous) +{ + int foundprevious = 0; + if (previous == NULL) + { + foundprevious = 1; + } + for (int i = 0; i < nb_cards; i++) + { + MTGCardInstance * current = cards[i]; + if (current == previous) + { + foundprevious = 1; + } + else if (foundprevious && current->isAttacker() && current->has(Constants::LURE)) + { + return current; + } + } + return NULL; +} + void MTGInPlay::untapAll() { int i; diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 37441f6d9..bfc326227 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -1547,17 +1547,33 @@ int MTGBlockRule::reactToClick(MTGCardInstance * card) card->toggleDefenser(NULL); } else + { + bool lured = false; + int lureFound = 0; + MTGCardInstance * lurers = NULL; + while(!lureFound) + { + lurers = game->currentPlayer->game->inPlay->getNextLurer(lurers); + lureFound = (lurers == NULL || lurers->attacker); + if(lurers) + lured = true; + } while (!result) { currentOpponent = game->currentPlayer->game->inPlay->getNextAttacker(currentOpponent); - canDefend = card->toggleDefenser(currentOpponent); + + if(lured && currentOpponent && !currentOpponent->has(Constants::LURE)) + currentOpponent = game->currentPlayer->game->inPlay->getNextAttacker(currentOpponent); + canDefend = card->toggleDefenser(currentOpponent); DebugTrace("Defenser Toggle: " << card->getName() << endl << "- canDefend: " << (canDefend == 0) << endl << "- currentOpponent: " << currentOpponent); - result = (canDefend || currentOpponent == NULL); + result = (currentOpponent == NULL || canDefend); } - return 1; + lured = false; + } + return 1; } const char * MTGBlockRule::getMenuText() diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index 896d05002..536402a32 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -1534,6 +1534,18 @@ bool BlockableChooser::canTarget(Targetable * target,bool withoutProtections) { if(!card->isAttacker() || !source->canBlock(card)) return false; + bool lured = false; + int lureFound = 0; + MTGCardInstance * lurers = NULL; + while(!lureFound) + { + lurers = card->controller()->game->inPlay->getNextLurer(lurers); + lureFound = (lurers == NULL || lurers->attacker); + if(lurers) + lured = true; + } + if(lured && card->controller()->inPlay()->hasAbility(Constants::LURE) && !card->has(Constants::LURE)) + return false; return true; } return TypeTargetChooser::canTarget(target,withoutProtections);