From 89fb3519793a7b595147ef9733f7d7bf45d5867d Mon Sep 17 00:00:00 2001 From: "wagic.the.homebrew@gmail.com" Date: Thu, 30 Apr 2009 13:48:41 +0000 Subject: [PATCH] Erwan - Added damage all (pyroclasm) and move all (not tested) --- projects/mtg/bin/Res/sets/10E/_cards.dat | 58 ++++++++++++ projects/mtg/bin/Res/sets/10E/todo.dat | 54 ++--------- projects/mtg/bin/Res/test/_tests.txt | 2 + projects/mtg/bin/Res/test/pyroclasm.txt | 20 +++++ projects/mtg/include/MTGAbility.h | 2 + projects/mtg/src/MTGAbility.cpp | 110 +++++++++++++++-------- 6 files changed, 162 insertions(+), 84 deletions(-) create mode 100644 projects/mtg/bin/Res/test/pyroclasm.txt diff --git a/projects/mtg/bin/Res/sets/10E/_cards.dat b/projects/mtg/bin/Res/sets/10E/_cards.dat index e75e05b59..0f0ef04af 100644 --- a/projects/mtg/bin/Res/sets/10E/_cards.dat +++ b/projects/mtg/bin/Res/sets/10E/_cards.dat @@ -1411,6 +1411,17 @@ subtype=Thopter toughness=2 [/card] [card] +text=Creatures you control get +3/+3 and gain trample until end of turn. (If a creature you control would deal enough combat damage to its blockers to destroy them, you may have it deal the rest of its damage to defending player.) +auto=lord(creatures|myinplay) 3/3 +auto=lord(creatures|myinplay) trample +id=130506 +name=Overrun +rarity=U +color=Green +type=Sorcery +mana={2}{G}{G}{G} +[/card] +[card] text=Enchant creature (Target a creature as you play this. This card comes into play attached to that creature.) Enchanted creature can't attack or block. id=129667 name=Pacifism @@ -1585,6 +1596,16 @@ subtype=Human Wizard toughness=1 [/card] [card] +text=Pyroclasm deals 2 damage to each creature. +auto=damage:2 all(creature) +id=129801 +name=Pyroclasm +rarity=U +color=Red +type=Sorcery +mana={1}{R} +[/card] +[card] text={T}: Add {1} to your mana pool. {T}, Sacrifice Quicksand: Target attacking creature without flying gets -1/-2 until end of turn. auto={T}:Add{1} auto={T}{S}:-1/-2 target(creature[attacking;-flying]) @@ -2078,6 +2099,19 @@ subtype=Wurm toughness=4 [/card] [card] +text=Spineless Thug can't block. +abilities=cantblock +id=129743 +name=Spineless Thug +rarity=C +color=Black +type=Creature +mana={1}{B} +power=2 +subtype=Zombie Mercenary +toughness=2 +[/card] +[card] text=Enchant creature (Target a creature as you play this. This card comes into play attached to that creature.) Whenever enchanted creature deals damage, you gain that much life. target=creature auto=lifelink @@ -2298,6 +2332,20 @@ subtype=Wolf toughness=1 [/card] [card] +text=Flash (You may play this spell any time you could play an instant.) Enchant creature (Target a creature as you play this. This card comes into play attached to that creature.) Enchanted creature gets +2/+2 and attacks each turn if able. +abilities=flash +target=creature +auto=2/2 +auto=mustattack +id=134756 +name=Uncontrollable Anger +rarity=C +color=Red +type=Enchantment +mana={2}{R}{R} +subtype=Aura +[/card] +[card] text={T}: Add {1} to your mana pool. {T}: Add {U} or {B} to your mana pool. Underground River deals 1 damage to you. id=129778 auto={T}:Add {1} @@ -2425,6 +2473,16 @@ subtype=Wall toughness=3 [/card] [card] +text=Creatures you control get +1/+1 until end of turn. +auto=lord(creatures|myinplay) 1/1 +id=129797 +name=Warrior's Honor +rarity=C +color=White +type=Instant +mana={2}{W} +[/card] +[card] text=Flying (This creature can't be blocked except by creatures with flying or reach.) abilities=flying id=129557 diff --git a/projects/mtg/bin/Res/sets/10E/todo.dat b/projects/mtg/bin/Res/sets/10E/todo.dat index f1b278f97..2513cf742 100644 --- a/projects/mtg/bin/Res/sets/10E/todo.dat +++ b/projects/mtg/bin/Res/sets/10E/todo.dat @@ -1023,15 +1023,7 @@ type=Enchantment mana={2}{G} subtype=Aura [/card] -[card] -text=Creatures you control get +3/+3 and gain trample until end of turn. (If a creature you control would deal enough combat damage to its blockers to destroy them, you may have it deal the rest of its damage to defending player.) -id=130506 -name=Overrun -rarity=U -color=Green -type=Sorcery -mana={2}{G}{G}{G} -[/card] + [card] text=Enchant creature (Target a creature as you play this. This card comes into play attached to that creature.) All damage that would be dealt to you is dealt to enchanted creature instead. id=135248 @@ -1106,15 +1098,7 @@ power=1 subtype=Human Wizard toughness=2 [/card] -[card] -text=Pyroclasm deals 2 damage to each creature. -id=129801 -name=Pyroclasm -rarity=U -color=Red -type=Sorcery -mana={1}{R} -[/card] + [card] text=Whenever you play a white, blue, black, or red spell, put a +1/+1 counter on Quirion Dryad. @@ -1421,18 +1405,7 @@ power=1 subtype=Drake toughness=1 [/card] -[card] -text=Spineless Thug can't block. -id=129743 -name=Spineless Thug -rarity=C -color=Black -type=Creature -mana={1}{B} -power=2 -subtype=Zombie Mercenary -toughness=2 -[/card] + [card] text=Spitting Earth deals damage equal to the number of Mountains you control to target creature. id=136509 @@ -1696,16 +1669,7 @@ color=Blue type=Instant mana={2}{U} [/card] -[card] -text=Flash (You may play this spell any time you could play an instant.) Enchant creature (Target a creature as you play this. This card comes into play attached to that creature.) Enchanted creature gets +2/+2 and attacks each turn if able. -id=134756 -name=Uncontrollable Anger -rarity=C -color=Red -type=Enchantment -mana={2}{R}{R} -subtype=Aura -[/card] + [card] text=Whenever an opponent draws a card, Underworld Dreams deals 1 damage to him or her. id=129779 @@ -1793,15 +1757,7 @@ color=Red type=Sorcery mana={5}{R}{R}{R} [/card] -[card] -text=Creatures you control get +1/+1 until end of turn. -id=129797 -name=Warrior's Honor -rarity=C -color=White -type=Instant -mana={2}{W} -[/card] + [card] text=Equipped creature is unblockable and has shroud. (It can't be the target of spells or abilities.) Equip {2} ({2}: Attach to target creature you control. Equip only as a sorcery.) id=135278 diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index f6bb46217..5d79c1581 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -87,6 +87,7 @@ paralysis2.txt persuasion.txt plague_rats.txt protomatter_powder.txt +pyroclasm.txt resurrection.txt rootwalla.txt royal_assassin.txt @@ -114,3 +115,4 @@ zombify.txt #Momir Basic Tests ######################## momir/keldon_warlord.txt + diff --git a/projects/mtg/bin/Res/test/pyroclasm.txt b/projects/mtg/bin/Res/test/pyroclasm.txt new file mode 100644 index 000000000..19fd71d58 --- /dev/null +++ b/projects/mtg/bin/Res/test/pyroclasm.txt @@ -0,0 +1,20 @@ +#Testing Pyroclasm +[INIT] +FIRSTMAIN +[PLAYER1] +hand:pyroclasm +inplay:air elemental,rage weaver +manapool:{1}{R} +[PLAYER2] +inplay:grizzly bears,relentless rats +[DO] +pyroclasm +[ASSERT] +FIRSTMAIN +[PLAYER1] +graveyard:pyroclasm,rage weaver +inplay:air elemental +manapool:{0} +[PLAYER2] +graveyard:grizzly bears,relentless rats +[END] \ No newline at end of file diff --git a/projects/mtg/include/MTGAbility.h b/projects/mtg/include/MTGAbility.h index 2fbaa6277..50cc9c652 100644 --- a/projects/mtg/include/MTGAbility.h +++ b/projects/mtg/include/MTGAbility.h @@ -226,6 +226,8 @@ class AbilityFactory{ public: int magicText(int id, Spell * spell, MTGCardInstance * card = NULL); int destroyAllInPlay(TargetChooser * tc, int bury = 0); + int moveAll(TargetChooser * tc, string destinationZone); + int damageAll(TargetChooser * tc, int damage); void addAbilities(int _id, Spell * spell); }; diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 0117a2a49..5741b2302 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -49,6 +49,40 @@ int AbilityFactory::destroyAllInPlay(TargetChooser * tc, int bury){ return 1; } +int AbilityFactory::damageAll(TargetChooser * tc, int damage){ + MTGCardInstance * source = tc->source; + tc->source = NULL; // This is to prevent protection from... as objects that destroy all do not actually target + GameObserver * g = GameObserver::GetInstance(); + for (int i = 0; i < 2 ; i++){ + for (int j = g->players[i]->game->inPlay->nb_cards-1; j >=0 ; j--){ + MTGCardInstance * current = g->players[i]->game->inPlay->cards[j]; + if (tc->canTarget(current)){ + g->mLayers->stackLayer()->addDamage(source,current, damage); + } + } + } + return 1; +} + + + +int AbilityFactory::moveAll(TargetChooser * tc, string destinationZone){ + MTGCardInstance * source = tc->source; + tc->source = NULL; // This is to prevent protection from... as objects that destroy all do not actually target + GameObserver * g = GameObserver::GetInstance(); + for (int i = 0; i < 2 ; i++){ + for (int j = g->players[i]->game->inPlay->nb_cards-1; j >=0 ; j--){ + MTGCardInstance * current = g->players[i]->game->inPlay->cards[j]; + if (tc->canTarget(current)){ + AZoneMover::moveTarget(current,destinationZone , source); + } + } + } + return 1; +} + + + int AbilityFactory::putInPlayFromZone(MTGCardInstance * card, MTGGameZone * zone, Player * p){ MTGCardInstance * copy = p->game->putInZone(card, zone, p->game->stack); @@ -206,7 +240,7 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){ s = s.substr(found+1); } - + int all = 0; //Target Abilities found = s.find("target("); if (found != string::npos){ @@ -215,8 +249,18 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){ TargetChooserFactory tcf; tc = tcf.createTargetChooser(starget, card); + }else{ + found = s.find("all("); + if (found != string::npos){ + all = 1; + int end = s.find(")", found); + string starget = s.substr(found + 4,end - found -4); + TargetChooserFactory tcf; + tc = tcf.createTargetChooser(starget, card); + } } + //Lord found = s.find("lord("); if (found != string::npos){ @@ -352,14 +396,16 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){ int end = s.find(")",found+1); string szone = s.substr(found + 7,end - found - 7); if (tc){ - //if (cost){ + if (all){ + moveAll(tc,szone); + }else{ AZoneMover * a = NEW AZoneMover(id,card,tc,szone,cost,doTap); if (may){ game->addObserver(NEW MayAbility(id,a,card)); }else{ game->addObserver(a); } - // } + } }else{ if (cost){ MTGAbility * a = NEW AZoneSelfMover(id,card,szone,cost,doTap); @@ -411,27 +457,22 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){ BuryEvent * action = NEW BuryEvent(); game->addObserver(NEW GenericTriggeredAbility(id, card,trigger,action)); }else{ - found = s.find("all("); - if (found != string::npos){ - int end = s.find(")"); - string starget = s.substr(found + 4,end - found - 4); - TargetChooserFactory tcf; - TargetChooser * targetAll = tcf.createTargetChooser(starget, card); + if (all){ if (dryMode){ - int myNbCards = countCards(targetAll,card->controller()); - int opponentNbCards = countCards(targetAll, card->controller()->opponent()); - int myCardsPower = countCards(targetAll,card->controller(),COUNT_POWER); - int opponentCardsPower = countCards(targetAll, card->controller()->opponent(),COUNT_POWER); - delete targetAll; + int myNbCards = countCards(tc,card->controller()); + int opponentNbCards = countCards(tc, card->controller()->opponent()); + int myCardsPower = countCards(tc,card->controller(),COUNT_POWER); + int opponentCardsPower = countCards(tc, card->controller()->opponent(),COUNT_POWER); + SAFE_DELETE(tc); if (myNbCards < opponentNbCards || myCardsPower < opponentCardsPower) dryModeResult = BAKA_EFFECT_GOOD; else dryModeResult = BAKA_EFFECT_BAD; break; }else{ if (cost){ - game->addObserver(NEW AAllDestroyer(id, card,targetAll,1,cost,doTap)); + game->addObserver(NEW AAllDestroyer(id, card,tc,1,cost,doTap)); }else{ - this->destroyAllInPlay(targetAll,1); - delete targetAll; + this->destroyAllInPlay(tc,1); + SAFE_DELETE(tc); } } }else{ @@ -454,27 +495,22 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){ found = s.find("destroy"); if (found != string::npos){ - found = s.find("all("); - if (found != string::npos){ - int end = s.find(")"); - string starget = s.substr(found + 4,end - found - 4); - TargetChooserFactory tcf; - TargetChooser * targetAll = tcf.createTargetChooser(starget, card); + if (all){ if (dryMode){ - int myNbCards = countCards(targetAll,card->controller()); - int opponentNbCards = countCards(targetAll, card->controller()->opponent()); - int myCardsPower = countCards(targetAll,card->controller(),COUNT_POWER); - int opponentCardsPower = countCards(targetAll, card->controller()->opponent(),COUNT_POWER); - delete targetAll; + int myNbCards = countCards(tc,card->controller()); + int opponentNbCards = countCards(tc, card->controller()->opponent()); + int myCardsPower = countCards(tc,card->controller(),COUNT_POWER); + int opponentCardsPower = countCards(tc, card->controller()->opponent(),COUNT_POWER); + SAFE_DELETE(tc); if (myNbCards < opponentNbCards || myCardsPower < opponentCardsPower) dryModeResult = BAKA_EFFECT_GOOD; else dryModeResult = BAKA_EFFECT_BAD; break; }else{ if (cost){ - game->addObserver(NEW AAllDestroyer(id, card,targetAll,0,cost,doTap)); + game->addObserver(NEW AAllDestroyer(id, card,tc,0,cost,doTap)); }else{ - this->destroyAllInPlay(targetAll); - delete targetAll; + this->destroyAllInPlay(tc); + SAFE_DELETE(tc); } } }else{ @@ -509,11 +545,15 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){ break; } if (tc){ - MTGAbility * a = NEW ADamager(id, card, cost, damage, tc,doTap); - if (multi){ - multi->Add(a); + if (all){ + damageAll(tc,damage); }else{ - game->addObserver(a); + MTGAbility * a = NEW ADamager(id, card, cost, damage, tc,doTap); + if (multi){ + multi->Add(a); + }else{ + game->addObserver(a); + } } }else{ if (multi){