Zillion: remove old option access from item link validation (#2673)
* Zillion: remove old option access from item link validation and a little bit a cleaning in other stuff nearby * one option access missed
This commit is contained in:
parent
6904bd5885
commit
ed6b7b2670
|
@ -4,7 +4,7 @@ import functools
|
|||
import settings
|
||||
import threading
|
||||
import typing
|
||||
from typing import Any, Dict, List, Literal, Set, Tuple, Optional, cast
|
||||
from typing import Any, Dict, List, Set, Tuple, Optional, cast
|
||||
import os
|
||||
import logging
|
||||
|
||||
|
@ -12,7 +12,7 @@ from BaseClasses import ItemClassification, LocationProgressType, \
|
|||
MultiWorld, Item, CollectionState, Entrance, Tutorial
|
||||
from .logic import cs_to_zz_locs
|
||||
from .region import ZillionLocation, ZillionRegion
|
||||
from .options import ZillionOptions, ZillionStartChar, validate
|
||||
from .options import ZillionOptions, validate
|
||||
from .id_maps import 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
|
||||
|
@ -225,7 +225,7 @@ class ZillionWorld(World):
|
|||
loc.access_rule = access_rule
|
||||
if not (limited_skill >= zz_loc.req):
|
||||
loc.progress_type = LocationProgressType.EXCLUDED
|
||||
self.multiworld.exclude_locations[p].value.add(loc.name)
|
||||
self.options.exclude_locations.value.add(loc.name)
|
||||
here.locations.append(loc)
|
||||
self.my_locations.append(loc)
|
||||
|
||||
|
@ -288,15 +288,15 @@ class ZillionWorld(World):
|
|||
if group["game"] == "Zillion":
|
||||
assert "item_pool" in group
|
||||
item_pool = group["item_pool"]
|
||||
to_stay: Literal['Apple', 'Champ', 'JJ'] = "JJ"
|
||||
to_stay: Chars = "JJ"
|
||||
if "JJ" in item_pool:
|
||||
assert "players" in group
|
||||
group_players = group["players"]
|
||||
start_chars = cast(Dict[int, ZillionStartChar], getattr(multiworld, "start_char"))
|
||||
players_start_chars = [
|
||||
(player, start_chars[player].current_option_name)
|
||||
for player in group_players
|
||||
]
|
||||
players_start_chars: List[Tuple[int, Chars]] = []
|
||||
for player in group_players:
|
||||
z_world = multiworld.worlds[player]
|
||||
assert isinstance(z_world, ZillionWorld)
|
||||
players_start_chars.append((player, z_world.options.start_char.get_char()))
|
||||
start_char_counts = Counter(sc for _, sc in players_start_chars)
|
||||
# majority rules
|
||||
if start_char_counts["Apple"] > start_char_counts["Champ"]:
|
||||
|
@ -304,7 +304,7 @@ class ZillionWorld(World):
|
|||
elif start_char_counts["Champ"] > start_char_counts["Apple"]:
|
||||
to_stay = "Champ"
|
||||
else: # equal
|
||||
choices: Tuple[Literal['Apple', 'Champ', 'JJ'], ...] = ("Apple", "Champ")
|
||||
choices: Tuple[Chars, ...] = ("Apple", "Champ")
|
||||
to_stay = multiworld.random.choice(choices)
|
||||
|
||||
for p, sc in players_start_chars:
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
from typing import Dict, FrozenSet, Tuple, cast, List, Counter as _Counter
|
||||
from typing import Dict, FrozenSet, Tuple, List, Counter as _Counter
|
||||
|
||||
from BaseClasses import CollectionState
|
||||
|
||||
from zilliandomizer.logic_components.items import Item, items
|
||||
from zilliandomizer.logic_components.locations import Location
|
||||
from zilliandomizer.randomizer import Randomizer
|
||||
from zilliandomizer.logic_components.items import Item, items
|
||||
from .region import ZillionLocation
|
||||
|
||||
from .item import ZillionItem
|
||||
from .id_maps import item_name_to_id
|
||||
|
||||
|
@ -18,11 +20,12 @@ def set_randomizer_locs(cs: CollectionState, p: int, zz_r: Randomizer) -> int:
|
|||
|
||||
returns a hash of the player and of the set locations with their items
|
||||
"""
|
||||
from . import ZillionWorld
|
||||
z_world = cs.multiworld.worlds[p]
|
||||
my_locations = cast(List[ZillionLocation], getattr(z_world, "my_locations"))
|
||||
assert isinstance(z_world, ZillionWorld)
|
||||
|
||||
_hash = p
|
||||
for z_loc in my_locations:
|
||||
for z_loc in z_world.my_locations:
|
||||
zz_name = z_loc.zz_loc.name
|
||||
zz_item = z_loc.item.zz_item \
|
||||
if isinstance(z_loc.item, ZillionItem) and z_loc.item.player == p \
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
from collections import Counter
|
||||
from dataclasses import dataclass
|
||||
from typing import Dict, Tuple
|
||||
from typing import ClassVar, Dict, Tuple
|
||||
from typing_extensions import TypeGuard # remove when Python >= 3.10
|
||||
|
||||
from Options import DefaultOnToggle, NamedRange, PerGameCommonOptions, Range, Toggle, Choice
|
||||
|
||||
from zilliandomizer.options import \
|
||||
Options as ZzOptions, char_to_gun, char_to_jump, ID, \
|
||||
VBLR as ZzVBLR, chars, Chars, ItemCounts as ZzItemCounts
|
||||
from zilliandomizer.options import (
|
||||
Options as ZzOptions, char_to_gun, char_to_jump, ID,
|
||||
VBLR as ZzVBLR, Chars, ItemCounts as ZzItemCounts
|
||||
)
|
||||
from zilliandomizer.options.parsing import validate as zz_validate
|
||||
|
||||
|
||||
|
@ -107,6 +108,15 @@ class ZillionStartChar(Choice):
|
|||
display_name = "start character"
|
||||
default = "random"
|
||||
|
||||
_name_capitalization: ClassVar[Dict[int, Chars]] = {
|
||||
option_jj: "JJ",
|
||||
option_apple: "Apple",
|
||||
option_champ: "Champ",
|
||||
}
|
||||
|
||||
def get_char(self) -> Chars:
|
||||
return ZillionStartChar._name_capitalization[self.value]
|
||||
|
||||
|
||||
class ZillionIDCardCount(Range):
|
||||
"""
|
||||
|
@ -348,16 +358,6 @@ def validate(options: ZillionOptions) -> "Tuple[ZzOptions, Counter[str]]":
|
|||
|
||||
# that should be all of the level requirements met
|
||||
|
||||
name_capitalization: Dict[str, Chars] = {
|
||||
"jj": "JJ",
|
||||
"apple": "Apple",
|
||||
"champ": "Champ",
|
||||
}
|
||||
|
||||
start_char = options.start_char
|
||||
start_char_name = name_capitalization[start_char.current_key]
|
||||
assert start_char_name in chars
|
||||
|
||||
starting_cards = options.starting_cards
|
||||
|
||||
room_gen = options.room_gen
|
||||
|
@ -371,7 +371,7 @@ def validate(options: ZillionOptions) -> "Tuple[ZzOptions, Counter[str]]":
|
|||
max_level.value,
|
||||
False, # tutorial
|
||||
skill,
|
||||
start_char_name,
|
||||
options.start_char.get_char(),
|
||||
floppy_req.value,
|
||||
options.continues.value,
|
||||
bool(options.randomize_alarms.value),
|
||||
|
|
Loading…
Reference in New Issue