def hailstorm(env: GameEnvironment): env.mileage = env.mileage - 5 - 10 * random() env.ammo -= 150 env.repairs = env.repairs - 2 - 2 * random() steady_print( "You're caught in a fierce hailstorm; ammo and supplies are damaged.\n" )
def south_pass(env: GameEnvironment): if not env.south_pass_clear: env.south_pass_clear = True if random() < 0.8: blizzard(env) steady_print("You made it safely through the South Pass....no snow!\n") env.south_pass_mileage = 1 if env.mileage < 1700 or env.blue_mountain_clear: return env.blue_mountain_clear = True if random() < 0.7: blizzard(env)
def swamped(env: GameEnvironment): env.mileage = env.mileage - 20 - (20 * random()) env.food -= 15 env.clothes -= 10 steady_print( "Your wagon gets swamped fording a river; you lose food and clothes.\n" )
def wagon_fire(env: GameEnvironment): env.mileage -= 15 env.food -= 20 env.ammo -= 400 env.repairs = env.repairs - 2 - 6 * random() steady_print( "You have a fire in your wagon. Food and supplies are damaged.\n")
def you_win(env: GameEnvironment): # Set ML? 3200 playsound('sounds/victory.wav') env.end_miles = (2040 - env.prior_mileage) / (env.mileage - env.prior_mileage) env.food += (1 - env.mileage) * (8 + 5 * env.eating) travelled = env.days_travelled() steady_print( f"You finally arrived at Oregon City after 2040 long miles.\n" f"You're exhausted and haggard, but you made it! A real pioneer!\n" f"You've been on the trail for {travelled['months']} months and {travelled['days']} days\n" f"You have few supplies remaining :\n") env.print_inventory() steady_print( "President James A. Polk sends you his heartiest\n" "congratulations and wishes you a prosperous life in your new home.\n") play_again()
def blizzard(env: GameEnvironment): steady_print( "Blizzard in the mountain pass. Going is slow; supplies are lost.\n") env.mileage = env.mileage - 30 - (40 * random()) env.food -= 12 env.ammo -= 200 env.repairs -= 5 if env.clothes < 18 + (2 * random()): illness(env)
def hunt(env: GameEnvironment): if env.ammo < 40: print("Tough luck. You don't have enough ammo to hunt.") env.out_of_ammo = True return env.mileage -= 45 score = _shoot(env) target = random() * 100 if target < 13 * score: steady_print("You missed completely…and your dinner got away.\n") elif score <= 1.0: steady_print( "Right between the eyes…you got a big one!\nFull bellies tonight!\n" ) env.ammo = int(env.ammo - 10 - (4 * random())) env.food = int(env.food + 26 + (3 * random())) else: steady_print("Nice shot…right on target…good eatin' tonight!\n") env.food = int(env.food + 24 - (2 * score)) env.ammo = int(env.ammo - 10 - (3 * score))
def bandits_attack(env: GameEnvironment): steady_print("Bandits attacking!\n") time.sleep(1) score = _shoot(env) env.ammo = env.ammo - 20 * score if env.ammo < 0: env.wallet = env.wallet / 3 steady_print("You try to drive them off but you run out of bullets.\n" "They grab as much cash as they can find.\n") if score > 1: steady_print("You get shot in the leg — \n") time.sleep(4) steady_print("and they grab one of your oxen.\n" "Better have a doc look at your leg…and soon!\n") env.hurt = True env.oxen -= 10 env.repairs -= 2 else: steady_print("That was the quickest draw outside of Dodge City.\n" "You got at least one and drove 'em off.\n")
def bad_weather(env: GameEnvironment): if env.mileage > 950: # It snows enough_clothing = env.clothes < 11 + (2 * random()) # noinspection SpellCheckingInspection steady_print( f"Cold weather…Brrrrrrr!…You{' do not ' if not enough_clothing else ' '}" f"have enough clothing to keep warm.\n") if not enough_clothing: illness(env) else: # It rains steady_print( "Heavy rains. Traveling is slow in the mud and you break your spare\n" "ox yoke using it to pry your wagon out of the mud. Worse yet, some\n" "of your ammo is damaged by the water.\n") env.mileage = env.mileage - 5 - (10 * random()) env.repairs -= 7 env.ammo -= 400 env.food -= 5
def eat(env: GameEnvironment): if env.food < 5: you_lose_food(env) resp = int_input( "Do you want to eat (1) poorly (2) moderately or (3) well? ") while resp not in (1, 2, 3): steady_print("Enter a 1, 2, or 3, please.") resp = int_input( "Do you want to eat (1) poorly (2) moderately or (3) well? ") amount_eaten = 4 + (2.5 * resp) env.food -= amount_eaten if env.food < 0 and resp != 1: steady_print("You don't have enough to eat that well.\n") env.food += amount_eaten eat(env) else: env.eating = resp return
def illness(env: GameEnvironment): if 100 * random() < 10 + 35 * (env.eating - 1): steady_print("Mild illness. Your own medicine will cure it.\n") env.mileage -= 5 env.repairs -= 1 elif 100 * random() < 100 - (40 // 4 ^ (env.eating - 1)): steady_print( "The whole family is sick. Your medicine will probably work okay.\n" ) env.mileage -= 5 env.repairs -= 2.5 else: steady_print( "Serious illness in the family. You'll have to stop and see a doctor\n" "soon. For now, your medicine will work.\n") env.repairs -= 5 env.sick = True if env.repairs < 0: steady_print(" …if only you had enough.") you_lose_sick(env, medical=True)
def wild_animals(env: GameEnvironment): steady_print( "You're sound asleep and you hear a noise…get up to investigate.\n") time.sleep(3) steady_print("It's wild animals! They attack you!\n") score = _shoot(env) if env.ammo < 40: steady_print("You're almost out of ammo; can't reach more.\n" "The wolves come at you biting and clawing.\n") env.hurt = True you_lose_sick(env) if score <= 2: steady_print("Nice shooting, pardner…They didn't get much.\n") else: steady_print( "Kind of slow on the draw. The wolves got at your food and clothes.\n" ) env.ammo -= 20 * score env.clothes -= 2 * score env.food -= 4 * score
def heavy_fog(env: GameEnvironment): env.mileage = env.mileage - 10 - 5 * random() steady_print( "You lose your way in heavy fog. Time lost regaining the trail.\n")
def no_water(env: GameEnvironment): env.mileage = env.mileage - 2 - (10 * random()) steady_print( "Nothing but contaminated and stagnant water near the trail.\n" "You lose time looking for a clean spring or creek.\n")
def broken_arm(env: GameEnvironment): env.mileage = env.mileage - 5 - (4 * random()) env.repairs = env.repairs - 1 - (2 * random()) steady_print( "Bad luck…your daughter breaks her arm. You must stop and\n" "make a splint and sling with some of your medical supplies.\n")
def wagon_breakdown(env: GameEnvironment): env.mileage = env.mileage - 15 - (5 * random()) env.repairs -= 4 steady_print( "Your wagon breaks down. It costs you time and supplies to fix it.\n")