mage/Mage.Sets/src/mage/cards/t/Toymaker.java
Grath 6606ebf0f2 Fix missing dependencies around DependencyType.BecomeCreature.
Also fix Tune Up to use a continuous effect, and a typo or two.
2025-03-19 11:31:39 -04:00

112 lines
3.6 KiB
Java

package mage.cards.t;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.DiscardCardCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.common.FilterArtifactPermanent;
import mage.filter.predicate.Predicates;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
/**
*
* @author TheElk801
*/
public final class Toymaker extends CardImpl {
private static final FilterArtifactPermanent filter = new FilterArtifactPermanent("noncreature artifact");
static {
filter.add(Predicates.not(CardType.CREATURE.getPredicate()));
}
public Toymaker(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{2}");
this.subtype.add(SubType.SPELLSHAPER);
this.power = new MageInt(1);
this.toughness = new MageInt(1);
// {1}, {tap}, Discard a card: Target noncreature artifact becomes an artifact creature with power and toughness each equal to its converted mana cost until end of turn.
Ability ability = new SimpleActivatedAbility(new ToymakerEffect(), new ManaCostsImpl<>("{1}"));
ability.addCost(new TapSourceCost());
ability.addCost(new DiscardCardCost());
ability.addTarget(new TargetPermanent(filter));
this.addAbility(ability);
}
private Toymaker(final Toymaker card) {
super(card);
}
@Override
public Toymaker copy() {
return new Toymaker(this);
}
}
class ToymakerEffect extends ContinuousEffectImpl {
ToymakerEffect() {
super(Duration.EndOfTurn, Outcome.BecomeCreature);
staticText = "Target noncreature artifact becomes an artifact creature with power and toughness each equal to its mana value until end of turn";
this.dependencyTypes.add(DependencyType.BecomeCreature);
}
private ToymakerEffect(final ToymakerEffect effect) {
super(effect);
}
@Override
public ToymakerEffect copy() {
return new ToymakerEffect(this);
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent artifact = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (artifact == null) {
return false;
}
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
if (!artifact.isArtifact(game)) {
artifact.addCardType(game, CardType.ARTIFACT);
}
if (!artifact.isCreature(game)) {
artifact.addCardType(game, CardType.CREATURE);
}
}
break;
case PTChangingEffects_7:
if (sublayer == SubLayer.SetPT_7b) {
int cmc = artifact.getManaValue();
artifact.getPower().setModifiedBaseValue(cmc);
artifact.getToughness().setModifiedBaseValue(cmc);
}
}
return true;
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.PTChangingEffects_7 || layer == Layer.TypeChangingEffects_4;
}
}