add available hint points to UI
This commit is contained in:
parent
e11f33b589
commit
7353b489ce
|
@ -56,6 +56,7 @@ class Context():
|
|||
self.check_points = 0
|
||||
self.forfeit_mode = ''
|
||||
self.remaining_mode = ''
|
||||
self.hint_points = 0
|
||||
# End WebUI Stuff
|
||||
|
||||
self.exit_event = asyncio.Event()
|
||||
|
@ -892,8 +893,13 @@ async def process_server_cmd(ctx: Context, cmd, args):
|
|||
|
||||
elif cmd == "AliasUpdate":
|
||||
ctx.player_names = {p: n for p, n in args}
|
||||
|
||||
elif cmd == 'Print':
|
||||
ctx.ui_node.log_info(args)
|
||||
|
||||
elif cmd == 'HintPointUpdate':
|
||||
ctx.hint_points = args[0]
|
||||
|
||||
else:
|
||||
logging.debug(f"unknown command {args}")
|
||||
|
||||
|
|
|
@ -402,6 +402,9 @@ def register_location_checks(ctx: Context, team: int, slot: int, locations):
|
|||
send_new_items(ctx)
|
||||
|
||||
if found_items:
|
||||
for client in ctx.endpoints:
|
||||
if client.team == team and client.slot == slot:
|
||||
asyncio.create_task(ctx.send_msgs(client, [["HintPointUpdate", (get_client_points(ctx, client),)]]))
|
||||
save(ctx)
|
||||
|
||||
|
||||
|
@ -702,9 +705,7 @@ class ClientMessageProcessor(CommandProcessor):
|
|||
@mark_raw
|
||||
def _cmd_hint(self, item_or_location: str = "") -> bool:
|
||||
"""Use !hint {item_name/location_name}, for example !hint Lamp or !hint Link's House. """
|
||||
points_available = self.ctx.location_check_points * len(
|
||||
self.ctx.location_checks[self.client.team, self.client.slot]) - \
|
||||
self.ctx.hint_cost * self.ctx.hints_used[self.client.team, self.client.slot]
|
||||
points_available = get_client_points(self.ctx, self.client)
|
||||
if not item_or_location:
|
||||
self.output(f"A hint costs {self.ctx.hint_cost} points. "
|
||||
f"You have {points_available} points.")
|
||||
|
@ -784,6 +785,10 @@ class ClientMessageProcessor(CommandProcessor):
|
|||
return False
|
||||
|
||||
|
||||
def get_client_points(ctx: Context, client: Client) -> int:
|
||||
return (ctx.location_check_points * len(ctx.location_checks[client.team, client.slot]) -
|
||||
ctx.hint_cost * ctx.hints_used[client.team, client.slot])
|
||||
|
||||
async def process_client_cmd(ctx: Context, client: Client, cmd, args):
|
||||
if type(cmd) is not str:
|
||||
await ctx.send_msgs(client, [['InvalidCmd']])
|
||||
|
|
2
Utils.py
2
Utils.py
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
__version__ = "2.3.2"
|
||||
__version__ = "2.3.3"
|
||||
_version_tuple = tuple(int(piece, 10) for piece in __version__.split("."))
|
||||
|
||||
import os
|
||||
|
|
2
WebUI.py
2
WebUI.py
|
@ -118,7 +118,7 @@ class WebUiClient(Node):
|
|||
def send_location_check(self, ctx: Context, last_check: str):
|
||||
self.broadcast_all(self.build_message('locationCheck', {
|
||||
'totalChecks': len(ctx.locations_checked),
|
||||
'hintPoints': 0,
|
||||
'hintPoints': ctx.hint_points,
|
||||
'lastCheck': last_check,
|
||||
}))
|
||||
|
||||
|
|
Loading…
Reference in New Issue