{"size": 1462, "ext": "js", "max_stars_repo_path": "src/input.js", "max_stars_repo_name": "Gaetz/js-Racing", "max_stars_repo_stars_event_min_datetime": "2021-05-06T22:27:28.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-06T22:27:28.000Z", "max_issues_repo_path": "src/input.js", "max_issues_repo_name": "Gaetz/js-Racing", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/input.js", "max_forks_repo_name": "Gaetz/js-Racing", "max_forks_repo_forks_event_min_datetime": "2019-10-02T01:46:30.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-11T21:14:13.000Z"}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": 3, "avg_line_length": 23.5806451613, "max_line_length": 91, "alphanum_fraction": 0.5800273598}
/**
 * Manage player's input
 */
class Input {
    constructor() {
        this.isPressedUp = false;
        this.isPressedDown = false;
        this.isPressedLeft = false;
        this.isPressedRight = false;
        this.isP2PressedUp = false;
        this.isP2PressedDown = false;
        this.isP2PressedLeft = false;
        this.isP2PressedRight = false;
    }

    /**
     * Get up input in function of asking car
     * @param {Car} car 
     */
    isUpInput(car) {
        return this.chooseInput(car.isPlayer2, this.isPressedUp, this.isP2PressedUp);
    }


    /**
     * Get up input in function of asking car
     * @param {Car} car 
     */
    isDownInput(car) {
        return this.chooseInput(car.isPlayer2, this.isPressedDown, this.isP2PressedDown);
    }

    /**
     * Get left input in function of asking car
     * @param {Car} car 
     */
    isLeftInput(car) {
        return this.chooseInput(car.isPlayer2, this.isPressedLeft, this.isP2PressedLeft);
    }

    /**
     * Get right input in function of asking car
     * @param {Car} car 
     */
    isRightInput(car) {
        return this.chooseInput(car.isPlayer2, this.isPressedRight, this.isP2PressedRight);
    }

    /**
     * 
     * @param {bool} isPlayer2 
     * @param {bool} p1Input 
     * @param {bool} p2input 
     */
    chooseInput(isPlayer2, p1Input, p2Input) {
        if (isPlayer2)
            return p2Input;
        else
            return p1Input;
    }
}
