forked from External/mage
Distinguish "blocks or becomes blocked" triggered abilities from "blocks or becomes blocked by a creature". Fixes #9347
This commit is contained in:
parent
8e67386628
commit
c8c663b976
56 changed files with 431 additions and 753 deletions
|
|
@ -1,8 +1,7 @@
|
|||
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.BlocksOrBlockedSourceTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
|
|
@ -10,26 +9,27 @@ 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 TriggeredAbilityImpl {
|
||||
/**
|
||||
* @author awjackson
|
||||
*/
|
||||
public class BushidoAbility extends BlocksOrBlockedSourceTriggeredAbility {
|
||||
|
||||
private DynamicValue value;
|
||||
private String rulesText = null;
|
||||
private final DynamicValue value;
|
||||
private final String rule;
|
||||
|
||||
public BushidoAbility(int value) {
|
||||
this(StaticValue.get(value));
|
||||
rulesText = "Bushido " + value + getReminder(Integer.toString(value));
|
||||
}
|
||||
|
||||
public BushidoAbility(DynamicValue value) {
|
||||
super(Zone.BATTLEFIELD, new BoostSourceEffect(value, value, Duration.EndOfTurn, true), false);
|
||||
if (!(value instanceof StaticValue)) {
|
||||
rulesText = "{this} has bushido X, where X is " + value.getMessage() + getReminder(value.toString());
|
||||
}
|
||||
super(new BoostSourceEffect(value, value, Duration.EndOfTurn, true));
|
||||
this.value = value;
|
||||
rule = (
|
||||
value instanceof StaticValue ?
|
||||
"Bushido " + value.toString() :
|
||||
"{this} has bushido X, where X is " + value.getMessage()
|
||||
) + getReminder(value.toString());
|
||||
}
|
||||
|
||||
static String getReminder(String xValue) {
|
||||
|
|
@ -39,28 +39,7 @@ public class BushidoAbility extends TriggeredAbilityImpl {
|
|||
public BushidoAbility(final BushidoAbility ability) {
|
||||
super(ability);
|
||||
this.value = ability.value;
|
||||
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;
|
||||
this.rule = ability.rule;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -74,6 +53,6 @@ public class BushidoAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return rulesText;
|
||||
return rule;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue