mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 03:51:58 -08:00
[DST] Reimplement Turn the Tables using RedirectionEffect (#9196)
This commit is contained in:
parent
6dd898a83c
commit
1e220d9f77
1 changed files with 15 additions and 15 deletions
|
|
@ -3,20 +3,20 @@ package mage.cards.t;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.PreventionEffectData;
|
import mage.abilities.effects.RedirectionEffect;
|
||||||
import mage.abilities.effects.common.PreventDamageToControllerEffect;
|
|
||||||
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.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
import mage.target.common.TargetAttackingCreature;
|
import mage.target.common.TargetAttackingCreature;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
|
* @author sprangg
|
||||||
*/
|
*/
|
||||||
public final class TurnTheTables extends CardImpl {
|
public final class TurnTheTables extends CardImpl {
|
||||||
|
|
||||||
|
|
@ -38,10 +38,10 @@ public final class TurnTheTables extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TurnTheTablesEffect extends PreventDamageToControllerEffect {
|
class TurnTheTablesEffect extends RedirectionEffect {
|
||||||
|
|
||||||
public TurnTheTablesEffect() {
|
public TurnTheTablesEffect() {
|
||||||
super(Duration.EndOfTurn, true, false, Integer.MAX_VALUE);
|
super(Duration.EndOfTurn, Integer.MAX_VALUE, UsageType.ACCORDING_DURATION);
|
||||||
staticText = "All combat damage that would be dealt to you this turn is dealt to target attacking creature instead";
|
staticText = "All combat damage that would be dealt to you this turn is dealt to target attacking creature instead";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,16 +55,16 @@ class TurnTheTablesEffect extends PreventDamageToControllerEffect {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PreventionEffectData preventDamageAction(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
PreventionEffectData preventionEffectData = super.preventDamageAction(event, source, game);
|
if (game.getPlayer(source.getControllerId()) == null || game.getPermanent(source.getFirstTarget()) == null) {
|
||||||
int damage = preventionEffectData.getPreventedDamage();
|
return false;
|
||||||
if (damage > 0) {
|
|
||||||
Permanent attackingCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
|
|
||||||
if (attackingCreature != null) {
|
|
||||||
attackingCreature.damage(damage, source.getSourceId(), source, game, false, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return preventionEffectData;
|
DamageEvent damageEvent = (DamageEvent) event;
|
||||||
|
if (!damageEvent.isCombatDamage() || !source.getControllerId().equals(damageEvent.getTargetId())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.redirectTarget = source.getTargets().get(0);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue