示例#1
0
class SUD:
    def __init__(self):
        self.myDungeon = 0

    def Run(self):
        self.myDungeon = Dungeon()
        self.myDungeon.Init()

        while True:
            self.Process()

    def Process(self):
        self.myDungeon.DisplayCurrentRoom()

        key = input(">")

        user_input = key.split(' ')

        user_input = [x for x in user_input if x != '']

        if user_input[0].lower() == 'help':
            print("do help")
        else:
            if user_input[0].lower() == 'go':
                if self.myDungeon.isValidMove(user_input[1].lower()):
                    self.myDungeon.MovePlayer(user_input[1].lower())
                else:
                    self.handleBadInput()
            else:
                self.handleBadInput()

    def handleBadInput(self):
        print("\nERROR")
        print("Press any key to continue")
        input()
示例#2
0
class SUD:
    def __init__(self):
        self.myDungeon = 0

    # start the dungeon loop
    def Run(self):
        self.myDungeon = Dungeon()
        self.myDungeon.Init()

        while True:
            self.Process()

    def Process(self):

        # on server
        self.myDungeon.DisplayCurrentRoom()  #-> send text to client

        # on client
        key = input(">")

        #on server
        user_input = key.split(' ')

        user_input = [x for x in user_input if x != '']

        if user_input[0].lower() == 'help':
            print("do help")
        else:
            if user_input[0].lower() == "go":
                if self.myDungeon.isValidMove(user_input[1].lower()):
                    self.myDungeon.MovePlayer(user_input[1].lower())
                else:
                    self.handleBadInput()
            else:
                self.handleBadInput()

    # on server  #-> send text to client
    def handleBadInput(self):
        print("\n ERROR")
        print("press any key to continue")
        input()