# Data Methods to fetch osrs data. This file has methods to fetch information about items, monsters and weapons. - - - (TItemData)= ## type TItemData ```pascal TItemData = record(TSRLBaseRecord) ITEMS_ZIP: String; ITEMS_PATH: String; Client: THTTPClient; PriceData: TJSONObject; Definitions: TJSONArray; ReloadTimer: TCountDown; IsSetup, OSRSBoxIsSetup, Disabled: Boolean; end; ``` TItemData type, responsible to handle anything that is related to item data. - - - ## ItemData.SetupWikiPrices() ```pascal procedure TItemData.SetupPrices(); ``` Internal method called automatically when we require price data. Doesn't need to be called since it will be called automatically if **ItemData.WikiPriceIsSetup** is false. It's also recalled when we try to fetch item data and 20 minutes have passed to update prices. - - - ## ItemData.GetData ```pascal function ItemData.GetData(Item: String): TJSONObject; ``` Internal method used to retrieve a TJSONObject of the Item we want information on. **Item** should be an item ID. - - - ## ItemData.GetTradeableID ```pascal function ItemData.GetTradeableID(Item: TRSItem): String; ``` Internal method used to retrieve only the tradeable version of an item if it exists. Some items have versions of themselves that are not tradeable and can't be used to fetch item prices, such as degraded items, ornamented items, etc. - - - ## ItemData.GetPrice ```pascal function ItemData.GetPrice(Item: TRSItem): TJSONObject; ``` Internal method used to fetch a price data TJSONObject of a certain item. - - - ## ItemData.GetPriceInt ```pascal function ItemData.GetPriceInt(Item: TRSItem; Key: String): Int32; ``` Wrapper method used to fetch ints from ItemData.GetPrice(). To use this you should be familar with the structure of the JSONObject ItemData.GetPrice() returns. Example: ```pascal WriteLn ItemData.GetPriceInt('Abyssal whip', 'low'); // will print the low price of abyssal whip. WriteLn ItemData.GetPriceInt('Abyssal whip', 'high'); // will print the high price of abyssal whip. ``` - - - ## ItemData.GetAverage ```pascal function ItemData.GetAverage(Item: TRSItem): Int32; ``` Method used to get the average price of **Item**. Example: ```pascal WriteLn ItemData.GetAverage('Abyssal whip'); ``` - - - ## ItemData.GetOSRSBoxInt() ```pascal function ItemData.GetOSRSBoxInt(Item: TRSItem; Key: String): Int32; ``` Wrapper method used to get the integer values of the OSRSBox item json. To use it, knowledge about the file structure is required. Example: ```pascal WriteLn ItemData.GetOSRSBoxInt('Abyssal whip', 'highalch'); //will print high alch value for the abyssal whip. ``` - - - ## ItemData.GetOSRSBoxBoolean() ```pascal function ItemData.GetOSRSBoxBoolean(Item: TRSItem; Key: String): Boolean; ``` Wrapper method used to get the boolean values of the OSRSBox item json. To use it, knowledge about the file structure is required. Example: ```pascal WriteLn ItemData.GetOSRSBoxBoolean('Abyssal whip', 'tradeable_on_ge'); ``` - - - ## ItemData.GetHighAlch() ```pascal function ItemData.GetHighAlch(Item: TRSItem): Int32; ``` Method used to get the the high alchemy value of an item. Example: ```pascal WriteLn ItemData.GetHighAlch('Magic longbow'); ``` - - - ## ItemData.GetHighAlchProfit() ```pascal function ItemData.GetHighAlchProfit(Item: TRSItem): Int32; ``` Method used to get the the high alchemy profit of an item. ```{note} HighAlchProfit = HighAlchValue - ItemAveragePrice - NatureRuneAveragePrice ``` Example: ```pascal WriteLn ItemData.GetHighAlchProfit('Magic longbow'); ``` - - - ## ItemData.GetLowAlchProfit() ```pascal function ItemData.GetLowAlchProfit(Item: TRSItem): Int32; ``` Method used to get the the low alchemy profit of an item. ```{note} LowAlchProfit = LowAlchValue - ItemAveragePrice - NatureRuneAveragePrice ``` Example: ```pascal WriteLn ItemData.GetLowAlchProfit('Magic longbow'); ``` - - - (ERSAttackType)= ## type ERSAttackType ```pascal ERSAttackType = (MELEE_ATTACK_TYPE, RANGED_ATTACK_TYPE, MAGIC_ATTACK_TYPE, TYPELESS_ATTACK_TYPE); ``` Enum of Attack types in game. Can be used to know what to pray for example. - - - (TRSMonsterDrop)= ## type TRSMonsterDrop ```pascal type TRSMonsterDrop = record Item: String; ID: String; Stackable: Boolean; Noted: Boolean; Quantity: Int32; end; TRSMonsterDropArray = array of TRSMonsterDrop; ``` Helper record to handle monster drops. Has several variable that hold information about monster drops such as wether it's stackable and/or noted and quantity. - - - (TMonsterData)= ## type TMonsterData ```pascal TMonsterData = record(TSRLBaseRecord) MONSTERS_ZIP: String; CACHE_PATH: String; Names: TStringList; Data: TJSONArray; IsSetup: Boolean; end; ``` Static TMonsterData type, responsible to handle anything that is related to monsters data. - - - ## TMonsterData.Setup() ```pascal procedure TMonsterData.Setup(); ``` Internal method to setup the TMonsterData record. - - - ## TMonsterData.GetInt() ```pascal function TMonsterData.GetInt(Monster, Key: String): Int32; ``` Wrapper method to get integer data from from monsters.json. ```{note} Using this requires you to know the structure of the monster.json file. ``` Example: ```pascal WriteLn TMonsterData.GetInt('Cow', 'hitpoints'); //This will print 8. ``` - - - ## TMonsterData.GetString() ```pascal function TMonsterData.GetString(Monster, Key: String): String; ``` Wrapper method to get string data from monsters.json. ```{note} Using this requires you to know the structure of the monster.json file. ``` Example: ```pascal WriteLn TMonsterData.GetString('Cow', 'drops'); ``` - - - ## TMonsterData.IsAgressive() ```pascal function TMonsterData.IsAgressive(Monster): String; ``` Method to get information on wether a monster is aggressive or not. Example: ```pascal WriteLn TMonsterData.IsAgressive('Cow'); //Will print False. ``` - - - ## TMonsterData.GetJSONArray() ```pascal function TMonsterData.GetJSONArray(Monster, Key: String): TJSONArray; ``` Internal method to get a TJSONArray value from monsters.json. - - - ## TMonsterData.GetJSONObject() ```pascal function TMonsterData.GetJSONObject(Monster, Key: String): TJSONObject; ``` Internal method to get a TJSONObject value from monsters.json. - - - ## TMonsterData.GetAttackTypes() ```pascal function TMonsterData.GetAttackTypes(Monster: String): array of ERSAttackType; ``` Method used to get an array of ERSAttackType used by the specified monster. - - - ## TMonsterData.GetDrop() ```pascal function TMonsterData.GetDrop(DropJSON: TJSONObject): TRSMonsterDrop; ``` Method to convert a monster json object to a TRSMonsterDrop. - - - ## TMonsterData.GetDrops() ```pascal function TMonsterData.GetDrops(Monster: String): TRSMonsterDropArray; ``` Method to return all monster drops as an array of TRSMonsterDrop. Example: ```pascal WriteLn TMonsterData.GetDrops('Abyssal demon'); //prints all monster drops. ``` - - - ## type TWeaponData ```pascal type TWeaponData = record Data: TJSONObject; IsSetup: Boolean; end; ``` Type responsible of handling anything that is related to weapons data. - - - ## WeaponData.Setup ```pascal procedure TWeaponData.Setup(); ``` Internal method to setup TWeaponData. - - - ## WeaponData.GetInt ```pascal function TWeaponData.GetInt(weapon, key: String): Int32; ``` Method to fetch integer data from weapons.json. ```{note} Using this requires knowledge of the structure of weapons.json ``` Example: ```pascal WriteLn TWeaponData.GetInt('Abyssal whip', 'special_attack'); //This will print 50. ``` - - - ## WeaponData.GetAttackType ```pascal function TWeaponData.GetAttackType(weapon: String): ERSAttackType; ``` Returns the ERSAttackType of the weapon specified. Example: ```pascal WriteLn TWeaponData.GetAttackType('Abyssal whip'); //This will print MELEE_ATTACK_TYPE. ``` - - - ## WeaponData.IsTwoHanded ```pascal function TWeaponData.IsTwoHanded(weapon: String): Boolean; ``` Returns wether the weapon is two-handed or not. Example: ```pascal WriteLn TWeaponData.IsTwoHanded('Abyssal whip'); //This will print false. ``` - - - ## WeaponData.GetRequirementsJSON ```pascal function TWeaponData.GetRequirementsJSON(weapon: String): TJSONObject; ``` Returns a TJSONObject of the level requirements for the weapon. - - - ## type TGearData ```pascal type TGearData = record Data: TJSONObject; IsSetup: Boolean; end; ``` Type responsible of handling anything that is related to weapons data. - - - ## GearData.Setup ```pascal procedure TGearData.Setup(); ``` Internal method to setup TGearData. - - - ## GearData.GetJSONArray ```pascal function TGearData.GetJSONArray(key: String): TJSONArray; ``` Method to fetch json arrays from gear.json. ```{note} Using this requires knowledge of the structure of gear.json ``` - - - ## GearData.GetItems ```pascal function TGearData.GetItems(key: String): TRSItemArray; ``` Method to fetch items under a key in gear.json.