From cf49cd5e4b6e0ddd337d7e62804ce48220bc13b3 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Wed, 3 Feb 2021 03:19:25 +0100 Subject: [PATCH] Mark Advancement items in the client --- MultiClient.py | 14 +++++++++++--- Utils.py | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/MultiClient.py b/MultiClient.py index 7ef16b02..067c7d69 100644 --- a/MultiClient.py +++ b/MultiClient.py @@ -37,6 +37,7 @@ import WebUI import Regions import Utils +import Items # logging note: # logging.* gets send to only the text console, logger.* gets send to the WebUI as well, if it's initialized. @@ -140,6 +141,13 @@ def color(text, *args): return color_code(*args) + text + color_code('reset') +def color_item(item_id: int, green: bool = False) -> str: + item_name = get_item_name_from_id(item_id) + item_colors = ['green' if green else 'cyan'] + if item_name in Items.progression_items: + item_colors.append("white_bg") + return color(item_name, *item_colors) + START_RECONNECT_DELAY = 5 SNES_RECONNECT_DELAY = 5 SERVER_RECONNECT_DELAY = 5 @@ -932,7 +940,7 @@ async def process_server_cmd(ctx: Context, cmd, args): ctx.ui_node.notify_item_sent(ctx.player_names[player_sent], ctx.player_names[player_recvd], get_item_name_from_id(item), get_location_name_from_address(location), player_sent == ctx.slot, player_recvd == ctx.slot) - item = color(get_item_name_from_id(item), 'cyan' if player_sent != ctx.slot else 'green') + item = color_item(item, player_sent == ctx.slot) player_sent = color(ctx.player_names[player_sent], 'yellow' if player_sent != ctx.slot else 'magenta') player_recvd = color(ctx.player_names[player_recvd], 'yellow' if player_recvd != ctx.slot else 'magenta') logging.info( @@ -943,7 +951,7 @@ async def process_server_cmd(ctx: Context, cmd, args): found = ReceivedItem(*args) ctx.ui_node.notify_item_found(ctx.player_names[found.player], get_item_name_from_id(found.item), get_location_name_from_address(found.location), found.player == ctx.slot) - item = color(get_item_name_from_id(found.item), 'cyan' if found.player != ctx.slot else 'green') + item = color_item(found.item, found.player == ctx.slot) player_sent = color(ctx.player_names[found.player], 'yellow' if found.player != ctx.slot else 'magenta') logging.info('%s found %s (%s)' % (player_sent, item, color(get_location_name_from_address(found.location), 'blue_bg', 'white'))) @@ -968,7 +976,7 @@ async def process_server_cmd(ctx: Context, cmd, args): get_item_name_from_id(hint.item), get_location_name_from_address(hint.location), hint.found, hint.finding_player == ctx.slot, hint.receiving_player == ctx.slot, hint.entrance if hint.entrance else None) - item = color(get_item_name_from_id(hint.item), 'green' if hint.found else 'cyan') + item = color_item(hint.item, hint.found) player_find = color(ctx.player_names[hint.finding_player], 'yellow' if hint.finding_player != ctx.slot else 'magenta') player_recvd = color(ctx.player_names[hint.receiving_player], diff --git a/Utils.py b/Utils.py index 369dba26..602b7751 100644 --- a/Utils.py +++ b/Utils.py @@ -13,7 +13,7 @@ class Version(typing.NamedTuple): micro: int -__version__ = "4.0.1" +__version__ = "4.1.0" _version_tuple = tuplize_version(__version__) import os