mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
* Some minor changes to Casting of Bones and the used effect.
This commit is contained in:
parent
25f5be3aba
commit
1e1e361c60
2 changed files with 22 additions and 30 deletions
|
@ -28,18 +28,18 @@
|
|||
package mage.cards.c;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.SubType;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DiesAttachedTriggeredAbility;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.DrawDiscardOneOfThemEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
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) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}");
|
||||
|
||||
|
||||
this.subtype.add(SubType.AURA);
|
||||
|
||||
// Enchant creature
|
||||
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||
this.getSpellAbility().addTarget(auraTarget);
|
||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.DrawCard));
|
||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Discard));
|
||||
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||
this.addAbility(ability);
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
|
@ -47,15 +46,15 @@ import mage.util.CardUtil;
|
|||
*/
|
||||
public class DrawDiscardOneOfThemEffect extends OneShotEffect {
|
||||
|
||||
private int cardsToDraw;
|
||||
|
||||
private final int cardsToDraw;
|
||||
|
||||
public DrawDiscardOneOfThemEffect(int cardsToDraw) {
|
||||
super(Outcome.DrawCard);
|
||||
this.cardsToDraw = cardsToDraw;
|
||||
staticText = new StringBuilder("draw ")
|
||||
.append(cardsToDraw == 1 ? "a" : CardUtil.numberToText(cardsToDraw))
|
||||
.append(" card").append(cardsToDraw == 1 ? "" : "s")
|
||||
.append(", then discard one of them").toString();
|
||||
staticText = "draw "
|
||||
+ (cardsToDraw == 1 ? "a" : CardUtil.numberToText(cardsToDraw))
|
||||
+ " card" + (cardsToDraw == 1 ? "" : "s")
|
||||
+ ", then discard one of them";
|
||||
}
|
||||
|
||||
public DrawDiscardOneOfThemEffect(final DrawDiscardOneOfThemEffect effect) {
|
||||
|
@ -70,28 +69,22 @@ public class DrawDiscardOneOfThemEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
Cards initialHand = player.getHand().copy();
|
||||
player.drawCards(cardsToDraw, game);
|
||||
Cards drawnCards = new CardsImpl();
|
||||
for(UUID cardId : player.getHand()) {
|
||||
if(!initialHand.contains(cardId)) {
|
||||
drawnCards.add(cardId);
|
||||
}
|
||||
}
|
||||
|
||||
if(!drawnCards.isEmpty()) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Cards initialHand = controller.getHand().copy();
|
||||
controller.drawCards(cardsToDraw, game);
|
||||
Cards drawnCards = new CardsImpl(controller.getHand().copy());
|
||||
drawnCards.removeAll(initialHand);
|
||||
if (!drawnCards.isEmpty()) {
|
||||
TargetCard cardToDiscard = new TargetCard(Zone.HAND, new FilterCard("card to discard"));
|
||||
cardToDiscard.setNotTarget(true);
|
||||
if(player.choose(Outcome.Discard, drawnCards, cardToDiscard, game)) {
|
||||
Card card = player.getHand().get(cardToDiscard.getFirstTarget(), game);
|
||||
if(card != null) {
|
||||
return player.discard(card, source, game);
|
||||
if (controller.choose(Outcome.Discard, drawnCards, cardToDiscard, game)) {
|
||||
Card card = controller.getHand().get(cardToDiscard.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
return controller.discard(card, source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue