Python Forum
How do I shorten my input options? - text adventure
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I shorten my input options? - text adventure
#2
class smart_dict(dict):
    def __missing__(self, key):
        return key

def Tavern():
    print('Typed 1')

def preArena():
    print('Typed 2')

def Quest_Board():
    print('Typed 3')

def Potion_Shop():
    print('Typed 4')

def Blacksmith():
    print('Typed 5')

options = {
    '1': ['You enter the Tavern', Tavern, 'Go to the -Tavern'],
    '2': ['You enter Arena', preArena, 'Go to the - Arena'],
    '3': ['You walk to the Quest Board', Quest_Board, 'Go to the - Quest Board'],
    '4': ['You enter the Potion Shop', Potion_Shop, 'Go to the - Potion Shop'],
    '5': ['You enter the Blacksmith', Blacksmith, 'Go to the - Blacksmith']
}

smart_dict(options)

while True:
    n=1
    print()
    for key, value in options.items():
        print('{}.) {}'.format(n, value[2]))
        n += 1

    Option = input("-->")
    if Option == options[Option]:
        continue
    print(options[Option][0])
    options[Option][1]()
I added stubs for the various functions you need to write
Reply


Messages In This Thread
RE: How do I shorten my input options? - text adventure - by Larz60+ - Jan-01-2017, 12:54 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  argparser not showing all options bigal 1 103 Yesterday, 02:54 AM
Last Post: deanhystad
Sad How to split a String from Text Input into 40 char chunks? lastyle 7 1,269 Aug-01-2023, 09:36 AM
Last Post: Pedroski55
  python multiple try except block in my code -- can we shorten code mg24 10 6,452 Nov-10-2022, 12:48 PM
Last Post: DeaD_EyE
  Want to shorten the python code shantanu97 3 1,337 Apr-25-2022, 01:12 PM
Last Post: snippsat
  loop adventure game ilikedofs 1 1,756 May-26-2021, 12:43 AM
Last Post: bowlofred
  how to make a hotkey for text adventure game myn2018 2 2,032 Jan-06-2021, 10:39 PM
Last Post: myn2018
  Choose your own adventure game noahc2004 2 2,636 Jun-26-2020, 02:06 PM
Last Post: DPaul
  Modify Input() text catosp 6 3,001 Jun-08-2020, 10:48 PM
Last Post: deanhystad
  Selecting text as an input lazerwolf101 2 2,308 May-29-2020, 06:52 AM
Last Post: lazerwolf101
  Help with options raiden 1 1,973 Aug-30-2019, 12:57 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020