From acd669ba34ae043a03e2d04c7c31269df548ade8 Mon Sep 17 00:00:00 2001 From: Alexandre CATTEAU Date: Thu, 23 May 2024 21:24:00 +0200 Subject: [PATCH] Add interface for MOC tracking --- main.py | 38 +++++++++++++++++++++++-- src/{moc-tracking.py => MamaOConnel.py} | 7 ++--- 2 files changed, 38 insertions(+), 7 deletions(-) rename src/{moc-tracking.py => MamaOConnel.py} (99%) diff --git a/main.py b/main.py index b260405..5518679 100644 --- a/main.py +++ b/main.py @@ -4,7 +4,7 @@ import os import random import jsonpickle -import time +from src.MamaOConnel import MamaOConnel class Circus: # There are: @@ -131,8 +131,10 @@ class Game: # General data to generate self.circus = Circus(playersNb) - # Mama O'Connell self.treasure = TreasureCard() + self.mamaoc = MamaOConnel() + while not self.mamaoc.solver(): + self.mamaoc = MamaOConnel() # Players self.players = [] @@ -153,6 +155,26 @@ class Game: def disableConcession(self): self.concession = False + # if number = 0 print Mama O'Connel's location, else print hint #number + def printMamaHint(self, number): + if number not in range(0, 4): + return False + os.system('clear') + input("When you are ready, press Enter.") + print("") + match number: + case 0: + print("Mama O'Connel is at: " + self.mamaoc.location.name) + case 1: + print("Mama O'Connel is " + str(self.mamaoc.hint1[1]) + " cities from " + self.mamaoc.hint1[0].name) + case 2: + print("Mama O'Connel is " + str(self.mamaoc.hint2[1]) + " cities from " + self.mamaoc.hint2[0].name) + case 3: + print("Mama O'Connel is " + str(self.mamaoc.hint3[1]) + " cities from " + self.mamaoc.hint3[0].name) + print("") + input("When you are done, press Enter.") + os.system('clear') + def printStatus(self): print("") print("---------------------------------------------------------------------") @@ -203,13 +225,15 @@ while True: myGame.printStatus() command = input("==> ") while command not in ('load', 'save', 'next year', 'exit', 'enable circus', 'take circus', 'enable concession',\ - 'take concession', 'disable concession', 'enable treasure', 'take treasure'): + 'take concession', 'disable concession', 'enable treasure', 'take treasure', 'mama hint 1', 'mama hint 2',\ + 'mama hint 3', 'mama location'): print("") print("Available commands:") print(" Main: 'load', 'save', 'next year', 'exit'") print(" Circus: 'enable circus', 'take circus'") print(" Treasure: 'enable treasure', 'take treasure'") print(" Concessions: 'enable concession', 'take concession', 'disable concession'") + print(" Mama O'Connel tracking: 'mama hint 1', 'mama hint 2', 'mama hint 3', 'mama location'") command = input("==> ") print("") match command: @@ -251,3 +275,11 @@ while True: player.concession.takeReward(choice) case 'disable concession': myGame.disableConcession() + case 'mama hint 1': + myGame.printMamaHint(1) + case 'mama hint 2': + myGame.printMamaHint(2) + case 'mama hint 3': + myGame.printMamaHint(3) + case 'mama location': + myGame.printMamaHint(0) diff --git a/src/moc-tracking.py b/src/MamaOConnel.py similarity index 99% rename from src/moc-tracking.py rename to src/MamaOConnel.py index 424fc76..1e301e3 100644 --- a/src/moc-tracking.py +++ b/src/MamaOConnel.py @@ -1,4 +1,3 @@ -import os import random class City: @@ -275,6 +274,6 @@ class MamaOConnel: return False return True -myMama = MamaOConnel() -while not myMama.solver(): - myMama = MamaOConnel() +# myMama = MamaOConnel() +# while not myMama.solver(): +# myMama = MamaOConnel()