Well this is my basic code for my RPG, can I have help improving it?

import cmd
import json
from  rpg_data import *



class RPG(cmd.Cmd):
    def do_n(self, line):
        try:
            Me.location =  Me.location.exits["north"]
        except:
            print("You can't go north")
    def do_s(self, line):
        try:
            Me.location =  Me.location.exits["south"]
        except:
            print("You can't go south")
    def do_e(self, line):
        try:
            Me.location =   Me.location.exits["east"]
        except:
            print("You can't go east")
    def do_w(self, line):
        try:
            Me.location =  Me.location.exits["west"]
        except:
            print("You can't go west")

    def do_u(self, line):
        try:
            Me.location =  Me.location.exits["up"]
        except:
            print("You can't go up")
    def do_d(self, line):
        try:
            Me.location =  Me.location.exits["down"]
        except:
            print("You can't go down")

    def do_inventory(self,line):
        print ("You have the following awesome items:")
        for item in Me.inventory:
            print ("    ", item.name)

    def do_look(self, line):
        Me.location.print_description()
        for npc in Me.location.npc_list:
            print("You see the", npc.description)

    def do_attack(self, line):
        if not Me.location.npc_list:
            print("You attack empty air?!?")
        else:
            pass


    def postcmd(self, stop, line):
        self.do_look(line) 
        return cmd.Cmd.postcmd(self, stop, line)


    def default(self, line):
        print ("I don't get it")

    def do_quit(self,line):
        print("Quitters always lose")
        return True




if __name__ == '__main__':
    RoomList = read_room_data()     

    Me = Adventurer()
    Me.inventory = [Item("sword"), Item("food")] 
    Me.location = RoomList[0]




    Me.location.print_description()
    RPG().cmdloop()

You have some errors on the imports, json and RPG_Data. We need the json and RPG_Data files in order to run the program.

Module json is built in, but module rpg_data is custome made.

Rpg Tutorial
I used to follow this tutorial when I made a text based rpg too. It's in c++ but I think you would be able to get some general ideas like inventories, monster creation and other rpg stuffs.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.