Skip to content
Merged
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
4 changes: 2 additions & 2 deletions worlds/zillion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ZillionWebWorld(WebWorld):
"English",
"setup_en.md",
"setup/en",
["beauxq"]
["beauxq"],
)]

option_groups = z_option_groups
Expand Down Expand Up @@ -365,7 +365,7 @@ def finalize_item_locations(self) -> GenData:
z_loc.zz_loc.item = multi_item
multi_items[z_loc.zz_loc.name] = (
z_loc.item.name,
self.multiworld.get_player_name(z_loc.item.player)
self.multiworld.get_player_name(z_loc.item.player),
)
# debug_zz_loc_ids.sort()
# for name, id_ in debug_zz_loc_ids.items():
Expand Down
18 changes: 9 additions & 9 deletions worlds/zillion/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def run_gui(self) -> None:

class ZillionManager(GameManager):
logging_pairs = [
("Client", "Archipelago")
("Client", "Archipelago"),
]
base_title = "Archipelago Zillion Client"

Expand Down Expand Up @@ -282,7 +282,7 @@ def on_package(self, cmd: str, args: dict[str, Any]) -> None:

payload = {
"cmd": "Get",
"keys": [f"zillion-{self.auth}-doors"]
"keys": [f"zillion-{self.auth}-doors"],
}
async_start(self.send_msgs([payload]))
elif cmd == "Retrieved":
Expand Down Expand Up @@ -326,7 +326,7 @@ def process_from_game_queue(self) -> None:
n_locations = len(self.missing_locations) + len(self.checked_locations) - 1 # -1 to ignore win
logger.info(f"New Check: {loc_name} ({self.ap_local_count}/{n_locations})")
async_start(self.send_msgs([
{"cmd": "LocationChecks", "locations": [server_id]}
{"cmd": "LocationChecks", "locations": [server_id]},
]))
else:
# This will happen a lot in Zillion,
Expand All @@ -338,7 +338,7 @@ def process_from_game_queue(self) -> None:
if not self.finished_game:
async_start(self.send_msgs([
{"cmd": "LocationChecks", "locations": [loc_name_to_id["J-6 bottom far left"]]},
{"cmd": "StatusUpdate", "status": ClientStatus.CLIENT_GOAL}
{"cmd": "StatusUpdate", "status": ClientStatus.CLIENT_GOAL},
]))
self.finished_game = True
elif isinstance(event_from_game, events.DoorEventFromGame):
Expand All @@ -347,7 +347,7 @@ def process_from_game_queue(self) -> None:
payload = {
"cmd": "Set",
"key": f"zillion-{self.auth}-doors",
"operations": [{"operation": "replace", "value": doors_b64}]
"operations": [{"operation": "replace", "value": doors_b64}],
}
async_start(self.send_msgs([payload]))
elif isinstance(event_from_game, events.MapEventFromGame):
Expand All @@ -367,7 +367,7 @@ def process_items_received(self) -> None:
# TODO: colors in this text, like sni client?
logger.info(f"received {self.ap_id_to_name[ap_id]} from {from_name}")
self.to_game.put_nowait(
events.ItemEventToGame(zz_item_ids)
events.ItemEventToGame(zz_item_ids),
)
self.next_item = len(self.items_received)

Expand Down Expand Up @@ -398,7 +398,7 @@ async def zillion_sync_task(ctx: ZillionContext) -> None:
logger.info("Start Zillion in RetroArch, then use the /sms command to connect to it.")
await asyncio.wait((
asyncio.create_task(ctx.look_for_retroarch.wait()),
asyncio.create_task(ctx.exit_event.wait())
asyncio.create_task(ctx.exit_event.wait()),
), return_when=asyncio.FIRST_COMPLETED)

last_log = ""
Expand Down Expand Up @@ -443,7 +443,7 @@ def log_no_spam(msg: str) -> None:
await asyncio.wait((
asyncio.create_task(ctx.got_slot_data.wait()),
asyncio.create_task(ctx.exit_event.wait()),
asyncio.create_task(asyncio.sleep(6))
asyncio.create_task(asyncio.sleep(6)),
), return_when=asyncio.FIRST_COMPLETED) # to not spam connect packets
else: # not correct seed name
log_no_spam("incorrect seed - did you mix up roms?")
Expand All @@ -467,7 +467,7 @@ def log_no_spam(msg: str) -> None:
await asyncio.wait((
asyncio.create_task(ctx.got_room_info.wait()),
asyncio.create_task(ctx.exit_event.wait()),
asyncio.create_task(asyncio.sleep(6))
asyncio.create_task(asyncio.sleep(6)),
), return_when=asyncio.FIRST_COMPLETED)
else: # no name found in game
if not help_message_shown:
Expand Down
4 changes: 2 additions & 2 deletions worlds/zillion/gen_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def to_json(self) -> str:
jsonable = {
"multi_items": self.multi_items,
"zz_game": self.zz_game.to_jsonable(),
"game_id": list(self.game_id)
"game_id": list(self.game_id),
}
return json.dumps(jsonable)

Expand All @@ -37,5 +37,5 @@ def from_json(gen_data_str: str) -> "GenData":
return GenData(
from_json["multi_items"],
ZzGame.from_jsonable(from_json["zz_game"]),
bytes(from_json["game_id"])
bytes(from_json["game_id"]),
)
12 changes: 6 additions & 6 deletions worlds/zillion/id_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@


def make_id_to_others(start_char: Chars) -> tuple[
dict[int, str], dict[int, int], dict[int, ZzItem]
dict[int, str], dict[int, int], dict[int, ZzItem],
]:
""" returns id_to_name, id_to_zz_id, id_to_zz_item """
id_to_name: dict[int, str] = {}
Expand All @@ -53,19 +53,19 @@ def make_id_to_others(start_char: Chars) -> tuple[
name_to_zz_item = {
"Apple": _zz_rescue_0,
"Champ": _zz_rescue_1,
"JJ": _zz_empty
"JJ": _zz_empty,
}
elif start_char == "Apple":
name_to_zz_item = {
"Apple": _zz_empty,
"Champ": _zz_rescue_1,
"JJ": _zz_rescue_0
"JJ": _zz_rescue_0,
}
else: # Champ
name_to_zz_item = {
"Apple": _zz_rescue_0,
"Champ": _zz_empty,
"JJ": _zz_rescue_1
"JJ": _zz_rescue_1,
}

for name, ap_id in item_name_to_id.items():
Expand Down Expand Up @@ -150,10 +150,10 @@ def get_slot_info(regions: Iterable[RegionData],
rescues[str(i)] = {
"start_char": ri.start_char,
"room_code": ri.room_code,
"mask": ri.mask
"mask": ri.mask,
}
return {
"start_char": start_char,
"rescues": rescues,
"loc_mem_to_id": loc_memory_to_loc_id
"loc_mem_to_id": loc_memory_to_loc_id,
}
14 changes: 7 additions & 7 deletions worlds/zillion/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ def set_randomizer_locs(cs: CollectionState, p: int, zz_r: Randomizer) -> int:
z_world = cs.multiworld.worlds[p]
assert isinstance(z_world, ZillionWorld)

_hash = p
hash_ = p
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 \
else zz_empty
zz_r.locations[zz_name].item = zz_item
_hash += (hash(zz_name) * (z_loc.zz_loc.req.gun + 2)) ^ hash(zz_item)
return _hash
hash_ += (hash(zz_name) * (z_loc.zz_loc.req.gun + 2)) ^ hash(zz_item)
return hash_


def item_counts(cs: CollectionState, p: int) -> tuple[tuple[str, int], ...]:
Expand Down Expand Up @@ -67,11 +67,11 @@ def cs_to_zz_locs(self, cs: CollectionState) -> frozenset[Location]:
returns frozenset of accessible zilliandomizer locations
"""
# caching this function because it would be slow
_hash = set_randomizer_locs(cs, self._player, self._zz_r)
hash_ = set_randomizer_locs(cs, self._player, self._zz_r)
counts = item_counts(cs, self._player)
_hash += hash(counts)
hash_ += hash(counts)

cntr, locs = self._cache.get(_hash, _cache_miss)
cntr, locs = self._cache.get(hash_, _cache_miss)
if cntr == cs.prog_items[self._player]:
# print("cache hit")
return locs
Expand All @@ -90,6 +90,6 @@ def cs_to_zz_locs(self, cs: CollectionState) -> frozenset[Location]:
tr = frozenset(self._zz_r.get_locations(have_req))

# save result in cache
self._cache[_hash] = (cs.prog_items[self._player].copy(), tr)
self._cache[hash_] = (cs.prog_items[self._player].copy(), tr)

return tr
16 changes: 8 additions & 8 deletions worlds/zillion/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from zilliandomizer.options import (
Options as ZzOptions, char_to_gun, char_to_jump, ID,
VBLR as ZzVBLR, Chars, ItemCounts as ZzItemCounts
VBLR as ZzVBLR, Chars, ItemCounts as ZzItemCounts,
)
from zilliandomizer.options.parsing import validate as zz_validate

Expand All @@ -23,7 +23,7 @@ class ZillionContinues(NamedRange):
display_name = "continues"
special_range_names = {
"vanilla": 3,
"infinity": 21
"infinity": 21,
}


Expand Down Expand Up @@ -247,7 +247,7 @@ class ZillionStartingCards(NamedRange):
range_end = 10
display_name = "starting cards"
special_range_names = {
"vanilla": 0
"vanilla": 0,
}


Expand Down Expand Up @@ -315,8 +315,8 @@ class ZillionOptions(PerGameCommonOptions):
z_option_groups = [
OptionGroup("item counts", [
ZillionIDCardCount, ZillionBreadCount, ZillionOpaOpaCount, ZillionZillionCount,
ZillionFloppyDiskCount, ZillionScopeCount, ZillionRedIDCardCount
])
ZillionFloppyDiskCount, ZillionScopeCount, ZillionRedIDCardCount,
]),
]


Expand Down Expand Up @@ -361,7 +361,7 @@ def validate(options: ZillionOptions) -> tuple[ZzOptions, Counter[str]]:
"Zillion": options.zillion_count,
"Floppy Disk": options.floppy_disk_count,
"Scope": options.scope_count,
"Red ID Card": options.red_id_card_count
"Red ID Card": options.red_id_card_count,
})
minimums = Counter({
"ID Card": 0,
Expand All @@ -370,7 +370,7 @@ def validate(options: ZillionOptions) -> tuple[ZzOptions, Counter[str]]:
"Zillion": guns_required,
"Floppy Disk": floppy_req.value,
"Scope": 0,
"Red ID Card": 1
"Red ID Card": 1,
})
for key in minimums:
item_counts[key] = max(minimums[key], item_counts[key])
Expand Down Expand Up @@ -426,7 +426,7 @@ def validate(options: ZillionOptions) -> tuple[ZzOptions, Counter[str]]:
bool(options.early_scope.value),
True, # balance defense
starting_cards.value,
map_gen
map_gen,
)
zz_validate(zz_op)
return zz_op, item_counts
4 changes: 2 additions & 2 deletions worlds/zillion/test/TestGoal.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class TestGoalAppleStart(ZillionTestBase):
"start_char": "Apple",
"jump_levels": "balanced",
"gun_levels": "low",
"zillion_count": 5
"zillion_count": 5,
}

def test_guns_jj_first(self) -> None:
Expand All @@ -131,7 +131,7 @@ class TestGoalChampStart(ZillionTestBase):
"jump_levels": "low",
"gun_levels": "balanced",
"opa_opa_count": 5,
"opas_per_level": 1
"opas_per_level": 1,
}

def test_jump_jj_first(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion worlds/zillion/test/TestOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_vblr_ap_to_zz(self) -> None:
""" all of the valid values for the AP options map to valid values for ZZ options """
for option_name, vblr_class in (
("jump_levels", ZillionJumpLevels),
("gun_levels", ZillionGunLevels)
("gun_levels", ZillionGunLevels),
):
for value in vblr_class.name_lookup.values():
self.options = {option_name: value}
Expand Down
Loading