Browse Source

3.141592653589

master
BARRAUX Arthur 3 years ago
parent
commit
c9760cd8b3
  1. 14
      main_tk.py

14
main_tk.py

@ -12,10 +12,12 @@ class Machine_a_sous:
def saisie(self): def saisie(self):
"""demande à l'utilisateur une mise""" """demande à l'utilisateur une mise"""
print('saisie')
if not 100 > self.mise >= 0 or not self.mise <= self.argent: # tant que mise n'est pas compris entre 0-100 et > mise if not 100 > self.mise >= 0 or not self.mise <= self.argent: # tant que mise n'est pas compris entre 0-100 et > mise
return False return False
if self.mise > self.argent or self.mise == 0: if self.mise > self.argent or self.mise == 0:
return "quit" return "quit"
else:
self.bank += self.mise self.bank += self.mise
self.argent -= self.mise self.argent -= self.mise
return self.mise return self.mise
@ -26,6 +28,9 @@ class Machine_a_sous:
return self.nombres return self.nombres
def gain(self): def gain(self):
print('hello')
print(self.mise, self.argent, self.bank)
print(self.nombres)
if len(set(self.nombres)) == 1 and 9 in self.nombres: if len(set(self.nombres)) == 1 and 9 in self.nombres:
self.gains = self.bank + self.mise self.gains = self.bank + self.mise
self.argent += self.gains self.argent += self.gains
@ -51,7 +56,6 @@ class Machine_a_sous:
class Game_gui: class Game_gui:
def __init__(self): def __init__(self):
self.bg_color = '#777777' self.bg_color = '#777777'
self.fen = tk.Tk() self.fen = tk.Tk()
self.fen.geometry('900x600') self.fen.geometry('900x600')
self.fen.title('Bellagio') self.fen.title('Bellagio')
@ -82,14 +86,16 @@ class Game_gui:
def play(self, event): def play(self, event):
machine.mise = int(self.entry_mise.get()) machine.mise = int(self.entry_mise.get())
if machine.saisie() == "quit": mise_state = machine.saisie()
if mise_state == "quit":
self.fen.quit() self.fen.quit()
elif machine.saisie() != False: elif mise_state != False:
machine.nbAlea() machine.nbAlea()
machine.gain() machine.gain()
self.name_info = [machine.bank, machine.mise, machine.argent] self.name_info = [machine.bank, machine.mise, machine.argent]
print(self.name_info)
self.maj_graph() self.maj_graph()
if machine.bank <= 500: if machine.bank <= 500 or machine.argent == 0:
self.fen.destroy() self.fen.destroy()
def maj_graph(self): def maj_graph(self):

Loading…
Cancel
Save