diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BushidoTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BushidoTest.java index f02153a56b..c50854e0f9 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BushidoTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/BushidoTest.java @@ -46,4 +46,24 @@ public class BushidoTest extends CardTestPlayerBase { assertPermanentCount(playerB, "Elite Vanguard", 0); } + /** + * Tests boosting on double block, it may only trigger once + */ + @Test + public void testMultipleBlocker() { + addCard(Zone.BATTLEFIELD, playerA, "Llanowar Elves", 1); + addCard(Zone.BATTLEFIELD, playerA, "Quirion Elves", 1); + + addCard(Zone.BATTLEFIELD, playerB, "Isao, Enlightened Bushi"); // 2/1 Bushido 2 + attack(2, playerB, "Isao, Enlightened Bushi"); + block(2, playerA, "Llanowar Elves", "Isao, Enlightened Bushi"); + block(2, playerA, "Quirion Elves", "Isao, Enlightened Bushi"); + + setStopAt(2, PhaseStep.END_COMBAT); + execute(); + + assertPowerToughness(playerB, "Isao, Enlightened Bushi", 4, 3); + assertPermanentCount(playerA, "Llanowar Elves", 0); + assertPermanentCount(playerA, "Quirion Elves", 0); + } } diff --git a/Mage/src/main/java/mage/abilities/keyword/BushidoAbility.java b/Mage/src/main/java/mage/abilities/keyword/BushidoAbility.java index 21592a8e91..365dc7f36b 100644 --- a/Mage/src/main/java/mage/abilities/keyword/BushidoAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/BushidoAbility.java @@ -28,40 +28,65 @@ package mage.abilities.keyword; import mage.abilities.Ability; -import mage.abilities.common.BlocksOrBecomesBlockedTriggeredAbility; +import mage.abilities.TriggeredAbilityImpl; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.effects.Effect; import mage.abilities.effects.common.continuous.BoostSourceEffect; import mage.constants.Duration; +import mage.constants.Zone; import mage.game.Game; +import mage.game.combat.CombatGroup; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; -public class BushidoAbility extends BlocksOrBecomesBlockedTriggeredAbility { +public class BushidoAbility extends TriggeredAbilityImpl { private DynamicValue value; - private String rule = null; + private String rulesText = null; public BushidoAbility(int value) { this(new StaticValue(value)); - rule = "Bushido " + value + getReminder(Integer.toString(value)); + rulesText = "Bushido " + value + getReminder(Integer.toString(value)); } public BushidoAbility(DynamicValue value) { - super(new BoostSourceEffect(value, value, Duration.EndOfTurn, true), false); + super(Zone.BATTLEFIELD, new BoostSourceEffect(value, value, Duration.EndOfTurn, true), false); if (!(value instanceof StaticValue)) { - rule = "{this} has bushido X, where X is " + value.getMessage() + getReminder(value.toString()); + rulesText = "{this} has bushido X, where X is " + value.getMessage() + getReminder(value.toString()); } this.value = value; } static String getReminder(String xValue) { - return " <i>(Whenever this creature blocks or becomes blocked, it gets +" + xValue+ "/+" + xValue + " until end of turn.)</i>"; + return " <i>(Whenever this creature blocks or becomes blocked, it gets +" + xValue + "/+" + xValue + " until end of turn.)</i>"; } public BushidoAbility(final BushidoAbility ability) { super(ability); this.value = ability.value; - this.rule = ability.rule; + this.rulesText = ability.rulesText; + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.DECLARE_BLOCKERS_STEP; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + Permanent source = game.getPermanent(getSourceId()); + if (source != null) { + if (source.isBlocked(game)) { + return true; + } + for (CombatGroup group : game.getCombat().getGroups()) { + if (group.getBlockers().contains(getSourceId())) { + return true; + } + } + } + return false; } @Override @@ -75,6 +100,6 @@ public class BushidoAbility extends BlocksOrBecomesBlockedTriggeredAbility { @Override public String getRule() { - return rule; + return rulesText; } }