From f198d776df245d9933ede2301e23e039f114328f Mon Sep 17 00:00:00 2001 From: Alexandre CATTEAU Date: Mon, 6 May 2024 10:50:49 +0200 Subject: [PATCH] Add Treasure Card --- data-generator.py | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/data-generator.py b/data-generator.py index cc7c5cf..90496c9 100644 --- a/data-generator.py +++ b/data-generator.py @@ -28,6 +28,9 @@ class Circus: self.state = 0 # 0 means Circus is not used in game yet, 1 means next wagon in list is #1, and so on def enable(self): + if self.state == 0: + print("Circus is not or no longer in game.") + return False self.state = 1 def getNextColor(self): @@ -43,6 +46,30 @@ class Circus: print("Circus stickers are now depleted.") self.state = 0 # effectively disable circus +class TreasureCard: + + def __init__(self): + self.treasures = [36, 33, 29, 27, 24] + self.state = -1 # disabled + + def enable(self): + self.state = 0 # 0 means 0 treasures have been found + + def getFoundNumber(self): + if self.state == -1: + print("Treasure hunt has not started yet or is completed.") + return False + return self.state + + def takeTreasure(self): + if self.state == -1: + print("Treasure hunt has not started yet or is completed.") + return False + self.state = self.state + 1 + if self.state == 5: + print("All treasures have been found.") + self.state = -1 # effectively disable treasure card + class ConcessionCard: # name may be different in English # Each card contains: @@ -87,7 +114,7 @@ class Game: # General data to generate self.circus = Circus(playersNb) # Mama O'Connell - # Treasures + self.treasure = TreasureCard() # Players self.players = [] @@ -108,8 +135,8 @@ class Game: print("") if self.circus.state > 0: print("Circus next sticker color: " + self.circus.getNextColor()) - # TODO: treasures remaining to find) - + if self.treasure.state > -1: + print(f"Treasures found: {self.treasure.getFoundNumber()}") def saveData(self): savefile = open('./savefile.json', 'w+') @@ -153,12 +180,12 @@ playersNb = 2 myGame = Game() myGame.initGame(playersNb) myGame.printStatus() -myGame.circus.enable() -myGame.circus.state = 19 +myGame.treasure.enable() myGame.printStatus() -print(myGame.circus.wagons) -myGame.circus.takeWagon() +myGame.treasure.takeTreasure() +myGame.treasure.takeTreasure() +myGame.treasure.takeTreasure() +myGame.treasure.takeTreasure() myGame.printStatus() -print(myGame.circus.wagons) -myGame.circus.takeWagon() +myGame.treasure.takeTreasure() myGame.printStatus()