mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
fixed Thwart the Enemy preventing all damage
This commit is contained in:
parent
ecf7cf46dd
commit
8b70ae8298
1 changed files with 19 additions and 19 deletions
|
@ -1,8 +1,3 @@
|
||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
package mage.abilities.effects.common;
|
package mage.abilities.effects.common;
|
||||||
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
|
@ -10,13 +5,13 @@ import mage.abilities.Ability;
|
||||||
import mage.abilities.Mode;
|
import mage.abilities.Mode;
|
||||||
import mage.abilities.effects.PreventionEffectImpl;
|
import mage.abilities.effects.PreventionEffectImpl;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
|
import mage.filter.FilterInPlay;
|
||||||
import mage.filter.FilterObject;
|
import mage.filter.FilterObject;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.DamageEvent;
|
import mage.game.events.DamageEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public class PreventAllDamageByAllObjectsEffect extends PreventionEffectImpl {
|
public class PreventAllDamageByAllObjectsEffect extends PreventionEffectImpl {
|
||||||
|
@ -36,7 +31,7 @@ public class PreventAllDamageByAllObjectsEffect extends PreventionEffectImpl {
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PreventAllDamageByAllObjectsEffect(final PreventAllDamageByAllObjectsEffect effect) {
|
private PreventAllDamageByAllObjectsEffect(final PreventAllDamageByAllObjectsEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
if (effect.filter != null) {
|
if (effect.filter != null) {
|
||||||
this.filter = effect.filter.copy();
|
this.filter = effect.filter.copy();
|
||||||
|
@ -50,20 +45,25 @@ public class PreventAllDamageByAllObjectsEffect extends PreventionEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (super.applies(event, source, game) && event instanceof DamageEvent && event.getAmount() > 0) {
|
if (!super.applies(event, source, game) || !(event instanceof DamageEvent) || event.getAmount() <= 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
DamageEvent damageEvent = (DamageEvent) event;
|
DamageEvent damageEvent = (DamageEvent) event;
|
||||||
if (damageEvent.isCombatDamage() || !onlyCombat) {
|
if (!damageEvent.isCombatDamage() && onlyCombat) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (filter == null) {
|
if (filter == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
MageObject damageSource = game.getObject(damageEvent.getSourceId());
|
MageObject damageSource = game.getObject(damageEvent.getSourceId());
|
||||||
if (damageSource != null && filter.match(damageSource, game)) {
|
if (damageSource == null) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (filter instanceof FilterInPlay) {
|
||||||
|
return ((FilterInPlay) filter).match(damageSource, source.getSourceId(), source.getControllerId(), game);
|
||||||
|
}
|
||||||
|
return filter.match(damageSource, game);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getText(Mode mode) {
|
public String getText(Mode mode) {
|
||||||
|
|
Loading…
Reference in a new issue