osrs-tools
Version:
A comprehensive TypeScript library for Old School RuneScape (OSRS) data and utilities, including quest data, skill requirements, and game item information
268 lines (267 loc) • 6.83 kB
JavaScript
/**
* Represents an item in the game. This class encapsulates all the properties and methods related to an item.
*/
export class Item {
id;
name;
examine;
value;
highAlch;
lowAlch;
weight;
members;
tradeable;
equipable;
releaseDate;
destroy;
questItem;
stackable;
noted;
notable = false;
officialWikiUrl;
iconUrl;
// Combat stats
attackStab;
attackSlash;
attackCrush;
attackMagic;
attackRanged;
defenceStab;
defenceSlash;
defenceCrush;
defenceMagic;
defenceRanged;
meleeStrength;
rangedStrength;
magicDamage;
prayer;
quantity;
constructor(id, name, examine, value, highAlch, lowAlch, weight, members, tradeable, equipable, releaseDate, destroy, questItem, stackable, noted, officialWikiUrl, iconUrl,
// Combat stats
attackStab, attackSlash, attackCrush, attackMagic, attackRanged, defenceStab, defenceSlash, defenceCrush, defenceMagic, defenceRanged, meleeStrength, rangedStrength, magicDamage, prayer, quantity, notable = false) {
this.id = id;
this.name = name;
this.examine = examine;
this.value = value;
this.highAlch = highAlch;
this.lowAlch = lowAlch;
this.weight = weight;
this.members = members;
this.tradeable = tradeable;
this.equipable = equipable;
this.releaseDate = releaseDate;
this.destroy = destroy;
this.questItem = questItem;
this.stackable = stackable;
this.noted = noted;
this.officialWikiUrl = officialWikiUrl;
this.iconUrl = iconUrl;
// Combat stats
this.attackStab = attackStab;
this.attackSlash = attackSlash;
this.attackCrush = attackCrush;
this.attackMagic = attackMagic;
this.attackRanged = attackRanged;
this.defenceStab = defenceStab;
this.defenceSlash = defenceSlash;
this.defenceCrush = defenceCrush;
this.defenceMagic = defenceMagic;
this.defenceRanged = defenceRanged;
this.meleeStrength = meleeStrength;
this.rangedStrength = rangedStrength;
this.magicDamage = magicDamage;
this.prayer = prayer;
this.quantity = quantity || 1; // Default quantity to 1 if not provided
this.notable = notable;
}
get Id() {
return this.id;
}
set Id(value) {
this.id = value;
}
get Name() {
return this.name;
}
set Name(value) {
this.name = value;
}
get Examine() {
return this.examine;
}
set Examine(value) {
this.examine = value;
}
get Value() {
return this.value;
}
set Value(value) {
this.value = value;
}
get HighAlch() {
return this.highAlch;
}
set HighAlch(value) {
this.highAlch = value;
}
get LowAlch() {
return this.lowAlch;
}
set LowAlch(value) {
this.lowAlch = value;
}
get Weight() {
return this.weight;
}
set Weight(value) {
this.weight = value;
}
get Members() {
return this.members;
}
set Members(value) {
this.members = value;
}
get Tradeable() {
return this.tradeable;
}
set Tradeable(value) {
this.tradeable = value;
}
get Equipable() {
return this.equipable;
}
set Equipable(value) {
this.equipable = value;
}
get ReleaseDate() {
return this.releaseDate;
}
set ReleaseDate(value) {
this.releaseDate = value;
}
get Destroy() {
return this.destroy;
}
set Destroy(value) {
this.destroy = value;
}
get QuestItem() {
return this.questItem;
}
set QuestItem(value) {
this.questItem = value;
}
get Stackable() {
return this.stackable;
}
set Stackable(value) {
this.stackable = value;
}
get Noted() {
return this.noted;
}
set Noted(value) {
this.noted = value;
}
get OfficialWikiUrl() {
return this.officialWikiUrl;
}
set OfficialWikiUrl(value) {
this.officialWikiUrl = value;
}
get IconUrl() {
return this.iconUrl;
}
set IconUrl(value) {
this.iconUrl = value;
}
// Combat stats getters and setters
get AttackStab() {
return this.attackStab;
}
set AttackStab(value) {
this.attackStab = value;
}
get AttackSlash() {
return this.attackSlash;
}
set AttackSlash(value) {
this.attackSlash = value;
}
get AttackCrush() {
return this.attackCrush;
}
set AttackCrush(value) {
this.attackCrush = value;
}
get AttackMagic() {
return this.attackMagic;
}
set AttackMagic(value) {
this.attackMagic = value;
}
get AttackRanged() {
return this.attackRanged;
}
set AttackRanged(value) {
this.attackRanged = value;
}
get DefenceStab() {
return this.defenceStab;
}
set DefenceStab(value) {
this.defenceStab = value;
}
get DefenceSlash() {
return this.defenceSlash;
}
set DefenceSlash(value) {
this.defenceSlash = value;
}
get DefenceCrush() {
return this.defenceCrush;
}
set DefenceCrush(value) {
this.defenceCrush = value;
}
get DefenceMagic() {
return this.defenceMagic;
}
set DefenceMagic(value) {
this.defenceMagic = value;
}
get DefenceRanged() {
return this.defenceRanged;
}
set DefenceRanged(value) {
this.defenceRanged = value;
}
get MeleeStrength() {
return this.meleeStrength;
}
set MeleeStrength(value) {
this.meleeStrength = value;
}
get RangedStrength() {
return this.rangedStrength;
}
set RangedStrength(value) {
this.rangedStrength = value;
}
get MagicDamage() {
return this.magicDamage;
}
set MagicDamage(value) {
this.magicDamage = value;
}
get Prayer() {
return this.prayer;
}
set Prayer(value) {
this.prayer = value;
}
static fromJson(json) {
return new Item(json.id, json.name, json.examine, json.value, json.highAlch, json.lowAlch, json.weight, json.members, json.tradeable, json.equipable, json.releaseDate, json.destroy, json.questItem, json.stackable, json.noted, json.officialWikiUrl, json.iconUrl, json.attackStab, json.attackSlash, json.attackCrush, json.attackMagic, json.attackRanged, json.defenceStab, json.defenceSlash, json.defenceCrush, json.defenceMagic, json.defenceRanged, json.meleeStrength, json.rangedStrength, json.magicDamage, json.prayer);
}
}