From a148c75ab22cb7af22946665c6c522c550a1f9d5 Mon Sep 17 00:00:00 2001 From: flifloo Date: Tue, 9 Jul 2019 16:28:06 +0200 Subject: [PATCH] Sorry I'm too hairy, it's pawn not paw ! --- Morpion.py | 26 +++++++++++++------------- gui.py | 16 ++++++++-------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Morpion.py b/Morpion.py index 2e8dc56..f1d5910 100644 --- a/Morpion.py +++ b/Morpion.py @@ -5,16 +5,16 @@ class Player: """self, number (int), pawn (str), name (str) A player of the party""" self.number = number # The number of the player - self.pawn = pawn # The paw of the player + self.pawn = pawn # The pawn of the player self.name = name # The name of the player - self.pawns = list() # All the paws on the grid of the player + self.pawns = list() # All the pawns on the grid of the player self.points = 0 # The points of the player def add_pawn(self, enemy: list, pos: int): """self, enemy (list), pos (int) Check if position is free by the enemy grid and add to the grid""" if (pos not in self.pawns) and (pos not in enemy): # Check the enemy grid - self.pawns.append(pos) # Add the paw to the player grid + self.pawns.append(pos) # Add the pawn to the player grid return True else: return False @@ -62,18 +62,18 @@ class Player: def __len__(self): """self - Return the number of player's paws""" + Return the number of player's panws""" return len(self.pawns) def __iter__(self): """self - Setup iterable for paws list""" + Setup iterable for pawns list""" self.iterable = 0 return self def __next__(self): """self - Return iterable of paws""" + Return iterable of pawns""" if self.iterable <= len(self.pawns)-1: # check is not exceed self.iterable += 1 return self.pawns[self.iterable-1] @@ -82,19 +82,19 @@ class Player: class Board: - """self, p1_paw (str), p1_name (str), p2_paw (str), p2_name (str) + """self, p1_pawn (str), p1_name (str), p2_pawn (str), p2_name (str) A party object""" - def __init__(self, p1_paw: str, p1_name : str, p2_paw: str, p2_name: str): - """self, p1_paw (str), p1_name (str), p2_paw (str), p2_name (str) + def __init__(self, p1_pawn: str, p1_name : str, p2_pawn: str, p2_name: str): + """self, p1_pawn (str), p1_name (str), p2_pawn (str), p2_name (str) A party object""" - # Security if conflict with players paws and name - if p1_paw == p2_paw: + # Security if conflict with players pawns and name + if p1_pawn == p2_pawn: raise ValueError("The pawns are the same !") elif p1_name == p2_name: raise ValueError("The name are the same !") - self.player1 = Player(1, p1_paw, p1_name) # Set player 1 - self.player2 = Player(2, p2_paw, p2_name) # Set player 2 + self.player1 = Player(1, p1_pawn, p1_name) # Set player 1 + self.player2 = Player(2, p2_pawn, p2_name) # Set player 2 self.curr_turn = [self.player1, self.player2] # Set turn order def check(self): diff --git a/gui.py b/gui.py index 687d082..dd5e2dc 100644 --- a/gui.py +++ b/gui.py @@ -36,11 +36,11 @@ def case(posi: int): def set_players(): - """Set players paws and name before start the party""" - if "" in [p1_paw.get(), p1_name.get(), p2_paw.get(), p2_name.get()]: # check if any empty entry + """Set players pawns and name before start the party""" + if "" in [p1_pawn.get(), p1_name.get(), p2_pawn.get(), p2_name.get()]: # check if any empty entry showerror("Error", "A entry is blank !") # Show a warning - elif p1_paw.get() == p2_paw.get(): # Check if players paws are same - showerror("Error", "Players paws are identical !") # Show a warning + elif p1_pawn.get() == p2_pawn.get(): # Check if players pawns are same + showerror("Error", "Players pawns are identical !") # Show a warning elif p1_name.get() == p2_name.get(): # Check if players names are same showerror("Error", "Players names are identical !") # Show a warning else: # If everything is fine @@ -62,20 +62,20 @@ players_p2f = LabelFrame(players_f, text="Player 2") players_p1f.grid(row=0, column=0) players_p2f.grid(row=0, column=1) -p1_paw, p1_name, p2_paw, p2_name = StringVar(), StringVar(), StringVar(), StringVar() # Setup entry value +p1_pawn, p1_name, p2_pawn, p2_name = StringVar(), StringVar(), StringVar(), StringVar() # Setup entry value # Generate symmetrically widgets for player infos -for i in [[players_p1f, p1_paw, p1_name], [players_p2f, p2_paw, p2_name]]: # List contain the frame and the entry var +for i in [[players_p1f, p1_pawn, p1_name], [players_p2f, p2_pawn, p2_name]]: # List contain the frame and the entry var Label(i[0], text="Player name:").pack() Entry(i[0], textvariable=i[2], width=20).pack() - Label(i[0], text="Player paw:").pack() + Label(i[0], text="Player pawn:").pack() Entry(i[0], textvariable=i[1], width=5).pack() Button(players, text="Submit", command=set_players).pack() # Create the submit button players.mainloop() -board = Board(p1_paw.get(), p1_name.get(), p2_paw.get(), p2_name.get()) # Create a party board +board = Board(p1_pawn.get(), p1_name.get(), p2_pawn.get(), p2_name.get()) # Create a party board # Create party window windows = Tk()