node-brawlstars
Version:
Javascript library to communicate with BrawlStars API
44 lines (43 loc) • 1.66 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Player = void 0;
const club_model_1 = require("./club.model");
const base_model_1 = require("./base.model");
const brawler_model_1 = require("./brawler.model");
class Player extends base_model_1.BaseModel {
get totalVictories() {
return this['3vs3Victories'] + this.soloVictories + this.duoVictories;
}
constructor(client, raw) {
super(client);
this.tag = raw.tag;
this.name = raw.name;
this.icon = raw.icon;
this.trophies = raw.trophies;
this.highestTrophies = raw.highestTrophies;
this.expLevel = raw.expLevel;
this.expPoints = raw.expPoints;
this.isQualifiedFromChampionshipChallenge = raw.isQualifiedFromChampionshipChallenge;
this['3vs3Victories'] = raw['3vs3Victories'];
this.soloVictories = raw.soloVictories;
this.duoVictories = raw.duoVictories;
this.bestRoboRumbleTime = raw.bestRoboRumbleTime;
this.bestTimeAsBigBrawler = raw.bestTimeAsBigBrawler;
if ('tag' in raw.club)
this.club = new club_model_1.Club(client, raw.club);
this.brawlers = raw.brawlers.map(brawler => new brawler_model_1.Brawler(client, brawler));
}
getClub() {
return this.client.getClub(this.club?.tag);
}
getBattles() {
return this.client.getPlayerBattlelog(this.tag).then(res => res.items);
}
}
exports.Player = Player;
(function (Player) {
function FromRaw(client, raw) {
return new Player(client, raw);
}
Player.FromRaw = FromRaw;
})(Player || (exports.Player = Player = {}));