osrs-tools 0.2.0 → 0.2.1
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.
- package/dist/index.d.ts +8 -0
- package/dist/index.js +12 -0
- package/dist/jest.config.dev.js +7 -0
- package/dist/model/Requirement.d.ts +65 -0
- package/dist/model/Requirement.js +130 -0
- package/dist/model/account/OsrsAccount.d.ts +31 -0
- package/dist/model/account/OsrsAccount.js +64 -0
- package/dist/model/quest/Quest.d.ts +41 -0
- package/dist/model/quest/Quest.js +2 -0
- package/dist/model/quest/QuestTool.d.ts +51 -0
- package/{src/model/quest/QuestTool.ts → dist/model/quest/QuestTool.js} +78 -96
- package/dist/model/slayer/Assignment.d.ts +17 -0
- package/dist/model/slayer/Assignment.js +28 -0
- package/dist/model/slayer/SlayerMaster.d.ts +67 -0
- package/dist/model/slayer/SlayerMaster.js +112 -0
- package/dist/model/slayer/SlayerReward.d.ts +33 -0
- package/dist/model/slayer/SlayerReward.js +30 -0
- package/dist/model/slayer/Task.d.ts +85 -0
- package/dist/model/slayer/Task.js +117 -0
- package/dist/resources/slayer/Masters.d.ts +10 -0
- package/dist/resources/slayer/Masters.js +100 -0
- package/dist/resources/slayer/SlayerData.d.ts +13 -0
- package/dist/resources/slayer/SlayerData.js +42 -0
- package/dist/resources/slayer/SlayerExtends.d.ts +23 -0
- package/dist/resources/slayer/SlayerExtends.js +184 -0
- package/dist/resources/slayer/SlayerUnlock.d.ts +7 -0
- package/dist/resources/slayer/SlayerUnlock.js +67 -0
- package/dist/resources/slayer/slayerBuys.d.ts +3 -0
- package/dist/resources/slayer/slayerBuys.js +34 -0
- package/dist/resources/slayer/tasks/ChaelderTasks.d.ts +3 -0
- package/dist/resources/slayer/tasks/ChaelderTasks.js +78 -0
- package/dist/resources/slayer/tasks/DuradelTasks.d.ts +2 -0
- package/dist/resources/slayer/tasks/DuradelTasks.js +18 -0
- package/{src/resources/slayer/tasks/KonarTasks.ts → dist/resources/slayer/tasks/KonarTasks.d.ts} +3 -6
- package/dist/resources/slayer/tasks/KonarTasks.js +5 -0
- package/dist/resources/slayer/tasks/MazchnaTasks.d.ts +3 -0
- package/dist/resources/slayer/tasks/MazchnaTasks.js +4 -0
- package/dist/resources/slayer/tasks/NieveTasks.d.ts +3 -0
- package/dist/resources/slayer/tasks/NieveTasks.js +78 -0
- package/dist/resources/slayer/tasks/ReadTasks.d.ts +1 -0
- package/dist/resources/slayer/tasks/ReadTasks.js +63 -0
- package/dist/resources/slayer/tasks/SpriaTasks.d.ts +2 -0
- package/dist/resources/slayer/tasks/SpriaTasks.js +117 -0
- package/dist/resources/slayer/tasks/Tureal.d.ts +3 -0
- package/dist/resources/slayer/tasks/Tureal.js +125 -0
- package/dist/resources/slayer/tasks/VannakaTasks.d.ts +3 -0
- package/dist/resources/slayer/tasks/VannakaTasks.js +78 -0
- package/package.json +22 -19
- package/src/index.ts +0 -11
- package/src/model/Requirement.ts +0 -173
- package/src/model/account/OsrsAccount.ts +0 -82
- package/src/model/quest/Quest.ts +0 -44
- package/src/model/slayer/Assignment.ts +0 -40
- package/src/model/slayer/SlayerMaster.ts +0 -137
- package/src/model/slayer/SlayerReward.ts +0 -39
- package/src/model/slayer/Task.ts +0 -168
- package/src/resources/QuestData.json +0 -754
- package/src/resources/quest/diaries.json +0 -1171
- package/src/resources/quest/diariesArray.json +0 -0
- package/src/resources/quest/exp.json +0 -1333
- package/src/resources/quest/questData.js +0 -5628
- package/src/resources/quest/questData.json +0 -5790
- package/src/resources/quest/questDataArray.js +0 -5489
- package/src/resources/quest/questDataArray.json +0 -5489
- package/src/resources/quest/subquestArray.js +0 -58
- package/src/resources/quest/subquestArray.json +0 -58
- package/src/resources/quest/testObj.json +0 -5682
- package/src/resources/quest/testarray.json +0 -5589
- package/src/resources/quests/CooksAssistant.json +0 -34
- package/src/resources/slayer/Masters.ts +0 -180
- package/src/resources/slayer/SlayerData.ts +0 -45
- package/src/resources/slayer/SlayerExtends.ts +0 -218
- package/src/resources/slayer/SlayerUnlock.ts +0 -194
- package/src/resources/slayer/slayer.json +0 -3581
- package/src/resources/slayer/slayerBuys.ts +0 -38
- package/src/resources/slayer/slayerData.json +0 -4431
- package/src/resources/slayer/tasks/ChaelderTasks.ts +0 -235
- package/src/resources/slayer/tasks/DuradelTasks.ts +0 -75
- package/src/resources/slayer/tasks/MazchnaTasks.ts +0 -5
- package/src/resources/slayer/tasks/NieveTasks.ts +0 -235
- package/src/resources/slayer/tasks/ReadTasks.ts +0 -55
- package/src/resources/slayer/tasks/SpriaTasks.ts +0 -344
- package/src/resources/slayer/tasks/Tureal.ts +0 -436
- package/src/resources/slayer/tasks/VannakaTasks.ts +0 -236
- package/src/resources/slayer/tasks/json/Chaeldar.json +0 -348
- package/src/resources/slayer/tasks/json/Duradel.json +0 -541
- package/src/resources/slayer/tasks/json/Krystilia.json +0 -2
- package/src/resources/slayer/tasks/json/Mazchna.json +0 -379
- package/src/resources/slayer/tasks/json/Neive.json +0 -320
- package/src/resources/slayer/tasks/json/Spria.json +0 -345
- package/src/resources/slayer/tasks/json/Tureal.json +0 -341
- package/src/resources/slayer/tasks/json/Vannaka.json +0 -547
package/src/model/quest/Quest.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// SkillRequirement interface
|
|
4
|
-
interface SkillRequirement {
|
|
5
|
-
level: number; // Required skill level
|
|
6
|
-
isBoostable: boolean; // Flag to indicate if the skill is boostable
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// Quest interface
|
|
11
|
-
interface Quest {
|
|
12
|
-
id: number; // Unique identifier
|
|
13
|
-
name: string; // Quest name
|
|
14
|
-
difficulty: string; // Difficulty level
|
|
15
|
-
skillRequirements: { [skill: string]: SkillRequirement }; // Skill level requirements with boostable flag
|
|
16
|
-
status: 'Not Started' | 'In Progress' | 'Completed'; // Quest status
|
|
17
|
-
miniquest: boolean; // Is this a miniquest?
|
|
18
|
-
shortName: string; // Short name for the quest
|
|
19
|
-
url: string; // URL to the quest guide
|
|
20
|
-
series: string; // Series of the quest (e.g. 'Elf', 'Mahjarrat')
|
|
21
|
-
members: boolean; // Is this a members-only quest?
|
|
22
|
-
questPoints: number; // Quest points rewarded
|
|
23
|
-
length: string; // Length of the quest
|
|
24
|
-
age: string; // Age of the quest
|
|
25
|
-
startLocation: string; // Starting location
|
|
26
|
-
difficultyLevel: string; // Difficulty level
|
|
27
|
-
officialDifficulty: string; // Official difficulty level
|
|
28
|
-
officialLength: string; // Official length
|
|
29
|
-
officialAge: string; // Official age
|
|
30
|
-
itemRequirements: string[]; // Item requirements
|
|
31
|
-
recommendedItems: string[]; // Recommended items
|
|
32
|
-
recommendedSkills: { [skill: string]: number }; // Recommended skills
|
|
33
|
-
recommendedPrayers: string[]; // Recommended prayers
|
|
34
|
-
questRequirements: string[]; // Names of quests that need to be completed before
|
|
35
|
-
rewards: {
|
|
36
|
-
experience?: { [skill: string]: number }; // Experience rewards per skill
|
|
37
|
-
items?: string[]; // List of items rewarded
|
|
38
|
-
areas?: string[]; // List of items rewarded
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
export { Quest };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Requirement } from '../Requirement';
|
|
2
|
-
import { Task } from './Task';
|
|
3
|
-
|
|
4
|
-
// A Class that represents an assignment of a task to a player.
|
|
5
|
-
// An assignment is a specific instance of a task, with a specific quantity and requirements.
|
|
6
|
-
// The assignment is the actual task given to a player, which is based on the Task.
|
|
7
|
-
export class Assignment {
|
|
8
|
-
name: string;
|
|
9
|
-
quantity: number;
|
|
10
|
-
requirements: Requirement[];
|
|
11
|
-
extendedAmountMin?: number | null;
|
|
12
|
-
extendedAmountMax?: number | null;
|
|
13
|
-
|
|
14
|
-
constructor(
|
|
15
|
-
name: string,
|
|
16
|
-
quantity: number,
|
|
17
|
-
requirements: Requirement[],
|
|
18
|
-
extendedAmountMin?: number | null,
|
|
19
|
-
extendedAmountMax?: number | null
|
|
20
|
-
) {
|
|
21
|
-
this.name = name;
|
|
22
|
-
this.quantity = quantity;
|
|
23
|
-
this.requirements = requirements;
|
|
24
|
-
this.extendedAmountMin = extendedAmountMin ?? null;
|
|
25
|
-
this.extendedAmountMax = extendedAmountMax ?? null;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Get the task name
|
|
29
|
-
*/
|
|
30
|
-
getName(): string {
|
|
31
|
-
return this.name;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Get the quantity of the task
|
|
36
|
-
*/
|
|
37
|
-
getQuantity(): number {
|
|
38
|
-
return this.quantity;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { Assignment } from './Assignment';
|
|
2
|
-
import { Task } from './Task';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* SlayerMaster class represents a Slayer Master in the game.
|
|
6
|
-
* It encapsulates the properties and methods related to a Slayer Master,
|
|
7
|
-
* including the tasks they assign, their location, level requirements,
|
|
8
|
-
* and the ability to generate random assignments.
|
|
9
|
-
* Reference: https://oldschool.runescape.wiki/w/Duradel
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
class SlayerMaster {
|
|
13
|
-
name: string; // Name of the Slayer Master
|
|
14
|
-
totalWeight: number; // Total weight of the tasks assigned to this Slayer Master. This is used to determine the likelihood of each task being assigned.
|
|
15
|
-
location: string = ''; // Location of the Slayer Master (optional, can be set later if needed)
|
|
16
|
-
minimumCombatLevel: number = 0; // Level requirement to access this Slayer Master (optional, can be set later if needed)
|
|
17
|
-
tasks: Task[]; // Array of tasks assigned to this Slayer Master. This holds the actual tasks that players can be assigned to kill.
|
|
18
|
-
wikiUrl: string = ''; // URL for the Slayer Master (optional, can be set later if needed)
|
|
19
|
-
taskPoints: Record<number, number>; // Mapping of task intervals to points
|
|
20
|
-
eliteDiaryTaskPoints?: Record<number, number>; // Mapping of task intervals to points
|
|
21
|
-
|
|
22
|
-
// Constructor for the SlayerMaster class
|
|
23
|
-
constructor(
|
|
24
|
-
name: string,
|
|
25
|
-
tasks: Task[],
|
|
26
|
-
location: string,
|
|
27
|
-
levelRequirement: number,
|
|
28
|
-
url: string,
|
|
29
|
-
taskPoints: Record<number, number>, // Pass the task points mapping in the constructor
|
|
30
|
-
eliteDiaryTaskPoints?: Record<number, number> // Optional mapping for elite diary task points
|
|
31
|
-
) {
|
|
32
|
-
this.name = name;
|
|
33
|
-
this.tasks = tasks; // Array of tasks assigned to this Slayer Master
|
|
34
|
-
this.tasks.forEach((task) => {
|
|
35
|
-
task.weight = task.weight || 0; // Default weight to 0 if not provided
|
|
36
|
-
}); // Initialize the tasks array
|
|
37
|
-
this.totalWeight = this.calculateTotalWeight(); // Calculate the total weight of the tasks
|
|
38
|
-
this.location = location; // Default to an empty string if not provided
|
|
39
|
-
this.minimumCombatLevel = levelRequirement; // Default to 0 if not provided
|
|
40
|
-
this.wikiUrl = url; // Default to an empty string if not provided
|
|
41
|
-
this.taskPoints = taskPoints; // Initialize the task points mapping
|
|
42
|
-
this.eliteDiaryTaskPoints = eliteDiaryTaskPoints; // Optional mapping for elite diary task points
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Calculate the total weight of all tasks assigned to this Slayer Master.
|
|
47
|
-
* @returns {number} The total weight of all tasks assigned to this Slayer Master.
|
|
48
|
-
*/
|
|
49
|
-
calculateTotalWeight(): number {
|
|
50
|
-
if (this.tasks.length === 0) return 0; // Return 0 if there are no tasks
|
|
51
|
-
return this.tasks.reduce((total, task) => {
|
|
52
|
-
return total + (task.weight || 0); // Sum up the weights of all tasks
|
|
53
|
-
}, 0);
|
|
54
|
-
throw new Error('Method not implemented.');
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Get the points awarded for completing a task based on the interval.
|
|
59
|
-
* @param {number} taskInterval - The interval of the task (e.g., 1 for every task, 10 for every 10th task, etc.).
|
|
60
|
-
* @returns {number} The points awarded for the given task interval.
|
|
61
|
-
*/
|
|
62
|
-
getPointsForTaskInterval(taskInterval: number): number {
|
|
63
|
-
return this.taskPoints[taskInterval] || 0; // Return the points for the interval or 0 if not defined
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Get the location of the Slayer Master
|
|
68
|
-
*/
|
|
69
|
-
getLocation(): string {
|
|
70
|
-
return this.location;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Get the minimum combat level of the Slayer Master
|
|
75
|
-
*/
|
|
76
|
-
getMinimumCombatLevel(): number {
|
|
77
|
-
return this.minimumCombatLevel;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Get the wiki URL of the Slayer Master
|
|
82
|
-
*/
|
|
83
|
-
getWikiUrl(): string {
|
|
84
|
-
return this.wikiUrl;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Get a random task based on the weighting system of the tasks.
|
|
89
|
-
* Tasks with higher weights have a higher chance of being selected.
|
|
90
|
-
* @returns {Task | null} A randomly selected task or null if no tasks are available.
|
|
91
|
-
*/
|
|
92
|
-
getRandomTask(): Task | null {
|
|
93
|
-
if (this.tasks.length === 0) return null; // Return null if there are no tasks
|
|
94
|
-
|
|
95
|
-
const randomWeight = Math.random() * this.totalWeight; // Generate a random number between 0 and totalWeight
|
|
96
|
-
let cumulativeWeight = 0;
|
|
97
|
-
|
|
98
|
-
for (const task of this.tasks) {
|
|
99
|
-
cumulativeWeight += task.weight || 0; // Add the task's weight to the cumulative weight
|
|
100
|
-
if (randomWeight <= cumulativeWeight) {
|
|
101
|
-
return task; // Return the task if the random weight falls within its range
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return null; // Fallback in case no task is selected (shouldn't happen if weights are correct)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Get the total weight of tasks
|
|
110
|
-
*/
|
|
111
|
-
getTotalWeight(): number {
|
|
112
|
-
return this.totalWeight;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Get Name of Slayer Master
|
|
117
|
-
*/
|
|
118
|
-
getName(): string {
|
|
119
|
-
return this.name;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Get Tasks
|
|
124
|
-
*/
|
|
125
|
-
getTasks(): Task[] {
|
|
126
|
-
return this.tasks;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* toString function
|
|
131
|
-
*/
|
|
132
|
-
toString(): string {
|
|
133
|
-
return `SlayerMaster :) WIP SlayerMaster:{\nname: ${this.name}\n}`;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export { SlayerMaster };
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
class SlayerUnlock {
|
|
2
|
-
name: string;
|
|
3
|
-
cost: number;
|
|
4
|
-
description: string;
|
|
5
|
-
|
|
6
|
-
constructor({ name, cost, description }: { name: string; cost: number; description: string }) {
|
|
7
|
-
this.name = name;
|
|
8
|
-
this.cost = cost;
|
|
9
|
-
this.description = description;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
class SlayerExtend {
|
|
14
|
-
name: string;
|
|
15
|
-
cost: number;
|
|
16
|
-
notes: string;
|
|
17
|
-
|
|
18
|
-
constructor({ name, cost, notes }: { name: string; cost: number; notes: string }) {
|
|
19
|
-
this.name = name;
|
|
20
|
-
this.cost = cost;
|
|
21
|
-
this.notes = notes;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
class SlayerBuy {
|
|
26
|
-
item: string;
|
|
27
|
-
priceSoldAt: number;
|
|
28
|
-
notes: string;
|
|
29
|
-
|
|
30
|
-
constructor({ item, priceSoldAt, notes }: { item: string; priceSoldAt: number; notes: string }) {
|
|
31
|
-
this.item = item;
|
|
32
|
-
this.priceSoldAt = priceSoldAt;
|
|
33
|
-
this.notes = notes;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
class SlayerReward { }
|
|
38
|
-
|
|
39
|
-
export { SlayerUnlock, SlayerReward, SlayerExtend, SlayerBuy };
|
package/src/model/slayer/Task.ts
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { Requirement } from '../Requirement';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Represents a Slayer task in the game. This class encapsulates all the properties and methods related to a Slayer task.
|
|
5
|
-
* A Slayer task defines the monsters that players can be assigned to kill, the amount of those monsters, and various other attributes.
|
|
6
|
-
* A Task is not an assignment, but rather a template for an assignment.
|
|
7
|
-
* The assignment is the actual task given to a player, which is based on the Task.
|
|
8
|
-
*/
|
|
9
|
-
class Task {
|
|
10
|
-
name: string; // Name of the task
|
|
11
|
-
weight: number; // Weight of the task, used to determine the likelihood of being assigned this task
|
|
12
|
-
amountMin: number; // Minimum amount of monsters to kill for this task
|
|
13
|
-
amountMax: number; // Maximum amount of monsters to kill for this task
|
|
14
|
-
requirements: Requirement[]; // Array of requirements for this task
|
|
15
|
-
extendedAmountMin?: number | null; // Minimum amount for extended tasks (optional)
|
|
16
|
-
extendedAmountMax?: number | null; // Maximum amount for extended tasks (optional)
|
|
17
|
-
alternatives?: any[] | null; // Array of alternatives for this task (optional)
|
|
18
|
-
CombatLevels: number[]; // Array of combat levels for this task
|
|
19
|
-
SlayerExp: number; // Slayer experience gained from this task
|
|
20
|
-
locations: string[]; // Array of locations where this task can be found
|
|
21
|
-
WildernessLevels: number[]; // Array of wilderness levels for this task
|
|
22
|
-
bosses: string[]; // Array of bosses for this task
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Constructor for the Task class.
|
|
26
|
-
* @param name - Name of the task
|
|
27
|
-
* @param amountMin - Minimum amount of monsters to kill for this task
|
|
28
|
-
* @param amountMax - Maximum amount of monsters to kill for this task
|
|
29
|
-
* @param requirements - Array of requirements for this task
|
|
30
|
-
* @param extendedAmountMin - Minimum amount for extended tasks (optional)
|
|
31
|
-
* @param extendedAmountMax - Maximum amount for extended tasks (optional)
|
|
32
|
-
* @param weight - Weight of the task (default is 1)
|
|
33
|
-
* @param alternatives - Array of alternatives for this task (optional)
|
|
34
|
-
* @param CombatLevels - Array of combat levels for this task
|
|
35
|
-
* @param SlayerExp - Slayer experience gained from this task
|
|
36
|
-
* @param locations - Array of locations where this task can be found
|
|
37
|
-
* @param WildernessLevels - Array of wilderness levels for this task
|
|
38
|
-
* @param bosses - Array of bosses for this task
|
|
39
|
-
*/
|
|
40
|
-
constructor(
|
|
41
|
-
name: string,
|
|
42
|
-
amountMin: number,
|
|
43
|
-
amountMax: number,
|
|
44
|
-
requirements: Requirement[],
|
|
45
|
-
extendedAmountMin?: number | null,
|
|
46
|
-
extendedAmountMax?: number | null,
|
|
47
|
-
alternatives: string[] = [],
|
|
48
|
-
weight: number = 1,
|
|
49
|
-
CombatLevels: number[] = [],
|
|
50
|
-
SlayerExp: number = 0,
|
|
51
|
-
locations: string[] = [],
|
|
52
|
-
WildernessLevels: number[] = [],
|
|
53
|
-
bosses: string[] = []
|
|
54
|
-
) {
|
|
55
|
-
this.name = name;
|
|
56
|
-
this.weight = weight;
|
|
57
|
-
this.amountMin = amountMin;
|
|
58
|
-
this.amountMax = amountMax;
|
|
59
|
-
this.requirements = requirements;
|
|
60
|
-
this.extendedAmountMin = extendedAmountMin ?? null;
|
|
61
|
-
this.extendedAmountMax = extendedAmountMax ?? null;
|
|
62
|
-
this.alternatives = alternatives ?? [];
|
|
63
|
-
this.CombatLevels = CombatLevels;
|
|
64
|
-
this.SlayerExp = SlayerExp;
|
|
65
|
-
this.locations = locations;
|
|
66
|
-
this.WildernessLevels = WildernessLevels;
|
|
67
|
-
this.bosses = bosses;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
static fromJSON(json: any): Task {
|
|
71
|
-
return new Task(
|
|
72
|
-
json.name,
|
|
73
|
-
json.amountMin,
|
|
74
|
-
json.amountMax,
|
|
75
|
-
json.extendedAmountMin,
|
|
76
|
-
json.extendedAmountMax,
|
|
77
|
-
json.requirements,
|
|
78
|
-
json.alternatives,
|
|
79
|
-
json.weight,
|
|
80
|
-
json.CombatLevels,
|
|
81
|
-
json.SlayerExp,
|
|
82
|
-
json.locations,
|
|
83
|
-
json.WildernessLevels,
|
|
84
|
-
json.bosses
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Get the name of the task.
|
|
90
|
-
* @example
|
|
91
|
-
* const task = new Task("Goblin", 10, 20, [], 0, null, [], 1);
|
|
92
|
-
* console.log(task.getName()); // "Goblin"
|
|
93
|
-
* @returns
|
|
94
|
-
*/
|
|
95
|
-
getName(): string {
|
|
96
|
-
return this.name;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Get the weight of the task. The weight is used to determine the likelihood of being assigned this task compared to others.
|
|
101
|
-
* @returns {number} The weight of the task, which can be used to determine the likelihood of being assigned this task compared to others.
|
|
102
|
-
*/
|
|
103
|
-
getWeight(): number {
|
|
104
|
-
return this.weight;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Get the minimum and maximum amount of monsters to kill for this task.
|
|
109
|
-
* The amountMin and amountMax properties define the range of monsters that can be assigned for this task.
|
|
110
|
-
* @returns {number} The minimum amount of monsters to kill for this task.
|
|
111
|
-
*/
|
|
112
|
-
getAmountMin(): number {
|
|
113
|
-
return this.amountMin;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Get the maximum amount of monsters to kill for this task.
|
|
118
|
-
* @returns {number} The maximum amount of monsters to kill for this task.
|
|
119
|
-
*/
|
|
120
|
-
getAmountMax(): number {
|
|
121
|
-
return this.amountMax;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
*
|
|
126
|
-
*/
|
|
127
|
-
getRequirements(): Requirement[] {
|
|
128
|
-
return this.requirements;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
*
|
|
133
|
-
* @returns {any[]} An array of alternatives for this task. If alternatives are defined as an object, it flattens the values into a single array.
|
|
134
|
-
*/
|
|
135
|
-
getAlternatives(): any[] {
|
|
136
|
-
return this.alternatives
|
|
137
|
-
? Array.isArray(this.alternatives)
|
|
138
|
-
? this.alternatives
|
|
139
|
-
: Object.values(this.alternatives).flat()
|
|
140
|
-
: [];
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
*
|
|
145
|
-
* @returns
|
|
146
|
-
*/
|
|
147
|
-
toJSON(): any {
|
|
148
|
-
return {
|
|
149
|
-
name: this.name,
|
|
150
|
-
weight: this.weight,
|
|
151
|
-
amountMin: this.amountMin,
|
|
152
|
-
amountMax: this.amountMax,
|
|
153
|
-
unlockRequirements: this.requirements,
|
|
154
|
-
alternatives: this.alternatives,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Returns a string representation of the Task object.
|
|
160
|
-
* This method is useful for debugging and logging purposes, providing a quick overview of the task's name and other properties.
|
|
161
|
-
* @returns {string} A string representation of the Task object, useful for debugging and logging purposes.
|
|
162
|
-
*/
|
|
163
|
-
toString(): string {
|
|
164
|
-
return `Task{ name: ${this.name} }`;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export { Task };
|