UNPKG

osrs-tools

Version:

A JavaScript package to provide JSON data for all current Old School RuneScape quests. This package aims to help junior software developers create tools related to Old School RuneScape. It's a work in progress, and issues should be reported to jamescer@ha

189 lines (188 loc) 10.8 kB
"use strict"; var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var _OsrsAccount_name, _OsrsAccount_combatLevel, _OsrsAccount_questPoints, _OsrsAccount_skills, _OsrsAccount_skillsDetail, _OsrsAccount_bosses, _OsrsAccount_clues, _OsrsAccount_bountyHunter, _OsrsAccount_lastManStanding, _OsrsAccount_pvpArena, _OsrsAccount_soulWarsZeal, _OsrsAccount_riftsClosed, _OsrsAccount_colosseumGlory, _OsrsAccount_collectionsLogged, _OsrsAccount_leaguePoints, _OsrsAccount_deadmanPoints; Object.defineProperty(exports, "__esModule", { value: true }); exports.OsrsAccount = void 0; class OsrsAccount { constructor(data) { _OsrsAccount_name.set(this, void 0); _OsrsAccount_combatLevel.set(this, void 0); _OsrsAccount_questPoints.set(this, void 0); _OsrsAccount_skills.set(this, void 0); _OsrsAccount_skillsDetail.set(this, void 0); _OsrsAccount_bosses.set(this, void 0); _OsrsAccount_clues.set(this, void 0); _OsrsAccount_bountyHunter.set(this, void 0); _OsrsAccount_lastManStanding.set(this, void 0); _OsrsAccount_pvpArena.set(this, void 0); _OsrsAccount_soulWarsZeal.set(this, void 0); _OsrsAccount_riftsClosed.set(this, void 0); _OsrsAccount_colosseumGlory.set(this, void 0); _OsrsAccount_collectionsLogged.set(this, void 0); _OsrsAccount_leaguePoints.set(this, void 0); _OsrsAccount_deadmanPoints.set(this, void 0); __classPrivateFieldSet(this, _OsrsAccount_name, data.name, "f"); __classPrivateFieldSet(this, _OsrsAccount_combatLevel, data.combatLevel, "f"); __classPrivateFieldSet(this, _OsrsAccount_questPoints, data.questPoints, "f"); __classPrivateFieldSet(this, _OsrsAccount_skills, data.skills, "f"); __classPrivateFieldSet(this, _OsrsAccount_skillsDetail, data.skillsDetail, "f"); __classPrivateFieldSet(this, _OsrsAccount_bosses, data.bosses, "f"); __classPrivateFieldSet(this, _OsrsAccount_clues, data.clues, "f"); __classPrivateFieldSet(this, _OsrsAccount_bountyHunter, data.bountyHunter, "f"); __classPrivateFieldSet(this, _OsrsAccount_lastManStanding, data.lastManStanding, "f"); __classPrivateFieldSet(this, _OsrsAccount_pvpArena, data.pvpArena, "f"); __classPrivateFieldSet(this, _OsrsAccount_soulWarsZeal, data.soulWarsZeal, "f"); __classPrivateFieldSet(this, _OsrsAccount_riftsClosed, data.riftsClosed, "f"); __classPrivateFieldSet(this, _OsrsAccount_colosseumGlory, data.colosseumGlory, "f"); __classPrivateFieldSet(this, _OsrsAccount_collectionsLogged, data.collectionsLogged, "f"); __classPrivateFieldSet(this, _OsrsAccount_leaguePoints, data.leaguePoints, "f"); __classPrivateFieldSet(this, _OsrsAccount_deadmanPoints, data.deadmanPoints, "f"); } static fromJson(json) { var _a, _b, _c, _d, _e, _f, _g; const name = json.name || ''; const combatLevel = (_c = (_b = (_a = json.main) === null || _a === void 0 ? void 0 : _a.combatLevel) !== null && _b !== void 0 ? _b : json.combatLevel) !== null && _c !== void 0 ? _c : 3; const questPoints = (_f = (_e = (_d = json.main) === null || _d === void 0 ? void 0 : _d.questPoints) !== null && _e !== void 0 ? _e : json.questPoints) !== null && _f !== void 0 ? _f : 0; // Accept both lower and upper case skill keys const skills = {}; const skillsDetail = {}; const srcSkills = ((_g = json.main) === null || _g === void 0 ? void 0 : _g.skills) || json.skills || {}; for (const key of Object.keys(srcSkills)) { skills[key.toLowerCase()] = { level: srcSkills[key].level }; skillsDetail[key.toLowerCase()] = { rank: srcSkills[key].rank, level: srcSkills[key].level, xp: srcSkills[key].xp, }; } const bosses = json.bosses ? Object.assign({}, json.bosses) : undefined; const clues = json.clues ? Object.assign({}, json.clues) : undefined; const bountyHunter = json.bountyHunter ? Object.assign({}, json.bountyHunter) : undefined; const lastManStanding = json.lastManStanding; const pvpArena = json.pvpArena; const soulWarsZeal = json.soulWarsZeal; const riftsClosed = json.riftsClosed; const colosseumGlory = json.colosseumGlory; const collectionsLogged = json.collectionsLogged; const leaguePoints = json.leaguePoints; const deadmanPoints = json.deadmanPoints; return new OsrsAccount({ name, combatLevel, questPoints, skills, skillsDetail, bosses, clues, bountyHunter, lastManStanding, pvpArena, soulWarsZeal, riftsClosed, colosseumGlory, collectionsLogged, leaguePoints, deadmanPoints, }); } get name() { return __classPrivateFieldGet(this, _OsrsAccount_name, "f"); } get combatLevel() { return __classPrivateFieldGet(this, _OsrsAccount_combatLevel, "f"); } get questPoints() { return __classPrivateFieldGet(this, _OsrsAccount_questPoints, "f"); } get skills() { return __classPrivateFieldGet(this, _OsrsAccount_skills, "f"); } get skillsDetail() { return __classPrivateFieldGet(this, _OsrsAccount_skillsDetail, "f"); } get bosses() { return __classPrivateFieldGet(this, _OsrsAccount_bosses, "f"); } get clues() { return __classPrivateFieldGet(this, _OsrsAccount_clues, "f"); } get bountyHunter() { return __classPrivateFieldGet(this, _OsrsAccount_bountyHunter, "f"); } get lastManStanding() { return __classPrivateFieldGet(this, _OsrsAccount_lastManStanding, "f"); } get pvpArena() { return __classPrivateFieldGet(this, _OsrsAccount_pvpArena, "f"); } get soulWarsZeal() { return __classPrivateFieldGet(this, _OsrsAccount_soulWarsZeal, "f"); } get riftsClosed() { return __classPrivateFieldGet(this, _OsrsAccount_riftsClosed, "f"); } get colosseumGlory() { return __classPrivateFieldGet(this, _OsrsAccount_colosseumGlory, "f"); } get collectionsLogged() { return __classPrivateFieldGet(this, _OsrsAccount_collectionsLogged, "f"); } get leaguePoints() { return __classPrivateFieldGet(this, _OsrsAccount_leaguePoints, "f"); } get deadmanPoints() { return __classPrivateFieldGet(this, _OsrsAccount_deadmanPoints, "f"); } getSkill(skillName) { return __classPrivateFieldGet(this, _OsrsAccount_skills, "f")[skillName.toLowerCase()]; } getSkillDetail(skillName) { var _a; return (_a = __classPrivateFieldGet(this, _OsrsAccount_skillsDetail, "f")) === null || _a === void 0 ? void 0 : _a[skillName.toLowerCase()]; } getBossScore(bossName) { var _a; return (_a = __classPrivateFieldGet(this, _OsrsAccount_bosses, "f")) === null || _a === void 0 ? void 0 : _a[bossName]; } getClueScore(clueType) { var _a; return (_a = __classPrivateFieldGet(this, _OsrsAccount_clues, "f")) === null || _a === void 0 ? void 0 : _a[clueType]; } toString() { return `${__classPrivateFieldGet(this, _OsrsAccount_name, "f")}:\nCombat Level: ${__classPrivateFieldGet(this, _OsrsAccount_combatLevel, "f")}\nQuestPoints: ${__classPrivateFieldGet(this, _OsrsAccount_questPoints, "f")}`; } toJson() { return { name: __classPrivateFieldGet(this, _OsrsAccount_name, "f"), combatLevel: __classPrivateFieldGet(this, _OsrsAccount_combatLevel, "f"), questPoints: __classPrivateFieldGet(this, _OsrsAccount_questPoints, "f"), skills: __classPrivateFieldGet(this, _OsrsAccount_skills, "f"), skillsDetail: __classPrivateFieldGet(this, _OsrsAccount_skillsDetail, "f"), bosses: __classPrivateFieldGet(this, _OsrsAccount_bosses, "f"), clues: __classPrivateFieldGet(this, _OsrsAccount_clues, "f"), bountyHunter: __classPrivateFieldGet(this, _OsrsAccount_bountyHunter, "f"), lastManStanding: __classPrivateFieldGet(this, _OsrsAccount_lastManStanding, "f"), pvpArena: __classPrivateFieldGet(this, _OsrsAccount_pvpArena, "f"), soulWarsZeal: __classPrivateFieldGet(this, _OsrsAccount_soulWarsZeal, "f"), riftsClosed: __classPrivateFieldGet(this, _OsrsAccount_riftsClosed, "f"), colosseumGlory: __classPrivateFieldGet(this, _OsrsAccount_colosseumGlory, "f"), collectionsLogged: __classPrivateFieldGet(this, _OsrsAccount_collectionsLogged, "f"), leaguePoints: __classPrivateFieldGet(this, _OsrsAccount_leaguePoints, "f"), deadmanPoints: __classPrivateFieldGet(this, _OsrsAccount_deadmanPoints, "f"), }; } } exports.OsrsAccount = OsrsAccount; _OsrsAccount_name = new WeakMap(), _OsrsAccount_combatLevel = new WeakMap(), _OsrsAccount_questPoints = new WeakMap(), _OsrsAccount_skills = new WeakMap(), _OsrsAccount_skillsDetail = new WeakMap(), _OsrsAccount_bosses = new WeakMap(), _OsrsAccount_clues = new WeakMap(), _OsrsAccount_bountyHunter = new WeakMap(), _OsrsAccount_lastManStanding = new WeakMap(), _OsrsAccount_pvpArena = new WeakMap(), _OsrsAccount_soulWarsZeal = new WeakMap(), _OsrsAccount_riftsClosed = new WeakMap(), _OsrsAccount_colosseumGlory = new WeakMap(), _OsrsAccount_collectionsLogged = new WeakMap(), _OsrsAccount_leaguePoints = new WeakMap(), _OsrsAccount_deadmanPoints = new WeakMap();