public boolean isEndOfGame(){
        if(isCheck()){
            //needs to get all moves, that keep King in game. If no moves available - End of Game

            //prepare copy of available moves
            Map<Position, Set<Position>> safeMoves = new HashMap<>();

            for(Position from : availableMoves.keySet()){
                if(!isCurrentUserPiece(from)){
                    continue;
                }
                Set<Position> available = availableMoves.get(from);
                Set<Position> real = new HashSet<>();
                for(Position to : available){
                    GameState copyState = this.copy();
                    copyState.move(from.toString(), to.toString());
                    copyState.switchPlayer();
                    if(!copyState.isCheck()){
                        real.add(to);
                    }
                }

                if(real.size() > 0){
                    safeMoves.put(from, real);
                }
            }
            availableMoves = safeMoves;
            return availableMoves.size() == 0;
        } else {
            return false;
        }
    }