From cc90fc61c60b412382883731dfdba683febc1b80 Mon Sep 17 00:00:00 2001 From: swordshine Date: Wed, 6 Aug 2014 05:59:40 +0000 Subject: [PATCH] - Added North Star --- .gitattributes | 1 + .../src/main/java/forge/card/MagicColor.java | 10 ++++++++++ .../java/forge/game/phase/PhaseHandler.java | 1 + .../main/java/forge/game/player/Player.java | 19 +++++++++++++++++++ .../res/cardsfolder/d/daxos_of_meletis.txt | 7 +++---- forge-gui/res/cardsfolder/n/north_star.txt | 7 +++++++ .../res/cardsfolder/p/psychic_intrusion.txt | 5 ++--- .../forge/player/HumanPlaySpellAbility.java | 18 ++++++++++++------ 8 files changed, 55 insertions(+), 13 deletions(-) create mode 100644 forge-gui/res/cardsfolder/n/north_star.txt diff --git a/.gitattributes b/.gitattributes index 17260d9dddf..c1895a95e1f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9440,6 +9440,7 @@ forge-gui/res/cardsfolder/n/norin_the_wary.txt svneol=native#text/plain forge-gui/res/cardsfolder/n/norns_annex.txt -text forge-gui/res/cardsfolder/n/norns_dominion.txt -text forge-gui/res/cardsfolder/n/norritt.txt -text +forge-gui/res/cardsfolder/n/north_star.txt -text forge-gui/res/cardsfolder/n/northern_paladin.txt svneol=native#text/plain forge-gui/res/cardsfolder/n/norwood_archers.txt svneol=native#text/plain forge-gui/res/cardsfolder/n/norwood_priestess.txt svneol=native#text/plain diff --git a/forge-core/src/main/java/forge/card/MagicColor.java b/forge-core/src/main/java/forge/card/MagicColor.java index f9fd57062bb..635d614bcde 100644 --- a/forge-core/src/main/java/forge/card/MagicColor.java +++ b/forge-core/src/main/java/forge/card/MagicColor.java @@ -1,6 +1,7 @@ package forge.card; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import java.util.List; @@ -127,5 +128,14 @@ public class MagicColor { /** The Basic lands. */ public static final List BASIC_LANDS = ImmutableList.of("Plains", "Island", "Swamp", "Mountain", "Forest"); public static final List SNOW_LANDS = ImmutableList.of("Snow-Covered Plains", "Snow-Covered Island", "Snow-Covered Swamp", "Snow-Covered Mountain", "Snow-Covered Forest"); + public static final ImmutableMap ANY_MANA_CONVERSION = new ImmutableMap.Builder() + .put("ManaColorConversion", "Additive") + .put("WhiteConversion", "All") + .put("BlueConversion", "All") + .put("BlackConversion", "All") + .put("RedConversion", "All") + .put("GreenConversion", "All") + .put("ColorlessConversion", "All") + .build(); } } diff --git a/forge-game/src/main/java/forge/game/phase/PhaseHandler.java b/forge-game/src/main/java/forge/game/phase/PhaseHandler.java index 895f5561d72..b998d1959df 100644 --- a/forge-game/src/main/java/forge/game/phase/PhaseHandler.java +++ b/forge-game/src/main/java/forge/game/phase/PhaseHandler.java @@ -733,6 +733,7 @@ public class PhaseHandler implements java.io.Serializable, IGameStateObject { p.setLifeLostThisTurn(0); p.setLifeGainedThisTurn(0); p.setLibrarySearched(0); + p.setNumManaConversion(0); p.removeKeyword("At the beginning of this turn's end step, you lose the game."); p.removeKeyword("Skip the untap step of this turn."); diff --git a/forge-game/src/main/java/forge/game/player/Player.java b/forge-game/src/main/java/forge/game/player/Player.java index 3cbfbf7b521..b60a7b41d83 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -184,6 +184,8 @@ public class Player extends GameEntity implements Comparable { private List lostOwnership = new ArrayList(); private List gainedOwnership = new ArrayList(); + private int numManaConversion = 0; + public final PlayerOutcome getOutcome() { return stats.getOutcome(); } @@ -2332,6 +2334,23 @@ public class Player extends GameEntity implements Comparable { this.numLibrarySearchedOwn++; } + public final void setNumManaConversion(final int l) { + this.numManaConversion = l; + } + + public final boolean hasManaConversion() { + return this.numManaConversion < this.getAmountOfKeyword("You may spend mana as though" + + " it were mana of any color to cast a spell this turn."); + } + + public final void incNumManaConversion() { + this.numManaConversion++; + } + + public final void decNumManaConversion() { + this.numManaConversion--; + } + /* * (non-Javadoc) * diff --git a/forge-gui/res/cardsfolder/d/daxos_of_meletis.txt b/forge-gui/res/cardsfolder/d/daxos_of_meletis.txt index d252988f581..d0a9244e25b 100644 --- a/forge-gui/res/cardsfolder/d/daxos_of_meletis.txt +++ b/forge-gui/res/cardsfolder/d/daxos_of_meletis.txt @@ -7,13 +7,12 @@ T:Mode$ DamageDone | ValidSource$ Card.Self | ValidTarget$ Player | CombatDamage SVar:TrigExile:AB$ Mill | Cost$ 0 | Defined$ TriggeredTarget | NumCards$ 1 | Destination$ Exile | RememberMilled$ True | SubAbility$ DBGainLife SVar:DBGainLife:DB$ GainLife | Defined$ You | LifeAmount$ X | References$ X | SubAbility$ DBEffect SVar:X:Remembered$CardManaCost -SVar:DBEffect:DB$ Effect | StaticAbilities$ STPlay,STPlay2 | Triggers$ TriggerCastDoM | SVars$ TrigRemoveSelf,DoM | RememberObjects$ Remembered | SubAbility$ DBCleanup -SVar:STPlay:Mode$ Continuous | EffectZone$ Command | Affected$ Card.IsRemembered+nonLand+YouOwn | AddSVar$ DoM | AddHiddenKeyword$ May be played & May spend mana as though it were mana of any color to cast CARDNAME | AffectedZone$ Exile | Description$ Until end of turn, you may cast that card and you may spend mana as though it were mana of any color to cast it. -SVar:STPlay2:Mode$ Continuous | EffectZone$ Command | Affected$ Card.IsRemembered+nonLand+OppOwn | AddSVar$ DoM | AddHiddenKeyword$ May be played by your opponent & May spend mana as though it were mana of any color to cast CARDNAME | AffectedZone$ Exile +SVar:DBEffect:DB$ Effect | StaticAbilities$ STPlay,STPlay2 | Triggers$ TriggerCastDoM | SVars$ TrigRemoveSelf | RememberObjects$ Remembered | SubAbility$ DBCleanup +SVar:STPlay:Mode$ Continuous | EffectZone$ Command | Affected$ Card.IsRemembered+nonLand+YouOwn | AddHiddenKeyword$ May be played & May spend mana as though it were mana of any color to cast CARDNAME | AffectedZone$ Exile | Description$ Until end of turn, you may cast that card and you may spend mana as though it were mana of any color to cast it. +SVar:STPlay2:Mode$ Continuous | EffectZone$ Command | Affected$ Card.IsRemembered+nonLand+OppOwn | AddHiddenKeyword$ May be played by your opponent & May spend mana as though it were mana of any color to cast CARDNAME | AffectedZone$ Exile SVar:TriggerCastDoM:Mode$ SpellCast | ValidCard$ Card.IsRemembered | TriggerZones$ Command | Execute$ TrigRemoveSelf | Static$ True SVar:TrigRemoveSelf:DB$ ChangeZone | Defined$ Self | Origin$ Command | Destination$ Exile SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True -SVar:DoM:SVar:ManaConversionMatrix:ManaColorConversion$ Additive | WhiteConversion$ All | BlueConversion$ All | BlackConversion$ All | RedConversion$ All | GreenConversion$ All | ColorlessConversion$ All SVar:RemAIDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/daxos_of_meletis.jpg Oracle:Daxos of Meletis can't be blocked by creatures with power 3 or greater.\nWhenever Daxos of Meletis deals combat damage to a player, exile the top card of that player's library. You gain life equal to that card's converted mana cost. Until end of turn, you may cast that card and you may spend mana as though it were mana of any color to cast it. diff --git a/forge-gui/res/cardsfolder/n/north_star.txt b/forge-gui/res/cardsfolder/n/north_star.txt new file mode 100644 index 00000000000..e1080342955 --- /dev/null +++ b/forge-gui/res/cardsfolder/n/north_star.txt @@ -0,0 +1,7 @@ +Name:North Star +ManaCost:4 +Types:Artifact +A:AB$ Pump | Cost$ 4 T | Defined$ You | KW$ You may spend mana as though it were mana of any color to cast a spell this turn. | SpellDescription$ For one spell this turn, you may spend mana as though it were mana of any color to pay that spell's mana cost. (Additional costs are still paid normally.) +SVar:RemAIDeck:True +SVar:Picture:http://www.wizards.com/global/images/magic/general/north_star.jpg +Oracle:{4}, {T}: For one spell this turn, you may spend mana as though it were mana of any color to pay that spell's mana cost. (Additional costs are still paid normally.) diff --git a/forge-gui/res/cardsfolder/p/psychic_intrusion.txt b/forge-gui/res/cardsfolder/p/psychic_intrusion.txt index daeed019a37..73e0c18be31 100644 --- a/forge-gui/res/cardsfolder/p/psychic_intrusion.txt +++ b/forge-gui/res/cardsfolder/p/psychic_intrusion.txt @@ -2,12 +2,11 @@ Name:Psychic Intrusion ManaCost:3 U B Types:Sorcery A:SP$ ChangeZone | Cost$ 3 U B | Origin$ Hand,Graveyard | Destination$ Exile | ValidTgts$ Opponent | DefinedPlayer$ Targeted | Chooser$ You | TgtPrompt$ Select target opponent | ChangeType$ Card.nonLand | ChangeNum$ 1 | IsCurse$ True | RememberChanged$ True | SubAbility$ DBEffect | StackDescription$ SpellDescription | SpellDescription$ Target opponent reveals his or her hand. You choose a nonland card from that player's graveyard or hand and exile it. You may cast that card for as long as it remains exiled, and you may spend mana as though it were mana of any color to cast that spell. -SVar:DBEffect:DB$ Effect | StaticAbilities$ STPlay | Triggers$ TriggerCastPI | SVars$ TrigRemoveSelf,ManaConversionPI | RememberObjects$ Remembered | Duration$ Permanent | SubAbility$ DBCleanup -SVar:STPlay:Mode$ Continuous | EffectZone$ Command | Affected$ Card.IsRemembered+OppOwn | AddSVar$ ManaConversionPI | AddHiddenKeyword$ May be played by your opponent & May spend mana as though it were mana of any color to cast CARDNAME | AffectedZone$ Exile | Description$ You may cast that card and you may spend mana as though it were mana of any color to cast it. +SVar:DBEffect:DB$ Effect | StaticAbilities$ STPlay | Triggers$ TriggerCastPI | SVars$ TrigRemoveSelf | RememberObjects$ Remembered | Duration$ Permanent | SubAbility$ DBCleanup +SVar:STPlay:Mode$ Continuous | EffectZone$ Command | Affected$ Card.IsRemembered+OppOwn | AddHiddenKeyword$ May be played by your opponent & May spend mana as though it were mana of any color to cast CARDNAME | AffectedZone$ Exile | Description$ You may cast that card and you may spend mana as though it were mana of any color to cast it. SVar:TriggerCastPI:Mode$ SpellCast | ValidCard$ Card.IsRemembered | TriggerZones$ Command | Execute$ TrigRemoveSelf | Static$ True SVar:TrigRemoveSelf:DB$ ChangeZone | Defined$ Self | Origin$ Command | Destination$ Exile SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True -SVar:ManaConversionPI:SVar:ManaConversionMatrix:ManaColorConversion$ Additive | WhiteConversion$ All | BlueConversion$ All | BlackConversion$ All | RedConversion$ All | GreenConversion$ All | ColorlessConversion$ All SVar:RemAIDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/psychic_intrusion.jpg Oracle:Target opponent reveals his or her hand. You choose a nonland card from that player's graveyard or hand and exile it. You may cast that card for as long as it remains exiled, and you may spend mana as though it were mana of any color to cast that spell. diff --git a/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java b/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java index 60d7ea53c4f..68889d69619 100644 --- a/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java +++ b/forge-gui/src/main/java/forge/player/HumanPlaySpellAbility.java @@ -20,9 +20,9 @@ package forge.player; import com.google.common.collect.Iterables; import forge.card.CardType; +import forge.card.MagicColor; import forge.game.Game; import forge.game.GameObject; -import forge.game.ability.AbilityFactory; import forge.game.ability.AbilityUtils; import forge.game.card.Card; import forge.game.cost.CostPartMana; @@ -40,7 +40,6 @@ import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.List; -import java.util.Map; /** *

