From e117cf82c908dc96f1ee35fcbe3984fefb700b72 Mon Sep 17 00:00:00 2001 From: "omegablast2002@yahoo.com" Date: Sun, 25 Sep 2011 13:51:33 +0000 Subject: [PATCH] just moving parserestrictions under the parsecastrestrictions...so they are together rather then an entire page apart :) no code change, it just bugged me :P --- projects/mtg/src/MTGAbility.cpp | 64 ++++++++++++++++----------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 372debbd8..984fcfe13 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -298,6 +298,38 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card,Player * player return 1; } +int AbilityFactory::parseRestriction(string s) +{ + if (s.find("myturnonly") != string::npos) + return ActivatedAbility::PLAYER_TURN_ONLY; + if (s.find("opponentturnonly") != string::npos) + return ActivatedAbility::OPPONENT_TURN_ONLY; + if (s.find("assorcery") != string::npos) + return ActivatedAbility::AS_SORCERY; + + string types[] = { "my", "opponent", "" }; + int starts[] = { ActivatedAbility::MY_BEFORE_BEGIN, ActivatedAbility::OPPONENT_BEFORE_BEGIN, ActivatedAbility::BEFORE_BEGIN }; + for (int j = 0; j < 3; ++j) + { + size_t found = s.find(types[j]); + if (found != string::npos) + { + for (int i = 0; i < Constants::NB_MTG_PHASES; i++) + { + string toFind = types[j]; + toFind.append(Constants::MTGPhaseCodeNames[i]).append("only"); + found = s.find(toFind); + if (found != string::npos) + { + return starts[j] + i; + } + } + } + } + + return ActivatedAbility::NO_RESTRICTION; +} + int AbilityFactory::countCards(TargetChooser * tc, Player * player, int option) { int result = 0; @@ -683,38 +715,6 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string magicText, int return NULL; } -int AbilityFactory::parseRestriction(string s) -{ - if (s.find("myturnonly") != string::npos) - return ActivatedAbility::PLAYER_TURN_ONLY; - if (s.find("opponentturnonly") != string::npos) - return ActivatedAbility::OPPONENT_TURN_ONLY; - if (s.find("assorcery") != string::npos) - return ActivatedAbility::AS_SORCERY; - - string types[] = { "my", "opponent", "" }; - int starts[] = { ActivatedAbility::MY_BEFORE_BEGIN, ActivatedAbility::OPPONENT_BEFORE_BEGIN, ActivatedAbility::BEFORE_BEGIN }; - for (int j = 0; j < 3; ++j) - { - size_t found = s.find(types[j]); - if (found != string::npos) - { - for (int i = 0; i < Constants::NB_MTG_PHASES; i++) - { - string toFind = types[j]; - toFind.append(Constants::MTGPhaseCodeNames[i]).append("only"); - found = s.find(toFind); - if (found != string::npos) - { - return starts[j] + i; - } - } - } - } - - return ActivatedAbility::NO_RESTRICTION; -} - // When abilities encapsulate each other, gets the deepest one (it is the one likely to have the most relevant information) MTGAbility * AbilityFactory::getCoreAbility(MTGAbility * a) {