mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22:00 -08:00
(#4015) fixed enrage triggers triggering multiple times in combat,
didn't fix triggers which use amount of damage dealt (Boros Reckoner)
This commit is contained in:
parent
f4cc8311e8
commit
59b38b76ec
11 changed files with 59 additions and 33 deletions
|
|
@ -58,7 +58,7 @@ public class BorosReckoner extends CardImpl {
|
||||||
this.toughness = new MageInt(3);
|
this.toughness = new MageInt(3);
|
||||||
|
|
||||||
// Whenever Boros Reckoner is dealt damage, it deals that much damage to target creature or player.
|
// Whenever Boros Reckoner is dealt damage, it deals that much damage to target creature or player.
|
||||||
Ability ability = new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new BorosReckonerDealDamageEffect(), false);
|
Ability ability = new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new BorosReckonerDealDamageEffect(), false, false, true);
|
||||||
ability.addTarget(new TargetCreatureOrPlayer());
|
ability.addTarget(new TargetCreatureOrPlayer());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ public class BroodhatchNantuko extends CardImpl {
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(1);
|
||||||
|
|
||||||
// Whenever Broodhatch Nantuko is dealt damage, you may create that many 1/1 green Insect creature tokens.
|
// Whenever Broodhatch Nantuko is dealt damage, you may create that many 1/1 green Insect creature tokens.
|
||||||
this.addAbility(new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new BroodhatchNantukoDealDamageEffect(), true));
|
this.addAbility(new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new BroodhatchNantukoDealDamageEffect(), true, false, true));
|
||||||
// Morph {2}{G}
|
// Morph {2}{G}
|
||||||
this.addAbility(new MorphAbility(this, new ManaCostsImpl("{2}{G}")));
|
this.addAbility(new MorphAbility(this, new ManaCostsImpl("{2}{G}")));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public class CoalhaulerSwine extends CardImpl {
|
||||||
this.toughness = new MageInt(4);
|
this.toughness = new MageInt(4);
|
||||||
|
|
||||||
// Whenever Coalhauler Swine is dealt damage, it deals that much damage to each player.
|
// Whenever Coalhauler Swine is dealt damage, it deals that much damage to each player.
|
||||||
this.addAbility(new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new CoalhaulerSwineEffect(), false));
|
this.addAbility(new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new CoalhaulerSwineEffect(), false, false, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CoalhaulerSwine(final CoalhaulerSwine card) {
|
public CoalhaulerSwine(final CoalhaulerSwine card) {
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ public class FiredrinkerSatyr extends CardImpl {
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(1);
|
||||||
|
|
||||||
// Whenever Firedrinker Satyr is dealt damage, it deals that much damage to you.
|
// Whenever Firedrinker Satyr is dealt damage, it deals that much damage to you.
|
||||||
this.addAbility(new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new FiredrinkerSatyrDealDamageEffect(), false));
|
this.addAbility(new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new FiredrinkerSatyrDealDamageEffect(), false, false, true));
|
||||||
// {1}{R}: Firedrinker Satyr gets +1/+0 until end of turn and deals 1 damage to you.
|
// {1}{R}: Firedrinker Satyr gets +1/+0 until end of turn and deals 1 damage to you.
|
||||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(1, 0, Duration.EndOfTurn), new ManaCostsImpl("{1}{R}"));
|
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(1, 0, Duration.EndOfTurn), new ManaCostsImpl("{1}{R}"));
|
||||||
Effect effect = new DamageControllerEffect(1);
|
Effect effect = new DamageControllerEffect(1);
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ public class HornetNest extends CardImpl {
|
||||||
// Defender
|
// Defender
|
||||||
this.addAbility(DefenderAbility.getInstance());
|
this.addAbility(DefenderAbility.getInstance());
|
||||||
// Whenever Hornet Nest is dealt damage, create that many 1/1 green Insect creature tokens with flying and deathtouch.
|
// Whenever Hornet Nest is dealt damage, create that many 1/1 green Insect creature tokens with flying and deathtouch.
|
||||||
this.addAbility(new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new HornetNestDealDamageEffect(), false));
|
this.addAbility(new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new HornetNestDealDamageEffect(), false, false, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public HornetNest(final HornetNest card) {
|
public HornetNest(final HornetNest card) {
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ public class IllusoryAmbusher extends CardImpl {
|
||||||
this.addAbility(FlashAbility.getInstance());
|
this.addAbility(FlashAbility.getInstance());
|
||||||
|
|
||||||
// Whenever Illusory Ambusher is dealt damage, draw that many cards.
|
// Whenever Illusory Ambusher is dealt damage, draw that many cards.
|
||||||
this.addAbility(new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new IllusoryAmbusherDealtDamageEffect(), false));
|
this.addAbility(new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new IllusoryAmbusherDealtDamageEffect(), false, false, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public IllusoryAmbusher(final IllusoryAmbusher card) {
|
public IllusoryAmbusher(final IllusoryAmbusher card) {
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public class JackalPup extends CardImpl {
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(1);
|
||||||
|
|
||||||
// Whenever Jackal Pup is dealt damage, it deals that much damage to you.
|
// Whenever Jackal Pup is dealt damage, it deals that much damage to you.
|
||||||
this.addAbility(new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new JackalPupEffect(), false));
|
this.addAbility(new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new JackalPupEffect(), false, false, true));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ public class MoggManiac extends CardImpl {
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(1);
|
||||||
|
|
||||||
// Whenever Mogg Maniac is dealt damage, it deals that much damage to target opponent.
|
// Whenever Mogg Maniac is dealt damage, it deals that much damage to target opponent.
|
||||||
Ability ability = new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new MoggManiacDealDamageEffect(), false);
|
Ability ability = new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new MoggManiacDealDamageEffect(), false, false, true);
|
||||||
ability.addTarget(new TargetOpponent());
|
ability.addTarget(new TargetOpponent());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ import mage.players.Player;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author LoneFox
|
* @author LoneFox
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class SaberAnts extends CardImpl {
|
public class SaberAnts extends CardImpl {
|
||||||
|
|
||||||
|
|
@ -57,7 +57,7 @@ public class SaberAnts extends CardImpl {
|
||||||
this.toughness = new MageInt(3);
|
this.toughness = new MageInt(3);
|
||||||
|
|
||||||
// Whenever Saber Ants is dealt damage, you may create that many 1/1 green Insect creature tokens.
|
// Whenever Saber Ants is dealt damage, you may create that many 1/1 green Insect creature tokens.
|
||||||
this.addAbility(new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new SaberAntsEffect(), true));
|
this.addAbility(new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new SaberAntsEffect(), true, false, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public SaberAnts(final SaberAnts card) {
|
public SaberAnts(final SaberAnts card) {
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public class ShinkaGatekeeper extends CardImpl {
|
||||||
this.toughness = new MageInt(2);
|
this.toughness = new MageInt(2);
|
||||||
|
|
||||||
// Whenever Shinka Gatekeeper is dealt damage, it deals that much damage to you.
|
// Whenever Shinka Gatekeeper is dealt damage, it deals that much damage to you.
|
||||||
this.addAbility(new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new ShinkaGatekeeperDealDamageEffect(), false));
|
this.addAbility(new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new ShinkaGatekeeperDealDamageEffect(), false, false, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShinkaGatekeeper(final ShinkaGatekeeper card) {
|
public ShinkaGatekeeper(final ShinkaGatekeeper card) {
|
||||||
|
|
@ -69,7 +69,6 @@ public class ShinkaGatekeeper extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class ShinkaGatekeeperDealDamageEffect extends OneShotEffect {
|
class ShinkaGatekeeperDealDamageEffect extends OneShotEffect {
|
||||||
|
|
||||||
public ShinkaGatekeeperDealDamageEffect() {
|
public ShinkaGatekeeperDealDamageEffect() {
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import mage.constants.Zone;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamagedCreatureEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -39,20 +40,30 @@ import mage.game.events.GameEvent;
|
||||||
*/
|
*/
|
||||||
public class DealtDamageToSourceTriggeredAbility extends TriggeredAbilityImpl {
|
public class DealtDamageToSourceTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
private boolean enrage;
|
private final boolean enrage;
|
||||||
|
private final boolean useValue;
|
||||||
|
private boolean usedForCombatDamageStep;
|
||||||
|
|
||||||
public DealtDamageToSourceTriggeredAbility(Zone zone, Effect effect, boolean optional) {
|
public DealtDamageToSourceTriggeredAbility(Zone zone, Effect effect, boolean optional) {
|
||||||
this(zone, effect, optional, false);
|
this(zone, effect, optional, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DealtDamageToSourceTriggeredAbility(Zone zone, Effect effect, boolean optional, boolean enrage) {
|
public DealtDamageToSourceTriggeredAbility(Zone zone, Effect effect, boolean optional, boolean enrage) {
|
||||||
|
this(zone, effect, optional, enrage, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DealtDamageToSourceTriggeredAbility(Zone zone, Effect effect, boolean optional, boolean enrage, boolean useValue) {
|
||||||
super(zone, effect, optional);
|
super(zone, effect, optional);
|
||||||
this.enrage = enrage;
|
this.enrage = enrage;
|
||||||
|
this.useValue = useValue;
|
||||||
|
this.usedForCombatDamageStep = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DealtDamageToSourceTriggeredAbility(final DealtDamageToSourceTriggeredAbility ability) {
|
public DealtDamageToSourceTriggeredAbility(final DealtDamageToSourceTriggeredAbility ability) {
|
||||||
super(ability);
|
super(ability);
|
||||||
this.enrage = ability.enrage;
|
this.enrage = ability.enrage;
|
||||||
|
this.useValue = ability.useValue;
|
||||||
|
this.usedForCombatDamageStep = ability.usedForCombatDamageStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -62,16 +73,32 @@ public class DealtDamageToSourceTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkEventType(GameEvent event, Game game) {
|
public boolean checkEventType(GameEvent event, Game game) {
|
||||||
return event.getType() == GameEvent.EventType.DAMAGED_CREATURE;
|
return event.getType() == GameEvent.EventType.DAMAGED_CREATURE || event.getType() == GameEvent.EventType.COMBAT_DAMAGE_STEP_POST;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getTargetId().equals(getSourceId())) {
|
if (event.getType() == GameEvent.EventType.DAMAGED_CREATURE && event.getTargetId().equals(getSourceId())) {
|
||||||
|
if (useValue) {
|
||||||
|
// TODO: this ability should only trigger once for multiple creatures dealing combat damage.
|
||||||
|
// If the damaged creature uses the amount (e.g. Boros Reckoner), this will still trigger separately instead of all at once
|
||||||
for (Effect effect : this.getEffects()) {
|
for (Effect effect : this.getEffects()) {
|
||||||
effect.setValue("damage", event.getAmount());
|
effect.setValue("damage", event.getAmount());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
if (((DamagedCreatureEvent) event).isCombatDamage()) {
|
||||||
|
if (!usedForCombatDamageStep) {
|
||||||
|
usedForCombatDamageStep = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (event.getType() == GameEvent.EventType.COMBAT_DAMAGE_STEP_POST) {
|
||||||
|
usedForCombatDamageStep = false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue