Skip to content

Commit f0efbc5

Browse files
committed
fixed quit cli
1 parent cde800a commit f0efbc5

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

client/src/main/java/it/polimi/ingsw/client/views/cli/ActionManager.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ private void clearAll() {
5858
}
5959

6060
void actionMenu(@NotNull Game game) throws RemoteException {
61+
System.out.println("Per uscire dalla partita premere 'q'");
6162
try {
6263
if (game.getActualPlayer().getPosition() == null) {
6364
System.out.println(game.getActualPlayer().getNickname() + " è la tua prima mossa: scegli " +
@@ -85,7 +86,7 @@ void actionMenu(@NotNull Game game) throws RemoteException {
8586
}
8687
}
8788

88-
private void selectReborningPowerUp(@NotNull Game game) throws InterruptedException {
89+
private void selectReborningPowerUp(@NotNull Game game) throws InterruptedException, RemoteException {
8990
if (Preferences.getToken() == null) throw new InterruptedException();
9091
if (game.getActualPlayer().getPowerUps().size() == 1) {
9192
try {
@@ -102,6 +103,7 @@ private void selectReborningPowerUp(@NotNull Game game) throws InterruptedExcept
102103
System.out.println((1 + i) + ". " + game.getActualPlayer().getPowerUps().get(i).getAmmoColor().escape() +
103104
game.getActualPlayer().getPowerUps().get(i).getType().name() + stdColor);
104105
String choice = getLine();
106+
if (choice.equals("q")) Client.API.quitGame(Preferences.getToken(), game.getUuid());
105107
if (Integer.parseInt(choice) > 0 && Integer.parseInt(choice) <= game.getActualPlayer().getPowerUps().size()) {
106108
try {
107109
if (!Client.API.doAction(Preferences.getToken(), Action.Builder.create(game.getUuid())
@@ -146,6 +148,7 @@ private void selectTagbackResponse(@NotNull Game game) throws InterruptedExcepti
146148
selectableTagbackGrenade.get(i).getType().name() + stdColor);
147149
System.out.println((selectableTagbackGrenade.size() + 1) + ". Non rispondere");
148150
String choice = getLine();
151+
if (choice.equals("q")) Client.API.quitGame(Preferences.getToken(), game.getUuid());
149152
if (Integer.parseInt(choice) > 0 && Integer.parseInt(choice) <= selectableTagbackGrenade.size())
150153
if (!Client.API.doAction(Preferences.getToken(), Action.Builder.create(game.getUuid()).buildUsePowerUp(selectableTagbackGrenade.get(Integer.parseInt(choice) - 1).getType(),
151154
selectableTagbackGrenade.get(Integer.parseInt(choice) - 1).getAmmoColor(), destination, target)))
@@ -167,6 +170,7 @@ private void selectStandardAction(@NotNull Game game) throws InterruptedExceptio
167170
"standard_actions_plus2").getAsString());
168171
else System.out.println(Utils.getStrings("cli", "possible_actions").get("frenzy_actions"));
169172
String choice = getLine();
173+
if (choice.equals("q")) Client.API.quitGame(Preferences.getToken(), game.getUuid());
170174
if (Integer.parseInt(choice) > 0 && Integer.parseInt(choice) < 7) {
171175
switch (Integer.parseInt(choice)) {
172176
case 1:
@@ -226,6 +230,7 @@ private void selectLastAction(@NotNull Game game) throws InterruptedException, R
226230
if (Preferences.getToken() == null) throw new InterruptedException();
227231
System.out.println(Utils.getStrings("cli", "possible_actions").get("last_standard_actions").getAsString());
228232
String choice = getLine();
233+
if (choice.equals("q")) Client.API.quitGame(Preferences.getToken(), game.getUuid());
229234
if (Integer.parseInt(choice) > 0 && Integer.parseInt(choice) < 4) {
230235
switch (Integer.parseInt(choice)) {
231236
case 1:
@@ -254,6 +259,7 @@ private void selectUltimateAction(@NotNull Game game) throws InterruptedExceptio
254259
if (Preferences.getToken() == null) throw new InterruptedException();
255260
System.out.println(Utils.getStrings("cli", "possible_actions").get("last_turn_actions").getAsString());
256261
String choice = getLine();
262+
if (choice.equals("q")) Client.API.quitGame(Preferences.getToken(), game.getUuid());
257263
if (Integer.parseInt(choice) > 0 && Integer.parseInt(choice) < 6) {
258264
switch (Integer.parseInt(choice)) {
259265
case 1:

0 commit comments

Comments
 (0)