mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
reworked AI, targeting and targets logic:
- refactor: simplified target implementation from a dozen canTarget, canChoose and possibleTargets methods to canTarget/possibleTargets only (part of #13638, #13766); - refactor: fixed wrong target implementations in many cards (example: TargetCardInHand for opponent's hand, close #6210); - AI: now human, AI and test players -- all use possibleTargets logic in most use cases instead filters or custom validation; - AI: improved AI sims support for multiple targets abilities; - AI: improved AI stability, freezes and targets errors in some use cases;
This commit is contained in:
parent
e866707912
commit
c7a485b728
240 changed files with 1652 additions and 3096 deletions
|
|
@ -18,10 +18,8 @@ import javax.swing.*;
|
|||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -258,7 +256,7 @@ public class CardArea extends JPanel implements CardEventProducer {
|
|||
this.reloaded = false;
|
||||
}
|
||||
|
||||
public void selectCards(List<UUID> selected) {
|
||||
public void selectCards(Set<UUID> selected) {
|
||||
for (Component component : cardArea.getComponents()) {
|
||||
if (component instanceof MageCard) {
|
||||
MageCard mageCard = (MageCard) component;
|
||||
|
|
@ -269,7 +267,7 @@ public class CardArea extends JPanel implements CardEventProducer {
|
|||
}
|
||||
}
|
||||
|
||||
public void markCards(List<UUID> marked) {
|
||||
public void markCards(Set<UUID> marked) {
|
||||
for (Component component : cardArea.getComponents()) {
|
||||
if (component instanceof MageCard) {
|
||||
MageCard mageCard = (MageCard) component;
|
||||
|
|
|
|||
|
|
@ -100,11 +100,11 @@
|
|||
cardArea.loadCards(showCards, bigCard, gameId);
|
||||
if (options != null) {
|
||||
if (options.containsKey("chosenTargets")) {
|
||||
java.util.List<UUID> chosenCards = (java.util.List<UUID>) options.get("chosenTargets");
|
||||
java.util.Set<UUID> chosenCards = (java.util.Set<UUID>) options.get("chosenTargets");
|
||||
cardArea.selectCards(chosenCards);
|
||||
}
|
||||
if (options.containsKey("possibleTargets")) {
|
||||
java.util.List<UUID> choosableCards = (java.util.List<UUID>) options.get("possibleTargets");
|
||||
java.util.Set<UUID> choosableCards = (java.util.Set<UUID>) options.get("possibleTargets");
|
||||
cardArea.markCards(choosableCards);
|
||||
}
|
||||
if (options.containsKey("queryType") && options.get("queryType") == QueryType.PICK_ABILITY) {
|
||||
|
|
|
|||
|
|
@ -216,17 +216,9 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
});
|
||||
}
|
||||
|
||||
public List<UUID> getPossibleTargets() {
|
||||
if (options != null && options.containsKey("possibleTargets")) {
|
||||
return (List<UUID>) options.get("possibleTargets");
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
public Set<UUID> getChosenTargets() {
|
||||
if (options != null && options.containsKey("chosenTargets")) {
|
||||
return new HashSet<>((List<UUID>) options.get("chosenTargets"));
|
||||
return (Set<UUID>) options.get("chosenTargets");
|
||||
} else {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue