Source: struct/MultiGame.js

'use strict';

const MultiScore = require('./MultiScore');

/**
 * Multi game info class
 * @memberof module:CustomClasses
 * @property {Number} id Match ID [alias: gameId]
 * @property {Date} startTime Game start time
 * @property {Date} endTime Game end time
 * @property {Number} beatmapId ID of beatmap played
 * @property {Mode} playMode Game mode the beatmap was played in
 * @property {MultiScoringType} scoringType Winning condition
 * @property {MultiTeamType} teamType Team type
 * @property {Number} mods Bitwise flag of mods used generated by the C#
 * @property {MultiScore[]} scores Scores in the game
 */
class MultiGame {
    constructor(data) {
        this.id = Number(data.game_id);
        this.startTime = new Date(data.start_time + ' GMT');
        this.endTime = new Date(data.end_time + ' GMT');
        this.beatmapId = Number(data.beatmap_id);
        this.playMode = Number(data.play_mode);
        this.scoringType = Number(data.scoring_type);
        this.teamType = Number(data.team_type);
        this.mods = Number(data.mods);
        this.scores = data.scores.map(s => new MultiScore(s));
    }

    get gameId() { return this.id; }
}

module.exports = MultiGame;