From 4d112ed03e8fb39868a14626c3a632af7324d9a8 Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 09:27:22 +0000 Subject: [PATCH] we have two functions that do the same thing. GameAction.exile(c) and GameAction.removeFromGame(c). Exile is the new language, so I left this function and updated all calls to use exile(c) --- src/forge/AbilityFactory_Bounce.java | 2 +- src/forge/CardFactory.java | 16 ++++---- src/forge/CardFactoryUtil.java | 2 +- src/forge/CardFactory_Creatures.java | 48 ++++++++++++------------ src/forge/CardFactory_Instants.java | 16 ++++---- src/forge/CardFactory_Planeswalkers.java | 2 +- src/forge/CardFactory_Sorceries.java | 10 ++--- src/forge/CombatUtil.java | 2 +- src/forge/GameAction.java | 19 +++++++--- 9 files changed, 62 insertions(+), 55 deletions(-) diff --git a/src/forge/AbilityFactory_Bounce.java b/src/forge/AbilityFactory_Bounce.java index 710dc3b2b6c..240820e9e29 100644 --- a/src/forge/AbilityFactory_Bounce.java +++ b/src/forge/AbilityFactory_Bounce.java @@ -193,7 +193,7 @@ public class AbilityFactory_Bounce { AllZone.GameAction.shuffle(tgtC.getOwner()); } else if(Destination.equals("Exile")) - AllZone.GameAction.removeFromGame(tgtC); + AllZone.GameAction.exile(tgtC); else if(Destination.equals("Hand")) { PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, tgtC.getOwner()); diff --git a/src/forge/CardFactory.java b/src/forge/CardFactory.java index 20552e8d39d..238c48903b4 100644 --- a/src/forge/CardFactory.java +++ b/src/forge/CardFactory.java @@ -3290,7 +3290,7 @@ public class CardFactory implements NewConstants { AllZone.GameAction.shuffle(tgtC.getOwner()); } else if(Destination.equals("Exile")) - AllZone.GameAction.removeFromGame(tgtC); + AllZone.GameAction.exile(tgtC); else if(Destination.equals("Hand")) { PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, tgtC.getOwner()); @@ -3453,7 +3453,7 @@ public class CardFactory implements NewConstants { AllZone.GameAction.shuffle(tgtC.getOwner()); } else if (Destination.equals("Exile")) - AllZone.GameAction.removeFromGame(tgtC); + AllZone.GameAction.exile(tgtC); else if (Destination.equals("Hand")) AllZone.GameAction.moveToHand(tgtC); } @@ -3628,7 +3628,7 @@ public class CardFactory implements NewConstants { AllZone.GameAction.moveToTopOfLibrary(c); AllZone.GameAction.shuffle(c.getOwner()); } - else if(Destination.equals("Exile")) AllZone.GameAction.removeFromGame(c); + else if(Destination.equals("Exile")) AllZone.GameAction.exile(c); else if(Destination.equals("Hand")) { PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, c.getOwner()); AllZone.GameAction.moveTo(hand, c); @@ -7022,7 +7022,7 @@ public class CardFactory implements NewConstants { public void resolve() { if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard())) { - AllZone.GameAction.removeFromGame(getTargetCard()); + AllZone.GameAction.exile(getTargetCard()); } }//resolve() }; @@ -7171,7 +7171,7 @@ public class CardFactory implements NewConstants { public void resolve() { if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard())) { - AllZone.GameAction.removeFromGame(getTargetCard()); + AllZone.GameAction.exile(getTargetCard()); //put permanent into play Card c = getSourceCard(); @@ -10509,7 +10509,7 @@ public class CardFactory implements NewConstants { CardList grave = AllZoneUtil.getPlayerGraveyard(player); PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player); //exile Feldon's Cane - AllZone.GameAction.removeFromGame(card); + AllZone.GameAction.exile(card); for(Card c:grave) { lib.add(c); @@ -10648,7 +10648,7 @@ public class CardFactory implements NewConstants { AllZone.GameAction.sacrifice(card); for(Card c:grave) { - AllZone.GameAction.removeFromGame(c); + AllZone.GameAction.exile(c); } AllZone.getZone(Constant.Zone.Graveyard, player).reset(); AllZone.GameAction.shuffle(player); @@ -10698,7 +10698,7 @@ public class CardFactory implements NewConstants { public void resolve() { if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard())) { - AllZone.GameAction.removeFromGame(getTargetCard()); + AllZone.GameAction.exile(getTargetCard()); }//if }//resolve() };//abilityComes diff --git a/src/forge/CardFactoryUtil.java b/src/forge/CardFactoryUtil.java index 103e8625e3f..63f1adbb94a 100644 --- a/src/forge/CardFactoryUtil.java +++ b/src/forge/CardFactoryUtil.java @@ -1729,7 +1729,7 @@ public class CardFactoryUtil { @Override public void resolve() { - AllZone.GameAction.removeFromGame(sourceCard); + AllZone.GameAction.exile(sourceCard); sourceCard.addCounter(Counters.TIME, suspendCounters); } }; diff --git a/src/forge/CardFactory_Creatures.java b/src/forge/CardFactory_Creatures.java index 267652500ff..004358b0c91 100644 --- a/src/forge/CardFactory_Creatures.java +++ b/src/forge/CardFactory_Creatures.java @@ -1846,7 +1846,7 @@ public class CardFactory_Creatures { if(card.isToken()) return; - AllZone.GameAction.removeFromGame(card); + AllZone.GameAction.exile(card); } };//SpellAbility Command destroy = new Command() { @@ -4430,7 +4430,7 @@ public class CardFactory_Creatures { play.remove(getTargetCard()); removed.add(getTargetCard()); */ - AllZone.GameAction.removeFromGame(getTargetCard()); + AllZone.GameAction.exile(getTargetCard()); } }//resolve() }; @@ -4558,7 +4558,7 @@ public class CardFactory_Creatures { play.remove(getTargetCard()); removed.add(getTargetCard()); */ - AllZone.GameAction.removeFromGame(getTargetCard()); + AllZone.GameAction.exile(getTargetCard()); } }//resolve() }; @@ -4685,7 +4685,7 @@ public class CardFactory_Creatures { play.remove(getTargetCard()); removed.add(getTargetCard()); */ - AllZone.GameAction.removeFromGame(getTargetCard()); + AllZone.GameAction.exile(getTargetCard()); } }//resolve() }; @@ -4849,7 +4849,7 @@ public class CardFactory_Creatures { play.remove(getTargetCard()); removed.add(getTargetCard()); */ - AllZone.GameAction.removeFromGame(getTargetCard()); + AllZone.GameAction.exile(getTargetCard()); } }//resolve() }; @@ -4981,7 +4981,7 @@ public class CardFactory_Creatures { play.remove(getTargetCard()); removed.add(getTargetCard()); */ - AllZone.GameAction.removeFromGame(getTargetCard()); + AllZone.GameAction.exile(getTargetCard()); } }//resolve() }; @@ -5533,7 +5533,7 @@ public class CardFactory_Creatures { { if(zone.is(Constant.Zone.Hand) && !c.isLand()) { - AllZone.GameAction.removeFromGame(c); + AllZone.GameAction.exile(c); chosen.push(c); AllZone.Stack.add(ability); stopSetNext(new ComputerAI_StackNotEmpty()); @@ -8035,8 +8035,8 @@ public class CardFactory_Creatures { @Override public void chooseTargetAI() { if (AllZone.Computer_Graveyard.getCards().length >=2) { - AllZone.GameAction.removeFromGame(AllZone.Computer_Graveyard.getCards()[0]); - AllZone.GameAction.removeFromGame(AllZone.Computer_Graveyard.getCards()[0]); + AllZone.GameAction.exile(AllZone.Computer_Graveyard.getCards()[0]); + AllZone.GameAction.exile(AllZone.Computer_Graveyard.getCards()[0]); } } @@ -8073,7 +8073,7 @@ public class CardFactory_Creatures { if (o!=null) { Card c1 = (Card)o; - AllZone.GameAction.removeFromGame(c1); + AllZone.GameAction.exile(c1); list.remove(c1); o = AllZone.Display.getChoice("Choose second card to exile", list.toArray()); @@ -8081,7 +8081,7 @@ public class CardFactory_Creatures { { Card c2 = (Card)o; - AllZone.GameAction.removeFromGame(c2); + AllZone.GameAction.exile(c2); once = true; AllZone.Stack.add(ability2); @@ -9243,7 +9243,7 @@ public class CardFactory_Creatures { list.addAll(AllZone.Human_Play.getCards()); list = list.getName("Stangg Twin"); - if(list.size() == 1) AllZone.GameAction.removeFromGame(list.get(0)); + if(list.size() == 1) AllZone.GameAction.exile(list.get(0)); } }); @@ -11108,7 +11108,7 @@ public class CardFactory_Creatures { if(getTargetCard() != null) { if(AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard())) { - AllZone.GameAction.removeFromGame(getTargetCard()); + AllZone.GameAction.exile(getTargetCard()); } } } @@ -11901,11 +11901,11 @@ public class CardFactory_Creatures { Object o = AllZone.Display.getChoiceOptional("Select card to remove: ", cards.toArray()); Card c = (Card) o; - AllZone.GameAction.removeFromGame(c); + AllZone.GameAction.exile(c); AllZone.GameAction.shuffle(opponent); } else { Card c = lib.get(0); - AllZone.GameAction.removeFromGame(c); + AllZone.GameAction.exile(c); AllZone.GameAction.shuffle(opponent); } } @@ -12991,10 +12991,10 @@ public class CardFactory_Creatures { Object o = AllZone.Display.getChoiceOptional(title, gravecards.toArray()); if(o != null) { Card removedCard = (Card) o; - AllZone.GameAction.removeFromGame(removedCard); + AllZone.GameAction.exile(removedCard); } } else { - AllZone.GameAction.removeFromGame(gravecards.get(0)); + AllZone.GameAction.exile(gravecards.get(0)); } } @@ -16222,7 +16222,7 @@ public class CardFactory_Creatures { } } } - AllZone.GameAction.removeFromGame(card); + AllZone.GameAction.exile(card); } }//if human else { @@ -16239,7 +16239,7 @@ public class CardFactory_Creatures { Card c = CardFactoryUtil.AI_getBestEnchantment(list, card, false); lib.remove(c); play.add(c); - AllZone.GameAction.removeFromGame(card); + AllZone.GameAction.exile(card); } } @@ -17601,7 +17601,7 @@ public class CardFactory_Creatures { list = list.getType("Nightmare"); for(Card c:list) { - AllZone.GameAction.removeFromGame(c); + AllZone.GameAction.exile(c); } } @@ -19238,7 +19238,7 @@ public class CardFactory_Creatures { int max = Math.min(lib.size(), 10); for(int i = 0; i < max; i++) { //remove the top card 10 times - AllZone.GameAction.removeFromGame(lib.get(0)); + AllZone.GameAction.exile(lib.get(0)); } if(getTargetCard() != null) { if(AllZone.GameAction.isCardInPlay(getTargetCard()) @@ -19262,7 +19262,7 @@ public class CardFactory_Creatures { public void makeToken(Card c) { - AllZone.GameAction.removeFromGame(c); + AllZone.GameAction.exile(c); CardFactoryUtil.makeToken("Zombie", "B 2 2 Zombie", card, "B", new String[] { "Creature", "Zombie"}, 2, 2, new String[] {""}); } @@ -20256,7 +20256,7 @@ public class CardFactory_Creatures { for(int m = 0; m < selection.size(); m++) { intermSumPower += selection.get(m).getBaseAttack(); intermSumToughness += selection.get(m).getBaseDefense(); - AllZone.GameAction.removeFromGame(selection.get(m)); + AllZone.GameAction.exile(selection.get(m)); } } @@ -20268,7 +20268,7 @@ public class CardFactory_Creatures { if(c.getNetAttack() <= 2 && c.getNetDefense() <= 3) { intermSumPower += c.getBaseAttack(); intermSumToughness += c.getBaseDefense(); - AllZone.GameAction.removeFromGame(c); + AllZone.GameAction.exile(c); count++; } //is this needed? diff --git a/src/forge/CardFactory_Instants.java b/src/forge/CardFactory_Instants.java index beea67b4579..1a6a494c628 100644 --- a/src/forge/CardFactory_Instants.java +++ b/src/forge/CardFactory_Instants.java @@ -438,7 +438,7 @@ public class CardFactory_Instants { && CardFactoryUtil.canTarget(card, getTargetCard())) { Player controller = getTargetCard().getController(); - AllZone.GameAction.removeFromGame(getTargetCard()); + AllZone.GameAction.exile(getTargetCard()); CardFactoryUtil.makeToken("Shapeshifter", "C 1 1 Shapeshifter", controller, "", new String[] {"Creature", "Shapeshifter"}, 1, @@ -1990,7 +1990,7 @@ public class CardFactory_Instants { if(!getTargetCard().isFaceDown()) { //bounce all permanents with the same name for(int i = 0; i < sameName.size(); i++) { - if(sameName.get(i).isToken()) AllZone.GameAction.removeFromGame(sameName.get(i)); + if(sameName.get(i).isToken()) AllZone.GameAction.exile(sameName.get(i)); else { PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, sameName.get(i).getOwner()); AllZone.GameAction.moveTo(hand, sameName.get(i)); @@ -3362,7 +3362,7 @@ public class CardFactory_Instants { PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player); //remove card from play - AllZone.GameAction.removeFromGame(getTargetCard()); + AllZone.GameAction.exile(getTargetCard()); //Retrieve basic land CardList lands = new CardList(lib.getCards()); @@ -3722,7 +3722,7 @@ public class CardFactory_Instants { public void selectCard(Card c, PlayerZone zone) { if(c.isBlue() && zone.is(Constant.Zone.Hand) && !c.equals(card)) { - AllZone.GameAction.removeFromGame(c); + AllZone.GameAction.exile(c); Player player = card.getController(); //AllZone.GameAction.getPlayerLife(player).subtractLife(1,card); player.subtractLife(1, card); @@ -4470,14 +4470,14 @@ public class CardFactory_Instants { if(o == null) break; Card c_1 = (Card) o; graveList.remove(c_1); //remove from the display list - AllZone.GameAction.removeFromGame(c_1); + AllZone.GameAction.exile(c_1); } } else { //Computer //Random random = new Random(); for(int j = 0; j < X; j++) { //int index = random.nextInt(X-j); - AllZone.GameAction.removeFromGame(graveList.get(j)); + AllZone.GameAction.exile(graveList.get(j)); } } @@ -4600,7 +4600,7 @@ public class CardFactory_Instants { for(int i = 0; i < 7; i++) { Card c = libList.get(i); - AllZone.GameAction.removeFromGame(c); + AllZone.GameAction.exile(c); } int max = libList.size(); @@ -4614,7 +4614,7 @@ public class CardFactory_Instants { } } else if(stop == 0) { - AllZone.GameAction.removeFromGame(c); + AllZone.GameAction.exile(c); } } } diff --git a/src/forge/CardFactory_Planeswalkers.java b/src/forge/CardFactory_Planeswalkers.java index 19a31501d04..1e18e69fa7d 100644 --- a/src/forge/CardFactory_Planeswalkers.java +++ b/src/forge/CardFactory_Planeswalkers.java @@ -2924,7 +2924,7 @@ class CardFactory_Planeswalkers { CardList handList = new CardList(hand.getCards()); for(Card c:libList) - AllZone.GameAction.removeFromGame(c); + AllZone.GameAction.exile(c); handList.shuffle(); for(Card c:handList) { diff --git a/src/forge/CardFactory_Sorceries.java b/src/forge/CardFactory_Sorceries.java index c99066bde60..b2e42115891 100644 --- a/src/forge/CardFactory_Sorceries.java +++ b/src/forge/CardFactory_Sorceries.java @@ -34,7 +34,7 @@ public class CardFactory_Sorceries { discardDraw7(AllZone.ComputerPlayer); if (cardName.equals("Time Reversal")) - AllZone.GameAction.removeFromGame(card); + AllZone.GameAction.exile(card); }//resolve() void discardDraw7(Player player) { @@ -6083,13 +6083,13 @@ public class CardFactory_Sorceries { damage++; // tally up how many cards removed Card c_1 = (Card) o; graveList.remove(c_1); //remove from the display list - AllZone.GameAction.removeFromGame(c_1); + AllZone.GameAction.exile(c_1); } } else { //Computer // it would be nice if the computer chose vanilla creatures over for(int j = 0; j < size; j++) { - AllZone.GameAction.removeFromGame(graveList.get(j)); + AllZone.GameAction.exile(graveList.get(j)); } } tPlayer.addDamage(damage, card); @@ -6578,7 +6578,7 @@ public class CardFactory_Sorceries { Card tgt = getTargetCard(); if (null != tgt) { if (tgt.isToken()) { - AllZone.GameAction.removeFromGame(tgt); + AllZone.GameAction.exile(tgt); } else { PlayerZone lib = AllZone.getZone(Constant.Zone.Library, tgt.getOwner()); PlayerZone play = AllZone.getZone(Constant.Zone.Play, tgt.getController()); @@ -7450,7 +7450,7 @@ public class CardFactory_Sorceries { for(int i = 0; i < target.length; i++) { Card c = target[i]; if (AllZone.GameAction.isCardInPlay(c)) - AllZone.GameAction.removeFromGame(c); + AllZone.GameAction.exile(c); } card.getController().addDamage(5, card); diff --git a/src/forge/CombatUtil.java b/src/forge/CombatUtil.java index 98818f7634d..a68e2c7002a 100644 --- a/src/forge/CombatUtil.java +++ b/src/forge/CombatUtil.java @@ -2574,7 +2574,7 @@ public class CombatUtil { @Override public void resolve() { if(attacker.isToken()) - AllZone.GameAction.removeFromGame(attacker); + AllZone.GameAction.exile(attacker); else { PlayerZone hand = AllZone.getZone(Constant.Zone.Hand, attacker.getOwner()); AllZone.GameAction.moveTo(hand, attacker); diff --git a/src/forge/GameAction.java b/src/forge/GameAction.java index d1c70ed1cf1..b468ddd37ec 100644 --- a/src/forge/GameAction.java +++ b/src/forge/GameAction.java @@ -168,7 +168,7 @@ public class GameAction { discard_nath(c); discard_megrim(c); if(CardFactoryUtil.getCards("Necropotence", c.getOwner()).size() > 0){ // necro disrupts madness - removeFromGame(c); + exile(c); return; } discard_madness(c); @@ -2417,6 +2417,7 @@ public class GameAction { return true; } + /* //because originally, MTGForge didn't keep track of cards removed from the game. public void removeFromGame(Card c) { if(AllZone.GameAction.isCardRemovedFromGame(c)) return; @@ -2428,17 +2429,23 @@ public class GameAction { zone.remove(c); if(!c.isToken()) removed.add(c); - } + }*/ /** * basically an alias for removeFromGame to bring the language in the code * to match the mechanics in Forge - * @param c + * @param c the card to be exiled */ - - public void exile(Card c) { - removeFromGame(c); + //removeFromGame(c); + if(AllZone.GameAction.isCardRemovedFromGame(c)) return; + + PlayerZone zone = AllZone.getZone(c); //could be hand, grave, play, ... + PlayerZone removed = AllZone.getZone(Constant.Zone.Removed_From_Play, c.getOwner()); + + if (zone != null) // for suspend + zone.remove(c); + if(!c.isToken()) removed.add(c); }