Added all functionality for all 3 MULTISESSION_MODEs.
This commit is contained in:
parent
b5ccad21c5
commit
85d4250f1d
3 changed files with 35 additions and 20 deletions
|
|
@ -9,7 +9,9 @@ from src.utils import utils, search, create
|
||||||
from src.objects.models import ObjectNick as Nick
|
from src.objects.models import ObjectNick as Nick
|
||||||
from src.commands.default.muxcommand import MuxCommand, MuxCommandOOC
|
from src.commands.default.muxcommand import MuxCommand, MuxCommandOOC
|
||||||
|
|
||||||
from settings import MAX_NR_CHARACTERS
|
from settings import MAX_NR_CHARACTERS, MULTISESSION_MODE
|
||||||
|
# force max nr chars to 1 if mode is 0 or 1
|
||||||
|
MAX_NR_CHARACTERS = MULTISESSION_MODE < 2 and 1 or MAX_NR_CHARACTERS
|
||||||
|
|
||||||
# limit symbol import for API
|
# limit symbol import for API
|
||||||
__all__ = ("CmdHome", "CmdLook", "CmdPassword", "CmdNick",
|
__all__ = ("CmdHome", "CmdLook", "CmdPassword", "CmdNick",
|
||||||
|
|
@ -822,7 +824,7 @@ class CmdOOCLook(MuxCommandOOC, CmdLook):
|
||||||
sessions = player.get_all_sessions()
|
sessions = player.get_all_sessions()
|
||||||
|
|
||||||
sessidstr = sessid and " (session id %i)" % sessid or ""
|
sessidstr = sessid and " (session id %i)" % sessid or ""
|
||||||
string = "You are logged in as {g%s{n%s." % (player.key, sessidstr)
|
string = "%sYou are logged in as {g%s{n%s." % (" "*10,player.key, sessidstr)
|
||||||
|
|
||||||
string += "\n\nSession(s) connected:"
|
string += "\n\nSession(s) connected:"
|
||||||
for sess in sessions:
|
for sess in sessions:
|
||||||
|
|
@ -830,7 +832,8 @@ class CmdOOCLook(MuxCommandOOC, CmdLook):
|
||||||
string += "\n %s %s" % (sessid == csessid and "{w%i{n" % csessid or csessid, sess.address)
|
string += "\n %s %s" % (sessid == csessid and "{w%i{n" % csessid or csessid, sess.address)
|
||||||
string += "\n\nUse {w@ic <character>{n to enter the game, {w@occ{n to get back here."
|
string += "\n\nUse {w@ic <character>{n to enter the game, {w@occ{n to get back here."
|
||||||
if characters:
|
if characters:
|
||||||
string += "\n\nAvailable character%s:" % (len(characters) > 1 and "s" or "")
|
string += "\n\nAvailable character%s%s:" % (len(characters) > 1 and "s" or "",
|
||||||
|
MAX_NR_CHARACTERS > 1 and " (out of a maximum of %i)" % MAX_NR_CHARACTERS or "")
|
||||||
for char in characters:
|
for char in characters:
|
||||||
csessid = char.sessid
|
csessid = char.sessid
|
||||||
if csessid:
|
if csessid:
|
||||||
|
|
@ -854,6 +857,11 @@ class CmdOOCLook(MuxCommandOOC, CmdLook):
|
||||||
def func(self):
|
def func(self):
|
||||||
"implement the ooc look command"
|
"implement the ooc look command"
|
||||||
|
|
||||||
|
if MULTISESSION_MODE < 2:
|
||||||
|
# only one character allowed
|
||||||
|
string = "You are out-of-character (OOC).\nUse {w@ic{n to get back into the game."
|
||||||
|
self.msg(string)
|
||||||
|
return
|
||||||
if utils.inherits_from(self.caller, "src.objects.objects.Object"):
|
if utils.inherits_from(self.caller, "src.objects.objects.Object"):
|
||||||
# An object of some type is calling. Use default look instead.
|
# An object of some type is calling. Use default look instead.
|
||||||
super(CmdOOCLook, self).func()
|
super(CmdOOCLook, self).func()
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ from src.commands.cmdhandler import CMD_LOGINSTART
|
||||||
# limit symbol import for API
|
# limit symbol import for API
|
||||||
__all__ = ("CmdUnconnectedConnect", "CmdUnconnectedCreate", "CmdUnconnectedQuit", "CmdUnconnectedLook", "CmdUnconnectedHelp")
|
__all__ = ("CmdUnconnectedConnect", "CmdUnconnectedCreate", "CmdUnconnectedQuit", "CmdUnconnectedLook", "CmdUnconnectedHelp")
|
||||||
|
|
||||||
|
MULTISESSION_MODE = settings.MULTISESSION_MODE
|
||||||
CONNECTION_SCREEN_MODULE = settings.CONNECTION_SCREEN_MODULE
|
CONNECTION_SCREEN_MODULE = settings.CONNECTION_SCREEN_MODULE
|
||||||
CONNECTION_SCREEN = ""
|
CONNECTION_SCREEN = ""
|
||||||
try:
|
try:
|
||||||
|
|
@ -164,12 +165,6 @@ class CmdUnconnectedCreate(MuxCommand):
|
||||||
new_player = create.create_player(playername, None, password,
|
new_player = create.create_player(playername, None, password,
|
||||||
permissions=permissions)
|
permissions=permissions)
|
||||||
|
|
||||||
# create character to go with player
|
|
||||||
new_character = create.create_object(typeclass, key=playername,
|
|
||||||
location=default_home, home=default_home,
|
|
||||||
permissions=permissions)
|
|
||||||
# set list
|
|
||||||
new_player.db._playable_characters.append(new_character)
|
|
||||||
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
session.msg("There was an error creating the default Player/Character:\n%s\n If this problem persists, contact an admin." % e)
|
session.msg("There was an error creating the default Player/Character:\n%s\n If this problem persists, contact an admin." % e)
|
||||||
|
|
@ -187,14 +182,24 @@ class CmdUnconnectedCreate(MuxCommand):
|
||||||
string = "New player '%s' could not connect to public channel!" % new_player.key
|
string = "New player '%s' could not connect to public channel!" % new_player.key
|
||||||
logger.log_errmsg(string)
|
logger.log_errmsg(string)
|
||||||
|
|
||||||
# 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 MULTISESSION_MODE < 2:
|
||||||
|
# if we only allow one character, create one with the same name as Player
|
||||||
|
# (in mode 2, the character must be created manually once logging in)
|
||||||
|
new_character = create.create_object(typeclass, key=playername,
|
||||||
|
location=default_home, home=default_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."
|
||||||
|
|
||||||
# If no description is set, set a default description
|
|
||||||
if not new_character.db.desc:
|
|
||||||
new_character.db.desc = "This is a Player."
|
|
||||||
|
|
||||||
# tell the caller everything went well.
|
# tell the caller everything went well.
|
||||||
string = "A new account '%s' was created. Welcome!"
|
string = "A new account '%s' was created. Welcome!"
|
||||||
|
|
|
||||||
|
|
@ -286,14 +286,16 @@ TIME_MONTH_PER_YEAR = 12
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
# Different Multisession modes allow a player (=account) to connect to the game simultaneously
|
# Different Multisession modes allow a player (=account) to connect to the game simultaneously
|
||||||
# with multiple clients (=sessions) in various ways according to the set mode:
|
# with multiple clients (=sessions). In modes 0,1 there is only one character created to the same
|
||||||
|
# name as the account at first login. In modes 1,2 no default character will be created and
|
||||||
|
# the MAX_NR_CHARACTERS value (below) defines how many characters are allowed.
|
||||||
# 0 - single session, one player, one character, when a new session is connected, the old one is disconnected
|
# 0 - single session, one player, one character, when a new session is connected, the old one is disconnected
|
||||||
# 1 - multiple sessions, one player, one character, each session getting the same data
|
# 1 - multiple sessions, one player, one character, each session getting the same data
|
||||||
# 2 - multiple sessions, one player, each session controlling different characters
|
# 2 - multiple sessions, one player, many characters, each session getting data from different characters
|
||||||
MULTISESSION_MODE = 0
|
MULTISESSION_MODE = 0
|
||||||
# The maximum number of characters allowed for MULTISESSION_MODE 1 or 2. This is checked
|
# The maximum number of characters allowed for MULTISESSION_MODE 2. This is checked
|
||||||
# by the default char-creation commands in this mode. Forced to 1 for MULTISESSION_MODE 0.
|
# by the default ooc char-creation command. Forced to 1 for MULTISESSION_MODE 0 and 1.
|
||||||
MAX_NR_CHARACTERS = 2
|
MAX_NR_CHARACTERS = 1
|
||||||
# The access hiearchy, in climbing order. A higher permission in the
|
# The access hiearchy, in climbing order. A higher permission in the
|
||||||
# hierarchy includes access of all levels below it. Used by the perm()/pperm() lock functions.
|
# hierarchy includes access of all levels below it. Used by the perm()/pperm() lock functions.
|
||||||
PERMISSION_HIERARCHY = ("Players","PlayerHelpers","Builders", "Wizards", "Immortals")
|
PERMISSION_HIERARCHY = ("Players","PlayerHelpers","Builders", "Wizards", "Immortals")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue