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)
This commit is contained in:
omegablast2002@yahoo.com
2011-04-25 14:48:03 +00:00
parent cf46404ed1
commit 9de076db75
3 changed files with 37 additions and 11 deletions

View File

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

View File

@@ -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()

View File

@@ -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