use of com.faforever.server.game.PlayerOptionReport in project faf-java-server by FAForever.
the class LegacyRequestTransformer method transform.
@Override
public ClientMessage transform(Map<String, Object> source) {
String command = (String) source.get("command");
LegacyClientMessageType messageType = LegacyClientMessageType.fromString(command);
Requests.verify(messageType != null, ErrorCode.INVALID_COMMAND, command);
switch(messageType) {
case HOST_GAME:
return handleHostGame(source);
case JOIN_GAME:
return new JoinGameRequest(((Number) source.get("uid")).intValue(), (String) source.get("password"));
case ASK_SESSION:
String userAgent = (String) source.get("user_agent");
return LegacySessionRequest.forUserAgent(userAgent);
case SOCIAL_ADD:
return handleSocialAdd(source);
case SOCIAL_REMOVE:
return handleSocialRemove(source);
case LOGIN:
return handleLogin(source);
case GAME_MATCH_MAKING:
return handleMatchMaking(source);
case AVATAR:
return handleAvatar(source);
case GAME_STATE:
return handleGameState(source);
case GAME_OPTION:
List<Object> args = getArgs(source);
return new GameOptionReport((String) args.get(0), args.get(1));
case PLAYER_OPTION:
args = getArgs(source);
return new PlayerOptionReport(Integer.parseInt((String) args.get(0)), (String) args.get(1), args.get(2));
case CLEAR_SLOT:
args = getArgs(source);
return ClearSlotRequest.valueOf((int) args.get(0));
case DESYNC:
return DesyncReport.INSTANCE;
case GAME_MODS:
return handleGameMods(source);
case GAME_RESULT:
return handleGameResult(source);
case OPERATION_COMPLETE:
return handleOperationComplete(source);
case JSON_STATS:
return handleJsonStats(source);
case ENFORCE_RATING:
return PlayerDefeatedReport.INSTANCE;
case TEAMKILL_REPORT:
return handleTeamKillReport(source);
case MUTUAL_DRAW:
return MutuallyAgreedDrawRequest.INSTANCE;
case AI_OPTION:
return handleAiOption(source);
case INITIATE_TEST:
throw new RequestException(ErrorCode.UNSUPPORTED_REQUEST, source);
case ICE_SERVERS:
return IceServersRequest.INSTANCE;
case ICE_MESSAGE:
args = getArgs(source);
return new IceMessage((int) args.get(0), args.get(1));
case RESTORE_GAME_SESSION:
return new RestoreGameSessionRequest((int) source.get("game_id"));
case CREATE_ACCOUNT:
throw new RequestException(ErrorCode.CREATE_ACCOUNT_IS_DEPRECATED);
case ADMIN:
return handleAdminAction(source);
case DISCONNECTED:
return DisconnectedReport.INSTANCE;
case BOTTLENECK:
return BottleneckReport.INSTANCE;
case CHAT:
return handleGameChatMessage((String) getArgs(source).get(0));
case BOTTLENECK_CLEARED:
return BottleneckClearedReport.INSTANCE;
default:
throw new ProgrammingError("Uncovered message type: " + messageType);
}
}
use of com.faforever.server.game.PlayerOptionReport in project faf-java-server by FAForever.
the class V2ClientMessageTransformerTest method playerOption.
@Test
public void playerOption() throws Exception {
ClientMessage result = instance.transform(write(new PlayerOptionClientMessage(123, "key", "value")));
assertThat(result, is(new PlayerOptionReport(123, "key", "value")));
}
use of com.faforever.server.game.PlayerOptionReport in project faf-java-server by FAForever.
the class GameServiceActivatorsTest method updatePlayerOption.
@Test
public void updatePlayerOption() throws Exception {
instance.updatePlayerOption(new PlayerOptionReport(1, "key", "value"), clientConnection.getAuthentication());
verify(gameService).updatePlayerOption(player, 1, "key", "value");
}
use of com.faforever.server.game.PlayerOptionReport in project faf-java-server by FAForever.
the class LegacyRequestTransformerTest method transformPlayerOption.
@Test
public void transformPlayerOption() throws Exception {
PlayerOptionReport playerOptionReport = (PlayerOptionReport) instance.transform(ImmutableMap.of(KEY_COMMAND, "PlayerOption", KEY_ARGS, Arrays.asList("1", "Faction", 3)));
assertThat(playerOptionReport, is(notNullValue()));
assertThat(playerOptionReport.getPlayerId(), is(1));
assertThat(playerOptionReport.getKey(), is("Faction"));
assertThat(playerOptionReport.getValue(), is(3));
}
Aggregations