How to use osrsbox - 10 common examples

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 / test / test_items_api.py View on Github external
def test_all_items_load_items_json(path_to_docs_dir: Path):
    path_to_items_json_dir_no_slash = path_to_docs_dir / "items-json"
    path_to_items_json_dir_slash = os.path.join(path_to_docs_dir, "items-json", "")

    for path in (path_to_items_json_dir_slash, path_to_items_json_dir_no_slash):
        all_db_items = all_items.AllItems(str(path))
        assert len(all_db_items.all_items) == NUMBER_OF_ITEMS
github osrsbox / osrsbox-db / test / test_items_api.py View on Github external
def test_all_items_load_items_complete(path_to_docs_dir: Path):
    path_to_items_complete = path_to_docs_dir / "items-complete.json"

    all_db_items = all_items.AllItems(str(path_to_items_complete))
    assert len(all_db_items.all_items) == NUMBER_OF_ITEMS
github osrsbox / osrsbox-db / test / test_monsters_api.py View on Github external
def test_all_monsters_load_monsters_json(path_to_docs_dir: Path):
    path_to_monsters_json_dir_no_slash = path_to_docs_dir / "monsters-json"
    path_to_monsters_json_dir_slash = os.path.join(path_to_docs_dir, "monsters-json", "")

    for path in (path_to_monsters_json_dir_slash, path_to_monsters_json_dir_no_slash):
        all_db_monsters = all_monsters.AllMonsters(str(path))
        assert len(all_db_monsters.all_monsters) == NUMBER_OF_MONSTERS
github osrsbox / osrsbox-db / test / test_monsters_api.py View on Github external
def test_all_monsters_load_monsters_complete(path_to_docs_dir: Path):
    path_to_monsters_complete = path_to_docs_dir / "monsters-complete.json"

    all_db_monsters = all_monsters.AllMonsters(str(path_to_monsters_complete))
    assert len(all_db_monsters.all_monsters) == NUMBER_OF_MONSTERS
github osrsbox / osrsbox-db / builders / monsters / builder.py View on Github external
def main(export: bool = False, verbose: bool = False, validate: bool = True):
    # Load the current database contents
    monsters_complete_file_path = Path(config.DOCS_PATH / "monsters-complete.json")
    with open(monsters_complete_file_path) as f:
        all_db_monsters = json.load(f)

    # Load the current item database contents
    all_db_items = items_api.load()

    # Load the item wikitext file
    wiki_text_file_path = Path(config.DATA_WIKI_PATH / "page-text-monsters.json")
    with open(wiki_text_file_path) as f:
        all_wikitext_raw = json.load(f)

    # Temp loading of monster ID -> wikitext
    processed_wikitextfile_path = Path(config.DATA_WIKI_PATH / "processed-wikitext-monsters.json")
    with open(processed_wikitextfile_path) as f:
        all_wikitext_processed = json.load(f)

    # Load the raw OSRS cache monster data
    # This is the final data load, and used as baseline data for database population
    all_monster_cache_data_path = Path(config.DATA_MONSTERS_PATH / "monsters-cache-data.json")
    with open(all_monster_cache_data_path) as f:
        all_monster_cache_data = json.load(f)
github osrsbox / osrsbox-db / scripts / items / generate_items_search_file.py View on Github external
def main():
    # Output dictionary of all items in items-search
    items_search = dict()

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

    for item in all_db_items:
        # Make a temporary dictionary for each item
        temp_dict = dict()

        # Add id, name, type and duplicate status
        temp_dict["id"] = item.id
        temp_dict["name"] = item.name
        temp_dict["type"] = None
        if item.noted:
            temp_dict["type"] = "noted"
        elif item.placeholder:
            temp_dict["type"] = "placeholder"
        else:
            temp_dict["type"] = "normal"
        temp_dict["duplicate"] = item.duplicate
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...