public static Response parseGameAction(MessageBuffer msg) { msg.reset(); Int32 size = msg.popInt(); Int16 action = msg.popShort(); Int32 timeStep = msg.popInt(); Int16 playerId = msg.popShort(); Int32 xPos = msg.popInt(); Int32 yPos = msg.popInt(); switch (action) { case Constants.POINTER_LOCATION: return new PointerLocationResponse(timeStep, playerId, xPos, yPos); case Constants.SELECTED_CASTLE: return new SelectedCastleResponse(timeStep, playerId, xPos, yPos); case Constants.PLACED_CANNON: return new PlacedCannonResponse(timeStep, playerId, xPos, yPos); case Constants.FIRED_CANNON: return new FiredCannonResponse(timeStep, playerId, xPos, yPos); case Constants.ROTATED_WALL: return new RotatedWallResponse(timeStep, playerId, xPos, yPos); case Constants.PLACED_WALL: return new PlacedWallResponse(timeStep, playerId, xPos, yPos); default: return null; } }
public static Response parseDenyJoinRoom(MessageBuffer msg) { msg.reset(); Int32 size = msg.popInt(); Int16 action = msg.popShort(); string roomName = msg.popString(); return new RoomNotJoinedResponse(roomName); }
public static Response parseEndGame(MessageBuffer msg) { msg.reset(); Int32 size = msg.popInt(); Int16 action = msg.popShort(); Int16 winnerID = msg.popShort(); return new EndGameResponse(winnerID); }
public static Response parseAuthAction(MessageBuffer msg) { msg.reset(); Int32 size = msg.popInt(); Int16 action = msg.popShort(); Int16 result = msg.popShort(); return new LoginResponse(result); }
public static Response parseCreateRoom(MessageBuffer msg) { msg.reset(); Int32 size = msg.popInt(); Int16 action = msg.popShort(); Int16 result = msg.popShort(); string roomName = msg.popString(); return new RoomCreatedResponse(result, roomName); }
public static Response parseAllowJoinRoom(MessageBuffer msg) { msg.reset(); Int32 size = msg.popInt(); Int16 action = msg.popShort(); Int16 numPlayers = msg.popShort(); string roomName = msg.popString(); List<string> playerNames = new List<string>(numPlayers); for (int i = 0; i < numPlayers; i++) playerNames.Add(msg.popString()); return new RoomJoinedResponse(roomName, playerNames, numPlayers); }
public static Response parseLeaveRoom(MessageBuffer msg) { msg.reset(); Int32 size = msg.popInt(); Int16 action = msg.popShort(); string userName = msg.popString(); string roomName = msg.popString(); return new PlayerLeftRoomResponse(userName, roomName); }
public static Response parseStartGame(MessageBuffer msg) { msg.reset(); Int32 size = msg.popInt(); Int16 action = msg.popShort(); Int16 numPlayers = msg.popShort(); List<Int16> playerIds = new List<Int16>(numPlayers); for (int i = 0; i < numPlayers; i++) playerIds.Add(msg.popShort()); List<string> playerNames = new List<string>(numPlayers); for (int i = 0; i < numPlayers; i++) playerNames.Add(msg.popString()); string map = msg.popString(); return new StartGameResponse(playerNames, map); }
public static Response parseSendAvailableRooms(MessageBuffer msg) { msg.reset(); Int32 size = msg.popInt(); Int16 action = msg.popShort(); Int16 numRooms = msg.popShort(); List<string> roomNames = new List<string>(numRooms); for (int i = 0; i < numRooms; i++) roomNames.Add(msg.popString()); List<Room> rooms = new List<Room>(numRooms); for (int i = 0; i < numRooms; i++) rooms.Add(new Room(roomNames[i], 2)); return new RoomsAvailableResponse(rooms); }