added a "while " tag for aslongas effects which are not supposed to be treated as oneshot abilities. adding it as a tag allows for maximum flexibility in the code.

while i was at it reworked the aslongas class completely, i promised myself if another bug popped up with aslongas i would rewrite it. 20 hours later, we have an aslongas which does not care about when cards come or go.
aslongas should never have used the added/removed to determine the validity of its effect. i allow update to sort it out now in the update function of aslongas...also added a new function to it called sorterfunction tho it looks as it could be reduced in code i would appreciate that it remains as it is, simply because of the nightmare i went through fixing the previous 7 bugs or more reported for aslongas. the logic was far to jumbled up. this i hope is atleast cleaner and easier to understand for the future devs that might work on it.

note: all test passed, all manual testing also passed.

new while tag is used as follows.

[card]
name=Emperor Crocodile
auto=aslongas(other creature|myBattlefield) all(this) sacrifice while <1
text=When you control no other creatures, sacrifice Emperor Crocodile.
mana={3}{G}
type=Creature
subtype=Crocodile
power=5
toughness=5
[/card]

this will denote that the ability is NOT a oneshot ability and should remain effective for the entire time the card is in the field.
Issue: 613
This commit is contained in:
omegablast2002@yahoo.com
2011-03-27 14:37:12 +00:00
parent 45566ad5bd
commit 7d98628355
2 changed files with 92 additions and 54 deletions
+18 -1
View File
@@ -1291,6 +1291,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
oneShot = 1;
if (a->oneShot)
oneShot = 1;
found = s.find("while ");
if (found != string::npos)
oneShot = 0;
Damageable * _target = NULL;
if (spell)
_target = spell->getNextDamageableTarget();
@@ -1299,14 +1302,22 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
int mini = 0;
int maxi = 0;
bool miniFound = false;
bool maxiFound = false;
found = s.find(" >");
if (found != string::npos)
{
mini = atoi(s.substr(found + 2, 3).c_str());
miniFound = true;
}
found = s.find(" <");
if (found != string::npos)
{
maxi = atoi(s.substr(found + 2, 3).c_str());
maxiFound = true;
}
switch (i)
{
@@ -1317,7 +1328,13 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
result = NEW AForeach(id, card, _target, lordTargets, lordIncludeSelf, a, mini, maxi);
break;
case 2:
result = NEW AAsLongAs(id, card, _target, lordTargets, lordIncludeSelf, a, mini, maxi);
{
if (!miniFound && !maxiFound)//for code without an operator treat as a mini.
{
miniFound = true;
}
result = NEW AAsLongAs(id, card, _target, lordTargets, lordIncludeSelf, a, mini, maxi,miniFound,maxiFound);
}
break;
case 3:
result = NEW ATeach(id, card, lordTargets, lordIncludeSelf, a);