added a way to set the max amount a counter ability can give you...aka the clockworks effect...as per mtg rules, you are still allowed to activate the effect but if it would put the target counters higher then the max allowed by that ability, then it will do nothing.

it strings exactly like normal counters did, except now after the name you can add yet another "," and a number or word varible...if you will not have a name it is still required that you add the extra comma, as it is a seperator for the parser. so clock works swarm would be counter(1/0,1,,4)...no matter what, this ability will do nothing if the amount of the target counter is already higher then the max allowed, in this case 4...other effects can give the creature more counters...however..this ability will resolve to nothing if youve exceeded the limit. until you are under the amount again.
This commit is contained in:
omegablast2002@yahoo.com
2011-02-08 15:12:14 +00:00
parent d852486355
commit f7b34295fb
4 changed files with 45 additions and 10 deletions
+2 -1
View File
@@ -886,12 +886,13 @@ class AACounter: public ActivatedAbility
public: public:
string counterstring; string counterstring;
int nb; int nb;
int maxNb;
int power; int power;
int toughness; int toughness;
string name; string name;
string menu; string menu;
AACounter(int id, MTGCardInstance * source, MTGCardInstance * target,string counterstring, const char * _name, int power, int toughness, int nb, AACounter(int id, MTGCardInstance * source, MTGCardInstance * target,string counterstring, const char * _name, int power, int toughness, int nb,int maxNb = 0,
ManaCost * cost = NULL, int doTap = 0); ManaCost * cost = NULL, int doTap = 0);
int resolve(); int resolve();
+1
View File
@@ -11,6 +11,7 @@ class Counter
public: public:
string name; string name;
int nb; int nb;
int maxNb;
int power, toughness; int power, toughness;
MTGCardInstance * target; MTGCardInstance * target;
Counter(MTGCardInstance * _target, int _power, int _toughness); Counter(MTGCardInstance * _target, int _power, int _toughness);
+17 -8
View File
@@ -287,8 +287,8 @@ AAPhaseOut * AAPhaseOut::clone() const
//Counters //Counters
AACounter::AACounter(int id, MTGCardInstance * source, MTGCardInstance * target,string counterstring, const char * _name, int power, int toughness, AACounter::AACounter(int id, MTGCardInstance * source, MTGCardInstance * target,string counterstring, const char * _name, int power, int toughness,
int nb, ManaCost * cost, int doTap) : int nb,int maxNb, ManaCost * cost, int doTap) :
ActivatedAbility(id, source, cost, 0, doTap),counterstring(counterstring), nb(nb), power(power), toughness(toughness), name(_name) ActivatedAbility(id, source, cost, 0, doTap),counterstring(counterstring), nb(nb),maxNb(maxNb), power(power), toughness(toughness), name(_name)
{ {
this->target = target; this->target = target;
if (name.find("Level")) if (name.find("Level"))
@@ -307,13 +307,22 @@ AACounter::AACounter(int id, MTGCardInstance * source, MTGCardInstance * target,
delete checkcounter; delete checkcounter;
if (nb > 0) if (nb > 0)
{ {
for (int i = 0; i < nb; i++) for (int i = 0; i < nb; i++)
{ {
while (_target->next) while (_target->next)
_target = _target->next; _target = _target->next;
_target->counters->addCounter(name.c_str(), power, toughness);
Counter * targetCounter = NULL;
int currentAmount = 0;
if (_target->counters && _target->counters->hasCounter(name.c_str(), power, toughness))
{
targetCounter = _target->counters->hasCounter(name.c_str(), power, toughness);
currentAmount = targetCounter->nb;
}
if(!maxNb || (maxNb && currentAmount < maxNb))
_target->counters->addCounter(name.c_str(), power, toughness);
}
} }
}
else else
{ {
for (int i = 0; i < -nb; i++) for (int i = 0; i < -nb; i++)
+25 -1
View File
@@ -214,6 +214,7 @@ int AbilityFactory::countCards(TargetChooser * tc, Player * player, int option)
Counter * AbilityFactory::parseCounter(string s, MTGCardInstance * target, Spell * spell) Counter * AbilityFactory::parseCounter(string s, MTGCardInstance * target, Spell * spell)
{ {
int nb = 1; int nb = 1;
int maxNb = 0;
string name = ""; string name = "";
size_t start = 0; size_t start = 0;
size_t end = s.length(); size_t end = s.length();
@@ -225,9 +226,15 @@ Counter * AbilityFactory::parseCounter(string s, MTGCardInstance * target, Spell
size_t separator2 = s.find(",", separator + 1); size_t separator2 = s.find(",", separator + 1);
if (separator2 == string::npos) if (separator2 == string::npos)
separator2 = s.find(".", separator + 1); separator2 = s.find(".", separator + 1);
size_t separator3 = string::npos;
if (separator2 != string::npos) if (separator2 != string::npos)
{ {
name = s.substr(separator2 + 1, end - separator2 - 1); name = s.substr(separator2 + 1, end - separator2 - 1);
separator3 = s.find(",", separator2 + 1);
if (separator3 != string::npos)
{
name = s.substr(separator2 + 1,separator3 - separator2 - 1);
}
} }
string nbstr = s.substr(separator + 1, separator2 - separator - 1); string nbstr = s.substr(separator + 1, separator2 - separator - 1);
WParsedInt * wpi; WParsedInt * wpi;
@@ -241,6 +248,22 @@ Counter * AbilityFactory::parseCounter(string s, MTGCardInstance * target, Spell
} }
nb = wpi->getValue(); nb = wpi->getValue();
delete (wpi); delete (wpi);
string maxNbstr;
if (separator3 != string::npos)
{
maxNbstr = s.substr(separator3 + 1, end - separator3 - 1);
WParsedInt * wpinb;
if (target)
{
wpinb = NEW WParsedInt(maxNbstr, spell, target);
}
else
{
wpinb = NEW WParsedInt(atoi(maxNbstr.c_str()));
}
maxNb = wpinb->getValue();
delete(wpinb);
}
end = separator; end = separator;
} }
@@ -250,6 +273,7 @@ Counter * AbilityFactory::parseCounter(string s, MTGCardInstance * target, Spell
{ {
Counter * counter = NEW Counter(target, name.c_str(), power, toughness); Counter * counter = NEW Counter(target, name.c_str(), power, toughness);
counter->nb = nb; counter->nb = nb;
counter->maxNb = maxNb;
return counter; return counter;
} }
return NULL; return NULL;
@@ -2330,7 +2354,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
if (counter) if (counter)
{ {
MTGAbility * a = MTGAbility * a =
NEW AACounter(id, card, target,counterString, counter->name.c_str(), counter->power, counter->toughness, counter->nb); NEW AACounter(id, card, target,counterString, counter->name.c_str(), counter->power, counter->toughness, counter->nb,counter->maxNb);
delete (counter); delete (counter);
a->oneShot = 1; a->oneShot = 1;
return a; return a;