allow_point(idea_id, user_socket_id, positive_point){
        let add_socket_id = true;
        let existing = false
        let index = -1
        // Finds if the user already gave some sort of point and gets the index of it
        for(let i = 0; i < this.parent.room.ideas[idea_id].socket_ids_who_gave_point.length && !existing; i++){
            existing = (String(this.parent.room.ideas[idea_id].socket_ids_who_gave_point[i].socket_id) == String(user_socket_id))
            if(existing){
                index = i
            }
        }
        
        // If the user gave any points
        if(index >= 0){
            // if the user wants to give positive point, but already gave negative, or
            // if the user wants to give negative point, but already gave positive,
            // delete the existing one, and allow the user to make change
            if(positive_point != this.parent.room.ideas[idea_id].socket_ids_who_gave_point[index].positive_point){
                add_socket_id = false;
                this.parent.room.ideas[idea_id].socket_ids_who_gave_point.splice(index, 1);
                return true;
            }
        }

        if(add_socket_id && index < 0){
            this.parent.room.ideas[idea_id].socket_ids_who_gave_point.push({
                socket_id: user_socket_id,
                positive_point: positive_point
            });
        }

        return index < 0;
    }
// User can give positive point if he gave negative one before
User can give positive point if he gave negative one before
User can give positive point if he gave negative one before
allow_point(idea_id, user_socket_id, positive_point){
        let add_socket_id = true;
        let existing = false
        let index = -1
        for(let i = 0; i < this.parent.room.ideas[idea_id].socket_ids_who_gave_point.length && !existing; i++){
            existing = (String(this.parent.room.ideas[idea_id].socket_ids_who_gave_point[i].socket_id) == String(user_socket_id))
            if(existing){
                index = i
            }
        }
        if(index >= 0){
            if(positive_point != this.parent.room.ideas[idea_id].socket_ids_who_gave_point[index].positive_point){
                add_socket_id = false;
                this.parent.room.ideas[idea_id].socket_ids_who_gave_point.splice(index, 1);
                return true;
            }
        }
        if(add_socket_id && index < 0){
            this.parent.room.ideas[idea_id].socket_ids_who_gave_point.push({
                socket_id: user_socket_id,
                positive_point: positive_point
            });
        }
        return index < 0;
    }
allow_point ( idea_id , user_socket_id , positive_point ) { let add_socket_id = true ; let existing = false let index = - 1 for ( let i = 0 ; i < this . parent . room . ideas [ idea_id ] . socket_ids_who_gave_point . length && ! existing ; i ++ ) { existing = ( String ( this . parent . room . ideas [ idea_id ] . socket_ids_who_gave_point [ i ] . socket_id ) == String ( user_socket_id ) ) if ( existing ) { index = i } } if ( index >= 0 ) { if ( positive_point != this . parent . room . ideas [ idea_id ] . socket_ids_who_gave_point [ index ] . positive_point ) { add_socket_id = false ; this . parent . room . ideas [ idea_id ] . socket_ids_who_gave_point . splice ( index , 1 ) ; return true ; } } if ( add_socket_id && index < 0 ) { this . parent . room . ideas [ idea_id ] . socket_ids_who_gave_point . push ( { socket_id : user_socket_id , positive_point : positive_point } ) ; } return index < 0 ; }
User can give positive point if he gave negative one before
User can give positive point if he gave negative one before
// Finds if the user already gave some sort of point and gets the index of it // If the user gave any points // if the user wants to give positive point, but already gave negative, or // if the user wants to give negative point, but already gave positive, // delete the existing one, and allow the user to make change