From 1edcf73295ea0082c89c1c1828fc8c9afadc2b33 Mon Sep 17 00:00:00 2001 From: Sol Date: Tue, 28 Aug 2012 01:25:49 +0000 Subject: [PATCH] - Added Phyrexian Portal - Simplified Two Piles logic allowed for FaceDown piles --- .gitattributes | 1 + res/cardsfolder/d/demonic_tutor.txt | 2 +- res/cardsfolder/p/phyrexian_portal.txt | 17 ++ .../abilityfactory/AbilityFactoryClash.java | 153 +++++++++++------- .../abilityfactory/AbilityFactoryReveal.java | 9 +- 5 files changed, 118 insertions(+), 64 deletions(-) create mode 100644 res/cardsfolder/p/phyrexian_portal.txt diff --git a/.gitattributes b/.gitattributes index bf3b9b567cc..ac83ad387ac 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6911,6 +6911,7 @@ res/cardsfolder/p/phyrexian_monitor.txt svneol=native#text/plain res/cardsfolder/p/phyrexian_negator.txt svneol=native#text/plain res/cardsfolder/p/phyrexian_obliterator.txt svneol=native#text/plain res/cardsfolder/p/phyrexian_plaguelord.txt svneol=native#text/plain +res/cardsfolder/p/phyrexian_portal.txt -text res/cardsfolder/p/phyrexian_processor.txt svneol=native#text/plain res/cardsfolder/p/phyrexian_prowler.txt svneol=native#text/plain res/cardsfolder/p/phyrexian_rager.txt svneol=native#text/plain diff --git a/res/cardsfolder/d/demonic_tutor.txt b/res/cardsfolder/d/demonic_tutor.txt index 3c84ed3b6cb..e04e3760c3a 100644 --- a/res/cardsfolder/d/demonic_tutor.txt +++ b/res/cardsfolder/d/demonic_tutor.txt @@ -2,7 +2,7 @@ Name:Demonic Tutor ManaCost:1 B Types:Sorcery Text:no text -A:SP$ ChangeZone | Cost$ 1 B| Origin$ Library | Destination$ Hand | ChangeType$ Card | ChangeNum$ 1 | Mandatory$ True | SpellDescription$ Search your library for a card and put that card into your hand. Then shuffle your library. +A:SP$ ChangeZone | Cost$ 1 B | Origin$ Library | Destination$ Hand | ChangeType$ Card | ChangeNum$ 1 | Mandatory$ True | SpellDescription$ Search your library for a card and put that card into your hand. Then shuffle your library. SVar:RemAIDeck:True SVar:Rarity:Uncommon SVar:Picture:http://resources.wizards.com/magic/cards/3e/en-us/card1155.jpg diff --git a/res/cardsfolder/p/phyrexian_portal.txt b/res/cardsfolder/p/phyrexian_portal.txt new file mode 100644 index 00000000000..9115b3a6e47 --- /dev/null +++ b/res/cardsfolder/p/phyrexian_portal.txt @@ -0,0 +1,17 @@ +Name:Phyrexian Portal +ManaCost:3 +Types:Artifact +Text:no text +A:AB$ Dig | Cost$ 3 | DigNum$ 10 | RememberRevealed$ True | NoMove$ True | Choser$ Opponent | ConditionCheckSVar$ X | ConditionSVarCompare$ GE10 | SubAbility$ DBTwoPiles | SpellDescription$ If your library has ten or more cards in it, target opponent looks at the top ten cards of your library and separates them into two face-down piles. Exile one of those piles. Search the other pile for a card, put it into your hand, then shuffle the rest of that pile into your library. | StackDescription$ If your library has ten or more cards in it, target opponent looks at the top ten cards of your library and separates them into two face-down piles. Exile one of those piles. Search the other pile for a card, put it into your hand, then shuffle the rest of that pile into your library. +SVar:DBTwoPiles:DB$ TwoPiles | Defined$ You | DefinedCards$ Remembered | Separator$ Opponent | FaceDown$ True | ConditionCheckSVar$ X | ConditionSVarCompare$ GE10 | ChosenPile$ DBHand | UnchosenPile$ DBExile | SubAbility$ DBCleanup +SVar:DBHand:DB$ ChangeZone | Defined$ Remembered | Origin$ Library | Destination$ Hand | ChangeType$ Card | ChangeNum$ 1 | Mandatory$ True | Shuffle$ True +SVar:DBExile:DB$ ChangeZone | Defined$ Remembered | Origin$ Library | Destination$ Exile +SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True +# This variable may be incorrect if the controller changes while the ability is on the stack +SVar:X:Count$InYourLibrary +SVar:Rarity:Rare +SVar:RemAIDeck:True +SVar:Picture:http://www.wizards.com/global/images/magic/general/phyrexian_portal.jpg +SetInfo:ALL|Rare|http://magiccards.info/scans/en/ai/168.jpg +Oracle:{3}: If your library has ten or more cards in it, target opponent looks at the top ten cards of your library and separates them into two face-down piles. Exile one of those piles. Search the other pile for a card, put it into your hand, then shuffle the rest of that pile into your library. +End \ No newline at end of file diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryClash.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryClash.java index 8fe2cc74a33..7f111c0ad23 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryClash.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryClash.java @@ -770,6 +770,7 @@ public final class AbilityFactoryClash { for (final Card c : l) { pile1.add(c); } + for (final Card c : pool) { if (!pile1.contains(c)) { pile2.add(c); @@ -806,67 +807,8 @@ public final class AbilityFactoryClash { System.out.println("Pile 2:" + pile2); card.clearRemembered(); - // then, the chooser picks a pile - if (chooser.isHuman()) { - final Card[] disp = new Card[pile1.size() + pile2.size() + 2]; - disp[0] = new Card(); - disp[0].setName("Pile 1"); - for (int i = 0; i < pile1.size(); i++) { - disp[1 + i] = pile1.get(i); - } - disp[pile1.size() + 1] = new Card(); - disp[pile1.size() + 1].setName("Pile 2"); - for (int i = 0; i < pile2.size(); i++) { - disp[pile1.size() + i + 2] = pile2.get(i); - } - - // make sure Pile 1 or Pile 2 is clicked on - boolean chosen = false; - while (!chosen) { - final Object o = GuiUtils.chooseOne("Choose a pile", disp); - final Card c = (Card) o; - if (c.getName().equals("Pile 1")) { - chosen = true; - for (final Card z : pile1) { - card.addRemembered(z); - } - } else if (c.getName().equals("Pile 2")) { - chosen = true; - for (final Card z : pile2) { - card.addRemembered(z); - } - pile1WasChosen = false; - } - - } - } else { - int cmc1 = CardFactoryUtil.evaluatePermanentList(new CardList(pile1)); - int cmc2 = CardFactoryUtil.evaluatePermanentList(new CardList(pile2)); - if (pool.getNotType("Creature").isEmpty()) { - cmc1 = CardFactoryUtil.evaluateCreatureList(new CardList(pile1)); - cmc2 = CardFactoryUtil.evaluateCreatureList(new CardList(pile2)); - System.out.println("value:" + cmc1 + " " + cmc2); - } - - // for now, this assumes that the outcome will be bad - // TODO: This should really have a ChooseLogic param to - // figure this out - if (cmc2 > cmc1) { - JOptionPane.showMessageDialog(null, "Computer chooses the Pile 1", "", - JOptionPane.INFORMATION_MESSAGE); - for (final Card c : pile1) { - card.addRemembered(c); - } - } else { - JOptionPane.showMessageDialog(null, "Computer chooses the Pile 2", "", - JOptionPane.INFORMATION_MESSAGE); - for (final Card c : pile2) { - card.addRemembered(c); - } - pile1WasChosen = false; - } - } - + pile1WasChosen = selectPiles(params, sa, pile1, pile2, chooser, card, pool); + // take action on the chosen pile if (params.containsKey("ChosenPile")) { final AbilityFactory afPile = new AbilityFactory(); @@ -901,4 +843,93 @@ public final class AbilityFactoryClash { } } // end twoPiles resolve + private static boolean selectPiles(final HashMap params, final SpellAbility sa, ArrayList pile1, ArrayList pile2, + Player chooser, Card card, CardList pool) { + boolean pile1WasChosen = true; + // then, the chooser picks a pile + + if (params.containsKey("FaceDown")) { + // Used for Phyrexian Portal, FaceDown Pile choosing + if (chooser.isHuman()) { + final String p1Str = String.format("Pile 1 (%s cards)", pile1.size()); + final String p2Str = String.format("Pile 2 (%s cards)", pile2.size()); + + final String message = String.format("Choose a pile\n%s or %s", p1Str, p2Str); + + final Object[] possibleValues = { p1Str , p2Str }; + + final Object playDraw = JOptionPane.showOptionDialog(null, message, "Choose a Pile", + JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, + possibleValues, possibleValues[0]); + + pile1WasChosen = playDraw.equals(0); + } + else { + // AI will choose the first pile if it is larger or the same + // TODO Improve this to be slightly more random to not be so predictable + pile1WasChosen = pile1.size() >= pile2.size(); + } + } + else { + if (chooser.isHuman()) { + final Card[] disp = new Card[pile1.size() + pile2.size() + 2]; + disp[0] = new Card(); + disp[0].setName("Pile 1"); + for (int i = 0; i < pile1.size(); i++) { + disp[1 + i] = pile1.get(i); + } + disp[pile1.size() + 1] = new Card(); + disp[pile1.size() + 1].setName("Pile 2"); + for (int i = 0; i < pile2.size(); i++) { + disp[pile1.size() + i + 2] = pile2.get(i); + } + + // make sure Pile 1 or Pile 2 is clicked on + while (true) { + final Object o = GuiUtils.chooseOne("Choose a pile", disp); + final Card c = (Card) o; + String name = c.getName(); + + if (!(name.equals("Pile 1") || name.equals("Pile 2"))) { + continue; + } + + pile1WasChosen = name.equals("Pile 1"); + break; + } + } else { + int cmc1 = CardFactoryUtil.evaluatePermanentList(new CardList(pile1)); + int cmc2 = CardFactoryUtil.evaluatePermanentList(new CardList(pile2)); + if (pool.getNotType("Creature").isEmpty()) { + cmc1 = CardFactoryUtil.evaluateCreatureList(new CardList(pile1)); + cmc2 = CardFactoryUtil.evaluateCreatureList(new CardList(pile2)); + System.out.println("value:" + cmc1 + " " + cmc2); + } + + // for now, this assumes that the outcome will be bad + // TODO: This should really have a ChooseLogic param to + // figure this out + pile1WasChosen = cmc1 >= cmc2; + if (pile1WasChosen) { + JOptionPane.showMessageDialog(null, "Computer chooses the Pile 1", "", + JOptionPane.INFORMATION_MESSAGE); + } else { + JOptionPane.showMessageDialog(null, "Computer chooses the Pile 2", "", + JOptionPane.INFORMATION_MESSAGE); + } + } + } + + if (pile1WasChosen) { + for (final Card z : pile1) { + card.addRemembered(z); + } + } else { + for (final Card z : pile2) { + card.addRemembered(z); + } + } + + return pile1WasChosen; + } } // end class AbilityFactory_Clash diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java index 2f7a9950d2f..13a94f5d6ed 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java @@ -226,6 +226,11 @@ public final class AbilityFactoryReveal { } else { sb.append(" "); } + + if (params.containsKey("StackDescription")) { + sb.append(params.get("StackDescription")); + return sb.toString(); + } ArrayList tgtPlayers; @@ -467,7 +472,7 @@ public final class AbilityFactoryReveal { cardsRevealed = true; } - if ((params.containsKey("RememberRevealed")) && cardsRevealed) { + if ((params.containsKey("RememberRevealed")) && !params.containsKey("RevealValid")) { for (final Card one : top) { host.addRemembered(one); } @@ -2232,7 +2237,7 @@ public final class AbilityFactoryReveal { } else { sb.append(sa.getSourceCard()).append(" - "); } - + ArrayList tgtPlayers; final Target tgt = sa.getTarget();