From f593623508b8db4b7f2b51ae8a4d92d055ec373b Mon Sep 17 00:00:00 2001 From: drmDev Date: Tue, 26 Jul 2016 22:58:20 -0400 Subject: [PATCH] finished implementation of cards. CardView bug fix for card number change. --- Mage.Common/src/mage/view/CardView.java | 3 +- .../src/mage/sets/odyssey/Gravestorm.java | 24 ++++++++----- .../src/mage/sets/onslaught/SyphonMind.java | 35 +++++++++---------- 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/Mage.Common/src/mage/view/CardView.java b/Mage.Common/src/mage/view/CardView.java index 7a6745c533..989c161296 100644 --- a/Mage.Common/src/mage/view/CardView.java +++ b/Mage.Common/src/mage/view/CardView.java @@ -275,7 +275,8 @@ public class CardView extends SimpleCardView { this.isToken = true; this.mageObjectType = MageObjectType.TOKEN; this.rarity = Rarity.COMMON; - if (!((PermanentToken) card).getToken().getOriginalCardNumber().isEmpty() && !"0".equals(((PermanentToken) card).getToken().getOriginalCardNumber())) { + boolean originalCardNumberIsNull = ((PermanentToken) card).getToken().getOriginalCardNumber() == null; + if (!originalCardNumberIsNull && !"0".equals(((PermanentToken) card).getToken().getOriginalCardNumber())) { // a token copied from permanent this.expansionSetCode = ((PermanentToken) card).getToken().getOriginalExpansionSetCode(); this.cardNumber = ((PermanentToken) card).getToken().getOriginalCardNumber(); diff --git a/Mage.Sets/src/mage/sets/odyssey/Gravestorm.java b/Mage.Sets/src/mage/sets/odyssey/Gravestorm.java index 6daa25ca8d..d993a37e78 100644 --- a/Mage.Sets/src/mage/sets/odyssey/Gravestorm.java +++ b/Mage.Sets/src/mage/sets/odyssey/Gravestorm.java @@ -43,6 +43,7 @@ import mage.filter.predicate.other.OwnerIdPredicate; import mage.game.Game; import mage.players.Player; import mage.target.common.TargetCardInGraveyard; +import mage.target.common.TargetOpponent; /** * @@ -55,7 +56,9 @@ public class Gravestorm extends CardImpl { this.expansionSetCode = "ODY"; // At the beginning of your upkeep, target opponent may exile a card from his or her graveyard. If that player doesn't, you may draw a card. - this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new GravestormEffect(), TargetController.YOU, false)); + Ability ability = new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new GravestormEffect(), TargetController.YOU, false); + ability.addTarget(new TargetOpponent()); + this.addAbility(ability); } public Gravestorm(final Gravestorm card) { @@ -93,17 +96,20 @@ class GravestormEffect extends OneShotEffect { filter.add(new OwnerIdPredicate(targetPlayer.getId())); TargetCardInGraveyard target = new TargetCardInGraveyard(filter); boolean opponentChoosesExile = targetPlayer.chooseUse(Outcome.Exile, "Exile a card from your graveyard?", source, game); + boolean opponentExilesACard = false; if (opponentChoosesExile && targetPlayer.chooseTarget(Outcome.Exile, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); - if (card != null) { - if (targetPlayer.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.GRAVEYARD, true)) { - if (you.chooseUse(Outcome.DrawCard, "Draw a card?", source, game)) { - you.drawCards(1, game); - } - } - } - return true; + if (card != null) { + opponentExilesACard = targetPlayer.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.GRAVEYARD, true); + } } + + if (!opponentExilesACard) { + if (you.chooseUse(Outcome.DrawCard, "Draw a card?", source, game)) { + you.drawCards(1, game); + } + } + return true; } return false; } diff --git a/Mage.Sets/src/mage/sets/onslaught/SyphonMind.java b/Mage.Sets/src/mage/sets/onslaught/SyphonMind.java index ba0e00f04d..c1a66c8fe8 100644 --- a/Mage.Sets/src/mage/sets/onslaught/SyphonMind.java +++ b/Mage.Sets/src/mage/sets/onslaught/SyphonMind.java @@ -28,14 +28,13 @@ package mage.sets.onslaught; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; import mage.cards.CardImpl; +import mage.constants.CardType; import mage.constants.Outcome; +import mage.constants.Rarity; import mage.game.Game; import mage.players.Player; import mage.target.common.TargetCardInHand; @@ -87,25 +86,25 @@ class SyphonMindEffect extends OneShotEffect { int amount = 0; boolean result = false; Player you = game.getPlayer(source.getControllerId()); - for (UUID playerId : you.getInRange()) { - if (!playerId.equals(source.getControllerId())) { - Player otherPlayer = game.getPlayer(playerId); - if (otherPlayer != null && otherPlayer.getHand().size() > 0) { - TargetCardInHand target = new TargetCardInHand(); - if (otherPlayer.choose(Outcome.Discard, target, source.getSourceId(), game)) { - Card card = game.getCard(target.getFirstTarget()); - if (card != null) { - if (otherPlayer.discard(card, source, game)) { - amount += 1; - result = true; - target.clearChosen(); + if (you != null) { + for (UUID playerId : you.getInRange()) { + if (!playerId.equals(source.getControllerId())) { + Player otherPlayer = game.getPlayer(playerId); + if (otherPlayer != null && otherPlayer.getHand().size() > 0) { + TargetCardInHand target = new TargetCardInHand(); + if (otherPlayer.choose(Outcome.Discard, target, source.getSourceId(), game)) { + Card card = game.getCard(target.getFirstTarget()); + if (card != null) { + if (otherPlayer.discard(card, source, game)) { + amount += 1; + result = true; + target.clearChosen(); + } } } } } - } - } - if (you != null) { + } you.drawCards(amount, game); } return result;