mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Added hint to Metalwork Colossus' cost reduction.
This commit is contained in:
parent
adfb01149a
commit
5b52c4b02b
1 changed files with 38 additions and 16 deletions
|
@ -6,8 +6,12 @@ import mage.abilities.SpellAbility;
|
|||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
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.cost.CostModificationEffectImpl;
|
||||
import mage.abilities.effects.common.cost.SpellCostReductionSourceEffect;
|
||||
import mage.abilities.hint.ValueHint;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
|
@ -19,7 +23,10 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
import mage.util.CardUtil;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
@ -27,6 +34,7 @@ import java.util.UUID;
|
|||
*/
|
||||
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");
|
||||
|
||||
public MetalworkColossus(UUID ownerId, CardSetInfo setInfo) {
|
||||
|
@ -35,8 +43,13 @@ public final class MetalworkColossus extends CardImpl {
|
|||
this.power = 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.addAbility(new SimpleStaticAbility(Zone.ALL, new MetalworkColossusCostReductionEffect()));
|
||||
// This spell costs {X} less to cast, where X is the total mana value of noncreature artifacts you control.
|
||||
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.
|
||||
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");
|
||||
|
||||
static {
|
||||
filter.add(Predicates.not(CardType.CREATURE.getPredicate()));
|
||||
}
|
||||
|
||||
MetalworkColossusCostReductionEffect() {
|
||||
super(Duration.Custom, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
||||
staticText = "this spell costs {X} less to cast, where X is the total mana value of noncreature artifacts you control";
|
||||
totalNonCreatureArtifactManaValue() {
|
||||
// Nothing to do.
|
||||
}
|
||||
|
||||
MetalworkColossusCostReductionEffect(final MetalworkColossusCostReductionEffect effect) {
|
||||
super(effect);
|
||||
private totalNonCreatureArtifactManaValue(final totalNonCreatureArtifactManaValue dynamicValue) {
|
||||
super();
|
||||
}
|
||||
|
||||
@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;
|
||||
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();
|
||||
}
|
||||
CardUtil.reduceCost(abilityToModify, totalCMC);
|
||||
return true;
|
||||
return totalCMC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
return abilityToModify.getSourceId().equals(source.getSourceId()) && (abilityToModify instanceof SpellAbility);
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetalworkColossusCostReductionEffect copy() {
|
||||
return new MetalworkColossusCostReductionEffect(this);
|
||||
public String toString() {
|
||||
return "X";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue