Compare commits

..

No commits in common. "2570974192020c176b848edecae379ba0fdd1826" and "f7571c299c9937f2e93068bb1659cf577e8c4415" have entirely different histories.

2 changed files with 7 additions and 37 deletions

40
main.py
View File

@ -142,9 +142,6 @@ class Game:
color = input("Enter player " + str(n + 1) + "'s color: ")
self.players.append(Player(color))
# Stickers pools
self.stickers = {'White': 0, 'Red': 0, 'Blue': 0, 'Yellow': 0, 'Green': 0, 'Black': 0}
def getPlayerByColor(self, color):
for player in self.players:
if player.color.lower() == color.lower():
@ -178,25 +175,6 @@ class Game:
input("When you are done, press Enter.")
os.system('clear')
def takeSticker(self, color, nb):
if not nb.isdigit() or int(nb) < 1:
print("ERROR: Not a positive number")
return False
nb = int(nb)
for c, n in self.stickers.items():
if c.lower() == color.lower():
if nb > n:
print("ERROR: not enough stickers remaining.")
return False
else:
self.stickers[c] = n - nb
return True
print("ERROR: color not found.")
return False
def newStickersBatch(self):
self.stickers = {x: self.stickers[x] + 7 for x in self.stickers}
def printStatus(self):
print("")
print("---------------------------------------------------------------------")
@ -213,13 +191,8 @@ class Game:
print("")
if self.circus.state > 0:
print("Circus next sticker color: " + self.circus.getNextColor())
print("")
if self.treasure.state > -1:
print(f"Treasures found: {self.treasure.getFoundNumber()}")
print("")
print("Road stickers:")
for color, nb in self.stickers.items():
print(" " + color + ": " + str(nb))
def saveData(self, path):
savefile = open('./' + path, 'w+')
@ -251,13 +224,12 @@ elif choice == "load":
while True:
myGame.printStatus()
command = input("==> ")
while command not in ('load', 'save', 'next year', 'exit', 'take sticker', 'batch sticker', 'enable circus',\
'take circus', 'enable concession', 'take concession', 'disable concession', 'enable treasure', 'take treasure',\
'mama hint 1', 'mama hint 2', 'mama hint 3', 'mama location'):
while command not in ('load', 'save', 'next year', 'exit', 'enable circus', 'take circus', 'enable concession',\
'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(" Stickers: 'take sticker', 'batch sticker'")
print(" Circus: 'enable circus', 'take circus'")
print(" Treasure: 'enable treasure', 'take treasure'")
print(" Concessions: 'enable concession', 'take concession', 'disable concession'")
@ -282,12 +254,6 @@ while True:
myGame.yearId = myGame.yearId + 1
case 'exit':
exit()
case 'take sticker':
choice = input("Color ? ==> ")
number = input("Nb ? ==> ")
myGame.takeSticker(choice, number)
case 'batch sticker':
myGame.newStickersBatch()
case 'enable circus':
myGame.circus.enable()
case 'take circus':

View File

@ -273,3 +273,7 @@ class MamaOConnel:
if len(cross) > 1: # multiple cities remaining after 3 hints
return False
return True
# myMama = MamaOConnel()
# while not myMama.solver():
# myMama = MamaOConnel()