Added Duration "Until your next turn" for continuous effects.

This commit is contained in:
LevelX2 2014-09-06 12:52:36 +02:00
parent d14921c5c2
commit 09242a40e7
5 changed files with 34 additions and 15 deletions

View file

@ -28,20 +28,33 @@
package mage.abilities.effects; package mage.abilities.effects;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.abilities.MageSingleton; import mage.abilities.MageSingleton;
import mage.abilities.TriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DomainValue; import mage.abilities.dynamicvalue.common.DomainValue;
import mage.abilities.dynamicvalue.common.SignInversionDynamicValue; import mage.abilities.dynamicvalue.common.SignInversionDynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.dynamicvalue.common.StaticValue;
import mage.constants.*; import mage.constants.AbilityType;
import mage.constants.Duration;
import mage.constants.EffectType;
import mage.constants.Layer;
import static mage.constants.Layer.AbilityAddingRemovingEffects_6;
import static mage.constants.Layer.ColorChangingEffects_5;
import static mage.constants.Layer.ControlChangingEffects_2;
import static mage.constants.Layer.CopyEffects_1;
import static mage.constants.Layer.PTChangingEffects_7;
import static mage.constants.Layer.TextChangingEffects_3;
import static mage.constants.Layer.TypeChangingEffects_4;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.game.Game; import mage.game.Game;
import java.util.*;
/** /**
* *
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
@ -57,6 +70,9 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
protected boolean affectedObjectsSet = false; protected boolean affectedObjectsSet = false;
protected List<UUID> objects = new ArrayList<>(); protected List<UUID> objects = new ArrayList<>();
protected Map<UUID, Integer> metadata = new HashMap<>(); protected Map<UUID, Integer> metadata = new HashMap<>();
// until your next turn
protected int startingTurn;
protected UUID startingControllerId;
public ContinuousEffectImpl(Duration duration, Outcome outcome) { public ContinuousEffectImpl(Duration duration, Outcome outcome) {
super(outcome); super(outcome);
@ -160,10 +176,15 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
} }
} }
} }
startingTurn = game.getTurnNum();
startingControllerId = source.getControllerId();
} }
@Override @Override
public boolean isInactive(Ability source, Game game) { public boolean isInactive(Ability source, Game game) {
if (duration.equals(Duration.UntilYourNextTurn)) {
return game.getActivePlayerId().equals(startingControllerId) && game.getTurnNum() != startingTurn;
}
return false; return false;
} }

View file

@ -115,6 +115,7 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
} }
break; break;
case Custom: case Custom:
case UntilYourNextTurn:
if (effect.isInactive(ability , game)) { if (effect.isInactive(ability , game)) {
it.remove(); it.remove();
} }

View file

@ -129,11 +129,7 @@ public class SacrificeEffect extends OneShotEffect{
} else { } else {
sb.append(" sacrifice "); sb.append(" sacrifice ");
} }
if (!count.toString().equals("1")) { sb.append(CardUtil.numberToText(count.toString(), "a")).append(" ");
sb.append(CardUtil.numberToText(count.toString())).append(" ");
} else {
sb.append("a ");
}
sb.append(filter.getMessage()); sb.append(filter.getMessage());
staticText = sb.toString(); staticText = sb.toString();
} }

View file

@ -30,14 +30,14 @@ package mage.abilities.effects.common.continious;
import java.util.Iterator; import java.util.Iterator;
import java.util.UUID; import java.util.UUID;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;

View file

@ -11,6 +11,7 @@ public enum Duration {
WhileOnStack(""), WhileOnStack(""),
WhileInGraveyard(""), WhileInGraveyard(""),
EndOfTurn("until end of turn"), EndOfTurn("until end of turn"),
UntilYourNextTurn("until your next turn"),
EndOfCombat("until end of combat"), EndOfCombat("until end of combat"),
Custom(""); Custom("");