diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index cb528fd6b..7c60f24af 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -2347,11 +2347,14 @@ public: MTGAbility * a; int includeSelf; int mini, maxi; - bool miniFound, maxiFound; + bool miniFound, maxiFound, compareZone; + int amount[2]; AAsLongAs(int _id, MTGCardInstance * _source, Damageable * _target, TargetChooser * _tc, int _includeSelf, - MTGAbility * ability, int mini = 0, int maxi = 0,bool miniFound = false,bool maxiFound = false) : - ListMaintainerAbility(_id, _source, _target), NestedAbility(ability), mini(mini), maxi(maxi),miniFound(miniFound),maxiFound(maxiFound) + MTGAbility * ability, int mini = 0, int maxi = 0,bool miniFound = false,bool maxiFound = false,bool compareZone = false) : + ListMaintainerAbility(_id, _source, _target), NestedAbility(ability), mini(mini), maxi(maxi),miniFound(miniFound),maxiFound(maxiFound),compareZone(compareZone) { + for (int j = 0; j < 2; j++) + amount[j] = 0; tc = _tc; includeSelf = _includeSelf; tc->targetter = NULL; @@ -2368,17 +2371,38 @@ public: } + void findMatchingAmount() + { + int Value = 0; + GameObserver * game = game->GetInstance(); + for (int i = 0; i < 2; i++) + { + Player * p = game->players[i]; + MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library }; + for (int k = 0; k < 4; k++) + { + MTGGameZone * zone = zones[k]; + Value = zone->countByCanTarget(tc); + } + amount[i] = Value; + } + } + int SorterFunction() { updateTargets(); int size = 0; size = (int) cards.size(); + if(compareZone) + findMatchingAmount(); + //compare like tc zones to find a matching amount. + //if any player has less/more of Tc targetable cards, ability is valid. /////////////////DO NOT REFACTOR THIS SECTION///////////////////////////////////////// //these were seperated becuase previous methods were far too confusing to understand// ////////////////////////////////////////////////////////////////////////////////////// if (miniFound) { - if (size > mini) + if (size > mini || (compareZone && (amount[0] > mini || amount[1] > mini))) { addAbilityToGame(); } @@ -2389,7 +2413,7 @@ public: } if (maxiFound) { - if (size < maxi) + if (size < maxi || (compareZone && (amount[0] < maxi || amount[1] < maxi))) { addAbilityToGame(); } diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 0f9803c7e..bcf48e5a9 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -1304,6 +1304,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG int maxi = 0; bool miniFound = false; bool maxiFound = false; + bool compareZone = false; found = s.find(" >"); if (found != string::npos) @@ -1318,7 +1319,13 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG maxi = atoi(s.substr(found + 2, 3).c_str()); maxiFound = true; } - + + found = s.find("compare"); + if (found != string::npos) + { + compareZone = true; + } + switch (i) { case 0: @@ -1333,7 +1340,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG { miniFound = true; } - result = NEW AAsLongAs(id, card, _target, lordTargets, lordIncludeSelf, a, mini, maxi,miniFound,maxiFound); + result = NEW AAsLongAs(id, card, _target, lordTargets, lordIncludeSelf, a, mini, maxi,miniFound,maxiFound,compareZone); } break; case 3: