From acf3aa66934e6e57fa22c3a1aea3ced319fce8c4 Mon Sep 17 00:00:00 2001 From: drdev Date: Mon, 25 Aug 2014 22:23:38 +0000 Subject: [PATCH] Make it so "target opponent" cards auto-target your opponent when playing 1v1. --- .../main/java/forge/player/TargetSelection.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/forge-gui/src/main/java/forge/player/TargetSelection.java b/forge-gui/src/main/java/forge/player/TargetSelection.java index a15ef2b1b4c..e8f58cc4346 100644 --- a/forge-gui/src/main/java/forge/player/TargetSelection.java +++ b/forge-gui/src/main/java/forge/player/TargetSelection.java @@ -83,10 +83,12 @@ public class TargetSelection { boolean hasEnoughTargets = minTargets == 0 || numTargeted >= minTargets; boolean hasAllTargets = numTargeted == maxTargets && maxTargets > 0; - if (maxTargets == 0) return true; + if (maxTargets == 0) { return true; } + // if not enough targets chosen, cancel Ability - if (this.bTargetingDone && !hasEnoughTargets) + if (this.bTargetingDone && !hasEnoughTargets) { return false; + } if (this.bTargetingDone && hasEnoughTargets || hasAllTargets || tgt.isDividedAsYouChoose() && tgt.getStillToDivide() == 0) { return true; @@ -114,6 +116,15 @@ public class TargetSelection { } else { final List validTargets = this.getValidCardsToTarget(); + if (validTargets.isEmpty()) { + //if no valid cards to target and only one valid non-card, auto-target the non-card + //this handles "target opponent" cards, along with any other cards that can only target a single non-card game entity + //note that we don't handle auto-targeting cards this way since it's possible that the result will be undesirable + List nonCardTargets = tgt.getAllCandidates(this.ability, true); + if (nonCardTargets.size() == 1) { + return ability.getTargets().add(nonCardTargets.get(0)); + } + } final Map playersWithValidTargets = new HashMap(); for (Card card : validTargets) { playersWithValidTargets.put(card.getController(), null);