From fdef1276474fc7fd366a0bb970503e9164d040d3 Mon Sep 17 00:00:00 2001 From: jendave Date: Sat, 6 Aug 2011 23:55:37 +0000 Subject: [PATCH] - Convert Dauntless Escort to AF_Effect - Cleanup in Phase and MagicStack --- res/cardsfolder/dauntless_escort.txt | 4 +- src/forge/GameActionUtil.java | 73 ----------------- src/forge/MagicStack.java | 82 ++----------------- src/forge/Phase.java | 50 +++++------ .../cardFactory/CardFactory_Creatures.java | 51 ------------ 5 files changed, 28 insertions(+), 232 deletions(-) diff --git a/res/cardsfolder/dauntless_escort.txt b/res/cardsfolder/dauntless_escort.txt index e689b59c5b8..9d6ae0e81d7 100644 --- a/res/cardsfolder/dauntless_escort.txt +++ b/res/cardsfolder/dauntless_escort.txt @@ -1,8 +1,10 @@ Name:Dauntless Escort ManaCost:1 W G Types:Creature Rhino Soldier -Text:Sacrifice Dauntless Escort: Creatures you control are indestructible this turn. +Text:no text PT:3/3 +A:AB$ Effect | Cost$ Sac<1/CARDNAME> | Name$ Dauntless Escort Effect | Keywords$ KWPump | SpellDescription$ Creatures you control are indestructible this turn. +SVar:KWPump:stPumpAll:Creature.YouCtrl:0/0/HIDDEN Indestructible:no Condition:Creatures you control are indestructible this turn. SVar:Rarity:Rare SVar:Picture:http://www.wizards.com/global/images/magic/general/dauntless_escort.jpg SetInfo:ARB|Rare|http://magiccards.info/scans/en/arb/67.jpg diff --git a/src/forge/GameActionUtil.java b/src/forge/GameActionUtil.java index 0fecc6b4a9c..3dc27812f97 100644 --- a/src/forge/GameActionUtil.java +++ b/src/forge/GameActionUtil.java @@ -5336,7 +5336,6 @@ public class GameActionUtil { Valor.execute(); Brawn.execute(); Filth.execute(); - Dauntless_Escort.execute(); Sacrifice_NoIslands.execute(); Sacrifice_NoForests.execute(); @@ -6455,78 +6454,6 @@ public class GameActionUtil { } }// execute() }; - - public static Command Dauntless_Escort = new Command() { - private static final long serialVersionUID = -2201201455269804L; - CardList old = new CardList(); - public void execute() { - - // Human Activates Dauntless Escort - PlayerZone PlayerPlayZone = AllZone.getZone(Constant.Zone.Battlefield,AllZone.HumanPlayer); - CardList PlayerCreatureList = AllZoneUtil.getCreaturesInPlay(AllZone.HumanPlayer); - PlayerZone opponentPlayZone = AllZone.getZone(Constant.Zone.Battlefield,AllZone.ComputerPlayer); - CardList opponentCreatureList = AllZoneUtil.getCreaturesInPlay(AllZone.ComputerPlayer); - if(Phase.isSacDauntlessEscort() == true) { - if(PlayerCreatureList.size() != 0) { - for(int i = 0; i < PlayerCreatureList.size(); i++) { - Card c = PlayerCreatureList.get(i); - c.removeExtrinsicKeyword("Indestructible"); - c.addExtrinsicKeyword("Indestructible"); - } - } - if(opponentCreatureList.size() != 0) { - for(int i = 0; i < opponentCreatureList.size(); i++) { - Card c = opponentCreatureList.get(i); - if(c.getOwner().isHuman()) { - if(old.size() == 0) { - c.removeExtrinsicKeyword("Indestructible"); - old.add(c); - } - for(int x = 0; x < old.size(); x++) { - if(old.get(x) == c) break; - c.removeExtrinsicKeyword("Indestructible"); - old.add(c); - } - } - } - } - } - - // Computer Activates Dauntless Escort - PlayerPlayZone = AllZone.getZone(Constant.Zone.Battlefield,AllZone.ComputerPlayer); - PlayerCreatureList = new CardList(PlayerPlayZone.getCards()); - PlayerCreatureList = PlayerCreatureList.getType("Creature"); - opponentPlayZone = AllZone.getZone(Constant.Zone.Battlefield,AllZone.HumanPlayer); - opponentCreatureList = new CardList(opponentPlayZone.getCards()); - opponentCreatureList = opponentCreatureList.getType("Creature"); - if(Phase.isSacDauntlessEscortAI() == true) { - if(PlayerCreatureList.size() != 0) { - for(int i = 0; i < PlayerCreatureList.size(); i++) { - Card c = PlayerCreatureList.get(i); - c.removeExtrinsicKeyword("Indestructible"); - c.addExtrinsicKeyword("Indestructible"); - } - } - if(opponentCreatureList.size() != 0) { - for(int i = 0; i < opponentCreatureList.size(); i++) { - Card c = opponentCreatureList.get(i); - if(c.getOwner().isComputer()) { - if(old.size() == 0) { - c.removeExtrinsicKeyword("Indestructible"); - old.add(c); - } - for(int x = 0; x < old.size(); x++) { - if(old.get(x) == c) break; - c.removeExtrinsicKeyword("Indestructible"); - old.add(c); - } - } - } - } - } - }// execute() - - }; public static Command Liu_Bei = new Command() { diff --git a/src/forge/MagicStack.java b/src/forge/MagicStack.java index 798dac628a2..3e6f3d18fea 100644 --- a/src/forge/MagicStack.java +++ b/src/forge/MagicStack.java @@ -29,13 +29,7 @@ public class MagicStack extends MyObservable { private boolean frozen = false; private boolean bResolving = false; private boolean splitSecondOnStack = false; - - private Object StormCount; - private Object PlayerSpellCount; - private Object PlayerCreatureSpellCount; - private Object ComputerSpellCount; - private Object ComputerCreatureSpellCount; - + public boolean isFrozen() { return frozen; } @@ -106,8 +100,7 @@ public class MagicStack extends MyObservable { } public void clearFrozen() { - // TODO: frozen triggered abilities and undoable costs have nasty - // consequences + // TODO: frozen triggered abilities and undoable costs have nasty consequences frozen = false; frozenStack.clear(); } @@ -691,20 +684,8 @@ public class MagicStack extends MyObservable { this.updateObservers(); if (sp.isSpell() && !sp.getSourceCard().isCopiedSpell()) { - Phase.setStormCount(Phase.getStormCount() + 1); - if (sp.getSourceCard().getController().isHuman()) { - Phase.PlayerSpellCount = Phase.PlayerSpellCount + 1; - if (sp.getSourceCard().isCreature()) { - Phase.PlayerCreatureSpellCount = Phase.PlayerCreatureSpellCount + 1; - } - } - - else { - Phase.ComputerSpellCount = Phase.ComputerSpellCount + 1; - if (sp.getSourceCard().isCreature()) { - Phase.ComputerCreatureSpellCount = Phase.ComputerCreatureSpellCount + 1; - } - } + Phase.increaseSpellCount(sp); + // attempt to counter human spell GameActionUtil.executePlayCardEffects(sp); @@ -887,47 +868,7 @@ public class MagicStack extends MyObservable { return a; } - public void setStormCount(Object stormCount) { - StormCount = stormCount; - } - - public Object getStormCount() { - return StormCount; - } - - public void setPlayerCreatureSpellCount(Object playerCreatureSpellCount) { - PlayerCreatureSpellCount = playerCreatureSpellCount; - } - - public Object getPlayerCreatureSpellCount() { - return PlayerCreatureSpellCount; - } - - public void setPlayerSpellCount(Object playerSpellCount) { - PlayerSpellCount = playerSpellCount; - } - - public Object getPlayerSpellCount() { - return PlayerSpellCount; - } - - public void setComputerSpellCount(Object computerSpellCount) { - ComputerSpellCount = computerSpellCount; - } - - public Object getComputerSpellCount() { - return ComputerSpellCount; - } - - public void setComputerCreatureSpellCount(Object computerCreatureSpellCount) { - ComputerCreatureSpellCount = computerCreatureSpellCount; - } - - public Object getComputerCreatureSpellCount() { - return ComputerCreatureSpellCount; - } - - public boolean hasSimultaneousStackEntries() + public boolean hasSimultaneousStackEntries() { return simultaneousStackEntryList.size() > 0; } @@ -935,21 +876,10 @@ public class MagicStack extends MyObservable { public void addSimultaneousStackEntry(SpellAbility sa) { simultaneousStackEntryList.add(sa); - /* - *Debug output. - System.out.println("STO add! Size:" + simultaneousStackEntryList.size()); - */ } public void chooseOrderOfSimultaneousStackEntryAll() { - /* - *Debug output. - if(simultaneousStackEntryList.size() > 0) - { - System.out.println("STO run! Size:" + simultaneousStackEntryList.size()); - } - */ chooseOrderOfSimultaneousStackEntry(AllZone.Phase.getPlayerTurn()); chooseOrderOfSimultaneousStackEntry(AllZone.Phase.getPlayerTurn().getOpponent()); } @@ -1014,7 +944,7 @@ public class MagicStack extends MyObservable { if(activePlayerSAs.get(0).isTrigger()) AllZone.GameAction.playSpellAbility(activePlayerSAs.get(0)); else - add(activePlayerSAs.get(0)); + add(activePlayerSAs.get(0)); //AllZone.GameAction.playSpellAbility(activePlayerSAs.get(0)); } } diff --git a/src/forge/Phase.java b/src/forge/Phase.java index 3f8266fd096..9db8b58bc0a 100644 --- a/src/forge/Phase.java +++ b/src/forge/Phase.java @@ -7,6 +7,9 @@ import java.util.Stack; import com.esotericsoftware.minlog.Log; +import forge.card.spellability.SpellAbility; +import forge.card.spellability.Spell_Permanent; + public class Phase extends MyObservable { private int phaseIndex; @@ -18,9 +21,7 @@ public class Phase extends MyObservable static int PlayerCreatureSpellCount; static int ComputerSpellCount; static int ComputerCreatureSpellCount; - private static boolean Sac_Dauntless_Escort; - private static boolean Sac_Dauntless_Escort_Comp; - + //Not sure these should be here but I can't think of a better place private static ArrayList ManaDrain_BonusMana_Human = new ArrayList(); private static ArrayList ManaDrain_BonusMana_AI = new ArrayList(); @@ -594,21 +595,6 @@ public class Phase extends MyObservable return sb.toString(); } - - public static boolean canPlayDuringCombat() { - String phase = AllZone.Phase.getPhase(); - ArrayList validPhases = new ArrayList(); - validPhases.add(Constant.Phase.Combat_Begin); - validPhases.add(Constant.Phase.Combat_Declare_Attackers); - validPhases.add(Constant.Phase.Combat_Declare_Attackers_InstantAbility); - validPhases.add(Constant.Phase.Combat_Declare_Blockers); - validPhases.add(Constant.Phase.Combat_Declare_Blockers_InstantAbility); - validPhases.add(Constant.Phase.Combat_FirstStrikeDamage); - validPhases.add(Constant.Phase.Combat_Damage); - validPhases.add(Constant.Phase.Combat_End); - - return validPhases.contains(phase); - } public static void main(String args[]) { Phase phase = new Phase(); @@ -618,20 +604,22 @@ public class Phase extends MyObservable } } - public static void setSacDauntlessEscort(boolean sac_Dauntless_Escort) { - Sac_Dauntless_Escort = sac_Dauntless_Escort; - } + public static void increaseSpellCount(SpellAbility sp){ + StormCount++; - public static boolean isSacDauntlessEscort() { - return Sac_Dauntless_Escort; - } - - public static void setSacDauntlessEscortAI(boolean sac_Dauntless_Escort_Comp) { - Sac_Dauntless_Escort_Comp = sac_Dauntless_Escort_Comp; - } - - public static boolean isSacDauntlessEscortAI() { - return Sac_Dauntless_Escort_Comp; + if (sp.getActivatingPlayer().isHuman()) { + PlayerSpellCount++; + if (sp instanceof Spell_Permanent && sp.getSourceCard().isCreature()) { + PlayerCreatureSpellCount++; + } + } + + else { + ComputerSpellCount++; + if (sp instanceof Spell_Permanent && sp.getSourceCard().isCreature()) { + Phase.ComputerCreatureSpellCount++; + } + } } public static void setStormCount(int stormCount) { diff --git a/src/forge/card/cardFactory/CardFactory_Creatures.java b/src/forge/card/cardFactory/CardFactory_Creatures.java index 6453e72e318..649273a6b85 100644 --- a/src/forge/card/cardFactory/CardFactory_Creatures.java +++ b/src/forge/card/cardFactory/CardFactory_Creatures.java @@ -1480,57 +1480,6 @@ public class CardFactory_Creatures { card.addComesIntoPlayCommand(comesIntoPlay); }//*************** END ************ END ************************** - - //*************** START *********** START ************************** - else if(cardName.equals("Dauntless Escort")) { - final SpellAbility ability = new Ability(card, "0") { - @Override - public boolean canPlayAI() { - PlayerZone PlayerPlayZone = AllZone.getZone(Constant.Zone.Battlefield, AllZone.ComputerPlayer); - CardList PlayerCreatureList = new CardList(PlayerPlayZone.getCards()); - PlayerCreatureList = PlayerCreatureList.getType("Creature"); - PlayerZone opponentPlayZone = AllZone.getZone(Constant.Zone.Battlefield, AllZone.HumanPlayer); - CardList opponentCreatureList = new CardList(opponentPlayZone.getCards()); - opponentCreatureList = opponentCreatureList.getType("Creature"); - return ((PlayerCreatureList.size() + 1 > 2* opponentCreatureList.size() + 1) && (Phase.isSacDauntlessEscortAI() == false) && (AllZone.Phase.getPhase().equals(Constant.Phase.Main1))) ; - } - - final Command untilEOT = new Command() { - private static final long serialVersionUID = 2701248867610L; - - public void execute() { - if(card.getController().isHuman()) { - Phase.setSacDauntlessEscort(false); - } else { - Phase.setSacDauntlessEscortAI(false); - } - PlayerZone PlayerPlayZone = AllZone.getZone(Constant.Zone.Battlefield, card.getController()); - CardList PlayerCreatureList = new CardList(PlayerPlayZone.getCards()); - PlayerCreatureList = PlayerCreatureList.getType("Creature"); - if(PlayerCreatureList.size() != 0) { - for(int i = 0; i < PlayerCreatureList.size(); i++) { - Card c = PlayerCreatureList.get(i); - c.removeExtrinsicKeyword("Indestructible"); - } - } - } - }; - @Override - public void resolve() { - AllZone.GameAction.sacrifice(card); - if(card.getController().isHuman()) { - Phase.setSacDauntlessEscort(true); - } - else Phase.setSacDauntlessEscortAI(true); - - AllZone.EndOfTurn.addUntil(untilEOT); - } - }; - card.addSpellAbility(ability); - ability.setStackDescription("Sacrifice Dauntless Escort: Creatures you control are indestructible this turn."); - }//*************** END ************ END ************************** - - //*************** START *********** START ************************** else if(cardName.equals("Wojek Embermage")) { Cost abCost = new Cost("T", cardName, true);