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
|
|
@ -51,20 +51,20 @@ import mage.target.common.TargetCreatureOrPlayer;
|
|||
public class BorosReckoner extends CardImpl {
|
||||
|
||||
public BorosReckoner(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{R/W}{R/W}{R/W}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{R/W}{R/W}{R/W}");
|
||||
this.subtype.add(SubType.MINOTAUR, SubType.WIZARD);
|
||||
|
||||
this.power = new MageInt(3);
|
||||
this.toughness = new MageInt(3);
|
||||
|
||||
// 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());
|
||||
this.addAbility(ability);
|
||||
|
||||
// {R/W}: Boros Reckoner gains first strike until end of turn.
|
||||
this.addAbility(new SimpleActivatedAbility(
|
||||
Zone.BATTLEFIELD, new GainAbilitySourceEffect(FirstStrikeAbility.getInstance(),Duration.EndOfTurn), new ManaCostsImpl("{R/W}")));
|
||||
Zone.BATTLEFIELD, new GainAbilitySourceEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn), new ManaCostsImpl("{R/W}")));
|
||||
}
|
||||
|
||||
public BorosReckoner(final BorosReckoner card) {
|
||||
|
|
|
|||
|
|
@ -52,13 +52,13 @@ import mage.players.Player;
|
|||
public class BroodhatchNantuko extends CardImpl {
|
||||
|
||||
public BroodhatchNantuko(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{G}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}");
|
||||
this.subtype.add(SubType.INSECT, SubType.DRUID);
|
||||
this.power = 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.
|
||||
this.addAbility(new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new BroodhatchNantukoDealDamageEffect(), true));
|
||||
this.addAbility(new DealtDamageToSourceTriggeredAbility(Zone.BATTLEFIELD, new BroodhatchNantukoDealDamageEffect(), true, false, true));
|
||||
// Morph {2}{G}
|
||||
this.addAbility(new MorphAbility(this, new ManaCostsImpl("{2}{G}")));
|
||||
}
|
||||
|
|
@ -100,4 +100,4 @@ class BroodhatchNantukoDealDamageEffect extends OneShotEffect {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,14 +49,14 @@ public class CoalhaulerSwine extends CardImpl {
|
|||
|
||||
public CoalhaulerSwine(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{R}{R}");
|
||||
|
||||
|
||||
this.subtype.add(SubType.BOAR);
|
||||
this.subtype.add(SubType.BEAST);
|
||||
this.power = new MageInt(4);
|
||||
this.toughness = new MageInt(4);
|
||||
|
||||
// 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) {
|
||||
|
|
@ -88,7 +88,7 @@ public class CoalhaulerSwine extends CardImpl {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
for (UUID playerId : game.getPlayers().keySet()) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if(player != null) {
|
||||
if (player != null) {
|
||||
player.damage((Integer) this.getValue("damage"), source.getSourceId(), game, false, true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ import mage.players.Player;
|
|||
public class FiredrinkerSatyr extends CardImpl {
|
||||
|
||||
public FiredrinkerSatyr(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{R}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{R}");
|
||||
this.subtype.add(SubType.SATYR);
|
||||
this.subtype.add(SubType.SHAMAN);
|
||||
|
||||
|
|
@ -62,9 +62,9 @@ public class FiredrinkerSatyr extends CardImpl {
|
|||
this.toughness = new MageInt(1);
|
||||
|
||||
// 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.
|
||||
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.setText("and deals 1 damage to you");
|
||||
ability.addEffect(effect);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class HornetNest extends CardImpl {
|
|||
// Defender
|
||||
this.addAbility(DefenderAbility.getInstance());
|
||||
// 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) {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ import mage.players.Player;
|
|||
public class IllusoryAmbusher extends CardImpl {
|
||||
|
||||
public IllusoryAmbusher(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{U}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{U}");
|
||||
this.subtype.add(SubType.CAT);
|
||||
this.subtype.add(SubType.ILLUSION);
|
||||
this.power = new MageInt(4);
|
||||
|
|
@ -57,9 +57,9 @@ public class IllusoryAmbusher extends CardImpl {
|
|||
|
||||
// Flash
|
||||
this.addAbility(FlashAbility.getInstance());
|
||||
|
||||
|
||||
// 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) {
|
||||
|
|
@ -100,4 +100,4 @@ class IllusoryAmbusherDealtDamageEffect extends OneShotEffect {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,14 +49,14 @@ import mage.players.Player;
|
|||
public class JackalPup extends CardImpl {
|
||||
|
||||
public JackalPup(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{R}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{R}");
|
||||
this.subtype.add(SubType.JACKAL);
|
||||
|
||||
this.power = new MageInt(2);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
// 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));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,13 +49,13 @@ import mage.target.common.TargetOpponent;
|
|||
public class MoggManiac extends CardImpl {
|
||||
|
||||
public MoggManiac(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{R}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}");
|
||||
this.subtype.add(SubType.GOBLIN);
|
||||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
// 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());
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,18 +46,18 @@ import mage.players.Player;
|
|||
/**
|
||||
*
|
||||
* @author LoneFox
|
||||
|
||||
*
|
||||
*/
|
||||
public class SaberAnts extends CardImpl {
|
||||
|
||||
public SaberAnts(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{G}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}");
|
||||
this.subtype.add(SubType.INSECT);
|
||||
this.power = new MageInt(2);
|
||||
this.toughness = new MageInt(3);
|
||||
|
||||
// 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) {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ import mage.players.Player;
|
|||
public class ShinkaGatekeeper extends CardImpl {
|
||||
|
||||
public ShinkaGatekeeper(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{R}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}");
|
||||
this.subtype.add(SubType.OGRE);
|
||||
this.subtype.add(SubType.WARRIOR);
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ public class ShinkaGatekeeper extends CardImpl {
|
|||
this.toughness = new MageInt(2);
|
||||
|
||||
// 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) {
|
||||
|
|
@ -69,7 +69,6 @@ public class ShinkaGatekeeper extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class ShinkaGatekeeperDealDamageEffect extends OneShotEffect {
|
||||
|
||||
public ShinkaGatekeeperDealDamageEffect() {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import mage.constants.Zone;
|
|||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.DamagedCreatureEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
|
|
@ -39,20 +40,30 @@ import mage.game.events.GameEvent;
|
|||
*/
|
||||
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) {
|
||||
this(zone, effect, optional, false);
|
||||
}
|
||||
|
||||
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);
|
||||
this.enrage = enrage;
|
||||
this.useValue = useValue;
|
||||
this.usedForCombatDamageStep = false;
|
||||
}
|
||||
|
||||
public DealtDamageToSourceTriggeredAbility(final DealtDamageToSourceTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.enrage = ability.enrage;
|
||||
this.useValue = ability.useValue;
|
||||
this.usedForCombatDamageStep = ability.usedForCombatDamageStep;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -62,16 +73,32 @@ public class DealtDamageToSourceTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
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
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getTargetId().equals(getSourceId())) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setValue("damage", event.getAmount());
|
||||
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()) {
|
||||
effect.setValue("damage", event.getAmount());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
if (((DamagedCreatureEvent) event).isCombatDamage()) {
|
||||
if (!usedForCombatDamageStep) {
|
||||
usedForCombatDamageStep = true;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.COMBAT_DAMAGE_STEP_POST) {
|
||||
usedForCombatDamageStep = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue