From 9de076db750ae8b736844b83cef0a1688746f91f Mon Sep 17 00:00:00 2001 From: "omegablast2002@yahoo.com" Date: Mon, 25 Apr 2011 14:48:03 +0000 Subject: [PATCH] added",once" tag for phaseaction, to denote that the effect is only to happen once before forcedestroy is declared. auto=@movedTo(graveyard) from(this|battlefield):phaseaction[endofturn,once] token(Bird,Creature Bird,4/4,red,flying) --- projects/mtg/include/AllAbilities.h | 5 +++-- projects/mtg/src/AllAbilities.cpp | 10 ++++----- projects/mtg/src/MTGAbility.cpp | 33 +++++++++++++++++++++++++---- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index ca7b73302..026e9a542 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -3884,10 +3884,11 @@ public: bool next; bool myturn; bool opponentturn; + bool once; Player * abilityOwner; APhaseAction(int _id, MTGCardInstance * card, MTGCardInstance * target, string sAbility, int restrictions = 0, int _phase = - Constants::MTG_PHASE_UPKEEP,bool forcedestroy = false,bool next = true,bool myturn = true,bool opponentturn = true); + Constants::MTG_PHASE_UPKEEP,bool forcedestroy = false,bool next = true,bool myturn = true,bool opponentturn = true,bool once = false); void Update(float dt); int resolve(); const char * getMenuText(); @@ -3902,7 +3903,7 @@ public: string sAbility; APhaseAction * ability; APhaseActionGeneric(int _id, MTGCardInstance * card, MTGCardInstance * target, string sAbility, int restrictions = 0, int _phase = - Constants::MTG_PHASE_UPKEEP,bool forcedestroy = false,bool next = true,bool myturn = false,bool opponentturn = false); + Constants::MTG_PHASE_UPKEEP,bool forcedestroy = false,bool next = true,bool myturn = false,bool opponentturn = false,bool once = false); int resolve(); const char * getMenuText(); APhaseActionGeneric * clone() const; diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index e53c58362..5b03df73f 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -2922,8 +2922,8 @@ AUpkeep::~AUpkeep() } //A Phase based Action -APhaseAction::APhaseAction(int _id, MTGCardInstance * card, MTGCardInstance * target, string sAbility, int restrictions, int _phase,bool forcedestroy,bool next,bool myturn,bool opponentturn) : -MTGAbility(_id, card),sAbility(sAbility), phase(_phase),forcedestroy(forcedestroy),next(next),myturn(myturn),opponentturn(opponentturn) +APhaseAction::APhaseAction(int _id, MTGCardInstance * card, MTGCardInstance * target, string sAbility, int restrictions, int _phase,bool forcedestroy,bool next,bool myturn,bool opponentturn,bool once) : +MTGAbility(_id, card),sAbility(sAbility), phase(_phase),forcedestroy(forcedestroy),next(next),myturn(myturn),opponentturn(opponentturn),once(once) { abilityId = _id; abilityOwner = card->controller(); @@ -2969,7 +2969,7 @@ void APhaseAction::Update(float dt) a->resolve(); delete (a); delete (ability); - if(this->oneShot) + if(this->oneShot || once) { this->forceDestroy = 1; } @@ -3010,11 +3010,11 @@ APhaseAction::~APhaseAction() } // the main ability -APhaseActionGeneric::APhaseActionGeneric(int _id, MTGCardInstance * card, MTGCardInstance * target, string sAbility, int restrictions, int _phase,bool forcedestroy,bool next,bool myturn,bool opponentturn) : +APhaseActionGeneric::APhaseActionGeneric(int _id, MTGCardInstance * card, MTGCardInstance * target, string sAbility, int restrictions, int _phase,bool forcedestroy,bool next,bool myturn,bool opponentturn,bool once) : InstantAbility(_id, source, target) { MTGCardInstance * _target = target; - ability = NEW APhaseAction(_id, card,_target, sAbility, restrictions, _phase,forcedestroy,next,myturn,opponentturn); + ability = NEW APhaseAction(_id, card,_target, sAbility, restrictions, _phase,forcedestroy,next,myturn,opponentturn,once); } int APhaseActionGeneric::resolve() diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 58a700aa0..6f153ee63 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -1142,11 +1142,26 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG found = s.find("phaseactionmulti"); if (found != string::npos) { - size_t start = s.find("["); + size_t start = s.find("["); size_t end = s.find("]", start); string s1 = s.substr(start + 1, end - start - 1); int phase = Constants::MTG_PHASE_UPKEEP; - + for (int i = 0; i < Constants::NB_MTG_PHASES; i++) + { + if (s1.find(Constants::MTGPhaseCodeNames[i]) != string::npos) + { + phase = i; + } + } + bool opponentturn = true,myturn = true; + if(s1.find("my") != string::npos) + { + opponentturn = false; + } + if(s1.find("opponent") != string::npos) + { + myturn = false; + } if (s1.find("combatends") != string::npos) { phase = Constants::MTG_PHASE_COMBATEND; @@ -1173,13 +1188,18 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG { next = false; } + bool once = false; + if (s1.find(",once") != string::npos) + { + once = true; + } string sAbility = s.substr(end + 1); MTGCardInstance * _target = NULL; if (spell) _target = spell->getNextCardTarget(); if(!_target) _target = target; - return NEW APhaseActionGeneric(id, card,_target,sAbility, restrictions, phase,sourceinPlay,next); + return NEW APhaseActionGeneric(id, card,_target, sAbility, restrictions, phase,sourceinPlay,next,myturn,opponentturn,once); } //Multiple abilities for ONE cost @@ -1660,13 +1680,18 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG { next = false; } + bool once = false; + if (s1.find(",once") != string::npos) + { + once = true; + } string sAbility = s.substr(end + 1); MTGCardInstance * _target = NULL; if (spell) _target = spell->getNextCardTarget(); if(!_target) _target = target; - return NEW APhaseActionGeneric(id, card,_target, sAbility, restrictions, phase,sourceinPlay,next,myturn,opponentturn); + return NEW APhaseActionGeneric(id, card,_target, sAbility, restrictions, phase,sourceinPlay,next,myturn,opponentturn,once); } //Upkeep Cost