Skip to content

Commit

Permalink
check the names and number of players
Browse files Browse the repository at this point in the history
  • Loading branch information
Yu-jinKim committed Nov 19, 2019
1 parent 4dd7841 commit 7a53717
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions gui_monopoly.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ def choose_names(self) -> None:
error.showMessage("Can't have more than 6 players")
error.exec_()
return
elif nb_players <= 0:
error = QErrorMessage()
error.showMessage("Are you kinding me?")
error.exec_()
return

except Exception as e:
error = QErrorMessage()
Expand Down Expand Up @@ -92,6 +97,14 @@ def create_players(self) -> None:
error.showMessage("Please give all players names")
error.exec_()
return
else:
names = [player.get_name() for player in players]

if name in names:
error = QErrorMessage()
error.showMessage("2 players can't have the same name")
error.exec_()
return

players[Player(name)] = color

Expand All @@ -111,7 +124,7 @@ def __init__(self):
nb_players_layout = QGridLayout()
button_layout = QHBoxLayout()

description = QLabel("Hallo, this is my Monopoly GUI game")
description = QLabel("Hallo, this is my Monopoly GUI game. 6 players max plz")
label = QLabel("How many players? :")
self.nb_players = QLineEdit()
self.start_game = QPushButton("Start game")
Expand Down Expand Up @@ -163,7 +176,7 @@ def __init__(self, nb_players):

self.setLayout(main_layout)

def open_colordialog(self, button: QPushButton):
def open_colordialog(self, button):
""" Open color dialog to get color for token
Args:
Expand Down

0 comments on commit 7a53717

Please sign in to comment.