diff --git a/contrib/tutorial_world/build.ev b/contrib/tutorial_world/build.ev index 6eafde0132..c9b804f5a6 100644 --- a/contrib/tutorial_world/build.ev +++ b/contrib/tutorial_world/build.ev @@ -673,15 +673,16 @@ hole # light source. # @desc - {YThe {yflickering light{Y of the torch reveals a small square + {YThe {yflickering light{Y of your makeshift light reveals a small square cell. It does not seem like you are still in the castle, for the stone of the walls are chiseled crudely and drip with water and mold. One wall holds a solid iron-cast door. While rusted and covered with lichen it seems very sturdy. In a corner lies what might have once - been a bed or a bench but is now nothing more than a pile or rotting - splinters. One of the walls are covered with a thick cover of black - roots where they have broken through the cracks.{n + been a bed or a bench but is now nothing more than a pile of splinters, + one of which you are using for light. One of the walls is covered with a + thick cover of black roots having broken through the cracks from the + outside.{n # @create/drop iron-cast door;iron;door;iron-cast # diff --git a/contrib/tutorial_world/rooms.py b/contrib/tutorial_world/rooms.py index a66a39886e..88eba3a49d 100644 --- a/contrib/tutorial_world/rooms.py +++ b/contrib/tutorial_world/rooms.py @@ -180,9 +180,9 @@ class CmdLookDark(Command): lightsource = lightsources[0] else: # create the light source from scratch. - lightsource = create_object(LightSource, key="torch") + lightsource = create_object(LightSource, key="splinter") lightsource.location = caller - string = "Your fingers bump against a piece of wood in a corner. Smelling it you sense the faint smell of tar. A {c%s{n!" + 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) diff --git a/src/commands/default/building.py b/src/commands/default/building.py index 05dff6cb14..65ec1223d3 100644 --- a/src/commands/default/building.py +++ b/src/commands/default/building.py @@ -1678,7 +1678,7 @@ class CmdExamine(ObjManipCommand): string += headers["cmdset"] % ("\n ".join("%s (prio %s)" % (cmdset.path, cmdset.priority) for cmdset in all_cmdsets)) #cmdsetstr = "\n".join([utils.fill(cmdset, indent=2) for cmdset in str(obj.cmdset).split("\n")]) - # list the actually available commands + # list the commands available to this object avail_cmdset = sorted([cmd.key for cmd in avail_cmdset if cmd.access(obj, "cmd")]) cmdsetstr = utils.fill(", ".join(avail_cmdset), indent=2) diff --git a/src/commands/default/cmdset_default.py b/src/commands/default/cmdset_default.py index e58a8423a2..51eb06d752 100644 --- a/src/commands/default/cmdset_default.py +++ b/src/commands/default/cmdset_default.py @@ -27,6 +27,7 @@ class DefaultCmdSet(CmdSet): self.add(general.CmdNick()) self.add(general.CmdGet()) self.add(general.CmdDrop()) + self.add(general.CmdGive()) self.add(general.CmdSay()) self.add(general.CmdAccess()) self.add(general.CmdColorTest()) diff --git a/src/commands/default/general.py b/src/commands/default/general.py index 1dc74e3584..3ec8f0c588 100644 --- a/src/commands/default/general.py +++ b/src/commands/default/general.py @@ -11,7 +11,7 @@ from src.commands.default.muxcommand import MuxCommand, MuxCommandOOC # limit symbol import for API __all__ = ("CmdHome", "CmdLook", "CmdPassword", "CmdNick", - "CmdInventory", "CmdGet", "CmdDrop", "CmdQuit", "CmdWho", + "CmdInventory", "CmdGet", "CmdDrop", "CmdGive", "CmdQuit", "CmdWho", "CmdSay", "CmdPose", "CmdEncoding", "CmdAccess", "CmdOOCLook", "CmdIC", "CmdOOC", "CmdColorTest") @@ -345,6 +345,42 @@ class CmdDrop(MuxCommand): obj.at_drop(caller) +class CmdGive(MuxCommand): + """ + give away things + + Usage: + give = + + Gives an items from your inventory to another character, + placing it in their inventory. + """ + key = "give" + locks = "cmd:all()" + + def func(self): + "Implement give" + + caller = self.caller + if not self.args or not self.rhs: + caller.msg("Usage: give = ") + return + to_give = caller.search(self.lhs) + target = caller.search(self.rhs) + if not (to_give and target): + return + if target == caller: + caller.msg("You keep %s to yourself." % to_give.key) + return + if not to_give.location == caller: + caller.msg("You are not holding %s." % to_give.key) + return + # give object + to_give.location = target + caller.msg("You give %s to %s." % (to_give.key, target.key)) + target.msg("%s gives you %s." % (caller.key, to_give.key)) + + class CmdQuit(MuxCommand): """ quit diff --git a/src/objects/objects.py b/src/objects/objects.py index cd589db688..b28d0e5481 100644 --- a/src/objects/objects.py +++ b/src/objects/objects.py @@ -387,13 +387,11 @@ class Object(TypeClass): parent doesn't work. """ try: - return _GA(_GA(self, "dbobj"),"dbid") == other \ - or _GA(_GA(self, "dbobj"),"dbid") == _GA(_GA(other,"dbobj"),"dbid") + return _GA(_GA(self, "dbobj"),"dbid") == _GA(_GA(other,"dbobj"),"dbid") except AttributeError: # compare players instead try: - return _GA(_GA(_GA(self, "dbobj"),"player"),"uid") == other \ - or _GA(_GA(_GA(self, "dbobj"),"player"),"uid") == _GA(_GA(other, "player"),"uid") + return _GA(_GA(_GA(self, "dbobj"),"player"),"uid") == _GA(_GA(other, "player"),"uid") except AttributeError: return False diff --git a/src/typeclasses/typeclass.py b/src/typeclasses/typeclass.py index f9af464dfa..7c46ecb322 100644 --- a/src/typeclasses/typeclass.py +++ b/src/typeclasses/typeclass.py @@ -157,10 +157,9 @@ class TypeClass(object): dbobj-recognized comparison """ try: - return other == self or other == _GA(self, dbobj) or other == _GA(self, dbobj).user + return _GA(_GA(self, "dbobj"), "dbid") == _GA(_GA(other, "dbobj"), "dbid") except AttributeError: - # if self.dbobj.user fails it means the two previous comparisons failed already - return False + return id(self) == id(other) def __delattr__(self, propname): diff --git a/src/utils/utils.py b/src/utils/utils.py index 89b7eb7f71..0093e819e5 100644 --- a/src/utils/utils.py +++ b/src/utils/utils.py @@ -350,13 +350,10 @@ def to_str(obj, encoding='utf-8', force_string=False): if force_string and not isinstance(obj, basestring): # some sort of other object. Try to # convert it to a string representation. - if hasattr(obj, '__str__'): - obj = obj.__str__() - elif hasattr(obj, '__unicode__'): - obj = obj.__unicode__() - else: - # last resort + try: obj = str(obj) + except Exception: + obj = unicode(obj) if isinstance(obj, basestring) and isinstance(obj, unicode): try: