Fix: complete refactor of TUI

Tests updated
This commit is contained in:
2026-06-10 22:15:32 +02:00
parent 8bd740e68a
commit 4ffe4c5352
31 changed files with 242 additions and 187 deletions
@@ -28,8 +28,57 @@ public class ClientLauncherTUI {
private TUI view;
private Terminal terminal;
private LineReader gameReader;
private String currentUsername = "";
private static final String BUILDING_DETAILS =
"ID 0 — Each time you complete a set of 6 different Character cards, take 5 \uD83C\uDF56. (Sets completed before acquiring don't count.)\n" +
"ID 1 — During the Sustenance Event, pay 1 less \uD83C\uDF56 for each Artist/Inventor/Gatherer in your tribe.\n" +
"ID 2 — During the Shamanic Ritual Event, you do not lose Prestige Points if you have fewer ⭐ than all other players.\n" +
"ID 3 — When you move your Totem to a Food-bonus space, take 1 extra \uD83C\uDF56. If placed last, pay 1 \uD83C\uDF56 normally (no effect).\n" +
"ID 4 — Each time you obtain a pair of identical Inventors (same icon), take 3 \uD83C\uDF56. (Pairs owned before don't count.)\n" +
"ID 5 — During the Shamanic Ritual Event, your tribe has 3 additional ⭐ icons.\n" +
"ID 6 — During the Shamanic Ritual Event, if you have more ⭐ than any other player, gain double Prestige. Ties still count.\n" +
"ID 7 — During the Hunt Event, take 1 \uD83C\uDF56 and gain 1 extra Prestige Point for each Hunter in your tribe.\n" +
"ID 8 — At end of game, gain double the Prestige Points shown on Builder cards in your tribe.\n" +
"ID 9 — During the Cave Paintings Event, take 1 \uD83C\uDF56 for each Artist in your tribe.\n" +
"ID 10 — At end of game, gain 6 Prestige Points for each complete set of 6 different Character cards.\n" +
"ID 11 — At end of game, gain the indicated Prestige Points for each Character card of the indicated type.\n" +
"ID 12 — After all Totems return to Turn Order (before End of Round), take 1 Character or 1 Building card from the top row (paying its cost).\n" +
"ID 13 — At end of game, gain 25 Prestige Points.";
private static final String EVENT_DETAILS =
"SUSTENANCE — Pay 1 \uD83C\uDF56 per Character (Buildings don't count). If you can't feed all Characters, lose the\n" +
" Prestige Points shown on the card for each one you couldn't feed. Each Gatherer gives a 3\uD83C\uDF56 discount.\n" +
" You cannot choose to lose PP to avoid paying Food. Sustenance resolves last if multiple Events occur.\n" +
"\n" +
"HUNT — Take 1 \uD83C\uDF56 and gain the Prestige Points shown on the card for each Hunter in your tribe.\n" +
"\n" +
"SHAMANIC RITUAL — Player with the most \uD83C\uDF1F icons gains the Prestige Points on the card.\n" +
" Player with the fewest \uD83C\uDF1F icons loses those Prestige Points. In case of a tie, all tied players gain/lose.\n" +
"\n" +
"CAVE PAINTINGS — If you have fewer Artists than the top-line threshold, lose the indicated Prestige Points.\n" +
" If you meet the bottom-line threshold, gain the indicated Prestige Points for each Artist in your tribe.";
private static final String CHARACTER_DETAILS =
"INVENTORS — At end of game, gain PP equal to (number of Inventors) × (number of different Invention icons).\n" +
" There are 10 different Invention icons.\n" +
"\n" +
"GATHERERS — During Sustenance, each Gatherer gives a 3\uD83C\uDF56 discount on what you owe.\n" +
" Note: you do not take any Food from Gatherers under any circumstances.\n" +
"\n" +
"SHAMANS — Each Shaman shows 13 \uD83C\uDF1F icons. During Shamanic Ritual, majority = gain PP; minority = lose PP.\n" +
"\n" +
"BUILDERS — During the game, each Builder reduces the \uD83C\uDF56 cost of every Building card by the amount\n" +
" shown in the top-right corner. At end of game, each Builder gives the PP shown in the bottom-left corner.\n" +
"\n" +
"ARTISTS — During Cave Paintings, gain or lose PP based on Artist count (see 'details events').\n" +
" At end of game, gain 10 PP for every 2 Artists in your tribe.\n" +
"\n" +
"HUNTERS — Adding a Hunter without the \uD83C\uDF56 icon: nothing. Adding a Hunter WITH the \uD83C\uDF56 icon:\n" +
" immediately take 1 \uD83C\uDF56 for each Hunter in your tribe (with or without the icon).\n" +
" During Hunt Event, take \uD83C\uDF56 and gain PP based on your Hunter count (see 'details events').";
/**
* Starts the TUI client. Creates a JLine terminal, loops through login → game → rematch.
*
@@ -52,7 +101,7 @@ public class ClientLauncherTUI {
view = new TUI(null);
ClientController controller = new ClientController(view);
LineReader gameReader = buildGameReader();
gameReader = buildGameReader();
view.setLineReader(gameReader);
while (true) {
@@ -157,6 +206,7 @@ public class ClientLauncherTUI {
node("skip"),
node("render"),
node("help"),
node("details", node("buildings"), node("events"), node("characters")),
node("rematch"),
node("quit")
);
@@ -188,7 +238,17 @@ public class ClientLauncherTUI {
}
case "skip" -> controller.skipTurn();
case "render" -> handleRender(parts);
case "help" -> view.renderHelp();
case "help" -> gameReader.printAbove("Commands: slot, draw, totem, skip, render, help, details, rematch, quit");
case "details" -> {
if (parts.length > 1 && parts[1].equalsIgnoreCase("buildings"))
gameReader.printAbove(BUILDING_DETAILS);
else if (parts.length > 1 && parts[1].equalsIgnoreCase("events"))
gameReader.printAbove(EVENT_DETAILS);
else if (parts.length > 1 && parts[1].equalsIgnoreCase("characters"))
gameReader.printAbove(CHARACTER_DETAILS);
else
gameReader.printAbove("Usage: details buildings | details events | details characters");
}
case "rematch" -> {
if (controller.miniModel == null
|| !controller.miniModel.currentState.getGameStage().equals(GameStages.ENDED)) {