osrs-tools 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +106 -30
  2. package/package.json +90 -75
  3. package/src/index.ts +6 -433
  4. package/src/model/Requirement.ts +173 -0
  5. package/src/model/account/OsrsAccount.ts +82 -0
  6. package/src/model/quest/Quest.ts +44 -0
  7. package/src/model/quest/QuestTool.ts +96 -0
  8. package/src/model/slayer/Assignment.ts +40 -0
  9. package/src/model/slayer/SlayerMaster.ts +137 -0
  10. package/src/model/slayer/SlayerReward.ts +39 -0
  11. package/src/model/slayer/Task.ts +168 -0
  12. package/src/resources/QuestData.json +754 -0
  13. package/src/{data/Diaries → resources/quest}/diaries.json +3 -3
  14. package/src/{data/quest/questData.ts → resources/quest/questData.js} +169 -223
  15. package/src/{data/quest/questDataArray.json → resources/quest/questData.json} +950 -1833
  16. package/src/resources/quest/questDataArray.js +5489 -0
  17. package/src/{data/quest/questData.json → resources/quest/questDataArray.json} +642 -643
  18. package/src/{data/quest/miniquestQuestArray.json → resources/quest/subquestArray.js} +2 -2
  19. package/src/{data/quest/subQuestArray.json → resources/quest/subquestArray.json} +1 -1
  20. package/src/{data → resources}/quest/testObj.json +148 -148
  21. package/src/{data → resources}/quest/testarray.json +149 -149
  22. package/src/resources/quests/CooksAssistant.json +34 -0
  23. package/src/resources/slayer/Masters.ts +180 -0
  24. package/src/resources/slayer/SlayerData.ts +45 -0
  25. package/src/resources/slayer/SlayerExtends.ts +218 -0
  26. package/src/resources/slayer/SlayerUnlock.ts +194 -0
  27. package/src/resources/slayer/slayer.json +3581 -0
  28. package/src/resources/slayer/slayerBuys.ts +38 -0
  29. package/src/resources/slayer/slayerData.json +4431 -0
  30. package/src/resources/slayer/tasks/ChaelderTasks.ts +235 -0
  31. package/src/resources/slayer/tasks/DuradelTasks.ts +75 -0
  32. package/src/resources/slayer/tasks/KonarTasks.ts +6 -0
  33. package/src/resources/slayer/tasks/MazchnaTasks.ts +5 -0
  34. package/src/resources/slayer/tasks/NieveTasks.ts +235 -0
  35. package/src/resources/slayer/tasks/ReadTasks.ts +55 -0
  36. package/src/resources/slayer/tasks/SpriaTasks.ts +344 -0
  37. package/src/resources/slayer/tasks/Tureal.ts +436 -0
  38. package/src/resources/slayer/tasks/VannakaTasks.ts +236 -0
  39. package/src/resources/slayer/tasks/json/Chaeldar.json +348 -0
  40. package/src/resources/slayer/tasks/json/Duradel.json +541 -0
  41. package/src/resources/slayer/tasks/json/Krystilia.json +2 -0
  42. package/src/resources/slayer/tasks/json/Mazchna.json +379 -0
  43. package/src/resources/slayer/tasks/json/Neive.json +320 -0
  44. package/src/resources/slayer/tasks/json/Spria.json +345 -0
  45. package/src/resources/slayer/tasks/json/Tureal.json +341 -0
  46. package/src/resources/slayer/tasks/json/Vannaka.json +547 -0
  47. package/src/cli.js +0 -9
  48. package/src/data/farming/fruitTrees.json +0 -165
  49. package/src/data/farming/locations.json +0 -78
  50. package/src/data/farming/patches.json +0 -102
  51. package/src/data/farming/seeds.json +0 -170
  52. package/src/data/farming/teleports.json +0 -301
  53. package/src/data/farming/treePatches.json +0 -3
  54. package/src/data/farming/trees.json +0 -103
  55. package/src/data/quest/miniquestQuestArray.ts +0 -8
  56. package/src/data/quest/questDataArray.ts +0 -4134
  57. package/src/data/quest/subQuestArray.ts +0 -60
  58. package/src/tests/QuestTest.js +0 -71
  59. package/src/tests/getAllQuestSeries.ts +0 -6
  60. package/src/tests/test Quest Array.ts +0 -9
  61. package/src/tests/test Requirements.ts +0 -56
  62. package/src/tests/test.ts +0 -402
  63. package/src/tests/test3.js +0 -370
  64. package/src/tests/testQuestCompletion.js +0 -367
  65. package/src/tests/testSeed.js +0 -8
  66. package/src/utils/AchievementDiary.ts +0 -18
  67. package/src/utils/Farming/FarmingTool.ts +0 -110
  68. package/src/utils/Farming/Seed.js +0 -42
  69. package/src/utils/Farming/TreeSeed.js +0 -21
  70. package/src/utils/OsrsAccount.ts +0 -280
  71. package/src/utils/Quest.ts +0 -99
  72. package/src/utils/QuestTool.ts +0 -437
  73. package/src/utils/Requirement.ts +0 -63
  74. package/src/utils/Skill.ts +0 -11
  75. /package/src/{data/Diaries → resources/quest}/diariesArray.json +0 -0
  76. /package/src/{data → resources/quest}/exp.json +0 -0
package/src/index.ts CHANGED
@@ -1,438 +1,11 @@
1
- // import { QuestTool } from './questTool.js';const { QuestTool } = require('./utils/QuestTool.js')
2
- // const { OsrsAccount } = require('./utils/OsrsAccount.js');
1
+ // import { QuestTool } from './questTool.js';
2
+ import { QuestTool } from './model/quest/QuestTool';
3
+ import { SlayerTool } from './model/slayer/SlayerTool';
4
+ import { OsrsAccount } from './model/account/OsrsAccount';
3
5
 
4
- import { OsrsAccount } from './utils/OsrsAccount';
5
- import { QuestTool } from './utils/QuestTool';
6
- import { QuestData } from './data/quest/questData';
7
- import { QuestArray } from './data/quest/questDataArray';
8
- import { SubQuestArray } from './data/quest/subQuestArray';
9
-
10
- /**
11
- * Returns the highest boost for the specified skillName
12
- * @deprecated
13
- */
14
- function highestBoost(skillName: string) {
15
- /**
16
- * List of highest boostable levels with skills including spicy stew etc
17
- */
18
- switch (skillName) {
19
- case 'construction':
20
- // spicy stew + crystal saw
21
- return 8;
22
- case 'strength':
23
- //spicy stew 5
24
- // Drunk dragon 1-7
25
- // Premade dr'dragon 1-7
26
- return 7;
27
- case 'thieving':
28
- case 'woodcutting':
29
- case 'hunter': // spicy stew
30
- case 'magic': // Imbued heart 10
31
- //spicy stew 5
32
- case 'hitpoints':
33
- // Guthix rest 5
34
- // Anglerfish
35
- //Abidor Crank 15
36
- // Amulet of the damned 10
37
- case 'mining': // spicy stew
38
- case 'prayer': // spicy stew
39
- case 'ranged': // spicy stew
40
- case 'runecraft': //spicy stew 5
41
- case 'slayer': //spicy stew 5
42
- case 'smithing': //spicy stew 5
43
- case 'cooking': // spicy stew
44
- case 'crafting': // spicy stew
45
- case 'defence': //spicy stew 5
46
- case 'farming': // spicy stew
47
- case 'firemaking': // spicy stew
48
- case 'fishing': // spicy stew
49
- case 'fletching': // spicy stew
50
- case 'herblore': // spicy stew
51
- case 'agility':
52
- // spicy stew
53
- case 'attack':
54
- //spicy stew
55
- return 5;
56
- default:
57
- break;
58
- }
59
- }
60
-
61
- var osrsAccount: any;
62
-
63
- /**
64
- * Assign a OSRS account to this package.
65
- * @deprecated
66
- */
67
- function setOsrsAccount(acc: any) {
68
- osrsAccount = acc;
69
- }
70
-
71
- /**
72
- * Assign a OSRS account to this package.
73
- * @deprecated
74
- */
75
- function getOsrsAccount() {
76
- return osrsAccount;
77
- }
78
-
79
- /**
80
- * Returns a json object of all old school runescape quests.
81
- * @deprecated
82
- */
83
- function getQuestObject() {
84
- return QuestData;
85
- }
86
-
87
- /**
88
- * Returns an array object of all old school runescape quests as json objects.
89
- * @deprecated
90
- */
91
- function getQuestArray() {
92
- return QuestArray;
93
- }
94
-
95
- /**
96
- * Returns an array object of all subquests for all old school runescape quests as json objects.
97
- * @deprecated
98
- */
99
- function subQuestArray() {
100
- return SubQuestArray;
101
- }
102
-
103
- function hello() {
104
- console.log('if you need help use the .help() method');
105
- console.log('This is a message from the demo package');
106
- }
107
-
108
- function contact() {
109
- console.log(
110
- 'If you need to contact me feel free to reach out to me at jamesmcerniglia@gmail.com'
111
- );
112
- }
113
-
114
- function help() {
115
- console.log(
116
- 'import q from "osrs-quest-tool";\n console.log(q.questObject());\n console.log(q.questArray());'
117
- );
118
- }
119
-
120
- // function meetQuestRequirements(quest, account: OsrsAccount) {
121
- // if (quest === 'Recipe for Disaster') {
122
- // // TODO
123
- // // Pirate Pete Subquest of Recipe for Disaster
124
- // return true;
125
- // } else if (quest === 'Pirate Pete subquest of Recipe for Disaster') {
126
- // // TODO
127
- // // Pirate Pete Subquest of Recipe for Disaster
128
- // return true;
129
- // }
130
- // //check to see if the account can fulfill all skill requirements
131
- // if (quest.requirements.levels) {
132
- // for (var x in quest.requirements.levels) {
133
- // var cur = quest.requirements.levels[x];
134
- // /**
135
- // * cur.level
136
- // * cur.skill
137
- // * cur.boostable
138
- // * cur.ironman
139
- // * types:
140
- // * "quest", "combat", "agility"...
141
- // * */
142
-
143
- // // If the requirement is mandatory for ironmen
144
- // if (cur.ironman && cur.ironman == true) {
145
- // if (cur.boostable) {
146
- // // Can boost with spicy stew
147
- // if (
148
- // account.main.skills[cur.skill] + highestBoost(cur.skill) <
149
- // cur.level
150
- // ) {
151
- // return false;
152
- // }
153
- // } else {
154
- // if (account.main.skills[cur.skill] < cur.level) {
155
- // return false;
156
- // }
157
- // }
158
- // }
159
- // // If the requirement is quest points, check to see if the account has the quest points to complete it
160
- // if (cur.skill === 'quest') {
161
- // if (account.main.questPoints < cur.level) {
162
- // return false;
163
- // }
164
-
165
- // // if the requirement is combat level to start the quest, check to see if the account's combat level is higher than or equal to the requirement
166
- // } else if (cur.skill === 'combat') {
167
- // if (account.main.combatLevel < cur.level) {
168
- // return false;
169
- // }
170
-
171
- // // If this is ANY skill agility, runecraft, woodcutting, slayer, attack, defence, hitpoints, mining smithing, herblore, fletching, ranged, magic
172
- // } else {
173
- // // if the requirement is boostable
174
- // if (cur.boostable) {
175
- // // check if max stew can reach
176
- // if (
177
- // account.main.skills[cur.skill] + highestBoost(cur.skill) <
178
- // cur.level
179
- // ) {
180
- // return false;
181
- // }
182
-
183
- // // if not boostable, check to see if the skill is higher than or equal to
184
- // } else {
185
- // if (account.main.skills[cur.skill] < cur.level) {
186
- // return false;
187
- // }
188
- // }
189
- // }
190
- // }
191
- // }
192
-
193
- // // Check for all quest requirements
194
- // // recursive method called
195
- // if (quest.requirements.quests) {
196
- // for (var y in quest.requirements.quests) {
197
- // // If any of the quests required are not completeable: return false
198
- // if (
199
- // this.meetQuestRequirements(
200
- // this.questObject[quest.requirements.quests[y]]
201
- // ) != true
202
- // ) {
203
- // return false;
204
- // }
205
- // }
206
- // }
207
-
208
- // // If the account can complete all quests and skills are higher than or boostable
209
- // return true;
210
- // }
211
-
212
- /**
213
- *
214
- * @param {*} quest - The quest object from this modules questObject, should be a Json object.
215
- * @param {*} account - The account that this quest is being compared to. Plans to remove this in the future?
216
- * @deprecated - Should use the QuestTool class for this;
217
- * Recursive method that iterates through a quests requirements that determines the quest is completable with the passed account
218
- * Possible revamp to remove account param to increase runtime?
219
- *
220
- */
221
- // function canCompleteQuest(quest, account) {
222
- // if (quest.name === 'Recipe for Disaster') {
223
- // // TODO
224
- // // Pirate Pete Subquest of Recipe for Disaster
225
- // return true;
226
- // } else if (quest.name === 'Pirate Pete subquest of Recipe for Disaster') {
227
- // // TODO
228
- // // Pirate Pete Subquest of Recipe for Disaster
229
- // return true;
230
- // }
231
- // //check to see if the account can fulfill all skill requirements
232
- // if (quest.requirements.levels) {
233
- // for (var x in quest.requirements.levels) {
234
- // var cur = quest.requirements.levels[x];
235
- // /**
236
- // * cur.level
237
- // * cur.skill
238
- // * cur.boostable
239
- // * cur.ironman
240
- // * types: "quest", "combat", "agility"...
241
- // * */
242
-
243
- // // If the requirement is mandatory for ironmen
244
- // if (cur.ironman && cur.ironman == true) {
245
- // if (cur.boostable) {
246
- // // Can boost with highest boost
247
- // if (
248
- // account.main.skills[cur.skill] + highestBoost(cur.skill) <
249
- // cur.level
250
- // ) {
251
- // return false;
252
- // }
253
- // } else {
254
- // if (account.main.skills[cur.skill] < cur.level) {
255
- // return false;
256
- // }
257
- // }
258
- // }
259
- // // If the requirement is quest points, check to see if the account has the quest points to complete it
260
- // if (cur.skill === 'quest') {
261
- // if (account.main.questPoints < cur.level) {
262
- // return false;
263
- // }
264
-
265
- // // if the requirement is combat level to start the quest, check to see if the account's combat level is higher than or equal to the requirement
266
- // } else if (cur.skill === 'combat') {
267
- // if (account.main.combatLevel < cur.level) {
268
- // return false;
269
- // }
270
-
271
- // // If this is ANY skill agility, runecraft, woodcutting, slayer, attack, defence, hitpoints, mining smithing, herblore, fletching, ranged, magic
272
- // } else {
273
- // // if the requirement is boostable
274
- // if (cur.boostable) {
275
- // // check if max stew can reach
276
- // if (
277
- // account.main.skills[cur.skill] + highestBoost(cur.skill) <
278
- // cur.level
279
- // ) {
280
- // return false;
281
- // }
282
-
283
- // // if not boostable, check to see if the skill is higher than or equal to
284
- // } else {
285
- // if (account.main.skills[cur.skill] < cur.level) {
286
- // return false;
287
- // }
288
- // }
289
- // }
290
- // }
291
- // }
292
-
293
- // // Check for all quest requirements
294
- // // recursive method called
295
- // if (quest.requirements.quests && quest.requirements.quests >= 1) {
296
- // for (var y in quest.requirements.quests) {
297
- // // If any of the quests required are not completeable: return false
298
- // if (
299
- // canCompleteQuest(this.questObject[quest.requirements.quests[y]]) != true
300
- // ) {
301
- // return false;
302
- // }
303
- // }
304
- // }
305
-
306
- // //iterate through any subquests and see if we can complete
307
- // //this is for future work with Recipe for Disaster
308
- // if (quest.subquests && quest.subquests.length >= 1) {
309
- // for (var y in quest.subquests) {
310
- // // If any of the quests required are not completeable: return false
311
- // if (
312
- // canCompleteQuest(this.questObject[quest.requirements.subquests[y]]) !=
313
- // true
314
- // ) {
315
- // return false;
316
- // }
317
- // }
318
- // }
319
-
320
- // // If the account can complete all quests and skills are higher than or boostable
321
- // return true;
322
- // }
323
-
324
- /**
325
- *
326
- * @param quest
327
- * @param account
328
- * @deprecated - Should use the QuestTool class for this;
329
- * @returns
330
- */
331
- // function meetsRequirement(quest, account) {
332
- // if (quest === 'Recipe for Disaster') {
333
- // // TODO
334
- // // Pirate Pete Subquest of Recipe for Disaster
335
- // return true;
336
- // } else if (quest === 'Pirate Pete subquest of Recipe for Disaster') {
337
- // // TODO
338
- // // Pirate Pete Subquest of Recipe for Disaster
339
- // return true;
340
- // }
341
- // //check to see if the account can fulfill all skill requirements
342
- // if (quest.requirements.levels) {
343
- // for (var x in quest.requirements.levels) {
344
- // var cur = quest.requirements.levels[x];
345
- // /**
346
- // * cur.level
347
- // * cur.skill
348
- // * cur.boostable
349
- // * cur.ironman
350
- // * types:
351
- // * "quest", "combat", "agility"...
352
- // * */
353
-
354
- // // If the requirement is mandatory for ironmen
355
- // if (cur.ironman && cur.ironman == true) {
356
- // if (cur.boostable) {
357
- // // Can boost with spicy stew
358
- // if (
359
- // account.main.skills[cur.skill] + highestBoost(cur.skill) <
360
- // cur.level
361
- // ) {
362
- // return false;
363
- // }
364
- // } else {
365
- // if (account.main.skills[cur.skill] < cur.level) {
366
- // return false;
367
- // }
368
- // }
369
- // }
370
- // // If the requirement is quest points, check to see if the account has the quest points to complete it
371
- // if (cur.skill === 'quest') {
372
- // if (account.main.questPoints < cur.level) {
373
- // return false;
374
- // }
375
-
376
- // // if the requirement is combat level to start the quest, check to see if the account's combat level is higher than or equal to the requirement
377
- // } else if (cur.skill === 'combat') {
378
- // if (account.main.combatLevel < cur.level) {
379
- // return false;
380
- // }
381
-
382
- // // If this is ANY skill agility, runecraft, woodcutting, slayer, attack, defence, hitpoints, mining smithing, herblore, fletching, ranged, magic
383
- // } else {
384
- // // if the requirement is boostable
385
- // if (cur.boostable) {
386
- // // check if max stew can reach
387
- // if (
388
- // account.main.skills[cur.skill] + highestBoost(cur.skill) <
389
- // cur.level
390
- // ) {
391
- // return false;
392
- // }
393
-
394
- // // if not boostable, check to see if the skill is higher than or equal to
395
- // } else {
396
- // if (account.main.skills[cur.skill] < cur.level) {
397
- // return false;
398
- // }
399
- // }
400
- // }
401
- // }
402
- // }
403
-
404
- // // Check for all quest requirements
405
- // // recursive method called
406
- // if (quest.requirements.quests) {
407
- // for (var y in quest.requirements.quests) {
408
- // // If any of the quests required are not completeable: return false
409
- // if (
410
- // meetQuestRequirements(this.questObject[quest.requirements.quests[y]]) !=
411
- // true
412
- // ) {
413
- // return false;
414
- // }
415
- // }
416
- // }
417
-
418
- // // If the account can complete all quests and skills are higher than or boostable
419
- // return true;
420
- // }
421
-
422
- export = {
6
+ export default {
423
7
  QuestTool,
424
8
  OsrsAccount,
425
- QuestArray,
426
- QuestData,
427
- hello,
428
- setOsrsAccount,
429
- getOsrsAccount,
430
- getQuestObject,
431
- getQuestArray,
432
- contact,
433
- help,
434
- // meetsRequirement,
435
- // canCompleteQuest,
436
- subQuestArray,
9
+ SlayerTool
437
10
  };
438
11
  // export default
@@ -0,0 +1,173 @@
1
+ // Base interface for all types of requirements
2
+ interface Requirement {
3
+ description: string;
4
+ isMet(): boolean;
5
+ }
6
+
7
+ // TODO: Add a requirement type for all "levels" (combat, slayer, farming, crafting etc.)
8
+ class LevelRequirement implements Requirement {
9
+ type: RequirementType = RequirementType.Level;
10
+ skillName: string;
11
+ level: number;
12
+ boostable: boolean = false; // Indicates if the level can be boosted
13
+
14
+ constructor(skillName: string, level: number, boostable: boolean = false) {
15
+ this.boostable = boostable;
16
+ this.skillName = skillName;
17
+ this.level = level;
18
+ }
19
+
20
+ get description(): string {
21
+ return `Level ${this.level}`;
22
+ }
23
+
24
+ isMet(): boolean {
25
+ // Replace with actual logic to check the player's level
26
+ return false; // TODO
27
+ }
28
+ }
29
+
30
+ // Enum for requirement types
31
+ enum RequirementType {
32
+ SlayerLevel = 'SlayerLevel',
33
+ Level = 'Level',
34
+ CombatLevel = 'CombatLevel',
35
+ Quest = 'Quest',
36
+ Item = 'Item',
37
+ Location = 'Location',
38
+ SlayerUnlock = 'SlayerUnlock',
39
+ }
40
+
41
+ // Slayer Unlock requirement
42
+ class SlayerUnlockRequirement implements Requirement {
43
+ type: RequirementType = RequirementType.SlayerUnlock;
44
+ name: string;
45
+
46
+ constructor(name: string) {
47
+ this.name = name;
48
+ }
49
+ get description(): string {
50
+ return `Slayer unlock: ${this.name}`;
51
+ }
52
+
53
+ isMet(): boolean {
54
+ // Replace with actual logic to check the player's Slayer level
55
+ return false; // TODO
56
+ }
57
+ }
58
+
59
+ // Slayer level requirement
60
+ class SlayerLevelRequirement implements Requirement {
61
+ type: RequirementType = RequirementType.SlayerLevel;
62
+ level: number;
63
+
64
+ constructor(level: number) {
65
+ this.level = level;
66
+ }
67
+
68
+ get description(): string {
69
+ return `Slayer level ${this.level}`;
70
+ }
71
+
72
+ isMet(): boolean {
73
+ // Replace with actual logic to check the player's Slayer level
74
+ return false; // TODO
75
+ }
76
+ }
77
+
78
+ // Combat level requirement
79
+ class CombatLevelRequirement implements Requirement {
80
+ type: RequirementType = RequirementType.CombatLevel;
81
+ level: number;
82
+
83
+ constructor(level: number) {
84
+ this.level = level;
85
+ }
86
+
87
+ get description(): string {
88
+ return `Combat level ${this.level}`;
89
+ }
90
+
91
+ isMet(): boolean {
92
+ // Replace with actual logic to check the player's Combat level
93
+ return false; // TODO
94
+ }
95
+ }
96
+
97
+ // Quest requirement
98
+ class QuestRequirement implements Requirement {
99
+ type: RequirementType = RequirementType.Quest;
100
+ questName: string;
101
+
102
+ constructor(questName: string) {
103
+ this.questName = questName;
104
+ }
105
+
106
+ get description(): string {
107
+ return `Completed quest: ${this.questName}`;
108
+ }
109
+
110
+ isMet(): boolean {
111
+ // Replace with actual logic to check if the quest is completed
112
+ return false; // TODO
113
+ }
114
+ }
115
+
116
+ // Item requirement
117
+ class ItemRequirement implements Requirement {
118
+ type: RequirementType = RequirementType.Item;
119
+ itemName: string;
120
+
121
+ constructor(itemName: string) {
122
+ this.itemName = itemName;
123
+ }
124
+
125
+ get description(): string {
126
+ return `Has item: ${this.itemName}`;
127
+ }
128
+
129
+ isMet(): boolean {
130
+ // Replace with actual logic to check if the player has the item
131
+ return false; // TODO
132
+ }
133
+ }
134
+
135
+ // Location requirement
136
+ class LocationRequirement implements Requirement {
137
+ type: RequirementType = RequirementType.Location;
138
+ locationName: string;
139
+
140
+ constructor(locationName: string) {
141
+ this.locationName = locationName;
142
+ }
143
+
144
+ get description(): string {
145
+ return `Access to location: ${this.locationName}`;
146
+ }
147
+
148
+ isMet(): boolean {
149
+ // Replace with actual logic to check if the player is in the location
150
+ return false; // TODO
151
+ }
152
+ }
153
+
154
+ // Example usage: Array of requirements for a monster
155
+ const monsterRequirements: Requirement[] = [
156
+ new SlayerLevelRequirement(44),
157
+ new CombatLevelRequirement(5),
158
+ new QuestRequirement('Dragon Slayer'),
159
+ new ItemRequirement('Anti-dragon shield'),
160
+ new LocationRequirement('Taverley Dungeon'),
161
+ ];
162
+
163
+ export {
164
+ Requirement,
165
+ RequirementType,
166
+ SlayerLevelRequirement,
167
+ CombatLevelRequirement,
168
+ QuestRequirement,
169
+ ItemRequirement,
170
+ LocationRequirement,
171
+ SlayerUnlockRequirement,
172
+ LevelRequirement,
173
+ };
@@ -0,0 +1,82 @@
1
+ interface OsrsAccountObject {
2
+ name: string;
3
+ main: {
4
+ combatLevel: number;
5
+ questPoints: number;
6
+ skills: {
7
+ [skillName: string]: {
8
+ level: number;
9
+ };
10
+ };
11
+ };
12
+ }
13
+
14
+ class OsrsAccount {
15
+ private osrsAccount: OsrsAccountObject | null;
16
+
17
+ constructor(accountObject: OsrsAccountObject | null) {
18
+ this.osrsAccount = accountObject ? accountObject : null;
19
+ this.setQuestPoints(0);
20
+ this.setCombatLevel();
21
+ }
22
+
23
+ getName(): string | undefined {
24
+ return this.osrsAccount?.name;
25
+ }
26
+
27
+ toString(): string {
28
+ return (
29
+ (this.osrsAccount?.name ?? "") +
30
+ ": \nCombat Level: " +
31
+ (this.osrsAccount?.main.combatLevel ?? "") +
32
+ "\nQuestPoints: " +
33
+ this.getQuestPoints()
34
+ );
35
+ }
36
+
37
+ getSkills(): { [skillName: string]: { level: number } } | undefined {
38
+ return this.osrsAccount?.main.skills;
39
+ }
40
+
41
+ getSkill(skillName: string): { level: number } | undefined {
42
+ return this.osrsAccount?.main.skills[skillName.toLowerCase()];
43
+ }
44
+
45
+ getQuestPoints(): number | undefined {
46
+ return this.osrsAccount?.main.questPoints;
47
+ }
48
+
49
+ setQuestPoints(x: number): void {
50
+ if (x >= 0 && this.osrsAccount) {
51
+ this.osrsAccount.main.questPoints = x;
52
+ }
53
+ }
54
+
55
+ getCombatLevel(): number | undefined {
56
+ return this.osrsAccount?.main.combatLevel;
57
+ }
58
+
59
+ setCombatLevel(): void {
60
+ if (this.osrsAccount) {
61
+ const attklvl = this.osrsAccount.main.skills.attack?.level ?? 1;
62
+ const strlvl = this.osrsAccount.main.skills.strength?.level ?? 1;
63
+ const deflvl = this.osrsAccount.main.skills.defence?.level ?? 1;
64
+ const rangedlvl = this.osrsAccount.main.skills.ranged?.level ?? 1;
65
+ const magiclvl = this.osrsAccount.main.skills.magic?.level ?? 1;
66
+ const praylvl = this.osrsAccount.main.skills.prayer?.level ?? 1;
67
+ const hplvl = this.osrsAccount.main.skills.hitpoints?.level ?? 10;
68
+ const x = [
69
+ 0.325 * (attklvl + strlvl),
70
+ 0.325 * ((3 * rangedlvl) / 2),
71
+ 0.325 * ((3 * magiclvl) / 2),
72
+ ];
73
+ const cbMax = Math.max(...x);
74
+
75
+ this.osrsAccount.main.combatLevel =
76
+ 0.25 * (deflvl + hplvl + praylvl / 2) + cbMax
77
+ ;
78
+ }
79
+ }
80
+ }
81
+
82
+ export { OsrsAccount };