Added hint to Metalwork Colossus' cost reduction.

This commit is contained in:
Alex Vasile 2022-05-14 19:52:33 -06:00
parent adfb01149a
commit 5b52c4b02b

View file

@ -6,8 +6,12 @@ import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.SacrificeTargetCost; import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ReturnSourceFromGraveyardToHandEffect; import mage.abilities.effects.common.ReturnSourceFromGraveyardToHandEffect;
import mage.abilities.effects.common.cost.CostModificationEffectImpl; import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.effects.common.cost.SpellCostReductionSourceEffect;
import mage.abilities.hint.ValueHint;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
@ -19,7 +23,10 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.target.common.TargetControlledPermanent; import mage.target.common.TargetControlledPermanent;
import mage.util.CardUtil; import mage.util.CardUtil;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.List;
import java.util.Objects;
import java.util.UUID; import java.util.UUID;
/** /**
@ -27,6 +34,7 @@ import java.util.UUID;
*/ */
public final class MetalworkColossus extends CardImpl { public final class MetalworkColossus extends CardImpl {
private static final String message = "Total mana value of noncreature artifacts you control";
private static final FilterControlledPermanent filter = new FilterControlledArtifactPermanent("artifacts"); private static final FilterControlledPermanent filter = new FilterControlledArtifactPermanent("artifacts");
public MetalworkColossus(UUID ownerId, CardSetInfo setInfo) { public MetalworkColossus(UUID ownerId, CardSetInfo setInfo) {
@ -35,8 +43,13 @@ public final class MetalworkColossus extends CardImpl {
this.power = new MageInt(10); this.power = new MageInt(10);
this.toughness = new MageInt(10); this.toughness = new MageInt(10);
// Metalwork Colossus costs {X} less to cast, where X is the total converted mana cost of noncreature artifacts you control. // This spell costs {X} less to cast, where X is the total mana value of noncreature artifacts you control.
this.addAbility(new SimpleStaticAbility(Zone.ALL, new MetalworkColossusCostReductionEffect())); DynamicValue xValue = new totalNonCreatureArtifactManaValue();
this.addAbility(new SimpleStaticAbility(
Zone.ALL,
new SpellCostReductionSourceEffect(xValue)
).addHint(new ValueHint(message, xValue))
);
// Sacrifice two artifacts: Return Metalwork Colossus from your graveyard to your hand. // Sacrifice two artifacts: Return Metalwork Colossus from your graveyard to your hand.
this.addAbility(new SimpleActivatedAbility(Zone.GRAVEYARD, new ReturnSourceFromGraveyardToHandEffect(), new SacrificeTargetCost(new TargetControlledPermanent(2, filter)))); this.addAbility(new SimpleActivatedAbility(Zone.GRAVEYARD, new ReturnSourceFromGraveyardToHandEffect(), new SacrificeTargetCost(new TargetControlledPermanent(2, filter))));
@ -52,40 +65,49 @@ public final class MetalworkColossus extends CardImpl {
} }
} }
class MetalworkColossusCostReductionEffect extends CostModificationEffectImpl { class totalNonCreatureArtifactManaValue implements DynamicValue {
private static final String message = "total mana value of noncreature artifacts you control";
private static final FilterPermanent filter = new FilterControlledArtifactPermanent("noncreature artifacts you control"); private static final FilterPermanent filter = new FilterControlledArtifactPermanent("noncreature artifacts you control");
static { static {
filter.add(Predicates.not(CardType.CREATURE.getPredicate())); filter.add(Predicates.not(CardType.CREATURE.getPredicate()));
} }
MetalworkColossusCostReductionEffect() { totalNonCreatureArtifactManaValue() {
super(Duration.Custom, Outcome.Benefit, CostModificationType.REDUCE_COST); // Nothing to do.
staticText = "this spell costs {X} less to cast, where X is the total mana value of noncreature artifacts you control";
} }
MetalworkColossusCostReductionEffect(final MetalworkColossusCostReductionEffect effect) { private totalNonCreatureArtifactManaValue(final totalNonCreatureArtifactManaValue dynamicValue) {
super(effect); super();
} }
@Override @Override
public boolean apply(Game game, Ability source, Ability abilityToModify) { public DynamicValue copy() {
return new totalNonCreatureArtifactManaValue(this);
}
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
int totalCMC = 0; int totalCMC = 0;
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { List<Permanent> permanents = game.getBattlefield().getActivePermanents(
filter,
sourceAbility.getControllerId(),
sourceAbility,
game);
for (Permanent permanent : permanents) {
totalCMC += permanent.getManaValue(); totalCMC += permanent.getManaValue();
} }
CardUtil.reduceCost(abilityToModify, totalCMC); return totalCMC;
return true;
} }
@Override @Override
public boolean applies(Ability abilityToModify, Ability source, Game game) { public String getMessage() {
return abilityToModify.getSourceId().equals(source.getSourceId()) && (abilityToModify instanceof SpellAbility); return message;
} }
@Override @Override
public MetalworkColossusCostReductionEffect copy() { public String toString() {
return new MetalworkColossusCostReductionEffect(this); return "X";
} }
} }