diff --git a/CommonClient.py b/CommonClient.py index 4892f69f..2e10f6d5 100644 --- a/CommonClient.py +++ b/CommonClient.py @@ -166,6 +166,7 @@ class CommonContext: server_address: typing.Optional[str] password: typing.Optional[str] hint_cost: typing.Optional[int] + hint_points: typing.Optional[int] player_names: typing.Dict[int, str] finished_game: bool @@ -711,6 +712,7 @@ async def process_server_cmd(ctx: CommonContext, args: dict): ctx.slot = args["slot"] # int keys get lost in JSON transfer ctx.slot_info = {int(pid): data for pid, data in args["slot_info"].items()} + ctx.hint_points = args.get("hint_points", 0) ctx.consume_players_package(args["players"]) msgs = [] if ctx.locations_checked: diff --git a/MultiServer.py b/MultiServer.py index 974886a9..57f93d67 100644 --- a/MultiServer.py +++ b/MultiServer.py @@ -700,6 +700,10 @@ class Context: targets: typing.Set[Client] = set(self.stored_data_notification_clients[key]) if targets: self.broadcast(targets, [{"cmd": "SetReply", "key": key, "value": self.hints[team, slot]}]) + self.broadcast(self.clients[team][slot], [{ + "cmd": "RoomUpdate", + "hint_points": get_slot_points(self, team, slot) + }]) def update_aliases(ctx: Context, team: int): @@ -1639,7 +1643,8 @@ async def process_client_cmd(ctx: Context, client: Client, args: dict): "players": ctx.get_players_package(), "missing_locations": get_missing_checks(ctx, team, slot), "checked_locations": get_checked_checks(ctx, team, slot), - "slot_info": ctx.slot_info + "slot_info": ctx.slot_info, + "hint_points": get_slot_points(ctx, team, slot), } reply = [connected_packet] start_inventory = get_start_inventory(ctx, slot, client.remote_start_inventory) diff --git a/docs/network protocol.md b/docs/network protocol.md index f4e261dc..052d62a5 100644 --- a/docs/network protocol.md +++ b/docs/network protocol.md @@ -128,7 +128,8 @@ Sent to clients when the connection handshake is successfully completed. | missing_locations | list\[int\] | Contains ids of remaining locations that need to be checked. Useful for trackers, among other things. | | checked_locations | list\[int\] | Contains ids of all locations that have been checked. Useful for trackers, among other things. Location ids are in the range of ± 253-1. | | slot_data | dict\[str, any\] | Contains a json object for slot related data, differs per game. Empty if not required. Not present if slot_data in [Connect](#Connect) is false. | -| slot_info | dict\[int, [NetworkSlot](#NetworkSlot)\] | maps each slot to a [NetworkSlot](#NetworkSlot) information | +| slot_info | dict\[int, [NetworkSlot](#NetworkSlot)\] | maps each slot to a [NetworkSlot](#NetworkSlot) information. | +| hint_points | int | Number of hint points that the current player has. | ### ReceivedItems Sent to clients when they receive an item. @@ -146,17 +147,16 @@ Sent to clients to acknowledge a received [LocationScouts](#LocationScouts) pack | locations | list\[[NetworkItem](#NetworkItem)\] | Contains list of item(s) in the location(s) scouted. | ### RoomUpdate -Sent when there is a need to update information about the present game session. Generally useful for async games. -Once authenticated (received Connected), this may also contain data from Connected. +Sent when there is a need to update information about the present game session. #### Arguments -The arguments for RoomUpdate are identical to [RoomInfo](#RoomInfo) barring: +RoomUpdate may contain the same arguments from [RoomInfo](#RoomInfo) and, once authenticated, arguments from +[Connected](#Connected) with the following exceptions: -| Name | Type | Notes | -| ---- | ---- | ----- | -| hint_points | int | New argument. The client's current hint points. | -| players | list\[[NetworkPlayer](#NetworkPlayer)\] | Send in the event of an alias rename. Always sends all players, whether connected or not. | -| checked_locations | list\[int\] | May be a partial update, containing new locations that were checked, especially from a coop partner in the same slot. | -| missing_locations | list\[int\] | Should never be sent as an update, if needed is the inverse of checked_locations. | +| Name | Type | Notes | +|-------------------|-----------------------------------------|-----------------------------------------------------------------------------------------------------------------------| +| players | list\[[NetworkPlayer](#NetworkPlayer)\] | Sent in the event of an alias rename. Always sends all players, whether connected or not. | +| checked_locations | list\[int\] | May be a partial update, containing new locations that were checked, especially from a coop partner in the same slot. | +| missing_locations | - | Never sent in this packet. If needed, it is the inverse of `checked_locations`. | All arguments for this packet are optional, only changes are sent. diff --git a/kvui.py b/kvui.py index 66da8c16..262f3684 100644 --- a/kvui.py +++ b/kvui.py @@ -151,11 +151,11 @@ class ServerLabel(HovererableLabel): min_cost = int(ctx.server_version >= (0, 3, 9)) text += f"\nA new !hint costs {ctx.hint_cost}% of checks made. " \ f"For you this means every " \ - f"{max(min_cost, int(ctx.hint_cost * 0.01 * ctx.total_locations))}" \ - f" location checks." + f"{max(min_cost, int(ctx.hint_cost * 0.01 * ctx.total_locations))} " \ + "location checks." \ + f"\nYou currently have {ctx.hint_points} points." elif ctx.hint_cost == 0: text += "\n!hint is free to use." - else: text += f"\nYou are not authenticated yet."