code cleanup
parent
49a78142d5
commit
1d7b378b52
|
@ -29,30 +29,31 @@ public class Client implements Runnable {
|
||||||
|
|
||||||
sendMessage(new Message.Sent(PacketTable.CONNECT, 0, ++lastMessageID));
|
sendMessage(new Message.Sent(PacketTable.CONNECT, 0, ++lastMessageID));
|
||||||
|
|
||||||
String prompt;
|
|
||||||
while (running) {
|
while (running) {
|
||||||
|
String prompt;
|
||||||
if ((prompt = view.nextInput()) != null) {
|
if ((prompt = view.nextInput()) != null) {
|
||||||
if (prompt.trim().isEmpty())
|
if (prompt.trim().isEmpty())
|
||||||
continue;
|
continue;
|
||||||
if (prompt.charAt(0) == '6')
|
if (prompt.charAt(0) == '6')
|
||||||
break;
|
break;
|
||||||
|
byte messageType;
|
||||||
switch (prompt.charAt(0)) {
|
switch (prompt.charAt(0)) {
|
||||||
case '1':
|
case '1':
|
||||||
Message.Sent buildMessage = new Message.Sent(PacketTable.BUILD,0,++lastMessageID);
|
messageType = PacketTable.BUILD;
|
||||||
buildMessage.getData().write(prompt.substring(1).getBytes());
|
|
||||||
sendMessage(buildMessage);
|
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
Message.Sent trainMessage = new Message.Sent(PacketTable.TRAIN,0,++lastMessageID);
|
messageType = PacketTable.TRAIN;
|
||||||
trainMessage.getData().write(prompt.substring(1).getBytes());
|
|
||||||
sendMessage(trainMessage);
|
|
||||||
break;
|
break;
|
||||||
case '3':
|
case '3':
|
||||||
Message.Sent upgradeMessage = new Message.Sent(PacketTable.UPGRADE,0,++lastMessageID);
|
messageType = PacketTable.UPGRADE;
|
||||||
upgradeMessage.getData().write(prompt.substring(1).getBytes());
|
|
||||||
sendMessage(upgradeMessage);
|
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
System.err.println("> Invalid command input!");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
Message.Sent buildMessage = new Message.Sent(messageType,0,++lastMessageID);
|
||||||
|
buildMessage.getData().write(prompt.substring(1).getBytes());
|
||||||
|
sendMessage(buildMessage);
|
||||||
|
|
||||||
view.printGameMenu();
|
view.printGameMenu();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue