1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-14 01:01:08 -09:00

* Bushido - Fixed that it triggerd wrongly for each blocker instead of only once if blocked.

This commit is contained in:
LevelX2 2018-02-04 21:13:07 +01:00
parent 0044c9df78
commit 88d4e2b965
2 changed files with 54 additions and 9 deletions
Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords
Mage/src/main/java/mage/abilities/keyword

View file

@ -46,4 +46,24 @@ public class BushidoTest extends CardTestPlayerBase {
assertPermanentCount(playerB, "Elite Vanguard", 0); 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);
}
} }

View file

@ -28,40 +28,65 @@
package mage.abilities.keyword; package mage.abilities.keyword;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.BlocksOrBecomesBlockedTriggeredAbility; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BoostSourceEffect; import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Zone;
import mage.game.Game; 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 DynamicValue value;
private String rule = null; private String rulesText = null;
public BushidoAbility(int value) { public BushidoAbility(int value) {
this(new StaticValue(value)); this(new StaticValue(value));
rule = "Bushido " + value + getReminder(Integer.toString(value)); rulesText = "Bushido " + value + getReminder(Integer.toString(value));
} }
public BushidoAbility(DynamicValue 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)) { 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; this.value = value;
} }
static String getReminder(String xValue) { 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) { public BushidoAbility(final BushidoAbility ability) {
super(ability); super(ability);
this.value = ability.value; 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 @Override
@ -75,6 +100,6 @@ public class BushidoAbility extends BlocksOrBecomesBlockedTriggeredAbility {
@Override @Override
public String getRule() { public String getRule() {
return rule; return rulesText;
} }
} }