getting Python 3.9 to recognize parameters and act accordingly (Interactive storytelling)

I'll try to keep it short and sweet.

I'm writing an interactive story that changes based on the "roll" of a d20 dice. I've managed to figure out getting started, but I've hit a point where I don't think Python is actually listening to the parameters I'm giving it, because it kind of just does whatever.

Essentially, here's what's supposed to happen:

Player agrees that they want to play the game -> Player Rolls dice -> Game uses the randomly rolled number to determine which start that the player will have.

What's currently happening is, all goes well until it's supposed to spit out the start that the player has. It doesn't seem to actually decide based on my parameters. For example, you're supposed to have the "human" start if the player rolls 5 or less, and an "elf" start for anything between 6 and 18. Here's what happened yesterday:

    venv\Scripts\python.exe C:/Users/drago/PycharmProjects/D20/venv/

Hello! Would you like to go on an adventure? y/n >> y
Great! Roll the dice.
Press R to roll the D20.
You rolled a 15!
You start as a human.
As a human, you don't have any special characteristics except your ability to learn.

The related code is below:

    def NewGame():
    inp = input("Hello! Would you like to go on an adventure? y/n >> ")
    if inp == "y" or inp == "yes":
        print("Great! Roll the dice.")
        input("Press R to roll the D20.")
        print("You rolled a " + str(RollD20()) + "!")
        input("Okay, bye! Press any key to exit.")

    def PostGen():
    if RollD20() <= 5:
        print("You start as a human.")
    elif RollD20() >= 6:
        print("You start as an elf.")
    elif RollD20() >= 19:
        print("You lucked out, and can start as a demigod!")

 def RollD20():
    n = random.randint(1, 20)
    return n

def PostStartHum():
    print("As a human, you don't have any special characteristics except your ability to learn.")
def PostStartElf():
    print("As an elf, you have a high intelligence and a deep respect for tradition.")
def PostStartDemi():
    print("As a demigod, you are the hand of the gods themselves; raw power incarnated in a human form...")
    print("However, even mighty decendants of gods have a weakness. Be careful."

Thanks for all your help.

Read more here:

Content Attribution

This content was originally published by R3TURN-0 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: