changed cmdset_default -> cmdset_character and changed the class names to match. Added migrations to properly update default-set cmdset_stores to the new positions (objects created from custom types are not migrated, these should see errors and need to re-point their imports to the new defaults)
This commit is contained in:
parent
c152202082
commit
a6544f2848
15 changed files with 193 additions and 81 deletions
|
|
@ -1,18 +1,19 @@
|
|||
"""
|
||||
This module ties together all the commands of the default command
|
||||
set. Note that some commands, such as communication-commands are
|
||||
instead put in the OOC cmdset.
|
||||
This module ties together all the commands default Character objects have
|
||||
available (i.e. IC commands). Note that some commands, such as communication-commands are
|
||||
instead put on the player level, in the Player cmdset. Player commands remain
|
||||
available also to Characters.
|
||||
"""
|
||||
from src.commands.cmdset import CmdSet
|
||||
from src.commands.default import general, help, admin, system
|
||||
from src.commands.default import building
|
||||
from src.commands.default import batchprocess
|
||||
|
||||
class DefaultCmdSet(CmdSet):
|
||||
class CharacterCmdSet(CmdSet):
|
||||
"""
|
||||
Implements the default command set.
|
||||
"""
|
||||
key = "DefaultMUX"
|
||||
key = "DefaultCharacter"
|
||||
priority = 0
|
||||
|
||||
def at_cmdset_creation(self):
|
||||
|
|
@ -21,7 +22,6 @@ class DefaultCmdSet(CmdSet):
|
|||
# The general commands
|
||||
self.add(general.CmdLook())
|
||||
self.add(general.CmdHome())
|
||||
self.add(general.CmdWho())
|
||||
self.add(general.CmdInventory())
|
||||
self.add(general.CmdPose())
|
||||
self.add(general.CmdNick())
|
||||
|
|
@ -30,8 +30,6 @@ class DefaultCmdSet(CmdSet):
|
|||
self.add(general.CmdGive())
|
||||
self.add(general.CmdSay())
|
||||
self.add(general.CmdAccess())
|
||||
self.add(general.CmdColorTest())
|
||||
self.add(general.CmdSessions())
|
||||
|
||||
# The help system
|
||||
self.add(help.CmdHelp())
|
||||
|
|
@ -21,7 +21,7 @@ class PlayerCmdSet(CmdSet):
|
|||
def at_cmdset_creation(self):
|
||||
"Populates the cmdset"
|
||||
|
||||
# General commands
|
||||
# Player-specific commands
|
||||
self.add(player.CmdOOCLook())
|
||||
self.add(player.CmdIC())
|
||||
self.add(player.CmdOOC())
|
||||
|
|
@ -30,6 +30,7 @@ class PlayerCmdSet(CmdSet):
|
|||
self.add(player.CmdQuit())
|
||||
self.add(player.CmdPassword())
|
||||
self.add(player.CmdColorTest())
|
||||
self.add(player.CmdSessions())
|
||||
|
||||
# testing
|
||||
self.add(building.CmdExamine())
|
||||
|
|
|
|||
|
|
@ -377,47 +377,6 @@ class CmdSay(MuxCommand):
|
|||
speech)
|
||||
caller.location.msg_contents(emit_string,
|
||||
exclude=caller)
|
||||
class CmdSessions(MuxCommand):
|
||||
"""
|
||||
check connected session(s)
|
||||
|
||||
Usage:
|
||||
@sessions
|
||||
|
||||
Lists the sessions currently connected to your account.
|
||||
|
||||
"""
|
||||
key = "@sessions"
|
||||
locks = "cmd:all()"
|
||||
help_category = "General"
|
||||
|
||||
def func(self):
|
||||
"Implement function"
|
||||
|
||||
# make sure we work on the player, not on the character
|
||||
player = self.caller
|
||||
if hasattr(player, "player"):
|
||||
player = player.player
|
||||
|
||||
sessions = player.get_all_sessions()
|
||||
|
||||
table = [["sessid"], ["host"], ["character"], ["location"]]
|
||||
for sess in sorted(sessions, key=lambda x:x.sessid):
|
||||
sessid = sess.sessid
|
||||
char = player.get_puppet(sessid)
|
||||
table[0].append(str(sess.sessid))
|
||||
table[1].append(str(sess.address[0]))
|
||||
table[2].append(char and str(char) or "None")
|
||||
table[3].append(char and str(char.location) or "N/A")
|
||||
ftable = utils.format_table(table, 5)
|
||||
string = ""
|
||||
for ir, row in enumerate(ftable):
|
||||
if ir == 0:
|
||||
string += "\n" + "{w%s{n" % ("".join(row))
|
||||
else:
|
||||
string += "\n" + "".join(row)
|
||||
self.msg(string)
|
||||
|
||||
|
||||
class CmdPose(MuxCommand):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from src.utils import utils
|
|||
from src.commands.command import Command
|
||||
|
||||
# limit symbol import for API
|
||||
__all__ = ("MuxCommand",)
|
||||
__all__ = ("MuxCommand", "MuxPlayerCommand")
|
||||
|
||||
class MuxCommand(Command):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ from src.utils import utils, create, search
|
|||
|
||||
from settings import MAX_NR_CHARACTERS, MULTISESSION_MODE
|
||||
# limit symbol import for API
|
||||
__all__ = ("CmdOOCLook", "CmdIC", "CmdOOC", "CmdPassword", "CmdQuit", "CmdEncoding", "CmdWho", "CmdColorTest")
|
||||
__all__ = ("CmdOOCLook", "CmdIC", "CmdOOC", "CmdPassword", "CmdQuit",
|
||||
"CmdEncoding", "CmdSessions", "CmdWho", "CmdColorTest")
|
||||
|
||||
# force max nr chars to 1 if mode is 0 or 1
|
||||
MAX_NR_CHARACTERS = MULTISESSION_MODE < 2 and 1 or MAX_NR_CHARACTERS
|
||||
|
|
@ -281,6 +282,47 @@ class CmdOOC(MuxPlayerCommand):
|
|||
else:
|
||||
raise RuntimeError("Could not unpuppet!")
|
||||
|
||||
class CmdSessions(MuxPlayerCommand):
|
||||
"""
|
||||
check connected session(s)
|
||||
|
||||
Usage:
|
||||
@sessions
|
||||
|
||||
Lists the sessions currently connected to your account.
|
||||
|
||||
"""
|
||||
key = "@sessions"
|
||||
locks = "cmd:all()"
|
||||
help_category = "General"
|
||||
|
||||
def func(self):
|
||||
"Implement function"
|
||||
|
||||
# make sure we work on the player, not on the character
|
||||
player = self.caller
|
||||
if hasattr(player, "player"):
|
||||
player = player.player
|
||||
|
||||
sessions = player.get_all_sessions()
|
||||
|
||||
table = [["sessid"], ["host"], ["character"], ["location"]]
|
||||
for sess in sorted(sessions, key=lambda x:x.sessid):
|
||||
sessid = sess.sessid
|
||||
char = player.get_puppet(sessid)
|
||||
table[0].append(str(sess.sessid))
|
||||
table[1].append(str(sess.address[0]))
|
||||
table[2].append(char and str(char) or "None")
|
||||
table[3].append(char and str(char.location) or "N/A")
|
||||
ftable = utils.format_table(table, 5)
|
||||
string = ""
|
||||
for ir, row in enumerate(ftable):
|
||||
if ir == 0:
|
||||
string += "\n" + "{w%s{n" % ("".join(row))
|
||||
else:
|
||||
string += "\n" + "".join(row)
|
||||
self.msg(string)
|
||||
|
||||
class CmdWho(MuxPlayerCommand):
|
||||
"""
|
||||
who
|
||||
|
|
|
|||
|
|
@ -122,14 +122,14 @@ class TestGeneral(CommandTest):
|
|||
#self.call(general.CmdQuit(), "", "You are already home")
|
||||
|
||||
from src.commands.default import help
|
||||
from src.commands.default.cmdset_default import DefaultCmdSet
|
||||
from src.commands.default.cmdset_character import CharacterCmdSet
|
||||
class TestHelp(CommandTest):
|
||||
CID = 2
|
||||
def test_cmds(self):
|
||||
sep = "-"*78 + "\n"
|
||||
self.call(help.CmdHelp(), "", sep + " Command help entries", cmdset=DefaultCmdSet())
|
||||
self.call(help.CmdHelp(), "", sep + " Command help entries", cmdset=CharacterCmdSet())
|
||||
self.call(help.CmdSetHelp(), "testhelp, General = This is a test", "Topic 'testhelp' was successfully created.")
|
||||
self.call(help.CmdHelp(), "testhelp", sep + "Help topic for testhelp", cmdset=DefaultCmdSet())
|
||||
self.call(help.CmdHelp(), "testhelp", sep + "Help topic for testhelp", cmdset=CharacterCmdSet())
|
||||
|
||||
|
||||
from src.commands.default import system
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue