mirror of
https://github.com/correl/mage.git
synced 2025-01-12 11:08:01 +00:00
new effect discarding mechanism
This commit is contained in:
parent
1a81cf650b
commit
cdb3ccfc38
5 changed files with 16 additions and 3 deletions
|
@ -43,6 +43,7 @@ import java.util.Date;
|
|||
public interface ContinuousEffect<T extends ContinuousEffect<T>> extends Effect<T> {
|
||||
|
||||
public boolean isUsed();
|
||||
public boolean isDiscarded();
|
||||
public Duration getDuration();
|
||||
public Date getTimestamp();
|
||||
public void setTimestamp();
|
||||
|
|
|
@ -52,6 +52,7 @@ public abstract class ContinuousEffectImpl<T extends ContinuousEffectImpl<T>> ex
|
|||
protected SubLayer sublayer;
|
||||
protected Date timestamp;
|
||||
protected boolean used = false;
|
||||
protected boolean discarded = false; // for manual effect discard
|
||||
protected boolean affectedObjectsSet = false;
|
||||
protected List<UUID> objects = new ArrayList<UUID>();
|
||||
protected Map<UUID, Integer> metadata = new HashMap<UUID, Integer>();
|
||||
|
@ -76,6 +77,7 @@ public abstract class ContinuousEffectImpl<T extends ContinuousEffectImpl<T>> ex
|
|||
this.sublayer = effect.sublayer;
|
||||
this.timestamp = new Date(effect.timestamp.getTime());
|
||||
this.used = effect.used;
|
||||
this.discarded = effect.discarded;
|
||||
this.affectedObjectsSet = effect.affectedObjectsSet;
|
||||
this.objects.addAll(effect.objects);
|
||||
}
|
||||
|
@ -120,6 +122,11 @@ public abstract class ContinuousEffectImpl<T extends ContinuousEffectImpl<T>> ex
|
|||
return used;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDiscarded() {
|
||||
return discarded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
//20100716 - 611.2c
|
||||
|
|
|
@ -130,7 +130,6 @@ public class ContinuousEffects implements Serializable {
|
|||
restrictionEffects.removeInactiveEffects(game);
|
||||
asThoughEffects.removeInactiveEffects(game);
|
||||
costModificationEffects.removeInactiveEffects(game);
|
||||
|
||||
}
|
||||
|
||||
public List<ContinuousEffect> getLayeredEffects(Game game) {
|
||||
|
|
|
@ -27,11 +27,12 @@
|
|||
*/
|
||||
package mage.abilities.effects;
|
||||
|
||||
import java.util.*;
|
||||
import mage.Constants;
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -80,9 +81,13 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
|
|||
Ability ability = abilityMap.get(effect.getId());
|
||||
if (ability == null)
|
||||
return true;
|
||||
|
||||
if (effect.isDiscarded())
|
||||
return true;
|
||||
|
||||
switch(effect.getDuration()) {
|
||||
case WhileOnBattlefield:
|
||||
if (game.getObject(ability.getSourceId()) == null)
|
||||
if (game.getObject(ability.getSourceId()) == null) //TODO: does this really works?? object is returned across the game
|
||||
return (true);
|
||||
case OneUse:
|
||||
return effect.isUsed();
|
||||
|
|
|
@ -726,6 +726,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
|||
}
|
||||
catch (Exception ex) {
|
||||
logger.fatal("Game exception ", ex);
|
||||
ex.printStackTrace();
|
||||
this.fireErrorEvent("Game exception occurred: ", ex);
|
||||
//restoreState(bookmark);
|
||||
bookmark = 0;
|
||||
|
|
Loading…
Reference in a new issue