• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python create.create_object函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中src.utils.create.create_object函数的典型用法代码示例。如果您正苦于以下问题:Python create_object函数的具体用法?Python create_object怎么用?Python create_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了create_object函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: generate_physical_loot

    def generate_physical_loot(self):
        if self.db.boss_mob is True:
            loot_generator = create.create_object("game.gamesrc.objects.world.generators.LootGenerator")
            loot_item = loot_generator.create_rare_lootset()
            loot_item.move_to(self, quiet=True)
            loot_generator.delete()
            return

        rn = random.random()
        if self.db.rating in 'hero':
            if rn < AVCONFIG['hero_mob_rare_loot_rate']:
                num_of_items = random.randrange(1,2)
                loot_generator = create.create_object("game.gamesrc.objects.world.generators.LootGenerator")
                loot = loot_generator.create_loot_set(loot_rating='rare', number_of_items=num_of_items, item_type='mixed')
                for item in loot:
                    item.move_to(self, quiet=True)
                loot_generator.delete()
                    
        if rn < AVCONFIG['mob_physical_loot_drop_rate']:
            num_of_items = random.randrange(1,3)
            loot_generator = create.create_object("game.gamesrc.objects.world.generators.LootGenerator")
            ratings = ['uncommon', 'average', 'rare']
            rating = random.choice(ratings)
            loot = loot_generator.create_loot_set(loot_rating=rating, number_of_items=num_of_items, item_type='mixed')
            for item in loot:
                item.move_to(self, quiet=True)
            loot_generator.delete()
开发者ID:abbacode,项目名称:avaloria,代码行数:27,代码来源:mob.py


示例2: generate_boss_mob

 def generate_boss_mob(self):
     if 'crypt' in self.db.dungeon_type:
         self.db.boss_names = ['Skeletal Lich', 'Frostbourne Witch']
         boss_name = random.choice(self.db.boss_names)
         boss_mob = create.create_object("game.gamesrc.objects.world.mob.Mob", key="%s" % boss_name, location=self.location)
         boss_mob.aliases = ['boss_mob']
         boss_mob.db.level = self.location.db.level
         boss_mob.db.rating = 'hero'
         boss_mob.db.boss_mob = True
         boss_mob.generate_stats()
         boss_mob.generate_rewards()
         boss_mob.generate_physical_loot()
         boss_mob.generate_skillset()
         boss_mob.update_stats()
         return boss_mob
     if 'ruins' in self.db.dungeon_type:
         self.db.boss_names = ['Pygmy Lord', 'Ghastly Ghoul', 'Spider Queen']
         boss_name = random.choice(self.db.boss_names)
         boss_mob = create.create_object("game.gamesrc.objects.world.mob.Mob", key="%s" % boss_name, location=self.location)
         boss_mob.aliases = ['boss_mob']
         boss_mob.db.level = self.location.db.level
         boss_mob.db.rating = 'hero'
         boss_mob.db.boss_mob = True
         boss_mob.generate_stats()
         boss_mob.generate_rewards()
         boss_mob.generate_physical_loot()
         boss_mob.generate_skillset()
         boss_mob.update_stats()
         return boss_mob 
开发者ID:abbacode,项目名称:avaloria,代码行数:29,代码来源:generators.py


示例3: create_objects

def create_objects():
    """
    Creates the #1 player and Limbo room.
    """

    print " Creating objects (Player #1 and Limbo room) ..."

    # Set the initial User's account object's username on the #1 object.
    # This object is pure django and only holds name, email and password.
    god_user = get_god_user()

    # Create a Player 'user profile' object to hold eventual
    # mud-specific settings for the bog standard User object. This is
    # accessed by user.get_profile() and can also store attributes.
    # It also holds mud permissions, but for a superuser these
    # have no effect anyhow.
    character_typeclass = settings.BASE_CHARACTER_TYPECLASS

    # Create the Player object as well as the in-game god-character
    # for user #1. We can't set location and home yet since nothing
    # exists. Also, all properties (name, email, password, is_superuser)
    # is inherited from the user so we don't specify it again here.

    god_player = create.create_player(god_user.username, None, None, user=god_user)
    god_character = create.create_object(character_typeclass, key=god_user.username)

    god_character.id = 1
    god_character.db.desc = _('This is User #1.')
    god_character.locks.add("examine:perm(Immortals);edit:false();delete:false();boot:false();msg:all();puppet:false()")
    god_character.permissions = "Immortals"

    god_character.save()
    god_player.set_attribute("_first_login", True)
    god_player.set_attribute("_last_puppet", god_character)
    god_player.db._playable_characters.append(god_character)

    # Limbo is the default "nowhere" starting room

    room_typeclass = settings.BASE_ROOM_TYPECLASS
    limbo_obj = create.create_object(room_typeclass, _('Limbo'))
    limbo_obj.id = 2
    string = " ".join([
        "Welcome to your new {wEvennia{n-based game. From here you are ready to begin development.",
        "Visit http://evennia.com if you should need help or would like to participate in community discussions.",
        "If you are logged in as User #1 you can create a demo/tutorial area with '@batchcommand contrib.tutorial_world.build'.",
        "Log out and create a new non-admin account at the login screen to play the tutorial properly."])
    string = _(string)
    limbo_obj.db.desc = string
    limbo_obj.save()

    # Now that Limbo exists, try to set the user up in Limbo (unless
    # the creation hooks already fixed this).
    if not god_character.location:
        god_character.location = limbo_obj
    if not god_character.home:
        god_character.home = limbo_obj
开发者ID:OthersGames,项目名称:asylum-jam,代码行数:56,代码来源:initial_setup.py


示例4: on_use

 def on_use(self, caller):
     manager = caller.db.spellbook
     spells = manager.db.spells
     if self.db.level_requirement is not None:
         if caller.db.attributes['level'] < self.db.level_requirement:
             caller.msg("{RYou are not high enough level to learn this spell.{n")
             return
     if 'heal' in self.db.spell:
         if 'heal' not in spells.keys():
             healing_spell_obj = create.create_object("game.gamesrc.objects.world.spells.Heal", key="Heal")
             healing_spell_obj.db.character = caller
             manager.add_item(healing_spell_obj.name.title(), healing_spell_obj)
             caller.msg("{CYou have learned the spell: {G%s{n{C.{n" % healing_spell_obj.name)
         else:
             caller.msg("You already know that spell.")
     if 'fireball' in self.db.spell:
         if 'fireball' not in spells.keys():
             fireball_spell_obj = create.create_object("game.gamesrc.objects.world.spells.Fireball", key="Fireball")
             fireball_spell_obj.db.character = caller
             manager.add_item(fireball_spell_obj.name, fireball_spell_obj)
             caller.msg("{CYou have learned the spell: {G%s{n{C.{n" % fireball_spell_obj.name)
         else:
             caller.msg("You already know that spell.")
     if 'mageshield' in self.db.spell:
         if 'mage shield' not in spells.keys():
             mageshield_spell_obj = create.create_object("game.gamesrc.objects.world.spells.MageShield", key="Mage Shield")
             mageshield_spell_obj.db.character = caller
             manager.add_item(mageshield_spell_obj.name, mageshield_spell_obj)
             caller.msg("{CYou have learned the spell:{n {G%s{n{C.{n" % mageshield_spell_obj.name)
         else:
             caller.msg("You already know that spell.")
     elif 'strength' in self.db.spell:
         if 'strength of the bear' not in spells.keys():
             strength_spell = create.create_object("game.gamesrc.objects.world.spells.StrOfBear", key="Strength Of The Bear")
             strength_spell.db.character = caller
             manager.add_item(strength_spell.name, strength_spell)
             caller.msg("{CYou have learned the spell:{n {G%s{C.{n" % strength_spell.name)
         else:
             caller.msg("You alredy know that spell.")
     elif 'magic missile' in self.db.spell:
         if 'magic missile' not in spells.keys():
             mm_spell = create.create_object("game.gamesrc.objects.world.spells.MagicMissile", key="Magic Missile")
             mm_spell.db.character = caller
             manager.add_item(mm_spell.name, mm_spell)
             caller.msg("{CYou have learned the spell:{n {G%s{C.{n" % mm_spell.name)
         else:
             caller.msg("You alreadyg know that spell.")
     caller.db.spellbook = manager
开发者ID:abbacode,项目名称:avaloria,代码行数:48,代码来源:spells.py


示例5: copy_object

    def copy_object(self, original_object, new_key=None,
                    new_location=None, new_player=None, new_home=None,
                    new_permissions=None, new_locks=None, new_aliases=None, new_destination=None):
        """
        Create and return a new object as a copy of the original object. All will
        be identical to the original except for the arguments given specifically
        to this method.

        original_object (obj) - the object to make a copy from
        new_key (str) - name the copy differently from the original.
        new_location (obj) - if not None, change the location
        new_home (obj) - if not None, change the Home
        new_aliases (list of strings) - if not None, change object aliases.
        new_destination (obj) - if not None, change destination
        """

        # get all the object's stats
        typeclass_path = original_object.typeclass_path
        if not new_key:
            new_key = original_object.key
        if not new_location:
            new_location = original_object.location
        if not new_home:
            new_home = original_object.home
        if not new_player:
            new_player = original_object.player
        if not new_aliases:
            new_aliases = original_object.aliases
        if not new_locks:
            new_locks = original_object.db_lock_storage
        if not new_permissions:
            new_permissions = original_object.permissions
        if not new_destination:
            new_destination = original_object.destination

        # create new object
        from src.utils import create
        from src.scripts.models import ScriptDB
        new_object = create.create_object(typeclass_path, key=new_key, location=new_location,
                                          home=new_home, player=new_player, permissions=new_permissions,
                                          locks=new_locks, aliases=new_aliases, destination=new_destination)
        if not new_object:
            return None

        # copy over all attributes from old to new.
        for attr in original_object.get_all_attributes():
            new_object.set_attribute(attr.key, attr.value)

        # copy over all cmdsets, if any
        for icmdset, cmdset in enumerate(original_object.cmdset.all()):
            if icmdset == 0:
                new_object.cmdset.add_default(cmdset)
            else:
                new_object.cmdset.add(cmdset)

        # copy over all scripts, if any
        for script in original_object.scripts.all():
            ScriptDB.objects.copy_script(script, new_obj=new_object.dbobj)

        return new_object
开发者ID:BGCX262,项目名称:zsmud-git,代码行数:60,代码来源:manager.py


示例6: setUp

 def setUp(self):
     "sets up testing environment"
     self.room1 = create.create_object("src.objects.objects.Room", key="Room%i"%self.CID)
     self.room1.db.desc = "room_desc"
     self.room2 = create.create_object("src.objects.objects.Room", key="Room%ib"%self.CID)
     self.obj1 = create.create_object("src.objects.objects.Object", key="Obj%i"%self.CID, location=self.room1, home=self.room1)
     self.obj2 = create.create_object("src.objects.objects.Object", key="Obj%ib"%self.CID, location=self.room1, home=self.room1)
     self.player = create.create_player("TestPlayer%i"%self.CID, "[email protected]", "testpassword", typeclass=TestPlayer, create_character=False)
     self.caller = create.create_player("Caller%i"%self.CID, "[email protected]", "testpassword", player_dbobj=self.player.dbobj,
                                        character_typeclass="src.objects.objects.Character",
                                        permissions=["Immortals"], character_home=self.room1, character_location=self.room1)
     self.caller.player = self.player
     self.char = create.create_player("Char%i"%self.CID, "[email protected]", "testpassword2", typeclass=TestPlayer,
                                      character_typeclass="src.objects.objects.Character",
                                      permissions=["Immortals"], character_home=self.room1, character_location=self.room1)
     self.char = create.create_script("src.scripts.scripts.Script", key="Script%i"%self.CID)
开发者ID:BGCX262,项目名称:zsmud-git,代码行数:16,代码来源:tests.py


示例7: func

    def func(self):
        "create the new character"
        player = self.player
        if not self.args:
            self.msg("Usage: @charcreate <charname> [= description]")
            return
        key = self.lhs
        desc = self.rhs
        if not player.is_superuser and \
            (player.db._playable_characters and
                len(player.db._playable_characters) >= MAX_NR_CHARACTERS):
            self.msg("You may only create a maximum of %i characters." % MAX_NR_CHARACTERS)
            return
        # create the character
        from src.objects.models import ObjectDB

        start_location = ObjectDB.objects.get_id(settings.START_LOCATION)
        default_home = ObjectDB.objects.get_id(settings.DEFAULT_HOME)
        typeclass = settings.BASE_CHARACTER_TYPECLASS
        permissions = settings.PERMISSION_PLAYER_DEFAULT

        new_character = create.create_object(typeclass, key=key,
                                             location=start_location,
                                             home=default_home,
                                             permissions=permissions)
        # only allow creator (and immortals) to puppet this char
        new_character.locks.add("puppet:id(%i) or pid(%i) or perm(Immortals) or pperm(Immortals)" %
                                (new_character.id, player.id))
        player.db._playable_characters.append(new_character)
        if desc:
            new_character.db.desc = desc
        elif not new_character.db.desc:
            new_character.db.desc = "This is a Player."
        self.msg("Created new character %s. Use {[email protected] %s{n to enter the game as this character." % (new_character.key, new_character.key))
开发者ID:RetroRodent,项目名称:evennia,代码行数:34,代码来源:player.py


示例8: debug_object_scripts

def debug_object_scripts(obj_path, caller):
    """
    Create an object and test all its associated scripts 
    independently. 
    """

    try:
        string = "\n Testing scripts on {w%s{n ... " % obj_path
        obj = create.create_object(obj_path)
        obj.location = caller.location
        obj = obj.dbobj
        string += "{gOk{n."
    except Exception:
        string += trace()
        try: obj.delete()
        except: pass
        return string 
    scripts = obj.scripts.all()
    if scripts:
        string += "\n Running tests on %i object scripts ... " % (len(scripts))
        for script in scripts:
            string += "\n {wTesting %s{n ..." % script.key
            path = script.typeclass_path
            string += debug_script(path, obj=obj)
            #string += debug_run_script(path, obj=obj)
    else:
        string += "\n No scripts defined on object."

    try: 
        obj.delete()
    except: 
        string += trace()
    return string 
开发者ID:BGCX262,项目名称:zsmud-git,代码行数:33,代码来源:debug.py


示例9: _create_character

def _create_character(session, new_player, typeclass, start_location, home, permissions):
    """
    Helper function, creates a character based on a player's name.
    This is meant for Guest and MULTISESSION_MODE < 2 situations.
    """
    try:
        if not start_location:
            start_location = home # fallback
        new_character = create.create_object(typeclass, key=new_player.key,
                                  location=start_location, home=home,
                                  permissions=permissions)
        # set playable character list
        new_player.db._playable_characters.append(new_character)

        # allow only the character itself and the player to puppet this character (and Immortals).
        new_character.locks.add("puppet:id(%i) or pid(%i) or perm(Immortals) or pperm(Immortals)" %
                                (new_character.id, new_player.id))

        # If no description is set, set a default description
        if not new_character.db.desc:
            new_character.db.desc = "This is a Player."
        # We need to set this to have @ic auto-connect to this character
        new_player.db._last_puppet = new_character
    except Exception, e:
        session.msg("There was an error creating the Character:\n%s\n If this problem persists, contact an admin." % e)
        logger.log_trace()
        return False
开发者ID:AHecky3,项目名称:evennia,代码行数:27,代码来源:unloggedin.py


示例10: generate_contents

 def generate_contents(self):
     loot_generator = create.create_object("game.gamesrc.objects.world.generators.LootGenerator", location=self)
     rn = random.random()
     if rn < .05:
         rare_item  = loot_generator.create_rare_lootset()
     else:
         rn = random.randrange(1,4)
         loot_set = loot_generator.create_loot_set(item_type='mixed', number_of_items=rn, loot_rating='average')
         for item in loot_set:
             item.move_to(self, quiet=True) 
     loot_generator.delete()
开发者ID:abbacode,项目名称:avaloria,代码行数:11,代码来源:storage.py


示例11: setUp

    def setUp(self):
        "sets up testing environment"
        settings.DEFAULT_HOME = "#2"
        # print "creating player %i: %s" % (self.CID, self.__class__.__name__)
        self.player = create.create_player(
            "TestPlayer%i" % self.CID, "[email protected]", "testpassword", typeclass=TestPlayerClass
        )
        self.player2 = create.create_player(
            "TestPlayer%ib" % self.CID, "[email protected]", "testpassword", typeclass=TestPlayerClass
        )
        self.room1 = create.create_object("src.objects.objects.Room", key="Room%i" % self.CID, nohome=True)
        self.room1.db.desc = "room_desc"
        self.room2 = create.create_object("src.objects.objects.Room", key="Room%ib" % self.CID)
        self.obj1 = create.create_object(TestObjectClass, key="Obj%i" % self.CID, location=self.room1, home=self.room1)
        self.obj2 = create.create_object(TestObjectClass, key="Obj%ib" % self.CID, location=self.room1, home=self.room1)
        self.char1 = create.create_object(
            TestCharacterClass, key="Char%i" % self.CID, location=self.room1, home=self.room1
        )
        self.char1.permissions.add("Immortals")
        self.char2 = create.create_object(
            TestCharacterClass, key="Char%ib" % self.CID, location=self.room1, home=self.room1
        )
        self.char1.player = self.player
        self.char2.player = self.player2
        self.script = create.create_script("src.scripts.scripts.Script", key="Script%i" % self.CID)
        self.player.permissions.add("Immortals")

        # set up a fake session

        global SESSIONS
        session = ServerSession()
        session.init_session("telnet", ("localhost", "testmode"), SESSIONS)
        session.sessid = self.CID
        SESSIONS.portal_connect(session.get_sync_data())
        SESSIONS.login(SESSIONS.session_from_sessid(self.CID), self.player, testmode=True)
开发者ID:Zurriel,项目名称:evennia,代码行数:35,代码来源:tests.py


示例12: generate_zone_manager

 def generate_zone_manager(self):
     self.db.dungeon_type_picked = random.choice(self.db.dungeon_types)
     zone = create.create_object('game.gamesrc.objects.world.rooms.Zone', key="%s Zone Manager" % self.db.dungeon_type_picked.title()) 
     zone.db.zone_type = self.db.dungeon_type_picked
     mg = zone.db.mob_generator
     mg.db.dungeon_type = self.db.dungeon_type_picked 
     zone.db.mob_generator = mg
     zone.aliases = ['zone_runner']
     zone.db.zone_name = '%s' % self.db.dungeon_type_picked.title()
     zone.db.is_dungeon = True
     zone.db.quest_items = ['Deity Seal']
     self.db.zone = zone
     self.refresh_level()
     zone.db.zone_level = "%s;%s" % (self.db.level, (self.db.level + 3))
开发者ID:abbacode,项目名称:avaloria,代码行数:14,代码来源:generators.py


示例13: at_start

    def at_start(self):
        self.obj.db.in_combat = True
        self.db.unbalanced_message_sent = False
        cm = create.create_object("game.gamesrc.objects.world.combat.CombatManager", key="%s_combat_manager" % self.obj.name)
        if self.obj.db.cmd_id is not None:
            cm = self.obj.db.cm_id
            cm.delete()

        self.obj.db.cm_id = cm
        cm.db.rounds = 0
        cm.attacker = self.obj
        cm.attacker_queue = self.obj.db.combat_queue
        cm.defender = self.obj.db.target
        cm.defender_queue = cm.defender.db.combat_queue
        cm.generate_texts()
开发者ID:abbacode,项目名称:avaloria,代码行数:15,代码来源:combat_scripts.py


示例14: at_repeat

 def at_repeat(self):
     rn = random.random()
     check = self.obj.search("Treasure Chest", global_search=False)
     if check is None:
         pass
     else:
         return
     
     if self.db.chest_spawn_attempt is False:
         if rn < AVCONFIG['chest_spawn_rate']:
             chest = create.create_object("game.gamesrc.objects.world.storage.StorageItem", key="Treasure Chest")
             chest.location = self.obj
             chest.generate_contents()
             self.db.chest_spawn_attempt = True
         else:
             self.db.chest_spawn_attempt = False
开发者ID:abbacode,项目名称:avaloria,代码行数:16,代码来源:dungeon_scripts.py


示例15: new_player

def new_player(name, email, password, request):
    """
    Easier front-end for creating a new player. Also sends reg email.
    """
    player = create_player(key=name, email=email, password=password,
        permissions=settings.PERMISSION_PLAYER_DEFAULT,
        typeclass=settings.BASE_PLAYER_TYPECLASS)
    player.is_active = False
    player.save()
    character = create_object(typeclass=settings.BASE_CHARACTER_TYPECLASS, key=name,
        permissions=settings.PERMISSION_PLAYER_DEFAULT, home=settings.CHARACTER_DEFAULT_HOME)
    character.db.spirit = player
    player.db.avatar = character
    player.db._last_puppet = character
    player.db._playable_characters = [ character ]
    character.locks.add("puppet:id(%i) or pid(%i) or perm(Immortals) or pperm(Immortals)" % (character.id, player.id))
    character.new_character()
    send_activation_email(player, request)
开发者ID:Kelketek,项目名称:wintersoasis,代码行数:18,代码来源:backend.py


示例16: at_object_creation

 def at_object_creation(self):
     self.db.zone_name = None
     self.aliases = ['zone_manager']
     self.db.enemy_npcs = []
     self.db.map = {}
     self.db.path_map = {}
     self.db.grid_size = None
     self.db.valid_zones = ['dungeon', 'woodlands', 'marshlands', 'tutorial']
     self.db.zone_type = 'marshlands'
     self.db.player_map = {}
     self.db.quest_items = []
     self.db.looted = False
     labels = string.ascii_uppercase
     self.db.x_axis_labels = list(labels)
     self.db.y_axis_labels = [x for x in range(0, len(self.db.x_axis_labels))]
     mob_generator = create.create_object("game.gamesrc.objects.world.generators.MobGenerator", key="%s mob_gen" % self.name)
     mob_generator.location = self
     mob_generator.db.dungeon_type = self.db.zone_type
     self.db.is_dungeon = False
     self.db.mob_generator = mob_generator
     self.set_zone_level()
开发者ID:abbacode,项目名称:avaloria,代码行数:21,代码来源:rooms.py


示例17: setUp

    def setUp(self):
        "sets up testing environment"
        self.room1 = create.create_object("src.objects.objects.Room", key="Room%i"%self.CID)
        self.room1.db.desc = "room_desc"
        self.room2 = create.create_object("src.objects.objects.Room", key="Room%ib" % self.CID)
        self.obj1 = create.create_object("src.objects.objects.Object", key="Obj%i" % self.CID, location=self.room1, home=self.room1)
        self.obj2 = create.create_object("src.objects.objects.Object", key="Obj%ib" % self.CID, location=self.room1, home=self.room1)
        self.char1 = create.create_object("src.objects.objects.Character", key="Char%i" % self.CID, location=self.room1, home=self.room1)
        self.char2 = create.create_object("src.objects.objects.Character", key="Char%ib" % self.CID, location=self.room1, home=self.room1)
        self.script = create.create_script("src.scripts.scripts.Script", key="Script%i" % self.CID)
        self.player = create.create_player("TestPlayer%i" % self.CID, "[email protected]", "testpassword", typeclass=TestPlayerClass)
        self.player2 = create.create_player("TestPlayer%ib" % self.CID, "[email protected]", "testpassword", typeclass=TestPlayerClass)

        self.player.permissions = "Immortals"
        self.char1.player = self.player
        self.char1.sessid = 1
开发者ID:OthersGames,项目名称:asylum-jam,代码行数:16,代码来源:tests.py


示例18: search

#HEADER
from src.utils import create, search

#CODE (create the backend room that contains all items in the game)
room_check = search("storage", global_search=True)
if room_check is None:
	caller.msg("Backend room exists, skipping.  Room id: %s"  % room_check.dbref)
	pass
