Esempio n. 1
0
def at_initial_setup():
    """
    Build up the default world and set default locations.
    """

    try:
        # load data
        from muddery.server.dao.worlddata import WorldData
        WorldData.reload()
        print("Reload world data.")

        # load game settings
        GAME_SETTINGS.reset()
        print("Reset game settings.")

        # build world
        builder.build_all()
        print("Builder build all.")

        # set limbo's desc
        limbo_obj = search.search_object("#2", exact=True)
        if limbo_obj:
            limbo_obj[0].db.desc = LIMBO_DESC
            limbo_obj[0].position = None
        print("Set limbo object.")

        # set default locations
        builder.reset_default_locations()
        print("Set default locations.")

        superuser = search.search_object("#1", exact=True)
        if superuser:
            superuser = superuser[0]

            # move the superuser to the start location
            start_location = search.search_object(settings.START_LOCATION,
                                                  exact=True)
            if start_location:
                start_location = start_location[0]
                superuser.move_to(start_location, quiet=True)

            # set superuser's data
            superuser.set_data_key(
                GAME_SETTINGS.get("default_player_character_key"), 1)
            superuser.set_nickname("superuser")

            print("Set superuser.")

    except Exception as e:
        ostring = "Can't set initial data: %s" % e
        print(ostring)
        print(traceback.format_exc())
Esempio n. 2
0
def at_server_start():
    """
    This is called every time the server starts up, regardless of
    how it was shut down.
    """
    # load data
    from muddery.server.dao.worlddata import WorldData
    WorldData.reload()

    # reset settings
    from muddery.server.utils.game_settings import GAME_SETTINGS
    GAME_SETTINGS.reset()

    # reload local strings
    from muddery.server.utils.localized_strings_handler import LOCALIZED_STRINGS_HANDLER
    LOCALIZED_STRINGS_HANDLER.reload()

    # reset default locations
    from muddery.server.utils import builder
    builder.reset_default_locations()
    
    # clear dialogues
    from muddery.server.utils.dialogue_handler import DIALOGUE_HANDLER
    DIALOGUE_HANDLER.clear()
    
    # reload equipment types
    from muddery.server.utils.equip_type_handler import EQUIP_TYPE_HANDLER
    EQUIP_TYPE_HANDLER.reload()

    # localize model fields
    from muddery.server.utils.localiztion_handler import localize_model_fields
    localize_model_fields()
    
    # load condition descriptions
    from muddery.server.utils.desc_handler import DESC_HANDLER
    DESC_HANDLER.reload()

    # load honours
    from muddery.server.dao.honours_mapper import HONOURS_MAPPER
    HONOURS_MAPPER.reload()
Esempio n. 3
0
    def func(self, args, request):
        try:
            # reload system data
            # import_syetem_data()

            # reload localized strings
            # LOCALIZED_STRINGS_HANDLER.reload()

            # reload data
            WorldData.reload()

            # rebuild the world
            build_all()

            # restart the server
            SESSIONS.announce_all("Server restarting ...")
            SESSIONS.portal_restart_server()
        except Exception as e:
            message = "Can not build the world: %s" % e
            logger.log_tracemsg(message)
            raise MudderyError(ERR.build_world_error, message)

        return success_response("success")