From 31b8c214311ad9fa5829670c297657d0f0ae1d65 Mon Sep 17 00:00:00 2001 From: meowism <64001779+meowism@users.noreply.github.com> Date: Fri, 24 Apr 2020 23:04:36 +0800 Subject: [PATCH] smol update just password message! --- Main_Merged_File.py | 88 +++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 56 deletions(-) diff --git a/Main_Merged_File.py b/Main_Merged_File.py index 0996108..6363463 100644 --- a/Main_Merged_File.py +++ b/Main_Merged_File.py @@ -8,7 +8,7 @@ This is really long, so be prepared. ''' -#import tkinter as tk # imports all names from tkinter as tk +import tkinter as tk # imports all names from tkinter as tk from tkinter import * # to import all names from tkinter # Note: It is assumed that both importing methods are used in the code. @@ -59,7 +59,6 @@ def login(): =========================================== """ global login_screen - login_screen = Toplevel(window) login_screen.title("Login") @@ -316,7 +315,7 @@ def signup_user(): elif not re.search("[!#$%&'()*+,-./:;<=>?@[\]^_`{|}~]", password_info): messagebox.showinfo("Invalid", "Password has no special characters") elif username_info.lower() in password_info.lower(): - messagebox.showinfo("Invalid", "Password should not contain the username") + messagebox.showinfo("Invalid", "Password should not contain your username.") # Note: Python reads line by line so putting this at the end works else: @@ -336,7 +335,6 @@ def signup_user(): # imported from login/signup GUI def basegame(): global game_screen - login_success_screen.destroy() login_screen.destroy() @@ -720,27 +718,10 @@ def submarine_alert_message(): else: Player["Submarine"] = "" # Restoring dictionary to empty value due to rejected spot submarine_placing_button() + +AI_player = {'Carrier':[(12,12,1), (12,13,1), (12,14,1), (12,15,1)], 'Submarine': [(12,0,0), (12,1,0), (12,2,0)]} - - -AI_player_submarine_randomizer_row = random.randint(13,20) -AI_player_submarine_randomizer_column = random.randint(1,8) - - -AI_player_surface_randomizer_row = random.randint(12,21) -AI_player_surface_randomizer_column = random.randint(11,17) - - -AI_player = {'Carrier':[(AI_player_surface_randomizer_row,AI_player_surface_randomizer_column,1), - (AI_player_surface_randomizer_row,AI_player_surface_randomizer_column+1,1), - (AI_player_surface_randomizer_row,AI_player_surface_randomizer_column+2,1), - (AI_player_surface_randomizer_row,AI_player_surface_randomizer_column+3,1)], - 'Submarine': [(AI_player_submarine_randomizer_row,AI_player_submarine_randomizer_column-1,0), - (AI_player_submarine_randomizer_row,AI_player_submarine_randomizer_column,0), - (AI_player_submarine_randomizer_row,AI_player_submarine_randomizer_column+1,0)]} - -print (AI_player) AI_counter = 0 Player_counter = 0 @@ -756,10 +737,6 @@ def redraw_boards(): global AI_frame global Player_frame global root - global surface_screen - - surface_screen.destroy() - game_screen.destroy() Player["Player Surface"] = {} Player["Player Underwater"] = {} @@ -866,7 +843,7 @@ def redraw_boards(): player_ship_location.grid(row = Player["Submarine"][i][0], column = Player["Submarine"][i][1]) - root.mainloop() + redraw_gameboard.mainloop() @@ -885,39 +862,17 @@ def AI_hit_missed(): def End_prompt(): - global redraw_gameboard - global End_prompt - global AI_counter - global Player_counter - global Player - global AI_player - global game_screen - - root.destroy() - - AI_counter = 0 - Player_counter = 0 - - Player = {} - AI_player = AI_player + global End_prompt End_prompt = Tk() - End_prompt.title("Game Over") + End_prompt.title("You Won the Game") End_prompt.geometry("250x250") End_prompt.resizable(False, False) - if AI_player == 7: - Win_announcer = Label(End_prompt, text = "BOT WON.") - Win_announcer.pack() - else: - Win_announcer = Label(End_prompt, text = "YOU WON!") - Win_announcer.pack() - - play_again = Button(End_prompt, height = 2, width = 10, - command=basegame, + command=player_boards, highlightbackground='white', text = "Play Again") play_again.place(relx = 0, rely = 0.5, anchor = W) @@ -932,15 +887,36 @@ def End_prompt(): quit_game.place(relx = 1, rely = 0.5, anchor = E) quit_game.pack() + +def play_again(): + global redraw_gameboard + global End_prompt + global AI_counter + global Player_counter + + redraw_gameboard.destroy() + End_prompt.destroy() + login_success_screen.destroy() + login_screen.destroy() + + AI_counter = 0 + Player_counter = 0 + + Player = {} + basegame() + + + def quit_battleship(): global redraw_gameboard global End_prompt global window global login_screen - global main_account_screen End_prompt.destroy() + redraw_gameboard.destroy() window.destroy() + login_screen.destroy() def draw_new_button_hit(row, column): @@ -2217,7 +2193,7 @@ def AI_player_turn(): global Player global AI_player - print ("Player Score = %d | AI Score = %d. First hit 7 wins." % (Player_counter, AI_counter)) + print ("Player counter = %d | AI counter = %d." % (Player_counter, AI_counter)) if Player_counter <= 6 and AI_counter <= 6: @@ -2260,4 +2236,4 @@ def AI_player_turn(): print ("AI Won, better luck next time") End_prompt() -main_account_screen() \ No newline at end of file +main_account_screen()