Skip to content

Commit dc939b3

Browse files
committed
fixed quit cli
1 parent f0efbc5 commit dc939b3

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ private void selectReborningPowerUp(@NotNull Game game) throws InterruptedExcept
103103
System.out.println((1 + i) + ". " + game.getActualPlayer().getPowerUps().get(i).getAmmoColor().escape() +
104104
game.getActualPlayer().getPowerUps().get(i).getType().name() + stdColor);
105105
String choice = getLine();
106-
if (choice.equals("q")) Client.API.quitGame(Preferences.getToken(), game.getUuid());
106+
if (choice.equals("q")) {
107+
Client.API.quitGame(Preferences.getToken(), game.getUuid());
108+
return;
109+
}
107110
if (Integer.parseInt(choice) > 0 && Integer.parseInt(choice) <= game.getActualPlayer().getPowerUps().size()) {
108111
try {
109112
if (!Client.API.doAction(Preferences.getToken(), Action.Builder.create(game.getUuid())
@@ -148,7 +151,10 @@ private void selectTagbackResponse(@NotNull Game game) throws InterruptedExcepti
148151
selectableTagbackGrenade.get(i).getType().name() + stdColor);
149152
System.out.println((selectableTagbackGrenade.size() + 1) + ". Non rispondere");
150153
String choice = getLine();
151-
if (choice.equals("q")) Client.API.quitGame(Preferences.getToken(), game.getUuid());
154+
if (choice.equals("q")) {
155+
Client.API.quitGame(Preferences.getToken(), game.getUuid());
156+
return;
157+
}
152158
if (Integer.parseInt(choice) > 0 && Integer.parseInt(choice) <= selectableTagbackGrenade.size())
153159
if (!Client.API.doAction(Preferences.getToken(), Action.Builder.create(game.getUuid()).buildUsePowerUp(selectableTagbackGrenade.get(Integer.parseInt(choice) - 1).getType(),
154160
selectableTagbackGrenade.get(Integer.parseInt(choice) - 1).getAmmoColor(), destination, target)))
@@ -170,7 +176,10 @@ private void selectStandardAction(@NotNull Game game) throws InterruptedExceptio
170176
"standard_actions_plus2").getAsString());
171177
else System.out.println(Utils.getStrings("cli", "possible_actions").get("frenzy_actions"));
172178
String choice = getLine();
173-
if (choice.equals("q")) Client.API.quitGame(Preferences.getToken(), game.getUuid());
179+
if (choice.equals("q")) {
180+
Client.API.quitGame(Preferences.getToken(), game.getUuid());
181+
return;
182+
}
174183
if (Integer.parseInt(choice) > 0 && Integer.parseInt(choice) < 7) {
175184
switch (Integer.parseInt(choice)) {
176185
case 1:
@@ -230,7 +239,10 @@ private void selectLastAction(@NotNull Game game) throws InterruptedException, R
230239
if (Preferences.getToken() == null) throw new InterruptedException();
231240
System.out.println(Utils.getStrings("cli", "possible_actions").get("last_standard_actions").getAsString());
232241
String choice = getLine();
233-
if (choice.equals("q")) Client.API.quitGame(Preferences.getToken(), game.getUuid());
242+
if (choice.equals("q")) {
243+
Client.API.quitGame(Preferences.getToken(), game.getUuid());
244+
return;
245+
}
234246
if (Integer.parseInt(choice) > 0 && Integer.parseInt(choice) < 4) {
235247
switch (Integer.parseInt(choice)) {
236248
case 1:
@@ -259,7 +271,10 @@ private void selectUltimateAction(@NotNull Game game) throws InterruptedExceptio
259271
if (Preferences.getToken() == null) throw new InterruptedException();
260272
System.out.println(Utils.getStrings("cli", "possible_actions").get("last_turn_actions").getAsString());
261273
String choice = getLine();
262-
if (choice.equals("q")) Client.API.quitGame(Preferences.getToken(), game.getUuid());
274+
if (choice.equals("q")) {
275+
Client.API.quitGame(Preferences.getToken(), game.getUuid());
276+
return;
277+
}
263278
if (Integer.parseInt(choice) > 0 && Integer.parseInt(choice) < 6) {
264279
switch (Integer.parseInt(choice)) {
265280
case 1:

0 commit comments

Comments
 (0)