else:
	room = create.create_object("game.gamesrc.objects.baseobjects.Room", key="storage", aliases=["items"])
	caller.msg("Backend Room created, id: %s" % room.dbref)

#CODE

preset_weapons = ['Sword of Truth', 'Blessed Hammer of An\'Karith', 'Axe of Ferocity', 'Arm of the Tyrant', 'Staff of Clarity',
					'Mace of the Druid King', 'Wizards Staff of Omen', 'Roderick\'s Claymore', ]
room = search("storage", global_search=True)
for weapon in preset_weapons:
	weapon = create.create_object("game.gamesrc.objects.world.items.Weapon", key=weapon, location=room)
	caller.msg("%s created!" % weapon.name)
	if 'Sword of Truth' in weapon:
		weapon.db.damage = "2d10"
		weapon.db.desc = "The sword's blade glimmers even when there is no light source.  It seeks evil."
		weapon.db.value = 1250
		weapon.db.item_level = "rare"
		weapon.db.slot = "weapon"
		weapon.db.weapon_type = "sword"
		weapon.db.attribute_bonuses = { 'str': 10, 'dex': 5, 'int': 1, 'con': 10 }
	elif 'Blessed Hammer of' in weapon:
		weapon.db.damage = "4d12"
		weapon.db.desc = "This giant two handed hammer looks impossible to lift, but is quite light in hand.  Runes are carved up and down the stone handle"
开发者ID:abbacode,项目名称:avaloria,代码行数:31,代码来源:backend.py


示例19: create_objects

def create_objects():
    """
    Creates the #1 player and Limbo room.
    """

    print " Creating objects (Player #1 and Limbo room) ..."

    # Set the initial User's account object's username on the #1 object.
    # This object is pure django and only holds name, email and password.
    god_player = get_god_player()

    # Create a Player 'user profile' object to hold eventual
    # mud-specific settings for the PlayerDB object.
    player_typeclass = settings.BASE_PLAYER_TYPECLASS

    # run all creation hooks on god_player (we must do so manually
    # since the manage.py command does not)
    god_player.typeclass_path = player_typeclass
    god_player.basetype_setup()
    god_player.at_player_creation()
    god_player.locks.add("examine:perm(Immortals);edit:false();delete:false();boot:false();msg:all()")
    # this is necessary for quelling to work correctly.
    god_player.permissions.add("Immortals")

    # Limbo is the default "nowhere" starting room

    # Create the in-game god-character for player #1 and set
    # it to exist in Limbo.
    character_typeclass = settings.BASE_CHARACTER_TYPECLASS
    god_character = create.create_object(character_typeclass,
                                           key=god_player.username, nohome=True)

    god_character.id = 1
    god_character.db.desc = _('This is User #1.')
    god_character.locks.add("examine:perm(Immortals);edit:false();delete:false();boot:false();msg:all();puppet:false()")
    god_character.permissions.add("Immortals")

    god_character.save()
    god_player.attributes.add("_first_login", True)
    god_player.attributes.add("_last_puppet", god_character)
    god_player.db._playable_characters.append(god_character)

    room_typeclass = settings.BASE_ROOM_TYPECLASS
    limbo_obj = create.create_object(room_typeclass, _('Limbo'), nohome=True)
    limbo_obj.id = 2
    string = " ".join([
        "Welcome to your new {wEvennia{n-based game. From here you are ready",
        "to begin development. Visit http://evennia.com if you should need",
        "help or would like to participate in community discussions. If you",
        "are logged in as User #1 you can create a demo/tutorial area with",
        "'@batchcommand contrib.tutorial_world.build'. Log out and create",
        "a new non-admin account at the login screen to play the tutorial",
        "properly."])
    string = _(string)
    limbo_obj.db.desc = string
    limbo_obj.save()

    # Now that Limbo exists, try to set the user up in Limbo (unless
    # the creation hooks already fixed this).
    if not god_character.location:
        god_character.location = limbo_obj
    if not god_character.home:
        god_character.home = limbo_obj
开发者ID:reddcoin-project,项目名称:ReddConnect,代码行数:63,代码来源:initial_setup.py


