From 6ad0bbf004d35048637d67ba0abd6bd422fe59f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tr=C3=A9meur?= Date: Mon, 29 Jan 2024 20:26:02 +0000 Subject: [PATCH] Generate year backlog --- games.py | 86 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 73 insertions(+), 13 deletions(-) diff --git a/games.py b/games.py index f4f0036..8d31193 100644 --- a/games.py +++ b/games.py @@ -19,7 +19,7 @@ year = 2016 concernedfiles = [] -endlessgames = ["the sims 4 (pc)","american truck simulator (pc)","civilization iv (pc)","final fantasy xiv (pc)","medieval ii: total war (pc)","tabletop simulator (pc)","train simulator 2020 (pc)"] +endlessgames = ["the sims 4 (pc)","american truck simulator (pc)","civilization iv (pc)","final fantasy xiv (pc)","medieval ii: total war (pc)","tabletop simulator (pc)","train simulator 2020 (pc)","theatrhythm curtain call (nintendo 3ds)"] while year < int(thisyear) + 1: month = 0 @@ -141,7 +141,7 @@ def nowplaying(consolelist): if len(consolelist) > 0: thegame = consolelist[-1] try: - if thegame["gameplay"]: + if thegame["gameplay"] > (datetime.now() - timedelta(days=180)): try: if thegame["completed"]: if thegame["completed"] > thegame["gameplay"]: @@ -312,26 +312,86 @@ if endless > 0: yeargames = 0 yearplaying = 0 for game in games: - if int(game["initialdate"].year) == int(thisyear): + if game["initialdate"].year == int(thisyear): + try: + if game["gameplay"]: + if game["id"] not in endlessgames: + yeargames += 1 + except: + yeargames += 1 +for game in games: + try: + if game["beaten"].year == int(thisyear): + yeargames -= 1 + except: + try: + if game["completed"].year == int(thisyear): + yeargames -= 1 + except: + pass + +writeindex.write(" \n \n
\n \n " + thisyear + " Backlog\n ") + +if yeargames > 0: + writeindex.write("⬆") +elif yeargames < 0: + writeindex.write("⬇") + +writeindex.write(str(abs(yeargames)) + "\n \n \n") + +yearbacklog = [] +for game in games: + try: + if game["completed"].year == int(thisyear): + yearbacklog.append(game) + except: + try: + if game["beaten"].year == int(thisyear): + yearbacklog.append(game) + except: + if game["initialdate"].year == int(thisyear): + yearbacklog.append(game) + +yearcompleted = 0 +yearbeaten = 0 +yearendless = 0 +yearunfinished = 0 +yeartotal = len(yearbacklog) +if yeartotal > 0: + for game in yearbacklog: try: if game["completed"]: - pass + yearcompleted += 1 except: try: if game["beaten"]: - pass + yearbeaten += 1 except: - yeargames += 1 try: if game["gameplay"]: - yearplaying += 1 + if game["id"] in endlessgames: + yearendless += 1 + else: + yearunfinished += 1 except: pass - -writeindex.write(" \n
\n
\n \n " + thisyear + " Backlog\n " + str(yeargames) + "\n \n \n \n \n") -if yearplaying > 0: - writeindex.write(" \n \n") - +yearunplayed = yeartotal - (yearcompleted + yearbeaten + yearunfinished + yearendless) +yeartakeup = 100 +if yearunplayed > 0: + writeindex.write(" \n \n") + yeartakeup = yeartakeup - round(((yearunplayed/yeartotal)*100),1) +if yearunfinished > 0: + writeindex.write(" \n \n") + yeartakeup = yeartakeup - round(((yearunfinished/yeartotal)*100),1) +if yearbeaten > 0: + writeindex.write(" \n \n") + yeartakeup = yeartakeup - round(((yearbeaten/yeartotal)*100),1) +if yearcompleted > 0: + writeindex.write(" \n \n") + yeartakeup = yeartakeup - round(((yearcompleted/yeartotal)*100),1) +if yearendless > 0: + writeindex.write(" \n \n") + writeindex.write(" \n
\n \n
\n
\n
\n Active Backlog · " + str(backlog) + " · " + str(round(((backlog/total)*100),1)) + "%\n
\n
\n
\n
\n") compare = [] @@ -398,7 +458,7 @@ def liststats(title,abbr,consolelist): unfinished += 1 except: pass - unplayed = total - (completed + beaten + unfinished) + unplayed = total - (completed + beaten + unfinished + endless) if unplayed > 0: writeindex.write(" " + str(unplayed) + "\n") if unfinished > 0: