From 09242a40e7063cf8c1c66cc326c2883b056b699a Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 6 Sep 2014 12:52:36 +0200 Subject: [PATCH] Added Duration "Until your next turn" for continuous effects. --- .../effects/ContinuousEffectImpl.java | 33 +++++++++++++++---- .../effects/ContinuousEffectsList.java | 1 + .../effects/common/SacrificeEffect.java | 6 +--- .../continious/BoostControlledEffect.java | 8 ++--- Mage/src/mage/constants/Duration.java | 1 + 5 files changed, 34 insertions(+), 15 deletions(-) diff --git a/Mage/src/mage/abilities/effects/ContinuousEffectImpl.java b/Mage/src/mage/abilities/effects/ContinuousEffectImpl.java index 813440a189..d147059ab0 100644 --- a/Mage/src/mage/abilities/effects/ContinuousEffectImpl.java +++ b/Mage/src/mage/abilities/effects/ContinuousEffectImpl.java @@ -28,20 +28,33 @@ 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.ActivatedAbility; import mage.abilities.MageSingleton; -import mage.abilities.TriggeredAbility; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.DomainValue; import mage.abilities.dynamicvalue.common.SignInversionDynamicValue; 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 java.util.*; - - /** * * @author BetaSteward_at_googlemail.com @@ -57,6 +70,9 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu protected boolean affectedObjectsSet = false; protected List objects = new ArrayList<>(); protected Map metadata = new HashMap<>(); + // until your next turn + protected int startingTurn; + protected UUID startingControllerId; public ContinuousEffectImpl(Duration duration, Outcome outcome) { super(outcome); @@ -160,10 +176,15 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu } } } + startingTurn = game.getTurnNum(); + startingControllerId = source.getControllerId(); } @Override public boolean isInactive(Ability source, Game game) { + if (duration.equals(Duration.UntilYourNextTurn)) { + return game.getActivePlayerId().equals(startingControllerId) && game.getTurnNum() != startingTurn; + } return false; } diff --git a/Mage/src/mage/abilities/effects/ContinuousEffectsList.java b/Mage/src/mage/abilities/effects/ContinuousEffectsList.java index 435b350c46..16314a524f 100644 --- a/Mage/src/mage/abilities/effects/ContinuousEffectsList.java +++ b/Mage/src/mage/abilities/effects/ContinuousEffectsList.java @@ -115,6 +115,7 @@ public class ContinuousEffectsList extends ArrayList } break; case Custom: + case UntilYourNextTurn: if (effect.isInactive(ability , game)) { it.remove(); } diff --git a/Mage/src/mage/abilities/effects/common/SacrificeEffect.java b/Mage/src/mage/abilities/effects/common/SacrificeEffect.java index 080c514851..3bec07b496 100644 --- a/Mage/src/mage/abilities/effects/common/SacrificeEffect.java +++ b/Mage/src/mage/abilities/effects/common/SacrificeEffect.java @@ -129,11 +129,7 @@ public class SacrificeEffect extends OneShotEffect{ } else { sb.append(" sacrifice "); } - if (!count.toString().equals("1")) { - sb.append(CardUtil.numberToText(count.toString())).append(" "); - } else { - sb.append("a "); - } + sb.append(CardUtil.numberToText(count.toString(), "a")).append(" "); sb.append(filter.getMessage()); staticText = sb.toString(); } diff --git a/Mage/src/mage/abilities/effects/common/continious/BoostControlledEffect.java b/Mage/src/mage/abilities/effects/common/continious/BoostControlledEffect.java index 8ecaaa7654..c88b235055 100644 --- a/Mage/src/mage/abilities/effects/common/continious/BoostControlledEffect.java +++ b/Mage/src/mage/abilities/effects/common/continious/BoostControlledEffect.java @@ -30,14 +30,14 @@ package mage.abilities.effects.common.continious; import java.util.Iterator; 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.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.StaticValue; 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.game.Game; import mage.game.permanent.Permanent; diff --git a/Mage/src/mage/constants/Duration.java b/Mage/src/mage/constants/Duration.java index 4a94d4482f..3fc54202ee 100644 --- a/Mage/src/mage/constants/Duration.java +++ b/Mage/src/mage/constants/Duration.java @@ -11,6 +11,7 @@ public enum Duration { WhileOnStack(""), WhileInGraveyard(""), EndOfTurn("until end of turn"), + UntilYourNextTurn("until your next turn"), EndOfCombat("until end of combat"), Custom("");