def gameOver(score): print('\nYou earned a score of ', str(score), ', Good job!', sep='') yourName = input('What is your name?: ') writeScores(yourName, score) displayScores() print('Sadly, it is a game over...') answer = input("Would you like to play again? (y/n): ") if answer == "n": print("Have a nice day!") sys.exit() else: size = 16 garden = engine.initGarden(size) turns = 10 totalTurns = 0 score = 0 cultivate(garden, turns, score, totalTurns)
def gameOver(score): print('\nYou earned a score of ', str(score), ', Good job!', sep='') print('Sadly, it is a game over...') answer = input("Would you like to play again? (y/n): ") if answer == "n": print("Have a nice day!") sys.exit() else: keepGoing = False while (keepGoing == False): size = int(input("What size of garden?: ")) print("") if (size % 2 == 1): size += 1 if (size < 6 or size > 36): print("Invalid size (try even: 6 -36)\n") else: keepGoing = True garden = engine.initGarden(size) turns = 10 score = 0 cultivate(garden, turns, score)
else: os.system('python3 arcade.py') sys.exit() keepGoing = False while (keepGoing == False): size = int(input("What size of garden?: ")) print("") if (size % 2 == 1): size += 1 if (size < 6 or size > 36): print("Invalid size (try even: 6 -36)\n") else: keepGoing = True garden = engine.initGarden(size) engine.printGarden(garden) def cultivate(garden, turns, score): while (True): button = input("\nplant(a) water(w) collect(s) till(d): ") if button == 'a': choice = input("tomatoes(a) eggplants(s) cotton(d): ") if choice == 'a': engine.advanceTime(garden) engine.plantPlants(garden, 1) turns, score = displayDetails(turns, score, garden) elif choice == 's': engine.advanceTime(garden) engine.plantPlants(garden, 11)
def cultivate(garden, turns, score, totalTurns): while (True): print("\nDay:", totalTurns) if (totalTurns % 10 == 9): print("\nNew season next turn") elif (totalTurns == 10): print("\nWelcome to the new season!\n") garden = engine.initGarden(14) engine.printGarden(garden) turns += 1 elif (totalTurns == 20): print("\nWelcome to the new season!\n") garden = engine.initGarden(12) engine.printGarden(garden) turns += 1 elif (totalTurns == 30): print("\nWelcome to the new season!\n") garden = engine.initGarden(10) engine.printGarden(garden) turns += 1 elif (totalTurns != 0 and totalTurns % 10 == 0): print("\nWelcome to the new season!\n") garden = engine.initGarden(8) engine.printGarden(garden) turns += 1 button = input("\nplant(a) water(w) collect(s) till(d): ") if button == 'a': choice = input("tomatoes(a) eggplants(s) cotton(d): ") if choice == 'a': engine.advanceTime(garden) engine.plantPlants(garden, 1) turns, score = displayDetails(turns, score, garden) totalTurns += 1 elif choice == 's': engine.advanceTime(garden) engine.plantPlants(garden, 11) turns, score = displayDetails(turns, score, garden) totalTurns += 1 elif choice == 'd': engine.advanceTime(garden) engine.plantPlants(garden, 21) turns, score = displayDetails(turns, score, garden) totalTurns += 1 else: print("--unknown command--") elif button == 'w': choice = input("top(w) bottom(s) left(a) right(d): ") if choice == 'w': engine.advanceTime(garden) engine.water(garden, 'top') turns, score = displayDetails(turns, score, garden) totalTurns += 1 elif choice == 'a': engine.advanceTime(garden) engine.water(garden, 'left') turns, score = displayDetails(turns, score, garden) totalTurns += 1 elif choice == 's': engine.advanceTime(garden) engine.water(garden, 'bot') turns, score = displayDetails(turns, score, garden) totalTurns += 1 elif choice == 'd': engine.advanceTime(garden) engine.water(garden, 'right') turns, score = displayDetails(turns, score, garden) totalTurns += 1 else: print("--unknown command--") elif button == 's': turns, score = engine.collect(garden, score, turns) engine.advanceTime(garden) turns, score = displayDetails(turns, score, garden) totalTurns += 1 elif button == 'd': engine.till(garden) engine.advanceTime(garden) turns, score = displayDetails(turns, score, garden) totalTurns += 1 elif button == 'stop': gameOver(score) else: # button == 'd' engine.rules()