From ee37070422f8682791e0406549de63b8b34f5aa9 Mon Sep 17 00:00:00 2001 From: BlauFeuer Date: Mon, 15 Jan 2018 13:50:08 -0500 Subject: [PATCH 1/7] `@locate` alias of CmdFind shows location of find If using `@locate` alias and only one object is found and the found object has a location, display that information. --- evennia/commands/default/building.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/evennia/commands/default/building.py b/evennia/commands/default/building.py index 445ec082a9..9a7caf8567 100644 --- a/evennia/commands/default/building.py +++ b/evennia/commands/default/building.py @@ -2315,6 +2315,8 @@ class CmdFind(COMMAND_DEFAULT_CLASS): else: result = result[0] string += "\n|g %s - %s|n" % (result.get_display_name(caller), result.path) + if self.cmdstring == "@locate" and not is_account and result.location: + string += " Location: {}".format(result.location.get_display_name(caller)) else: # Not an account/dbref search but a wider search; build a queryset. # Searchs for key and aliases @@ -2350,6 +2352,8 @@ class CmdFind(COMMAND_DEFAULT_CLASS): else: string = "|wOne Match|n(#%i-#%i%s):" % (low, high, restrictions) string += "\n |g%s - %s|n" % (results[0].get_display_name(caller), results[0].path) + if self.cmdstring == "@locate" and nresults == 1 and results[0].location: + string += " Location: {}".format(results[0].location.get_display_name(caller)) else: string = "|wMatch|n(#%i-#%i%s):" % (low, high, restrictions) string += "\n |RNo matches found for '%s'|n" % searchstring From 0abaf90b6a86d146962ce8e2005a86b9faf8a45e Mon Sep 17 00:00:00 2001 From: BlauFeuer Date: Mon, 15 Jan 2018 13:53:19 -0500 Subject: [PATCH 2/7] Typo fix in CmdWhisper help docstring --- evennia/commands/default/general.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evennia/commands/default/general.py b/evennia/commands/default/general.py index 612a798167..195ad9a7d1 100644 --- a/evennia/commands/default/general.py +++ b/evennia/commands/default/general.py @@ -439,7 +439,7 @@ class CmdWhisper(COMMAND_DEFAULT_CLASS): Usage: whisper = - whisper , = , = Talk privately to one or more characters in your current location, without others in the room being informed. From 8ba52361d788603f600891f3aad497b02043474c Mon Sep 17 00:00:00 2001 From: BlauFeuer Date: Wed, 17 Jan 2018 15:36:27 -0500 Subject: [PATCH 3/7] Docstring typo fix in access method of Command --- evennia/commands/command.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evennia/commands/command.py b/evennia/commands/command.py index 48a4b132da..17902b3602 100644 --- a/evennia/commands/command.py +++ b/evennia/commands/command.py @@ -297,7 +297,7 @@ class Command(with_metaclass(CommandMeta, object)): Args: srcobj (Object): Object trying to gain permission access_type (str, optional): The lock type to check. - default (bool, optional): The fallbacl result if no lock + default (bool, optional): The fallback result if no lock of matching `access_type` is found on this Command. """ From 7daf8db1202d8990e73db5a28d418e891ab305f2 Mon Sep 17 00:00:00 2001 From: BlauFeuer Date: Fri, 19 Jan 2018 01:57:48 -0500 Subject: [PATCH 4/7] Whitespace formatting MULTISESSION_MODE comments --- evennia/settings_default.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/evennia/settings_default.py b/evennia/settings_default.py index 19666b8bf1..dc2e064633 100644 --- a/evennia/settings_default.py +++ b/evennia/settings_default.py @@ -470,7 +470,7 @@ BASE_SCRIPT_TYPECLASS = "typeclasses.scripts.Script" DEFAULT_HOME = "#2" # The start position for new characters. Default is Limbo (#2). # MULTISESSION_MODE = 0, 1 - used by default unloggedin create command -# MULTISESSION_MODE = 2,3 - used by default character_create command +# MULTISESSION_MODE = 2, 3 - used by default character_create command START_LOCATION = "#2" # Lookups of Attributes, Tags, Nicks, Aliases can be aggressively # cached to avoid repeated database hits. This often gives noticeable @@ -545,8 +545,8 @@ INLINEFUNC_MODULES = ["evennia.utils.inlinefuncs", # 3 - like mode 2, except multiple sessions can puppet one character, each # session getting the same data. MULTISESSION_MODE = 0 -# The maximum number of characters allowed for MULTISESSION_MODE 2,3. This is -# checked by the default ooc char-creation command. Forced to 1 for +# The maximum number of characters allowed for MULTISESSION_MODE 2, 3. +# This is checked by the default ooc char-creation command. Forced to 1 for # MULTISESSION_MODE 0 and 1. MAX_NR_CHARACTERS = 1 # The access hierarchy, in climbing order. A higher permission in the From 01ad0f884343dada93ec62a959d040aeb92b3745 Mon Sep 17 00:00:00 2001 From: BlauFeuer Date: Fri, 19 Jan 2018 05:28:03 -0500 Subject: [PATCH 5/7] Fix to catch non `@` version of command --- evennia/commands/default/building.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/evennia/commands/default/building.py b/evennia/commands/default/building.py index 9a7caf8567..de263fa4ff 100644 --- a/evennia/commands/default/building.py +++ b/evennia/commands/default/building.py @@ -2315,7 +2315,7 @@ class CmdFind(COMMAND_DEFAULT_CLASS): else: result = result[0] string += "\n|g %s - %s|n" % (result.get_display_name(caller), result.path) - if self.cmdstring == "@locate" and not is_account and result.location: + if "locate" in self.cmdstring and not is_account and result.location: string += " Location: {}".format(result.location.get_display_name(caller)) else: # Not an account/dbref search but a wider search; build a queryset. @@ -2352,7 +2352,7 @@ class CmdFind(COMMAND_DEFAULT_CLASS): else: string = "|wOne Match|n(#%i-#%i%s):" % (low, high, restrictions) string += "\n |g%s - %s|n" % (results[0].get_display_name(caller), results[0].path) - if self.cmdstring == "@locate" and nresults == 1 and results[0].location: + if "locate" in self.cmdstring and nresults == 1 and results[0].location: string += " Location: {}".format(results[0].location.get_display_name(caller)) else: string = "|wMatch|n(#%i-#%i%s):" % (low, high, restrictions) From b8c2059f79af00d0f3de5317b86370c9b000055b Mon Sep 17 00:00:00 2001 From: BlauFeuer Date: Thu, 15 Feb 2018 17:25:01 -0500 Subject: [PATCH 6/7] Add loc switch to CmdFind and docstring --- evennia/commands/default/building.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/evennia/commands/default/building.py b/evennia/commands/default/building.py index de263fa4ff..ee0062e96b 100644 --- a/evennia/commands/default/building.py +++ b/evennia/commands/default/building.py @@ -2238,12 +2238,14 @@ class CmdFind(COMMAND_DEFAULT_CLASS): Usage: @find[/switches] [= dbrefmin[-dbrefmax]] + @locate - this is a shorthand for using the /loc switch. Switches: room - only look for rooms (location=None) exit - only look for exits (destination!=None) char - only look for characters (BASE_CHARACTER_TYPECLASS) exact- only exact matches are returned. + loc - display object location if exists and match has one result Searches the database for an object of a particular name or exact #dbref. Use *accountname to search for an account. The switches allows for @@ -2266,6 +2268,9 @@ class CmdFind(COMMAND_DEFAULT_CLASS): caller.msg("Usage: @find [= low [-high]]") return + if "locate" in self.cmdstring: # Use option /loc as a default for @locate command alias + switches.append('loc') + searchstring = self.lhs low, high = 1, ObjectDB.objects.all().order_by("-id")[0].id if self.rhs: @@ -2315,8 +2320,8 @@ class CmdFind(COMMAND_DEFAULT_CLASS): else: result = result[0] string += "\n|g %s - %s|n" % (result.get_display_name(caller), result.path) - if "locate" in self.cmdstring and not is_account and result.location: - string += " Location: {}".format(result.location.get_display_name(caller)) + if "loc" in self.switches and not is_account and result.location: + string += " (|wlocation|n: |g{}|n)".format(result.location.get_display_name(caller)) else: # Not an account/dbref search but a wider search; build a queryset. # Searchs for key and aliases @@ -2352,8 +2357,8 @@ class CmdFind(COMMAND_DEFAULT_CLASS): else: string = "|wOne Match|n(#%i-#%i%s):" % (low, high, restrictions) string += "\n |g%s - %s|n" % (results[0].get_display_name(caller), results[0].path) - if "locate" in self.cmdstring and nresults == 1 and results[0].location: - string += " Location: {}".format(results[0].location.get_display_name(caller)) + if "loc" in self.switches and nresults == 1 and results[0].location: + string += " (|wlocation|n: |g{}|n)".format(results[0].location.get_display_name(caller)) else: string = "|wMatch|n(#%i-#%i%s):" % (low, high, restrictions) string += "\n |RNo matches found for '%s'|n" % searchstring From 8378ba7a8d4d495a63802bded0d8d16b5151ed59 Mon Sep 17 00:00:00 2001 From: BlauFeuer Date: Thu, 15 Feb 2018 19:41:24 -0500 Subject: [PATCH 7/7] Add test for CmdFind locate alias and loc switch --- evennia/commands/default/tests.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/evennia/commands/default/tests.py b/evennia/commands/default/tests.py index 013baec4cc..850c1b6e4f 100644 --- a/evennia/commands/default/tests.py +++ b/evennia/commands/default/tests.py @@ -293,6 +293,12 @@ class TestBuilding(CommandTest): def test_find(self): self.call(building.CmdFind(), "Room2", "One Match") + expect = "One Match(#1#7, loc):\n " +\ + "Char2(#7) evennia.objects.objects.DefaultCharacter (location: Room(#1))" + self.call(building.CmdFind(), "Char2", expect, cmdstring="locate") + self.call(building.CmdFind(), "Char2", expect, cmdstring="@locate") + self.call(building.CmdFind(), "/loc Char2", expect, cmdstring="find") + self.call(building.CmdFind(), "Char2", "One Match", cmdstring="@find") def test_script(self): self.call(building.CmdScript(), "Obj = scripts.Script", "Script scripts.Script successfully added")