- Attempted to fix the "single zone" targeting restriction for cards that require choosing multiple cards via a list input.

- For the human player, once the first target is chosen, the other targets are only listed from the same zone (e.g. from the same graveyard), other targets are not listed.
- For the AI player, the illegally chosen targets are removed post-selection from the targeting list. This is suboptimal and is only done this way so the AI at least does not cheat. We need an AI expert to expand on this to make the AI choose targets sanely in the first place.
This commit is contained in:
Agetian
2016-07-14 06:09:33 +00:00
parent 72fae66f7d
commit 6bf4c4ad66
2 changed files with 29 additions and 0 deletions

View File

@@ -73,6 +73,7 @@ public class TargetSelection {
final int maxTargets = numTargets != null ? numTargets.intValue() : tgt.getMaxTargets(ability.getHostCard(), ability);
//final int maxTotalCMC = tgt.getMaxTotalCMC(ability.getHostCard(), ability);
final int numTargeted = ability.getTargets().getNumTargeted();
final boolean isSingleZone = ability.getTargetRestrictions().isSingleZone();
final boolean hasEnoughTargets = minTargets == 0 || numTargeted >= minTargets;
final boolean hasAllTargets = numTargeted == maxTargets && maxTargets > 0;
@@ -114,6 +115,19 @@ public class TargetSelection {
}
else {
final List<Card> validTargets = CardUtil.getValidCardsToTarget(tgt, ability);
// single zone
if (isSingleZone) {
final List<Card> removeCandidates = new ArrayList<>();
final Card firstTgt = ability.getTargets().getFirstTargetedCard();
if (firstTgt != null) {
for (Card t : validTargets) {
if (!t.getController().equals(firstTgt.getController())) {
removeCandidates.add(t);
}
}
validTargets.removeAll(removeCandidates);
}
}
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