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; }