@@ -70,9 +69,8 @@ public class HumanPlaySpellAbility { final Card c = this.ability.getHostCard(); boolean manaConversion = (ability.isSpell() && c.hasKeyword("May spend mana as though it were mana of any color to cast CARDNAME")); - - Map params = AbilityFactory.getMapParams(c.getSVar("ManaConversionMatrix")); - + boolean playerManaConversion = human.hasManaConversion() + && human.getController().confirmAction(ability, null, "Do you want to spend mana as though it were mana of any color to pay the cost?"); if (this.ability instanceof Spell && !c.isCopiedSpell()) { fromZone = game.getZoneOf(c); if (fromZone != null) { @@ -85,7 +83,11 @@ public class HumanPlaySpellAbility { game.getStack().freezeStack(); if (manaConversion) { - AbilityUtils.applyManaColorConversion(human, params); + AbilityUtils.applyManaColorConversion(human, MagicColor.Constant.ANY_MANA_CONVERSION); + } + if (playerManaConversion) { + AbilityUtils.applyManaColorConversion(human, MagicColor.Constant.ANY_MANA_CONVERSION); + human.incNumManaConversion(); } // This line makes use of short-circuit evaluation of boolean values, that is each subsequent argument // is only executed or evaluated if the first argument does not suffice to determine the value of the expression @@ -108,6 +110,10 @@ public class HumanPlaySpellAbility { if (manaConversion) { manapool.restoreColorReplacements(); } + if (playerManaConversion) { + manapool.restoreColorReplacements(); + human.decNumManaConversion(); + } return; }