user2900585
user2900585

Reputation:

Python text RPG commands, what am I doing wrong?

I have already defined Player in a class, but how come I can't get it to print "true" whenever I enter "help"? I don't get any errors, but it simply continues the While loop. Am I just not seeing something?

Commands = { #In-game commands
    'help': help,
    'exit': exit
    }

def charactercreation():
    print("Welcome to the wasteland. What is your name? ")
    Player.name = input(">> ")
    Player.hp = 30
    Player.curhp = 30
    Player.per = 7
    Player.dr = 1
    Player.agi = 5

def isValidCMD(cmd):
    if cmd in Commands:
        return True
    return False

def main(Player): #Main function
    Player.dead = False
    while(Player.dead == False):
        input(">> ")

        if input(isValidCMD):
            print("True")

charactercreation()
main(Player)

Upvotes: 0

Views: 65

Answers (1)

Christian Ternus
Christian Ternus

Reputation: 8492

When you say

    input(">> ")

    if input(isValidCMD):
        print("True")

you're asking for more input. Try:

    cmd = input(">> ")

    if isValidCMD(cmd):
        print("True")

instead.

Upvotes: 2

Related Questions