Add Treasure Card
This commit is contained in:
parent
496f83129c
commit
f198d776df
@ -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
|
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):
|
def enable(self):
|
||||||
|
if self.state == 0:
|
||||||
|
print("Circus is not or no longer in game.")
|
||||||
|
return False
|
||||||
self.state = 1
|
self.state = 1
|
||||||
|
|
||||||
def getNextColor(self):
|
def getNextColor(self):
|
||||||
@ -43,6 +46,30 @@ class Circus:
|
|||||||
print("Circus stickers are now depleted.")
|
print("Circus stickers are now depleted.")
|
||||||
self.state = 0 # effectively disable circus
|
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
|
class ConcessionCard: # name may be different in English
|
||||||
# Each card contains:
|
# Each card contains:
|
||||||
@ -87,7 +114,7 @@ class Game:
|
|||||||
# General data to generate
|
# General data to generate
|
||||||
self.circus = Circus(playersNb)
|
self.circus = Circus(playersNb)
|
||||||
# Mama O'Connell
|
# Mama O'Connell
|
||||||
# Treasures
|
self.treasure = TreasureCard()
|
||||||
|
|
||||||
# Players
|
# Players
|
||||||
self.players = []
|
self.players = []
|
||||||
@ -108,8 +135,8 @@ class Game:
|
|||||||
print("")
|
print("")
|
||||||
if self.circus.state > 0:
|
if self.circus.state > 0:
|
||||||
print("Circus next sticker color: " + self.circus.getNextColor())
|
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):
|
def saveData(self):
|
||||||
savefile = open('./savefile.json', 'w+')
|
savefile = open('./savefile.json', 'w+')
|
||||||
@ -153,12 +180,12 @@ playersNb = 2
|
|||||||
myGame = Game()
|
myGame = Game()
|
||||||
myGame.initGame(playersNb)
|
myGame.initGame(playersNb)
|
||||||
myGame.printStatus()
|
myGame.printStatus()
|
||||||
myGame.circus.enable()
|
myGame.treasure.enable()
|
||||||
myGame.circus.state = 19
|
|
||||||
myGame.printStatus()
|
myGame.printStatus()
|
||||||
print(myGame.circus.wagons)
|
myGame.treasure.takeTreasure()
|
||||||
myGame.circus.takeWagon()
|
myGame.treasure.takeTreasure()
|
||||||
|
myGame.treasure.takeTreasure()
|
||||||
|
myGame.treasure.takeTreasure()
|
||||||
myGame.printStatus()
|
myGame.printStatus()
|
||||||
print(myGame.circus.wagons)
|
myGame.treasure.takeTreasure()
|
||||||
myGame.circus.takeWagon()
|
|
||||||
myGame.printStatus()
|
myGame.printStatus()
|
||||||
|
Loading…
Reference in New Issue
Block a user