Files
dockipelago/worlds/cat_quest/items.py
Jonathan Tinney 7971961166
Some checks failed
Analyze modified files / flake8 (push) Failing after 2m28s
Build / build-win (push) Has been cancelled
Build / build-ubuntu2204 (push) Has been cancelled
ctest / Test C++ ubuntu-latest (push) Has been cancelled
ctest / Test C++ windows-latest (push) Has been cancelled
Analyze modified files / mypy (push) Has been cancelled
Build and Publish Docker Images / Push Docker image to Docker Hub (push) Successful in 5m4s
Native Code Static Analysis / scan-build (push) Failing after 5m2s
type check / pyright (push) Successful in 1m7s
unittests / Test Python 3.11.2 ubuntu-latest (push) Failing after 16m23s
unittests / Test Python 3.12 ubuntu-latest (push) Failing after 28m19s
unittests / Test Python 3.13 ubuntu-latest (push) Failing after 14m49s
unittests / Test hosting with 3.13 on ubuntu-latest (push) Successful in 5m0s
unittests / Test Python 3.13 macos-latest (push) Has been cancelled
unittests / Test Python 3.11 windows-latest (push) Has been cancelled
unittests / Test Python 3.13 windows-latest (push) Has been cancelled
add schedule I, sonic 1/frontiers/heroes, spirit island
2026-04-02 23:46:36 -07:00

93 lines
3.0 KiB
Python

from __future__ import annotations
from typing import TYPE_CHECKING
from BaseClasses import Item, ItemClassification
from .itemData import fillers, royal_arts, skills, prog_skills, prog_skill_uprades, prog_magic_levels, misc
if TYPE_CHECKING:
from .world import CatQuestWorld
ALL_ITEMS: list[Item] = fillers + royal_arts + skills + prog_skills + prog_skill_uprades + prog_magic_levels + misc
def create_item_name_to_id() -> dict[str, int]:
item_id_dict = {}
current_id = 1
for item in ALL_ITEMS:
item_id_dict[item["name"]] = current_id
current_id += 1
return item_id_dict
ITEM_NAME_TO_ID = create_item_name_to_id()
ITEM_ID_TO_NAME = {v: k for k, v in ITEM_NAME_TO_ID.items()}
def create_item_classification() -> dict[str, ItemClassification]:
item_classification_dict = {}
for item in ALL_ITEMS:
item_classification_dict[item["name"]] = item["classification"]
return item_classification_dict
DEFAULT_ITEM_CLASSIFICATIONS = create_item_classification()
class CatQuestItem(Item):
game = "Cat Quest"
def get_random_filler_item_name(world: CatQuestWorld) -> str:
return ITEM_ID_TO_NAME.get(world.random.randint(1, len(fillers)))
def create_item_with_correct_classification(world: CatQuestWorld, name: str) -> CatQuestItem:
classification = DEFAULT_ITEM_CLASSIFICATIONS[name]
skill_related_item_names = {
item["name"]
for item in (skills + prog_skills + prog_skill_uprades + prog_magic_levels)
}
if world.options.goal == "spellmastery":
if name in skill_related_item_names:
classification = ItemClassification.progression
return CatQuestItem(name, classification, ITEM_NAME_TO_ID[name], world.player)
def create_all_items(world: CatQuestWorld) -> None:
itempool = []
required_items: list[Item] = royal_arts + misc
for item in required_items:
itempool.append(world.create_item(item["name"]))
if world.options.skill_upgrade == "progressive_skills":
for skill in prog_skills:
for i in range(10):
itempool.append(world.create_item(skill["name"]))
else:
for skill in skills:
itempool.append(world.create_item(skill["name"]))
if world.options.skill_upgrade == "upgrades":
for upgrade in prog_skill_uprades:
for i in range(9):
itempool.append(world.create_item(upgrade["name"]))
if world.options.skill_upgrade == "magic_levels":
for level in prog_magic_levels:
for i in range(9):
itempool.append(world.create_item(level["name"]))
number_of_items = len(itempool)
number_of_unfilled_locations = len(world.multiworld.get_unfilled_locations(world.player))
needed_number_of_filler_items = number_of_unfilled_locations - number_of_items
itempool += [world.create_filler() for _ in range(needed_number_of_filler_items)]
world.multiworld.itempool += itempool