def run_game() -> None:
    random.seed()
    gs = GameState()
    intro()
    for j, seg in enumerate(segments, 1):
        gs.segment = seg
        cls(4)
        print(centered(f'~ February {seg.day + 13 + gs.hazard_delay} 1923 ~'))
        print(centered(f'~ {seg.city}, {seg.country} ~'))
        print()

        if j == 1:
            first_departure()
        elif j < 24:
            arrive_depart(j, gs)
        else:
            if gs.alive: announce_arrival(seg)
            endgame(gs)
            return

        # TODO: train noises??
        if j == 23: determine_outcome(gs)

        if gs.alive:
            run_meals(gs)
            run_convo(gs)
            run_hazards(gs)
            time.sleep(1.0)
def ring_doorbell() -> None:
    print(centered("*  * BRRRINNNG! *  *"))
    print()
    time.sleep(1.0)
    if random.randrange(0, 5) == 0:
        print(centered("*  * Knock knock knock! *  *"))
        print()
        time.sleep(1.0)
    print('You open the door:')
    # pause('Press <return> to open the door...')
    print()
def serve_breakfast() -> None:
    cls(4)
    print("Breakfast is now being served in the restaurant car.")
    pause("Press <return> when you're ready to have breakfast.")
    cls(8)
    print(centered("BREAKFAST MENU"))
    cls(3)
    for i in range(4):
        print(centered(breakfasts[(3 * i) + random.randrange(0, 3)]))
        cls(3)
    print(centered(breakfasts[12]))
    cls(4)
    pause('Press <return> when you have finished eating.')
def serve_dinner() -> None:
    cls(4)
    print("Dinner is now being served in the restaurant car.")
    pause("Press <return> when you're ready to have dinner.")
    cls(8)
    print(centered("DINNER MENU"))
    cls(2)
    for i in range(7):
        print(centered(dinners[(3 * i) + random.randrange(0, 3)]))
        print()
    for i in [22, 23, 24]:
        print(centered(dinners[i]))
        print()
    pause('Press <return> when you have finished eating.')
def derail(gs: GameState) -> None:
    if gs.derailed or (random.random() > 0.02):
        return  # 2% chance of derailment
    gs.derailed = True
    gs.hazard_delay += 1
    cls(4)
    print(centered(" * * SCREEECH! * *"))
    time.sleep(1.0)
    cls(2)
    print("You hear a loud screeching noise as the train comes to a")
    print("crashing stop.  The engine, tender, and first coach are")
    print("leaning at a crazy angle.  People are screaming.")
    time.sleep(1.0)
    print()
    print("While not as bad as the derailment at Vitry-le-Francois in")
    print("November 1911, there is no question that the front of the")
    print("train has left the track.")
    time.sleep(1.0)
    print()
    print("You are stranded for exactly one day while the track is")
    print("repaired and a new locomotive obtained.")
    print()
    print(
        f"The train is now exactly {plural(gs.hazard_delay,'day')} behind schedule."
    )
    print()
    pause()
def serve_lunch() -> None:
    cls(4)
    print(
        "An enormous buffet luncheon has been laid out in the restaurant car.")
    pause('Press <return> when you have finished eating.')
    cls(4)
    print(centered(" * * B-U-R-P ! * * "))
    time.sleep(1.0)
示例#7
0
def endgame(gs: GameState) -> None:
    cls(6)
    print(centered(" * * N E P T U N E ! * *"))
    cls(2)
    print(f'You finally reached Neptune in {fmt_days(gs.totime)}.')
    print("Had your engines run at 100% efficiency the entire way, you would")
    print(
        "have averaged 51,389 mph and completed the trip in exactly 6 years.")
    print()
    if gs.totime <= 2220:
        print(centered("Congratulations!  Outstanding job!"))
    else:
        tm = gs.totime - 2190
        print(f'Your trip took longer than this by {fmt_days(tm)}.')
        print()
        years_over = min(tm // 365, 3)
        scale = [
            "excellent (room for slight improvement).",
            "quite good (but could be better).",
            "marginal (could do much better).",
            "abysmal (need lots more practice)."
        ]
        print(f'Your performance was {scale[years_over]}')
    print()
    if gs.breed < 105:
        print('I guess you realize that the return trip will be extremely')
        print(
            f'chancy with only {gs.breed} breeder reactor cells operational.')
    else:
        print(
            f'Fortunately you have {gs.breed} operational breeder reactor cells'
        )
        print("for your return trip.  Very good.")
    print()
    back_to_2 = max(int(42250.0 / (8.0 + gs.futot / 40.0)), 405)
    print(
        f'With your remaining {gs.futot} pounds of fuel and {gs.breed} breeder'
    )
    print(f'cells, to get back to Theta 2 will take {fmt_days(back_to_2)}.')
    print()
def endgame(gs: GameState) -> None:
    cls(4)
    print("Your journey has ended.  Georges Nagelmackers and the")
    print("management of Cie. Internationale des Wagons-Lits ")
    print("hope you enjoyed your trip on the Orient Express, the")
    print("most famous train in the world.")
    if gs.perfection:
        print()
        print("Whitehall telegraphs congratulations for identifying both")
        print("the killer and defector correctly.")
        time.sleep(1.0)
        for _ in range(3):
            cls(2)
            print(centered('* * CONGRATULATIONS! * *'))
            time.sleep(1.5)
    cls(4)
    pause()
def bandits(gs: GameState) -> None:
    if gs.bandits or (random.random() > 0.04): return  # 4% chance of bandits
    gs.bandits = True
    cls(4)
    print(centered(" * * CLANG! * *"))
    time.sleep(1.0)
    cls(4)
    print("You are rudely awakened from a deep sleep by a loud noise")
    print("as the train jerks to a halt.")
    time.sleep(1.0)
    print()
    ring_doorbell()
    print()
    print("You are shocked to see a bandit waving a gun in your face.")
    print("He demands you give him your wallet, jewelry, and watch.")
    time.sleep(1.0)
    print()
    print("The bandits are off the train in a few moments with")
    print("their loot.  They disappear into the forest.  No one")
    print("was injured, and the train resumes its journey.")
    cls(3)
    pause()
示例#10
0
def timed_banner(n, msg, delay):
    cmsg = centered(msg)
    for _ in range(n):
        print(cmsg)
        print()
        time.sleep(delay)