diff --git a/projects/mtg/bin/Res/sets/TSP/_cards.dat b/projects/mtg/bin/Res/sets/TSP/_cards.dat index 5d0403307..af1bb6ed8 100644 --- a/projects/mtg/bin/Res/sets/TSP/_cards.dat +++ b/projects/mtg/bin/Res/sets/TSP/_cards.dat @@ -557,7 +557,7 @@ subtype=Sliver power=2 toughness=2 text=All Sliver creatures have "This creature gets +1/+1 as long as you control a Swamp." All Slivers have "{B}: Regenerate this permanent." -auto=lord(sliver) aslongas(swamp|myinplay) 1/1 +auto=aslongas(swamp|myinplay) lord(sliver) 1/1 auto=lord(sliver) {B}:regenerate rarity=R [/card] diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index dd38a34e9..8ec976a42 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -39,6 +39,8 @@ ascendant_evincar2.txt ascendant_evincar3.txt ashen_firebeast.txt ashen_firebeast2.txt +barbed_sliver.txt +basal_sliver.txt beacon_of_unrest.txt #befoul.txt blessed_wine.txt @@ -141,6 +143,7 @@ resurrection.txt righteous_cause.txt rootwalla.txt royal_assassin.txt +sedge_sliver.txt seismic_assault.txt siege_gang_commander.txt shivan_hellkite.txt diff --git a/projects/mtg/bin/Res/test/barbed_sliver.txt b/projects/mtg/bin/Res/test/barbed_sliver.txt new file mode 100644 index 000000000..4833464e3 --- /dev/null +++ b/projects/mtg/bin/Res/test/barbed_sliver.txt @@ -0,0 +1,27 @@ +#Bug:barbed sliver's ability gives +1/+0 to itself +[INIT] +FIRSTMAIN +[PLAYER1] +inplay:barbed sliver,metallic sliver +manapool:{2} +[PLAYER2] +[DO] +metallic sliver +next +#begin +next +#attackers +metallic sliver +next +#blockers +next +#damage +next +#end +[ASSERT] +COMBATEND +[PLAYER1] +inplay:barbed sliver,metallic sliver +[PLAYER2] +life:18 +[END] \ No newline at end of file diff --git a/projects/mtg/bin/Res/test/basal_sliver.txt b/projects/mtg/bin/Res/test/basal_sliver.txt new file mode 100644 index 000000000..e05f7a1f5 --- /dev/null +++ b/projects/mtg/bin/Res/test/basal_sliver.txt @@ -0,0 +1,16 @@ +#Bug:basal sliver's ability doesn't give mana +[INIT] +FIRSTMAIN +[PLAYER1] +inplay:basal sliver,metallic sliver +[PLAYER2] +[DO] +metallic sliver +[ASSERT] +FIRSTMAIN +[PLAYER1] +inplay:basal sliver +graveyard:metallic sliver +manapool:{B}{B} +[PLAYER2] +[END] \ No newline at end of file diff --git a/projects/mtg/bin/Res/test/sedge_sliver.txt b/projects/mtg/bin/Res/test/sedge_sliver.txt new file mode 100644 index 000000000..1fa9824f7 --- /dev/null +++ b/projects/mtg/bin/Res/test/sedge_sliver.txt @@ -0,0 +1,21 @@ +#Bug:sedge sliver's ability gives +1/+1 to itself +[INIT] +COMBATATTACKERS +[PLAYER1] +inplay:sedge sliver,metallic sliver,swamp +[PLAYER2] +[DO] +metallic sliver +next +#blockers +next +#damage +next +#end +[ASSERT] +COMBATEND +[PLAYER1] +inplay:sedge sliver,metallic sliver,swamp +[PLAYER2] +life:18 +[END] \ No newline at end of file diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 6927b7841..049bcb35a 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -240,6 +240,7 @@ class GenericActivatedAbility:public ActivatedAbility{ int resolve(){ counters++; + ability->target = target; //may have been updated... if (ability) return ability->resolve(); return 0; } diff --git a/projects/mtg/include/MTGAbility.h b/projects/mtg/include/MTGAbility.h index ed5a569c9..094300e22 100644 --- a/projects/mtg/include/MTGAbility.h +++ b/projects/mtg/include/MTGAbility.h @@ -236,6 +236,7 @@ class AManaProducer: public MTGAbility{ void Render(); int isReactingToClick(MTGCardInstance * _card, ManaCost * mana = NULL); int resolve(); + int destroy(); int reactToClick(MTGCardInstance * _card); const char * getMenuText(); int testDestroy(); diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 790625fe8..ed7110643 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -244,52 +244,58 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG //Lord, foreach, aslongas string lords[] = {"lord(","foreach(", "aslongas(", "all("}; - for (int i = 0; i < 4; ++i){ - found = s.find(lords[i]); - if (found != string::npos){ - size_t header = lords[i].size(); - size_t end = s.find(")", found+header); - string s1; - if (found == 0 || end != s.size()-1){ - s1 = s.substr(end+1); - }else{ - s1 = s.substr(0, found); - } - if (end != string::npos){ - int lordIncludeSelf = 1; - size_t other = s.find("other", end); - if ( other != string::npos){ - lordIncludeSelf = 0; - s.replace(other, 5,""); - } - string lordTargetsString = s.substr(found+header,end-found-header); - TargetChooserFactory tcf; - TargetChooser * lordTargets = tcf.createTargetChooser(lordTargetsString, card); - - - MTGAbility * a = parseMagicLine(s1,id,spell, card); - if (!a){ - SAFE_DELETE(lordTargets); - return NULL; - } - MTGAbility * result = NULL; - int oneShot = 0; - if (card->hasType("sorcery") || card->hasType("instant")) oneShot = 1; - if (i == 3) oneShot = 1; - if (a->oneShot) oneShot = 1; - switch(i){ - case 0: result = NEW ALord(id, card, lordTargets, lordIncludeSelf, a); break; - case 1: result = NEW AForeach(id, card, target,lordTargets, lordIncludeSelf, a); break; - case 2: result = NEW AAsLongAs(id, card, lordTargets, lordIncludeSelf, a); break; - case 3: result = NEW ALord(id, card, lordTargets, lordIncludeSelf, a); break; - default: result = NULL; - } - if (result) result->oneShot = oneShot; - return result; - } - return NULL; + found = string::npos; + int i = -1; + for (int j = 0; j < 4; ++j){ + size_t found2 = s.find(lords[j]); + if (found2!=string::npos && ((found == string::npos) || found2 < found)){ + found = found2; + i = j; } } + if (found != string::npos){ + size_t header = lords[i].size(); + size_t end = s.find(")", found+header); + string s1; + if (found == 0 || end != s.size()-1){ + s1 = s.substr(end+1); + }else{ + s1 = s.substr(0, found); + } + if (end != string::npos){ + int lordIncludeSelf = 1; + size_t other = s.find("other", end); + if ( other != string::npos){ + lordIncludeSelf = 0; + s.replace(other, 5,""); + } + string lordTargetsString = s.substr(found+header,end-found-header); + TargetChooserFactory tcf; + TargetChooser * lordTargets = tcf.createTargetChooser(lordTargetsString, card); + + + MTGAbility * a = parseMagicLine(s1,id,spell, card); + if (!a){ + SAFE_DELETE(lordTargets); + return NULL; + } + MTGAbility * result = NULL; + int oneShot = 0; + if (card->hasType("sorcery") || card->hasType("instant")) oneShot = 1; + if (i == 3) oneShot = 1; + if (a->oneShot) oneShot = 1; + switch(i){ + case 0: result = NEW ALord(id, card, lordTargets, lordIncludeSelf, a); break; + case 1: result = NEW AForeach(id, card, target,lordTargets, lordIncludeSelf, a); break; + case 2: result = NEW AAsLongAs(id, card, lordTargets, lordIncludeSelf, a); break; + case 3: result = NEW ALord(id, card, lordTargets, lordIncludeSelf, a); break; + default: result = NULL; + } + if (result) result->oneShot = oneShot; + return result; + } + return NULL; + } //Fizzle (counterspell...) @@ -2420,10 +2426,7 @@ other solutions need to be provided for abilities that add mana (ex: mana flare) animation -= 4 *dt; if (!animation) animation = -1; if (animation < 0){ - animation = 0; - currentlyTapping--; resolve(); - if (mParticleSys) mParticleSys->Stop(); } } @@ -2450,8 +2453,11 @@ other solutions need to be provided for abilities that add mana (ex: mana flare) } int AManaProducer::resolve(){ + animation = 0; + if (currentlyTapping > 0) currentlyTapping--; controller = source->controller(); controller->getManaPool()->add(output); + if (mParticleSys) mParticleSys->Stop(); return 1; } @@ -2488,6 +2494,11 @@ other solutions need to be provided for abilities that add mana (ex: mana flare) return 1; } + int AManaProducer::destroy(){ + if (animation >0) resolve(); //if we get destroyed while the animation was taking place (dirty...) + return MTGAbility::destroy(); + } + const char * AManaProducer::getMenuText(){ if (menutext.size())return menutext.c_str(); menutext = "Add ";