<commit_before>package org.amc.game.chessserver;

import org.amc.game.chess.ChessBoard;
import org.amc.game.chess.ChessGame;
import org.amc.game.chess.ChessGamePlayer;
import org.amc.game.chess.Colour;
import org.amc.game.chess.ComparePlayers;
import org.amc.game.chess.Player;
import org.amc.game.chess.SetupChessBoard;
import org.apache.log4j.Logger;

import javax.persistence.Entity;

@Entity
public class TwoViewServerChessGame extends ServerChessGame {

    private static final long serialVersionUID = 4322777387785605817L;
    private static final Logger logger = Logger.getLogger(TwoViewServerChessGame.class);
    
    public TwoViewServerChessGame() {
        super();
    }
    
    public TwoViewServerChessGame(long uid, Player player) {
        super(uid, player);
      
    }
    
    public TwoViewServerChessGame(long uid, ChessGame chessGame) {
        super(uid, chessGame);
    }
    
    /**
     * Adds player to the black side of the chess game
     * Only valid if ServerChessGame is in AWAITING_PLAYER state, no exception
     * is thrown if not in that state
     * 
     * @param opponent
     *            Player
     */
    public void addOpponent(Player opponent) {
        checkForNull(Player.class, opponent);
        if (ServerGameStatus.AWAITING_PLAYER.equals(getCurrentStatus())) {
            if (ComparePlayers.comparePlayers(getPlayer(), opponent)) {
                logger.debug(String.format("Player:(%s) tried to join their own game",
                                opponent.getName()));
            } else {
                ChessBoard board = new ChessBoard();
                SetupChessBoard.setUpChessBoardToDefault(board);
                synchronized (this) {
                    setChessGame(getChessGameFactory().getChessGame(board, getPlayer(), 
                                    new ChessGamePlayer(opponent, Colour.BLACK)));
                    setCurrentStatus(ServerGameStatus.IN_PROGRESS);
                }
                notifyObservers(opponent);
            }
        }
    }
}
<commit_msg>refactor move method<commit_after>package org.amc.game.chessserver;

import org.amc.game.chess.ChessBoard;
import org.amc.game.chess.ChessGame;
import org.amc.game.chess.ChessGamePlayer;
import org.amc.game.chess.Colour;
import org.amc.game.chess.ComparePlayers;
import org.amc.game.chess.Player;
import org.amc.game.chess.SetupChessBoard;
import org.apache.log4j.Logger;

import javax.persistence.Entity;

@Entity
public class TwoViewServerChessGame extends ServerChessGame {

    private static final long serialVersionUID = 4322777387785605817L;
    private static final Logger logger = Logger.getLogger(TwoViewServerChessGame.class);
    
    public TwoViewServerChessGame() {
        super();
    }
    
    public TwoViewServerChessGame(long uid, Player player) {
        super(uid, player);
      
    }
    
    public TwoViewServerChessGame(long uid, ChessGame chessGame) {
        super(uid, chessGame);
    }
    
    /**
     * Adds player to the black side of the chess game
     * Only valid if ServerChessGame is in AWAITING_PLAYER state, no exception
     * is thrown if not in that state
     * 
     * @param opponent
     *            Player
     */
    public void addOpponent(Player opponent) {
        checkForNull(Player.class, opponent);
        if (isGameAwaitingPlayer()) {
            if (ComparePlayers.comparePlayers(getPlayer(), opponent)) {
                logger.debug(String.format("Player:(%s) tried to join their own game",
                                opponent.getName()));
            } else {
                setupChessGame(opponent);
            }
        }
    }
    
    private boolean isGameAwaitingPlayer() {
        return ServerGameStatus.AWAITING_PLAYER.equals(getCurrentStatus());
    }
    
    private void setupChessGame(Player opponent) {
        ChessBoard board = new ChessBoard();
        SetupChessBoard.setUpChessBoardToDefault(board);
        synchronized (this) {
            setChessGame(getChessGameFactory().getChessGame(board, getPlayer(), 
                            new ChessGamePlayer(opponent, Colour.BLACK)));
            setCurrentStatus(ServerGameStatus.IN_PROGRESS);
        }
        notifyObservers(opponent);
    }
}

{'fraction_non_alphanumeric': 0.08851224105461393, 'fraction_numerical': 0.009416195856873822, 'mean_word_length': 2.4742436631234668, '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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6720699', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1230, 'n_words': 250}