[ONE] Implement Blue Sun's Twilight

This commit is contained in:
Evan Kranzler 2022-12-14 09:43:01 -05:00
parent 50a52d18e3
commit 31797c7c4f
2 changed files with 70 additions and 0 deletions

View file

@ -0,0 +1,69 @@
package mage.cards.b;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.effects.common.CreateTokenCopyTargetEffect;
import mage.abilities.effects.common.continuous.GainControlTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ComparisonType;
import mage.constants.Duration;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.ManaValuePredicate;
import mage.game.Game;
import mage.target.TargetPermanent;
import mage.target.targetadjustment.TargetAdjuster;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class BlueSunsTwilight extends CardImpl {
public BlueSunsTwilight(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{U}{U}");
// Gain control of target creature with mana value X or less. If X is 5 or more, create a token that's a copy of that creature.
this.getSpellAbility().addEffect(new GainControlTargetEffect(Duration.Custom, true));
this.getSpellAbility().addEffect(new ConditionalOneShotEffect(
new CreateTokenCopyTargetEffect(), BlueSunsTwilightCondition.instance,
"If X is 5 or more, create a token that's a copy of that creature"
));
this.getSpellAbility().setTargetAdjuster(BlueSunsTwilightAdjuster.instance);
}
private BlueSunsTwilight(final BlueSunsTwilight card) {
super(card);
}
@Override
public BlueSunsTwilight copy() {
return new BlueSunsTwilight(this);
}
}
enum BlueSunsTwilightCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {
return source.getManaCostsToPay().getX() >= 5;
}
}
enum BlueSunsTwilightAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
int xValue = ability.getManaCostsToPay().getX();
FilterPermanent filter = new FilterCreaturePermanent("creature with mana value " + xValue + " or less");
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, xValue + 1));
ability.getTargets().clear();
ability.addTarget(new TargetPermanent(filter));
}
}

View file

@ -20,6 +20,7 @@ public final class PhyrexiaAllWillBeOne extends ExpansionSet {
this.blockName = "Phyrexia: All Will Be One";
this.hasBoosters = false; // temporary
cards.add(new SetCardInfo("Blue Sun's Twilight", 43, Rarity.RARE, mage.cards.b.BlueSunsTwilight.class));
cards.add(new SetCardInfo("Forest", 276, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Island", 273, Rarity.LAND, mage.cards.basiclands.Island.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Mountain", 275, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS));