* Some minor changes to Casting of Bones and the used effect.

This commit is contained in:
LevelX2 2018-03-13 22:57:27 +01:00
parent 25f5be3aba
commit 1e1e361c60
2 changed files with 22 additions and 30 deletions

View file

@ -28,18 +28,18 @@
package mage.cards.c; package mage.cards.c;
import java.util.UUID; import java.util.UUID;
import mage.constants.SubType;
import mage.target.common.TargetCreaturePermanent;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.DiesAttachedTriggeredAbility; import mage.abilities.common.DiesAttachedTriggeredAbility;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.DrawDiscardOneOfThemEffect; import mage.abilities.effects.common.DrawDiscardOneOfThemEffect;
import mage.constants.Outcome;
import mage.target.TargetPermanent;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
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.Outcome;
import mage.constants.SubType;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
/** /**
* *
@ -49,14 +49,13 @@ public class CastingOfBones extends CardImpl {
public CastingOfBones(UUID ownerId, CardSetInfo setInfo) { public CastingOfBones(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}");
this.subtype.add(SubType.AURA); this.subtype.add(SubType.AURA);
// Enchant creature // Enchant creature
TargetPermanent auraTarget = new TargetCreaturePermanent(); TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget); this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.DrawCard)); this.getSpellAbility().addEffect(new AttachEffect(Outcome.DrawCard));
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Discard));
Ability ability = new EnchantAbility(auraTarget.getTargetName()); Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability); this.addAbility(ability);

View file

@ -27,7 +27,6 @@
*/ */
package mage.abilities.effects.common; package mage.abilities.effects.common;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card; import mage.cards.Card;
@ -47,15 +46,15 @@ import mage.util.CardUtil;
*/ */
public class DrawDiscardOneOfThemEffect extends OneShotEffect { public class DrawDiscardOneOfThemEffect extends OneShotEffect {
private int cardsToDraw; private final int cardsToDraw;
public DrawDiscardOneOfThemEffect(int cardsToDraw) { public DrawDiscardOneOfThemEffect(int cardsToDraw) {
super(Outcome.DrawCard); super(Outcome.DrawCard);
this.cardsToDraw = cardsToDraw; this.cardsToDraw = cardsToDraw;
staticText = new StringBuilder("draw ") staticText = "draw "
.append(cardsToDraw == 1 ? "a" : CardUtil.numberToText(cardsToDraw)) + (cardsToDraw == 1 ? "a" : CardUtil.numberToText(cardsToDraw))
.append(" card").append(cardsToDraw == 1 ? "" : "s") + " card" + (cardsToDraw == 1 ? "" : "s")
.append(", then discard one of them").toString(); + ", then discard one of them";
} }
public DrawDiscardOneOfThemEffect(final DrawDiscardOneOfThemEffect effect) { public DrawDiscardOneOfThemEffect(final DrawDiscardOneOfThemEffect effect) {
@ -70,28 +69,22 @@ public class DrawDiscardOneOfThemEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (player != null) { if (controller != null) {
Cards initialHand = player.getHand().copy(); Cards initialHand = controller.getHand().copy();
player.drawCards(cardsToDraw, game); controller.drawCards(cardsToDraw, game);
Cards drawnCards = new CardsImpl(); Cards drawnCards = new CardsImpl(controller.getHand().copy());
for(UUID cardId : player.getHand()) { drawnCards.removeAll(initialHand);
if(!initialHand.contains(cardId)) { if (!drawnCards.isEmpty()) {
drawnCards.add(cardId);
}
}
if(!drawnCards.isEmpty()) {
TargetCard cardToDiscard = new TargetCard(Zone.HAND, new FilterCard("card to discard")); TargetCard cardToDiscard = new TargetCard(Zone.HAND, new FilterCard("card to discard"));
cardToDiscard.setNotTarget(true); cardToDiscard.setNotTarget(true);
if(player.choose(Outcome.Discard, drawnCards, cardToDiscard, game)) { if (controller.choose(Outcome.Discard, drawnCards, cardToDiscard, game)) {
Card card = player.getHand().get(cardToDiscard.getFirstTarget(), game); Card card = controller.getHand().get(cardToDiscard.getFirstTarget(), game);
if(card != null) { if (card != null) {
return player.discard(card, source, game); return controller.discard(card, source, game);
} }
} }
} }
return true; return true;
} }
return false; return false;