示例20: generate_rooms

    def generate_rooms(self):
        """
        This generates the actual room objects of the dungeon
        TODO: Add cardinal direction to where exits point.
        """
        #is there already a dungeon built?
        manager = self.db.manager
        if len(manager.db.dungeon) >= 1:
            manager.delete_previous_dungeon()
            #we need to nuke to zone object as well so it re-creates itself on this use
            zone = self.db.zone
            zone.delete()
            self.db.zone = None

        #If we have no zone attribute, make a zone object and assign one.
        if not hasattr(self, 'zone'):
            self.generate_zone_manager()
            zone = self.db.zone
        #or if the zone attribute is None, create and assign on
        elif self.db.zone is None:
            self.generate_zone_manager()
            zone = self.db.zone
        else:
        #or just use whats there.
            zone = self.db.zone
        #grab the zone path map for the dungeon
        path_map = zone.db.path_map
            
        dungeon = []
        #first we build a list of rooms.
        for i in range(self.db.number_of_rooms):
            room = create.create_object("game.gamesrc.objects.world.rooms.DungeonRoom", key = "%s - Room %s" % (self.db.dungeon_type_picked, i))
            self.generate_room_texts(room)
            room.db.level = self.db.level
            room.db.dungeon_type = self.db.dungeon_type_picked
            if i == self.db.number_of_rooms - 1:
                room.db.last_room = True
            else:
                room.db.last_room = False
            #add the script that spawns and watches the rooms treasure spawn (chests, loot caches and what not)
            room.scripts.add("game.gamesrc.scripts.world_scripts.dungeon_scripts.TreasureSpawner")
            room.db.manager = zone
            #add the room to the dungeon list of rooms
            dungeon.append(room)
            #add the cell to the path_map so the zone manager knows where to look for things.
            path_map['A%s' % i] = room
            #add a cell number to the dungeon room
            room.db.cell_number = 'A%s' % i
            if i > 0:
                room.aliases = ['%s_quest_item_spawn' % self.db.dungeon_type_picked]
        zone.db.path_map = path_map
        manager.db.dungeon = dungeon
        self.db.zone = zone
        #manually trigger zone_runner to spawn mobs
        zone.update()

        i = 0   
        lair = self.search(self.location.db.lair_id, global_search=True)
        rooms = manager.db.dungeon
        for room in manager.db.dungeon:
            exit_name = random.choice(self.db.exit_types)
            if i != 0:
                #if not the first room
                previous_room = rooms[i - 1]
                destination_obj = previous_room
                #link to previous room
                exit = create.create_object("game.gamesrc.objects.baseobjects.Exit", key="Previous Room", location=room, destination=destination_obj)
                exit.aliases = [exit.key.lower(), 'prev', 'pr']
                exit_name = random.choice(self.db.exit_types)
                #link to the next room
                try:    
                    next_room = rooms[i + 1]
                except IndexError:
                    
                    return
                destination_obj = next_room
                exit2 = create.create_object("game.gamesrc.objects.baseobjects.Exit", key=exit_name, location=room, destination=destination_obj)
            else:
                #portal back home
                exit = create.create_object("game.gamesrc.objects.baseobjects.Exit", key="Glowing Red Portal", location=room, destination=lair)
                exit.aliases = [ 'portal', 'glowing portal', 'red portal' ]
                #portal to the dungeon
                entrance_to_dungeon = create.create_object("game.gamesrc.objects.baseobjects.Exit", key="Glowing Red Portal",
                                                                 location=lair, destination=room)
                entrance_to_dungeon.aliases = [ 'portal', 'glowing portal', 'red portal' ]
                next_room = rooms[1]
                exit_name = random.choice(self.db.exit_types)
                destination_obj = next_room
                next_room_exit = create.create_object("game.gamesrc.objects.baseobjects.Exit", key=exit_name, 
                                                            location=room, destination=destination_obj)
            i += 1
开发者ID:abbacode,项目名称:avaloria,代码行数:91,代码来源:generators.py



注:本文中的src.utils.create.create_object函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.SharedMemoryModel类代码示例发布时间:2022-05-27
下一篇:
Python logger.debug函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap