Zillion: use Option.current_key

and other minor fixes
This commit is contained in:
beauxq 2023-03-06 19:14:25 -08:00 committed by black-sliver
parent 8ca25fed63
commit e6109394ad
4 changed files with 18 additions and 14 deletions

View File

@ -2,13 +2,12 @@ from collections import deque, Counter
from contextlib import redirect_stdout from contextlib import redirect_stdout
import functools import functools
import threading import threading
from typing import Any, Dict, List, Set, Tuple, Optional, cast from typing import Any, Dict, List, Literal, Set, Tuple, Optional, cast
import os import os
import logging import logging
from BaseClasses import ItemClassification, LocationProgressType, \ from BaseClasses import ItemClassification, LocationProgressType, \
MultiWorld, Item, CollectionState, Entrance, Tutorial MultiWorld, Item, CollectionState, Entrance, Tutorial
from Options import AssembleOptions
from .logic import cs_to_zz_locs from .logic import cs_to_zz_locs
from .region import ZillionLocation, ZillionRegion from .region import ZillionLocation, ZillionRegion
from .options import ZillionStartChar, zillion_options, validate from .options import ZillionStartChar, zillion_options, validate
@ -48,17 +47,17 @@ class ZillionWorld(World):
game = "Zillion" game = "Zillion"
web = ZillionWebWorld() web = ZillionWebWorld()
option_definitions: Dict[str, AssembleOptions] = zillion_options option_definitions = zillion_options
topology_present: bool = True # indicate if world type has any meaningful layout/pathing topology_present = True # indicate if world type has any meaningful layout/pathing
# map names to their IDs # map names to their IDs
item_name_to_id: Dict[str, int] = _item_name_to_id item_name_to_id = _item_name_to_id
location_name_to_id: Dict[str, int] = _loc_name_to_id location_name_to_id = _loc_name_to_id
# increment this every time something in your world's names/id mappings changes. # increment this every time something in your world's names/id mappings changes.
# While this is set to 0 in *any* AutoWorld, the entire DataPackage is considered in testing mode and will be # While this is set to 0 in *any* AutoWorld, the entire DataPackage is considered in testing mode and will be
# retrieved by clients on every connection. # retrieved by clients on every connection.
data_version: int = 1 data_version = 1
logger: logging.Logger logger: logging.Logger
@ -250,7 +249,7 @@ class ZillionWorld(World):
if group["game"] == "Zillion": if group["game"] == "Zillion":
assert "item_pool" in group assert "item_pool" in group
item_pool = group["item_pool"] item_pool = group["item_pool"]
to_stay = "JJ" to_stay: Literal['Apple', 'Champ', 'JJ'] = "JJ"
if "JJ" in item_pool: if "JJ" in item_pool:
assert "players" in group assert "players" in group
group_players = group["players"] group_players = group["players"]

View File

@ -42,6 +42,7 @@ def item_counts(cs: CollectionState, p: int) -> Tuple[Tuple[str, int], ...]:
LogicCacheType = Dict[int, Tuple[_Counter[Tuple[str, int]], FrozenSet[Location]]] LogicCacheType = Dict[int, Tuple[_Counter[Tuple[str, int]], FrozenSet[Location]]]
""" { hash: (cs.prog_items, accessible_locations) } """
def cs_to_zz_locs(cs: CollectionState, p: int, zz_r: Randomizer, id_to_zz_item: Dict[int, Item]) -> FrozenSet[Location]: def cs_to_zz_locs(cs: CollectionState, p: int, zz_r: Randomizer, id_to_zz_item: Dict[int, Item]) -> FrozenSet[Location]:

View File

@ -276,14 +276,14 @@ def validate(world: "MultiWorld", p: int) -> "Tuple[ZzOptions, Counter[str]]":
skill = wo.skill[p].value skill = wo.skill[p].value
jump_levels = cast(ZillionJumpLevels, wo.jump_levels[p]) jump_levels = cast(ZillionJumpLevels, wo.jump_levels[p])
jump_option = jump_levels.get_current_option_name().lower() jump_option = jump_levels.current_key
required_level = char_to_jump["Apple"][cast(ZzVBLR, jump_option)].index(3) + 1 required_level = char_to_jump["Apple"][cast(ZzVBLR, jump_option)].index(3) + 1
if skill == 0: if skill == 0:
# because of hp logic on final boss # because of hp logic on final boss
required_level = 8 required_level = 8
gun_levels = cast(ZillionGunLevels, wo.gun_levels[p]) gun_levels = cast(ZillionGunLevels, wo.gun_levels[p])
gun_option = gun_levels.get_current_option_name().lower() gun_option = gun_levels.current_key
guns_required = char_to_gun["Champ"][cast(ZzVBLR, gun_option)].index(3) guns_required = char_to_gun["Champ"][cast(ZzVBLR, gun_option)].index(3)
floppy_req = cast(ZillionFloppyReq, wo.floppy_req[p]) floppy_req = cast(ZillionFloppyReq, wo.floppy_req[p])
@ -347,10 +347,14 @@ def validate(world: "MultiWorld", p: int) -> "Tuple[ZzOptions, Counter[str]]":
# that should be all of the level requirements met # that should be all of the level requirements met
name_capitalization = {
"jj": "JJ",
"apple": "Apple",
"champ": "Champ",
}
start_char = cast(ZillionStartChar, wo.start_char[p]) start_char = cast(ZillionStartChar, wo.start_char[p])
start_char_name = start_char.get_current_option_name() start_char_name = name_capitalization[start_char.current_key]
if start_char_name == "Jj":
start_char_name = "JJ"
assert start_char_name in chars assert start_char_name in chars
start_char_name = cast(Chars, start_char_name) start_char_name = cast(Chars, start_char_name)

View File

@ -15,7 +15,7 @@ class ZillionRegion(Region):
name: str, name: str,
hint: str, hint: str,
player: int, player: int,
multiworld: Optional[MultiWorld] = None) -> None: multiworld: MultiWorld) -> None:
super().__init__(name, player, multiworld, hint) super().__init__(name, player, multiworld, hint)
self.zz_r = zz_r self.zz_r = zz_r