mirror of
https://github.com/magefree/mage.git
synced 2026-01-25 12:49:39 -08:00
* Arashin War Beast - Fixed triggerd ability.
This commit is contained in:
parent
bcb1331c0f
commit
a588b601b6
2 changed files with 105 additions and 20 deletions
|
|
@ -29,11 +29,20 @@ package mage.sets.fatereforged;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.keyword.ManifestEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.permanent.BlockingPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.DamagedCreatureEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -49,7 +58,7 @@ public class ArashinWarBeast extends CardImpl {
|
|||
this.toughness = new MageInt(6);
|
||||
|
||||
// Whenever Arashin War Beast deals combat damage to one or more blockers, manifest the top card of your library.
|
||||
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new ManifestEffect(1), true));
|
||||
this.addAbility(new ArashinWarBeastTriggeredAbility(new ManifestEffect(1), true));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -62,3 +71,55 @@ public class ArashinWarBeast extends CardImpl {
|
|||
return new ArashinWarBeast(this);
|
||||
}
|
||||
}
|
||||
|
||||
class ArashinWarBeastTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("one or more blockers");
|
||||
|
||||
static {
|
||||
filter.add(new BlockingPredicate());
|
||||
}
|
||||
|
||||
boolean usedForCombatDamageStep;
|
||||
|
||||
public ArashinWarBeastTriggeredAbility(Effect effect, boolean optional) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
this.usedForCombatDamageStep = false;
|
||||
}
|
||||
|
||||
public ArashinWarBeastTriggeredAbility(final ArashinWarBeastTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.usedForCombatDamageStep = ability.usedForCombatDamageStep;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArashinWarBeastTriggeredAbility copy() {
|
||||
return new ArashinWarBeastTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.DAMAGED_CREATURE &&
|
||||
event.getSourceId().equals(this.sourceId) &&
|
||||
((DamagedCreatureEvent) event).isCombatDamage() &&
|
||||
!usedForCombatDamageStep) {
|
||||
Permanent creature = game.getPermanentOrLKIBattlefield(event.getTargetId());
|
||||
if (creature == null || !filter.match(creature, getSourceId(), getControllerId(), game)) {
|
||||
return false;
|
||||
}
|
||||
// trigger only once per combat damage step
|
||||
usedForCombatDamageStep = true;
|
||||
return true;
|
||||
|
||||
}
|
||||
if (event.getType() == EventType.COMBAT_DAMAGE_STEP_POST) {
|
||||
usedForCombatDamageStep = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever {this} deals combat damage to one or more blockers, " + super.getRule();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue