use Executor, update MatchScreen

This commit is contained in:
Anthony Calosa
2024-11-23 13:22:41 +08:00
parent 0b9fb9f379
commit b0411423f6
3 changed files with 20 additions and 12 deletions

View File

@@ -79,6 +79,7 @@ public class AiAttackController {
private int aiAggression = 0; // how aggressive the ai is attack will be depending on circumstances
private final boolean nextTurn; // include creature that can only attack/block next turn
private final int timeOut;
private List<CompletableFuture<Integer>> futures = new ArrayList<>();
/**
* <p>
@@ -910,7 +911,6 @@ public class AiAttackController {
final AtomicInteger numForcedAttackers = new AtomicInteger(0);
// nextTurn is now only used by effect from Oracle en-Vec, which can skip check must attack,
// because creatures not chosen can't attack.
List<CompletableFuture<Integer>> futures = new ArrayList<>();
if (!nextTurn) {
for (final Card attacker : this.attackers) {
final GameEntity finalDefender = defender;

View File

@@ -777,7 +777,7 @@ public class StaticData {
continue;
Map<String, Pair<Boolean, Integer>> cardCount = new HashMap<>();
List<CompletableFuture<Integer>> futures = new ArrayList<>();
List<CompletableFuture<?>> futures = new ArrayList<>();
for (CardEdition.CardInSet c : e.getAllCardsInSet()) {
if (cardCount.containsKey(c.name)) {
cardCount.put(c.name, Pair.of(c.collectorNumber != null && c.collectorNumber.startsWith("F"), cardCount.get(c.name).getRight() + 1));
@@ -798,12 +798,12 @@ public class StaticData {
}
if (cp == null) {
if (isFunny) //skip funny cards
return 0;
return null;
if (!loadNonLegalCards && CardEdition.Type.FUNNY.equals(e.getType()))
return 0;
return null;
EDITION_Q.add(e.getCode() + "_" + e.getName());
CNI_Q.add(e.getCode() + "_" + c + "\n");
return 0;
return null;
}
// check the front image
String imagePath = ImageUtil.getImageRelativePath(cp, "", true, false);
@@ -813,7 +813,7 @@ public class StaticData {
file = ImageKeys.setLookUpFile(imagePath, imagePath +"border");
if (file == null) {
if (imagePath.isEmpty())
return 0;
return null;
EDITION_Q.add(e.getCode() + "_" + e.getName());
NIF_Q.add(e.getCode() + "_" + imagePath + "\n");
}
@@ -827,16 +827,16 @@ public class StaticData {
file = ImageKeys.setLookUpFile(imagePath, imagePath +"border");
if (file == null) {
if (imagePath.isEmpty())
return 0;
return null;
EDITION_Q.add(e.getCode() + "_" + e.getName());
NIF_Q.add(e.getCode() + "_" + imagePath + "\n");
}
}
}
return 0;
return null;
}).exceptionally(ex -> {
ex.printStackTrace();
return 0;
return null;
}));
}
CompletableFuture<?>[] futuresArray = futures.toArray(new CompletableFuture<?>[0]);

View File

@@ -91,6 +91,11 @@ public class MatchScreen extends FScreen {
private static List<FDisplayObject> potentialListener;
private int selectedPlayer;
private final Map<Integer, Vector2> endpoints;
private final Set<CardView> cardsonBattlefield;
private final Set<PlayerView> playerViewSet;
public MatchScreen(List<VPlayerPanel> playerPanels0) {
super(new FMenuBar());
@@ -164,6 +169,9 @@ public class MatchScreen extends FScreen {
log.setMenuTab(new HiddenMenuTab(log));
devMenu.setMenuTab(new HiddenMenuTab(devMenu));
}
endpoints = new HashMap<>();
cardsonBattlefield = new HashSet<>();
playerViewSet = new HashSet<>();
}
private boolean is4Player() {
@@ -459,9 +467,9 @@ public class MatchScreen extends FScreen {
void drawArcs(Graphics g) {
//get all card targeting arrow origins on the battlefield
final Map<Integer, Vector2> endpoints = new HashMap<>();
final Set<CardView> cardsonBattlefield = new HashSet<>();
final Set<PlayerView> playerViewSet = new HashSet<>();
endpoints.clear();
cardsonBattlefield.clear();
playerViewSet.clear();
final GameView game = MatchController.instance.getGameView();
try {
for (PlayerView p : game.getPlayers()) {