mirror of
https://github.com/correl/mage.git
synced 2025-04-05 01:09:06 -09:00
Fixed Issue#67: Evernight Shade doesn't loose +1/+1 effects
This commit is contained in:
parent
88f990ec67
commit
3b3d02b3f8
7 changed files with 60 additions and 11 deletions
Mage.Tests/src/test/java/org/mage/test/cards/continuous
Mage/src/mage
abilities/effects
game
|
@ -0,0 +1,32 @@
|
|||
package org.mage.test.cards.continuous;
|
||||
|
||||
import mage.Constants;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* @author magenoxx_at_gmail.com
|
||||
*/
|
||||
public class EvernightShadeTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
* Tests boost disappeared after creature died
|
||||
*/
|
||||
@Test
|
||||
public void testBoostWithUndying() {
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Swamp", 3);
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain", 1);
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Evernight Shade");
|
||||
addCard(Constants.Zone.HAND, playerA, "Lightning Bolt");
|
||||
|
||||
activateAbility(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "{B}");
|
||||
activateAbility(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "{B}");
|
||||
castSpell(1, Constants.PhaseStep.POSTCOMBAT_MAIN, playerA, "Lightning Bolt", "Evernight Shade");
|
||||
|
||||
setStopAt(1, Constants.PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertPowerToughness(playerA, "Evernight Shade", 2, 2);
|
||||
}
|
||||
|
||||
}
|
|
@ -46,6 +46,7 @@ public interface ContinuousEffect<T extends ContinuousEffect<T>> extends Effect<
|
|||
|
||||
public boolean isUsed();
|
||||
public boolean isDiscarded();
|
||||
public void discard();
|
||||
public Duration getDuration();
|
||||
public Date getTimestamp();
|
||||
public void setTimestamp();
|
||||
|
|
|
@ -127,6 +127,11 @@ public abstract class ContinuousEffectImpl<T extends ContinuousEffectImpl<T>> ex
|
|||
return discarded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
this.discarded = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
//20100716 - 611.2c
|
||||
|
|
|
@ -159,7 +159,7 @@ public class ContinuousEffects implements Serializable {
|
|||
case WhileOnStack:
|
||||
case WhileInGraveyard:
|
||||
Ability ability = layeredEffects.getAbility(effect.getId());
|
||||
if (ability.isInUseableZone(game, false))
|
||||
if (ability.isInUseableZone(game, null, false))
|
||||
layerEffects.add(effect);
|
||||
break;
|
||||
default:
|
||||
|
@ -203,7 +203,7 @@ public class ContinuousEffects implements Serializable {
|
|||
List<RequirementEffect> effects = new ArrayList<RequirementEffect>();
|
||||
for (RequirementEffect effect: requirementEffects) {
|
||||
Ability ability = requirementEffects.getAbility(effect.getId());
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, false)) {
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, false)) {
|
||||
if (effect.applies(permanent, ability, game))
|
||||
effects.add(effect);
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ public class ContinuousEffects implements Serializable {
|
|||
List<RestrictionEffect> effects = new ArrayList<RestrictionEffect>();
|
||||
for (RestrictionEffect effect: restrictionEffects) {
|
||||
Ability ability = restrictionEffects.getAbility(effect.getId());
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, false)) {
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, permanent, false)) {
|
||||
if (effect.applies(permanent, ability, game))
|
||||
effects.add(effect);
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ public class ContinuousEffects implements Serializable {
|
|||
//get all applicable transient Replacement effects
|
||||
for (ReplacementEffect effect: replacementEffects) {
|
||||
Ability ability = replacementEffects.getAbility(effect.getId());
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, false)) {
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, false)) {
|
||||
if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
|
||||
if (effect.applies(event, ability, game)) {
|
||||
replaceEffects.add(effect);
|
||||
|
@ -248,7 +248,7 @@ public class ContinuousEffects implements Serializable {
|
|||
}
|
||||
for (PreventionEffect effect: preventionEffects) {
|
||||
Ability ability = preventionEffects.getAbility(effect.getId());
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, false)) {
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, false)) {
|
||||
if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
|
||||
if (effect.applies(event, ability, game)) {
|
||||
replaceEffects.add(effect);
|
||||
|
@ -270,7 +270,7 @@ public class ContinuousEffects implements Serializable {
|
|||
|
||||
for (CostModificationEffect effect: costModificationEffects) {
|
||||
Ability ability = costModificationEffects.getAbility(effect.getId());
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, false)) {
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, false)) {
|
||||
if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
|
||||
costEffects.add(effect);
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ public class ContinuousEffects implements Serializable {
|
|||
|
||||
for (AsThoughEffect effect: asThoughEffects) {
|
||||
Ability ability = asThoughEffects.getAbility(effect.getId());
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, false)) {
|
||||
if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, false)) {
|
||||
if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
|
||||
asThoughEffectsList.add(effect);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ import mage.game.permanent.Permanent;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class BoostSourceEffect extends ContinuousEffectImpl<BoostSourceEffect> {
|
||||
public class BoostSourceEffect extends ContinuousEffectImpl<BoostSourceEffect> implements SourceEffect {
|
||||
private DynamicValue power;
|
||||
private DynamicValue toughness;
|
||||
private boolean lockedIn;
|
||||
|
@ -82,6 +82,7 @@ public class BoostSourceEffect extends ContinuousEffectImpl<BoostSourceEffect> {
|
|||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
getAffectedObjects().add(source.getSourceId());
|
||||
if (lockedIn) {
|
||||
power = new StaticValue(power.calculate(game, source));
|
||||
toughness = new StaticValue(toughness.calculate(game, source));
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package mage.abilities.effects.common.continious;
|
||||
|
||||
/**
|
||||
* Marker interface
|
||||
*
|
||||
* @author magenoxx_at_gmail.com
|
||||
*/
|
||||
public interface SourceEffect {
|
||||
}
|
|
@ -39,6 +39,7 @@ import mage.abilities.effects.ContinuousEffect;
|
|||
import mage.abilities.effects.ContinuousEffects;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.CopyEffect;
|
||||
import mage.abilities.effects.common.continious.SourceEffect;
|
||||
import mage.abilities.keyword.LeylineAbility;
|
||||
import mage.abilities.keyword.TransformAbility;
|
||||
import mage.abilities.mana.TriggeredManaAbility;
|
||||
|
@ -1447,9 +1448,9 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
|||
for (ContinuousEffect effect : getContinuousEffects().getLayeredEffects(this)) {
|
||||
if (effect.getAffectedObjects().contains(sourceId)) {
|
||||
effect.getAffectedObjects().remove(sourceId);
|
||||
}
|
||||
if (effect.getAffectedObjects().contains(sourceId)) {
|
||||
effect.getAffectedObjects().remove(sourceId);
|
||||
if (effect instanceof SourceEffect) {
|
||||
effect.discard();
|
||||
}
|
||||
}
|
||||
}
|
||||
getContinuousEffects().removeGainedEffectsForSource(sourceId);
|
||||
|
|
Loading…
Add table
Reference in a new issue