Skip to content

Commit d60043b

Browse files
committed
merged
2 parents 3cbf440 + 375f34e commit d60043b

File tree

256 files changed

+91065
-2665
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

256 files changed

+91065
-2665
lines changed

.github/labeler.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
- '!data/**'
2222
- '!.run/**'
2323
- '!.github/**'
24-
- '!worlds_disabled/**'
2524
- '!worlds/**'
2625
- '!WebHost.py'
2726
- '!WebHostLib/**'

AHITClient.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import sys
12
from worlds.ahit.Client import launch
23
import Utils
34
import ModuleUpdate
45
ModuleUpdate.update()
56

67
if __name__ == "__main__":
78
Utils.init_logging("AHITClient", exception_logger="Client")
8-
launch()
9+
launch(*sys.argv[1:])

BaseClasses.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,7 @@ class CollectionState():
736736
additional_copy_functions: List[Callable[[CollectionState, CollectionState], CollectionState]] = []
737737

738738
def __init__(self, parent: MultiWorld, allow_partial_entrances: bool = False):
739+
assert parent.worlds, "CollectionState created without worlds initialized in parent"
739740
self.prog_items = {player: Counter() for player in parent.get_all_ids()}
740741
self.multiworld = parent
741742
self.reachable_regions = {player: set() for player in parent.get_all_ids()}
@@ -1012,6 +1013,17 @@ def collect(self, item: Item, prevent_sweep: bool = False, location: Optional[Lo
10121013

10131014
return changed
10141015

1016+
def add_item(self, item: str, player: int, count: int = 1) -> None:
1017+
"""
1018+
Adds the item to state.
1019+
1020+
:param item: The item to be added.
1021+
:param player: The player the item is for.
1022+
:param count: How many of the item to add.
1023+
"""
1024+
assert count > 0
1025+
self.prog_items[player][item] += count
1026+
10151027
def remove(self, item: Item):
10161028
changed = self.multiworld.worlds[item.player].remove(self, item)
10171029
if changed:
@@ -1020,6 +1032,33 @@ def remove(self, item: Item):
10201032
self.blocked_connections[item.player] = set()
10211033
self.stale[item.player] = True
10221034

1035+
def remove_item(self, item: str, player: int, count: int = 1) -> None:
1036+
"""
1037+
Removes the item from state.
1038+
1039+
:param item: The item to be removed.
1040+
:param player: The player the item is for.
1041+
:param count: How many of the item to remove.
1042+
"""
1043+
assert count > 0
1044+
self.prog_items[player][item] -= count
1045+
if self.prog_items[player][item] < 1:
1046+
del (self.prog_items[player][item])
1047+
1048+
def set_item(self, item: str, player: int, count: int) -> None:
1049+
"""
1050+
Sets the item in state equal to the provided count.
1051+
1052+
:param item: The item to modify.
1053+
:param player: The player the item is for.
1054+
:param count: How many of the item to now have.
1055+
"""
1056+
assert count >= 0
1057+
if count == 0:
1058+
del (self.prog_items[player][item])
1059+
else:
1060+
self.prog_items[player][item] = count
1061+
10231062

10241063
class EntranceType(IntEnum):
10251064
ONE_WAY = 1

CommonClient.py

Lines changed: 54 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -266,38 +266,71 @@ def update_game(self, game: str, name_to_id_lookup_table: typing.Dict[str, int])
266266
last_death_link: float = time.time() # last send/received death link on AP layer
267267

268268
# remaining type info
269-
slot_info: typing.Dict[int, NetworkSlot]
270-
server_address: typing.Optional[str]
271-
password: typing.Optional[str]
272-
hint_cost: typing.Optional[int]
273-
hint_points: typing.Optional[int]
274-
player_names: typing.Dict[int, str]
269+
slot_info: dict[int, NetworkSlot]
270+
"""Slot Info from the server for the current connection"""
271+
server_address: str | None
272+
"""Autoconnect address provided by the ctx constructor"""
273+
password: str | None
274+
"""Password used for Connecting, expected by server_auth"""
275+
hint_cost: int | None
276+
"""Current Hint Cost per Hint from the server"""
277+
hint_points: int | None
278+
"""Current avaliable Hint Points from the server"""
279+
player_names: dict[int, str]
280+
"""Current lookup of slot number to player display name from server (includes aliases)"""
275281

276282
finished_game: bool
283+
"""
284+
Bool to signal that status should be updated to Goal after reconnecting
285+
to be used to ensure that a StatusUpdate packet does not get lost when disconnected
286+
"""
277287
ready: bool
278-
team: typing.Optional[int]
279-
slot: typing.Optional[int]
280-
auth: typing.Optional[str]
281-
seed_name: typing.Optional[str]
288+
"""Bool to keep track of state for the /ready command"""
289+
team: int | None
290+
"""Team number of currently connected slot"""
291+
slot: int | None
292+
"""Slot number of currently connected slot"""
293+
auth: str | None
294+
"""Name used in Connect packet"""
295+
seed_name: str | None
296+
"""Seed name that will be validated on opening a socket if present"""
282297

283298
# locations
284-
locations_checked: typing.Set[int] # local state
285-
locations_scouted: typing.Set[int]
286-
items_received: typing.List[NetworkItem]
287-
missing_locations: typing.Set[int] # server state
288-
checked_locations: typing.Set[int] # server state
289-
server_locations: typing.Set[int] # all locations the server knows of, missing_location | checked_locations
290-
locations_info: typing.Dict[int, NetworkItem]
299+
locations_checked: set[int]
300+
"""
301+
Local container of location ids checked to signal that LocationChecks should be resent after reconnecting
302+
to be used to ensure that a LocationChecks packet does not get lost when disconnected
303+
"""
304+
locations_scouted: set[int]
305+
"""
306+
Local container of location ids scouted to signal that LocationScouts should be resent after reconnecting
307+
to be used to ensure that a LocationScouts packet does not get lost when disconnected
308+
"""
309+
items_received: list[NetworkItem]
310+
"""List of NetworkItems recieved from the server"""
311+
missing_locations: set[int]
312+
"""Container of Locations that are unchecked per server state"""
313+
checked_locations: set[int]
314+
"""Container of Locations that are checked per server state"""
315+
server_locations: set[int]
316+
"""Container of Locations that exist per server state; a combination between missing and checked locations"""
317+
locations_info: dict[int, NetworkItem]
318+
"""Dict of location id: NetworkItem info from LocationScouts request"""
291319

292320
# data storage
293-
stored_data: typing.Dict[str, typing.Any]
294-
stored_data_notification_keys: typing.Set[str]
321+
stored_data: dict[str, typing.Any]
322+
"""
323+
Data Storage values by key that were retrieved from the server
324+
any keys subscribed to with SetNotify will be kept up to date
325+
"""
326+
stored_data_notification_keys: set[str]
327+
"""Current container of watched Data Storage keys, managed by ctx.set_notify"""
295328

296329
# internals
297-
# current message box through kvui
298330
_messagebox: typing.Optional["kvui.MessageBox"] = None
299-
# message box reporting a loss of connection
331+
"""Current message box through kvui"""
300332
_messagebox_connection_loss: typing.Optional["kvui.MessageBox"] = None
333+
"""Message box reporting a loss of connection"""
301334

302335
def __init__(self, server_address: typing.Optional[str] = None, password: typing.Optional[str] = None) -> None:
303336
# server state

0 commit comments

Comments
 (0)