[LTR] Implement Sauron's Ransom (#10587)

This commit is contained in:
Susucre 2023-07-09 08:14:13 +02:00 committed by GitHub
parent 03f8d72031
commit 24cba3cb68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 115 additions and 0 deletions

View file

@ -0,0 +1,114 @@
package mage.cards.s;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.keyword.TheRingTemptsYouEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.Target;
import mage.target.TargetCard;
import mage.target.common.TargetOpponent;
import java.util.UUID;
/**
*
* @author Susucr
*/
public final class SauronsRansom extends CardImpl {
public SauronsRansom(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}{B}");
// Choose an opponent. They look at the top four cards of your library and separate
// them into a face-down pile and a face-up pile. Put one pile into your hand and
// the other into your graveyard. The Ring tempts you.
getSpellAbility().addEffect(new SauronsRansomEffect());
getSpellAbility().addEffect(new TheRingTemptsYouEffect());
}
private SauronsRansom(final SauronsRansom card) {
super(card);
}
@Override
public SauronsRansom copy() {
return new SauronsRansom(this);
}
}
class SauronsRansomEffect extends OneShotEffect {
public SauronsRansomEffect() {
super(Outcome.Benefit);
this.staticText = "Choose an opponent. They look at the top four cards of your library and separate " +
"them into a face-down pile and a face-up pile. Put one pile into your hand and " +
"the other into your graveyard";
}
public SauronsRansomEffect(final SauronsRansomEffect effect) {
super(effect);
}
@Override
public SauronsRansomEffect copy() {
return new SauronsRansomEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Target targetOpponent = new TargetOpponent(true);
targetOpponent.choose(Outcome.Neutral, source.getControllerId(), source.getSourceId(), source, game);
Player opponent = game.getPlayer(targetOpponent.getFirstTarget());
if (opponent == null) {
return false;
}
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject == null) {
return false;
}
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4));
TargetCard targetFaceDownPile = new TargetCard(
0, Integer.MAX_VALUE, Zone.LIBRARY,
new FilterCard("cards for the face-down pile"));
opponent.choose(outcome, cards, targetFaceDownPile, source, game);
Cards faceDownPile = new CardsImpl(targetFaceDownPile.getTargets());
cards.removeAll(targetFaceDownPile.getTargets());
controller.revealCards(sourceObject.getIdName() + " - cards in face-up pile", cards, game);
game.informPlayers(opponent.getLogName() + " puts " + faceDownPile.size() + " card(s) into the face-down pile");
boolean pileChosen =
controller.chooseUse(
outcome, "Choose a pile to put in your hand.", null,
"Face-down", "Face-up", source, game);
if (pileChosen) { // Face-down was chosen
controller.moveCards(faceDownPile, Zone.HAND, source, game);
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
} else { // Face-up was chosen
controller.moveCards(faceDownPile, Zone.GRAVEYARD, source, game);
controller.moveCards(cards, Zone.HAND, source, game);
}
return true;
}
}

View file

@ -222,6 +222,7 @@ public final class TheLordOfTheRingsTalesOfMiddleEarth extends ExpansionSet {
cards.add(new SetCardInfo("Saruman of Many Colors", 223, Rarity.MYTHIC, mage.cards.s.SarumanOfManyColors.class));
cards.add(new SetCardInfo("Saruman the White", 67, Rarity.UNCOMMON, mage.cards.s.SarumanTheWhite.class));
cards.add(new SetCardInfo("Saruman's Trickery", 68, Rarity.UNCOMMON, mage.cards.s.SarumansTrickery.class));
cards.add(new SetCardInfo("Sauron's Ransom", 225, Rarity.RARE, mage.cards.s.SauronsRansom.class));
cards.add(new SetCardInfo("Sauron, the Dark Lord", 224, Rarity.MYTHIC, mage.cards.s.SauronTheDarkLord.class));
cards.add(new SetCardInfo("Sauron, the Lidless Eye", 288, Rarity.MYTHIC, mage.cards.s.SauronTheLidlessEye.class));
cards.add(new SetCardInfo("Sauron, the Necromancer", 106, Rarity.RARE, mage.cards.s.SauronTheNecromancer.class));