mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +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,19 +45,24 @@ 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) {
|
||||||
DamageEvent damageEvent = (DamageEvent) event;
|
return false;
|
||||||
if (damageEvent.isCombatDamage() || !onlyCombat) {
|
|
||||||
if (filter == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
MageObject damageSource = game.getObject(damageEvent.getSourceId());
|
|
||||||
if (damageSource != null && filter.match(damageSource, game)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
DamageEvent damageEvent = (DamageEvent) event;
|
||||||
|
if (!damageEvent.isCombatDamage() && onlyCombat) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (filter == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
MageObject damageSource = game.getObject(damageEvent.getSourceId());
|
||||||
|
if (damageSource == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (filter instanceof FilterInPlay) {
|
||||||
|
return ((FilterInPlay) filter).match(damageSource, source.getSourceId(), source.getControllerId(), game);
|
||||||
|
}
|
||||||
|
return filter.match(damageSource, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue