osrs-tools
Version:
A comprehensive TypeScript library for Old School RuneScape (OSRS) data and utilities, including quest data, skill requirements, and game item information
62 lines (61 loc) • 2.12 kB
JavaScript
/**
* Types and interfaces for quest and skill requirements
*/
/**
* Base type for all requirements in OSRS
*/
export var RequirementType;
(function (RequirementType) {
/** Level requirement for a specific skill */
RequirementType["Level"] = "Level";
/** Required combat level */
RequirementType["CombatLevel"] = "CombatLevel";
/** Required Slayer level */
RequirementType["SlayerLevel"] = "SlayerLevel";
/** Quest that must be completed */
RequirementType["Quest"] = "Quest";
/** Number of quest points needed */
RequirementType["QuestPoint"] = "QuestPoint";
/** Item that must be possessed */
RequirementType["Item"] = "Item";
/** Location that must be accessible */
RequirementType["Location"] = "Location";
/** Slayer reward that must be unlocked */
RequirementType["SlayerUnlock"] = "SlayerUnlock";
})(RequirementType || (RequirementType = {}));
/** Helper function to create a level requirement */
export function createLevelRequirement(skillName, level, boostable = false, description) {
return {
boostable,
description: description || `${level} ${skillName}`,
level,
skillName,
type: RequirementType.Level,
};
}
/** Helper function to create a quest requirement */
export function createQuestRequirement(questName, description) {
return {
description: description || `Completion of ${questName}`,
questName,
type: RequirementType.Quest,
};
}
/** Helper function to create a quest points requirement */
export function createQuestPointRequirement(points, description) {
return {
description: description || `${points} Quest Points`,
points,
type: RequirementType.QuestPoint,
};
}
/** Helper function to create an item requirement */
export function createItemRequirement(itemName, quantity = 1, consumed = false, description) {
return {
consumed,
description: description || `${quantity}x ${itemName}${consumed ? " (consumed)" : ""}`,
itemName,
quantity,
type: RequirementType.Item,
};
}