diff --git a/Mage.Sets/src/mage/sets/avacynrestored/TamiyoTheMoonSage.java b/Mage.Sets/src/mage/sets/avacynrestored/TamiyoTheMoonSage.java index c7e877cb811..00151b80268 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/TamiyoTheMoonSage.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/TamiyoTheMoonSage.java @@ -27,7 +27,12 @@ */ package mage.sets.avacynrestored; -import mage.Constants.*; +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Duration; +import mage.Constants.Outcome; +import mage.Constants.Rarity; +import mage.Constants.Zone; import mage.abilities.Ability; import mage.abilities.LoyaltyAbility; import mage.abilities.TriggeredAbilityImpl; @@ -40,6 +45,7 @@ import mage.abilities.effects.common.GetEmblemEffect; import mage.abilities.effects.common.SkipNextUntapTargetEffect; import mage.abilities.effects.common.TapTargetEffect; import mage.abilities.effects.common.continious.MaximumHandSizeControllerEffect; +import mage.abilities.effects.common.continious.MaximumHandSizeControllerEffect.HandSizeModification; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.cards.Card; import mage.cards.CardImpl; @@ -54,7 +60,6 @@ import mage.target.TargetPermanent; import mage.target.TargetPlayer; import mage.target.targetpointer.FixedTarget; -import java.util.UUID; /** * @@ -190,7 +195,7 @@ class TamiyoTheMoonSageEffect extends OneShotEffect { class TamiyoTheMoonSageEmblem extends Emblem { public TamiyoTheMoonSageEmblem() { - Ability ability = new SimpleStaticAbility(Zone.COMMAND, new MaximumHandSizeControllerEffect(Integer.MAX_VALUE, Duration.EndOfGame, false)); + Ability ability = new SimpleStaticAbility(Zone.COMMAND, new MaximumHandSizeControllerEffect(Integer.MAX_VALUE, Duration.EndOfGame, HandSizeModification.SET)); this.getAbilities().add(ability); this.getAbilities().add(new TamiyoTheMoonSageTriggeredAbility()); } diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/GracefulAdept.java b/Mage.Sets/src/mage/sets/championsofkamigawa/GracefulAdept.java index 1e628cd11e7..62afce4f2d1 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/GracefulAdept.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/GracefulAdept.java @@ -28,14 +28,15 @@ package mage.sets.championsofkamigawa; import java.util.UUID; - -import mage.Constants; import mage.Constants.CardType; +import mage.Constants.Duration; import mage.Constants.Rarity; +import mage.Constants.Zone; import mage.MageInt; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.Effect; import mage.abilities.effects.common.continious.MaximumHandSizeControllerEffect; +import mage.abilities.effects.common.continious.MaximumHandSizeControllerEffect.HandSizeModification; import mage.cards.CardImpl; /** @@ -55,8 +56,8 @@ public class GracefulAdept extends CardImpl { this.toughness = new MageInt(3); // You have no maximum hand size. - Effect effect = new MaximumHandSizeControllerEffect(Integer.MAX_VALUE, Constants.Duration.WhileOnBattlefield, false); - this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, effect)); + Effect effect = new MaximumHandSizeControllerEffect(Integer.MAX_VALUE, Duration.WhileOnBattlefield, HandSizeModification.SET); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); } public GracefulAdept(final GracefulAdept card) { diff --git a/Mage.Sets/src/mage/sets/conflux/ReliquaryTower.java b/Mage.Sets/src/mage/sets/conflux/ReliquaryTower.java index 0f5ad079122..61d698f4977 100644 --- a/Mage.Sets/src/mage/sets/conflux/ReliquaryTower.java +++ b/Mage.Sets/src/mage/sets/conflux/ReliquaryTower.java @@ -28,13 +28,14 @@ package mage.sets.conflux; import java.util.UUID; - -import mage.Constants; import mage.Constants.CardType; +import mage.Constants.Duration; import mage.Constants.Rarity; +import mage.Constants.Zone; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.Effect; import mage.abilities.effects.common.continious.MaximumHandSizeControllerEffect; +import mage.abilities.effects.common.continious.MaximumHandSizeControllerEffect.HandSizeModification; import mage.abilities.mana.ColorlessManaAbility; import mage.cards.CardImpl; @@ -49,8 +50,8 @@ public class ReliquaryTower extends CardImpl { this.expansionSetCode = "CON"; // You have no maximum hand size. - Effect effect = new MaximumHandSizeControllerEffect(Integer.MAX_VALUE, Constants.Duration.WhileOnBattlefield, false); - this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, effect)); + Effect effect = new MaximumHandSizeControllerEffect(Integer.MAX_VALUE, Duration.WhileOnBattlefield, HandSizeModification.SET); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); // {tap}: Add {1} to your mana pool. this.addAbility(new ColorlessManaAbility()); diff --git a/Mage.Sets/src/mage/sets/magic2010/Spellbook.java b/Mage.Sets/src/mage/sets/magic2010/Spellbook.java index ec876ac9263..f847358918a 100644 --- a/Mage.Sets/src/mage/sets/magic2010/Spellbook.java +++ b/Mage.Sets/src/mage/sets/magic2010/Spellbook.java @@ -28,13 +28,13 @@ package mage.sets.magic2010; import java.util.UUID; - import mage.Constants; import mage.Constants.CardType; import mage.Constants.Rarity; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.Effect; import mage.abilities.effects.common.continious.MaximumHandSizeControllerEffect; +import mage.abilities.effects.common.continious.MaximumHandSizeControllerEffect.HandSizeModification; import mage.cards.CardImpl; /** @@ -48,7 +48,7 @@ public class Spellbook extends CardImpl { this.expansionSetCode = "M10"; // You have no maximum hand size. - Effect effect = new MaximumHandSizeControllerEffect(Integer.MAX_VALUE, Constants.Duration.WhileOnBattlefield, false); + Effect effect = new MaximumHandSizeControllerEffect(Integer.MAX_VALUE, Constants.Duration.WhileOnBattlefield, HandSizeModification.SET); this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, effect)); } diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/PraetorsCounsel.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/PraetorsCounsel.java index 50fb6a0eeb6..96627392b26 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/PraetorsCounsel.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/PraetorsCounsel.java @@ -36,6 +36,7 @@ import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.ExileSpellEffect; import mage.abilities.effects.common.continious.MaximumHandSizeControllerEffect; +import mage.abilities.effects.common.continious.MaximumHandSizeControllerEffect.HandSizeModification; import mage.cards.Card; import mage.cards.CardImpl; import mage.game.Game; @@ -53,7 +54,7 @@ public class PraetorsCounsel extends CardImpl { this.color.setGreen(true); this.getSpellAbility().addEffect(new PraetorsCounselEffect()); this.getSpellAbility().addEffect(ExileSpellEffect.getInstance()); - this.getSpellAbility().addEffect(new MaximumHandSizeControllerEffect(Integer.MAX_VALUE, Duration.EndOfGame, false)); + this.getSpellAbility().addEffect(new MaximumHandSizeControllerEffect(Integer.MAX_VALUE, Duration.EndOfGame, HandSizeModification.SET)); } public PraetorsCounsel(final PraetorsCounsel card) { diff --git a/Mage.Sets/src/mage/sets/newphyrexia/JinGitaxiasCoreAugur.java b/Mage.Sets/src/mage/sets/newphyrexia/JinGitaxiasCoreAugur.java index 4fde7634bf1..ad6769134ca 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/JinGitaxiasCoreAugur.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/JinGitaxiasCoreAugur.java @@ -28,20 +28,19 @@ package mage.sets.newphyrexia; import java.util.UUID; - import mage.Constants; import mage.Constants.CardType; +import mage.Constants.Duration; import mage.Constants.Rarity; +import mage.Constants.TargetController; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.BeginningOfYourEndStepTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.common.DrawCardControllerEffect; +import mage.abilities.effects.common.continious.MaximumHandSizeControllerEffect; +import mage.abilities.effects.common.continious.MaximumHandSizeControllerEffect.HandSizeModification; import mage.abilities.keyword.FlashAbility; import mage.cards.CardImpl; -import mage.game.Game; -import mage.players.Player; /** * @@ -59,9 +58,15 @@ public class JinGitaxiasCoreAugur extends CardImpl { this.power = new MageInt(5); this.toughness = new MageInt(4); + // Flash this.addAbility(FlashAbility.getInstance()); + + // At the beginning of your end step, draw seven cards. this.addAbility(new BeginningOfYourEndStepTriggeredAbility(new DrawCardControllerEffect(7), false)); - this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new JinGitaxiasCoreAugurEffect())); + + // Each opponent's maximum hand size is reduced by seven. + this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, + new MaximumHandSizeControllerEffect(7, Duration.WhileOnBattlefield, HandSizeModification.REDUCE, TargetController.OPPONENT))); } public JinGitaxiasCoreAugur(final JinGitaxiasCoreAugur card) { @@ -72,31 +77,4 @@ public class JinGitaxiasCoreAugur extends CardImpl { public JinGitaxiasCoreAugur copy() { return new JinGitaxiasCoreAugur(this); } -} - -class JinGitaxiasCoreAugurEffect extends ContinuousEffectImpl { - JinGitaxiasCoreAugurEffect() { - super(Constants.Duration.WhileOnBattlefield, Constants.Layer.PlayerEffects, Constants.SubLayer.NA, Constants.Outcome.Detriment); - staticText = "Each opponent's maximum hand size is reduced by seven"; - } - - JinGitaxiasCoreAugurEffect(final JinGitaxiasCoreAugurEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - for (UUID opponentId : game.getOpponents(source.getControllerId())) { - Player player = game.getPlayer(opponentId); - if (player != null) { - player.setMaxHandSize(player.getMaxHandSize() - 7); - } - } - return true; - } - - @Override - public JinGitaxiasCoreAugurEffect copy() { - return new JinGitaxiasCoreAugurEffect(this); - } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/VensersJournal.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/VensersJournal.java index cc9b453934c..d06594c9068 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/VensersJournal.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/VensersJournal.java @@ -28,16 +28,18 @@ package mage.sets.scarsofmirrodin; import java.util.UUID; - -import mage.Constants; import mage.Constants.CardType; +import mage.Constants.Duration; import mage.Constants.Rarity; +import mage.Constants.TargetController; +import mage.Constants.Zone; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.dynamicvalue.common.CardsInControllerHandCount; import mage.abilities.effects.Effect; import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.continious.MaximumHandSizeControllerEffect; +import mage.abilities.effects.common.continious.MaximumHandSizeControllerEffect.HandSizeModification; import mage.cards.CardImpl; /** @@ -51,11 +53,11 @@ public class VensersJournal extends CardImpl { this.expansionSetCode = "SOM"; // You have no maximum hand size. - Effect effect = new MaximumHandSizeControllerEffect(Integer.MAX_VALUE, Constants.Duration.WhileOnBattlefield, false); - this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, effect)); + Effect effect = new MaximumHandSizeControllerEffect(Integer.MAX_VALUE, Duration.WhileOnBattlefield, HandSizeModification.SET); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); // At the beginning of your upkeep, you gain 1 life for each card in your hand. - this.addAbility(new BeginningOfUpkeepTriggeredAbility(new GainLifeEffect(new CardsInControllerHandCount()), Constants.TargetController.YOU, false)); + this.addAbility(new BeginningOfUpkeepTriggeredAbility(new GainLifeEffect(new CardsInControllerHandCount()), TargetController.YOU, false)); } public VensersJournal(final VensersJournal card) { diff --git a/Mage.Sets/src/mage/sets/visions/AnvilOfBogardan.java b/Mage.Sets/src/mage/sets/visions/AnvilOfBogardan.java index 3754d1ada0a..6b0048829ff 100644 --- a/Mage.Sets/src/mage/sets/visions/AnvilOfBogardan.java +++ b/Mage.Sets/src/mage/sets/visions/AnvilOfBogardan.java @@ -30,13 +30,17 @@ package mage.sets.visions; import java.util.UUID; import mage.Constants; import mage.Constants.CardType; +import mage.Constants.Duration; import mage.Constants.Rarity; +import mage.Constants.TargetController; +import mage.Constants.Zone; import mage.abilities.Ability; import mage.abilities.common.BeginningOfDrawTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.continious.MaximumHandSizeControllerEffect; +import mage.abilities.effects.common.continious.MaximumHandSizeControllerEffect.HandSizeModification; import mage.cards.CardImpl; import mage.game.Game; import mage.players.Player; @@ -52,11 +56,11 @@ public class AnvilOfBogardan extends CardImpl { this.expansionSetCode = "VIS"; // Players have no maximum hand size. - Effect effect = new MaximumHandSizeControllerEffect(Integer.MAX_VALUE, Constants.Duration.WhileOnBattlefield, false, true); - this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, effect)); + Effect effect = new MaximumHandSizeControllerEffect(Integer.MAX_VALUE, Duration.WhileOnBattlefield, HandSizeModification.SET, TargetController.ANY); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); // At the beginning of each player's draw step, that player draws an additional card, then discards a card. - this.addAbility(new BeginningOfDrawTriggeredAbility(Constants.Zone.BATTLEFIELD, new AnvilOfBogardanEffect(), Constants.TargetController.ANY, false)); + this.addAbility(new BeginningOfDrawTriggeredAbility(Zone.BATTLEFIELD, new AnvilOfBogardanEffect(), TargetController.ANY, false)); } public AnvilOfBogardan(final AnvilOfBogardan card) { diff --git a/Mage/src/mage/abilities/effects/common/continious/MaximumHandSizeControllerEffect.java b/Mage/src/mage/abilities/effects/common/continious/MaximumHandSizeControllerEffect.java index 04a7a7ccdad..11af4f310b8 100644 --- a/Mage/src/mage/abilities/effects/common/continious/MaximumHandSizeControllerEffect.java +++ b/Mage/src/mage/abilities/effects/common/continious/MaximumHandSizeControllerEffect.java @@ -27,99 +27,147 @@ */ package mage.abilities.effects.common.continious; +import java.util.UUID; import mage.Constants.Duration; import mage.Constants.Layer; import mage.Constants.Outcome; import mage.Constants.SubLayer; +import mage.Constants.TargetController; import mage.abilities.Ability; import mage.abilities.effects.ContinuousEffectImpl; import mage.game.Game; import mage.players.Player; /** - * @author nantuko + * @author nantuko, LevelX2 */ public class MaximumHandSizeControllerEffect extends ContinuousEffectImpl { + public static enum HandSizeModification { SET, INCREASE, REDUCE }; + protected int handSize; - protected boolean reduce; - protected boolean allPlayers; + protected HandSizeModification handSizeModification; + protected TargetController targetController; /** * @param handSize Maximum hand size to set or to reduce by * @param duration Effect duration - * @param reduce If true, the hand size will be reduced related to current - * value, otherwise it will be set. + * @param handSizeModification SET, INCREASE, REDUCE + * */ - public MaximumHandSizeControllerEffect(int handSize, Duration duration, boolean reduce) { - super(duration, Layer.PlayerEffects, SubLayer.NA, Outcome.Benefit); - this.handSize = handSize; - this.reduce = reduce; - setText(); + public MaximumHandSizeControllerEffect(int handSize, Duration duration, HandSizeModification handSizeModification) { + this(handSize, duration, handSizeModification, TargetController.YOU); } - public MaximumHandSizeControllerEffect(int handSize, Duration duration, boolean reduce, boolean allPlayers) { - super(duration, Layer.PlayerEffects, SubLayer.NA, Outcome.Benefit); + public MaximumHandSizeControllerEffect(int handSize, Duration duration, HandSizeModification handSizeModification, TargetController targetController) { + super(duration, Layer.PlayerEffects, SubLayer.NA, defineOutcome(handSizeModification, targetController)); this.handSize = handSize; - this.reduce = reduce; - this.allPlayers = allPlayers; + this.handSizeModification = handSizeModification; + this.targetController = targetController; setText(); } public MaximumHandSizeControllerEffect(final MaximumHandSizeControllerEffect effect) { super(effect); this.handSize = effect.handSize; - this.reduce = effect.reduce; - this.allPlayers = effect.allPlayers; + this.handSizeModification = effect.handSizeModification; + this.targetController = effect.targetController; } @Override public MaximumHandSizeControllerEffect copy() { return new MaximumHandSizeControllerEffect(this); } + + protected static Outcome defineOutcome(HandSizeModification handSizeModification, TargetController targetController) { + Outcome newOutcome = Outcome.Benefit; + if ((targetController.equals(TargetController.YOU) || targetController.equals(TargetController.ANY)) + && handSizeModification.equals(HandSizeModification.REDUCE)) { + newOutcome = Outcome.Detriment; + } + return newOutcome; + } @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (allPlayers) { - for (Player playerid : game.getPlayers().values()) { - if (playerid != null) { - if (reduce) { - player.setMaxHandSize(player.getMaxHandSize() - handSize); - } else { - player.setMaxHandSize(handSize); - } + Player controller = game.getPlayer(source.getControllerId()); + switch(targetController) { + case ANY: + for (UUID playerId: controller.getInRange()) { + setHandSize(game, playerId); } - } - return true; - } - if (!allPlayers && player != null) { - if (reduce) { - player.setMaxHandSize(player.getMaxHandSize() - handSize); - } else { - player.setMaxHandSize(handSize); - } - return true; + break; + case OPPONENT: + for (UUID playerId: game.getOpponents(source.getControllerId())) { + setHandSize(game, playerId); + } + break; + case YOU: + setHandSize(game, source.getControllerId()); + break; + default: + throw new UnsupportedOperationException("Not supported yet."); } return true; } - private void setText() { - if (allPlayers && handSize == Integer.MAX_VALUE) { - staticText = "All players have no maximum hand size"; - } - if (!allPlayers && handSize == Integer.MAX_VALUE) { - staticText = "You have no maximum hand size"; - } - if (!allPlayers && staticText == null) { - StringBuilder sb = new StringBuilder("Your maximum hand size is "); - if (reduce) { - sb.append("reduced by "); - sb.append(Integer.toString(handSize)); - } else { - sb.append(Integer.toString(handSize)); + private void setHandSize(Game game, UUID playerId) { + Player player = game.getPlayer(playerId); + if (player != null) { + switch(handSizeModification) { + case SET: + player.setMaxHandSize(handSize); + break; + case INCREASE: + player.setMaxHandSize(player.getMaxHandSize() + handSize); + break; + case REDUCE: + player.setMaxHandSize(player.getMaxHandSize() - handSize); + break; } - staticText = sb.toString(); } } + + private void setText() { + StringBuilder sb = new StringBuilder(); + switch(targetController) { + case ANY: + if (handSize == Integer.MAX_VALUE) { + sb.append("All players have no "); + } else { + sb.append("All players "); + } + break; + case OPPONENT: + if (handSize == Integer.MAX_VALUE) { + sb.append("Each opponent has no "); + } else { + sb.append("Each opponent's "); + } + break; + case YOU: + if (handSize == Integer.MAX_VALUE) { + sb.append("You have no "); + } else { + sb.append("Your "); + } + break; + } + sb.append("maximum hand size"); + if (handSizeModification.equals(HandSizeModification.INCREASE)){ + sb.append(" is increased by "); + } else if (handSizeModification.equals(HandSizeModification.REDUCE)){ + sb.append(" is reduced by "); + } else if (handSize != Integer.MAX_VALUE) { + sb.append(" is "); + } + if (handSize != Integer.MAX_VALUE) { + sb.append(handSize); + } + if (duration == Duration.EndOfGame) { + sb.append(" for the rest of the game"); + } + staticText = sb.toString(); + } + } \ No newline at end of file