def arrive_depart(j: int, gs: GameState) -> None:
    seg = gs.segment
    ta = announce_arrival(seg)
    td = seg.tdepart
    if ta > (td - 2): td = ta + 4  # ensure depart after arrival

    if j == 24: return  # end of game...

    if seg.tf == TimeFrame.Night:
        print("Asleep in your compartment, you barely notice that the")
        print(f"departure was right on time at {fmt_time(td)}.")
        cls(2)
        pause()
        return

    if j == 23: turkish_police(gs)

    print(f'Departure is at {fmt_time(td)}.')
    print()
    if said_y('Would you like to get off the train and stretch your legs? '):
        print('Ok, but be sure not to miss the train.')
        time.sleep(1.0)
    else:
        print('Ok, you stay in your compartment.')
    print()
    print('All aboard....')
    time.sleep(1.0)
    print('The train is leaving.')
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 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 turkish_police(gs: GameState) -> None:
    ci = CheckedInput('Who do you identify? ', int)
    ci.choices([1, 2, 3, 4, 5],
               "Please enter the number for your choice ([1-5])")

    cls(4)
    print("The Turkish police have boarded the train.  They have been")
    print("asked to assist you, but for them to do so you will have to")
    print("identify the killer (the dealer in machine guns) and the defector")
    print("(the Scotch drinker) to them.  The arms dealers are lined")
    print("up as follows:")
    print()
    print("  (1) Austrian, (2) Turk, (3) Pole, (4) Greek, (5) Rumanian.")
    print()
    print("They ask who the defector is. ", end='')
    gs.my_defector = ci.run()
    time.sleep(1.0)
    print()
    print("They ask who the killer is. ", end='')
    ci.ensure(lambda c: c != gs.my_defector,
              "You already chose him for the defector!")
    gs.my_killer = ci.run()
    time.sleep(1.5)
    print()
    print("The police take into custody the man you identified as the")
    print("killer and provide a guard to ride on the train with the")
    print("defector.  You return to your compartment, praying that")
    print("you made the correct deductions and identified the right men.")
    print()
    pause()
    print()
def snow(gs: GameState) -> None:
    x = random.random()
    if x > 0.65: return  # 65% chance of snow
    cls(4)
    print("It is snowing heavily ", end='')
    if x > 0.01:
        print("but the tracks have been cleared and the train")
        print("will not be delayed.")
    else:
        print("and the train is forced to slow down.")
        print()
        print("Oh no!  The train is coming to a stop.  Let's hope this is")
        print("not a repeat of the trip of January 29, 1929 when the Orient")
        print("Express was stuck in snowdrifts for five days.")
        print()
        time.sleep(1.0)
        print("But it looks like it is!")
        time.sleep(1.0)
        print()
        gs.hazard_delay += 2
        print(
            "You are stranded for two days until a snowplow clears the track.")
        print(
            f"The train is now exactly {gs.hazard_delay} days behind schedule."
        )
    cls(2)
    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)
Beispiel #7
0
def engine_malfunction(gs: GameState, reduction: float) -> None:
    cls(10)
    timed_banner(3, '* * ENGINE MALFUNCTION!!! * *', 0.5)
    cls(5)
    print(
        f'You will have to operate your engines at a {int(reduction*100)}% reduction'
    )
    print(f'in speed until you reach {trip[gs.seg+1].location}.')
    print()
    pause()
Beispiel #8
0
def run_game():
    random.seed()
    cls()
    print(title)
    pause()
    print(scenario)
    pause()
    state = GameState()
    while state.seg < (len(trip) - 1):
        one_segment(state)
    endgame(state)
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.')
Beispiel #10
0
def one_segment(gs: GameState) -> None:
    cls(7)
    print_conditions(gs)
    trade_fuel(gs)
    print('\nAfter trading:')
    fuel_report(gs)
    engine_power(gs)
    gs.futot -= gs.fuseg
    breeder_usage(gs)
    gs.futot -= 5 * gs.ubreed
    calculate_results(gs)
    gs.seg += 1
    cls(8)
    timed_banner(3, '* * Travelling * *', 0.5)
def determine_outcome(gs: GameState) -> None:
    d, k = defector(), killer()

    # Did you get everything right?
    if gs.my_defector == d and gs.my_killer == k:
        gs.perfection = True
        return

    # The defector is killed by bandits if you didn't either
    # protect him or arrest him
    if d not in [gs.my_defector, gs.my_killer]:
        print()
        print("You are suddenly awakened by what sounded like a gunshot.")
        print("You rush to the defector's compartment, but he is okay.")
        print("However, one of the other arms dealers has been shot.")
        time.sleep(2.0)
        print()
        print("You review the details of the case in your mind and realize")
        print("that you came to the wrong conclusion and due to your mistake")
        print("a man lies dead at the hand of bandits.  You return to your")
        print("compartment and are consoled by the thought that you correctly")
        print("identified the killer and that he will hang for his crimes.")
        print()
        print("At least, you hope that's true...")
        pause()

    # if you didn't identify the killer, he kills you!
    if k != gs.my_killer:
        ring_doorbell()
        print("A man is standing outside.  He says, 'You made a")
        print("mistake.  A bad one.  You see, I am the machine gun dealer.'")
        if gs.my_killer == d:
            print()
            print(
                "'Moreover,' he says, 'you identified the man who was cooperating"
            )
            print(
                "with you as the killer.  So the state will take care of him.  Ha.'"
            )
        print()
        time.sleep(2.0)
        print("He draws a gun.  BANG.  You are dead.")
        print()
        print("You never know that the train arrived at 12:30, right on")
        print("time at Constantinople, Turkey.")
        cls(3)
        gs.alive = False
        pause()
def first_departure() -> None:
    print("The taxi has dropped you at Victoria Station in London.")
    print("The Orient Express is standing majestically on Track 14.")
    print('All aboard....')
    time.sleep(1.0)
    pause('Press <return> to board the train...')
    print('The train is leaving.')
    time.sleep(1.0)
    whoIdx = random.randrange(3, 23)
    who = people[whoIdx:whoIdx + 3]
    print()
    print(f'"You speak to some of the passengers--{who[0]},')
    print(f'{who[1]}, {who[2]} and others--and ask them to keep')
    print('their eyes and ears open and to pass any information--no')
    print('matter how trivial--to you in compartment 13.  The Channel')
    print('crossing is pleasant and the first part of the trip uneventful.')
    cls(4)
    pause()
Beispiel #13
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 run_convo(gs: GameState) -> None:
    if gs.segment.nconv == 0: return
    cls(2)
    print("Later, in your compartment: ")
    for i in range(gs.segment.nconv):
        cls(2)
        convo = gs.conversations.pop()
        ring_doorbell()
        person = convo.who or people[random.randrange(2, 25)]
        print(f'Standing there is {person}, who tells you:')
        print(convo.msg)
        cls(2)
        pause('Press <return> when finished with the conversation...')
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 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()
Beispiel #18
0
(which takes spent fuel from your engines along with a small amount
of primary fuel and turns it into a much greater amount of primary
fuel).
     The space stations along the way usually have a small stock of
engine repair parts, breeder reactor cells, and nuclear fuel which
are available to you on a barter basis.


"""


def run_game():
    random.seed()
    cls()
    print(title)
    pause()
    print(scenario)
    pause()
    state = GameState()
    while state.seg < (len(trip) - 1):
        one_segment(state)
    endgame(state)


if __name__ == "__main__":
    while True:
        run_game()
        cls(3)
        if not said_y('Would you like to play again? '):
            break
def intro() -> None:
    cls()
    print(title)
    pause()
    print(scenario)
    pause("Press <return> to call a taxi...")