Erwan
- Adding external rules mechanism. It is very crude for the moment, but I hope it will grow. Have a look at Rules/mtg.txt for basic usage
This commit is contained in:
@@ -5,6 +5,26 @@
|
||||
#include "../include/WEvent.h"
|
||||
|
||||
|
||||
//Parses a string and gives phase numer
|
||||
int PhaseRing::phaseStrToInt(string s){
|
||||
if (s.compare("untap") == 0) return Constants::MTG_PHASE_UNTAP;
|
||||
if (s.compare("upkeep") == 0)return Constants::MTG_PHASE_UPKEEP;
|
||||
if (s.compare("draw") == 0)return Constants::MTG_PHASE_DRAW;
|
||||
if (s.compare("firstmain") == 0)return Constants::MTG_PHASE_FIRSTMAIN;
|
||||
if (s.compare("combatbegin") == 0)return Constants::MTG_PHASE_COMBATBEGIN;
|
||||
if (s.compare("combatattackers") == 0)return Constants::MTG_PHASE_COMBATATTACKERS;
|
||||
if (s.compare("combatblockers") == 0)return Constants::MTG_PHASE_COMBATBLOCKERS;
|
||||
if (s.compare("combatdamage") == 0)return Constants::MTG_PHASE_COMBATDAMAGE;
|
||||
if (s.compare("combatend") == 0)return Constants::MTG_PHASE_COMBATEND;
|
||||
if (s.compare("secondmain") == 0)return Constants::MTG_PHASE_SECONDMAIN;
|
||||
if (s.compare("endofturn") == 0)return Constants::MTG_PHASE_ENDOFTURN;
|
||||
if (s.compare("cleanup") == 0)return Constants::MTG_PHASE_CLEANUP;
|
||||
OutputDebugString("PHASERING: Unknown Phase name:");
|
||||
OutputDebugString(s.c_str());
|
||||
OutputDebugString("\n");
|
||||
return Constants::MTG_PHASE_FIRSTMAIN;
|
||||
}
|
||||
|
||||
/* Creates a New phase ring with the default rules */
|
||||
PhaseRing::PhaseRing(Player* players[], int nbPlayers){
|
||||
for (int i = 0; i < nbPlayers; i++){
|
||||
@@ -24,19 +44,19 @@ PhaseRing::~PhaseRing(){
|
||||
}
|
||||
}
|
||||
|
||||
//Tells if next phase will be another Damage phase rather than combat ends
|
||||
bool PhaseRing::extraDamagePhase(int id){
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
if (id != Constants::MTG_PHASE_COMBATEND) return false;
|
||||
if (g->combatStep != END_FIRST_STRIKE) return false;
|
||||
for (int j = 0; j < 2; ++j){
|
||||
MTGGameZone * z = g->players[j]->game->inPlay;
|
||||
//Tells if next phase will be another Damage phase rather than combat ends
|
||||
bool PhaseRing::extraDamagePhase(int id){
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
if (id != Constants::MTG_PHASE_COMBATEND) return false;
|
||||
if (g->combatStep != END_FIRST_STRIKE) return false;
|
||||
for (int j = 0; j < 2; ++j){
|
||||
MTGGameZone * z = g->players[j]->game->inPlay;
|
||||
for (int i= 0; i < z->nb_cards; ++i){
|
||||
MTGCardInstance * card = z->cards[i];
|
||||
if ((card->isAttacker() || card->isDefenser()) && !(card->has(Constants::FIRSTSTRIKE) || card->has(Constants::DOUBLESTRIKE))) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const char * PhaseRing::phaseName(int id){
|
||||
|
||||
Reference in New Issue
Block a user