コード例 #1
0
  @Override
  public GameRoom update(Long id, GameRoomDto.Update updateDto) {
    final GameRoom gameRoom = getById(id);

    if (updateDto.getName() != null && !updateDto.getName().isEmpty()) {
      gameRoom.setName(updateDto.getName());
    }

    if (updateDto.getOwner() != null) {
      gameRoom.setOwner(updateDto.getOwner());
    }

    if (updateDto.getPlayers() != null) {
      gameRoom.getPlayers().clear();
      gameRoom.setPlayers(updateDto.getPlayers());
    }

    if (updateDto.getSetting() != null) {
      gameRoom.setSetting(updateDto.getSetting());
    }

    if (updateDto.getGameCount() != null) {
      updateDto.setGameCount(updateDto.getGameCount());
    }

    if (updateDto.getPlayerRankMap() != null) {
      gameRoom.getPlayerRankMap().clear();
      gameRoom.setPlayerRankMap(updateDto.getPlayerRankMap());
    }

    gameRoom.setUpdated(new Date());

    return update(gameRoom);
  }
コード例 #2
0
  private void fillInitData(final GameRoom gameRoom) {
    gameRoom.setStatus(Status.NORMAL);

    gameRoom.getPlayers().add(gameRoom.getOwner());
    gameRoom.getPlayerRankMap().put(1, gameRoom.getOwner());

    final Date now = new Date();
    gameRoom.setCreated(now);
    gameRoom.setUpdated(now);

    gameRoom.setEnabled(Enabled.TRUE);
  }
コード例 #3
0
 private void deleteOperation(GameRoom gameRoom) throws JsonProcessingException {
   gameRoom.setEnabled(Enabled.FALSE);
   gameRoom.getPlayers().clear();
   gameRoom.getPlayerRankMap().clear();
   gameRoom.setDeleted(new Date());
 }