How to use the osrsbox.items_api function in osrsbox

To help you get started, we’ve selected a few osrsbox examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github osrsbox / osrsbox-db / osrsbox / items_api_examples / print_all_items.py View on Github external
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.  If not, see .
###############################################################################
"""

from osrsbox import items_api


if __name__ == "__main__":
    # Load all items
    all_db_items = items_api.load()

    # Loop through all items in the database and print the item name for each item
    for item in all_db_items:
        # print(item.id, item.name)  # Old, simple printing method
        print(f"{item.id:<6} {item.name}")  # New, f-strings printing method
github osrsbox / osrsbox-db / scripts / items / generate_dmm_only_items.py View on Github external
def main():
    # Output dictionary of DMM-only items
    dmm_only_items = dict()

    # Start processing all items in database
    all_db_items = items_api.load()

    for item in all_db_items:
        if item.name in DMM_MODE_ITEM_NAMES:
            dmm_only_items[item.id] = item.name

    # Write out file
    out_fi_path = Path(config.DATA_ITEMS_PATH / "dmm-only-items.json")
    with open(out_fi_path, "w") as f:
        json.dump(dmm_only_items, f, indent=4)
github osrsbox / osrsbox-db / scripts / items / generate_buy_limits.py View on Github external
def main():
    # Load all items from osrsbox item API
    all_db_items = items_api.load()

    # Get a dict with: id -> ItemProperties
    all_item_ids = dict()
    for item in all_db_items:
        all_item_ids[item.id] = item

    # Load the ge-limits-ids.json file from RuneLite
    ge_limits_path = Path(config.DATA_ITEMS_PATH / "ge-limits-ids.json")
    with open(ge_limits_path) as f:
        ge_limits = json.load(f)

    # Make a dict of: name -> buy_limit
    buy_limits = dict()
    for item_id, buy_limit in ge_limits.items():
        item_id = int(item_id)
        item_name = all_item_ids[item_id].name
github osrsbox / osrsbox-db / scripts / items / check_item_ammo_requirements.py View on Github external
def main():
    # Start processing all items in database
    all_db_items = items_api.load()

    # Load current file
    iar_file = Path(config.DATA_ITEMS_PATH / "ammo-requirements.json")
    with open(iar_file) as f:
        known_ammo = json.load(f)

    done = list()
    for i in known_ammo:
        done.append(i)

    for item in all_db_items:
        if item.id in BAD_IDS:
            # Item ID is not really ammo, skip to next
            continue
        if str(item.id) in done:
            # Item is already processed...
github osrsbox / osrsbox-db / osrsbox / items_api_examples / print_sort_item_releases.py View on Github external
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.  If not, see .
###############################################################################
"""

import collections
import datetime

from osrsbox import items_api


if __name__ == "__main__":
    # Load all items
    all_db_items = items_api.load()

    items_by_release_date = collections.defaultdict(list)

    # Loop through all items in the database
    for item in all_db_items:
        if item.release_date:  # Check item has a release date (aka, not None)
            # Convert date string to a Python datetime object
            datetime_object = datetime.datetime.strptime(item.release_date, '%Y-%m-%d')
            # Append item object to dictionary > list
            items_by_release_date[datetime_object].append(item)

    # Sort dictionary by release date
    items_by_release_date = sorted(items_by_release_date.items())

    # Loop dictionary
    for release_date, items in items_by_release_date:
github osrsbox / osrsbox-db / scripts / update / update_json_files.py View on Github external
def generate_item_slot_files():
    """Generate the `docs/items-slot/` JSON files."""
    # Read in the item database content
    all_db_items = items_api.load()

    items = collections.defaultdict(list)

    # Fetch every equipable item with an item slot value
    for item in all_db_items:
        if item.equipable_by_player:
            items[item.equipment.slot].append(item)

    # Process each item found, and add to an individual file for each equipment slot
    for slot in items:
        json_out = {}
        for item in items[slot]:
            json_out_temp = item.construct_json()
            json_out[item.id] = json_out_temp
        out_fi = Path(config.DOCS_PATH / "items-json-slot" / f"items-{slot}.json")
        with open(out_fi, "w") as f: