diff --git a/src/forge/CardFactory.java b/src/forge/CardFactory.java index 64c0cdee00e..501eda4f880 100644 --- a/src/forge/CardFactory.java +++ b/src/forge/CardFactory.java @@ -4787,6 +4787,8 @@ public class CardFactory implements NewConstants { PlayerZone from = AllZone.getZone(c); PlayerZone to = AllZone.getZone(Constant.Zone.Play, card.getController()); + CardFactoryUtil.checkEquipmentOnControllerChange(from, to, c); + from.remove(c); to.add(c); @@ -6353,6 +6355,7 @@ public class CardFactory implements NewConstants { //moveTo() makes a new card, so you don't have to remove "Haste" //AllZone.GameAction.moveTo(playEOT[0], target[0]); + temp[0].remove(target[0]); orig[0].add(target[0]); target[0].untap(); @@ -6385,6 +6388,8 @@ public class CardFactory implements NewConstants { temp[0] = play; orig[0].remove(getTargetCard()); + CardFactoryUtil.checkEquipmentOnControllerChange(orig[0], temp[0], getTargetCard()); + ((PlayerZone_ComesIntoPlay) AllZone.Human_Play).setTriggers(true); ((PlayerZone_ComesIntoPlay) AllZone.Computer_Play).setTriggers(true); @@ -16101,6 +16106,7 @@ public class CardFactory implements NewConstants { PlayerZone to = AllZone.getZone(Constant.Zone.Play, AllZone.GameAction.getOpponent(card.getController())); + CardFactoryUtil.checkEquipmentOnControllerChange(from, to, c); to.add(c); ((PlayerZone_ComesIntoPlay) AllZone.Human_Play).setTriggers(true); diff --git a/src/forge/CardFactoryUtil.java b/src/forge/CardFactoryUtil.java index aff785521ca..f4d0fd40e0f 100644 --- a/src/forge/CardFactoryUtil.java +++ b/src/forge/CardFactoryUtil.java @@ -3047,7 +3047,6 @@ public class CardFactoryUtil { list.add(ability); } } - return list; } @@ -3065,6 +3064,16 @@ public class CardFactoryUtil { return neededDamage; } + public static void checkEquipmentOnControllerChange(PlayerZone from, PlayerZone to, Card c) + { + if (!c.isEquipped()) + ; + else if (!from.equals(to)) + { + c.unEquipAllCards(); + } + } + //may return null static public Card getRandomCard(CardList list) { if(list.size() == 0) return null; diff --git a/src/forge/CardFactory_Auras.java b/src/forge/CardFactory_Auras.java index d57cdb490c4..93739330df2 100644 --- a/src/forge/CardFactory_Auras.java +++ b/src/forge/CardFactory_Auras.java @@ -2849,6 +2849,8 @@ class CardFactory_Auras { PlayerZone to = AllZone.getZone(Constant.Zone.Play, card.getController()); to.add(crd); + CardFactoryUtil.checkEquipmentOnControllerChange(from, to, crd); + ((PlayerZone_ComesIntoPlay) AllZone.Human_Play).setTriggers(true); ((PlayerZone_ComesIntoPlay) AllZone.Computer_Play).setTriggers(true); } @@ -2881,6 +2883,7 @@ class CardFactory_Auras { crd.setController(opp); PlayerZone to = AllZone.getZone(Constant.Zone.Play, opp); + CardFactoryUtil.checkEquipmentOnControllerChange(from, to, crd); to.add(crd); ((PlayerZone_ComesIntoPlay) AllZone.Human_Play).setTriggers(true); diff --git a/src/forge/CardFactory_Creatures.java b/src/forge/CardFactory_Creatures.java index b59b2124ef2..a94a8ee7e91 100644 --- a/src/forge/CardFactory_Creatures.java +++ b/src/forge/CardFactory_Creatures.java @@ -7765,6 +7765,7 @@ public class CardFactory_Creatures { from.remove(c); PlayerZone to = AllZone.getZone(Constant.Zone.Play, card.getController()); + CardFactoryUtil.checkEquipmentOnControllerChange(from, to, c); to.add(c); ((PlayerZone_ComesIntoPlay) AllZone.Human_Play).setTriggers(true); diff --git a/src/forge/Combat.java b/src/forge/Combat.java index bd34b0e4a8d..11051c67f45 100644 --- a/src/forge/Combat.java +++ b/src/forge/Combat.java @@ -165,7 +165,7 @@ public class Combat { blocked.add(attacker); getList(attacker).add(blocker); - CombatUtil.checkBlockedAttackers(attacker, blocker); + //CombatUtil.checkBlockedAttackers(attacker, blocker); } public void resetBlockers() { diff --git a/src/forge/CombatUtil.java b/src/forge/CombatUtil.java index e10e95fbfd6..55753cc0fd3 100644 --- a/src/forge/CombatUtil.java +++ b/src/forge/CombatUtil.java @@ -418,7 +418,7 @@ public class CombatUtil { //loop through blockers for(int inner = 0; inner < defend.length; inner++) { - checkDeclareBlockers(defend[inner]); + //checkDeclareBlockers(defend[inner]); blockerName = defend[inner].getName(); if(defend[inner].isFaceDown()) blockerName = "Morph"; @@ -469,7 +469,7 @@ public class CombatUtil { //loop through blockers for(int inner = 0; inner < defend.length; inner++) { - checkDeclareBlockers(defend[inner]); + //checkDeclareBlockers(defend[inner]); blockerName = defend[inner].getName(); if(defend[inner].isFaceDown()) blockerName = "Morph"; @@ -1444,7 +1444,7 @@ public class CombatUtil { } - private static void checkDeclareBlockers(Card c) { + static void checkDeclareBlockers(Card c) { if(AllZone.Phase.getPhase().equals("Declare Blockers")) { if(c.getName().equals("Jedit Ojanen of Efrava") && !c.getCreatureBlockedThisTurn()) { @@ -1509,9 +1509,11 @@ public class CombatUtil { for(Ability ab:CardFactoryUtil.getBushidoEffects(a)) AllZone.Stack.add(ab); } - + if (!b.getCreatureBlockedThisTurn()) { for(Ability ab:CardFactoryUtil.getBushidoEffects(b)) AllZone.Stack.add(ab); + b.setCreatureBlockedThisTurn(true); + } if(a.getKeyword().contains("Flanking") && !b.getKeyword().contains("Flanking")) { int flankingMagnitude = 0; diff --git a/src/forge/Computer.java b/src/forge/Computer.java index 50b97a1a35c..9ee5f31bf40 100644 --- a/src/forge/Computer.java +++ b/src/forge/Computer.java @@ -9,6 +9,7 @@ public interface Computer public void declare_attackers(); public void declare_blockers();//this is called after when the Human or Computer blocks public void declare_blockers_after();//can play Instants and Abilities + public void after_declare_blockers(); public void end_of_combat(); public void main2(); public void end_of_turn();//end of Human's turn diff --git a/src/forge/ComputerAI_Burn.java b/src/forge/ComputerAI_Burn.java index d03662da31b..9bb18b7ea36 100644 --- a/src/forge/ComputerAI_Burn.java +++ b/src/forge/ComputerAI_Burn.java @@ -88,6 +88,11 @@ public class ComputerAI_Burn implements Computer { AllZone.Phase.setNeedToNextPhase(true); } + public void after_declare_blockers() + { + AllZone.Phase.setNeedToNextPhase(true); + } + public void end_of_combat() { AllZone.Phase.setNeedToNextPhase(true); diff --git a/src/forge/ComputerAI_Burn2.java b/src/forge/ComputerAI_Burn2.java index 49d361b8ca7..6bcb9d233bd 100644 --- a/src/forge/ComputerAI_Burn2.java +++ b/src/forge/ComputerAI_Burn2.java @@ -125,6 +125,11 @@ public class ComputerAI_Burn2 implements Computer { AllZone.Phase.setNeedToNextPhase(true); } + public void after_declare_blockers() + { + AllZone.Phase.setNeedToNextPhase(true); + } + public void end_of_combat() { AllZone.Phase.setNeedToNextPhase(true); diff --git a/src/forge/ComputerAI_General.java b/src/forge/ComputerAI_General.java index 4995080dd77..cdbcaa1766b 100644 --- a/src/forge/ComputerAI_General.java +++ b/src/forge/ComputerAI_General.java @@ -287,6 +287,29 @@ public class ComputerAI_General implements Computer { AllZone.Phase.setNeedToNextPhase(true); } + public void after_declare_blockers() { + CardList list = new CardList(); + list.addAll(AllZone.Combat.getAllBlockers().toArray()); + list.addAll(AllZone.pwCombat.getAllBlockers().toArray()); + + CardList attList = new CardList(); + attList.addAll(AllZone.Combat.getAttackers()); + attList.addAll(AllZone.pwCombat.getAttackers()); + + + for(Card c:list) + CombatUtil.checkDeclareBlockers(c); + + + for (Card a:attList){ + CardList blockList = AllZone.Combat.getBlockers(a); + for (Card b:blockList) + CombatUtil.checkBlockedAttackers(a, b); + } + + AllZone.Phase.setNeedToNextPhase(true); + } + public void end_of_combat() { AllZone.Phase.setNeedToNextPhase(true); diff --git a/src/forge/ComputerAI_Input.java b/src/forge/ComputerAI_Input.java index eaaf4e0e887..0e9bd7f8186 100644 --- a/src/forge/ComputerAI_Input.java +++ b/src/forge/ComputerAI_Input.java @@ -46,6 +46,9 @@ public class ComputerAI_Input extends Input { computer.declare_attackers(); } else if(phase.equals(Constant.Phase.Combat_Declare_Blockers_InstantAbility)) { computer.declare_blockers_after(); + } else if (phase.equals(Constant.Phase.Combat_After_Declare_Blockers)) + { + computer.after_declare_blockers(); } else if(phase.equals(Constant.Phase.Main2)) { computer.main2(); } else if(phase.equals(Constant.Phase.At_End_Of_Turn)) { diff --git a/src/forge/ComputerAI_Rats2.java b/src/forge/ComputerAI_Rats2.java index fa7c8671600..155ea845bb8 100644 --- a/src/forge/ComputerAI_Rats2.java +++ b/src/forge/ComputerAI_Rats2.java @@ -123,6 +123,11 @@ public class ComputerAI_Rats2 implements Computer public void declare_blockers_after(){playInstantAndAbilities();} + public void after_declare_blockers() + { + AllZone.Phase.setNeedToNextPhase(true); + } + public void end_of_combat() { AllZone.Phase.setNeedToNextPhase(true); diff --git a/src/forge/ComputerAI_Testing.java b/src/forge/ComputerAI_Testing.java index afac11a8f1e..1e3984e19e9 100644 --- a/src/forge/ComputerAI_Testing.java +++ b/src/forge/ComputerAI_Testing.java @@ -45,6 +45,11 @@ public class ComputerAI_Testing implements Computer //for debugging: System.out.println("need to nextPhase(ComputerAI_Testing.declare_blockers_after) = true"); AllZone.Phase.setNeedToNextPhase(true); } + + public void after_declare_blockers() + { + AllZone.Phase.setNeedToNextPhase(true); + } public void end_of_combat() { diff --git a/src/forge/Constant.java b/src/forge/Constant.java index ec71de0235f..3b51aa2f272 100644 --- a/src/forge/Constant.java +++ b/src/forge/Constant.java @@ -65,6 +65,7 @@ public interface Constant { public static final String Combat_Declare_Attackers_InstantAbility = "Declare Attackers - Play Instants and Abilities"; public static final String Combat_Declare_Attackers = "Declare Attackers"; public static final String Combat_Declare_Blockers = "Declare Blockers"; + public static final String Combat_After_Declare_Blockers = "After Declare Blockers Phase"; public static final String Combat_Declare_Blockers_InstantAbility = "Declare Blockers - Play Instants and Abilities"; public static final String Combat_Damage = "Combat Damage"; public static final String Combat_FirstStrikeDamage = "First Strike Damage"; diff --git a/src/forge/InputControl.java b/src/forge/InputControl.java index 2ab564677e6..8d0b45866d0 100644 --- a/src/forge/InputControl.java +++ b/src/forge/InputControl.java @@ -114,7 +114,34 @@ public class InputControl extends MyObservable implements java.io.Serializable { //do not return getInput() here. There is now a check for null by this method's caller. return null; } - } else if(phase.equals(Constant.Phase.Combat_FirstStrikeDamage)) { + } + /* + else if (phase.equals(Constant.Phase.Combat_After_Declare_Blockers)) + { + CardList list = new CardList(); + list.addAll(AllZone.Combat.getAllBlockers().toArray()); + list.addAll(AllZone.pwCombat.getAllBlockers().toArray()); + + CardList attList = new CardList(); + attList.addAll(AllZone.Combat.getAttackers()); + attList.addAll(AllZone.pwCombat.getAttackers()); + + + for(Card c:list) + CombatUtil.checkDeclareBlockers(c); + + + for (Card a:attList){ + CardList blockList = AllZone.Combat.getBlockers(a); + for (Card b:blockList) + CombatUtil.checkBlockedAttackers(a, b); + } + + AllZone.Phase.setNeedToNextPhase(true); + } + */ + + else if(phase.equals(Constant.Phase.Combat_FirstStrikeDamage)) { if(!skipPhase()) return new Input_FirstStrikeDamage(); else { diff --git a/src/forge/Phase.java b/src/forge/Phase.java index df92db2fc18..f34acfba704 100644 --- a/src/forge/Phase.java +++ b/src/forge/Phase.java @@ -23,6 +23,7 @@ public class Phase extends MyObservable { {Constant.Player.Computer, Constant.Phase.Combat_Declare_Blockers}, {Constant.Player.Human, Constant.Phase.Combat_Declare_Blockers_InstantAbility}, {Constant.Player.Computer, Constant.Phase.Combat_Declare_Blockers_InstantAbility}, + {Constant.Player.Computer, Constant.Phase.Combat_After_Declare_Blockers}, {Constant.Player.Human, Constant.Phase.Combat_FirstStrikeDamage}, //TODO: need to allow computer to have priority (play instants and abilities). {Constant.Player.Human, Constant.Phase.Combat_Damage}, {Constant.Player.Human, Constant.Phase.End_Of_Combat}, @@ -42,6 +43,7 @@ public class Phase extends MyObservable { {Constant.Player.Human, Constant.Phase.Combat_Declare_Blockers}, {Constant.Player.Computer, Constant.Phase.Combat_Declare_Blockers_InstantAbility}, {Constant.Player.Human, Constant.Phase.Combat_Declare_Blockers_InstantAbility}, + {Constant.Player.Computer, Constant.Phase.Combat_After_Declare_Blockers}, {Constant.Player.Human, Constant.Phase.Combat_FirstStrikeDamage}, //TODO: need to allow computer to have priority (play instants and abilities). {Constant.Player.Human, Constant.Phase.Combat_Damage}, {Constant.Player.Human, Constant.Phase.End_Of_Combat},