|
@ -12,13 +12,15 @@ 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" |
|
|
self.bank += self.mise |
|
|
else: |
|
|
self.argent -= self.mise |
|
|
self.bank += self.mise |
|
|
return self.mise |
|
|
self.argent -= self.mise |
|
|
|
|
|
return self.mise |
|
|
|
|
|
|
|
|
def nbAlea(self): |
|
|
def nbAlea(self): |
|
|
"""renvoie une liste de 3 nombre aléatoires entre 0 et 9""" |
|
|
"""renvoie une liste de 3 nombre aléatoires entre 0 et 9""" |
|
@ -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): |
|
|