<commit_before>import java.rmi.RemoteException;
import java.util.*;

public class BoardHandlerImpl implements IBoardHandler {

    private Map<String, String> lastSelectedUserMapToGameId = new HashMap<>();
    private List<IUser> listOfUsers = new ArrayList<>();
    private Map<String, IUser> ownersOfSymbols = new HashMap<>();
    private final List<String> availableSymbolsToTake = Arrays.asList("X", "Y");
    private Map<String, IBoardListener> userListenerMap = new HashMap<>();
    private Map<String, Board> gameIdToBoardMap = new HashMap<>();

    @Override
    public String register(IUser user, IBoardListener l, String gameId) throws RemoteException, UserRejectedException {
        if (!userListenerMap.containsKey(user.getNick()) && userListenerMap.size() < 2 && ownersOfSymbols.size() < 2) {
            userListenerMap.put(user.getNick(), l);
            listOfUsers.add(user);
            String selectedSymbol = getFreeUserSymbol();
            user.setSymbol(selectedSymbol);
            System.out.println(String.format("User %s is now registered with symbol %s, gameid %s", user.getNick(), user.getSymbol(), user.getGameId()));

            if (gameIdToBoardMap.get(gameId) == null) {
                Board board = new Board();
                gameIdToBoardMap.put(gameId, board);
            }
            ownersOfSymbols.put(selectedSymbol, user);


            return selectedSymbol;
        } else {
            return "";
        }
    }

    private void nextTurn(String gameId) throws RemoteException {
        if (userListenerMap.size() == 2) {
            final String lastSelectedUser = lastSelectedUserMapToGameId.get(gameId);
            System.out.println("Next turn!");
            if (lastSelectedUser == null) {
                lastSelectedUserMapToGameId.put(gameId, listOfUsers.stream().filter(user -> {
                    try {
                        return Objects.equals(user.getGameId(), gameId);
                    } catch (RemoteException e) {
                        e.printStackTrace();
                        return false;
                    }
                }).findFirst().get().getNick());
            } else {
                lastSelectedUserMapToGameId.put(gameId, listOfUsers.stream().filter(user -> {
                    try {
                        return !Objects.equals(user.getNick(), lastSelectedUser);
                    } catch (RemoteException e) {
                        e.printStackTrace();
                        return false;
                    }
                }).findFirst().get().getNick());
            }
            requestMoveFromClient(lastSelectedUser, gameId);
        }
    }

    @Override
    public void requestFirstMove(String gameId) {<commit_msg>-Null poinet bug weith last selected<commit_after>import java.rmi.RemoteException;
import java.util.*;

public class BoardHandlerImpl implements IBoardHandler {

    private Map<String, String> lastSelectedUserMapToGameId = new HashMap<>();
    private List<IUser> listOfUsers = new ArrayList<>();
    private Map<String, IUser> ownersOfSymbols = new HashMap<>();
    private final List<String> availableSymbolsToTake = Arrays.asList("X", "Y");
    private Map<String, IBoardListener> userListenerMap = new HashMap<>();
    private Map<String, Board> gameIdToBoardMap = new HashMap<>();

    @Override
    public String register(IUser user, IBoardListener l, String gameId) throws RemoteException, UserRejectedException {
        if (!userListenerMap.containsKey(user.getNick()) && userListenerMap.size() < 2 && ownersOfSymbols.size() < 2) {
            userListenerMap.put(user.getNick(), l);
            listOfUsers.add(user);
            String selectedSymbol = getFreeUserSymbol();
            user.setSymbol(selectedSymbol);
            System.out.println(String.format("User %s is now registered with symbol %s, gameid %s", user.getNick(), user.getSymbol(), user.getGameId()));

            if (gameIdToBoardMap.get(gameId) == null) {
                Board board = new Board();
                gameIdToBoardMap.put(gameId, board);
            }
            ownersOfSymbols.put(selectedSymbol, user);


            return selectedSymbol;
        } else {
            return "";
        }
    }

    private void nextTurn(String gameId) throws RemoteException {
        if (userListenerMap.size() == 2) {
            final String lastSelectedUser = lastSelectedUserMapToGameId.get(gameId);
            System.out.println("Next turn!");
            if (lastSelectedUser == null) {
                lastSelectedUserMapToGameId.put(gameId, listOfUsers.stream().filter(user -> {
                    try {
                        return Objects.equals(user.getGameId(), gameId);
                    } catch (RemoteException e) {
                        e.printStackTrace();
                        return false;
                    }
                }).findFirst().get().getNick());
            } else {
                lastSelectedUserMapToGameId.put(gameId, listOfUsers.stream().filter(user -> {
                    try {
                        return !Objects.equals(user.getNick(), lastSelectedUser);
                    } catch (RemoteException e) {
                        e.printStackTrace();
                        return false;
                    }
                }).findFirst().get().getNick());
            }
            requestMoveFromClient(lastSelectedUserMapToGameId.get(gameId), gameId);
        }
    }

    @Override
    public void requestFirstMove(String gameId) {
{'fraction_non_alphanumeric': 0.1100253347810351, 'fraction_numerical': 0.0010857763300760044, 'mean_word_length': 2.08082497212932, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '3687594', 'n_tokens_mistral': 1426, 'n_tokens_neox': 1352, 'n_words': 303}