Skip to content

Commit

Permalink
MultiServer: send new read_hints datastore values on change (Archipel…
Browse files Browse the repository at this point in the history
  • Loading branch information
Berserker66 authored Mar 12, 2024
1 parent c795c72 commit ae6c16b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions MultiServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,15 +707,18 @@ def on_goal_achieved(self, client: Client):
self.save() # save goal completion flag

def on_new_hint(self, team: int, slot: int):
key: str = f"_read_hints_{team}_{slot}"
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.on_changed_hints(team, slot)
self.broadcast(self.clients[team][slot], [{
"cmd": "RoomUpdate",
"hint_points": get_slot_points(self, team, slot)
}])

def on_changed_hints(self, team: int, slot: int):
key: str = f"_read_hints_{team}_{slot}"
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]}])

def on_client_status_change(self, team: int, slot: int):
key: str = f"_read_client_status_{team}_{slot}"
targets: typing.Set[Client] = set(self.stored_data_notification_clients[key])
Expand Down Expand Up @@ -975,7 +978,10 @@ def register_location_checks(ctx: Context, team: int, slot: int, locations: typi
"hint_points": get_slot_points(ctx, team, slot),
"checked_locations": new_locations, # send back new checks only
}])

old_hints = ctx.hints[team, slot].copy()
ctx.recheck_hints(team, slot)
if old_hints != ctx.hints[team, slot]:
ctx.on_changed_hints(team, slot)
ctx.save()


Expand Down

0 comments on commit ae6c16b

Please sign in to comment.