示例#1
0
文件: main.py 项目: semtle/ShinyMUD
def setup():
    """Initialize the game!"""
    if os.path.exists(DB_NAME):
        print "\nYou already have a game set up.\n\n" +\
              "If you're trying to create a god character, call this script again with the \n" +\
              "create_god option. If you want to import ShinyMUD's pre-packaged game areas, \n" +\
              "you can already do that in-game (see 'help import')."
    else:
        world = setup_stub_world()
        from shinymud.lib.sport import inport_dir

        print "\nWelcome to the ShinyMUD setup wizard! First, we'll have you create a \n" +\
              "God character (a character with full in-game priviliges).\n"
        create_god(world)
        if os.path.exists(PREPACK):
            print "\nDo you want to import our pre-packaged starting areas?"
            print "You can always delete them later in-game if you don't want them anymore."
            choice = (raw_input("Yes/No: ")).strip()
            if choice.lower().startswith('y'):
                try:
                    print ' Importing Built-in Areas '.center(50, '-')
                    result = inport_dir('area', source_path=PREPACK)
                    print result
                except Exception as e:
                    print "Oops, there was an error importing our areas.\n" +\
                          "No worries, we'll just start your game and you can try again later."
            else:
                print "Skipping the area import then. You can always import them later in-game anyway."
        print "\nOk, you're done with the game setup! Now starting your game server..."
        start()
示例#2
0
文件: main.py 项目: ei-grad/ShinyMUD
def setup():
    """Initialize the game!"""
    if os.path.exists(DB_NAME):
        print "\nYou already have a game set up.\n\n" +\
              "If you're trying to create a god character, call this script again with the \n" +\
              "create_god option. If you want to import ShinyMUD's pre-packaged game areas, \n" +\
              "you can already do that in-game (see 'help import')."
    else:
        world = setup_stub_world()
        from shinymud.lib.sport import inport_dir
        
        print "\nWelcome to the ShinyMUD setup wizard! First, we'll have you create a \n" +\
              "God character (a character with full in-game priviliges).\n"
        create_god(world)
        if os.path.exists(PREPACK):
            print "\nDo you want to import our pre-packaged starting areas?"
            print "You can always delete them later in-game if you don't want them anymore."
            choice = (raw_input("Yes/No: ")).strip()
            if choice.lower().startswith('y'):
                try:
                    print ' Importing Built-in Areas '.center(50, '-')
                    result = inport_dir('area', source_path=PREPACK)
                    print result
                except Exception as e:
                    print "Oops, there was an error importing our areas.\n" +\
                          "No worries, we'll just start your game and you can try again later."
            else:
                print "Skipping the area import then. You can always import them later in-game anyway."
        print "\nOk, you're done with the game setup! Now starting your game server..."
        start()
示例#3
0
    def test_inport_dir(self):
        from shinymud.models.area import Area
        from shinymud.lib.sport import export, inport_dir
        from shinymud.data.config import AREAS_EXPORT_DIR
        epath = AREAS_EXPORT_DIR + '/test'

        a = Area.create({'name': 'supertestfooarea'})
        b = Area.create({'name': 'supertestbararea'})
        c = Area.create({'name': 'supertestbazarea'})
        export('area', a, dest_path=epath)
        export('area', b, dest_path=epath)
        export('area', c, dest_path=epath)
        self.world.destroy_area('supertestfooarea', 'test')
        self.world.destroy_area('supertestbararea', 'test')
        self.world.destroy_area('supertestbazarea', 'test')

        txt = inport_dir('area', source_path=epath)
        self.world.log.debug(txt)
        self.assertTrue(self.world.area_exists('supertestfooarea'))
        self.assertTrue(self.world.area_exists('supertestbararea'))
        self.assertTrue(self.world.area_exists('supertestbazarea'))

        shutil.rmtree(epath, True)
示例#4
0
 def test_inport_dir(self):
     from shinymud.models.area import Area
     from shinymud.lib.sport import export, inport_dir
     from shinymud.data.config import AREAS_EXPORT_DIR
     epath = AREAS_EXPORT_DIR + '/test'
     
     a = Area.create({'name': 'supertestfooarea'})
     b = Area.create({'name': 'supertestbararea'})
     c = Area.create({'name': 'supertestbazarea'})
     export('area', a, dest_path=epath)
     export('area', b, dest_path=epath)
     export('area', c, dest_path=epath)
     self.world.destroy_area('supertestfooarea', 'test')
     self.world.destroy_area('supertestbararea', 'test')
     self.world.destroy_area('supertestbazarea', 'test')
     
     txt = inport_dir('area', source_path=epath)
     self.world.log.debug(txt)
     self.assertTrue(self.world.area_exists('supertestfooarea'))
     self.assertTrue(self.world.area_exists('supertestbararea'))
     self.assertTrue(self.world.area_exists('supertestbazarea'))
     
     shutil.rmtree(epath, True)