UNPKG

steam-condenser

Version:
172 lines 5.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SteamPlayer = void 0; var SteamPlayer = /** @class */ (function () { function SteamPlayer(id, name, score, connectTime) { this.connectTime = connectTime; this.id = id; this.name = name; this.score = score; this.extended = false; } /** * Extends a player object with information retrieved from a RCON call to * the status command * * @param string playerData The player data retrieved from * <var>rcon status</var> * @throws SteamCondenserException if the information belongs to another * player */ SteamPlayer.prototype.addInformation = function (playerData) { if (playerData.name !== this.name) { throw new Error('Information to add belongs to a different player.'); } this.extended = true; this.connectionId = Number.parseInt(playerData.userid, 10); if (typeof playerData.state !== 'undefined') { this.state = playerData.state; } this.steamId = playerData.uniqueid; if (!this.isBot()) { this.loss = Number.parseInt(playerData.loss, 10); this.ping = Number.parseInt(playerData.ping, 10); if (typeof playerData.state !== 'undefined') { var address = playerData.adr.split(':'); this.ipAddress = address[0]; this.clientPort = Number.parseInt(address[1], 10); } if (typeof playerData.rate !== 'undefined') { this.rate = Number.parseInt(playerData.rate, 10); } } }; /** * Returns the client port of this player * * @return int The client port of the player */ SteamPlayer.prototype.getClientPort = function () { return this.clientPort; }; /** * Returns the connection ID (as used on the server) of this player * * @return int The connection ID of this player */ SteamPlayer.prototype.getConnectionId = function () { return this.connectionId; }; /** * Returns the time this player is connected to the server * * @return float The connection time of the player */ SteamPlayer.prototype.getConnectTime = function () { return this.connectTime; }; /** * Returns the ID of this player * * @return int The ID of this player */ SteamPlayer.prototype.getId = function () { return this.id; }; /** * Returns the IP address of this player * * @return string The IP address of this player */ SteamPlayer.prototype.getIpAddress = function () { return this.ipAddress; }; /** * Returns the packet loss of this player's connection * * @return string The packet loss of this player's connection */ SteamPlayer.prototype.getLoss = function () { return this.loss; }; /** * Returns the nickname of this player * * @return string The name of this player */ SteamPlayer.prototype.getName = function () { return this.name; }; /** * Returns the ping of this player * * @return int The ping of this player */ SteamPlayer.prototype.getPing = function () { return this.ping; }; /** * Returns the rate of this player * * @return int The rate of this player */ SteamPlayer.prototype.getRate = function () { return this.rate; }; /** * Returns the score of this player * * @return int The score of this player */ SteamPlayer.prototype.getScore = function () { return this.score; }; /** * Returns the connection state of this player * * @return string The connection state of this player */ SteamPlayer.prototype.getState = function () { return this.state; }; /** * Returns the SteamID of this player * * @return string The SteamID of this player */ SteamPlayer.prototype.getSteamId = function () { return this.steamId; }; /** * Returns whether this player is a bot * * @return bool <var>true</var> if this player is a bot */ SteamPlayer.prototype.isBot = function () { return this.steamId === 'BOT'; }; /** * Returns whether this player object has extended information gathered * using RCON * * @return bool <var>true</var> if extended information for this player * is available */ SteamPlayer.prototype.isExtended = function () { return this.extended; }; /** * Returns a string representation of this player * * @return string A string representing this player */ SteamPlayer.prototype.toString = function () { if (this.extended) { return "#" + this.connectionId + " \"" + this.name + "\", SteamID: " + this.steamId + " Score: " + this.score + ", Time: " + this.connectTime; } return "#" + this.id + " \"" + this.name + "\", Score: " + this.score + ", Time: " + this.connectTime; }; return SteamPlayer; }()); exports.SteamPlayer = SteamPlayer; //# sourceMappingURL=SteamPlayer.js.map