FIx: case sensitive
This commit is contained in:
@@ -4,6 +4,9 @@ import it.polimi.ingsw.gc14.Network.NetworkEvent;
|
|||||||
import it.polimi.ingsw.gc14.Network.RMI.Client.RMIClient;
|
import it.polimi.ingsw.gc14.Network.RMI.Client.RMIClient;
|
||||||
import it.polimi.ingsw.gc14.Network.TCP.Client.TCPClient;
|
import it.polimi.ingsw.gc14.Network.TCP.Client.TCPClient;
|
||||||
import it.polimi.ingsw.gc14.View.TUI.TUI;
|
import it.polimi.ingsw.gc14.View.TUI.TUI;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,6 +17,8 @@ import java.util.Scanner;
|
|||||||
*/
|
*/
|
||||||
public class ClientLauncherTUI {
|
public class ClientLauncherTUI {
|
||||||
|
|
||||||
|
List<String> admissibleChar=new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The TUI view associated with this client.
|
* The TUI view associated with this client.
|
||||||
*/
|
*/
|
||||||
@@ -29,6 +34,23 @@ public class ClientLauncherTUI {
|
|||||||
*/
|
*/
|
||||||
public void main() throws InterruptedException {
|
public void main() throws InterruptedException {
|
||||||
view = new TUI(null);
|
view = new TUI(null);
|
||||||
|
admissibleChar.add("0");
|
||||||
|
admissibleChar.add("1");
|
||||||
|
admissibleChar.add("2");
|
||||||
|
admissibleChar.add("3");
|
||||||
|
admissibleChar.add("4");
|
||||||
|
admissibleChar.add("5");
|
||||||
|
admissibleChar.add("6");
|
||||||
|
admissibleChar.add("7");
|
||||||
|
admissibleChar.add("8");
|
||||||
|
admissibleChar.add("9");
|
||||||
|
admissibleChar.add("A");
|
||||||
|
admissibleChar.add("B");
|
||||||
|
admissibleChar.add("C");
|
||||||
|
admissibleChar.add("a");
|
||||||
|
admissibleChar.add("b");
|
||||||
|
admissibleChar.add("c");
|
||||||
|
|
||||||
ClientController controller = new ClientController(view);
|
ClientController controller = new ClientController(view);
|
||||||
Scanner scanner = new Scanner(System.in);
|
Scanner scanner = new Scanner(System.in);
|
||||||
System.out.println("Insert username: ");
|
System.out.println("Insert username: ");
|
||||||
@@ -103,29 +125,37 @@ public class ClientLauncherTUI {
|
|||||||
private void getInput(Scanner scanner, ClientController controller, String username) {
|
private void getInput(Scanner scanner, ClientController controller, String username) {
|
||||||
String action = scanner.next();
|
String action = scanner.next();
|
||||||
int pos = -1;
|
int pos = -1;
|
||||||
if (!action.equals("7") && !action.equals("8") && !action.equals("9") && !action.equals("A") && !action.equals("B") && !action.equals("C")) {
|
|
||||||
try {
|
if(admissibleChar.contains(username))
|
||||||
System.out.println("Insert the required position:");
|
{
|
||||||
pos = scanner.nextInt();
|
if (!action.equals("7") && !action.equals("8") && !action.equals("9") && !action.equals("A") && !action.equals("B") && !action.equals("C")) {
|
||||||
} catch (Exception e) {
|
try {
|
||||||
System.out.println("ERROR: Invalid input(expected number)");
|
System.out.println("Insert the required position:");
|
||||||
|
pos = scanner.nextInt();
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("ERROR: Invalid input(expected number)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch (action) {
|
||||||
|
case "0" -> controller.slotChoice(username, pos);
|
||||||
|
case "1" -> controller.drawUpperTribeCard(username, pos);
|
||||||
|
case "2" -> controller.drawUpperBuildingCard(username, pos);
|
||||||
|
case "3" -> controller.drawLowerTribeCard(username, pos);
|
||||||
|
case "4" -> controller.drawLowerBuildingCard(username, pos);
|
||||||
|
case "5" -> controller.pickOptionalTribeCard(username, pos);
|
||||||
|
case "6" -> controller.pickOptionalBuildingCard(username, pos);
|
||||||
|
case "7" -> controller.noOptionalCard(username);
|
||||||
|
case "8" -> controller.skipUpper(username);
|
||||||
|
case "9" -> controller.skipLower(username);
|
||||||
|
case "A", "a" -> view.fullRender();
|
||||||
|
case "B", "b" -> view.renderBoard();
|
||||||
|
case "C", "c" -> view.renderPlayer();
|
||||||
|
default -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (action) {
|
else
|
||||||
case "0" -> controller.slotChoice(username, pos);
|
{
|
||||||
case "1" -> controller.drawUpperTribeCard(username, pos);
|
System.out.println("ERROR: Invalid input(action not valid)");
|
||||||
case "2" -> controller.drawUpperBuildingCard(username, pos);
|
|
||||||
case "3" -> controller.drawLowerTribeCard(username, pos);
|
|
||||||
case "4" -> controller.drawLowerBuildingCard(username, pos);
|
|
||||||
case "5" -> controller.pickOptionalTribeCard(username, pos);
|
|
||||||
case "6" -> controller.pickOptionalBuildingCard(username, pos);
|
|
||||||
case "7" -> controller.noOptionalCard(username);
|
|
||||||
case "8" -> controller.skipUpper(username);
|
|
||||||
case "9" -> controller.skipLower(username);
|
|
||||||
case "A" -> view.fullRender();
|
|
||||||
case "B" -> view.renderBoard();
|
|
||||||
case "C" -> view.renderPlayer();
|
|
||||||
default -> {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user