[AFR] Implemented Ray of Frost

This commit is contained in:
Daniel Bomar 2021-07-14 09:24:59 -05:00
parent 338f67c915
commit 945c4f5b87
No known key found for this signature in database
GPG key ID: C86C8658F4023918
2 changed files with 117 additions and 0 deletions

View file

@ -0,0 +1,116 @@
package mage.cards.r;
import java.util.UUID;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.common.DontUntapInControllersUntapStepEnchantedEffect;
import mage.abilities.effects.common.TapEnchantedEffect;
import mage.constants.*;
import mage.abilities.keyword.FlashAbility;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import mage.abilities.Ability;
import mage.abilities.effects.common.AttachEffect;
import mage.target.TargetPermanent;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
/**
*
* @author weirddan455
*/
public final class RayOfFrost extends CardImpl {
public RayOfFrost(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}");
this.subtype.add(SubType.AURA);
// Flash
this.addAbility(FlashAbility.getInstance());
// Enchant creature
TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Removal));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
// When Ray of Frost enters the battlefield, if enchanted creature is red, tap it.
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new TapEnchantedEffect()),
RayOfFrostCondition.instance,
"When {this} enters the battlefield, if enchanted creature is red, tap it."
));
// As long as enchanted creature is red, it loses all abilities.
this.addAbility(new SimpleStaticAbility(new RayOfFrostLoseAbilitiesEffect()));
// Enchanted creature doesn't untap during its controller's untap step.
this.addAbility(new SimpleStaticAbility(new DontUntapInControllersUntapStepEnchantedEffect()));
}
private RayOfFrost(final RayOfFrost card) {
super(card);
}
@Override
public RayOfFrost copy() {
return new RayOfFrost(this);
}
}
enum RayOfFrostCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {
Permanent enchantment = source.getSourcePermanentIfItStillExists(game);
if (enchantment == null) {
return false;
}
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
return creature != null && creature.getColor(game).isRed();
}
@Override
public String toString() {
return "if enchanted creature is red";
}
}
class RayOfFrostLoseAbilitiesEffect extends ContinuousEffectImpl {
public RayOfFrostLoseAbilitiesEffect() {
super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.LoseAbility);
this.staticText = "As long as enchanted creature is red, it loses all abilities";
}
private RayOfFrostLoseAbilitiesEffect(final RayOfFrostLoseAbilitiesEffect effect) {
super(effect);
}
@Override
public RayOfFrostLoseAbilitiesEffect copy() {
return new RayOfFrostLoseAbilitiesEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent enchantment = source.getSourcePermanentIfItStillExists(game);
if (enchantment != null) {
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
if (creature != null && creature.getColor(game).isRed()) {
creature.removeAllAbilities(source.getSourceId(), game);
return true;
}
}
return false;
}
}

View file

@ -192,6 +192,7 @@ public final class AdventuresInTheForgottenRealms extends ExpansionSet {
cards.add(new SetCardInfo("Ranger's Hawk", 37, Rarity.COMMON, mage.cards.r.RangersHawk.class));
cards.add(new SetCardInfo("Ranger's Longbow", 203, Rarity.COMMON, mage.cards.r.RangersLongbow.class));
cards.add(new SetCardInfo("Ray of Enfeeblement", 116, Rarity.UNCOMMON, mage.cards.r.RayOfEnfeeblement.class));
cards.add(new SetCardInfo("Ray of Frost", 68, Rarity.UNCOMMON, mage.cards.r.RayOfFrost.class));
cards.add(new SetCardInfo("Reaper's Talisman", 117, Rarity.UNCOMMON, mage.cards.r.ReapersTalisman.class));
cards.add(new SetCardInfo("Red Dragon", 160, Rarity.UNCOMMON, mage.cards.r.RedDragon.class));
cards.add(new SetCardInfo("Rimeshield Frost Giant", 69, Rarity.COMMON, mage.cards.r.RimeshieldFrostGiant.class));