diff --git a/src/forge/AllZone.java b/src/forge/AllZone.java index 0ea82f9844b..8cf3b2a00eb 100644 --- a/src/forge/AllZone.java +++ b/src/forge/AllZone.java @@ -99,7 +99,7 @@ public class AllZone implements NewConstants { { p = (PlayerZone)it.next(); - if(GameAction.isCardInZone(c, p)) + if(AllZoneUtil.isCardInZone(p, c)) return p; } return null; diff --git a/src/forge/GameAction.java b/src/forge/GameAction.java index 94e2e3ba530..4cdeb4b2588 100644 --- a/src/forge/GameAction.java +++ b/src/forge/GameAction.java @@ -188,7 +188,7 @@ public class GameAction { Ability ability = new Ability(pVoid, "0") { @Override public void resolve() { - if(AllZone.GameAction.isCardInZone(voidingCard, grave)) + if(AllZoneUtil.isCardInZone(grave, voidingCard)) moveTo(AllZone.getZone(Constant.Zone.Exile, voidingCard.getOwner()), voidingCard); } @@ -2024,7 +2024,7 @@ public class GameAction { if(Zones.contains("Exiled")) Required_Zone[0] = AllZone.getZone(Constant.Zone.Exile, Source.getController()); //if(Zones.contains("Sideboard")) Required_Zone[0] = AllZone.getZone(Constant.Zone.Sideboard, Source.getController()); - if(AllZone.GameAction.isCardInZone(Source,Required_Zone[0]) || Zones.equals("Any")) { + if(AllZoneUtil.isCardInZone(Required_Zone[0], Source) || Zones.equals("Any")) { if(Keyword_Details[7].equals("Yes_No")) { if(Source.getController().equals(AllZone.HumanPlayer)) { Object[] possibleValues = {"Yes", "No"}; @@ -2063,7 +2063,7 @@ public class GameAction { if(Zones.contains("Exiled")) Required_Zone[0] = AllZone.getZone(Constant.Zone.Exile, Source.getController()); //if(Zones.contains("Sideboard")) Required_Zone[0] = AllZone.getZone(Constant.Zone.Sideboard, Source.getController()); - if(AllZone.GameAction.isCardInZone(Source,Required_Zone[0]) || Zones.equals("Any")) { + if(AllZoneUtil.isCardInZone(Required_Zone[0], Source) || Zones.equals("Any")) { if(Keyword_Details[6].equals("ASAP")) { if(Keyword_Details[5].equals("InputType - CreatureORPlayer") && Source.getController().equals(AllZone.HumanPlayer)) { paidCommand.execute(); @@ -2189,6 +2189,7 @@ public class GameAction { } } + @Deprecated public boolean isCardInZone(Card card, PlayerZone p) { ArrayList list = new ArrayList(Arrays.asList(p.getCards())); return list.contains(card); @@ -2687,16 +2688,16 @@ public class GameAction { SpellAbility[] abilities = canPlaySpellAbility(c.getSpellAbility()); ArrayList choices = new ArrayList(); - if(c.isLand() && isCardInZone(c, AllZone.Human_Hand) && AllZone.HumanPlayer.canPlayLand()) - choices.add("Play land"); - + if(c.isLand() && AllZoneUtil.isCardInZone(AllZone.Human_Hand, c) && AllZone.HumanPlayer.canPlayLand()) + choices.add("Play land"); + for(SpellAbility sa:abilities) { // for uncastables like lotus bloom, check if manaCost is blank sa.setActivatingPlayer(AllZone.HumanPlayer); - if(sa.canPlay() && (!sa.isSpell() || !sa.getManaCost().equals(""))) { - choices.add(sa.toString()); - map.put(sa.toString(), sa); - } + if(sa.canPlay() && (!sa.isSpell() || !sa.getManaCost().equals(""))) { + choices.add(sa.toString()); + map.put(sa.toString(), sa); + } } String choice; diff --git a/src/forge/GameActionUtil.java b/src/forge/GameActionUtil.java index f3c677e9667..6429e438865 100644 --- a/src/forge/GameActionUtil.java +++ b/src/forge/GameActionUtil.java @@ -409,9 +409,7 @@ public class GameActionUtil { { final Player controller = c.getController(); final PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, controller); - final PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, controller); - CardList list = new CardList(); - list.addAll(grave.getCards()); + CardList list = AllZoneUtil.getPlayerGraveyard(controller); list = list.getName("Vengevine"); if(list.size() > 0) { for(int i = 0; i < list.size(); i++) { @@ -419,18 +417,18 @@ public class GameActionUtil { Ability ability = new Ability(card, "0") { @Override public void resolve() { - if(controller == AllZone.HumanPlayer){ + if(controller.isHuman()){ Object[] possibleValues = {"Yes", "No"}; Object q = JOptionPane.showOptionDialog(null, "Return Vengevine from the graveyard?", "Vengevine Ability", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, possibleValues, possibleValues[0]); if(q.equals(0)) { - if(AllZone.GameAction.isCardInZone(card, grave)) { + if(AllZoneUtil.isCardInPlayerGraveyard(controller, card)) { AllZone.GameAction.moveTo(play, card); } } } else { - if(AllZone.GameAction.isCardInZone(card, grave)) { + if(AllZoneUtil.isCardInPlayerGraveyard(controller, card)) { AllZone.GameAction.moveTo(play, card); } } @@ -2339,10 +2337,9 @@ public class GameActionUtil { public void resolve() { Card target = getTargetCard(); if(target != null){ - PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, src.getController()); - if(AllZone.GameAction.isCardInZone(getTargetCard(), grave)) { + if(AllZoneUtil.isCardInPlayerGraveyard(src.getController(), target)) { PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, src.getController()); - AllZone.GameAction.moveTo(hand, getTargetCard()); + AllZone.GameAction.moveTo(hand, target); } } @@ -2354,15 +2351,8 @@ public class GameActionUtil { private static final long serialVersionUID = -7433708170033536384L; public void execute() { - PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, src.getController()); - CardList list = new CardList(grave.getCards()); - - list = list.filter(new CardListFilter() { - public boolean addCard(Card crd) { - return crd.isCreature(); - } - }); - // list = list.getType("Creature"); + CardList list = AllZoneUtil.getPlayerGraveyard(src.getController()); + list = list.filter(AllZoneUtil.creatures); if(list.isEmpty()) { AllZone.Stack.addSimultaneousStackEntry(ability); diff --git a/src/forge/PlayerZone_ComesIntoPlay.java b/src/forge/PlayerZone_ComesIntoPlay.java index 28006a9e90b..d6a8400d29b 100644 --- a/src/forge/PlayerZone_ComesIntoPlay.java +++ b/src/forge/PlayerZone_ComesIntoPlay.java @@ -23,8 +23,8 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone { super.add(o); - Card c = (Card) o; - //final Player player = c.getController(); + final Card c = (Card) o; + final Player player = c.getController(); if(trigger && ((CardFactoryUtil.oppHasKismet(c.getController()) && (c.isLand() || c.isCreature() || c.isArtifact())) || (AllZoneUtil.isCardInPlay("Urabrask the Hidden",c.getController().getOpponent()) && c.isCreature()) @@ -121,27 +121,6 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone { } } - /* Converted to AF trigger - CardList seeds = AllZoneUtil.getCardsInPlay("Seed the Land"); - final Card seedLand = c; - for(Card seed:seeds) { - final Card source = seed; - SpellAbility ability = new Ability(source, "") { - @Override - public void resolve() { - CardFactoryUtil.makeToken("Snake", "G 1 1 Snake", seedLand.getController(), - "G", new String[] {"Creature", "Snake"}, 1, 1, new String[] {}); - } - }; - StringBuilder sb = new StringBuilder(); - sb.append(source).append(" - ").append(seedLand.getController()); - sb.append(" puts a 1/1 green Snake token onto the battlefield."); - ability.setStackDescription(sb.toString()); - - AllZone.Stack.add(ability); - } - */ - //Tectonic Instability CardList tis = AllZoneUtil.getCardsInPlay("Tectonic Instability"); final Card tisLand = c; @@ -206,31 +185,29 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone { if(meek.size() > 0 && c.isCreature() && c.getNetAttack() == 1 && c.getNetDefense() == 1) { for(int i = 0; i < meek.size(); i++) { final Card crd = meek.get(i); - final Card creat = c; - final PlayerZone graveZone = grave; Ability ability = new Ability(meek.get(i), "0") { @Override public void resolve() { - if(crd.getController().equals(AllZone.HumanPlayer)) { - if(GameActionUtil.showYesNoDialog(crd, "Attach " + crd + " to " + creat + "?")) { - if(AllZone.GameAction.isCardInZone(crd, graveZone) - && AllZoneUtil.isCardInPlay(creat) && creat.isCreature() - && creat.getNetAttack() == 1 && creat.getNetDefense() == 1) { + if(crd.getController().isHuman()) { + if(GameActionUtil.showYesNoDialog(crd, "Attach " + crd + " to " + c + "?")) { + if(AllZoneUtil.isCardInPlayerGraveyard(player, crd) + && AllZoneUtil.isCardInPlay(c) && c.isCreature() + && c.getNetAttack() == 1 && c.getNetDefense() == 1) { AllZone.GameAction.moveToPlay(crd); - crd.equipCard(creat); + crd.equipCard(c); } } } else //computer { - if(AllZone.GameAction.isCardInZone(crd, graveZone) - && AllZoneUtil.isCardInPlay(creat) && creat.isCreature() - && creat.getNetAttack() == 1 && creat.getNetDefense() == 1) { + if(AllZoneUtil.isCardInPlayerGraveyard(player, crd) + && AllZoneUtil.isCardInPlay(c) && c.isCreature() + && c.getNetAttack() == 1 && c.getNetDefense() == 1) { AllZone.GameAction.moveToPlay(crd); - crd.equipCard(creat); + crd.equipCard(c); } } } diff --git a/src/forge/card/cardFactory/CardFactoryUtil.java b/src/forge/card/cardFactory/CardFactoryUtil.java index d6ddbd11702..e01ca516472 100644 --- a/src/forge/card/cardFactory/CardFactoryUtil.java +++ b/src/forge/card/cardFactory/CardFactoryUtil.java @@ -888,12 +888,10 @@ public class CardFactoryUtil { @Override public boolean canPlay() { - PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, sourceCard.getController()); - ArrayList spellsOnStack = AllZone.Stack.getSourceCards(); Card sourceCard = this.getSourceCard(); - return AllZone.GameAction.isCardInZone(sourceCard, grave) && !spellsOnStack.contains(sourceCard) + return AllZoneUtil.isCardInPlayerGraveyard(sourceCard.getController(), sourceCard) && !spellsOnStack.contains(sourceCard) && (sourceCard.isInstant() || Phase.canCastSorcery(sourceCard.getController())); } diff --git a/src/forge/card/cardFactory/CardFactory_Auras.java b/src/forge/card/cardFactory/CardFactory_Auras.java index ec7443dbf10..30397835436 100644 --- a/src/forge/card/cardFactory/CardFactory_Auras.java +++ b/src/forge/card/cardFactory/CardFactory_Auras.java @@ -958,7 +958,7 @@ class CardFactory_Auras { PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController()); // Animate Dead got destroyed before its ability resolved - if (!AllZone.GameAction.isCardInZone(card, play)) + if (!AllZoneUtil.isCardInZone(play, card)) return; Card animated = targetC[0]; @@ -1002,7 +1002,7 @@ class CardFactory_Auras { PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController()); - if(AllZone.GameAction.isCardInZone(c, play)) { + if(AllZoneUtil.isCardInZone(play, c)) { AllZone.GameAction.sacrifice(c); } } @@ -1016,7 +1016,7 @@ class CardFactory_Auras { PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController()); - if(AllZone.GameAction.isCardInZone(c, play)) + if(AllZoneUtil.isCardInZone(play, c)) AllZone.Stack.addSimultaneousStackEntry(detach); } diff --git a/src/forge/card/cardFactory/CardFactory_Creatures.java b/src/forge/card/cardFactory/CardFactory_Creatures.java index 9daaf859810..1949ad93c29 100644 --- a/src/forge/card/cardFactory/CardFactory_Creatures.java +++ b/src/forge/card/cardFactory/CardFactory_Creatures.java @@ -424,9 +424,7 @@ public class CardFactory_Creatures { @Override public boolean canPlay() { - PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController()); - - return AllZone.GameAction.isCardInZone(card, grave); + return AllZoneUtil.isCardInPlayerGraveyard(card.getController(), card); } };//Ability @@ -525,14 +523,14 @@ public class CardFactory_Creatures { @Override public void resolve() { - // TODO: change to static ability? + // TODO: change to static ability? CardList library = AllZoneUtil.getPlayerCardsInLibrary(card.getController()); if(library.size() == 0) return; - - Card top = library.get(0); - if(top.isLand()) - card.getController().playLand(top); + + Card top = library.get(0); + if(top.isLand()) + card.getController().playLand(top); }//resolve() @Override @@ -542,7 +540,7 @@ public class CardFactory_Creatures { PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController()); boolean canPlayLand = card.getController().canPlayLand(); - return (AllZone.GameAction.isCardInZone(card, play) && library.get(0).isLand() && canPlayLand); + return (AllZoneUtil.isCardInZone(play, card) && library.get(0).isLand() && canPlayLand); } };//SpellAbility @@ -1606,7 +1604,7 @@ public class CardFactory_Creatures { PlayerZone grave = AllZone.getZone(target[0]); //checks to see if card is still in the graveyard - if(grave != null && AllZone.GameAction.isCardInZone(target[0], grave)) { + if(grave != null && AllZoneUtil.isCardInZone(grave, target[0])) { PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController()); target[0].setController(card.getController()); AllZone.GameAction.moveTo(play, target[0]); @@ -2323,7 +2321,7 @@ public class CardFactory_Creatures { @Override public void resolve() { Card c = null; - if(card.getController().equals(AllZone.HumanPlayer)) { + if(card.getController().isHuman()) { Object o = GuiUtils.getChoiceOptional("Select Elemental", getCreatures()); c = (Card) o; @@ -2331,9 +2329,7 @@ public class CardFactory_Creatures { c = getAIElemental(); } - PlayerZone grave = AllZone.getZone(c); - - if(AllZone.GameAction.isCardInZone(c, grave)) { + if(AllZoneUtil.isCardInPlayerGraveyard(card.getController(), c)) { PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, c.getController()); AllZone.GameAction.moveTo(play, c); } diff --git a/src/forge/card/cardFactory/CardFactory_Sorceries.java b/src/forge/card/cardFactory/CardFactory_Sorceries.java index 5cec60b8255..5e4df0376ab 100644 --- a/src/forge/card/cardFactory/CardFactory_Sorceries.java +++ b/src/forge/card/cardFactory/CardFactory_Sorceries.java @@ -446,9 +446,8 @@ public class CardFactory_Sorceries { if(biggest.getNetAttack() < creature.get(i).getNetAttack()) biggest = creature.get(i); c2 = biggest; } - } - PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController()); - if(AllZone.GameAction.isCardInZone(c2, grave)) { + } + if(AllZoneUtil.isCardInPlayerGraveyard(card.getController(), c2)) { AllZone.GameAction.moveToHand(c2); } // Player Draws 3 Cards @@ -3524,20 +3523,18 @@ public class CardFactory_Sorceries { @Override public void resolve() { - CardList threshold = new CardList(); - PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, card.getController()); - threshold.addAll(grave.getCards()); + CardList threshold = AllZoneUtil.getPlayerGraveyard(card.getController()); Card c = getTargetCard(); if(threshold.size() >= 7) { - if(AllZone.GameAction.isCardInZone(c, grave)) { + if(AllZoneUtil.isCardInPlayerGraveyard(card.getController(), c)) { PlayerZone play = AllZone.getZone(Constant.Zone.Battlefield, card.getController()); AllZone.GameAction.moveTo(play, c); } } else { - if(AllZone.GameAction.isCardInZone(c, grave)) { + if(AllZoneUtil.isCardInPlayerGraveyard(card.getController(), c)) { PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, card.getController()); AllZone.GameAction.moveTo(hand, c); }