From 64a234ef4476052357ef42048238754dc7cc6c1c Mon Sep 17 00:00:00 2001 From: "omegablast2002@yahoo.com" Date: Wed, 2 Mar 2011 21:33:42 +0000 Subject: [PATCH] added support for customphasering construction in rules txt... exsample [INIT] mode=mtg [PLAYERS] life:2000 poisoncount:4 customphasering:untap,firstmain,firstmain,draw,firstmain,upkeep,draw auto=shuffle auto=draw:7 auto=@each my draw:draw:1 auto=maxPlay(land)1 by default every turn will have normal order we've always been use to however before begins --required added automatically anything you want in any order anything you want in any order anything you want in any order anything you want in any order anything you want in any order anything you want in any order anything you want in any order anything you want in any order cleanup---required added automatically after end of turn---required added automatically svntax customphasering:blah,blah,blah listed in the order you want it to go. you can repeat a phase as often as you want, you can omit phases. please note, this was not designed with MTG in mind..some of the rules require certain phases to work...this is for CUSTOM game building...i repeat NOT DESIGNED FOR MTG...tho it can be used with most(almost all, with the exception of those which require certain phases to work, exsample, ninjitsu will only work in a phasering which contains blockers and attackers) enjoy..... --- projects/mtg/include/Player.h | 1 + projects/mtg/include/Rules.h | 1 + projects/mtg/src/PhaseRing.cpp | 27 +++++++++++++++++++++++---- projects/mtg/src/Rules.cpp | 10 ++++++++-- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/projects/mtg/include/Player.h b/projects/mtg/include/Player.h index 40ac434e1..eb734d4b8 100644 --- a/projects/mtg/include/Player.h +++ b/projects/mtg/include/Player.h @@ -33,6 +33,7 @@ public: string deckFile; string deckFileSmall; string deckName; + string phaseRing; Player(MTGDeck * deck, string deckFile, string deckFileSmall); virtual ~Player(); diff --git a/projects/mtg/include/Rules.h b/projects/mtg/include/Rules.h index f4542e9bc..39e7ce423 100644 --- a/projects/mtg/include/Rules.h +++ b/projects/mtg/include/Rules.h @@ -26,6 +26,7 @@ class RulesPlayerData { public: vector extraRules; + string phaseRing; int life; int poisonCount; int damageCount; diff --git a/projects/mtg/src/PhaseRing.cpp b/projects/mtg/src/PhaseRing.cpp index 9bfda1b83..b4353c0b0 100644 --- a/projects/mtg/src/PhaseRing.cpp +++ b/projects/mtg/src/PhaseRing.cpp @@ -4,7 +4,7 @@ #include "MTGDefinitions.h" #include "Player.h" #include "WEvent.h" - +#include "Rules.h" //Parses a string and gives phase numer int PhaseRing::phaseStrToInt(string s) { @@ -30,10 +30,29 @@ PhaseRing::PhaseRing(Player* players[], int nbPlayers) { for (int i = 0; i < nbPlayers; i++) { - for (int j = 0; j < Constants::NB_MTG_PHASES; j++) + if(players[i]->phaseRing.size()) { - Phase * phase = NEW Phase(j, players[i]); - addPhase(phase); + Phase * defaultsphase = NEW Phase(Constants::MTG_PHASE_BEFORE_BEGIN, players[i]); + addPhase(defaultsphase); + vectorcustomRing = split(players[i]->phaseRing,','); + for (unsigned int k = 0;k < customRing.size(); k++) + { + int customOrder = phaseStrToInt(customRing[k]); + Phase * phase = NEW Phase(customOrder, players[i]); + addPhase(phase); + } + defaultsphase = NEW Phase(Constants::MTG_PHASE_CLEANUP, players[i]); + addPhase(defaultsphase); + defaultsphase = NEW Phase(Constants::MTG_PHASE_AFTER_EOT, players[i]); + addPhase(defaultsphase); + } + else + { + for (int j = 0; j < Constants::NB_MTG_PHASES; j++) + { + Phase * phase = NEW Phase(j, players[i]); + addPhase(phase); + } } } current = ring.begin(); diff --git a/projects/mtg/src/Rules.cpp b/projects/mtg/src/Rules.cpp index d0baee7f1..2da693b19 100644 --- a/projects/mtg/src/Rules.cpp +++ b/projects/mtg/src/Rules.cpp @@ -105,12 +105,12 @@ void RulesState::parsePlayerState(int playerId, string s) playerData[playerId].life = atoi((s.substr(limiter + 1)).c_str()); return; } - else if (areaS.compare("poisonCount") == 0) + else if (areaS.compare("poisoncount") == 0) { playerData[playerId].poisonCount = atoi((s.substr(limiter + 1)).c_str()); return; } - else if (areaS.compare("damageCount") == 0) + else if (areaS.compare("damagecount") == 0) { playerData[playerId].damageCount = atoi((s.substr(limiter + 1)).c_str()); return; @@ -131,6 +131,11 @@ void RulesState::parsePlayerState(int playerId, string s) playerData[playerId].manapool = ManaCost::parseManaCost(s.substr(limiter + 1)); return; } + else if (areaS.compare("customphasering") == 0) + { + playerData[playerId].phaseRing = s.substr(limiter + 1); + return; + } else if (areaS.compare("auto") == 0) { playerData[playerId].extraRules.push_back(s.substr(limiter + 1)); @@ -331,6 +336,7 @@ Player * Rules::initPlayer(int playerId) return loadPlayerRandom(isAI, GAME_TYPE_RANDOM2); } } + p->phaseRing = initState.playerData[playerId].phaseRing; return p; }