From 7c9b5704ed9a75632dff77a4a41380599dcf684c Mon Sep 17 00:00:00 2001 From: moomarc Date: Thu, 8 Mar 2012 20:19:47 +0000 Subject: [PATCH] Added Mind Maggots Small change to ChooseNumber to make Min/Max read SVars. Small change to ChooseNumber to allow different titles for the list block to expand its uses slightly. Changed title of choice list for Ashling's Prerogative --- .gitattributes | 1 + res/cardsfolder/a/ashlings_prerogative.txt | 2 +- res/cardsfolder/m/mind_maggots.txt | 21 ++++++++++++++ .../abilityfactory/AbilityFactoryChoose.java | 28 +++++++++++++++++-- 4 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 res/cardsfolder/m/mind_maggots.txt diff --git a/.gitattributes b/.gitattributes index 746d39d70a4..08c3ffcad12 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5545,6 +5545,7 @@ res/cardsfolder/m/mind_funeral.txt svneol=native#text/plain res/cardsfolder/m/mind_games.txt svneol=native#text/plain res/cardsfolder/m/mind_harness.txt svneol=native#text/plain res/cardsfolder/m/mind_knives.txt svneol=native#text/plain +res/cardsfolder/m/mind_maggots.txt -text res/cardsfolder/m/mind_over_matter.txt svneol=native#text/plain res/cardsfolder/m/mind_peel.txt svneol=native#text/plain res/cardsfolder/m/mind_ravel.txt svneol=native#text/plain diff --git a/res/cardsfolder/a/ashlings_prerogative.txt b/res/cardsfolder/a/ashlings_prerogative.txt index 49760be97af..a73fdd2680f 100644 --- a/res/cardsfolder/a/ashlings_prerogative.txt +++ b/res/cardsfolder/a/ashlings_prerogative.txt @@ -3,7 +3,7 @@ ManaCost:1 R Types:Enchantment Text:no text T:Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Any | Destination$ Battlefield | Execute$ ChooseMode | Static$ True | TriggerDescription$ As CARDNAME enters the battlefield, choose odd or even. (Zero is even.) -SVar:ChooseMode:AB$ ChooseNumber | Cost$ 0 | Defined$ You | Min$ 0 | Max$ 1 | SpellDescription$ Choose odd or even (Zero is even.) +SVar:ChooseMode:AB$ ChooseNumber | Cost$ 0 | Defined$ You | Min$ 0 | Max$ 1 | ListTitle$ Choose ODD or EVEN (0=Even; 1=Odd) | SpellDescription$ Choose odd or even (Zero is even.) S:Mode$ Continuous | Affected$ Creature.cmcM2X | AddKeyword$ Haste | Description$ Each creature with converted mana cost of the chosen value has haste. S:Mode$ ETBTapped | ValidCard$ Creature.cmcM2Y | Description$ Each creature without converted mana cost of the chosen value enters the battlefield tapped. # The next 2 static abilities add text to the card panel for convenience indicating choice. diff --git a/res/cardsfolder/m/mind_maggots.txt b/res/cardsfolder/m/mind_maggots.txt new file mode 100644 index 00000000000..1993219c325 --- /dev/null +++ b/res/cardsfolder/m/mind_maggots.txt @@ -0,0 +1,21 @@ +Name:Mind Maggots +ManaCost:3 B +Types:Creature Insect +Text:no text +PT:2/2 +T:Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Any | Destination$ Battlefield | Execute$ ChooseDiscardCount | TriggerDescription$ When CARDNAME enters the battlefield, discard any number of creature cards. For each card discarded this way, put two +1/+1 counters on CARDNAME. +SVar:ChooseDiscardCount:AB$ ChooseNumber | Cost$ 0 | Defined$ You | Min$ 0 | Max$ MaxChoice | ListTitle$ Discard how many creatures? | SubAbility$ MindMaggotsDiscard +# Used ChooseNumber here because otherwise the user must cancel for every valid card not discarded which can make it seem slow or broken. +SVar:MindMaggotsDiscard:DB$ Discard | DiscardValid$ Creature | NumCards$ ChosenMaggots | Optional$ True | Mode$ TgtChoose | RememberDiscarded$ True | SubAbility$ MindMaggotsPutCounter +SVar:MindMaggotsPutCounter:DB$ PutCounter | CounterType$ P1P1 | CounterNum$ MindMaggotsCount | SubAbility$ MindMaggotsCleanup +SVar:MindMaggotsCleanup:DB$ Cleanup | ClearRemembered$ True +SVar:MaxChoice:Count$TypeInYourHand.Creature +SVar:ChosenMaggots:Count$ChosenNumber +SVar:DiscardedMind:Remembered$Amount +SVar:MindMaggotsCount:SVar$DiscardedMind/Times.2 +SVar:RemAIDeck:True +SVar:Rarity:Uncommon +SVar:Picture:http://www.wizards.com/global/images/magic/general/mind_maggots.jpg +SetInfo:EXO|Uncommon|http://magiccards.info/scans/en/ex/66.jpg +Oracle:When Mind Maggots enters the battlefield, discard any number of creature cards. For each card discarded this way, put two +1/+1 counters on Mind Maggots. +End \ No newline at end of file diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java index cd85ab745af..1d65f836ea3 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java @@ -911,10 +911,28 @@ public final class AbilityFactoryChoose { private static void chooseNumberResolve(final AbilityFactory af, final SpellAbility sa) { final HashMap params = af.getMapParams(); final Card card = af.getHostCard(); - final int min = params.containsKey("Min") ? Integer.parseInt(params.get("Min")) : 0; - final int max = params.containsKey("Max") ? Integer.parseInt(params.get("Max")) : 99; + //final int min = params.containsKey("Min") ? Integer.parseInt(params.get("Min")) : 0; + //final int max = params.containsKey("Max") ? Integer.parseInt(params.get("Max")) : 99; final boolean random = params.containsKey("Random"); + final int min; + if (!params.containsKey("Min")) { + min = Integer.parseInt("0"); + } else if (params.get("Min").matches("[0-9][0-9]?")) { + min = Integer.parseInt(params.get("Min")); + } else { + min = CardFactoryUtil.xCount(card, card.getSVar(params.get("Min"))); + } // Allow variables for Min + + final int max; + if (!params.containsKey("Max")) { + max = Integer.parseInt("99"); + } else if (params.get("Max").matches("[0-9][0-9]?")) { + max = Integer.parseInt(params.get("Max")); + } else { + max = CardFactoryUtil.xCount(card, card.getSVar(params.get("Max"))); + } // Allow variables for Max + final String[] choices = new String[max + 1]; if (!random) { // initialize the array @@ -941,6 +959,12 @@ public final class AbilityFactoryChoose { chosen = randomGen.nextInt(max - min) + min; final String message = "Randomly chosen number: " + chosen; JOptionPane.showMessageDialog(null, message, "" + card, JOptionPane.PLAIN_MESSAGE); + } else if (params.containsKey("ListTitle")) { + final Object o = GuiUtils.chooseOne(params.get("ListTitle"), choices); + if (null == o) { + return; + } + chosen = Integer.parseInt((String) o); } else { final Object o = GuiUtils.chooseOne("Choose a number", choices); if (null == o) {