mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
[DMU] Implemented Karn, Living Legacy
This commit is contained in:
parent
02968c9cc1
commit
b9bbb4d1b3
4 changed files with 243 additions and 0 deletions
96
Mage.Sets/src/mage/cards/k/KarnLivingLegacy.java
Normal file
96
Mage.Sets/src/mage/cards/k/KarnLivingLegacy.java
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
package mage.cards.k;
|
||||||
|
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.LoyaltyAbility;
|
||||||
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.effects.common.CreateTokenEffect;
|
||||||
|
import mage.abilities.effects.common.GetEmblemEffect;
|
||||||
|
import mage.cards.*;
|
||||||
|
import mage.constants.*;
|
||||||
|
import mage.filter.StaticFilters;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.command.emblems.KarnLivingLegacyEmblem;
|
||||||
|
import mage.game.permanent.token.PowerstoneToken;
|
||||||
|
import mage.players.Player;
|
||||||
|
import mage.target.TargetCard;
|
||||||
|
import mage.target.common.TargetCardInLibrary;
|
||||||
|
import mage.util.ManaUtil;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author TheElk801
|
||||||
|
*/
|
||||||
|
public final class KarnLivingLegacy extends CardImpl {
|
||||||
|
|
||||||
|
public KarnLivingLegacy(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, "{4}");
|
||||||
|
|
||||||
|
this.addSuperType(SuperType.LEGENDARY);
|
||||||
|
this.subtype.add(SubType.KARN);
|
||||||
|
this.setStartingLoyalty(4);
|
||||||
|
|
||||||
|
// +1: Create a tapped Powerstone token.
|
||||||
|
this.addAbility(new LoyaltyAbility(new CreateTokenEffect(new PowerstoneToken()), 1));
|
||||||
|
|
||||||
|
// -1: Pay any amount of mana. Look at that many cards from the top of your library, then put one of those cards into your hand and rest on the bottom of your library in a random order.
|
||||||
|
this.addAbility(new LoyaltyAbility(new KarnLivingLegacyEffect(), -1));
|
||||||
|
|
||||||
|
// -7: You get an emblem with "Tap an untapped artifact you control: This emblem deals 1 damage to any target."
|
||||||
|
this.addAbility(new LoyaltyAbility(new GetEmblemEffect(new KarnLivingLegacyEmblem()), -7));
|
||||||
|
}
|
||||||
|
|
||||||
|
private KarnLivingLegacy(final KarnLivingLegacy card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KarnLivingLegacy copy() {
|
||||||
|
return new KarnLivingLegacy(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class KarnLivingLegacyEffect extends OneShotEffect {
|
||||||
|
|
||||||
|
KarnLivingLegacyEffect() {
|
||||||
|
super(Outcome.Benefit);
|
||||||
|
staticText = "pay any amount of mana. Look at that many cards from the top of your library, " +
|
||||||
|
"then put one of those cards into your hand and rest on the bottom of your library in a random order";
|
||||||
|
}
|
||||||
|
|
||||||
|
private KarnLivingLegacyEffect(final KarnLivingLegacyEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KarnLivingLegacyEffect copy() {
|
||||||
|
return new KarnLivingLegacyEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
|
if (player == null || player.getLibrary().size() < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int amount = ManaUtil.playerPaysXGenericMana(
|
||||||
|
true, "Karn, Living Legacy", player, source, game
|
||||||
|
);
|
||||||
|
if (amount < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, amount));
|
||||||
|
if (cards.isEmpty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
TargetCard target = new TargetCardInLibrary(StaticFilters.FILTER_CARD);
|
||||||
|
player.choose(outcome, cards, target, game);
|
||||||
|
Card card = cards.get(target.getFirstTarget(), game);
|
||||||
|
if (card != null) {
|
||||||
|
player.moveCards(card, Zone.HAND, source, game);
|
||||||
|
}
|
||||||
|
cards.retainZone(Zone.LIBRARY, game);
|
||||||
|
player.putCardsOnBottomOfLibrary(card, game, source, false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -130,6 +130,7 @@ public final class DominariaUnited extends ExpansionSet {
|
||||||
cards.add(new SetCardInfo("Join Forces", 21, Rarity.UNCOMMON, mage.cards.j.JoinForces.class));
|
cards.add(new SetCardInfo("Join Forces", 21, Rarity.UNCOMMON, mage.cards.j.JoinForces.class));
|
||||||
cards.add(new SetCardInfo("Joint Exploration", 56, Rarity.UNCOMMON, mage.cards.j.JointExploration.class));
|
cards.add(new SetCardInfo("Joint Exploration", 56, Rarity.UNCOMMON, mage.cards.j.JointExploration.class));
|
||||||
cards.add(new SetCardInfo("Juniper Order Rootweaver", 22, Rarity.COMMON, mage.cards.j.JuniperOrderRootweaver.class));
|
cards.add(new SetCardInfo("Juniper Order Rootweaver", 22, Rarity.COMMON, mage.cards.j.JuniperOrderRootweaver.class));
|
||||||
|
cards.add(new SetCardInfo("Karn, Living Legacy", 1, Rarity.MYTHIC, mage.cards.k.KarnLivingLegacy.class));
|
||||||
cards.add(new SetCardInfo("Karplusan Forest", 250, Rarity.RARE, mage.cards.k.KarplusanForest.class));
|
cards.add(new SetCardInfo("Karplusan Forest", 250, Rarity.RARE, mage.cards.k.KarplusanForest.class));
|
||||||
cards.add(new SetCardInfo("Keldon Flamesage", 135, Rarity.RARE, mage.cards.k.KeldonFlamesage.class));
|
cards.add(new SetCardInfo("Keldon Flamesage", 135, Rarity.RARE, mage.cards.k.KeldonFlamesage.class));
|
||||||
cards.add(new SetCardInfo("Keldon Strike Team", 136, Rarity.COMMON, mage.cards.k.KeldonStrikeTeam.class));
|
cards.add(new SetCardInfo("Keldon Strike Team", 136, Rarity.COMMON, mage.cards.k.KeldonStrikeTeam.class));
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package mage.game.command.emblems;
|
||||||
|
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
|
import mage.abilities.costs.common.TapTargetCost;
|
||||||
|
import mage.abilities.effects.common.DamageTargetEffect;
|
||||||
|
import mage.filter.common.FilterControlledArtifactPermanent;
|
||||||
|
import mage.filter.common.FilterControlledPermanent;
|
||||||
|
import mage.filter.predicate.permanent.TappedPredicate;
|
||||||
|
import mage.game.command.Emblem;
|
||||||
|
import mage.target.common.TargetAnyTarget;
|
||||||
|
import mage.target.common.TargetControlledPermanent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author TheElk801
|
||||||
|
*/
|
||||||
|
public final class KarnLivingLegacyEmblem extends Emblem {
|
||||||
|
|
||||||
|
private static final FilterControlledPermanent filter = new FilterControlledArtifactPermanent("an untapped artifact you control");
|
||||||
|
|
||||||
|
static {
|
||||||
|
filter.add(TappedPredicate.UNTAPPED);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -7: You get an emblem with "Tap an untapped artifact you control: This emblem deals 1 damage to any target."
|
||||||
|
public KarnLivingLegacyEmblem() {
|
||||||
|
this.setName("Emblem Karn");
|
||||||
|
this.setExpansionSetCodeForImage("DMU");
|
||||||
|
Ability ability = new SimpleActivatedAbility(
|
||||||
|
new DamageTargetEffect(1, "this emblem"),
|
||||||
|
new TapTargetCost(new TargetControlledPermanent(filter))
|
||||||
|
);
|
||||||
|
ability.addTarget(new TargetAnyTarget());
|
||||||
|
this.getAbilities().add(ability);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,110 @@
|
||||||
|
package mage.game.permanent.token;
|
||||||
|
|
||||||
|
import mage.ConditionalMana;
|
||||||
|
import mage.MageObject;
|
||||||
|
import mage.Mana;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.SpellAbility;
|
||||||
|
import mage.abilities.condition.Condition;
|
||||||
|
import mage.abilities.costs.Cost;
|
||||||
|
import mage.abilities.mana.ConditionalColorlessManaAbility;
|
||||||
|
import mage.abilities.mana.builder.ConditionalManaBuilder;
|
||||||
|
import mage.abilities.mana.conditional.ManaCondition;
|
||||||
|
import mage.cards.Card;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.command.Commander;
|
||||||
|
import mage.game.stack.Spell;
|
||||||
|
import mage.game.stack.StackAbility;
|
||||||
|
import mage.game.stack.StackObject;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author TheElk801
|
||||||
|
*/
|
||||||
|
public final class PowerstoneToken extends TokenImpl {
|
||||||
|
|
||||||
|
public PowerstoneToken() {
|
||||||
|
super("Powerstone Token", "Powerstone token");
|
||||||
|
cardType.add(CardType.ARTIFACT);
|
||||||
|
|
||||||
|
// {T}: Add {C}. This mana can't be spent to cast a nonartifact spell.
|
||||||
|
this.addAbility(new ConditionalColorlessManaAbility(1, new PowerstoneTokenManaBuilder()));
|
||||||
|
|
||||||
|
availableImageSetCodes = Arrays.asList("DMU");
|
||||||
|
}
|
||||||
|
|
||||||
|
public PowerstoneToken(final PowerstoneToken token) {
|
||||||
|
super(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PowerstoneToken copy() {
|
||||||
|
return new PowerstoneToken(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PowerstoneTokenManaBuilder extends ConditionalManaBuilder {
|
||||||
|
|
||||||
|
public PowerstoneTokenManaBuilder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ConditionalMana build(Object... options) {
|
||||||
|
this.mana.setFlag(true); // indicates that the mana is from second ability
|
||||||
|
return new PowerstoneTokenConditionalMana(this.mana);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRule() {
|
||||||
|
return "This mana can't be spent to cast a nonartifact spell.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PowerstoneTokenConditionalMana extends ConditionalMana {
|
||||||
|
|
||||||
|
PowerstoneTokenConditionalMana(Mana mana) {
|
||||||
|
super(mana);
|
||||||
|
staticText = "This mana can't be spent to cast a nonartifact spell.";
|
||||||
|
addCondition(new PowerstoneTokenManaCondition());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PowerstoneTokenManaCondition extends ManaCondition implements Condition {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
if (!(source instanceof SpellAbility)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
MageObject object = game.getObject(source);
|
||||||
|
if (object instanceof StackObject) {
|
||||||
|
return object instanceof StackAbility || !object.isArtifact(game);
|
||||||
|
}
|
||||||
|
if (!game.inCheckPlayableState()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Spell spell;
|
||||||
|
if (object instanceof Card) {
|
||||||
|
spell = new Spell(
|
||||||
|
(Card) object, (SpellAbility) source, source.getControllerId(),
|
||||||
|
game.getState().getZone(source.getSourceId()), game
|
||||||
|
);
|
||||||
|
} else if (object instanceof Commander) {
|
||||||
|
spell = new Spell(
|
||||||
|
((Commander) object).getSourceObject(),
|
||||||
|
(SpellAbility) source, source.getControllerId(),
|
||||||
|
game.getState().getZone(source.getSourceId()), game
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
spell = null;
|
||||||
|
}
|
||||||
|
return spell == null || spell.isArtifact(game);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source, UUID originalId, Cost costToPay) {
|
||||||
|
return apply(game, source);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue