From ce0051e545559bfab76b9758efe750bb6113ca7e Mon Sep 17 00:00:00 2001 From: "wagic.the.homebrew@gmail.com" Date: Thu, 12 Nov 2009 13:57:22 +0000 Subject: [PATCH] Erwan - fix issue 154 (dragon whelp) - Fix issue 157 (erg raiders) - fix issue 169 (living artifact) - fix issue 159 (stonebrow) although I believe this card doesn't work correctly... --- projects/mtg/bin/Res/sets/TSP/_cards.dat | 2 +- projects/mtg/bin/Res/test/_tests.txt | 4 ++ .../Res/test/bugs/living_artifact_i169.txt | 67 ------------------- .../Res/test/{bugs => }/dragon_whelp_i154.txt | 0 .../Res/test/{bugs => }/erg_raiders_i157.txt | 0 .../mtg/bin/Res/test/living_artifact_i169.txt | 24 +++++++ .../Res/test/{bugs => }/stonebrow_i159.txt | 0 projects/mtg/include/AllAbilities.h | 58 +++++++--------- projects/mtg/src/MTGAbility.cpp | 8 ++- 9 files changed, 61 insertions(+), 102 deletions(-) delete mode 100644 projects/mtg/bin/Res/test/bugs/living_artifact_i169.txt rename projects/mtg/bin/Res/test/{bugs => }/dragon_whelp_i154.txt (100%) rename projects/mtg/bin/Res/test/{bugs => }/erg_raiders_i157.txt (100%) create mode 100644 projects/mtg/bin/Res/test/living_artifact_i169.txt rename projects/mtg/bin/Res/test/{bugs => }/stonebrow_i159.txt (100%) diff --git a/projects/mtg/bin/Res/sets/TSP/_cards.dat b/projects/mtg/bin/Res/sets/TSP/_cards.dat index 00a500871..b348662ef 100644 --- a/projects/mtg/bin/Res/sets/TSP/_cards.dat +++ b/projects/mtg/bin/Res/sets/TSP/_cards.dat @@ -683,7 +683,7 @@ rarity=R mana={3}{R}{G} type=Creature subtype=Centaur Warrior -auto=lord(creature[attacking,trample]|myBattlefield) 2/2 +auto=lord(creature[attacking;trample]|myBattlefield) 2/2 power=4 toughness=4 abilities=legendary,trample diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index 2ced45052..78f1c8b3c 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -111,6 +111,7 @@ dingus_egg.txt doomed_necromancer.txt dragon_fodder.txt dragon_fodder2.txt +dragon_whelp_i154.txt drain_life.txt drift_of_the_dead.txt dromad_purebred.txt @@ -119,6 +120,7 @@ duskwalker.txt elvish_piper.txt elvish_promenade.txt emblem_of_the_warmind.txt +erg_raiders_i157.txt flagstones.txt farhaven_elf.txt fastbond.txt @@ -172,6 +174,7 @@ lhurgoyf.txt liability.txt lifeforce.txt lifetap.txt +living_artifact_i169.txt living_lands.txt lord_of_the_pit.txt lord_of_the_pit2.txt @@ -243,6 +246,7 @@ stasis.txt steelclad_serpent1.txt steelclad_serpent2.txt stillmoon_cavalier.txt +stonebrow_i159.txt stronghold_discipline.txt sword_to_plowshares.txt symbiotic_wurm.txt diff --git a/projects/mtg/bin/Res/test/bugs/living_artifact_i169.txt b/projects/mtg/bin/Res/test/bugs/living_artifact_i169.txt deleted file mode 100644 index fb2ee084e..000000000 --- a/projects/mtg/bin/Res/test/bugs/living_artifact_i169.txt +++ /dev/null @@ -1,67 +0,0 @@ -#NAME: Living Artifact -#DESC: I checked an old bug list entry claiming that -#DESC: Living Artifact "gives you one life whenever -#DESC: a card is tapped". I couldn't reproduce that. -#DESC: However, I couldn't produce *any* effect from -#DESC: Living Artifact either. -#DESC: The script first tests for the condition of -#DESC: the bug report mentioned above, then tries to -#DESC: activate Living Artifact when it should be -#DESC: possible. The Assert part may need tweaking -#DESC: since I have no way of knowing how Living -#DESC: Artifact is assumed to be activated correctly. -#DESC: See http://code.google.com/p/wagic/issues/detail?id=169 -[INIT] -firstmain -[PLAYER1] -inplay:Forest,Sol Ring,Craw Wurm -hand:Living Artifact -library:Plains -manapool:{G} -[PLAYER2] -inplay:Grizzly Bears -library:Swamp,Mountain -[DO] -Living Artifact -Sol Ring -next -next -# Try a couple of things that should NOT put -# counters on Living Artifact -Forest -Sol Ring -Craw Wurm -eot -# 2nd player does nothing: -eot -# 1st player tries to use Living Artifact. This should -# have NO effect at this stage. -next -Living Artifact -eot -# 2nd player attacks: -next -next -next -next -next -Grizzly Bears -eot -# 1st player tries to use Living Artifact. This should -# work now since he has sustained damage -next -Living Artifact -[ASSERT] -upkeep -[PLAYER1] -inplay:Forest,Sol Ring,Craw Wurm,Living Artifact -hand:Plains -library: -life:19 -manapool: -[PLAYER2] -inplay:Grizzly Bears -hand:Swamp,Mountain -library: -life:14 -[END] diff --git a/projects/mtg/bin/Res/test/bugs/dragon_whelp_i154.txt b/projects/mtg/bin/Res/test/dragon_whelp_i154.txt similarity index 100% rename from projects/mtg/bin/Res/test/bugs/dragon_whelp_i154.txt rename to projects/mtg/bin/Res/test/dragon_whelp_i154.txt diff --git a/projects/mtg/bin/Res/test/bugs/erg_raiders_i157.txt b/projects/mtg/bin/Res/test/erg_raiders_i157.txt similarity index 100% rename from projects/mtg/bin/Res/test/bugs/erg_raiders_i157.txt rename to projects/mtg/bin/Res/test/erg_raiders_i157.txt diff --git a/projects/mtg/bin/Res/test/living_artifact_i169.txt b/projects/mtg/bin/Res/test/living_artifact_i169.txt new file mode 100644 index 000000000..d036616e7 --- /dev/null +++ b/projects/mtg/bin/Res/test/living_artifact_i169.txt @@ -0,0 +1,24 @@ +#NAME: Living Artifact +#DESC: See http://code.google.com/p/wagic/issues/detail?id=169 +[INIT] +firstmain +[PLAYER1] +inplay:Sol Ring +hand:Living Artifact,shock +manapool:{G}{R} +[PLAYER2] +[DO] +Living Artifact +Sol Ring +shock +p1 +Living Artifact +Living Artifact +[ASSERT] +firstmain +[PLAYER1] +inplay:Sol Ring,Living Artifact +life:19 +graveyard:shock +[PLAYER2] +[END] diff --git a/projects/mtg/bin/Res/test/bugs/stonebrow_i159.txt b/projects/mtg/bin/Res/test/stonebrow_i159.txt similarity index 100% rename from projects/mtg/bin/Res/test/bugs/stonebrow_i159.txt rename to projects/mtg/bin/Res/test/stonebrow_i159.txt diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 9294c7540..3204b590e 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -990,6 +990,10 @@ class ASpellCastLife:public MTGAbility{ return a; } + ~ASpellCastLife(){ + SAFE_DELETE(cost); + } + }; //Allows to untap at any moment for an amount of mana @@ -1212,7 +1216,7 @@ class APowerToughnessModifierUntilEndOfTurn: public ActivatedAbility{ } void Update(float dt){ - if (newPhase != currentPhase && newPhase ==Constants::MTG_PHASE_AFTER_EOT){ + if (newPhase != currentPhase && newPhase == Constants::MTG_PHASE_AFTER_EOT){ counters = 0; } ActivatedAbility::Update(dt); @@ -2786,16 +2790,14 @@ class ALivingArtifact:public MTGAbility{ latest = NULL; } - void Update(float dt){ - if (newPhase != currentPhase && newPhase == Constants::MTG_PHASE_UNTAP) usedThisTurn = 0; - Damage * damage = ((Damage *)game->mLayers->stackLayer()->getNext(latest,ACTION_DAMAGE,RESOLVED_OK)); - while (damage){ - if (damage->target == source->controller()){ - counters += damage->damage; - } - latest = damage; - damage = ((Damage *)game->mLayers->stackLayer()->getNext(damage,ACTION_DAMAGE,RESOLVED_OK)); - } + int receiveEvent(WEvent * event){ + WEventDamage * e = dynamic_cast(event); + if (!e) return 0; + Player * p = dynamic_cast(e->damage->target); + if (!p) return 0; + if (p != source->controller()) return 0; + counters+=e->damage->damage; + return 1; //is this meant to return 0 or 1? } int isReactingtoclick(MTGCardInstance * card, ManaCost * mana = NULL){ @@ -2914,38 +2916,28 @@ class AAnimateDead:public MTGAbility{ //1159 Erg Raiders class AErgRaiders:public MTGAbility{ public: - int init; - int dealDamage; + int attackedThisTurn; AErgRaiders(int _id, MTGCardInstance * _source):MTGAbility(_id, _source){ - init = 0; - dealDamage = 0; + attackedThisTurn = 1; } void Update(float dt){ if (newPhase != currentPhase){ Player * controller = source->controller(); if (newPhase == Constants::MTG_PHASE_COMBATDAMAGE && game->currentPlayer == controller){ - if (!source->isAttacker() && init){ - dealDamage = 1; - } - }else if (newPhase == Constants::MTG_PHASE_UNTAP && game->currentPlayer != controller){ - if (dealDamage){ - game->mLayers->stackLayer()->addDamage(source, controller,2); - } - init = 1; - dealDamage = 0; + if (source->isAttacker()){ + attackedThisTurn = 1; + } + }else if (newPhase == Constants::MTG_PHASE_UNTAP){ + if (game->currentPlayer != controller && !attackedThisTurn){ + game->mLayers->stackLayer()->addDamage(source, controller,2); + }else if (game->currentPlayer == controller) { + attackedThisTurn = 0; + } } } - } - virtual ostream& toString(ostream& out) const - { - out << "AErgRaiders ::: init : " << init - << " ; dealDamage : " << dealDamage - << " ("; - return MTGAbility::toString(out) << ")"; - } AErgRaiders * clone() const{ AErgRaiders * a = NEW AErgRaiders(*this); a->isClone = 1; @@ -3396,7 +3388,7 @@ class ADragonWhelp: public APowerToughnessModifierUntilEndOfTurn{ } void Update(float dt){ - if (newPhase != currentPhase && newPhase == Constants::MTG_PHASE_UNTAP && counters > 3){ + if (newPhase != currentPhase && newPhase == Constants::MTG_PHASE_AFTER_EOT && counters > 3){ source->controller()->game->putInGraveyard(source); } APowerToughnessModifierUntilEndOfTurn::Update(dt); diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 194a76196..5983db98f 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -325,7 +325,13 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG TargetChooserFactory tcf; TargetChooser * lordTargets = tcf.createTargetChooser(lordTargetsString, card); - + if (!lordTargets){ + OutputDebugString("MTGABILITY: Parsing Error:"); + OutputDebugString(s.c_str()); + OutputDebugString("\n"); + return NULL; + } + MTGAbility * a = parseMagicLine(s1,id,spell, card,0,activated); //activated lords usually force an end of turn ability if (!a){ SAFE_DELETE(lordTargets);