<commit_before>package net.rk.splendid;

import net.rk.splendid.dao.GameDao;
import net.rk.splendid.dao.entities.GameEntity;
import net.rk.splendid.dao.entities.OfyGameState;
import net.rk.splendid.dto.GameConfig;
import net.rk.splendid.dto.GameState;
import net.rk.splendid.game.GameActions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/game")
public final class GameDataController {
  @Autowired private GameDao gameDao;
  @Autowired private CommonSessionParameters commonSessionParameters;

  @ModelAttribute
  public void handleCommonAttributes(
      @RequestParam("id") String gameRefId,
      @RequestParam(value = "playerToken", required = false) String playerToken) {
    commonSessionParameters.setGameRef(gameRefId);
    commonSessionParameters.setPlayerToken(playerToken);
  }

  @RequestMapping("/getConfig")
  public GameConfig getGameConfig() {
    return gameDao.getGameConfigImpl();
  }

  @RequestMapping("/getState")
  public GameState getGameState() {
    GameEntity gameEntity = gameDao.getGameEntity();
    return OfyGameState.toDto(
        gameDao.getGameStateImpl(),
        gameEntity.getGameConfig(),
        commonSessionParameters.getPlayerToken());
  }

  @RequestMapping("/act")
  public GameState executePlayerAction(
      @RequestParam("action") String action,
      @RequestParam("payload") String payload) {
    GameEntity gameEntity = gameDao.getGameEntity();
    OfyGameState oldState = gameEntity.getGameState();
    OfyGameState newState = GameActions.GetAction(action, payload)
        .apply(commonSessionParameters.getPlayerToken(), oldState);
    gameDao.updateGameStateImpl(newState);
    return OfyGameState.toDto(
        newState,
        gameEntity.getGameConfig(),
        commonSessionParameters.getPlayerToken());
  }

  @RequestMapping("/join")
  public GameConfig joinGame(
      CommonSessionParameters sessionParams,
      @RequestParam("playerName") String playerName) {<commit_msg>Removing CommonSessionParameters argument from joinGame handler.<commit_after>package net.rk.splendid;

import net.rk.splendid.dao.GameDao;
import net.rk.splendid.dao.entities.GameEntity;
import net.rk.splendid.dao.entities.OfyGameState;
import net.rk.splendid.dto.GameConfig;
import net.rk.splendid.dto.GameState;
import net.rk.splendid.game.GameActions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/game")
public final class GameDataController {
  @Autowired private GameDao gameDao;
  @Autowired private CommonSessionParameters commonSessionParameters;

  @ModelAttribute
  public void handleCommonAttributes(
      @RequestParam("id") String gameRefId,
      @RequestParam(value = "playerToken", required = false) String playerToken) {
    commonSessionParameters.setGameRef(gameRefId);
    commonSessionParameters.setPlayerToken(playerToken);
  }

  @RequestMapping("/getConfig")
  public GameConfig getGameConfig() {
    return gameDao.getGameConfigImpl();
  }

  @RequestMapping("/getState")
  public GameState getGameState() {
    GameEntity gameEntity = gameDao.getGameEntity();
    return OfyGameState.toDto(
        gameDao.getGameStateImpl(),
        gameEntity.getGameConfig(),
        commonSessionParameters.getPlayerToken());
  }

  @RequestMapping("/act")
  public GameState executePlayerAction(
      @RequestParam("action") String action,
      @RequestParam("payload") String payload) {
    GameEntity gameEntity = gameDao.getGameEntity();
    OfyGameState oldState = gameEntity.getGameState();
    OfyGameState newState = GameActions.GetAction(action, payload)
        .apply(commonSessionParameters.getPlayerToken(), oldState);
    gameDao.updateGameStateImpl(newState);
    return OfyGameState.toDto(
        newState,
        gameEntity.getGameConfig(),
        commonSessionParameters.getPlayerToken());
  }

  @RequestMapping("/join")
  public GameConfig joinGame(@RequestParam("playerName") String playerName) {
{'fraction_non_alphanumeric': 0.10082534017399063, 'fraction_numerical': 0.0, 'mean_word_length': 5.142465753424657, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1212563', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1264, 'n_words': 218}