UNPKG

kartrider.js

Version:
57 lines (56 loc) 1.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MatchDetail = void 0; const Player_1 = require("./Player"); const Match_1 = require("./Match"); class MatchDetail extends Match_1.Match { constructor(client, data) { super(client, data); this._playTime = data.playTime; this._gameSpeed = data.gameSpeed; if (data.players) this.players = data.players .map(data => new Player_1.Player(client, data)) .sort((a, b) => { const ARank = a.matchRank || 99; const BRank = b.matchRank || 99; return ARank - BRank; }); if (data.teams) this.teams = data.teams.map(data => { const players = data.players.map((playerData) => new Player_1.Player(client, playerData, data.teamId)); return { teamID: data.teamId, players }; }).sort((a, b) => Number(a.teamID) - Number(b.teamID)); } get isTeam() { return Boolean(this.matchResult !== "0"); } get winner() { var _a, _b; if (this.matchResult == "0") return (_a = this.players) === null || _a === void 0 ? void 0 : _a[0]; else { const team = (_b = this.teams) === null || _b === void 0 ? void 0 : _b.find(team => team.teamID === this.matchResult); return team || { teamID: this.matchResult }; } } get playTime() { return this._playTime; } get gameSpeed() { switch (this._gameSpeed) { case 0: return "빠름"; case 1: return "매우빠름"; case 2: return "가장빠름"; case 3: return "보통"; case 4: return "무한"; } return "보통"; } } exports.MatchDetail = MatchDetail;