diff --git a/projects/mtg/Makefile b/projects/mtg/Makefile index 95000c02d..7d17eb833 100644 --- a/projects/mtg/Makefile +++ b/projects/mtg/Makefile @@ -1,4 +1,4 @@ -OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/CardPrimitive.o objs/CardSelector.o objs/CardSelectorSingleton.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DeckDataWrapper.o objs/DeckMenu.o objs/DeckMenuItem.o objs/DeckMetaData.o objs/DeckStats.o objs/DuelLayers.o objs/Effects.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameState.o objs/GameStateAwards.o objs/GameStateDeckViewer.o objs/GameStateDuel.o objs/DeckManager.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GameStateStory.o objs/GameStateTransitions.o objs/GuiAvatars.o objs/GuiBackground.o objs/GuiCardsController.o objs/GuiCombat.o objs/GuiFrame.o objs/GuiHand.o objs/GuiLayers.o objs/GuiMana.o objs/GuiPhaseBar.o objs/GuiPlay.o objs/GuiStatic.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGPack.o objs/MTGRules.o objs/Navigator.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/Pos.o objs/PrecompiledHeader.o objs/PriceList.o objs/ReplacementEffects.o objs/Rules.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/SimplePad.o objs/StoryFlow.o objs/StyleManager.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/ThisDescriptor.o objs/Token.o objs/Translate.o objs/TranslateKeys.o objs/Trash.o objs/utils.o objs/WEvent.o objs/WResourceManager.o objs/WCachedResource.o objs/WDataSrc.o objs/WGui.o objs/WFilter.o objs/Tasks.o objs/WFont.o +OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/CardPrimitive.o objs/CardSelector.o objs/CardSelectorSingleton.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DeckDataWrapper.o objs/DeckMenu.o objs/DeckMenuItem.o objs/DeckMetaData.o objs/DeckStats.o objs/DuelLayers.o objs/Effects.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameState.o objs/GameStateAwards.o objs/GameStateDeckViewer.o objs/GameStateDuel.o objs/DeckManager.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GameStateStory.o objs/GameStateTransitions.o objs/GuiAvatars.o objs/GuiBackground.o objs/GuiCardsController.o objs/GuiCombat.o objs/GuiFrame.o objs/GuiHand.o objs/GuiLayers.o objs/GuiMana.o objs/GuiPhaseBar.o objs/GuiPlay.o objs/GuiStatic.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGPack.o objs/MTGRules.o objs/Navigator.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/Pos.o objs/PrecompiledHeader.o objs/PriceList.o objs/ReplacementEffects.o objs/Rules.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/SimplePad.o objs/StoryFlow.o objs/StyleManager.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/ThisDescriptor.o objs/Token.o objs/Translate.o objs/TranslateKeys.o objs/Trash.o objs/utils.o objs/WEvent.o objs/WResourceManager.o objs/WCachedResource.o objs/WDataSrc.o objs/WGui.o objs/WFilter.o objs/Tasks.o objs/WFont.o objs/AllAbilities.o DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS)) RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 8449b47ba..25aa4cce9 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -929,7 +929,7 @@ toughness=4 [/card] [card] name=Alabaster Leech -auto=lord(*[white]|myhand) white:+1 +auto=lord(*[white]|myhand) manaredux( white, +1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -1598,7 +1598,7 @@ type=Land [/card] [card] name=Andradite Leech -auto=lord(*[black]|myhand) black:+1 +auto=lord(*[black]|myhand) manaredux( black, +1 ) auto={B}:1/1 autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost @@ -3089,8 +3089,8 @@ subtype=Aura [/card] [card] name=Aura of Silence -auto=lord(artifact[-land]|opponenthand) colorless:+2 -auto=lord(enchantment|opponenthand) colorless:+2 +auto=lord(artifact[-land]|opponenthand) manaredux( colorless, +2 ) +auto=lord(enchantment|opponenthand) manaredux( colorless, +2 ) auto={S}:destroy target(artifact,enchantment) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost @@ -3862,8 +3862,8 @@ toughness=2 [/card] [card] name=Ballyrush Banneret -auto=lord(kithkin|myhand) colorless:-1 -auto=lord(soldier|myhand) colorless:-1 +auto=lord(kithkin|myhand) manaredux( colorless, -1 ) +auto=lord(soldier|myhand) manaredux( colorless, -1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -6552,8 +6552,8 @@ type=Sorcery [/card] [card] name=Bosk Banneret -auto=lord(treefolk|myhand) colorless:-1 -auto=lord(shaman|myhand) colorless:-1 +auto=lord(treefolk|myhand) manaredux( colorless, -1 ) +auto=lord(shaman|myhand) manaredux( colorless, -1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -6939,8 +6939,8 @@ type=Sorcery [/card] [card] name=Brighthearth Banneret -auto=lord(elemental|myhand) colorless:-1 -auto=lord(warrior|myhand) colorless:-1 +auto=lord(elemental|myhand) manaredux( colorless, -1 ) +auto=lord(warrior|myhand) manaredux( colorless, -1 ) autohand={1}{R}{S}:counter(1/1,1) target(creature) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost @@ -9097,8 +9097,8 @@ toughness=2 [/card] [card] name=Chill -auto=lord(*[red]|myhand) colorless:+2 -auto=lord(*[red]|opponenthand) colorless:+2 +auto=lord(*[red]|myhand) manaredux( colorless, +2 ) +auto=lord(*[red]|opponenthand) manaredux( colorless, +2 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -9884,11 +9884,11 @@ auto=choice name(Creature) && counter(0/0,1,CloudKeyC) all(this) auto=choice name(Enchantment) && counter(0/0,1,CloudKeyE) all(this) auto=choice name(Instant) && counter(0/0,1,CloudKeyI) all(this) auto=choice name(Sorcery) && counter(0/0,1,CloudKeyS) all(this) -auto=this(counter{0/0.1.CloudKeyA}) lord(Artifact|myhand) colorless:-1 -auto=this(counter{0/0.1.CloudKeyC}) lord(Creature|myhand) colorless:-1 -auto=this(counter{0/0.1.CloudKeyE}) lord(Enchantment|myhand) colorless:-1 -auto=this(counter{0/0.1.CloudKeyI}) lord(Instant|myhand) colorless:-1 -auto=this(counter{0/0.1.CloudKeyS}) lord(Sorcery|myhand) colorless:-1 +auto=this(counter{0/0.1.CloudKeyA}) lord(Artifact|myhand) manaredux( colorless, -1 ) +auto=this(counter{0/0.1.CloudKeyC}) lord(Creature|myhand) manaredux( colorless, -1 ) +auto=this(counter{0/0.1.CloudKeyE}) lord(Enchantment|myhand) manaredux( colorless, -1 ) +auto=this(counter{0/0.1.CloudKeyI}) lord(Instant|myhand) manaredux( colorless, -1 ) +auto=this(counter{0/0.1.CloudKeyS}) lord(Sorcery|myhand) manaredux( colorless, -1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -12241,7 +12241,7 @@ type=Land [/card] [card] name=Daru Warchief -auto=lord(soldier|myhand) colorless:-1 +auto=lord(soldier|myhand) manaredux( colorless, -1 ) auto=lord(soldier|myBattlefield) 1/2 text=Soldier spells you cast cost {1} less to cast. -- Soldier creatures you control get +1/+2. mana={2}{W}{W} @@ -13194,7 +13194,7 @@ toughness=1 [/card] [card] name=Derelor -auto=lord(*[black]|myhand) black:+1 +auto=lord(*[black]|myhand) manaredux( black, +1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -14327,7 +14327,7 @@ toughness=2 [/card] [card] name=Dragonspeaker Shaman -auto=lord(dragon|myhand) colorless:-2 +auto=lord(dragon|myhand) manaredux( colorless, -2 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -15559,8 +15559,8 @@ toughness=3 [/card] [card] name=Edgewalker -auto=lord(cleric|myhand) white:-1 -auto=lord(cleric|myhand) black:-1 +auto=lord(cleric|myhand) manaredux( white, -1 ) +auto=lord(cleric|myhand) manaredux( black, -1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -16324,7 +16324,7 @@ toughness=1 [/card] [card] name=Emerald Medallion -auto=lord(*[green]|myhand) colorless:-1 +auto=lord(*[green]|myhand) manaredux( colorless, -1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -17113,7 +17113,7 @@ type=Artifact [/card] [card] name=Etherium Sculptor -auto=lord(artifact|myhand) colorless:-1 +auto=lord(artifact|myhand) manaredux( colorless, -1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -17486,7 +17486,7 @@ type=Artifact [/card] [card] name=Eye of Ugin -auto=lord(eldrazi[-white;-blue;-black;-red;-green]|myhand) colorless:-2 +auto=lord(eldrazi[-white;-blue;-black;-red;-green]|myhand) manaredux( colorless, -2 ) auto={7}{T}:moveTo(myhand) target(creature[-white;-blue;-black;-red;-green]|myLibrary) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost @@ -18143,8 +18143,8 @@ subtype=Aura [/card] [card] name=Feroz's Ban -auto=lord(creature|myhand) colorless:+2 -auto=lord(creature|opponenthand) colorless:+2 +auto=lord(creature|myhand) manaredux( colorless, +2 ) +auto=lord(creature|opponenthand) manaredux( colorless, +2 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -19966,8 +19966,8 @@ toughness=2 [card] name=Frogtosser Banneret abilities=haste -auto=lord(goblin|myhand) colorless:-1 -auto=lord(rogue|myhand) colorless:-1 +auto=lord(goblin|myhand) manaredux( colorless, -1 ) +auto=lord(rogue|myhand) manaredux( colorless, -1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -21525,8 +21525,8 @@ toughness=3 [/card] [card] name=Glowrider -auto=lord(*[-creature;-land]|myhand) colorless:+1 -auto=lord(*[-creature;-land]|opponenthand) colorless:+1 +auto=lord(*[-creature;-land]|myhand) manaredux( colorless, +1 ) +auto=lord(*[-creature;-land]|opponenthand) manaredux( colorless, +1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -22268,7 +22268,7 @@ toughness=1 [/card] [card] name=Goblin Warchief -auto=lord(goblin|myhand) colorless:-1 +auto=lord(goblin|myhand) manaredux( colorless, -1 ) auto=lord(goblin|myBattlefield) haste autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost @@ -22707,9 +22707,9 @@ type=Artifact [/card] [card] name=Grand Arbiter Augustin IV -auto=lord(*[white;blue]|myhand) colorless:-1 -auto=lord(*[blue]|myhand) colorless:-1 -auto=lord(*[-land]|opponenthand) colorless:+1 +auto=lord(*[white;blue]|myhand) manaredux( colorless, -1 ) +auto=lord(*[blue]|myhand) manaredux( colorless, -1 ) +auto=lord(*[-land]|opponenthand) manaredux( colorless, +1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -24769,8 +24769,8 @@ toughness=1 [/card] [card] name=Helm of Awakening -auto=lord(*|myhand) colorless:-1 -auto=lord(*|opponenthand) colorless:-1 +auto=lord(*|myhand) manaredux( colorless, -1 ) +auto=lord(*|opponenthand) manaredux( colorless, -1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -24961,8 +24961,8 @@ type=Land [/card] [card] name=High Seas -auto=lord(creature[red;green]|myhand) colorless:+1 -auto=lord(creature[red;green]|opponenthand) colorless:+1 +auto=lord(creature[red;green]|myhand) manaredux( colorless, +1 ) +auto=lord(creature[red;green]|opponenthand) manaredux( colorless, +1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -26942,8 +26942,8 @@ toughness=4 [/card] [card] name=Irini Sengir -auto=lord(enchantment[white;green]|myhand) colorless:+1 -auto=lord(enchantment[white;green]|opponenthand) colorless:+1 +auto=lord(enchantment[white;green]|myhand) manaredux( colorless, +1 ) +auto=lord(enchantment[white;green]|opponenthand) manaredux( colorless, +1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -27283,7 +27283,7 @@ type=Artifact [/card] [card] name=Jade Leech -auto=lord(*[green]|myhand) green:+1 +auto=lord(*[green]|myhand) manaredux( green, +1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -27480,7 +27480,7 @@ toughness=1 [/card] [card] name=Jet Medallion -auto=lord(*[black]|myhand) colorless:-1 +auto=lord(*[black]|myhand) manaredux( colorless, -1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -30009,7 +30009,7 @@ toughness=5 [card] name=Krosan Warchief auto={1}{G}:regenerate target(beast) -auto=lord(beast|myhand) colorless:-1 +auto=lord(beast|myhand) manaredux( colorless, -1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -31675,8 +31675,8 @@ toughness=1 [/card] [card] name=Lodestone Golem -auto=lord(*[-artifact;-land]|myhand) colorless:+1 -auto=lord(*[-artifact;-land]|opponenthand) colorless:+1 +auto=lord(*[-artifact;-land]|myhand) manaredux( colorless, +1 ) +auto=lord(*[-artifact;-land]|opponenthand) manaredux( colorless, +1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -31743,7 +31743,7 @@ autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost autolibrary=all(*|myhand) resetcost -auto=lord(arcane|myhand) colorless:-1 +auto=lord(arcane|myhand) manaredux( colorless, -1 ) auto=lord(spirit|myBattlefield) 1/1 text=Arcane spells you cast cost {1} less to cast. -- Spirit creatures you control get +1/+1. mana={3} @@ -32753,8 +32753,8 @@ type=Sorcery [/card] [card] name=Mana Matrix -auto=lord(instant|myhand) colorless:-2 -auto=lord(enchantment|myhand) colorless:-2 +auto=lord(instant|myhand) manaredux( colorless, -2 ) +auto=lord(enchantment|myhand) manaredux( colorless, -2 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -36899,7 +36899,7 @@ toughness=1 [/card] [card] name=Nightscape Familiar -auto=lord(*[blue;red]|myhand) colorless:-1 +auto=lord(*[blue;red]|myhand) manaredux( colorless, -1 ) auto={1}{B}:regenerate autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost @@ -39244,7 +39244,7 @@ toughness=4 [/card] [card] name=Pearl Medallion -auto=lord(*[white]|myhand) colorless:-1 +auto=lord(*[white]|myhand) manaredux( colorless, -1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -40517,7 +40517,7 @@ type=Sorcery [/card] [card] name=Planar Gate -auto=lord(creature|myhand) colorless:-2 +auto=lord(creature|myhand) manaredux( colorless, -2 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -45061,7 +45061,7 @@ toughness=2 [card] name=Ruby Leech abilities=first strike -auto=lord(*[red]|myhand) red:+1 +auto=lord(*[red]|myhand) manaredux( red, +1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -45075,7 +45075,7 @@ toughness=2 [/card] [card] name=Ruby Medallion -auto=lord(*[red]|myhand) colorless:-1 +auto=lord(*[red]|myhand) manaredux( colorless, -1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -45788,7 +45788,7 @@ toughness=1 [card] name=Sapphire Leech abilities=flying -auto=lord(*[blue]|myhand) blue:+1 +auto=lord(*[blue]|myhand) manaredux( blue, +1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -45802,7 +45802,7 @@ toughness=2 [/card] [card] name=Sapphire Medallion -auto=lord(*[blue]|myhand) colorless:-1 +auto=lord(*[blue]|myhand) manaredux( colorless, -1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -47318,20 +47318,20 @@ auto=choice name(Sorcery) && moveTo(myexile) notatarget(sorcery|myhand) && count auto=choice name(Tribal Instant) && moveTo(myexile) notatarget(instant[tribal]|myhand) && counter(0/0,1,TribalInstant) all(this) auto=choice name(Tribal Sorcery) && moveTo(myexile) notatarget(sorcery[tribal]|myhand) && counter(0/0,1,TribalSorcery) all(this) auto=choice name(cancel) && 0/0 -auto=this(counter{0/0.1.Artifact}) lord(artifact[-land]|myhand) colorless:-2 -auto=this(counter{0/0.1.ArtifactCreature}) lord(artifact[-creature;-land]|myhand) colorless:-2 -auto=this(counter{0/0.1.ArtifactCreature}) lord(creature[-artifact]|myhand) colorless:-2 -auto=this(counter{0/0.1.ArtifactCreature}) lord(creature[artifact]|myhand) colorless:-2 -auto=this(counter{0/0.1.Creature}) lord(creature|myhand) colorless:-2 -auto=this(counter{0/0.1.Enchantment}) lord(enchantment|myhand) colorless:-2 -auto=this(counter{0/0.1.Instant}) lord(instant|myhand) colorless:-2 -auto=this(counter{0/0.1.Sorcery}) lord(sorcery|myhand) colorless:-2 -auto=this(counter{0/0.1.TribalInstant}) lord(tribal[-instant]|myhand) colorless:-2 -auto=this(counter{0/0.1.TribalInstant}) lord(instant[-tribal]|myhand) colorless:-2 -auto=this(counter{0/0.1.TribalInstant}) lord(instant[tribal]|myhand) colorless:-2 -auto=this(counter{0/0.1.TribalSorcery}) lord(tribal[-sorcery]|myhand) colorless:-2 -auto=this(counter{0/0.1.TribalSorcery}) lord(sorcery[-tribal]|myhand) colorless:-2 -auto=this(counter{0/0.1.TribalSorcery}) lord(sorcery[tribal]|myhand) colorless:-2 +auto=this(counter{0/0.1.Artifact}) lord(artifact[-land]|myhand) manaredux( colorless, -2 ) +auto=this(counter{0/0.1.ArtifactCreature}) lord(artifact[-creature;-land]|myhand) manaredux( colorless, -2 ) +auto=this(counter{0/0.1.ArtifactCreature}) lord(creature[-artifact]|myhand) manaredux( colorless, -2 ) +auto=this(counter{0/0.1.ArtifactCreature}) lord(creature[artifact]|myhand) manaredux( colorless, -2 ) +auto=this(counter{0/0.1.Creature}) lord(creature|myhand) manaredux( colorless, -2 ) +auto=this(counter{0/0.1.Enchantment}) lord(enchantment|myhand) manaredux( colorless, -2 ) +auto=this(counter{0/0.1.Instant}) lord(instant|myhand) manaredux( colorless, -2 ) +auto=this(counter{0/0.1.Sorcery}) lord(sorcery|myhand) manaredux( colorless, -2 ) +auto=this(counter{0/0.1.TribalInstant}) lord(tribal[-instant]|myhand) manaredux( colorless, -2 ) +auto=this(counter{0/0.1.TribalInstant}) lord(instant[-tribal]|myhand) manaredux( colorless, -2 ) +auto=this(counter{0/0.1.TribalInstant}) lord(instant[tribal]|myhand) manaredux( colorless, -2 ) +auto=this(counter{0/0.1.TribalSorcery}) lord(tribal[-sorcery]|myhand) manaredux( colorless, -2 ) +auto=this(counter{0/0.1.TribalSorcery}) lord(sorcery[-tribal]|myhand) manaredux( colorless, -2 ) +auto=this(counter{0/0.1.TribalSorcery}) lord(sorcery[tribal]|myhand) manaredux( colorless, -2 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -51412,8 +51412,8 @@ type=Enchantment [/card] [card] name=Sphere of Resistance -auto=lord(*[-land]|myhand) colorless:+1 -auto=lord(*[-land]|opponenthand) colorless:+1 +auto=lord(*[-land]|myhand) manaredux( colorless, +1 ) +auto=lord(*[-land]|opponenthand) manaredux( colorless, +1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -52249,8 +52249,8 @@ type=Artifact [card] name=Squeeze text=Sorcery spells cost {3} more to cast. -auto=lord(sorcery|myhand) colorless:+3 -auto=lord(sorcery|opponenthand) colorless:+3 +auto=lord(sorcery|myhand) manaredux( colorless, +3 ) +auto=lord(sorcery|opponenthand) manaredux( colorless, +3 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -52865,7 +52865,7 @@ toughness=2 [/card] [card] name=Stinkdrinker Daredevil -auto=lord(giant|myhand) colorless:-2 +auto=lord(giant|myhand) manaredux( colorless, -2 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -52931,7 +52931,7 @@ autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost autolibrary=all(*|myhand) resetcost -auto=lord(*|myhand) colorless:-1 +auto=lord(*|myhand) manaredux( colorless, -1 ) text=Spells you cast cost up to {1} less to cast. mana={5} type=Artifact @@ -53069,8 +53069,8 @@ toughness=2 [card] name=Stonybrook Banneret abilities=islandwalk -auto=lord(merfolk|myhand) colorless:-1 -auto=lord(wizard|myhand) colorless:-1 +auto=lord(merfolk|myhand) manaredux( colorless, -1 ) +auto=lord(wizard|myhand) manaredux( colorless, -1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -53196,7 +53196,7 @@ toughness=1 [card] name=Stormscape Familiar abilities=flying -auto=lord(*[white;black]|myhand) colorless:-1 +auto=lord(*[white;black]|myhand) manaredux( colorless, -1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -53879,7 +53879,7 @@ toughness=1 [card] name=Sunscape Familiar abilities=flying -auto=lord(*[green;blue]|myhand) colorless:-1 +auto=lord(*[green;blue]|myhand) manaredux( colorless, -1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -55926,8 +55926,8 @@ toughness=7 [/card] [card] name=Thorn of Amethyst -auto=lord(*[-creature;-land]|myhand) colorless:+1 -auto=lord(*[-creature;-land]|opponenthand) colorless:+1 +auto=lord(*[-creature;-land]|myhand) manaredux( colorless, +1 ) +auto=lord(*[-creature;-land]|opponenthand) manaredux( colorless, +1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -55974,7 +55974,7 @@ toughness=1 [/card] [card] name=Thornscape Familiar -auto=lord(*[red;white]|myhand) colorless:-1 +auto=lord(*[red;white]|myhand) manaredux( colorless, -1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -56425,7 +56425,7 @@ toughness=1 [card] name=Thunderscape Familiar abilities=first strike -auto=lord(*[black;green]|myhand) colorless:-1 +auto=lord(*[black;green]|myhand) manaredux( colorless, -1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost @@ -58532,7 +58532,7 @@ toughness=2 [card] name=Undead Warchief auto=lord(zombie|myBatllefield) 2/1 -auto=lord(zombie|myhand) colorless:-1 +auto=lord(zombie|myhand) manaredux( colorless, -1 ) autoexile=all(*|myhand) resetcost autograveyard=all(*|myhand) resetcost autohand=all(*|myhand) resetcost diff --git a/projects/mtg/include/ActionStack.h b/projects/mtg/include/ActionStack.h index 14d7ebb53..16872b5d6 100644 --- a/projects/mtg/include/ActionStack.h +++ b/projects/mtg/include/ActionStack.h @@ -90,11 +90,7 @@ class Spell: public Interruptible { ~Spell(); int resolve(); void Render(); - bool kickerWasPaid(); - bool AlternativeWasPaid(); - bool BuyBackWasPaid(); - bool FlashBackWasPaid(); - bool RetraceWasPaid(); + bool FullfilledAlternateCost(const int &costType); const string getDisplayName() const; virtual ostream& toString(ostream& out) const; MTGCardInstance * getNextCardTarget(MTGCardInstance * previous = 0); diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 353188a71..b7787a64b 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -565,7 +565,7 @@ public: int triggered; bool must; MTGAbility * mClone; - MayAbility(int _id, MTGAbility * _ability, MTGCardInstance * _source, bool must = false):MTGAbility(_id,_source),NestedAbility(_ability),must(must){ + MayAbility(int _id, MTGAbility * _ability, MTGCardInstance * _source, bool must = false):MTGAbility(_id, _source),NestedAbility(_ability),must(must){ triggered = 0; mClone = NULL; } @@ -736,7 +736,7 @@ public: //Copier. ActivatedAbility class AACopier:public ActivatedAbility{ public: - AACopier(int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost=NULL):ActivatedAbility(_id,_source,_cost,0,0){ + AACopier(int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost=NULL):ActivatedAbility(_id, _source,_cost,0,0){ target = _target; } @@ -768,7 +768,7 @@ public: string with; listawith; listcolors; - AACloner(int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost=NULL, int who = 0,string with =""):ActivatedAbility(_id,_source,_cost,0,0), who(who){ + AACloner(int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost=NULL, int who = 0,string with =""):ActivatedAbility(_id, _source,_cost,0,0), who(who){ target = _target; source = _source; @@ -860,7 +860,7 @@ public: class AAMover:public ActivatedAbility{ public: string destination; - AAMover(int _id, MTGCardInstance * _source, MTGCardInstance * _target, string dest, ManaCost * _cost=NULL, int doTap=0):ActivatedAbility(_id,_source,_cost,0,doTap),destination(dest){ + AAMover(int _id, MTGCardInstance * _source, MTGCardInstance * _target, string dest, ManaCost * _cost=NULL, int doTap=0):ActivatedAbility(_id, _source,_cost,0,doTap),destination(dest){ if (_target) target = _target; } @@ -916,7 +916,7 @@ public: int limitPerTurn; int counters; MTGGameZone * activeZone; - GenericTargetAbility(int _id, MTGCardInstance * _source, TargetChooser * _tc,MTGAbility * a, ManaCost * _cost = NULL, int _tap=0, int limit = 0, int restrictions = 0, MTGGameZone * dest = NULL):TargetAbility(_id,_source, _tc,_cost,restrictions,_tap),limitPerTurn(limit), activeZone(dest){ + GenericTargetAbility(int _id, MTGCardInstance * _source, TargetChooser * _tc,MTGAbility * a, ManaCost * _cost = NULL, int _tap=0, int limit = 0, int restrictions = 0, MTGGameZone * dest = NULL):TargetAbility(_id, _source, _tc,_cost,restrictions,_tap),limitPerTurn(limit), activeZone(dest){ ability = a; MTGAbility * core = AbilityFactory::getCoreAbility(a); if (dynamic_cast(core)) tc->other = true; //http://code.google.com/p/wagic/issues/detail?id=209 (avoid inifinite loop) @@ -1268,13 +1268,13 @@ public: string name; WParsedInt * multiplier; int who; - ATokenCreator(int _id,MTGCardInstance * _source,ManaCost * _cost, int tokenId, int _doTap, WParsedInt * multiplier = NULL,int who = 0):ActivatedAbility(_id,_source,_cost,0,_doTap), tokenId(tokenId), multiplier(multiplier), who(who){ + ATokenCreator(int _id,MTGCardInstance * _source,ManaCost * _cost, int tokenId, int _doTap, WParsedInt * multiplier = NULL,int who = 0):ActivatedAbility(_id, _source,_cost,0,_doTap), tokenId(tokenId), multiplier(multiplier), who(who){ if(!multiplier) this->multiplier = NEW WParsedInt(1); MTGCard * card = GameApp::collection->getCardById(tokenId); if (card) name = card->data->getName(); } - ATokenCreator(int _id,MTGCardInstance * _source,ManaCost * _cost, string sname, string stypes,int _power,int _toughness, string sabilities, int _doTap, WParsedInt * multiplier = NULL,int who = 0):ActivatedAbility(_id,_source,_cost,0,_doTap), multiplier(multiplier),who(who){ + ATokenCreator(int _id,MTGCardInstance * _source,ManaCost * _cost, string sname, string stypes,int _power,int _toughness, string sabilities, int _doTap, WParsedInt * multiplier = NULL,int who = 0):ActivatedAbility(_id, _source,_cost,0,_doTap), multiplier(multiplier),who(who){ power = _power; toughness = _toughness; name = sname; @@ -1386,7 +1386,7 @@ public: class ANamer:public ActivatedAbility{ public: string name; - ANamer(int _id,MTGCardInstance * _source,ManaCost * _cost, string sname, int _doTap):ActivatedAbility(_id,_source,_cost,0,_doTap){ + ANamer(int _id,MTGCardInstance * _source,ManaCost * _cost, string sname, int _doTap):ActivatedAbility(_id, _source,_cost,0,_doTap){ name = sname; } int resolve(){ @@ -1412,79 +1412,58 @@ public: } }; //----------------------------------------------------------------------------------------------- +class AABanishCard: public ActivatedAbility { + +protected: -class AADestroyer:public ActivatedAbility{ public: - int bury; - AADestroyer(int _id, MTGCardInstance * _source, MTGCardInstance * _target, int _bury = 0, ManaCost * _cost=NULL):ActivatedAbility(_id,_source,_cost),bury(_bury){ - if (_target) target = _target; - } - - int resolve(){ - MTGCardInstance * _target = (MTGCardInstance *) target; - if(_target){ - if (bury) return _target->bury(); - else return _target->destroy(); - } - return 0; - } - - const char * getMenuText(){ - return "Destroy"; - } - - - AADestroyer * clone() const{ - AADestroyer * a = NEW AADestroyer(*this); - a->isClone = 1; - return a; - } - + int banishmentType; + const static int BANISHED = -1; + const static int BURY = 0; + const static int DESTROY = 1; + const static int SACRIFICE = 2; + const static int DISCARD = 3; + AABanishCard(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost, int _banishmentType); + int resolve(); + virtual const char * getMenuText(); + AABanishCard * clone() const; }; -class AASacDis:public ActivatedAbility{ +class AABuryCard:public AABanishCard{ public: - int sacrifice; - AASacDis(int _id, MTGCardInstance * _source, MTGCardInstance * _target, int _sacrifice = 0, ManaCost * _cost=NULL):ActivatedAbility(_id,_source,_cost),sacrifice(_sacrifice){ - if (_target) target = _target; - } - int resolve(){ - MTGCardInstance * _target = (MTGCardInstance *) target; - - if(_target){ - Player * p = _target->controller(); - Player * owner = _target->owner; - if (sacrifice) - { - WEvent * e = NEW WEventCardSacrifice(_target); - GameObserver * game = GameObserver::GetInstance(); - game->receiveEvent(e); - p->game->putInGraveyard(_target); - return 1; - } - else - { - WEvent * e = NEW WEventCardDiscard(_target); - GameObserver * game = GameObserver::GetInstance(); - game->receiveEvent(e); - p->game->putInGraveyard(_target); - return 1; - } - } - return 0; - } - const char * getMenuText(){ - if(sacrifice) return "Sacrifice"; - else return "Discard"; - } - AASacDis * clone() const{ - AASacDis * a = NEW AASacDis(*this); - a->isClone = 1; - return a; - } + AABuryCard(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost, int _banishmentType); + int resolve(); + const char * getMenuText(); + AABuryCard * clone() const; }; + +class AADestroyCard:public AABanishCard{ +public: + AADestroyCard(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost, int _banishmentType); + int resolve(); + const char * getMenuText(); + AADestroyCard * clone() const; +}; + +class AASacrificeCard:public AABanishCard{ +public: + AASacrificeCard(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost, int _banishmentType); + int resolve(); + const char * getMenuText(); + AASacrificeCard * clone() const; +}; + +class AADiscardCard:public AABanishCard{ +public: + AADiscardCard(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost, int _banishmentType); + int resolve(); + const char * getMenuText(); + AADiscardCard * clone() const; +}; + + /*Changes one of the basic abilities of target source : spell target : spell target (creature) @@ -1496,7 +1475,7 @@ public: int modifier; int ability; int value_before_modification; - ABasicAbilityModifier(int _id, MTGCardInstance * _source, MTGCardInstance * _target, int _ability, int _modifier = 1): MTGAbility(_id,_source,_target),modifier(_modifier),ability(_ability){ + ABasicAbilityModifier(int _id, MTGCardInstance * _source, MTGCardInstance * _target, int _ability, int _modifier = 1): MTGAbility(_id, _source,_target),modifier(_modifier),ability(_ability){ } @@ -1547,7 +1526,7 @@ public: int modifier; int stateBeforeActivation[50]; int ability; - ABasicAbilityModifierUntilEOT(int _id, MTGCardInstance * _source, int _ability, ManaCost * _cost, TargetChooser * _tc = NULL, int _modifier = 1,int _tap=1): TargetAbility(_id,_source,_cost,0,_tap),modifier(_modifier), ability(_ability){ + ABasicAbilityModifierUntilEOT(int _id, MTGCardInstance * _source, int _ability, ManaCost * _cost, TargetChooser * _tc = NULL, int _modifier = 1,int _tap=1): TargetAbility(_id, _source,_cost,0,_tap),modifier(_modifier), ability(_ability){ nbTargets = 0; tc = _tc; if (!tc) tc = NEW CreatureTargetChooser(_source); @@ -1652,9 +1631,9 @@ public: class ABasicAbilityAuraModifierUntilEOT: public ActivatedAbility{ public: AInstantBasicAbilityModifierUntilEOT * ability; - ABasicAbilityAuraModifierUntilEOT(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost, int _ability, int _value = 1):ActivatedAbility(_id,_source, _cost, 0,0){ + ABasicAbilityAuraModifierUntilEOT(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost, int _ability, int _value = 1):ActivatedAbility(_id, _source, _cost, 0,0){ target = _target; - ability = NEW AInstantBasicAbilityModifierUntilEOT(_id,_source,_target,_ability, _value); + ability = NEW AInstantBasicAbilityModifierUntilEOT(_id, _source,_target,_ability, _value); } int isReactingToClick(MTGCardInstance * card, ManaCost * cost = NULL){ @@ -1693,7 +1672,7 @@ public: class AEquip:public TargetAbility{ public: vector currentAbilities; - AEquip(int _id, MTGCardInstance * _source, ManaCost * _cost=NULL, int doTap=0, int restrictions = ActivatedAbility::AS_SORCERY):TargetAbility(_id,_source,NULL,_cost,restrictions,doTap){ + AEquip(int _id, MTGCardInstance * _source, ManaCost * _cost=NULL, int doTap=0, int restrictions = ActivatedAbility::AS_SORCERY):TargetAbility(_id, _source,NULL,_cost,restrictions,doTap){ aType = MTGAbility::STANDARD_EQUIP; } @@ -2149,7 +2128,7 @@ public: //Basic regeneration mechanism for a Mana cost class AStandardRegenerate:public ActivatedAbility{ public: - AStandardRegenerate(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost = NULL):ActivatedAbility(_id,_source,_cost,0,0){ + AStandardRegenerate(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost = NULL):ActivatedAbility(_id, _source,_cost,0,0){ target = _target; aType = MTGAbility::STANDARD_REGENERATE; } @@ -2716,7 +2695,7 @@ public: class AALifeSet:public ActivatedAbilityTP{ public: WParsedInt * life; - AALifeSet(int _id, MTGCardInstance * _source, Targetable * _target, WParsedInt * life, ManaCost * _cost=NULL, int doTap = 0, int who = TargetChooser::UNSET):ActivatedAbilityTP(_id,_source,_target,_cost,doTap,who),life(life){ + AALifeSet(int _id, MTGCardInstance * _source, Targetable * _target, WParsedInt * life, ManaCost * _cost=NULL, int doTap = 0, int who = TargetChooser::UNSET):ActivatedAbilityTP(_id, _source,_target,_cost,doTap,who),life(life){ } int resolve(){ @@ -2753,7 +2732,7 @@ class AADamager:public ActivatedAbilityTP{ public: WParsedInt * damage; - AADamager(int _id, MTGCardInstance * _source, Targetable * _target, WParsedInt * damage, ManaCost * _cost=NULL, int doTap = 0, int who = TargetChooser::UNSET):ActivatedAbilityTP(_id,_source,_target,_cost,doTap,who),damage(damage){ + AADamager(int _id, MTGCardInstance * _source, Targetable * _target, WParsedInt * damage, ManaCost * _cost=NULL, int doTap = 0, int who = TargetChooser::UNSET):ActivatedAbilityTP(_id, _source,_target,_cost,doTap,who),damage(damage){ aType = MTGAbility::DAMAGER; } @@ -2787,7 +2766,7 @@ public: class AADamagePrevent:public ActivatedAbilityTP{ public: int preventing; - AADamagePrevent(int _id, MTGCardInstance * _source, Targetable * _target,int preventing, ManaCost * _cost=NULL, int doTap = 0, int who = TargetChooser::UNSET):ActivatedAbilityTP(_id,_source,_target,_cost,doTap,who),preventing(preventing){ + AADamagePrevent(int _id, MTGCardInstance * _source, Targetable * _target,int preventing, ManaCost * _cost=NULL, int doTap = 0, int who = TargetChooser::UNSET):ActivatedAbilityTP(_id, _source,_target,_cost,doTap,who),preventing(preventing){ aType = MTGAbility::STANDARD_PREVENT; } @@ -2818,7 +2797,7 @@ public: class AAAlterPoison:public ActivatedAbilityTP{ public: int poison; - AAAlterPoison(int _id, MTGCardInstance * _source, Targetable * _target,int poison, ManaCost * _cost=NULL, int doTap = 0, int who = TargetChooser::UNSET):ActivatedAbilityTP(_id,_source,_target,_cost,doTap,who),poison(poison){ + AAAlterPoison(int _id, MTGCardInstance * _source, Targetable * _target,int poison, ManaCost * _cost=NULL, int doTap = 0, int who = TargetChooser::UNSET):ActivatedAbilityTP(_id, _source,_target,_cost,doTap,who),poison(poison){ } int resolve(){ @@ -3225,46 +3204,19 @@ public: } ~ABloodThirst(){} }; + //reduce or increase manacost of target by color:amount------------------------------------------ class AManaRedux:public MTGAbility{ public: int amount; int type; - AManaRedux(int id, MTGCardInstance * source, MTGCardInstance * target,int amount,int type):MTGAbility(id,source,target),amount(amount),type(type){ - MTGCardInstance * _target = (MTGCardInstance *)target; - } - int addToGame(){ - MTGCardInstance * _target = (MTGCardInstance *)target; - amount; - type; - if(amount < 0){ - //amount = amount * -1; - amount = abs(amount); - if(_target->getManaCost()->hasColor(type)){ - if(_target->getManaCost()->getConvertedCost() >= 1){ - _target->getManaCost()->remove(type,amount); - if(_target->getManaCost()->alternative > 0){ - _target->getManaCost()->alternative->remove(type,amount);} - if(_target->getManaCost()->BuyBack > 0){ - _target->getManaCost()->BuyBack->remove(type,amount);} - } - } - }else{ - _target->getManaCost()->add(type,amount); - if(_target->getManaCost()->alternative > 0){ - _target->getManaCost()->alternative->add(type,amount);} - if(_target->getManaCost()->BuyBack > 0){ - _target->getManaCost()->BuyBack->add(type,amount);} - } - return MTGAbility::addToGame(); - } - AManaRedux * clone() const{ - AManaRedux * a = NEW AManaRedux(*this); - a->isClone = 1; - return a; - } - ~AManaRedux(){} + AManaRedux(int id, MTGCardInstance * source, MTGCardInstance * target, int amount, int type); + int addToGame(); + AManaRedux * clone() const; + ~AManaRedux(); }; + + //------------------------------------ class ATransformer:public MTGAbility{ public: @@ -4170,7 +4122,7 @@ public: int usedThisTurn; int counters; Damage * latest; - ALivingArtifact(int _id, MTGCardInstance * _source, MTGCardInstance * _target):MTGAbility(_id,_source,_target){ + ALivingArtifact(int _id, MTGCardInstance * _source, MTGCardInstance * _target):MTGAbility(_id, _source,_target){ usedThisTurn = 0; counters = 0; latest = NULL; @@ -4367,7 +4319,7 @@ public: //1117 Jandor's Ring class AJandorsRing:public ActivatedAbility{ public: - AJandorsRing(int _id, MTGCardInstance * _source):ActivatedAbility(_id,_source, NEW ManaCost()){ + AJandorsRing(int _id, MTGCardInstance * _source):ActivatedAbility(_id, _source, NEW ManaCost()){ cost->add(Constants::MTG_COLOR_ARTIFACT, 2); } @@ -4709,7 +4661,7 @@ public: //1288 EarthBind class AEarthbind:public ABasicAbilityModifier{ public: - AEarthbind(int _id, MTGCardInstance * _source, MTGCardInstance * _target):ABasicAbilityModifier(_id,_source,_target,Constants::FLYING,0){ + AEarthbind(int _id, MTGCardInstance * _source, MTGCardInstance * _target):ABasicAbilityModifier(_id, _source,_target,Constants::FLYING,0){ if (value_before_modification){ Damageable * _target = (Damageable *)target; game->mLayers->stackLayer()->addDamage(source,_target,2); diff --git a/projects/mtg/include/MTGAbility.h b/projects/mtg/include/MTGAbility.h index 3b6139559..5aa8ecb53 100644 --- a/projects/mtg/include/MTGAbility.h +++ b/projects/mtg/include/MTGAbility.h @@ -280,13 +280,17 @@ class GenericTriggeredAbility:public TriggeredAbility, public NestedAbility{ class AbilityFactory{ private: int countCards(TargetChooser * tc, Player * player = NULL, int option = 0); - TriggeredAbility * parseTrigger(string s, int id, Spell * spell, MTGCardInstance *card, Targetable * target); + TriggeredAbility * parseTrigger(string s, string magicText, int id, Spell * spell, MTGCardInstance *card, Targetable * target); int parseRestriction(string s); - public: + MTGAbility * getAlternateCost( string s, int id, Spell *spell, MTGCardInstance *card ); + MTGAbility * getManaReduxAbility(string s, int id, Spell *spell, MTGCardInstance *card, MTGCardInstance *target); + +public: Counter * parseCounter(string s, MTGCardInstance * target, Spell * spell = NULL); int parsePowerToughness(string s, int *power, int *toughness); int getAbilities(vector * v, Spell * spell, MTGCardInstance * card = NULL, int id = 0,MTGGameZone * dest = NULL); MTGAbility * parseMagicLine(string s, int id, Spell * spell, MTGCardInstance *card, int activated = 0, int forceUEOT = 0,int oneShot = 0,int forceForever = 0, MTGGameZone * dest = NULL); + int abilityEfficiency(MTGAbility * a, Player * p, int mode = MODE_ABILITY, TargetChooser * tc = NULL); int magicText(int id, Spell * spell, MTGCardInstance * card = NULL, int mode = MODE_PUTINTOPLAY, TargetChooser * tc = NULL, MTGGameZone * dest = NULL); static int computeX(Spell * spell, MTGCardInstance * card); diff --git a/projects/mtg/include/MTGDefinitions.h b/projects/mtg/include/MTGDefinitions.h index 517816ab9..2cc4d763a 100644 --- a/projects/mtg/include/MTGDefinitions.h +++ b/projects/mtg/include/MTGDefinitions.h @@ -5,10 +5,36 @@ const float DEFAULT_MENU_FONT_SCALE = 1.0f; const float DEFAULT_MAIN_FONT_SCALE = 1.0f; const float DEFAULT_TEXT_FONT_SCALE = 1.0f; +#include +using std::string; class Constants { public: - enum + // Exception Codes + +/* Exception codes */ + const static int PARSER_FAILED_INSTANTIATION = 1000; + const static int PARSER_KEYWORD_NOT_MATCHED = 2000; + const static int PARSER_INVALID_KEYWORD = 3000; + + + // color constants + static const string kManaColorless; + static const string kManaGreen; + static const string kManaBlue; + static const string kManaRed; + static const string kManaBlack; + static const string kManaWhite; + + // alternative costs constants + + static const string kAlternativeKeyword; + static const string kBuyBackKeyword; + static const string kFlashBackKeyword; + static const string kRetraceKeyword; + static const string kKickerKeyword; + + enum { MTG_COLOR_ARTIFACT = 0, MTG_COLOR_GREEN = 1, @@ -186,6 +212,8 @@ class Constants static char MTGColorChars[]; static const char* MTGColorStrings[]; static int _r[], _g[], _b[]; + + static const char* MTGBasicAbilities[]; static const char* MTGPhaseNames[]; static const char* MTGPhaseCodeNames[]; diff --git a/projects/mtg/src/ActionStack.cpp b/projects/mtg/src/ActionStack.cpp index a2783d6aa..d3bb46641 100644 --- a/projects/mtg/src/ActionStack.cpp +++ b/projects/mtg/src/ActionStack.cpp @@ -192,24 +192,31 @@ int Spell::computeXX(MTGCardInstance * card){ return xx; } -bool Spell::kickerWasPaid(){ - return (payResult == ManaCost::MANA_PAID_WITH_KICKER); -} -bool Spell::AlternativeWasPaid(){ - return (payResult == ManaCost::MANA_PAID_WITH_ALTERNATIVE); -} +bool Spell::FullfilledAlternateCost(const int &costType) +{ + bool hasFullfilledAlternateCost = false; -bool Spell::BuyBackWasPaid(){ - return (payResult == ManaCost::MANA_PAID_WITH_BUYBACK); -} - -bool Spell::FlashBackWasPaid(){ - return (payResult == ManaCost::MANA_PAID_WITH_FLASHBACK); -} - -bool Spell::RetraceWasPaid(){ - return (payResult == ManaCost::MANA_PAID_WITH_RETRACE); + switch(costType) + { + case ManaCost::MANA_PAID_WITH_KICKER: + hasFullfilledAlternateCost = (payResult == ManaCost::MANA_PAID_WITH_KICKER); + break; + case ManaCost::MANA_PAID_WITH_ALTERNATIVE: + hasFullfilledAlternateCost = (payResult == ManaCost::MANA_PAID_WITH_ALTERNATIVE); + break; + case ManaCost::MANA_PAID_WITH_BUYBACK: + hasFullfilledAlternateCost = (payResult == ManaCost::MANA_PAID_WITH_BUYBACK); + break; + case ManaCost::MANA_PAID_WITH_FLASHBACK: + hasFullfilledAlternateCost = (payResult == ManaCost::MANA_PAID_WITH_FLASHBACK); + break; + case ManaCost::MANA_PAID_WITH_RETRACE: + hasFullfilledAlternateCost = (payResult == ManaCost::MANA_PAID_WITH_RETRACE); + break; + } + + return hasFullfilledAlternateCost; } const string Spell::getDisplayName() const { diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp new file mode 100644 index 000000000..12a484271 --- /dev/null +++ b/projects/mtg/src/AllAbilities.cpp @@ -0,0 +1,164 @@ +#include "PrecompiledHeader.h" +#include "AllAbilities.h" + +// BanishCard implementations + +AABanishCard::AABanishCard(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost=NULL, int _banishmentType = -1):ActivatedAbility(_id, _source,_cost),banishmentType(_banishmentType) { + if (_target) target = _target; +} + +const char * AABanishCard::getMenuText() +{ + return "Send to graveyard"; +} + +int AABanishCard::resolve() +{ + DebugTrace("This is not implemented!"); + return 0; +} + +AABanishCard * AABanishCard::clone() const{ + AABanishCard * a = NEW AABanishCard(*this); + a->isClone = 1; + return a; +} + +// Bury + +AABuryCard::AABuryCard(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost = NULL , int _banishmentType = 0):AABanishCard(_id, _source, _target, _cost, AABanishCard::BURY) +{} + +int AABuryCard::resolve(){ + MTGCardInstance * _target = (MTGCardInstance *) target; + if(_target){ + return _target->bury(); + } + return 0; +} + +const char * AABuryCard::getMenuText(){ + return "Bury"; +} + +AABuryCard * AABuryCard::clone() const{ + AABuryCard * a = NEW AABuryCard(*this); + a->isClone = 1; + return a; +} + + +// Destroy + +AADestroyCard::AADestroyCard(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost = NULL, int _banishmentType = 0):AABanishCard(_id, _source, _target, _cost, AABanishCard::DESTROY) +{} + +int AADestroyCard::resolve(){ + MTGCardInstance * _target = (MTGCardInstance *) target; + if(_target){ + return _target->destroy(); + } + return 0; +} + +const char * AADestroyCard::getMenuText(){ + return "Destroy"; +} + +AADestroyCard * AADestroyCard::clone() const{ + AADestroyCard * a = NEW AADestroyCard(*this); + a->isClone = 1; + return a; +} + +// Sacrifice +AASacrificeCard::AASacrificeCard(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost = NULL, int _banishmentType = 0):AABanishCard(_id, _source, _target, _cost, AABanishCard::SACRIFICE) { +} + +int AASacrificeCard::resolve(){ + MTGCardInstance * _target = (MTGCardInstance *) target; + if(_target){ + Player * p = _target->controller(); + WEvent * e = NEW WEventCardSacrifice(_target); + GameObserver * game = GameObserver::GetInstance(); + game->receiveEvent(e); + p->game->putInGraveyard(_target); + return 1; + } + return 0; +} + +const char * AASacrificeCard::getMenuText(){ + return "Sacrifice"; +} + +AASacrificeCard * AASacrificeCard::clone() const{ + AASacrificeCard * a = NEW AASacrificeCard(*this); + a->isClone = 1; + return a; +} + +// Discard + +AADiscardCard::AADiscardCard(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost = NULL, int _banishmentType = 0):AABanishCard(_id, _source, _target, _cost, AABanishCard::DISCARD) { +} + +int AADiscardCard::resolve(){ + MTGCardInstance * _target = (MTGCardInstance *) target; + if(_target){ + Player * p = _target->controller(); + WEvent * e = NEW WEventCardDiscard(_target); + GameObserver * game = GameObserver::GetInstance(); + game->receiveEvent(e); + p->game->putInGraveyard(_target); + return 1; + } + return 0; +} + +const char * AADiscardCard::getMenuText(){ + return "Discard"; +} + +AADiscardCard * AADiscardCard::clone() const{ + AADiscardCard * a = NEW AADiscardCard(*this); + a->isClone = 1; + return a; +} + + +//Mana Redux +AManaRedux::AManaRedux(int id, MTGCardInstance * source, MTGCardInstance * target,int amount,int type):MTGAbility(id,source,target),amount(amount),type(type) { + MTGCardInstance * _target = (MTGCardInstance *)target; +} + +int AManaRedux::addToGame(){ + MTGCardInstance * _target = (MTGCardInstance *)target; + if(amount < 0){ + amount = abs(amount); + if(_target->getManaCost()->hasColor(type)){ + if(_target->getManaCost()->getConvertedCost() >= 1){ + _target->getManaCost()->remove(type,amount); + if(_target->getManaCost()->alternative > 0){ + _target->getManaCost()->alternative->remove(type,amount);} + if(_target->getManaCost()->BuyBack > 0){ + _target->getManaCost()->BuyBack->remove(type,amount);} + } + } + }else{ + _target->getManaCost()->add(type,amount); + if(_target->getManaCost()->alternative > 0){ + _target->getManaCost()->alternative->add(type,amount);} + if(_target->getManaCost()->BuyBack > 0){ + _target->getManaCost()->BuyBack->add(type,amount);} + } + return MTGAbility::addToGame(); +} + +AManaRedux * AManaRedux::clone() const { + AManaRedux * a = NEW AManaRedux(*this); + a->isClone = 1; + return a; +} + +AManaRedux::~AManaRedux(){} diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index cd9e2b733..be6963aaa 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -93,13 +93,11 @@ int AbilityFactory::parsePowerToughness(string s, int *power, int *toughness){ return 0; } -TriggeredAbility * AbilityFactory::parseTrigger(string magicText, int id, Spell * spell, MTGCardInstance *card, Targetable * target){ - size_t found = magicText.find("@"); - if (found == string::npos) return NULL; - - found = magicText.find(":"); - if (found == string::npos) return NULL; - string s = magicText.substr(0,found); +// evaluate trigger ability +// ie auto=@attacking(mytgt):destroy target(*) +// eval only the text between the @ and the first : +TriggeredAbility * AbilityFactory::parseTrigger(string s, string magicText, int id, Spell * spell, MTGCardInstance *card, Targetable * target){ + size_t found = string::npos; //Card Changed Zone found = s.find("movedto("); @@ -424,7 +422,6 @@ MTGAbility * AbilityFactory::getCoreAbility(MTGAbility * a){ //Beware, Spell CAN be null when the function is called by the AI trying to analyze the effects of a given card MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTGCardInstance *card, int activated, int forceUEOT, int oneShot,int forceFOREVER, MTGGameZone * dest){ size_t found; - trim(s); //TODO This block redundant with calling function @@ -433,20 +430,30 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG MTGCardInstance * target = card->target; if (!target) target = card; - TriggeredAbility * trigger = NULL; - trigger = parseTrigger(s,id,spell,card,target); - //Dirty way to remove the trigger text (could get in the way) - if (trigger){ - found = s.find(":"); - string s1 = s.substr(found+1); - MTGAbility * a = parseMagicLine(s1, id, spell, card,activated); - if (!a){ - delete trigger; - return NULL; - } - return NEW GenericTriggeredAbility(id,card,trigger,a,NULL,target); - } + found = s.find("@"); + if ( found != string::npos ) + { + found = s.find(":", found); + if (found != string::npos) + { + TriggeredAbility * trigger = NULL; + string triggerText = s.substr(0, found ); + trigger = parseTrigger(triggerText, s,id,spell,card,target); + //Dirty way to remove the trigger text (could get in the way) + if (trigger) + { + //found = s.find(":", found); + string s1 = s.substr(found+1); + MTGAbility * a = parseMagicLine(s1, id, spell, card,activated); + if (!a){ + delete trigger; + return NULL; + } + return NEW GenericTriggeredAbility(id,card,trigger,a,NULL,target); + } + } + } int doTap = 0; //Tap in the cost ? if (s.find("{t}") != string::npos) doTap = 1; @@ -515,55 +522,47 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG SAFE_DELETE(cost); } - //kicker cost - found = s.find("kicker "); - if (found == 0){ - if (spell && spell->kickerWasPaid()){ - string s1 = s.substr(found+7); - return parseMagicLine(s1,id,spell, card); + // figure out alternative cost effects + string keyword; + int costType = -1; + if (s.find( Constants::kKickerKeyword ) == 0 ) + { + costType = ManaCost::MANA_PAID_WITH_KICKER; + keyword = Constants::kKickerKeyword; + } + if (s.find( Constants::kRetraceKeyword ) == 0 ) + { + costType = ManaCost::MANA_PAID_WITH_RETRACE; + keyword = Constants::kRetraceKeyword; + } + if (s.find( Constants::kAlternativeKeyword ) == 0 ) + { + costType = ManaCost::MANA_PAID_WITH_ALTERNATIVE; + keyword = Constants::kAlternativeKeyword ; + } + if (s.find( Constants::kBuyBackKeyword ) == 0 ) + { + costType = ManaCost::MANA_PAID_WITH_BUYBACK; + keyword = Constants::kBuyBackKeyword; + } + if (s.find( Constants::kFlashBackKeyword ) == 0 ) + { + costType = ManaCost::MANA_PAID_WITH_FLASHBACK; + keyword = Constants::kFlashBackKeyword; + } + + if ( (costType > -1) && (!keyword.empty()) ) + { + if ( spell && spell->FullfilledAlternateCost( costType )) + { + string s1 = s.substr(keyword.length()); + return parseMagicLine(s1, id, spell, card); } + DebugTrace("INFO parseMagicLine: Alternative Cost was not fulfilled for " << s); return NULL; } - //alternative cost - found = s.find("alternative "); - if (found == 0){ - if (spell && spell->AlternativeWasPaid()){ - string s1 = s.substr(found+12); - return parseMagicLine(s1,id,spell, card); - } - return NULL; - } - //buyback cost - found = s.find("buyback "); - if (found == 0){ - if (spell && spell->BuyBackWasPaid()){ - string s1 = s.substr(found+8); - return parseMagicLine(s1,id,spell, card); - } - return NULL; - } - - //flashback cost - found = s.find("flashback "); - if (found == 0){ - if (spell && spell->FlashBackWasPaid()){ - string s1 = s.substr(found+9); - return parseMagicLine(s1,id,spell, card); - } - return NULL; - } - - //retrace cost - found = s.find("retrace "); - if (found == 0){ - if (spell && spell->RetraceWasPaid()){ - string s1 = s.substr(found+8); - return parseMagicLine(s1,id,spell, card); - } - return NULL; - } //When...comes into play, you may... found = s.find("may "); if (found == 0){ @@ -587,7 +586,6 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG return NEW MayAbility(id,a1,card,true); } - //Multiple abilities for ONE cost found = s.find("&&"); if (found != string::npos){ @@ -602,6 +600,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG multi->oneShot=1; return multi; } + //rather dirty way to stop thises and lords from conflicting with each other. string prelords[] = {"foreach(","lord(","aslongas(", "all("}; @@ -628,49 +627,49 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG //why does tc even exist here? This shouldn't happen... SAFE_DELETE(tc); //http://code.google.com/p/wagic/issues/detail?id=424 - size_t header = thises[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){ - string thisDescriptorString = s.substr(found+header,end-found-header); - ThisDescriptorFactory tdf; - ThisDescriptor * td = tdf.createThisDescriptor(thisDescriptorString); - - if (!td){ - DebugTrace("MTGABILITY: Parsing Error:" << s); - return NULL; - } + size_t header = thises[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){ + string thisDescriptorString = s.substr(found+header,end-found-header); + ThisDescriptorFactory tdf; + ThisDescriptor * td = tdf.createThisDescriptor(thisDescriptorString); - MTGAbility * a = parseMagicLine(s1,id,spell, card,0,activated); - if (!a){ - SAFE_DELETE(td); - return NULL; - } - MTGAbility * result = NULL; - int oneShot = 0; - found = s.find(" oneshot"); - if (found !=string::npos) oneShot = 1; - if (activated) oneShot = 1; - if (card->hasType("sorcery") || card->hasType("instant")) oneShot = 1; - if (a->oneShot) oneShot = 1; - Damageable * _target = NULL; - if (spell) _target = spell->getNextDamageableTarget(); - if (!_target) _target = target; + if (!td){ + DebugTrace("MTGABILITY: Parsing Error:" << s); + return NULL; + } - switch(i){ + MTGAbility * a = parseMagicLine(s1,id,spell, card,0,activated); + if (!a){ + SAFE_DELETE(td); + return NULL; + } + MTGAbility * result = NULL; + int oneShot = 0; + found = s.find(" oneshot"); + if (found !=string::npos) oneShot = 1; + if (activated) oneShot = 1; + if (card->hasType("sorcery") || card->hasType("instant")) oneShot = 1; + if (a->oneShot) oneShot = 1; + Damageable * _target = NULL; + if (spell) _target = spell->getNextDamageableTarget(); + if (!_target) _target = target; + + switch(i){ case 0: result = NEW AThis(id, card, _target, td, a); break; case 1: result = NEW AThisForEach(id, card, _target, td, a); break; default: result = NULL; - } - if (result){ result->oneShot = oneShot;} - return result; - } - return NULL; + } + if (result){ result->oneShot = oneShot;} + return result; + } + return NULL; } @@ -967,33 +966,31 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG return a; } - //Bury, destroy - string destroys[] = {"bury","destroy"}; - int destroyTypes[]= {1, 0}; - for (int i = 0; i < 2; ++i){ - found = s.find(destroys[i]); - if (found != string::npos){ - int bury = destroyTypes[i]; - MTGAbility * a = NEW AADestroyer(id,card,target,bury); - a->oneShot = 1; - return a; - } + //Bury, destroy, sacrifice, reject(discard) + if ( s.find("bury") != string::npos ) + { + MTGAbility *a = NEW AABuryCard(id, card, target, NULL, AABanishCard::BURY); + a->oneShot = 1; + return a; } - - //sacrifices and discards - string sacdis[] = {"sacrifice","reject"}; - int sacdisTypes[]= {1, 0}; - for (int i = 0; i < 2; ++i){ - found = s.find(sacdis[i]); - if (found != string::npos){ - int sacrifice = sacdisTypes[i]; - MTGAbility * a = NEW AASacDis(id,card,target,sacrifice); - a->oneShot = 1; - return a; - } + else if ( s.find("destroy") != string::npos ) + { + MTGAbility * a = NEW AADestroyCard(id, card, target, NULL, AABanishCard::DESTROY); + a->oneShot = 1; + return a; + } + else if ( s.find("sacrifice") != string::npos ) + { + MTGAbility *a = NEW AASacrificeCard(id, card, target, NULL, AABanishCard::SACRIFICE); + a->oneShot = 1; + return a; + } + else if ( s.find("reject") != string::npos ) + { + MTGAbility *a = NEW AADiscardCard(id, card, target, NULL, AABanishCard::DISCARD); + a->oneShot = 1; + return a; } - - int who = TargetChooser::UNSET; if (s.find(" controller") != string::npos) who=TargetChooser::CONTROLLER; @@ -1332,7 +1329,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG int power, toughness; if (parsePowerToughness(spt,&power, &toughness)){ int MaxOpponent = atoi(s.substr(end+1,end+2).c_str()); - return NEW ARampageAbility(id,card,power,toughness,MaxOpponent); + return NEW ARampageAbility(id,card,power,toughness,MaxOpponent); } return NULL; } @@ -1410,71 +1407,16 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG return a; } + if ( s.find("manaredux(") != string::npos ) + return getManaReduxAbility( s.substr( s.find("manaredux(") + 10), id, spell, card, target ); - -//ManaRedux - found = s.find("colorless:"); - if (found != string::npos){ - size_t start = s.find(":",found); - size_t end = s.find(" ",start); - int amount; - if (end != string::npos){amount = atoi(s.substr(start+1,end-start-1).c_str());} - else{amount = atoi(s.substr(start+1).c_str());} - MTGAbility * a = NEW AManaRedux(id,card,target,amount,0); - return a;} - found = s.find("green:"); - if (found != string::npos){ - size_t start = s.find(":",found); - size_t end = s.find(" ",start); - int amount; - if (end != string::npos){amount = atoi(s.substr(start+1,end-start-1).c_str());} - else{amount = atoi(s.substr(start+1).c_str());} - MTGAbility * a = NEW AManaRedux(id,card,target,amount,1); - return a;} - found = s.find("blue:"); - if (found != string::npos){ - size_t start = s.find(":",found); - size_t end = s.find(" ",start); - int amount; - if (end != string::npos){amount = atoi(s.substr(start+1,end-start-1).c_str());} - else{amount = atoi(s.substr(start+1).c_str());} - MTGAbility * a = NEW AManaRedux(id,card,target,amount,2); - return a;} - found = s.find("red:"); - if (found != string::npos){ - size_t start = s.find(":",found); - size_t end = s.find(" ",start); - int amount; - if (end != string::npos){amount = atoi(s.substr(start+1,end-start-1).c_str());} - else{amount = atoi(s.substr(start+1).c_str());} - MTGAbility * a = NEW AManaRedux(id,card,target,amount,3); - return a;} - found = s.find("black:"); - if (found != string::npos){ - size_t start = s.find(":",found); - size_t end = s.find(" ",start); - int amount; - if (end != string::npos){amount = atoi(s.substr(start+1,end-start-1).c_str());} - else{amount = atoi(s.substr(start+1).c_str());} - MTGAbility * a = NEW AManaRedux(id,card,target,amount,4); - return a;} - found = s.find("white:"); - if (found != string::npos){ - size_t start = s.find(":",found); - size_t end = s.find(" ",start); - int amount; - if (end != string::npos){amount = atoi(s.substr(start+1,end-start-1).c_str());} - else{amount = atoi(s.substr(start+1).c_str());} - MTGAbility * a = NEW AManaRedux(id,card,target,amount,5); - return a; - } //resetcost dirty code found = s.find("resetcost"); - if (found != string::npos){ - MTGAbility * a = NEW AResetCost(id,card,target); - return a; - } - //transform....(hivestone,living enchantment) + if (found != string::npos){ + MTGAbility * a = NEW AResetCost(id,card,target); + return a; + } + //transform....(hivestone,living enchantment) found = s.find("transforms("); if (found != string::npos){ size_t real_end = s.find(")", found); @@ -1489,16 +1431,18 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG } if (end != real_end){ sabilities = s.substr(end+1, real_end - end); - } + } MTGAbility * a; - if(forceFOREVER){a = NEW ATransformerFOREVER(id,card,target,stypes,sabilities); - } + if(forceFOREVER){ + a = NEW ATransformerFOREVER(id,card,target,stypes,sabilities); + } else if (forceUEOT){ a = NEW ATransformerUEOT(id,card,target,stypes,sabilities); - }else{ + } + else{ a = NEW ATransformer(id,card,target,stypes,sabilities); - } - return a; + } + return a; } //Change Power/Toughness WParsedPT * wppt = NEW WParsedPT(s,spell,card); @@ -1510,7 +1454,8 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG return NEW APowerToughnessModifier(id, card, target,wppt); } return NEW APowerToughnessModifierUntilEndOfTurn(id,card,target,wppt); - }else{ + } + else{ delete wppt; } @@ -1561,22 +1506,6 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG return NULL; //TODO } - //Gain/loose simple Ability - for (int j = 0; j < Constants::NB_BASIC_ABILITIES; j++){ - found = s.find(Constants::MTGBasicAbilities[j]); - if (found == 0 || found == 1){ - int modifier = 1; - if (found > 0 && s[found-1] == '-') modifier = 0; - if (!activated){ - if(card->hasType("instant") || card->hasType("sorcery") || forceUEOT){ - return NEW AInstantBasicAbilityModifierUntilEOT(id, card,target, j,modifier); - } - return NEW ABasicAbilityModifier(id, card,target, j,modifier); - } - return NEW ABasicAbilityAuraModifierUntilEOT(id, card,target, NULL,j,modifier); - } - } - //frozen, next untap this does not untap. found = s.find("frozen"); if (found != string::npos){ @@ -1610,6 +1539,25 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG return a; } + //Gain/loose simple Ability + DebugTrace(" start gain/lose simple ability " ); + for (int j = 0; j < Constants::NB_BASIC_ABILITIES; j++){ + found = s.find(Constants::MTGBasicAbilities[j]); + DebugTrace( "basic ability search at index " << Constants::MTGBasicAbilities[j] ); + if (found == 0 || found == 1){ + int modifier = 1; + if (found > 0 && s[found-1] == '-') modifier = 0; + if (!activated){ + if(card->hasType("instant") || card->hasType("sorcery") || forceUEOT){ + return NEW AInstantBasicAbilityModifierUntilEOT(id, card,target, j,modifier); + } + return NEW ABasicAbilityModifier(id, card,target, j,modifier); + } + return NEW ABasicAbilityAuraModifierUntilEOT(id, card,target, NULL,j,modifier); + } + } + + DebugTrace(" end gain/lose simple ability " ); //Untapper (Ley Druid...) found = s.find("untap"); if (found != string::npos){ @@ -1625,7 +1573,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG a->oneShot = 1; return a; } - return NULL; + + DebugTrace(" no matching ability found. " << s); + return NULL; } //Tells the AI if the ability should target itself or an ennemy @@ -1673,7 +1623,8 @@ int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode, Targ } if (dynamic_cast(a)) return BAKA_EFFECT_GOOD; - if (dynamic_cast(a)) return BAKA_EFFECT_BAD; + if (dynamic_cast(a)) return BAKA_EFFECT_BAD; + if (dynamic_cast(a)) return BAKA_EFFECT_BAD; if (dynamic_cast(a)) return BAKA_EFFECT_GOOD; if (AALifer * abi = dynamic_cast(a)) return abi->life > 0 ? BAKA_EFFECT_GOOD : BAKA_EFFECT_BAD; if (dynamic_cast(a)) return BAKA_EFFECT_BAD; @@ -2435,6 +2386,53 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){ } + +//mehods used in parseMagicLine() + +//ManaRedux -> manaredux(colorless,+2) +// -> manaredux(green,-2) +MTGAbility * AbilityFactory::getManaReduxAbility(string s, int id, Spell *spell, MTGCardInstance *card, MTGCardInstance *target) +{ + int color = -1; + string manaCost; + size_t endIndex = manaCost.find(")"); + if ( s.find( Constants::kManaColorless ) != string::npos) { + manaCost = s.substr( s.find(",")+ 1, endIndex ); + color = Constants::MTG_COLOR_ARTIFACT; + } + else if (s.find( Constants::kManaGreen ) != string::npos){ + manaCost = s.substr( s.find(",")+ 1, endIndex ); + color = Constants::MTG_COLOR_GREEN; + } + else if ( s.find( Constants::kManaBlue ) != string::npos){ + manaCost = s.substr( s.find(",")+ 1, endIndex ); + color = Constants::MTG_COLOR_BLUE; + } + else if ( s.find( Constants::kManaRed ) != string::npos){ + manaCost = s.substr( s.find(",") + 1, endIndex ); + color = Constants::MTG_COLOR_RED; + } + else if ( s.find( Constants::kManaBlack ) != string::npos){ + manaCost = s.substr( s.find(",")+ 1, endIndex ); + color = Constants::MTG_COLOR_BLACK; + } + else if ( s.find( Constants::kManaWhite ) != string::npos){ + manaCost = s.substr( s.find(",")+ 1, endIndex ); + color = Constants::MTG_COLOR_WHITE; + } + else + { + DebugTrace("An error has happened in creating a Mana Redux Ability! " << s ); + return NULL; + } + // figure out the mana cost + int amount = atoi(manaCost.c_str()); + return NEW AManaRedux(id, card, target, amount, color); +} + + + + MTGAbility::MTGAbility(int id, MTGCardInstance * card):ActionElement(id){ game = GameObserver::GetInstance(); source = card; diff --git a/projects/mtg/src/MTGDefinitions.cpp b/projects/mtg/src/MTGDefinitions.cpp index 3352b17f7..f2261b993 100644 --- a/projects/mtg/src/MTGDefinitions.cpp +++ b/projects/mtg/src/MTGDefinitions.cpp @@ -1,14 +1,31 @@ #include "PrecompiledHeader.h" +#include +using std::string; #include "MTGDefinitions.h" char Constants::MTGColorChars[] = {'x','g','u','r','b','w','l'}; const char* Constants::MTGColorStrings[] = {"artifact", "green", "blue", "red", "black", "white", "land"}; +const string Constants::kManaColorless = "colorless"; +const string Constants::kManaGreen = "green"; +const string Constants::kManaBlue = "blue"; +const string Constants::kManaRed = "red"; +const string Constants::kManaBlack = "black"; +const string Constants::kManaWhite = "white"; + int Constants::_r[7] = {75, 20, 20, 200,50,255,128}; int Constants::_g[7] = {30, 140, 30, 15, 50,255,128}; int Constants::_b[7] = {20, 0, 140,15, 50,255,128}; + +const string Constants::kAlternativeKeyword = "alternative"; +const string Constants::kBuyBackKeyword = "buyback"; +const string Constants::kFlashBackKeyword = "flashback"; +const string Constants::kRetraceKeyword = "retrace"; +const string Constants::kKickerKeyword = "kicker"; + + const char* Constants::MTGBasicAbilities[] = { "trample", "forestwalk", diff --git a/projects/mtg/template.vcproj b/projects/mtg/template.vcproj index b0312ba13..823518c0d 100644 --- a/projects/mtg/template.vcproj +++ b/projects/mtg/template.vcproj @@ -445,6 +445,10 @@ RelativePath=".\src\AIStats.cpp" > + + @@ -1347,10 +1351,6 @@ Name="Resource Files" Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" > - -