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 a110c7c609..5b85ac9c26 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 @@ -2040,7 +2040,7 @@ public class HumanPlayer extends PlayerImpl { return null; } - MageObject object = game.getObject(card.getId()); + MageObject object = game.getObject(card.getId()); // must be object to find real abilities (example: commander) if (object != null) { String message = "Choose ability to cast" + (nonMana ? " for FREE" : "") + "
" + object.getLogName(); LinkedHashMap useableAbilities = getSpellAbilities(playerId, object, game.getState().getZone(object.getId()), game); @@ -2065,6 +2065,8 @@ public class HumanPlayer extends PlayerImpl { } } } + + // default ability (example: on disconnect or cancel) return card.getSpellAbility(); } 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 02e48baf35..eed3dc92f3 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 @@ -4146,7 +4146,8 @@ public class TestPlayer implements Player { public SpellAbility chooseAbilityForCast(Card card, Game game, boolean noMana) { assertAliasSupportInChoices(false); - Map useable = PlayerImpl.getSpellAbilities(this.getId(), card, game.getState().getZone(card.getId()), game); + MageObject object = game.getObject(card.getId()); // must be object to find real abilities (example: commander) + Map useable = PlayerImpl.getSpellAbilities(this.getId(), object, game.getState().getZone(object.getId()), game); String allInfo = useable.values().stream().map(Object::toString).collect(Collectors.joining("\n")); if (useable.size() == 1) { return (SpellAbility) useable.values().iterator().next(); diff --git a/Mage.Tests/src/test/java/org/mage/test/serverside/base/MageTestPlayerBase.java b/Mage.Tests/src/test/java/org/mage/test/serverside/base/MageTestPlayerBase.java index 1ed6be9e9c..c9bdd0da24 100644 --- a/Mage.Tests/src/test/java/org/mage/test/serverside/base/MageTestPlayerBase.java +++ b/Mage.Tests/src/test/java/org/mage/test/serverside/base/MageTestPlayerBase.java @@ -10,6 +10,7 @@ import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.Effect; import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.effects.common.DestroyTargetEffect; import mage.abilities.effects.common.cost.SpellsCostIncreasingAllEffect; import mage.abilities.effects.common.cost.SpellsCostReductionAllEffect; import mage.cards.Card; @@ -32,6 +33,7 @@ import mage.server.util.ConfigWrapper; import mage.server.util.PluginClassLoader; import mage.server.util.config.GamePlugin; import mage.server.util.config.Plugin; +import mage.target.TargetPermanent; import mage.target.common.TargetAnyTarget; import mage.util.CardUtil; import mage.util.Copier; @@ -467,6 +469,21 @@ public abstract class MageTestPlayerBase { ability ); } + + /** + * Add target destroy ability that can be called by text "target destroy" + * + * @param controller + */ + protected void addCustomEffect_DestroyTarget(TestPlayer controller) { + Ability ability = new SimpleActivatedAbility(new DestroyTargetEffect().setText("target destroy"), new ManaCostsImpl("")); + ability.addTarget(new TargetPermanent()); + addCustomCardWithAbility( + "target destroy for " + controller.getName(), + controller, + ability + ); + } } // custom card with global abilities list to init (can contains abilities per card name) diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index f3b7debffc..a400dd71a5 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -1521,7 +1521,14 @@ public abstract class PlayerImpl implements Player, Serializable { public static LinkedHashMap getSpellAbilities(UUID playerId, MageObject object, Zone zone, Game game) { LinkedHashMap useable = new LinkedHashMap<>(); - for (Ability ability : object.getAbilities()) { + Abilities allAbilities; + if (object instanceof Card) { + allAbilities = ((Card) object).getAbilities(game); + } else { + allAbilities = object.getAbilities(); + } + + for (Ability ability : allAbilities) { if (ability instanceof SpellAbility) { switch (((SpellAbility) ability).getSpellAbilityType()) { case BASE_ALTERNATE: