From c4dc83dec9bbb2395b5c9d246d40785631d2c1c2 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Tue, 27 Jul 2021 18:30:24 +0400 Subject: [PATCH] [AFR] fixed Bruenor Battlehammer - correct tests, getPlayable support, additional info in choose pay dialog; --- .../src/mage/cards/b/BruenorBattlehammer.java | 28 +++++++++++++------ .../single/afr/BruenorBattlehammerTest.java | 6 +++- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/Mage.Sets/src/mage/cards/b/BruenorBattlehammer.java b/Mage.Sets/src/mage/cards/b/BruenorBattlehammer.java index c2751114a2..c70f83bd04 100644 --- a/Mage.Sets/src/mage/cards/b/BruenorBattlehammer.java +++ b/Mage.Sets/src/mage/cards/b/BruenorBattlehammer.java @@ -107,15 +107,27 @@ class BruenorBattlehammerCostEffect extends CostModificationEffectImpl { @Override public boolean apply(Game game, Ability source, Ability abilityToModify) { - Player controller = game.getPlayer(abilityToModify.getControllerId()); - if (controller == null || !controller.chooseUse( - Outcome.PlayForFree, "Pay {0} to equip?", source, game - )) { - return false; + boolean applyReduce = false; + if (game.inCheckPlayableState()) { + // getPlayable use - apply all the time + applyReduce = true; + } else { + // real use - ask the player + Player controller = game.getPlayer(abilityToModify.getControllerId()); + if (controller != null + && controller.chooseUse(Outcome.PlayForFree, + String.format("Pay {0} to equip instead %s?", abilityToModify.getManaCostsToPay().getText()), source, game)) { + applyReduce = true; + } } - abilityToModify.getCosts().clear(); - abilityToModify.getManaCostsToPay().clear(); - return true; + + if (applyReduce) { + abilityToModify.getCosts().clear(); + abilityToModify.getManaCostsToPay().clear(); + return true; + } + + return false; } @Override diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/afr/BruenorBattlehammerTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/afr/BruenorBattlehammerTest.java index fab9ac5bef..36b4b0c3c3 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/afr/BruenorBattlehammerTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/afr/BruenorBattlehammerTest.java @@ -24,10 +24,13 @@ public class BruenorBattlehammerTest extends CardTestPlayerBase { addCard(Zone.BATTLEFIELD, playerA, bonesplitter); addCard(Zone.BATTLEFIELD, playerA, morningstar); - setChoice(playerA, true); + // activate {2} for free activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Equip {2}", lion); + setChoice(playerA, true); // use for free + // activate {1} for mana activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Equip {1}", lion); + setStrictChooseMode(true); setStopAt(1, PhaseStep.END_TURN); execute(); assertAllCommandsUsed(); @@ -49,6 +52,7 @@ public class BruenorBattlehammerTest extends CardTestPlayerBase { setChoice(playerA, true); activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Equip", lion); + setStrictChooseMode(true); setStopAt(1, PhaseStep.END_TURN); execute(); assertAllCommandsUsed();