From 1d55211245f6812b1177cf76fa74fbc0f1276585 Mon Sep 17 00:00:00 2001 From: "wagic.the.homebrew@gmail.com" Date: Wed, 18 Nov 2009 14:37:28 +0000 Subject: [PATCH] Erwan - Added ">" and "<" for foreach and aslongas. Can be used to code threshold cards. See black vise (RV) and korsan beast (ODY) --- projects/mtg/bin/Res/sets/ODY/_cards.dat | 12 +++++ projects/mtg/bin/Res/sets/ODY/todo.dat | 11 ---- projects/mtg/bin/Res/sets/RV/_cards.dat | 1 + projects/mtg/bin/Res/sets/SCG/_cards.dat | 14 ++++++ projects/mtg/bin/Res/test/_tests.txt | 3 ++ projects/mtg/bin/Res/test/black_vise.txt | 19 +++++++ projects/mtg/bin/Res/test/krosan_beast.txt | 23 +++++++++ projects/mtg/bin/Res/test/krosan_beast2.txt | 23 +++++++++ projects/mtg/include/AllAbilities.h | 56 ++++++++++++++------- projects/mtg/src/MTGAbility.cpp | 21 +++++--- 10 files changed, 145 insertions(+), 38 deletions(-) create mode 100644 projects/mtg/bin/Res/test/black_vise.txt create mode 100644 projects/mtg/bin/Res/test/krosan_beast.txt create mode 100644 projects/mtg/bin/Res/test/krosan_beast2.txt diff --git a/projects/mtg/bin/Res/sets/ODY/_cards.dat b/projects/mtg/bin/Res/sets/ODY/_cards.dat index d37bce5fb..2ee468a31 100644 --- a/projects/mtg/bin/Res/sets/ODY/_cards.dat +++ b/projects/mtg/bin/Res/sets/ODY/_cards.dat @@ -670,6 +670,18 @@ toughness=3 abilities=reach [/card] [card] +text=Threshold - Krosan Beast gets +7/+7 as long as seven or more cards are in your graveyard. +auto=aslongas(*|mygraveyard) 7/7 >6 +id=30549 +name=Krosan Beast +rarity=R +type=Creature +mana={3}{G} +power=1 +subtype=Squirrel Beast +toughness=1 +[/card] +[card] text=Forestwalk id=29782 name=Leaf Dancer diff --git a/projects/mtg/bin/Res/sets/ODY/todo.dat b/projects/mtg/bin/Res/sets/ODY/todo.dat index 174cb2c37..45026d855 100644 --- a/projects/mtg/bin/Res/sets/ODY/todo.dat +++ b/projects/mtg/bin/Res/sets/ODY/todo.dat @@ -932,17 +932,6 @@ subtype=Human Druid toughness=1 [/card] [card] -text=Threshold - Krosan Beast gets +7/+7 as long as seven or more cards are in your graveyard. -id=30549 -name=Krosan Beast -rarity=R -type=Creature -mana={3}{G} -power=1 -subtype=Squirrel Beast -toughness=1 -[/card] -[card] text=Target player draws cards equal to the number of cards in his or her hand, then discards that many cards. id=29937 name=Laquatus's Creativity diff --git a/projects/mtg/bin/Res/sets/RV/_cards.dat b/projects/mtg/bin/Res/sets/RV/_cards.dat index 1166a71e4..f116dfc90 100644 --- a/projects/mtg/bin/Res/sets/RV/_cards.dat +++ b/projects/mtg/bin/Res/sets/RV/_cards.dat @@ -183,6 +183,7 @@ name=Black Vise rarity=U type=Artifact mana={1} +auto=@each opponent upkeep:foreach(*|opponenthand) damage:1 opponent >4 [/card] [card] text=Enchant creature Enchanted creature has protection from black. This effect doesn't remove Black Ward. diff --git a/projects/mtg/bin/Res/sets/SCG/_cards.dat b/projects/mtg/bin/Res/sets/SCG/_cards.dat index 408f98f38..0e5fb1f89 100644 --- a/projects/mtg/bin/Res/sets/SCG/_cards.dat +++ b/projects/mtg/bin/Res/sets/SCG/_cards.dat @@ -7,3 +7,17 @@ text={3}, {T}, Sacrifice Ark of Blight: Destroy target land. auto={3}{T}{S}:destroy target(land) rarity=U [/card] +[card] +id=42024 +name=Bladewing the Risen +mana={3}{B}{B}{R}{R} +type=Creature +subtype=Zombie Dragon +power=4 +toughness=4 +text=Flying When Bladewing the Risen enters the battlefield, you may return target Dragon permanent card from your graveyard to the battlefield. {B}{R}: Dragon creatures get +1/+1 until end of turn. +abilities=Legendary,Flying +auto=may moveTo(myBattlefield) target(dragon[-instant;_sorcery]|mygraveyard) +auto={B}{R}:lord(dragon) 1/1 +rarity=R +[/card] diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index cacd7857c..4b2a1fbfa 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -76,6 +76,7 @@ basal_sliver.txt beacon_of_unrest.txt belligerent_hatchling.txt benalish_knight.txt +black_vise.txt blessed_wine.txt blinking_spirit.txt bloodfire_colossus.txt @@ -180,6 +181,8 @@ keldon_warlord.txt keldon_warlord2.txt kird_ape.txt kjeldoran_frostbeast1.txt +krosan_beast.txt +krosan_beast2.txt kraken_eye.txt kraken_eye2.txt kraken_eye3.txt diff --git a/projects/mtg/bin/Res/test/black_vise.txt b/projects/mtg/bin/Res/test/black_vise.txt new file mode 100644 index 000000000..51561a3bb --- /dev/null +++ b/projects/mtg/bin/Res/test/black_vise.txt @@ -0,0 +1,19 @@ +#Test ">" symbol in foreach +[INIT] +SECONDMAIN +[PLAYER1] +inplay:black vise +[PLAYER2] +hand:act of treason,mountain,plains,swamp,forest,island +[DO] +eot +next +#upkeep +[ASSERT] +UPKEEP +[PLAYER1] +inplay:black vise +[PLAYER2] +hand:act of treason,mountain,plains,swamp,forest,island +life:18 +[END] \ No newline at end of file diff --git a/projects/mtg/bin/Res/test/krosan_beast.txt b/projects/mtg/bin/Res/test/krosan_beast.txt new file mode 100644 index 000000000..908074d3a --- /dev/null +++ b/projects/mtg/bin/Res/test/krosan_beast.txt @@ -0,0 +1,23 @@ +#Test Threshold +[INIT] +COMBATATTACKERS +[PLAYER1] +graveyard:island,swamp,mountain,plains,forest,grizzly bears,raging goblin +inplay:krosan beast +[PLAYER2] +[DO] +krosan beast +next +#blockers +next +#damage +next +#end combat +[ASSERT] +COMBATEND +[PLAYER1] +graveyard:island,swamp,mountain,plains,forest,grizzly bears,raging goblin +inplay:krosan beast +[PLAYER2] +life:12 +[END] \ No newline at end of file diff --git a/projects/mtg/bin/Res/test/krosan_beast2.txt b/projects/mtg/bin/Res/test/krosan_beast2.txt new file mode 100644 index 000000000..9a4a4c1e4 --- /dev/null +++ b/projects/mtg/bin/Res/test/krosan_beast2.txt @@ -0,0 +1,23 @@ +#Test Threshold +[INIT] +COMBATATTACKERS +[PLAYER1] +graveyard:island,swamp,mountain +inplay:krosan beast +[PLAYER2] +[DO] +krosan beast +next +#blockers +next +#damage +next +#end combat +[ASSERT] +COMBATEND +[PLAYER1] +graveyard:island,swamp,mountain +inplay:krosan beast +[PLAYER2] +life:19 +[END] \ No newline at end of file diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 72a520317..bbee37186 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -1510,7 +1510,8 @@ class AAsLongAs:public ListMaintainerAbility{ MTGAbility * ability; MTGAbility * a; int includeSelf; - AAsLongAs(int _id, MTGCardInstance * _source, Damageable * _target, TargetChooser * _tc, int _includeSelf, MTGAbility * a):ListMaintainerAbility(_id, _source,_target),ability(a){ + int mini,maxi; + AAsLongAs(int _id, MTGCardInstance * _source, Damageable * _target, TargetChooser * _tc, int _includeSelf, MTGAbility * ability,int mini = 0, int maxi = 0):ListMaintainerAbility(_id, _source,_target),ability(ability),mini(mini),maxi(maxi){ tc = _tc; includeSelf = _includeSelf; tc->targetter = NULL; @@ -1532,19 +1533,31 @@ class AAsLongAs:public ListMaintainerAbility{ return 1; } + int addAbilityToGame(){ + if (a) return 0; + a = ability->clone(); + if (a->oneShot){ + a->resolve(); + SAFE_DELETE(a); + }else{ + a->addToGame(); + } + return 1; + } + + int removeAbilityFromGame(){ + if (!a) return 0; + game->removeObserver(a); + a = NULL; + return 1; + } int _added(Damageable * d){ - if (cards.size()== 1){ - a = ability->clone(); - if (a->oneShot){ - a->resolve(); - SAFE_DELETE(a); - }else{ - a->addToGame(); - } - return 1; - } - return 0; + size_t size = cards.size(); + if (mini && (int)size <= mini) return 0; + if (maxi && (int)size >= maxi) return removeAbilityFromGame(); + if (!mini && !maxi && size !=1) return 0; + return addAbilityToGame(); } int added(MTGCardInstance * card){ @@ -1557,12 +1570,11 @@ class AAsLongAs:public ListMaintainerAbility{ int removed(MTGCardInstance * card){ - if (cards.size()== 0 && a){ - game->removeObserver(a); - a = NULL; - return 1; - } - return 0; + size_t size = cards.size(); + if (mini && (int)size <= mini) return removeAbilityFromGame(); + if (maxi && (int)size == maxi-1) return addAbilityToGame(); + if (!mini && !maxi && size !=0) return 0; + return removeAbilityFromGame(); } ~AAsLongAs(){ @@ -1583,6 +1595,7 @@ class ALord:public ListMaintainerAbility{ MTGAbility * ability; int includeSelf; map abilities; + ALord(int _id, MTGCardInstance * card, TargetChooser * _tc, int _includeSelf, MTGAbility * a):ListMaintainerAbility(_id,card), ability(a){ tc = _tc; tc->targetter = NULL; @@ -1656,8 +1669,10 @@ class AForeach:public ListMaintainerAbility{ public: MTGAbility * ability; int includeSelf; + int mini; + int maxi; map abilities; - AForeach(int _id, MTGCardInstance * card,Damageable * _target, TargetChooser * _tc, int _includeSelf, MTGAbility * a):ListMaintainerAbility(_id,card,_target), ability(a){ + AForeach(int _id, MTGCardInstance * card,Damageable * _target, TargetChooser * _tc, int _includeSelf, MTGAbility * a, int mini = 0, int maxi = 0):ListMaintainerAbility(_id,card,_target), ability(a),mini(mini),maxi(maxi){ tc = _tc; tc->targetter = NULL; includeSelf = _includeSelf; @@ -1670,6 +1685,9 @@ class AForeach:public ListMaintainerAbility{ } int added(MTGCardInstance * card){ + if (mini && cards.size() <= (size_t)mini) return 0; + if (maxi && cards.size() >= (size_t)maxi) return 0; + MTGAbility * a = ability->clone(); a->target = target; if (a->oneShot){ diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 2e80aac83..a8eea90cf 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -347,12 +347,19 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG if (i == 3) oneShot = 1; if (a->oneShot) oneShot = 1; Damageable * _target = NULL; - if (spell) _target = spell->getNextDamageableTarget(); + if (spell) _target = spell->getNextDamageableTarget(); if (!_target) _target = target; + + int mini = 0; + int maxi = 0; + found = s.find(">"); + if (found !=string::npos) mini = atoi(s.substr(found+1,1).c_str()); + found = s.find("<"); + if (found !=string::npos) maxi = atoi(s.substr(found+1,1).c_str()); 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, _target,lordTargets, lordIncludeSelf, a); break; + case 1: 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); break; case 3: result = NEW ALord(id, card, lordTargets, lordIncludeSelf, a); break; default: result = NULL; } @@ -927,11 +934,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){ game->addObserver(ability); break; } - case 1097: //Black Vise - { - game->addObserver( NEW ALifeZoneLink(_id ,card, Constants::MTG_PHASE_UPKEEP, 4)); - break; - } + case 1191: //Blue Elemental Blast { if (card->target){ @@ -1148,11 +1151,13 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){ game->addObserver( NEW ASoulNet(_id ,card)); break; } + case 1139: //The Rack { game->addObserver( NEW ALifeZoneLink(_id ,card, Constants::MTG_PHASE_UPKEEP, -3)); break; } + case 1140: //Throne of Bone { int cost[] = {Constants::MTG_COLOR_ARTIFACT, 1};