Add interface for MOC tracking
This commit is contained in:
		
							
								
								
									
										38
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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()
 | 
			
		||||
		Reference in New Issue
	
	Block a user