diff --git a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java index d1c17c24666..4708905b368 100644 --- a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java @@ -1895,27 +1895,6 @@ public class ComputerPlayer extends PlayerImpl implements Player { return 0; } - @Override - public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana) { - switch (ability.getSpellAbilityType()) { - case SPLIT: - case SPLIT_FUSED: - case SPLIT_AFTERMATH: - MageObject object = game.getObject(ability.getSourceId()); - if (object != null) { - LinkedHashMap useableAbilities = getSpellAbilities(playerId, object, game.getState().getZone(object.getId()), game); - if (useableAbilities != null && !useableAbilities.isEmpty()) { - // game.fireGetChoiceEvent(playerId, name, object, new ArrayList<>(useableAbilities.values())); - // TODO: Improve this - return (SpellAbility) useableAbilities.values().iterator().next(); - } - } - return null; - default: - return ability; - } - } - @Override public Mode chooseMode(Modes modes, Ability source, Game game) { log.debug("chooseMode"); diff --git a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java index edd52b2c80e..18ca9e30a42 100644 --- a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java @@ -1973,51 +1973,6 @@ public class HumanPlayer extends PlayerImpl { return true; } - @Override - public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana) { - if (gameInCheckPlayableState(game)) { - return null; - } - - // TODO: add canRespond cycle? - if (!canRespond()) { - return null; - } - - switch (ability.getSpellAbilityType()) { - case SPLIT: - case SPLIT_FUSED: - case SPLIT_AFTERMATH: - MageObject object = game.getObject(ability.getSourceId()); - if (object != null) { - String message = "Choose ability to cast" + (noMana ? " for FREE" : "") + "
" + object.getLogName(); - LinkedHashMap useableAbilities = getSpellAbilities(playerId, object, game.getState().getZone(object.getId()), game); - if (useableAbilities != null - && useableAbilities.size() == 1) { - return (SpellAbility) useableAbilities.values().iterator().next(); - } else if (useableAbilities != null - && !useableAbilities.isEmpty()) { - - updateGameStatePriority("chooseSpellAbilityForCast", game); - prepareForResponse(game); - if (!isExecutingMacro()) { - game.fireGetChoiceEvent(playerId, message, object, new ArrayList<>(useableAbilities.values())); - } - waitForResponse(game); - - if (response.getUUID() != null) { - if (useableAbilities.containsKey(response.getUUID())) { - return (SpellAbility) useableAbilities.get(response.getUUID()); - } - } - } - } - return null; - default: - return ability; - } - } - @Override public SpellAbility chooseAbilityForCast(Card card, Game game, boolean nonMana) { if (gameInCheckPlayableState(game)) { diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayer.java b/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayer.java index b0ec4c7b39d..244e572636a 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayer.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayer.java @@ -29,39 +29,6 @@ public class TestComputerPlayer extends ComputerPlayer { this.testPlayerLink = testPlayerLink; } - @Override - public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana) { - // copy-paste for TestComputerXXX - - // workaround to cast fused cards in tests by it's NAMES (Wear, Tear, Wear // Tear) - // reason: TestPlayer uses outer computerPlayer to cast, not TestPlayer - switch (ability.getSpellAbilityType()) { - case SPLIT: - case SPLIT_FUSED: - case SPLIT_AFTERMATH: - if (!this.testPlayerLink.getChoices().isEmpty()) { - MageObject object = game.getObject(ability.getSourceId()); - if (object != null) { - LinkedHashMap useableAbilities = getSpellAbilities(playerId, object, game.getState().getZone(object.getId()), game); - - // left, right or fused cast - for (String choose : this.testPlayerLink.getChoices()) { - for (ActivatedAbility activatedAbility : useableAbilities.values()) { - if (activatedAbility instanceof SpellAbility) { - if (((SpellAbility) activatedAbility).getCardName().equals(choose)) { - return (SpellAbility) activatedAbility; - } - } - } - } - } - } - } - - // default implementation by AI - return super.chooseSpellAbilityForCast(ability, game, noMana); - } - @Override public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game) { // copy-paste for TestComputerXXX diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayer7.java b/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayer7.java index f8d9933eb4a..d09df3087f0 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayer7.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayer7.java @@ -29,39 +29,6 @@ public class TestComputerPlayer7 extends ComputerPlayer7 { this.testPlayerLink = testPlayerLink; } - @Override - public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana) { - // copy-paste for TestComputerXXX - - // workaround to cast fused cards in tests by it's NAMES (Wear, Tear, Wear // Tear) - // reason: TestPlayer uses outer computerPlayer to cast, not TestPlayer - switch (ability.getSpellAbilityType()) { - case SPLIT: - case SPLIT_FUSED: - case SPLIT_AFTERMATH: - if (!this.testPlayerLink.getChoices().isEmpty()) { - MageObject object = game.getObject(ability.getSourceId()); - if (object != null) { - LinkedHashMap useableAbilities = getSpellAbilities(playerId, object, game.getState().getZone(object.getId()), game); - - // left, right or fused cast - for (String choose : this.testPlayerLink.getChoices()) { - for (ActivatedAbility activatedAbility : useableAbilities.values()) { - if (activatedAbility instanceof SpellAbility) { - if (((SpellAbility) activatedAbility).getCardName().equals(choose)) { - return (SpellAbility) activatedAbility; - } - } - } - } - } - } - } - - // default implementation by AI - return super.chooseSpellAbilityForCast(ability, game, noMana); - } - @Override public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game) { // copy-paste for TestComputerXXX diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayerMonteCarlo.java b/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayerMonteCarlo.java index aad9d886505..3dd236fcd96 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayerMonteCarlo.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestComputerPlayerMonteCarlo.java @@ -29,39 +29,6 @@ public class TestComputerPlayerMonteCarlo extends ComputerPlayerMCTS { this.testPlayerLink = testPlayerLink; } - @Override - public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana) { - // copy-paste for TestComputerXXX - - // workaround to cast fused cards in tests by it's NAMES (Wear, Tear, Wear // Tear) - // reason: TestPlayer uses outer computerPlayer to cast, not TestPlayer - switch (ability.getSpellAbilityType()) { - case SPLIT: - case SPLIT_FUSED: - case SPLIT_AFTERMATH: - if (!this.testPlayerLink.getChoices().isEmpty()) { - MageObject object = game.getObject(ability.getSourceId()); - if (object != null) { - LinkedHashMap useableAbilities = getSpellAbilities(playerId, object, game.getState().getZone(object.getId()), game); - - // left, right or fused cast - for (String choose : this.testPlayerLink.getChoices()) { - for (ActivatedAbility activatedAbility : useableAbilities.values()) { - if (activatedAbility instanceof SpellAbility) { - if (((SpellAbility) activatedAbility).getCardName().equals(choose)) { - return (SpellAbility) activatedAbility; - } - } - } - } - } - } - } - - // default implementation by AI - return super.chooseSpellAbilityForCast(ability, game, noMana); - } - @Override public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game) { // copy-paste for TestComputerXXX diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java index 34f9dbdc1ac..4dd31575be4 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java @@ -3456,12 +3456,6 @@ public class TestPlayer implements Player { computerPlayer.cleanUpOnMatchEnd(); } - @Override - public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana) { - Assert.fail("That's method must calls only from computerPlayer->cast(), see TestComputerPlayerXXX"); - return computerPlayer.chooseSpellAbilityForCast(ability, game, noMana); - } - @Override public void skip() { computerPlayer.skip(); diff --git a/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java b/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java index ed5e1adbbc1..a104c25d485 100644 --- a/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java +++ b/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java @@ -543,11 +543,6 @@ public class PlayerStub implements Player { return false; } - @Override - public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana) { - return null; - } - @Override public boolean putInHand(Card card, Game game) { return false; diff --git a/Mage/src/main/java/mage/players/Player.java b/Mage/src/main/java/mage/players/Player.java index 0e7c6109031..51f75361376 100644 --- a/Mage/src/main/java/mage/players/Player.java +++ b/Mage/src/main/java/mage/players/Player.java @@ -317,8 +317,6 @@ public interface Player extends MageItem, Copyable { boolean cast(SpellAbility ability, Game game, boolean noMana, MageObjectReference reference); - SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana); - SpellAbility chooseAbilityForCast(Card card, Game game, boolean noMana); boolean putInHand(Card card, Game game); diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index 305199185a8..a4a8667dafb 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -1120,13 +1120,7 @@ public abstract class PlayerImpl implements Player, Serializable { SpellAbility ability = originalAbility.copy(); ability.setControllerId(getId()); ability.setSourceObjectZoneChangeCounter(game.getState().getZoneChangeCounter(ability.getSourceId())); - if (ability.getSpellAbilityType() != SpellAbilityType.BASE) { - ability = chooseSpellAbilityForCast(ability, game, noMana); - if (ability == null) { - // No ability could be cast (selected), probably because of no valid targets (happens often if a card can be cast by an effect). - return false; - } - } + //20091005 - 601.2a if (ability.getSourceId() == null) { logger.error("Ability without sourceId turn " + game.getTurnNum() + ". Ability: " + ability.getRule()); @@ -1189,11 +1183,6 @@ public abstract class PlayerImpl implements Player, Serializable { return false; } - @Override - public SpellAbility chooseSpellAbilityForCast(SpellAbility ability, Game game, boolean noMana) { - return ability; - } - @Override public boolean playLand(Card card, Game game, boolean ignoreTiming) { // Check for alternate casting possibilities: e.g. land with Morph