From 565ee573721afef735daa4d9b32f4159350b7ff7 Mon Sep 17 00:00:00 2001 From: "omegablast2002@yahoo.com" Date: Mon, 28 Mar 2011 16:39:30 +0000 Subject: [PATCH] it was reported to me that cards such as Isleback Spawn were not actually working correctly, to fix these i added a compareZone function to aslongas and a tag to use when you want to compare different like zones, example: lets say in the case of Isleback Spawn you want to see if ANY player has less then 20 cards. auto=aslongas(*|library) 4/8 <21 compare this will check if either you or your opponent has less then 20 cards. rather then adding the total cards in both libraries. over the last weeks ive seen this cards code change atleast 3 times. this should be the final version for it and any other cards like it. --- projects/mtg/include/AllAbilities.h | 34 ++++++++++++++++++++++++----- projects/mtg/src/MTGAbility.cpp | 11 ++++++++-- 2 files changed, 38 insertions(+), 7 deletions(-) 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: