mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
Fix Shockmaw Dragon's damage trigger (#8155)
* Fix Shockmaw Dragon's damage trigger The previous implementation was very wrong. This implementation is copied from Balefire Dragon's, except dealing one damage rather than the same amount as the damage dealt to the player. * Update ShockmawDragon.java Fix imports.
This commit is contained in:
parent
c1d6309db9
commit
40cf802d6b
1 changed files with 25 additions and 37 deletions
|
@ -2,21 +2,19 @@ package mage.cards.s;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.common.DamageTargetEffect;
|
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
|
||||||
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.keyword.FlyingAbility;
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Outcome;
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
import mage.constants.Zone;
|
import mage.filter.StaticFilters;
|
||||||
import mage.filter.FilterPermanent;
|
|
||||||
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.DamagedPlayerEvent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.TargetPermanent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -34,7 +32,7 @@ public final class ShockmawDragon extends CardImpl {
|
||||||
this.addAbility(FlyingAbility.getInstance());
|
this.addAbility(FlyingAbility.getInstance());
|
||||||
|
|
||||||
// Whenever Shockmaw Dragon deals combat damage to a player, it deals 1 damage to each creature that player controls.
|
// Whenever Shockmaw Dragon deals combat damage to a player, it deals 1 damage to each creature that player controls.
|
||||||
this.addAbility(new PolisCrusherTriggeredAbility());
|
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new ShockmawDragonEffect(), false, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ShockmawDragon(final ShockmawDragon card) {
|
private ShockmawDragon(final ShockmawDragon card) {
|
||||||
|
@ -47,45 +45,35 @@ public final class ShockmawDragon extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PolisCrusherTriggeredAbility extends TriggeredAbilityImpl {
|
class ShockmawDragonEffect extends OneShotEffect {
|
||||||
|
|
||||||
public PolisCrusherTriggeredAbility() {
|
public ShockmawDragonEffect() {
|
||||||
super(Zone.BATTLEFIELD, new DamageTargetEffect(1), true);
|
super(Outcome.Damage);
|
||||||
|
staticText = "it deals 1 damage to each creature that player controls";
|
||||||
}
|
}
|
||||||
|
|
||||||
public PolisCrusherTriggeredAbility(final PolisCrusherTriggeredAbility ability) {
|
public ShockmawDragonEffect(final ShockmawDragonEffect effect) {
|
||||||
super(ability);
|
super(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PolisCrusherTriggeredAbility copy() {
|
public boolean apply(Game game, Ability source) {
|
||||||
return new PolisCrusherTriggeredAbility(this);
|
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||||
}
|
if (player != null) {
|
||||||
|
int amount = (Integer) getValue("damage");
|
||||||
@Override
|
if (amount > 0) {
|
||||||
public boolean checkEventType(GameEvent event, Game game) {
|
for (Permanent creature : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), game)) {
|
||||||
return event.getType() == GameEvent.EventType.DAMAGED_PLAYER;
|
creature.damage(1, source.getSourceId(), source, game, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
|
||||||
if (event.getSourceId().equals(this.sourceId) && ((DamagedPlayerEvent) event).isCombatDamage()) {
|
|
||||||
Player player = game.getPlayer(event.getTargetId());
|
|
||||||
if (player != null) {
|
|
||||||
FilterPermanent filter = new FilterPermanent("a creature controlled by " + player.getLogName());
|
|
||||||
filter.add(CardType.CREATURE.getPredicate());
|
|
||||||
filter.add(new ControllerIdPredicate(event.getTargetId()));
|
|
||||||
this.getTargets().clear();
|
|
||||||
this.addTarget(new TargetPermanent(filter));
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
public ShockmawDragonEffect copy() {
|
||||||
return "Whenever {this} deals combat damage to a player,"
|
return new ShockmawDragonEffect(this);
|
||||||
+ " it deals 1 damage to each creature that player controls";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue