From ae98af475cbc52a5039f5101a425e94c730356e3 Mon Sep 17 00:00:00 2001 From: elcnesh Date: Mon, 28 Jul 2014 20:17:33 +0000 Subject: [PATCH] Fix some more getOpponent calls. --- .../java/forge/game/ability/AbilityUtils.java | 11 ------- .../game/ability/effects/DiscardEffect.java | 32 +++++++++++++++---- .../res/cardsfolder/r/rakdos_augermage.txt | 6 ++-- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java index d08591084ed..831d74ca421 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java @@ -993,17 +993,6 @@ public class AbilityUtils { o = ((SpellAbility) c).getHostCard().getController(); } } - else if (defined.endsWith("Opponent")) { - String replacingType = defined.substring(8); - replacingType = replacingType.substring(0, replacingType.length() - 8); - final Object c = root.getReplacingObject(replacingType); - if (c instanceof Card) { - o = ((Card) c).getController().getOpponent(); - } - if (c instanceof SpellAbility) { - o = ((SpellAbility) c).getHostCard().getController().getOpponent(); - } - } else if (defined.endsWith("Owner")) { String replacingType = defined.substring(8); replacingType = replacingType.substring(0, replacingType.length() - 5); diff --git a/forge-game/src/main/java/forge/game/ability/effects/DiscardEffect.java b/forge-game/src/main/java/forge/game/ability/effects/DiscardEffect.java index da0f8af14bd..7309a6fcd4e 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/DiscardEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/DiscardEffect.java @@ -1,6 +1,8 @@ package forge.game.ability.effects; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; + import forge.game.ability.AbilityUtils; import forge.game.ability.SpellAbilityEffect; import forge.game.card.Card; @@ -13,6 +15,7 @@ import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetRestrictions; import forge.game.zone.ZoneType; import forge.util.Aggregates; + import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; @@ -92,9 +95,24 @@ public class DiscardEffect extends SpellAbilityEffect { final TargetRestrictions tgt = sa.getTargetRestrictions(); final List discarded = new ArrayList(); + final List targets = getTargetPlayers(sa), + discarders; + Player firstTarget = null; + if (mode.equals("RevealTgtChoose")) { + // In this case the target need not be the discarding player + discarders = getDefinedPlayersOrTargeted(sa); + firstTarget = Iterables.getFirst(targets, null); + if (tgt != null && !firstTarget.canBeTargetedBy(sa)) { + firstTarget = null; + } + } else { + discarders = targets; + } - for (final Player p : getTargetPlayers(sa)) { - if ((tgt == null) || p.canBeTargetedBy(sa)) { + + for (final Player p : discarders) { + if ((mode.equals("RevealTgtChoose") && firstTarget != null) + || tgt == null || p.canBeTargetedBy(sa)) { if (sa.hasParam("RememberDiscarder")) { source.addRemembered(p); } @@ -178,7 +196,9 @@ public class DiscardEffect extends SpellAbilityEffect { // Reveal final List dPHand = p.getCardsIn(ZoneType.Hand); - p.getOpponent().getController().reveal(dPHand, ZoneType.Hand, p, "Reveal "); + for (final Player opp : p.getOpponents()) { + opp.getController().reveal(dPHand, ZoneType.Hand, p, "Reveal "); + } String valid = sa.hasParam("DiscardValid") ? sa.getParam("DiscardValid") : "Card"; @@ -193,7 +213,7 @@ public class DiscardEffect extends SpellAbilityEffect { p.discard(c, sa); discarded.add(c); } - } else if (mode.equals("RevealYouChoose") || mode.equals("RevealOppChoose") || mode.equals("TgtChoose")) { + } else if (mode.equals("RevealYouChoose") || mode.equals("RevealTgtChoose") || mode.equals("TgtChoose")) { List dPHand = new ArrayList(p.getCardsIn(ZoneType.Hand)); dPHand = CardLists.filter(dPHand, Presets.NON_TOKEN); if (dPHand.isEmpty()) @@ -211,8 +231,8 @@ public class DiscardEffect extends SpellAbilityEffect { Player chooser = p; if (mode.equals("RevealYouChoose")) { chooser = source.getController(); - } else if (mode.equals("RevealOppChoose")) { - chooser = source.getController().getOpponent(); + } else if (mode.equals("RevealTgtChoose")) { + chooser = firstTarget; } if (mode.startsWith("Reveal") && p != chooser) diff --git a/forge-gui/res/cardsfolder/r/rakdos_augermage.txt b/forge-gui/res/cardsfolder/r/rakdos_augermage.txt index 7df58d303bc..24a9ae2ff98 100644 --- a/forge-gui/res/cardsfolder/r/rakdos_augermage.txt +++ b/forge-gui/res/cardsfolder/r/rakdos_augermage.txt @@ -3,8 +3,8 @@ ManaCost:B B R Types:Creature Human Wizard PT:3/2 K:First Strike -A:AB$ Discard | Cost$ T | ValidTgts$ Opponent | SorcerySpeed$ True | NumCards$ 1 | Mode$ RevealYouChoose | SubAbility$ DBDiscard | SpellDescription$ Reveal your hand and discard a card of target opponent's choice. Then that player reveals his or her hand and discards a card of your choice. Activate this ability only any time you could cast a sorcery. -SVar:DBDiscard:DB$ Discard | Defined$ You | NumCards$ 1 | Mode$ RevealOppChoose +A:AB$ Discard | Cost$ T | Defined$ You | ValidTgts$ Opponent | SorcerySpeed$ True | NumCards$ 1 | Mode$ RevealTgtChoose | SubAbility$ DBDiscard | SpellDescription$ Reveal your hand and discard a card of target opponent's choice. Then that player reveals his or her hand and discards a card of your choice. Activate this ability only any time you could cast a sorcery. +SVar:DBDiscard:DB$ Discard | Defined$ ParentTarget | NumCards$ 1 | Mode$ RevealYouChoose SVar:RemAIDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/rakdos_augermage.jpg -Oracle:First strike\n{T}: Reveal your hand and discard a card of target opponent's choice. Then that player reveals his or her hand and discards a card of your choice. Activate this ability only any time you could cast a sorcery. +Oracle:First strike\n{T}: Reveal your hand and discard a card of target opponent's choice. Then that player reveals his or her hand and discards a card of your choice. Activate this ability only any time you could cast a sorcery. \ No newline at end of file