ps2census
Version:
Client to connect to the PS2 Event Stream websocket.
42 lines • 1.77 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Death = exports.Kill = void 0;
const ps2_constants_1 = require("../constants/ps2.constants");
const formatters_1 = require("../../utils/formatters");
const attacker_event_1 = require("./base/attacker.event");
var Kill;
(function (Kill) {
Kill[Kill["Normal"] = 0] = "Normal";
Kill[Kill["TeamKill"] = 1] = "TeamKill";
Kill[Kill["Suicide"] = 2] = "Suicide";
Kill[Kill["RestrictedArea"] = 3] = "RestrictedArea";
})(Kill || (exports.Kill = Kill = {}));
class Death extends attacker_event_1.AttackerEvent {
constructor(...params) {
super(...params);
this.emit = 'death';
this.is_headshot = (0, formatters_1.numberStringToBoolean)(params[Death.DATA].is_headshot);
this.is_critical = (0, formatters_1.numberStringToBoolean)(params[Death.DATA].is_critical);
}
get kill_type() {
if (this.attacker_character_id === '0')
return Kill.RestrictedArea;
if (this.attacker_character_id === this.character_id)
return Kill.Suicide;
return this.attacker_team_id === this.team_id ? Kill.TeamKill : Kill.Normal;
}
get character_faction() {
return (Death.loadoutFactionMap.get(this.character_loadout_id) ?? ps2_constants_1.Faction.NONE);
}
get character_loadout() {
const loadout = Death.loadoutTypeMap.get(this.character_loadout_id);
if (loadout === undefined)
throw new TypeError(`Unknown character_loadout_id when determining loadout: ${this.character_loadout_id}`);
return loadout;
}
toHash() {
return `Death:${this.character_id}:${this.timestamp}`;
}
}
exports.Death = Death;
//# sourceMappingURL=death.event.js.map