extended "vanishing" to support "fading" these 2 abilities are the same with the exception of the name of the counter the creature receive.

This commit is contained in:
omegablast2002@yahoo.com
2011-02-06 18:20:59 +00:00
parent 26b1cd2c34
commit de6e5ed7eb
3 changed files with 30 additions and 10 deletions

View File

@@ -3964,8 +3964,9 @@ class AVanishing: public ActivatedAbility
public:
int timeLeft;
int amount;
string counterName;
AVanishing(int _id, MTGCardInstance * card, ManaCost * _cost, int _tap = 0, int restrictions = 0,int amount = 0);
AVanishing(int _id, MTGCardInstance * card, ManaCost * _cost, int _tap = 0, int restrictions = 0,int amount = 0,string counterName = "");
void Update(float dt);
int resolve();
const char * getMenuText();

View File

@@ -2782,12 +2782,12 @@ APreventDamageTypesUEOT::~APreventDamageTypesUEOT()
SAFE_DELETE(ability);
}
//AVanishing creature
AVanishing::AVanishing(int _id, MTGCardInstance * card, ManaCost * _cost, int _tap, int restrictions, int amount) :
ActivatedAbility(_id, card, _cost, restrictions, _tap),amount(amount)
//AVanishing creature also fading
AVanishing::AVanishing(int _id, MTGCardInstance * card, ManaCost * _cost, int _tap, int restrictions, int amount, string counterName) :
ActivatedAbility(_id, card, _cost, restrictions, _tap),amount(amount),counterName(counterName)
{
for(int i = 0;i< amount;i++)
source->counters->addCounter("time",0,0);
source->counters->addCounter(counterName.c_str(),0,0);
}
void AVanishing::Update(float dt)
@@ -2796,13 +2796,13 @@ void AVanishing::Update(float dt)
{
if(newPhase == Constants::MTG_PHASE_UPKEEP)
{
source->counters->removeCounter("time",0,0);
source->counters->removeCounter(counterName.c_str(),0,0);
Counter * targetCounter = NULL;
timeLeft = 0;
if (source->counters && source->counters->hasCounter("time", 0, 0))
if (source->counters && source->counters->hasCounter(counterName.c_str(), 0, 0))
{
targetCounter = source->counters->hasCounter("time", 0, 0);
targetCounter = source->counters->hasCounter(counterName.c_str(), 0, 0);
timeLeft = targetCounter->nb;
}
else
@@ -2835,6 +2835,8 @@ int AVanishing::resolve()
const char * AVanishing::getMenuText()
{
if(counterName.find("fading") != string::npos)
return "Fading";
return "Vanishing";
}

View File

@@ -2439,10 +2439,27 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
{
amount = atoi(s.substr(start + 1).c_str());
}
MTGAbility * a = NEW AVanishing(id, card, NULL, doTap, restrictions,amount);
MTGAbility * a = NEW AVanishing(id, card, NULL, doTap, restrictions,amount,"time");
return a;
}
//Fading
found = s.find("fading:");
if (found != string::npos)
{
size_t start = s.find(":", found);
size_t end = s.find(" ", start);
int amount;
if (end != string::npos)
{
amount = atoi(s.substr(start + 1, end - start - 1).c_str());
}
else
{
amount = atoi(s.substr(start + 1).c_str());
}
MTGAbility * a = NEW AVanishing(id, card, NULL, doTap, restrictions,amount,"fade");
return a;
}
if (s.find("altercost(") != string::npos)
return getManaReduxAbility(s.substr(s.find("altercost(") + 10), id, spell, card, target);