[SNC] Implemented Hold for Ransom

This commit is contained in:
Daniel Bomar 2022-04-14 11:20:39 -05:00
parent 141fd46e55
commit a2f32841f0
No known key found for this signature in database
GPG key ID: C86C8658F4023918
2 changed files with 110 additions and 0 deletions

View file

@ -0,0 +1,109 @@
package mage.cards.h;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.ActivateAsSorceryActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.combat.CantAttackBlockAttachedEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
import mage.abilities.effects.common.AttachEffect;
import mage.target.TargetPermanent;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.target.targetpointer.FixedTarget;
/**
*
* @author weirddan455
*/
public final class HoldForRansom extends CardImpl {
public HoldForRansom(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}");
this.subtype.add(SubType.AURA);
// Enchant creature
TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Removal));
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Enchanted creature can't attack or block and has "{7}: Hold for Ransom's controller sacrifices it and draws a card. Activate only as a sorcery."
Ability ability = new SimpleStaticAbility(new CantAttackBlockAttachedEffect(AttachmentType.AURA));
ability.addEffect(new HoldForRansomGainEffect());
this.addAbility(ability);
}
private HoldForRansom(final HoldForRansom card) {
super(card);
}
@Override
public HoldForRansom copy() {
return new HoldForRansom(this);
}
}
class HoldForRansomGainEffect extends GainAbilityAttachedEffect {
public HoldForRansomGainEffect() {
super(new ActivateAsSorceryActivatedAbility(new HoldForRansomSacrificeEffect(), new GenericManaCost(7)), AttachmentType.AURA);
this.staticText = "and has \"" + ability.getRule() + '"';
}
private HoldForRansomGainEffect(final HoldForRansomGainEffect effect) {
super(effect);
}
@Override
public HoldForRansomGainEffect copy() {
return new HoldForRansomGainEffect(this);
}
@Override
public void afterGain(Game game, Ability source, Permanent permanent, Ability addedAbility) {
Permanent aura = game.getPermanent(source.getSourceId());
addedAbility.getEffects().setTargetPointer(new FixedTarget(aura == null ? null : aura.getId(), game));
}
}
class HoldForRansomSacrificeEffect extends OneShotEffect {
public HoldForRansomSacrificeEffect() {
super(Outcome.Sacrifice);
this.staticText = "Hold for Ransom's controller sacrifices it and draws a card";
}
private HoldForRansomSacrificeEffect(final HoldForRansomSacrificeEffect effect) {
super(effect);
}
@Override
public HoldForRansomSacrificeEffect copy() {
return new HoldForRansomSacrificeEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent aura = game.getPermanent(targetPointer.getFirst(game, source));
if (aura == null) {
return false;
}
Player auraController = game.getPlayer(aura.getControllerId());
aura.sacrifice(source, game);
if (auraController != null) {
auraController.drawCards(1, source, game);
}
return true;
}
}

View file

@ -83,6 +83,7 @@ public final class StreetsOfNewCapenna extends ExpansionSet {
cards.add(new SetCardInfo("Grisly Sigil", 82, Rarity.UNCOMMON, mage.cards.g.GrislySigil.class));
cards.add(new SetCardInfo("Halo Fountain", 15, Rarity.MYTHIC, mage.cards.h.HaloFountain.class));
cards.add(new SetCardInfo("Hoard Hauler", 109, Rarity.RARE, mage.cards.h.HoardHauler.class));
cards.add(new SetCardInfo("Hold for Ransom", 16, Rarity.COMMON, mage.cards.h.HoldForRansom.class));
cards.add(new SetCardInfo("Hostile Takeover", 191, Rarity.RARE, mage.cards.h.HostileTakeover.class));
cards.add(new SetCardInfo("Hypnotic Grifter", 45, Rarity.UNCOMMON, mage.cards.h.HypnoticGrifter.class));
cards.add(new SetCardInfo("Illicit Shipment", 83, Rarity.UNCOMMON, mage.cards.i.IllicitShipment.class));