diff --git a/contrib/tutorial_world/build.ev b/contrib/tutorial_world/build.ev index c9b804f5a6..e6b9a36017 100644 --- a/contrib/tutorial_world/build.ev +++ b/contrib/tutorial_world/build.ev @@ -1196,6 +1196,9 @@ stairs down # to tutorial outro @tel tut#17 # +# we want to clear the weapon-rack ids on the character when exiting. +@set here/wracklist = ["rack_sarcophagus"] +# # this quits the tutorial and cleans up all variables that was . @desc {gThanks for trying out this little Evennia tutorial! diff --git a/contrib/tutorial_world/mob.py b/contrib/tutorial_world/mob.py index 082376fc10..f210e15bcf 100644 --- a/contrib/tutorial_world/mob.py +++ b/contrib/tutorial_world/mob.py @@ -114,10 +114,9 @@ class AttackTimer(Script): #return else: #dead mode. Wait for respawn. - dead_at = self.db.dead_at - if not dead_at: - self.db.dead_at = time.time() - if (time.time() - self.db.dead_at) > self.db.dead_timer: + if not self.obj.db.dead_at: + self.obj.db.dead_at = time.time() + if (time.time() - self.obj.db.dead_at) > self.obj.db.dead_timer: self.obj.reset() class Enemy(Mob): @@ -332,12 +331,12 @@ class Enemy(Mob): string += "You fear it's only a matter of time before it materializes somewhere again." self.location.msg_contents(string, exclude=[attacker]) - # put enemy in dead mode and hide it from view. IrregularEvent will bring it back later. + # put enemy in dead mode and hide it from view. AttackTimer will bring it back later. + self.db.dead_at = time.time() self.db.roam_mode = False self.db.pursue_mode = False self.db.battle_mode = False self.db.dead_mode = True - self.db.dead_at = time.time() self.location = None else: self.location.msg_contents("%s wails, shudders and writhes." % self.key) diff --git a/contrib/tutorial_world/objects.py b/contrib/tutorial_world/objects.py index 3ecbee76ac..0a184bf94d 100644 --- a/contrib/tutorial_world/objects.py +++ b/contrib/tutorial_world/objects.py @@ -559,7 +559,7 @@ class CrumblingWall(TutorialObject, Exit): "called when the object is first created." super(CrumblingWall, self).at_object_creation() - self.aliases = ["secret passage", "crack", "opening", "secret door"] + self.aliases = ["secret passage", "passage", "crack", "opening", "secret door"] # this is assigned first when pushing button, so assign this at creation time! self.db.destination = 2 # locks on the object directly transfer to the exit "command" @@ -722,7 +722,7 @@ class CmdAttack(Command): ostring = "%s slash at %s with %s. " % (self.caller.key, target.key, self.obj.key) self.caller.db.combat_parry_mode = False else: - self.caller.msg("You fumble with your weapon, unable to choose an appropriate action...") + self.caller.msg("You fumble with your weapon, unsure of whether to stab, slash or parry ...") self.caller.location.msg_contents("%s fumbles with their weapon." % self.obj.key) self.caller.db.combat_parry_mode = False return @@ -807,12 +807,12 @@ class CmdGetWeapon(Command): "Implement the command" rack_id = self.obj.db.rack_id - if eval("self.caller.db.%s" % rack_id): - # we don't allow to take more than one weapon from rack. - self.caller.msg("%s has no more to offer." % self.obj.name) + if self.caller.get_attribute(rack_id): + # we don't allow a player to take more than one weapon from rack. + self.caller.msg("%s has no more to offer you." % self.obj.name) else: dmg, name, aliases, desc, magic = self.obj.randomize_type() - new_weapon = create_object(Weapon, key=name, aliases=aliases,location=self.caller) + new_weapon = create_object(Weapon, key=name, aliases=aliases,location=self.caller, home=self.caller) new_weapon.db.rack_id = rack_id new_weapon.db.damage = dmg new_weapon.db.desc = desc @@ -825,7 +825,7 @@ class CmdGetWeapon(Command): else: self.caller.msg(ostring) # tag the caller so they cannot keep taking objects from the rack. - exec("self.caller.db.%s = True" % rack_id) + self.caller.set_attribute(rack_id, True) class CmdSetWeaponRack(CmdSet): @@ -848,7 +848,7 @@ class WeaponRack(TutorialObject): def at_object_creation(self): "called at creation" self.cmdset.add_default(CmdSetWeaponRack, permanent=True) - self.rack_id = "weaponrack_1" + self.db.rack_id = "weaponrack_1" self.db.min_dmg = 1.0 self.db.max_dmg = 4.0 self.db.magic = False diff --git a/contrib/tutorial_world/rooms.py b/contrib/tutorial_world/rooms.py index 88eba3a49d..4e23c4864f 100644 --- a/contrib/tutorial_world/rooms.py +++ b/contrib/tutorial_world/rooms.py @@ -184,7 +184,7 @@ class CmdLookDark(Command): lightsource.location = caller string = "Your fingers bump against a splinter of wood in a corner. It smells of resin and seems dry enough to burn!" string += "\nYou pick it up, holding it firmly. Now you just need to {wlight{n it using the flint and steel you carry with you." - caller.msg(string % lightsource.key) + caller.msg(string) class CmdDarkHelp(Command): """ @@ -663,6 +663,10 @@ class IntroRoom(TutorialRoom): class OutroRoom(TutorialRoom): """ Outro room. + + One can set an attribute list "wracklist" with weapon-rack ids + in order to clear all weapon rack ids from the character. + """ def at_object_receive(self, character, source_location): @@ -670,8 +674,12 @@ class OutroRoom(TutorialRoom): Do cleanup. """ if character.has_player: + if self.db.wracklist: + for wrackid in self.db.wracklist: + character.del_attribute(wrackid) + del character.db.health_max del character.db.health - del character.db.has_climbed + del character.db.last_climbed del character.db.puzzle_clue del character.db.combat_parry_mode del character.db.tutorial_bridge_position diff --git a/src/locks/lockfuncs.py b/src/locks/lockfuncs.py index ccbfe2c0b5..693b372aec 100644 --- a/src/locks/lockfuncs.py +++ b/src/locks/lockfuncs.py @@ -383,19 +383,17 @@ def holds(accessing_obj, accessed_obj, *args, **kwargs): contents = accessing_obj.obj.contents except AttributeError: return False - def check_holds(objid): # helper function. Compares both dbrefs and keys/aliases. objid = str(objid) - dbref = utils.dbref(objid) + dbref = utils.dbref(objid, reqhash=False) if dbref and any((True for obj in contents if obj.dbid == dbref)): return True objid = objid.lower() return any((True for obj in contents if obj.key.lower() == objid or objid in [al.lower() for al in obj.aliases])) - if not args: - # holds() - check if accessed_obj is held by accessing_ob + # holds() - check if accessed_obj or accessed_obj.obj is held by accessing_obj try: if check_holds(accessed_obj.dbid): return True diff --git a/src/locks/lockhandler.py b/src/locks/lockhandler.py index 1fc39fb1bc..dfb98ecd38 100644 --- a/src/locks/lockhandler.py +++ b/src/locks/lockhandler.py @@ -221,8 +221,8 @@ class LockHandler(object): if not callable(func): elist.append(_("Lock: function '%s' is not available.") % funcstring) continue - args = list(arg.strip() for arg in rest.split(',') if not '=' in arg) - kwargs = dict([arg.split('=', 1) for arg in rest.split(',') if '=' in arg]) + args = list(arg.strip() for arg in rest.split(',') if arg and not '=' in arg) + kwargs = dict([arg.split('=', 1) for arg in rest.split(',') if arg and '=' in arg]) lock_funcs.append((func, args, kwargs)) evalstring = evalstring.replace(funcstring, '%s') if len(lock_funcs) < nfuncs: