Closed mathman50 closed 2 years ago
Thanks, personally I'm not interested in having statistics, but I'll consider adding this as a configurable option.
On Mon, Jan 17, 2022 at 8:43 AM mathman50 @.***> wrote:
Code for adding a game statistics popup """ Author:- Mathman50 Modified on:- 17/01/2022 14:28:13 """ """ Add a pickle file 'current.stats' containing the list stats = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
def popupstats(self): """ Insert this function in the Wordle class and insert: self.popupstats() at the end of the lose function and the celebrate function
To load the 'current.stats' file, add the line: self.stats = pickle.load(open('current.stats', 'rb')) After the line: self.stats = pickle.load(open('answers.list', 'rb')) """ outfile = open('current.stats', 'wb') # open the pickle file to write too # noqa pickle.dump(self.stats, outfile) # dump the data to the file outfile.close() # close the file popup = tk.Toplevel(root, bg='black', relief='sunken', borderwidth=10) popup.wm_title("Stats") popup.tkraise(root) # This just tells the message to be on top of the root window. # noqa tk.Label( popup, fg='white', bg='black', text="Statistics", font=("Ariel", 24) ).pack( side="top", fill="both", pady=10 ) tk.Label( popup, fg='white', bg='black', text=( str(self.stats[6]) + " " + str(int(self.stats[7] / self.stats[6] * 100)) + " " + str(self.stats[8]) + " " + str(self.stats[9]) ), font=("Ariel", 24) ).pack( side="top", fill="both", pady=1 ) tk.Label( popup, fg='white', bg='black', text=( "Played" + " " + "Win %" + " " + "Current" + " " + "Max\n" + " " * 42 + "Streak" + " Streak" ), font=("Ariel", 10) ).pack( side="top", fill="both", pady=10 ) tk.Label( popup, fg='white', bg='black', text="GUESS DISTRIBUTION", font=("Ariel", 18) ).pack( side="top", fill="both", pady=10 ) for i in range(6): if self.guess == i: b = "green" else: b = "black" if self.stats[6] != 0: spcs = int(self.stats[i] / self.stats[6] * 25) else: spcs = 0 # x = ">" * spcs txt = str(i + 1) + ": " + ">" * spcs + str(self.stats[i]) tk.Label( popup, fg='white', bg=b, text=txt, font=("Ariel", 10), anchor="w", width=30 ).pack( side="top", fill="none", pady=2 ) tk.Button( popup, text="Okay", font=('Arial', 12), relief='raised', borderwidth=5, command=popup.destroy ).pack() popup.geometry("+%d+%d" % (700, 10))
— Reply to this email directly, view it on GitHub https://github.com/saulspatz/wordle/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPKBPJ5A3BP5PZFOW5ZJ53UWQTKZANCNFSM5ME33WKA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you are subscribed to this thread.Message ID: @.***>
No problem. Great implementation, I enjoy playing.
Code for adding a game statistics popup """ Author:- Mathman50 Modified on:- 17/01/2022 14:28:13 """ """ Add a pickle file 'current.stats' containing the list stats = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]