Fix: all JavaDOC completed
This commit is contained in:
@@ -25,13 +25,13 @@ import static org.jline.builtins.Completers.TreeCompleter.node;
|
||||
* Handles login, connects to the server, and drives the JLine-powered command loop.
|
||||
*/
|
||||
public class ClientLauncherTUI {
|
||||
//TODO
|
||||
/** TUI view shared with the client controller. */
|
||||
private TUI view;
|
||||
//TODO
|
||||
/** JLine terminal used for all input/output. */
|
||||
private Terminal terminal;
|
||||
//TODO
|
||||
/** Line reader used during active gameplay, with tab-completion wired. */
|
||||
private LineReader gameReader;
|
||||
//TODO
|
||||
/** Username of the currently logged-in player; empty string before login. */
|
||||
private String currentUsername = "";
|
||||
|
||||
private static final String BUILDING_DETAILS =
|
||||
@@ -81,7 +81,12 @@ public class ClientLauncherTUI {
|
||||
"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').";
|
||||
//TODO
|
||||
/**
|
||||
* Launches the TUI client.
|
||||
*
|
||||
* @param args command-line arguments (unused).
|
||||
* @throws InterruptedException if the thread is interrupted during startup.
|
||||
*/
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
new ClientLauncherTUI().start();
|
||||
}
|
||||
@@ -132,7 +137,12 @@ public class ClientLauncherTUI {
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO
|
||||
/**
|
||||
* Prompts for username, player count, network type, and server IP, then connects.
|
||||
*
|
||||
* @param controller the client controller to connect.
|
||||
* @return {@code true} on successful connection; {@code false} if input is invalid or connection fails.
|
||||
*/
|
||||
private boolean doLogin(ClientController controller) {
|
||||
LineReader loginReader = LineReaderBuilder.builder()
|
||||
.terminal(terminal)
|
||||
@@ -202,7 +212,12 @@ public class ClientLauncherTUI {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//TODO
|
||||
/**
|
||||
* Builds the JLine {@link LineReader} used during gameplay, with tab-completion
|
||||
* for all valid commands.
|
||||
*
|
||||
* @return the configured {@link LineReader}.
|
||||
*/
|
||||
private LineReader buildGameReader() {
|
||||
Completer completer = new TreeCompleter(
|
||||
node("slot"),
|
||||
@@ -227,7 +242,12 @@ public class ClientLauncherTUI {
|
||||
.option(LineReader.Option.DISABLE_EVENT_EXPANSION, true)
|
||||
.build();
|
||||
}
|
||||
//TODO
|
||||
/**
|
||||
* Returns the command-line prompt string showing the current username.
|
||||
*
|
||||
* @param controller the client controller (reserved for future use).
|
||||
* @return the prompt string.
|
||||
*/
|
||||
private String buildPrompt(ClientController controller) {
|
||||
return currentUsername.isEmpty() ? "> " : currentUsername + "> ";
|
||||
}
|
||||
@@ -279,7 +299,12 @@ public class ClientLauncherTUI {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//TODO
|
||||
/**
|
||||
* Handles the {@code draw} command, dispatching to the appropriate controller draw method.
|
||||
*
|
||||
* @param parts the tokenised command: {@code [draw, upper|lower, tribe|building, pos]}.
|
||||
* @param controller the client controller to invoke.
|
||||
*/
|
||||
private void handleDraw(String[] parts, ClientController controller) {
|
||||
if (parts.length < 4) {
|
||||
view.showError(ErrorType.GENERIC_ERROR, "Usage: draw upper|lower tribe|building <pos>");
|
||||
@@ -295,11 +320,21 @@ public class ClientLauncherTUI {
|
||||
else if (tribe) controller.drawLowerTribeCard(pos);
|
||||
else controller.drawLowerBuildingCard(pos);
|
||||
}
|
||||
//TODO
|
||||
/**
|
||||
* Handles the {@code clear} command by triggering a full board re-render.
|
||||
*
|
||||
* @param parts the tokenised command (only the command token is used).
|
||||
*/
|
||||
private void handleRender(String[] parts) {
|
||||
view.renderBoard();
|
||||
}
|
||||
//TODO
|
||||
/**
|
||||
* Parses an integer position argument at {@code idx} in {@code parts}.
|
||||
*
|
||||
* @param parts the tokenised command array.
|
||||
* @param idx index of the position argument.
|
||||
* @return the parsed integer, or {@code -1} if missing or malformed.
|
||||
*/
|
||||
private int parsePos(String[] parts, int idx) {
|
||||
if (parts.length <= idx) {
|
||||
view.showError(ErrorType.GENERIC_ERROR, "Missing position argument.");
|
||||
@@ -313,7 +348,11 @@ public class ClientLauncherTUI {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
//TODO
|
||||
/**
|
||||
* Disconnects the client if one is currently connected; safe to call when already disconnected.
|
||||
*
|
||||
* @param controller the client controller to disconnect.
|
||||
*/
|
||||
private void safeQuit(ClientController controller) {
|
||||
if (controller.getClient() != null) controller.disconnect();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user