diff --git a/.gitattributes b/.gitattributes index 95e785c940f..d96f0e24519 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8910,6 +8910,7 @@ src/forge/card/abilityFactory/AbilityFactory_Animate.java -text svneol=native#te src/forge/card/abilityFactory/AbilityFactory_ChangeZone.java -text svneol=native#text/plain src/forge/card/abilityFactory/AbilityFactory_Choose.java -text svneol=native#text/plain src/forge/card/abilityFactory/AbilityFactory_Clash.java -text svneol=native#text/plain +src/forge/card/abilityFactory/AbilityFactory_Cleanup.java -text svneol=native#text/plain src/forge/card/abilityFactory/AbilityFactory_Combat.java -text svneol=native#text/plain src/forge/card/abilityFactory/AbilityFactory_Copy.java -text svneol=native#text/plain src/forge/card/abilityFactory/AbilityFactory_CounterMagic.java -text svneol=native#text/plain diff --git a/res/cardsfolder/teferis_puzzle_box.txt b/res/cardsfolder/teferis_puzzle_box.txt index dcdf2c98d1d..d3e1796f471 100644 --- a/res/cardsfolder/teferis_puzzle_box.txt +++ b/res/cardsfolder/teferis_puzzle_box.txt @@ -1,7 +1,12 @@ Name:Teferi's Puzzle Box ManaCost:4 Types:Artifact -Text:At the beginning of each player's draw step, that player puts the cards in his or her hand on the bottom of his or her library in any order, then draws that many cards. +Text:no text +T:Mode$ Phase | Phase$ Draw | ValidPlayer$ Player | TriggerZones$ Battlefield | Execute$ TrigChangeAll | TriggerDescription$ At the beginning of each player's draw step, that player puts the cards in his or her hand on the bottom of his or her library in any order, then draws that many cards. +SVar:TrigChangeAll:DB$ ChangeZoneAll | Defined$ TriggeredPlayer | Origin$ Hand | Destination$ Library | LibraryPosition$ -1 | RememberChanged$ True | ForgetOtherRemembered$ True | SubAbility$ SVar=DBDraw +SVar:DBDraw:DB$Draw | NumCards$ X | Defined$ TriggeredPlayer | SubAbility$ SVar=DBCleanup +SVar:DBCleanup:DB$Cleanup | ClearRemembered$ True +SVar:X:Remembered$Amount SVar:RemRandomDeck:True SVar:Rarity:Rare SVar:Picture:http://www.wizards.com/global/images/magic/general/teferis_puzzle_box.jpg diff --git a/src/forge/GameActionUtil.java b/src/forge/GameActionUtil.java index bb3b928e1bb..1c42c0cde67 100644 --- a/src/forge/GameActionUtil.java +++ b/src/forge/GameActionUtil.java @@ -102,7 +102,7 @@ public class GameActionUtil { public static void executeDrawStepEffects() { AllZone.Stack.freezeStack(); final Player player = AllZone.Phase.getPlayerTurn(); - draw_Teferi_Puzzle_Box(player); + draw_Sylvan_Library(player); AllZone.Stack.unfreezeStack(); @@ -4640,44 +4640,6 @@ public class GameActionUtil { }//end for } - - private static void draw_Teferi_Puzzle_Box(Player player) { - CardList list = AllZoneUtil.getCardsInPlay("Teferi's Puzzle Box"); - PlayerZone Playerhand = AllZone.getZone(Constant.Zone.Hand, player); - PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player); - - CardList hand = new CardList(); - Card[] handlist = null; - if(list.size() > 0) { - AllZone.Display.showMessage("Shuffle cards back into your library: "); - ButtonUtil.enableOnlyCancel(); - hand.addAll(Playerhand.getCards()); - int Count = hand.size(); - for(int i = 0; i < list.size(); i++) { - if(AllZone.HumanPlayer.equals(player)) { - for(int e = 0; e < Count; e++) { - if(hand.size() == 0) hand.addAll(Playerhand.getCards()); - handlist = hand.toArray(); - Object check = GuiUtils.getChoice("Select card to put on bottom of library", handlist); - if(check != null) { - Card target = ((Card) check); - hand.remove(target); - AllZone.GameAction.moveTo(lib, target); - } - } - }else { - for(int x = 0; x < hand.size(); x++) hand.remove(hand.get(x)); - hand.addAll(Playerhand.getCards()); - for(int e = 0; e < hand.size(); e++) { - AllZone.GameAction.moveTo(lib, hand.get(e)); - } - } - - player.drawCards(Count); - } - } - - }// Teferi_Puzzle_Box private static void upkeep_Carnophage() { final Player player = AllZone.Phase.getPlayerTurn(); diff --git a/src/forge/card/abilityFactory/AbilityFactory.java b/src/forge/card/abilityFactory/AbilityFactory.java index 78e381e4524..c47d54592ea 100644 --- a/src/forge/card/abilityFactory/AbilityFactory.java +++ b/src/forge/card/abilityFactory/AbilityFactory.java @@ -680,6 +680,11 @@ public class AbilityFactory { if(isDb) SA = AbilityFactory_DelayedTrigger.getDrawback(this); } + + if(API.equals("Cleanup")) { + if(isDb) + SA = AbilityFactory_Cleanup.getDrawback(this); + } if (SA == null) throw new RuntimeException("AbilityFactory : SpellAbility was not created for "+hostCard.getName()+". Looking for API: "+API); diff --git a/src/forge/card/abilityFactory/AbilityFactory_ChangeZone.java b/src/forge/card/abilityFactory/AbilityFactory_ChangeZone.java index fe6705e0afd..46bb296858e 100644 --- a/src/forge/card/abilityFactory/AbilityFactory_ChangeZone.java +++ b/src/forge/card/abilityFactory/AbilityFactory_ChangeZone.java @@ -1468,16 +1468,27 @@ public class AbilityFactory_ChangeZone { String destination = params.get("Destination"); String origin = params.get("Origin"); - CardList cards = AllZoneUtil.getCardsInZone(origin); + CardList cards = null; - Player tgtPlayer = null; - if(af.getAbTgt() != null) - if(af.getAbTgt().getTargetPlayers() != null) { - tgtPlayer = af.getAbTgt().getTargetPlayers().get(0); - cards = AllZoneUtil.getCardsInZone(origin,tgtPlayer); - } - cards = filterListByType(cards, params, sa); + ArrayList tgtPlayers = null; + Target tgt = af.getAbTgt(); + if (tgt != null) + tgtPlayers = tgt.getTargetPlayers(); + else if (params.containsKey("Defined")) // Make sure Defined exists to use it + tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa); + + if (tgtPlayers == null || tgtPlayers.isEmpty()) + cards = AllZoneUtil.getCardsInZone(origin); + else + cards = AllZoneUtil.getCardsInZone(origin,tgtPlayers.get(0)); + + cards = filterListByType(cards, params, sa); + + if (params.containsKey("ForgetOtherRemembered")) + sa.getSourceCard().clearRemembered(); + + String remember = params.get("RememberChanged"); // I don't know if library position is necessary. It's here if it is, just in case int libraryPos = params.containsKey("LibraryPosition") ? Integer.parseInt(params.get("LibraryPosition")) : 0; @@ -1490,6 +1501,9 @@ public class AbilityFactory_ChangeZone { } else AllZone.GameAction.moveTo(destination, c, libraryPos); + + if (remember != null) + sa.getSourceCard().addRemembered(c); } // if Shuffle parameter exists, and any amount of cards were owned by that player, then shuffle that library diff --git a/src/forge/card/abilityFactory/AbilityFactory_Cleanup.java b/src/forge/card/abilityFactory/AbilityFactory_Cleanup.java new file mode 100644 index 00000000000..822658b267d --- /dev/null +++ b/src/forge/card/abilityFactory/AbilityFactory_Cleanup.java @@ -0,0 +1,46 @@ +package forge.card.abilityFactory; + +import forge.card.spellability.Ability_Sub; +import forge.card.spellability.SpellAbility; + +import java.util.HashMap; + +// Cleanup is not the same as other AFs, it is only used as a Drawback, and only used to Cleanup particular card states +// That need to be reset. I'm creating this to clear Remembered Cards at the end of an Effect so they don't get shown on a card +// After the effect finishes resolving. +public class AbilityFactory_Cleanup { + + public static Ability_Sub getDrawback(final AbilityFactory AF) + { + final Ability_Sub drawback = new Ability_Sub(AF.getHostCard(),AF.getAbTgt()) { + private static final long serialVersionUID = 6192972525033429820L; + + @Override + public boolean chkAI_Drawback() { + return true; + } + + @Override + public boolean doTrigger(boolean mandatory) { + return true; + } + + @Override + public void resolve() { + doResolve(AF,this); + } + }; + + return drawback; + } + + private static void doResolve(AbilityFactory AF,SpellAbility sa) + { + HashMap params = AF.getMapParams(); + + if (params.containsKey("ClearRemembered")) + sa.getSourceCard().clearRemembered(); + + AbilityFactory.resolveSubAbility(sa); + } +}