Fix some more getOpponent calls.

This commit is contained in:
elcnesh
2014-07-28 20:17:33 +00:00
parent b59f77e2ac
commit ae98af475c
3 changed files with 29 additions and 20 deletions

View File

@@ -993,17 +993,6 @@ public class AbilityUtils {
o = ((SpellAbility) c).getHostCard().getController(); 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")) { else if (defined.endsWith("Owner")) {
String replacingType = defined.substring(8); String replacingType = defined.substring(8);
replacingType = replacingType.substring(0, replacingType.length() - 5); replacingType = replacingType.substring(0, replacingType.length() - 5);

View File

@@ -1,6 +1,8 @@
package forge.game.ability.effects; package forge.game.ability.effects;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import forge.game.ability.AbilityUtils; import forge.game.ability.AbilityUtils;
import forge.game.ability.SpellAbilityEffect; import forge.game.ability.SpellAbilityEffect;
import forge.game.card.Card; import forge.game.card.Card;
@@ -13,6 +15,7 @@ import forge.game.spellability.SpellAbility;
import forge.game.spellability.TargetRestrictions; import forge.game.spellability.TargetRestrictions;
import forge.game.zone.ZoneType; import forge.game.zone.ZoneType;
import forge.util.Aggregates; import forge.util.Aggregates;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
@@ -92,9 +95,24 @@ public class DiscardEffect extends SpellAbilityEffect {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
final List<Card> discarded = new ArrayList<Card>(); final List<Card> discarded = new ArrayList<Card>();
final List<Player> 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")) { if (sa.hasParam("RememberDiscarder")) {
source.addRemembered(p); source.addRemembered(p);
} }
@@ -178,7 +196,9 @@ public class DiscardEffect extends SpellAbilityEffect {
// Reveal // Reveal
final List<Card> dPHand = p.getCardsIn(ZoneType.Hand); final List<Card> 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"; String valid = sa.hasParam("DiscardValid") ? sa.getParam("DiscardValid") : "Card";
@@ -193,7 +213,7 @@ public class DiscardEffect extends SpellAbilityEffect {
p.discard(c, sa); p.discard(c, sa);
discarded.add(c); 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<Card> dPHand = new ArrayList<Card>(p.getCardsIn(ZoneType.Hand)); List<Card> dPHand = new ArrayList<Card>(p.getCardsIn(ZoneType.Hand));
dPHand = CardLists.filter(dPHand, Presets.NON_TOKEN); dPHand = CardLists.filter(dPHand, Presets.NON_TOKEN);
if (dPHand.isEmpty()) if (dPHand.isEmpty())
@@ -211,8 +231,8 @@ public class DiscardEffect extends SpellAbilityEffect {
Player chooser = p; Player chooser = p;
if (mode.equals("RevealYouChoose")) { if (mode.equals("RevealYouChoose")) {
chooser = source.getController(); chooser = source.getController();
} else if (mode.equals("RevealOppChoose")) { } else if (mode.equals("RevealTgtChoose")) {
chooser = source.getController().getOpponent(); chooser = firstTarget;
} }
if (mode.startsWith("Reveal") && p != chooser) if (mode.startsWith("Reveal") && p != chooser)

View File

@@ -3,8 +3,8 @@ ManaCost:B B R
Types:Creature Human Wizard Types:Creature Human Wizard
PT:3/2 PT:3/2
K:First Strike 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. 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$ You | NumCards$ 1 | Mode$ RevealOppChoose SVar:DBDiscard:DB$ Discard | Defined$ ParentTarget | NumCards$ 1 | Mode$ RevealYouChoose
SVar:RemAIDeck:True SVar:RemAIDeck:True
SVar:Picture:http://www.wizards.com/global/images/magic/general/rakdos_augermage.jpg 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.