From 2f8f021d0639246e33ac8dcfad4e4d4dbefc4320 Mon Sep 17 00:00:00 2001 From: Mez Date: Sun, 10 Aug 2025 09:35:29 +0100 Subject: [PATCH] Add monthly acrostics function --- tools.py | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 111 insertions(+), 1 deletion(-) diff --git a/tools.py b/tools.py index 64faff1..8cc40c9 100644 --- a/tools.py +++ b/tools.py @@ -1844,13 +1844,119 @@ def recentpri(): print(", ".join(recentcards)) else: print("None received") + +def acrostics(monthly=False): + startdate = input("Enter the start date (MMDD): ") + themonth = int(startdate[0:2]) + theday = int(startdate[2:4]) + urls = [] + for event in log.log: + if event["date"].year == datetime.datetime.today().year: + if event["date"].month >= themonth: + if event["date"].day >= theday: + if "trade with " in event["event"]: + try: + if event["received"]: + urls.append(event["url"]) + except: + pass + candidates = [] + for event in log.log: + if event["url"] in urls: + try: + for card in event["received"]: + if "sig_" not in card: + carddict = {} + carddict["card"] = card + carddict["player"] = event["event"][11:] + carddict["url"] = event["url"] + candidates.append(carddict) + except: + pass + try: + for card in event["lost"]: + if "sig_" not in card: + carddict = {} + carddict["card"] = card + carddict["player"] = event["event"][11:] + carddict["url"] = event["url"] + candidates.append(carddict) + except: + pass + maxcards = {} + for card in candidates: + theplayer = card["player"] + if theplayer in maxcards: + maxcards[theplayer] += 1 + else: + maxcards[theplayer] = 1 + for player in maxcards: + maxcards[player] = int(maxcards[player] / 2) + if monthly: + word = input("Enter the monthly phrase: ").replace(" ","").replace(",","").replace("'","#").replace("-","#").lower() + else: + word = input("Enter the weekly word: ").replace(" ","").lower() + wordspace = [] + places = len(word) + while places > 0: + wordspace.append("") + places -= 1 + for card in candidates: + wordindex = 0 + go = True + theplayer = card["player"] + if maxcards[theplayer] > 0: + for space in wordspace: + if go: + if space == "": + if len(colors.cardlist) + colors.tradepend > 800 and monthly: + if word[wordindex] == "#": + if card["card"][0] == "0" or card["card"][0] == "1" or card["card"][0] == "2" or card["card"][0] == "3" or card["card"][0] == "4" or card["card"][0] == "5" or card["card"][0] == "6" or card["card"][0] == "7" or card["card"][0] == "8" or card["card"][0] == "9": + newspace = word[wordindex].upper() + " " + card["card"] + " – " + card["player"] + "" + wordspace[wordindex] = newspace + go = False + theplayer = card["player"] + maxcards[theplayer] -= 1 + else: + if card["card"][0] == word[wordindex]: + newspace = word[wordindex].upper() + " " + card["card"] + " – " + card["player"] + "" + wordspace[wordindex] = newspace + go = False + theplayer = card["player"] + maxcards[theplayer] -= 1 + else: + if word[wordindex] == "#": + if "0" in card["card"] or "1" in card["card"] or "2" in card["card"] or "3" in card["card"] or "4" in card["card"] or "5" in card["card"] or "6" in card["card"] or "7" in card["card"] or "8" in card["card"] or "9" in card["card"]: + newspace = word[wordindex].upper() + " " + card["card"] + " – " + card["player"] + "" + wordspace[wordindex] = newspace + go = False + theplayer = card["player"] + maxcards[theplayer] -= 1 + else: + if word[wordindex] in card["card"]: + newspace = word[wordindex].upper() + " " + card["card"] + " – " + card["player"] + "" + wordspace[wordindex] = newspace + go = False + theplayer = card["player"] + maxcards[theplayer] -= 1 + wordindex += 1 + remaining = [] + spaceindex = 0 + for space in wordspace: + if space == "": + remaining.append(word[spaceindex].upper()) + spaceindex += 1 + if len(remaining) > 0: + print("Still need " + ", ".join(remaining)) + else: + print("\n" + "\n".join(wordspace) + "\n") if __name__ == "__main__": while True: index = 0 # adapted from https://stackoverflow.com/a/64536882 indexValidList = [] print("Choose from the list:") - options = ["Generate next palette portfolio","Generate next monochrome portfolio","Generate Switch It Up request","Generate Swap Station request","Generate Go Fish comment","Generate Release Roulette comment","Generate Riku’s Favors comment","Generate Natsume’s Book of Cards comment","Generate Little Spell Academia comment","Generate art shop request","Generate art studio request","Check a trade offer","Propose a trade","Get a list of random cards from tradepile (excluding specials)","Get a list of random cards from tradepile (including specials)","Check a card in the collection","Check details of a deck","See decks mastered today","See most wanted character cards","See most wanted special cards","Show wanted cards gained yesterday + today","See some statistics about the collection"] + options = ["Generate next palette portfolio","Generate next monochrome portfolio","Generate Switch It Up request","Generate Swap Station request","Generate Go Fish comment","Generate Release Roulette comment","Generate Riku’s Favors comment","Generate Natsume’s Book of Cards comment","Generate Little Spell Academia comment","Generate weekly acrostics comment","Generate monthly acrostics comment","Generate art shop request","Generate art studio request","Check a trade offer","Propose a trade","Get a list of random cards from tradepile (excluding specials)","Get a list of random cards from tradepile (including specials)","Check a card in the collection","Check details of a deck","See decks mastered today","See most wanted character cards","See most wanted special cards","Show wanted cards gained yesterday + today","See some statistics about the collection"] for optionName in options: index = index + 1 indexValidList.extend([options.index(optionName)]) @@ -1910,5 +2016,9 @@ if __name__ == "__main__": lsa() elif chosen == "Show wanted cards gained yesterday + today": recentpri() + elif chosen == "Generate weekly acrostics comment": + acrostics() + elif chosen == "Generate monthly acrostics comment": + acrostics(True) print("\n") input("Press Enter to continue or Ctrl-C to exit")