private void processCommandAndArgument(String command, String arg, ClientThread thread) throws CommandException { if (command.equals("HELLO")) { // HELLO if (arg == null) {throw new CommandException("HELLO needs an argument");} String name = sanitiseMessage(arg); ChildCSC.clientHello(game, name, thread); outputMessage("HELLO " + name); } else if (command.equals("LOOK")) { // LOOK if (arg != null) {throw new CommandException("LOOK does not take an argument");} outputMessage("LOOKREPLY" + System.getProperty("line.separator") + ChildCSC.clientLook(game, thread)); } else if (command.equals("PICKUP")) { // PICKUP if (arg != null) {throw new CommandException("PICKUP does not take an argument");} ChildCSC.clientPickup(game, thread); outputSuccess(); } else if (command.equals("MOVE")) { // MOVE if (arg == null) {throw new CommandException("MOVE needs a direction");} ChildCSC.clientMove(getDirection(arg), game, thread); outputSuccess(); //check to see if this has changed someones map ChildCSC.checkChange(game, thread); // Notify the client of the success ChildCSC.advanceTurn(game, thread); } else if (command.equals("CHAT")) { // CHAT if (arg == null) {throw new CommandException("CHAT needs a Message");} ChildCSC.clientCHAT(game, arg); } else if (command.equals("ATTACK")) { // ATTACK // We need to know which direction to move in. if (arg == null) {throw new CommandException("ATTACK needs a direction");} ChildCSC.clientAttack(getDirection(arg), game, thread); outputSuccess(); } else if (command.equals("ENDTURN")) { // ENDTURN ChildCSC.clientEndTurn(game, thread); } else if (command.equals("SHOUT")) { // SHOUT // Ensure they have given us something to shout. if (arg == null) {throw new CommandException("need something to shout");} ChildCSC.clientShout(sanitiseMessage(arg), game, thread); outputSuccess(); } else { // If it is none of the above then it must be a bad command. throw new CommandException("Invalid Command"); } }