class GameConfig
{
	/**
	 * @param  {Client} client
	 */
	constructor(client)
	{
		/**
		 * @type {Client}
		 */
        this.client = client;
    }

    async init()
    {
        let response = await this.client._get("/api/games/");
        
        if (response.status !== 200)
            return response.status;

        let response_data = await response.json();

        /**
         * @type {Number}
         */
        this.size_x = response_data.MAP_SIZE_X;
        /**
         * @type {Number}
         */
        this.size_y = response_data.MAP_SIZE_Y;
        /**
         * @type {Number}
         */
        this.center_x = this.size_x / 2;
        /**
         * @type {Number}
         */
        this.center_y = this.size_y / 2;

        /**
         * @type {Number}
         */
        this.paddle_ratio = response_data.PADDLE_RATIO;
        /**
         * @type {Number}
         */
        this.paddle_speed_per_second_max = response_data.PADDLE_SPEED_PER_SECOND_MAX;
        /**
         * @type {Number}
         */
        this.wall_ratio = response_data.WALL_RATIO;

        /**
         * @type {Number}
         */
        this.ball_speed_inc = response_data.BALL_SPEED_INC;
        /**
         * @type {Number}
         */
        this.ball_speed_start = response_data.BALL_SPEED_START;

        /**
         * @type {Number}
         */
        this.ball_size = response_data.BALL_SIZE;
        /**
         * @type {Number}
         */
        this.ball_spawn_x = this.center_x;
        /**
         * @type {Number}
         */
        this.ball_spawn_y = this.center_y;

        return 0;
    }
}

export { GameConfig }