Wrote tests that are currently broken for sending server commands through text chat.

#tests
This commit is contained in:
Calum
2017-09-03 20:38:31 +12:00
parent 88d1e91b6f
commit 5026c568a7
6 changed files with 208 additions and 32 deletions
@@ -386,32 +386,34 @@ public class ServerToClientThread implements Runnable, Observer {
Arrays.copyOfRange(chatterPayload, 3, 3 + chatterPayload.length)
);
String[] words = chatterText.split("\\s+");
if (words.length < 3) {
return;
for (String s : words) {
System.out.println(s);
}
switch (words[2].trim()) {
case ">speed":
try {
GameState.setSpeedMultiplier(Double.valueOf(words[3]));
if (words.length > 2 && isHost) {
switch (words[2].trim()) {
case ">speed":
try {
GameState.setSpeedMultiplier(Double.valueOf(words[3]));
GameState.broadcastChatter(new ChatterMessage(
Byte.toUnsignedInt(chatterPayload[1]),
words[0] + "Host has set speed modifier to x" + words[3]
));
} catch (Exception e) {
logger.error("cannot parse >speed value");
}
return;
case ">finish":
System.out.println(words[2].trim());
GameState.endRace();
GameState.broadcastChatter(new ChatterMessage(
Byte.toUnsignedInt(chatterPayload[1]),
words[0] + "Host has set speed modifier to x" + words[3]
chatterPayload[1],
words[0] + "Host has ended the game"
));
} catch (Exception e) {
logger.error("cannot parse >speed value");
}
break;
case ">finish":
GameState.endRace();
GameState.broadcastChatter(new ChatterMessage(
chatterPayload[1],
words[0] + "Host has ended the game"
));
break;
default:
GameState.broadcastChatter(
ServerPacketParser.extractChatterText(chatterPayload)
);
return;
}
}
GameState.broadcastChatter(
ServerPacketParser.extractChatterText(chatterPayload)
);
}
}