From 06164ae6cf354eb383d6de63438c48c5d614f1bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tr=C3=A9meur?= Date: Thu, 31 Oct 2024 07:25:02 +0000 Subject: [PATCH] Account for crayon losses --- loggen.py | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/loggen.py b/loggen.py index f08b308..14b8fc4 100644 --- a/loggen.py +++ b/loggen.py @@ -1,5 +1,20 @@ import datetime,os -import log,skel,tcgcore +import log,skel,tcgcore,variables + +def crayonlog(colour,event): + crayonno = event["crayons"][colour] + if variables.british: + if colour == "gray": + crayonrend = "grey" + else: + crayonrend = colour + else: + crayonrend = colour + if crayonno > 0: + crayonstring = "+" + str(crayonno) + " " + crayonrend + else: + crayonstring = str(crayonno) + " " + crayonrend + return crayonstring def loggen(): if not os.path.isdir("build/log"): @@ -26,65 +41,51 @@ def loggen(): pass try: if event["crayons"]: - crayontypes = len(event["crayons"]) - content.write("Gained crayons: ") + content.write("Crayons: ") try: - redno = event["crayons"]["red"] - content.write(str(redno) + " red") + content.write(crayonlog("red",event)) if list(event["crayons"])[-1] != "red": content.write(", ") except: pass try: - orangeno = event["crayons"]["orange"] - content.write(str(orangeno) + " orange") + content.write(crayonlog("orange",event)) if list(event["crayons"])[-1] != "orange": content.write(", ") except: pass try: - yellowno = event["crayons"]["yellow"] - content.write(str(yellowno) + " yellow") + content.write(crayonlog("yellow",event)) if list(event["crayons"])[-1] != "yellow": content.write(", ") except: pass try: - greenno = event["crayons"]["green"] - content.write(str(greenno) + " green") + content.write(crayonlog("green",event)) if list(event["crayons"])[-1] != "green": content.write(", ") except: pass try: - blueno = event["crayons"]["blue"] - content.write(str(blueno) + " blue") + content.write(crayonlog("blue",event)) if list(event["crayons"])[-1] != "blue": content.write(", ") except: pass try: - purpleno = event["crayons"]["purple"] - content.write(str(purpleno) + " purple") + content.write(crayonlog("purple",event)) if list(event["crayons"])[-1] != "purple": content.write(", ") except: pass try: - brownno = event["crayons"]["brown"] - content.write(str(brownno) + " brown") + content.write(crayonlog("brown",event)) if list(event["crayons"])[-1] != "brown": content.write(", ") except: pass try: - grayno = event["crayons"]["gray"] - if variables.british: - content.write(str(grayno) + " grey") - else: - content.write(str(grayno) + " gray") - if list(event["crayons"])[-1] != "gray": - content.write(", ") + content.write(crayonlog("gray",event)) except: pass content.write(".")