Fixed Duplicity casting costs.

This commit is contained in:
LevelX2 2018-11-26 19:00:59 +01:00
parent 09b64b2025
commit 2323654a22
2 changed files with 202 additions and 203 deletions

View file

@ -1,200 +1,200 @@
package mage.cards.d; package mage.cards.d;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility; import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.BeginningOfYourEndStepTriggeredAbility; import mage.abilities.common.BeginningOfYourEndStepTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.discard.DiscardControllerEffect; import mage.abilities.effects.common.discard.DiscardControllerEffect;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.players.Player; import mage.players.Player;
import mage.util.CardUtil; import mage.util.CardUtil;
/** /**
* *
* @author jeffwadsworth * @author jeffwadsworth
*/ */
public final class Duplicity extends CardImpl { public final class Duplicity extends CardImpl {
public Duplicity(UUID ownerId, CardSetInfo setInfo) { public Duplicity(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}{U}");
// When Duplicity enters the battlefield, exile the top five cards of your library face down. // When Duplicity enters the battlefield, exile the top five cards of your library face down.
this.addAbility(new EntersBattlefieldTriggeredAbility(new DuplicityEffect(), false)); this.addAbility(new EntersBattlefieldTriggeredAbility(new DuplicityEffect(), false));
// At the beginning of your upkeep, you may exile all cards from your hand face down. If you do, put all other cards you own exiled with Duplicity into your hand. // At the beginning of your upkeep, you may exile all cards from your hand face down. If you do, put all other cards you own exiled with Duplicity into your hand.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new DuplicityExileHandEffect(), TargetController.YOU, true)); this.addAbility(new BeginningOfUpkeepTriggeredAbility(new DuplicityExileHandEffect(), TargetController.YOU, true));
// At the beginning of your end step, discard a card. // At the beginning of your end step, discard a card.
this.addAbility(new BeginningOfYourEndStepTriggeredAbility(new DiscardControllerEffect(1), false)); this.addAbility(new BeginningOfYourEndStepTriggeredAbility(new DiscardControllerEffect(1), false));
// When you lose control of Duplicity, put all cards exiled with Duplicity into their owner's graveyard. // When you lose control of Duplicity, put all cards exiled with Duplicity into their owner's graveyard.
this.addAbility(new LoseControlDuplicity()); this.addAbility(new LoseControlDuplicity());
} }
public Duplicity(final Duplicity card) { public Duplicity(final Duplicity card) {
super(card); super(card);
} }
@Override @Override
public Duplicity copy() { public Duplicity copy() {
return new Duplicity(this); return new Duplicity(this);
} }
} }
class DuplicityEffect extends OneShotEffect { class DuplicityEffect extends OneShotEffect {
public DuplicityEffect() { public DuplicityEffect() {
super(Outcome.Exile); super(Outcome.Exile);
staticText = "exile the top five cards of your library face down"; staticText = "exile the top five cards of your library face down";
} }
public DuplicityEffect(final DuplicityEffect effect) { public DuplicityEffect(final DuplicityEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null if (controller != null
&& sourceObject != null) { && sourceObject != null) {
if (controller.getLibrary().hasCards()) { if (controller.getLibrary().hasCards()) {
UUID exileId = CardUtil.getCardExileZoneId(game, source); UUID exileId = CardUtil.getCardExileZoneId(game, source);
Set<Card> cardsToExile = controller.getLibrary().getTopCards(game, 5); Set<Card> cardsToExile = controller.getLibrary().getTopCards(game, 5);
for (Card card : cardsToExile) { for (Card card : cardsToExile) {
controller.moveCardsToExile(card, source, game, true, exileId, sourceObject.getName()); controller.moveCardsToExile(card, source, game, true, exileId, sourceObject.getName());
card.setFaceDown(true, game); card.setFaceDown(true, game);
} }
} }
return true; return true;
} }
return false; return false;
} }
@Override @Override
public DuplicityEffect copy() { public DuplicityEffect copy() {
return new DuplicityEffect(this); return new DuplicityEffect(this);
} }
} }
class DuplicityExileHandEffect extends OneShotEffect { class DuplicityExileHandEffect extends OneShotEffect {
public DuplicityExileHandEffect() { public DuplicityExileHandEffect() {
super(Outcome.Exile); super(Outcome.Exile);
staticText = "you may exile all cards from your hand face down. If you do, put all other cards you own exiled with {this} into your hand"; staticText = "you may exile all cards from your hand face down. If you do, put all other cards you own exiled with {this} into your hand";
} }
public DuplicityExileHandEffect(final DuplicityExileHandEffect effect) { public DuplicityExileHandEffect(final DuplicityExileHandEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null if (controller != null
&& sourceObject != null) { && sourceObject != null) {
if (!controller.getHand().isEmpty()) { if (!controller.getHand().isEmpty()) {
UUID exileId = CardUtil.getCardExileZoneId(game, source); UUID exileId = CardUtil.getCardExileZoneId(game, source);
Set<Card> cardsFromHandToExile = controller.getHand().getCards(game); Set<Card> cardsFromHandToExile = controller.getHand().getCards(game);
for (Card card : cardsFromHandToExile) { for (Card card : cardsFromHandToExile) {
controller.moveCardsToExile(card, source, game, true, exileId, sourceObject.getName()); controller.moveCardsToExile(card, source, game, true, exileId, sourceObject.getName());
card.setFaceDown(true, game); card.setFaceDown(true, game);
} }
Set<Card> cardsInExile = game.getExile().getExileZone(exileId).getCards(game); Set<Card> cardsInExile = game.getExile().getExileZone(exileId).getCards(game);
Set<Card> cardsToReturnToHandFromExile = new HashSet<>(); Set<Card> cardsToReturnToHandFromExile = new HashSet<>();
for (Card card : cardsInExile) { for (Card card : cardsInExile) {
if (!cardsFromHandToExile.contains(card)) { if (!cardsFromHandToExile.contains(card)) {
cardsToReturnToHandFromExile.add(card); cardsToReturnToHandFromExile.add(card);
} }
} }
controller.moveCards(cardsToReturnToHandFromExile, Zone.HAND, source, game); controller.moveCards(cardsToReturnToHandFromExile, Zone.HAND, source, game);
} }
return true; return true;
} }
return false; return false;
} }
@Override @Override
public DuplicityExileHandEffect copy() { public DuplicityExileHandEffect copy() {
return new DuplicityExileHandEffect(this); return new DuplicityExileHandEffect(this);
} }
} }
class LoseControlDuplicity extends DelayedTriggeredAbility { class LoseControlDuplicity extends DelayedTriggeredAbility {
public LoseControlDuplicity() { public LoseControlDuplicity() {
super(new PutExiledCardsInOwnersGraveyard(), Duration.EndOfGame, false); super(new PutExiledCardsInOwnersGraveyard(), Duration.EndOfGame, false);
} }
public LoseControlDuplicity(final LoseControlDuplicity ability) { public LoseControlDuplicity(final LoseControlDuplicity ability) {
super(ability); super(ability);
} }
@Override @Override
public LoseControlDuplicity copy() { public LoseControlDuplicity copy() {
return new LoseControlDuplicity(this); return new LoseControlDuplicity(this);
} }
@Override @Override
public boolean checkEventType(GameEvent event, Game game) { public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.LOST_CONTROL; return event.getType() == GameEvent.EventType.LOST_CONTROL;
} }
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
return event.getPlayerId().equals(controllerId); return event.getPlayerId().equals(controllerId);
} }
@Override @Override
public String getRule() { public String getRule() {
return "When you lose control of {this}, put all cards exiled with {this} into their owner's graveyard."; return "When you lose control of {this}, put all cards exiled with {this} into their owner's graveyard.";
} }
} }
class PutExiledCardsInOwnersGraveyard extends OneShotEffect { class PutExiledCardsInOwnersGraveyard extends OneShotEffect {
public PutExiledCardsInOwnersGraveyard() { public PutExiledCardsInOwnersGraveyard() {
super(Outcome.Neutral); super(Outcome.Neutral);
staticText = " put all cards exiled with {this} into their owner's graveyard."; staticText = " put all cards exiled with {this} into their owner's graveyard.";
} }
public PutExiledCardsInOwnersGraveyard(final PutExiledCardsInOwnersGraveyard effect) { public PutExiledCardsInOwnersGraveyard(final PutExiledCardsInOwnersGraveyard effect) {
super(effect); super(effect);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null if (controller != null
&& sourceObject != null) { && sourceObject != null) {
UUID exileId = CardUtil.getCardExileZoneId(game, source); UUID exileId = CardUtil.getCardExileZoneId(game, source);
Set<Card> cardsInExile = game.getExile().getExileZone(exileId).getCards(game); Set<Card> cardsInExile = game.getExile().getExileZone(exileId).getCards(game);
controller.moveCardsToGraveyardWithInfo(cardsInExile, source, game, Zone.EXILED); controller.moveCardsToGraveyardWithInfo(cardsInExile, source, game, Zone.EXILED);
return true; return true;
} }
return false; return false;
} }
@Override @Override
public PutExiledCardsInOwnersGraveyard copy() { public PutExiledCardsInOwnersGraveyard copy() {
return new PutExiledCardsInOwnersGraveyard(this); return new PutExiledCardsInOwnersGraveyard(this);
} }
} }

View file

@ -1,4 +1,3 @@
package mage.cards.p; package mage.cards.p;
import java.util.UUID; import java.util.UUID;
@ -11,8 +10,8 @@ import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -26,7 +25,7 @@ import mage.target.common.TargetControlledPermanent;
public final class ProwlingPangolin extends CardImpl { public final class ProwlingPangolin extends CardImpl {
public ProwlingPangolin(UUID ownerId, CardSetInfo setInfo) { public ProwlingPangolin(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{B}{B}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}{B}");
this.subtype.add(SubType.BEAST, SubType.PANGOLIN); this.subtype.add(SubType.BEAST, SubType.PANGOLIN);
this.power = new MageInt(6); this.power = new MageInt(6);
this.toughness = new MageInt(5); this.toughness = new MageInt(5);