diff --git a/Mage.Sets/src/mage/cards/f/FortifyingDraught.java b/Mage.Sets/src/mage/cards/f/FortifyingDraught.java index 5290d1d9e5..f8083d28ae 100644 --- a/Mage.Sets/src/mage/cards/f/FortifyingDraught.java +++ b/Mage.Sets/src/mage/cards/f/FortifyingDraught.java @@ -23,12 +23,13 @@ public final class FortifyingDraught extends CardImpl { // You gain 2 life. Target creature gets +X/+X until end of turn, where X is the amount of life you gained this turn. this.getSpellAbility().addEffect(new GainLifeEffect(2)); this.getSpellAbility().addEffect(new BoostTargetEffect( - ControllerGotLifeCount.getInstance(), - ControllerGotLifeCount.getInstance(), + ControllerGotLifeCount.instance, + ControllerGotLifeCount.instance, Duration.EndOfTurn, true ).setText("Target creature gets +X/+X until end of turn, where X is the amount of life you gained this turn.")); this.getSpellAbility().addTarget(new TargetCreaturePermanent()); this.getSpellAbility().addWatcher(new PlayerGainedLifeWatcher()); + this.getSpellAbility().addHint(ControllerGotLifeCount.getHint()); } private FortifyingDraught(final FortifyingDraught card) { diff --git a/Mage.Sets/src/mage/cards/g/GoldenRatio.java b/Mage.Sets/src/mage/cards/g/GoldenRatio.java index 60bb92f6c3..6c6ad5f270 100644 --- a/Mage.Sets/src/mage/cards/g/GoldenRatio.java +++ b/Mage.Sets/src/mage/cards/g/GoldenRatio.java @@ -4,6 +4,7 @@ import mage.MageInt; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; +import mage.abilities.hint.Hint; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; @@ -12,8 +13,10 @@ import mage.filter.StaticFilters; import mage.game.Game; import mage.players.Player; +import java.util.List; import java.util.Objects; import java.util.UUID; +import java.util.stream.Collectors; /** * @author TheElk801 @@ -25,6 +28,7 @@ public final class GoldenRatio extends CardImpl { // Draw a card for each different power among creatures you control. this.getSpellAbility().addEffect(new GoldenRatioEffect()); + this.getSpellAbility().addHint(GoldenRatioHint.instance); } private GoldenRatio(final GoldenRatio card) { @@ -75,3 +79,36 @@ class GoldenRatioEffect extends OneShotEffect { return player.drawCards(unique, source, game) > 0; } } + +enum GoldenRatioHint implements Hint { + instance; + + @Override + public String getText(Game game, Ability ability) { + List values = game + .getBattlefield() + .getActivePermanents( + StaticFilters.FILTER_CONTROLLED_CREATURE, + ability.getControllerId(), ability.getSourceId(), game + ) + .stream() + .filter(Objects::nonNull) + .map(MageObject::getPower) + .map(MageInt::getValue) + .distinct() + .sorted() + .collect(Collectors.toList()); + String message = "" + values.size(); + if (values.size() > 0) { + message += " ("; + message += values.stream().map(i -> "" + i).reduce((a, b) -> a + ", " + b).orElse(""); + message += ')'; + } + return "Different powers among creatures you control: " + message; + } + + @Override + public GoldenRatioHint copy() { + return instance; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/l/LiciaSanguineTribune.java b/Mage.Sets/src/mage/cards/l/LiciaSanguineTribune.java index d43b1d6851..09486a71fb 100644 --- a/Mage.Sets/src/mage/cards/l/LiciaSanguineTribune.java +++ b/Mage.Sets/src/mage/cards/l/LiciaSanguineTribune.java @@ -7,8 +7,7 @@ import mage.abilities.common.LimitedTimesPerTurnActivatedAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.condition.common.MyTurnCondition; import mage.abilities.costs.common.PayLifeCost; -import mage.abilities.dynamicvalue.DynamicValue; -import mage.abilities.effects.Effect; +import mage.abilities.dynamicvalue.common.ControllerGotLifeCount; import mage.abilities.effects.common.cost.CostModificationEffectImpl; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.hint.common.MyTurnHint; @@ -40,7 +39,9 @@ public final class LiciaSanguineTribune extends CardImpl { this.toughness = new MageInt(4); // Licia, Sanguine Tribune costs 1 less to cast for each 1 life you gained this turn. - this.addAbility(new SimpleStaticAbility(Zone.ALL, new LiciaSanguineTribuneCostReductionEffect()), new PlayerGainedLifeWatcher()); + this.addAbility(new SimpleStaticAbility( + Zone.ALL, new LiciaSanguineTribuneCostReductionEffect() + ).addHint(ControllerGotLifeCount.getHint()), new PlayerGainedLifeWatcher()); // First strike this.addAbility(FirstStrikeAbility.getInstance()); @@ -49,8 +50,11 @@ public final class LiciaSanguineTribune extends CardImpl { this.addAbility(LifelinkAbility.getInstance()); // Pay 5 life: Put three +1/+1 counters on Licia. Activate this ability only on your turn and only once each turn. - this.addAbility(new LimitedTimesPerTurnActivatedAbility(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.P1P1.createInstance(3)), new PayLifeCost(5), 1, MyTurnCondition.instance) - .addHint(MyTurnHint.instance)); + this.addAbility(new LimitedTimesPerTurnActivatedAbility( + Zone.BATTLEFIELD, + new AddCountersSourceEffect(CounterType.P1P1.createInstance(3)), + new PayLifeCost(5), 1, MyTurnCondition.instance + ).addHint(MyTurnHint.instance)); } private LiciaSanguineTribune(final LiciaSanguineTribune card) { @@ -78,8 +82,7 @@ class LiciaSanguineTribuneCostReductionEffect extends CostModificationEffectImpl public boolean apply(Game game, Ability source, Ability abilityToModify) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - DynamicValue reductionAmount = new YouGainLifeCount(); - CardUtil.reduceCost(abilityToModify, reductionAmount.calculate(game, source, this)); + CardUtil.reduceCost(abilityToModify, ControllerGotLifeCount.instance.calculate(game, source, this)); return true; } return false; @@ -98,34 +101,3 @@ class LiciaSanguineTribuneCostReductionEffect extends CostModificationEffectImpl return new LiciaSanguineTribuneCostReductionEffect(this); } } - -class YouGainLifeCount implements DynamicValue { - - @Override - public int calculate(Game game, Ability sourceAbility, Effect effect) { - return this.calculate(game, sourceAbility.getControllerId()); - } - - public int calculate(Game game, UUID controllerId) { - PlayerGainedLifeWatcher watcher = game.getState().getWatcher(PlayerGainedLifeWatcher.class); - if (watcher != null) { - return watcher.getLifeGained(controllerId); - } - return 0; - } - - @Override - public YouGainLifeCount copy() { - return new YouGainLifeCount(); - } - - @Override - public String toString() { - return "X"; - } - - @Override - public String getMessage() { - return "the total life you gained this turn"; - } -} diff --git a/Mage.Sets/src/mage/cards/v/VoraciousWurm.java b/Mage.Sets/src/mage/cards/v/VoraciousWurm.java index e8c14b1ee2..289a7ef2ed 100644 --- a/Mage.Sets/src/mage/cards/v/VoraciousWurm.java +++ b/Mage.Sets/src/mage/cards/v/VoraciousWurm.java @@ -1,7 +1,5 @@ - package mage.cards.v; -import java.util.UUID; import mage.MageInt; import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.dynamicvalue.common.ControllerGotLifeCount; @@ -13,6 +11,8 @@ import mage.constants.SubType; import mage.counters.CounterType; import mage.watchers.common.PlayerGainedLifeWatcher; +import java.util.UUID; + /** * @author LevelX2 */ @@ -26,9 +26,9 @@ public final class VoraciousWurm extends CardImpl { this.toughness = new MageInt(2); // Voracious Wurm enters the battlefield with X +1/+1 counters on it, where X is the amount of life you've gained this turn. - this.addAbility(new EntersBattlefieldAbility( - new AddCountersSourceEffect(CounterType.P1P1.createInstance(0), ControllerGotLifeCount.getInstance(), true)), - new PlayerGainedLifeWatcher()); + this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect( + CounterType.P1P1.createInstance(0), ControllerGotLifeCount.instance, true + )).addHint(ControllerGotLifeCount.getHint()), new PlayerGainedLifeWatcher()); } private VoraciousWurm(final VoraciousWurm card) { diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/ControllerGotLifeCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ControllerGotLifeCount.java index 2663f6a040..feb2cd4d1e 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/ControllerGotLifeCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ControllerGotLifeCount.java @@ -1,31 +1,24 @@ - package mage.abilities.dynamicvalue.common; -import java.io.ObjectStreamException; -import java.util.UUID; import mage.abilities.Ability; -import mage.abilities.MageSingleton; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.effects.Effect; +import mage.abilities.hint.Hint; +import mage.abilities.hint.ValueHint; import mage.game.Game; import mage.watchers.common.PlayerGainedLifeWatcher; +import java.util.UUID; + /** * Amount of life the controller got this turn. * * @author LevelX2 */ -public class ControllerGotLifeCount implements DynamicValue, MageSingleton { +public enum ControllerGotLifeCount implements DynamicValue { + instance; - private static final ControllerGotLifeCount fINSTANCE = new ControllerGotLifeCount(); - - private Object readResolve() throws ObjectStreamException { - return fINSTANCE; - } - - public static ControllerGotLifeCount getInstance() { - return fINSTANCE; - } + private static final Hint hint = new ValueHint("Life gained this turn:", instance); @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { @@ -42,7 +35,7 @@ public class ControllerGotLifeCount implements DynamicValue, MageSingleton { @Override public ControllerGotLifeCount copy() { - return new ControllerGotLifeCount(); + return instance; } @Override @@ -54,4 +47,8 @@ public class ControllerGotLifeCount implements DynamicValue, MageSingleton { public String getMessage() { return "the amount of life you've gained this turn"; } + + public static Hint getHint() { + return hint; + } }