From bf60a0b5349dea9c46cbb3a85938017c8c3d626b Mon Sep 17 00:00:00 2001 From: slapshot5 Date: Thu, 25 Aug 2011 05:39:44 +0000 Subject: [PATCH] add the ability to Exile cards face down. Added an ExileFaceDown$ True parameter to ChangeZone and ChangeZoneAll. In the GUI code, I had to change the ZoneAction (for viewing Exile, Graveyard, etc.) class to not use the YieldUtils iterator stuff. I pull the Generator into an ArrayList. If someone can do it with Iterator, go for it. --- src/main/java/forge/GuiDisplay4.java | 34 +++++++++++++++---- .../AbilityFactory_ChangeZone.java | 23 ++++++++++--- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/src/main/java/forge/GuiDisplay4.java b/src/main/java/forge/GuiDisplay4.java index a88ff38620e..44bc3937c93 100644 --- a/src/main/java/forge/GuiDisplay4.java +++ b/src/main/java/forge/GuiDisplay4.java @@ -30,7 +30,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; -import java.util.Iterator; import java.util.List; import java.util.Observable; import java.util.Observer; @@ -299,7 +298,7 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo GuiDisplayUtil.devModeSetLife(); } }; - //end DevMode AddCounter + //end DevMode SetLife Object[] objDev = { GuiDisplay4.canLoseByDecking, @@ -1505,15 +1504,38 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo if (AllZone.getNameChanger().shouldChangeCardName()) { c = AllZone.getNameChanger().changeCard(c); } - - Iterator iter = YieldUtils.toIterable(c).iterator(); - if (!iter.hasNext()) { + Iterable myIterable = YieldUtils.toIterable(c); + ArrayList choices = YieldUtils.toArrayList(myIterable); + System.out.println("immediately after: "+choices); + //Iterator iter = myIterable.iterator(); + + ArrayList choices2 = new ArrayList(); + + if (choices.isEmpty()) { GuiUtils.getChoiceOptional(title, new String[]{"no cards"}); } else { - Card choice = GuiUtils.getChoiceOptional(title, iter); + for(int i = 0; i < choices.size(); i++) { + Card crd = choices.get(i); + System.out.println(crd+": "+crd.isFaceDown()); + if(crd.isFaceDown()) { + Card faceDown = new Card(); + faceDown.setName("Face Down"); + choices2.add(faceDown); + System.out.println("Added: "+faceDown); + } + else { + choices2.add(crd); + } + } + System.out.println("Face down cards replaced: "+choices2); + Card choice = (Card) GuiUtils.getChoiceOptional(title, choices2.toArray()); if (choice != null) doAction(choice); + /* + Card choice = GuiUtils.getChoiceOptional(title, iter); + if (choice != null) doAction(choice); + */ } } diff --git a/src/main/java/forge/card/abilityFactory/AbilityFactory_ChangeZone.java b/src/main/java/forge/card/abilityFactory/AbilityFactory_ChangeZone.java index 89fe676dfa5..4c157541bf7 100644 --- a/src/main/java/forge/card/abilityFactory/AbilityFactory_ChangeZone.java +++ b/src/main/java/forge/card/abilityFactory/AbilityFactory_ChangeZone.java @@ -650,8 +650,12 @@ public class AbilityFactory_ChangeZone { c.addController(af.getHostCard()); movedCard = AllZone.getGameAction().moveTo(AllZone.getZone(destination, c.getController()), c); - } else + } else { movedCard = AllZone.getGameAction().moveTo(destZone, c); + if(params.containsKey("ExileFaceDown")) { + movedCard.setIsFaceDown(true); + } + } if (remember != null) card.addRemembered(movedCard); @@ -771,8 +775,12 @@ public class AbilityFactory_ChangeZone { } newCard = AllZone.getGameAction().moveTo(AllZone.getZone(destination, c.getController()), c); - } else + } else { newCard = AllZone.getGameAction().moveTo(destZone, c); + if(params.containsKey("ExileFaceDown")) { + newCard.setIsFaceDown(true); + } + } if (remember != null) card.addRemembered(newCard); @@ -1399,6 +1407,9 @@ public class AbilityFactory_ChangeZone { } } else { movedCard = AllZone.getGameAction().moveTo(AllZone.getZone(destination, pl), tgtC); + if(params.containsKey("ExileFaceDown")) { + movedCard.setIsFaceDown(true); + } } } if (remember != null) @@ -1747,8 +1758,12 @@ public class AbilityFactory_ChangeZone { if (params.containsKey("GainControl")) { c.addController(af.getHostCard()); AllZone.getGameAction().moveToPlay(c, sa.getActivatingPlayer()); - } else - AllZone.getGameAction().moveTo(destination, c, libraryPos); + } else { + Card movedCard = AllZone.getGameAction().moveTo(destination, c, libraryPos); + if(params.containsKey("ExileFaceDown")) { + movedCard.setIsFaceDown(true); + } + } if (remember != null) sa.getSourceCard().addRemembered(c);