From fe91960980950405ac30ce7bc3917de093289ca1 Mon Sep 17 00:00:00 2001 From: "omegablast2002@yahoo.com" Date: Mon, 3 Oct 2011 13:13:37 +0000 Subject: [PATCH] moved all basic MTG related rules out of the engine and into rules.txt. this allows users to create a mod without having to struggle with avoiding certain phase based or cost actions. attackrule and attacker phase can be seperated now by not including auto=attackrule in your rules.txt....this means you can still have an attackers phase, but clicking the cards won't put the cards into attacker mode or add "attacker" to thier menu abilities. ect... this also allows us to eventaully change/add to these base rules without having to create entirely new rules for them by modifying the base classes with new variables and so on. IMPORTANT: UPDATE YOUR RULES FOLDER, OR NOTHING WILL WORK FOR YOU. --- projects/mtg/src/ActionStack.cpp | 2 +- projects/mtg/src/DuelLayers.cpp | 22 ----- projects/mtg/src/MTGAbility.cpp | 150 ++++++++++++++++++++++++++++++- 3 files changed, 150 insertions(+), 24 deletions(-) diff --git a/projects/mtg/src/ActionStack.cpp b/projects/mtg/src/ActionStack.cpp index c33fb5524..19311daa5 100644 --- a/projects/mtg/src/ActionStack.cpp +++ b/projects/mtg/src/ActionStack.cpp @@ -578,7 +578,7 @@ int ActionStack::setIsInterrupting(Player * player) return 0; } - // Is it a valid interruption request, or is uninterruptible stuff going on in the game? + //Is it a valid interruption request, or is uninterruptible stuff going on in the game? if (observer->getCurrentTargetChooser()) { DebugTrace("ActionStack: WARNING - We were asked to interrupt, During Targetchoosing" << endl diff --git a/projects/mtg/src/DuelLayers.cpp b/projects/mtg/src/DuelLayers.cpp index fd7b17f51..30a25daf9 100644 --- a/projects/mtg/src/DuelLayers.cpp +++ b/projects/mtg/src/DuelLayers.cpp @@ -19,28 +19,6 @@ void DuelLayers::init(GameObserver* go) //1 Action Layer action = NEW ActionLayer(go); action->Add(NEW MTGGamePhase(go, action->getMaxId())); - //Add Magic Specific Rules - action->Add(NEW MTGEventBonus(go, -1)); - action->Add(NEW MTGPutInPlayRule(go, -1)); - action->Add(NEW MTGKickerRule(go, -1)); - action->Add(NEW MTGAlternativeCostRule(go, -1)); - action->Add(NEW MTGBuyBackRule(go, -1)); - action->Add(NEW MTGFlashBackRule(go, -1)); - action->Add(NEW MTGRetraceRule(go, -1)); - action->Add(NEW MTGSuspendRule(go, -1)); - action->Add(NEW MTGAttackRule(go, -1)); - action->Add(NEW MTGBlockRule(go, -1)); - action->Add(NEW MTGCombatTriggersRule(go, -1)); - action->Add(NEW MTGLegendRule(go, -1)); - action->Add(NEW MTGPlaneWalkerRule(go, -1)); - action->Add(NEW MTGTokensCleanup(go, -1)); // needs to be before persist - action->Add(NEW MTGPersistRule(go, -1)); - action->Add(NEW MTGVampireRule(go, -1)); - action->Add(NEW MTGUnearthRule(go, -1)); - action->Add(NEW MTGLifelinkRule(go, -1)); - action->Add(NEW MTGDeathtouchRule(go, -1)); - action->Add(NEW OtherAbilitiesEventReceiver(go, -1)); - action->Add(NEW MTGMorphCostRule(go, -1)); //Other display elements action->Add(NEW HUDDisplay(go, -1)); diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index d8e15c38e..515b88f00 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -754,6 +754,155 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG if (!target) target = card; + //MTG Specific rules + //adds the bonus credit system + found = s.find("bonusrule"); + if(found != string::npos) + { + observer->addObserver(NEW MTGEventBonus(observer, -1)); + return NULL; + } + //putinplay/cast rule.. this is a parent rule and is required for all cost related rules. + found = s.find("putinplayrule"); + if(found != string::npos) + { + observer->addObserver(NEW MTGPutInPlayRule(observer, -1)); + return NULL; + } + //rule for kicker handling + found = s.find("kickerrule"); + if(found != string::npos) + { + observer->addObserver(NEW MTGKickerRule(observer, -1)); + return NULL; + } + //alternative cost types rule, this is a parent rule and is required for all cost related rules. + found = s.find("alternativecostrule"); + if(found != string::npos) + { + observer->addObserver(NEW MTGAlternativeCostRule(observer, -1)); + return NULL; + } + //alternative cost type buyback + found = s.find("buybackrule"); + if(found != string::npos) + { + observer->addObserver(NEW MTGBuyBackRule(observer, -1)); + return NULL; + } + //alternative cost type flashback + found = s.find("flashbackrule"); + if(found != string::npos) + { + observer->addObserver(NEW MTGFlashBackRule(observer, -1)); + return NULL; + } + //alternative cost type retrace + found = s.find("retracerule"); + if(found != string::npos) + { + observer->addObserver(NEW MTGRetraceRule(observer, -1)); + return NULL; + } + //alternative cost type suspend + found = s.find("suspendrule"); + if(found != string::npos) + { + observer->addObserver(NEW MTGSuspendRule(observer, -1)); + return NULL; + } + //alternative cost type morph + found = s.find("morphrule"); + if(found != string::npos) + { + observer->addObserver(NEW MTGMorphCostRule(observer, -1)); + return NULL; + } + //this rule handles attacking ability during attacker phase + found = s.find("attackrule"); + if(found != string::npos) + { + observer->addObserver(NEW MTGAttackRule(observer, -1)); + return NULL; + } + //this rule handles blocking ability during blocker phase + found = s.find("blockrule"); + if(found != string::npos) + { + observer->addObserver(NEW MTGBlockRule(observer, -1)); + return NULL; + } + //this rule handles combat related triggers. note, combat related triggered abilities will not work without it. + found = s.find("combattriggerrule"); + if(found != string::npos) + { + observer->addObserver(NEW MTGCombatTriggersRule(observer, -1)); + return NULL; + } + //this handles the legend rule + found = s.find("legendrule"); + if(found != string::npos) + { + observer->addObserver(NEW MTGLegendRule(observer, -1)); + return NULL; + } + //this handles the planeswalker named legend rule which is dramatically different from above. + found = s.find("planeswalkerrule"); + if(found != string::npos) + { + observer->addObserver(NEW MTGPlaneWalkerRule(observer, -1)); + return NULL; + } + //this handles the clean up of tokens !!MUST BE ADDED BEFORE PERSIST RULE!! + found = s.find("tokencleanuprule"); + if(found != string::npos) + { + observer->addObserver(NEW MTGTokensCleanup(observer, -1)); + return NULL; + } + //this handles the returning of cards with persist to the battlefield. + found = s.find("persistrule"); + if(found != string::npos) + { + observer->addObserver(NEW MTGPersistRule(observer, -1)); + return NULL; + } + //this handles the vectors of cards which attacked and were attacked and later died during that turn. + found = s.find("vampirerule"); + if(found != string::npos) + { + observer->addObserver(NEW MTGVampireRule(observer, -1)); + return NULL; + } + //this handles the removel of cards which were unearthed. + found = s.find("unearthrule"); + if(found != string::npos) + { + observer->addObserver(NEW MTGUnearthRule(observer, -1)); + return NULL; + } + //this handles lifelink ability rules. + found = s.find("lifelinkrule"); + if(found != string::npos) + { + observer->addObserver(NEW MTGLifelinkRule(observer, -1)); + return NULL; + } + //this handles death touch ability rule. + found = s.find("deathtouchrule"); + if(found != string::npos) + { + observer->addObserver(NEW MTGDeathtouchRule(observer, -1)); + return NULL; + } + //this handles all other events reciever, this one is essential for the game to play. + found = s.find("otherabilitiesrule"); + if(found != string::npos) + { + observer->addObserver(NEW OtherAbilitiesEventReceiver(observer, -1)); + return NULL; + } + //need to remove the section inside the transforms ability from the string before parsing //TODO: store string values of "&&" so we can remove the classes added just to add support //the current parser finds other abilities inside what should be nested abilities, and converts them into @@ -2287,7 +2436,6 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG a->oneShot = 1; return a; } - DebugTrace(" no matching ability found. " << s); return NULL; }