Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zillion: use useful item classification #4179

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions worlds/zillion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
import os
import logging

from BaseClasses import ItemClassification, LocationProgressType, \
MultiWorld, Item, CollectionState, Entrance, Tutorial
from BaseClasses import LocationProgressType, MultiWorld, Item, CollectionState, Entrance, Tutorial

from .gen_data import GenData
from .logic import ZillionLogicCache
Expand All @@ -18,7 +17,7 @@
from .id_maps import ZillionSlotInfo, get_slot_info, item_name_to_id as _item_name_to_id, \
loc_name_to_id as _loc_name_to_id, make_id_to_others, \
zz_reg_name_to_reg_name, base_id
from .item import ZillionItem
from .item import ZillionItem, get_classification
from .patch import ZillionPatch

from zilliandomizer.system import System
Expand Down Expand Up @@ -410,12 +409,8 @@ def create_item(self, name: str) -> Item:
self.logger.warning("warning: called `create_item` without calling `generate_early` first")
assert self.id_to_zz_item, "failed to get item maps"

classification = ItemClassification.filler
zz_item = self.id_to_zz_item[item_id]
if zz_item.required:
classification = ItemClassification.progression
if not zz_item.is_progression:
classification = ItemClassification.progression_skip_balancing
classification = get_classification(name, zz_item, self._item_counts)

z_item = ZillionItem(name, classification, item_id, self.player, zz_item)
return z_item
Expand Down
28 changes: 28 additions & 0 deletions worlds/zillion/item.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
from typing import Counter
from BaseClasses import Item, ItemClassification as IC
from zilliandomizer.logic_components.items import Item as ZzItem

_useful_thresholds = {
"Apple": 9999,
"Champ": 9999,
"JJ": 9999,
"Win": 9999,
"Empty": 0,
Copy link
Collaborator

@Exempt-Medic Exempt-Medic Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are Empty and Bread included if the default is already 0?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values are here so that it's more clear when reading this code what happens with Empty and Bread.
If this "Empty": 0, weren't here, it would take a little more mental energy for the reader to figure out what happens with it.

The default is just a safety in case something changes in the future.

"ID Card": 10,
"Red ID Card": 2,
"Floppy Disk": 7,
"Bread": 0,
"Opa-Opa": 20,
"Zillion": 8,
"Scope": 8,
}
""" make the item useful if the number in the item pool is below this number """


def get_classification(name: str, zz_item: ZzItem, item_counts: Counter[str]) -> IC:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this not accounting for extra items such as from start_inventory, item_plando, and item_links is intended / expected?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I admit I didn't think of those when writing this.

But thinking about it now, I think it's not worth the added complexity for something that won't make very much of a difference.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it's not worth changing, especially since this'll only ever make items Useful when they shouldn't be, and not the reverse.

classification = IC.filler
if zz_item.required:
classification = IC.progression
if not zz_item.is_progression:
classification = IC.progression_skip_balancing
if item_counts[name] < _useful_thresholds.get(name, 0):
classification |= IC.useful
return classification


class ZillionItem(Item):
game = "Zillion"
Expand Down
Loading