Removed redundant handling of applied effects of replacements effects.

This commit is contained in:
LevelX2 2013-04-21 22:38:10 +02:00
parent e98d46f95a
commit e313b130fe
6 changed files with 13 additions and 32 deletions

View file

@ -147,14 +147,12 @@ class ShiningShoalPreventDamageTargetEffect extends PreventionEffectImpl<Shining
if (permanent != null) {
game.informPlayers("Dealing " + prevented + " to " + permanent.getName() + " instead");
// keep the original source id as it is redirecting
event.getAppliedEffects().add(getId());
permanent.damage(prevented, event.getSourceId(), game, true, false, event.getAppliedEffects());
}
Player player = game.getPlayer(redirectTo);
if (player != null) {
game.informPlayers("Dealing " + prevented + " to " + player.getName() + " instead");
// keep the original source id as it is redirecting
event.getAppliedEffects().add(getId());
player.damage(prevented, event.getSourceId(), game, true, false, event.getAppliedEffects());
}
}
@ -164,7 +162,7 @@ class ShiningShoalPreventDamageTargetEffect extends PreventionEffectImpl<Shining
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (!this.used && super.applies(event, source, game) && !event.getAppliedEffects().contains(getId())) {
if (!this.used && super.applies(event, source, game)) {
// check source
MageObject object = game.getObject(event.getSourceId());

View file

@ -99,23 +99,17 @@ class DoranTheSiegeTowerEffect extends ReplacementEffectImpl<DoranTheSiegeTowerE
public boolean applies(GameEvent event, Ability source, Game game) {
switch (event.getType()) {
case DAMAGE_PLAYER:
if (((DamagePlayerEvent) event).isCombatDamage() &&
(event.getAppliedEffects() == null || !event.getAppliedEffects().contains(this.getId()))) {
event.getAppliedEffects().add(this.getId());
if (((DamagePlayerEvent) event).isCombatDamage()) {
return true;
}
break;
case DAMAGE_PLANESWALKER:
if (((DamagePlaneswalkerEvent) event).isCombatDamage() &&
(event.getAppliedEffects() == null || !event.getAppliedEffects().contains(this.getId()))) {
event.getAppliedEffects().add(this.getId());
if (((DamagePlaneswalkerEvent) event).isCombatDamage()) {
return true;
}
break;
case DAMAGE_CREATURE:
if (((DamageCreatureEvent) event).isCombatDamage() &&
(event.getAppliedEffects() == null || !event.getAppliedEffects().contains(this.getId()))) {
event.getAppliedEffects().add(this.getId());
if (((DamageCreatureEvent) event).isCombatDamage()) {
return true;
}
break;

View file

@ -97,7 +97,6 @@ class CorpsejackMenaceReplacementEffect extends ReplacementEffectImpl<Corpsejack
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent p = game.getPermanent(event.getTargetId());
if (p != null) {
event.getAppliedEffects().add(getId()); // because replaced events are droped, this keeps track of consumed replacement effects for one origin event
p.addCounters(CounterType.P1P1.createInstance(event.getAmount()*2), game, event.getAppliedEffects());
}
return true;
@ -105,8 +104,7 @@ class CorpsejackMenaceReplacementEffect extends ReplacementEffectImpl<Corpsejack
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.ADD_COUNTER && !event.getAppliedEffects().contains(getId())
&& event.getData().equals(CounterType.P1P1.getName())) {
if (event.getType() == GameEvent.EventType.ADD_COUNTER && event.getData().equals(CounterType.P1P1.getName())) {
Permanent target = game.getPermanent(event.getTargetId());
if (target != null && target.getControllerId().equals(source.getControllerId())
&& target.getCardType().contains(CardType.CREATURE)) {

View file

@ -104,8 +104,7 @@ class PalisadeGiantReplacementEffect extends ReplacementEffectImpl<PalisadeGiant
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.DAMAGE_PLAYER && event.getPlayerId().equals(source.getControllerId())
&& !event.getAppliedEffects().contains(getId()))
if (event.getType() == GameEvent.EventType.DAMAGE_PLAYER && event.getPlayerId().equals(source.getControllerId()))
{
return true;
@ -116,8 +115,7 @@ class PalisadeGiantReplacementEffect extends ReplacementEffectImpl<PalisadeGiant
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (targetPermanent != null &&
targetPermanent.getControllerId().equals(source.getControllerId()) &&
!targetPermanent.getName().equals(sourcePermanent.getName()) && // no redirection from or to other Palisade Giants
!event.getAppliedEffects().contains(getId())) {
!targetPermanent.getName().equals(sourcePermanent.getName())) { // no redirection from or to other Palisade Giants
return true;
}
}
@ -148,8 +146,6 @@ class PalisadeGiantReplacementEffect extends ReplacementEffectImpl<PalisadeGiant
}
game.informPlayers(message.toString());
// remember redirection effect (614.5)
event.getAppliedEffects().add(getId());
// redirect damage
sourcePermanent.damage(damageEvent.getAmount(), damageEvent.getSourceId(), game, damageEvent.isPreventable(), damageEvent.isCombatDamage(), event.getAppliedEffects());
return true;

View file

@ -87,13 +87,11 @@ class FurnaceOfRathEffect extends ReplacementEffectImpl<FurnaceOfRathEffect> {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (!event.getAppliedEffects().contains(this.getId())) {
switch (event.getType()) {
case DAMAGE_PLAYER:
return true;
case DAMAGE_CREATURE:
return true;
}
switch (event.getType()) {
case DAMAGE_PLAYER:
return true;
case DAMAGE_CREATURE:
return true;
}
return false;
}
@ -106,7 +104,6 @@ class FurnaceOfRathEffect extends ReplacementEffectImpl<FurnaceOfRathEffect> {
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
DamageEvent damageEvent = (DamageEvent)event;
damageEvent.getAppliedEffects().add(getId());
if (damageEvent.getType() == EventType.DAMAGE_PLAYER) {
Player targetPlayer = game.getPlayer(event.getTargetId());
if (targetPlayer != null) {

View file

@ -180,9 +180,7 @@ class BuybackEffect extends ReplacementEffectImpl<BuybackEffect> {
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(source.getSourceId())) {
ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
if (zEvent.getFromZone() == Zone.STACK &&
(event.getAppliedEffects() == null || !event.getAppliedEffects().contains(this.getId()))) {
event.getAppliedEffects().add(this.getId());
if (zEvent.getFromZone() == Zone.STACK ) {
return true;
}
}