From f73541bafa0dfb1bc3a268c31b5ac238fdb7252f Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Mon, 22 Jun 2020 03:53:00 +0200 Subject: [PATCH] Tracker fine tuning --- WebHost/__init__.py | 6 ++++-- WebHost/customserver.py | 3 ++- WebHost/templates/tracker.html | 7 ++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/WebHost/__init__.py b/WebHost/__init__.py index e055ba82..a2dddb9f 100644 --- a/WebHost/__init__.py +++ b/WebHost/__init__.py @@ -94,7 +94,7 @@ def new_room(seed: int): def _read_log(path: str): if os.path.exists(path): - with open(path) as log: + with open(path, encoding="utf-8-sig") as log: yield from log else: yield f"Logfile {path} does not exist. " \ @@ -227,7 +227,9 @@ def get_tracker(room: int): for location in locations_checked: item, recipient = locations[location, player] inventory[team][recipient][links.get(item, item)] += 1 - + for (team, player), game_state in room.multisave.get("client_game_state", []): + if game_state: + inventory[team][player][106] = 1 # Triforce from MultiServer import get_item_name_from_id from Items import lookup_id_to_name player_names = {} diff --git a/WebHost/customserver.py b/WebHost/customserver.py index 5df9ed1e..8e77a213 100644 --- a/WebHost/customserver.py +++ b/WebHost/customserver.py @@ -76,7 +76,8 @@ def run_server_process(room_id, ponyconfig: dict): logging.basicConfig(format='[%(asctime)s] %(message)s', level=logging.INFO, - filename=os.path.join(LOGS_FOLDER, f"{room_id}.txt")) + handlers=[ + logging.FileHandler(os.path.join(LOGS_FOLDER, f"{room_id}.txt"), 'a', 'utf-8-sig')]) ctx = WebHostContext() ctx.load(room_id) ctx.auto_shutdown = 24 * 60 * 60 # 24 hours diff --git a/WebHost/templates/tracker.html b/WebHost/templates/tracker.html index 4d486ef7..6999f026 100644 --- a/WebHost/templates/tracker.html +++ b/WebHost/templates/tracker.html @@ -12,8 +12,9 @@ Name {% for name in tracking_names %} {% if name in icons %} - {{ name }} + {{ name }} {% else %} {{ name }} {% endif %} @@ -28,7 +29,7 @@ {% for id in tracking_ids %} {% if items[id] %} - + {% if id in multi_items %}{{ items[id] }}{% else %}✔️{% endif %} {% else %}