AI: added support of TargetCard targeting in hand, graveyard, exile zones. Added additional checks for tests.

This commit is contained in:
Oleg Agafonov 2021-09-03 00:26:39 +04:00
parent 98b758e95e
commit 4d0761fa27

View file

@ -2314,6 +2314,8 @@ public class TestPlayer implements Player {
return true; return true;
} }
Set<Zone> targetCardZonesChecked = new HashSet<>(); // control miss implementation
// player // player
if (target.getOriginalTarget() instanceof TargetPlayer if (target.getOriginalTarget() instanceof TargetPlayer
|| target.getOriginalTarget() instanceof TargetAnyTarget || target.getOriginalTarget() instanceof TargetAnyTarget
@ -2397,9 +2399,12 @@ public class TestPlayer implements Player {
} }
} }
// card in hand // card in hand (only own hand supports here)
// TODO: add not own hand too, example
if (target.getOriginalTarget() instanceof TargetCardInHand if (target.getOriginalTarget() instanceof TargetCardInHand
|| target.getOriginalTarget() instanceof TargetDiscard) { || target.getOriginalTarget() instanceof TargetDiscard
|| (target.getOriginalTarget() instanceof TargetCard && target.getOriginalTarget().getZone() == Zone.HAND)) {
targetCardZonesChecked.add(Zone.HAND);
for (String targetDefinition : targets) { for (String targetDefinition : targets) {
checkTargetDefinitionMarksSupport(target, targetDefinition, "^"); checkTargetDefinitionMarksSupport(target, targetDefinition, "^");
String[] targetList = targetDefinition.split("\\^"); String[] targetList = targetDefinition.split("\\^");
@ -2424,8 +2429,9 @@ public class TestPlayer implements Player {
// card in exile // card in exile
if (target.getOriginalTarget() instanceof TargetCardInExile if (target.getOriginalTarget() instanceof TargetCardInExile
|| target.getOriginalTarget() instanceof TargetPermanentOrSuspendedCard) { || target.getOriginalTarget() instanceof TargetPermanentOrSuspendedCard
|| (target.getOriginalTarget() instanceof TargetCard && target.getOriginalTarget().getZone() == Zone.EXILED)) {
targetCardZonesChecked.add(Zone.EXILED);
FilterCard filter = null; FilterCard filter = null;
if (target.getOriginalTarget().getFilter() instanceof FilterCard) { if (target.getOriginalTarget().getFilter() instanceof FilterCard) {
filter = (FilterCard) target.getOriginalTarget().getFilter(); filter = (FilterCard) target.getOriginalTarget().getFilter();
@ -2488,7 +2494,9 @@ public class TestPlayer implements Player {
if (target.getOriginalTarget() instanceof TargetCardInOpponentsGraveyard if (target.getOriginalTarget() instanceof TargetCardInOpponentsGraveyard
|| target.getOriginalTarget() instanceof TargetCardInYourGraveyard || target.getOriginalTarget() instanceof TargetCardInYourGraveyard
|| target.getOriginalTarget() instanceof TargetCardInGraveyard || target.getOriginalTarget() instanceof TargetCardInGraveyard
|| target.getOriginalTarget() instanceof TargetCardInGraveyardOrBattlefield) { || target.getOriginalTarget() instanceof TargetCardInGraveyardOrBattlefield
|| (target.getOriginalTarget() instanceof TargetCard && target.getOriginalTarget().getZone() == Zone.GRAVEYARD)) {
targetCardZonesChecked.add(Zone.GRAVEYARD);
TargetCard targetFull = (TargetCard) target.getOriginalTarget(); TargetCard targetFull = (TargetCard) target.getOriginalTarget();
List<UUID> needPlayers = game.getState().getPlayersInRange(getId(), game).toList(); List<UUID> needPlayers = game.getState().getPlayersInRange(getId(), game).toList();
@ -2560,6 +2568,14 @@ public class TestPlayer implements Player {
} }
} }
} }
// uninplemented TargetCard's zone
if (target.getOriginalTarget() instanceof TargetCard && !targetCardZonesChecked.contains(target.getOriginalTarget().getZone())) {
Assert.fail("Found unimplemented TargetCard's zone or TargetCard's extented class: "
+ target.getOriginalTarget().getClass().getCanonicalName()
+ ", zone " + target.getOriginalTarget().getZone()
+ ", from " + (source == null ? "unknown source" : source.getSourceObject(game)));
}
} }
// wrong target settings by addTarget // wrong target settings by addTarget