Remove get_ansiname() by condensing functionality into get_name(). Removed session debug statements I had in for testing.
This commit is contained in:
parent
a73a3523af
commit
7012960a70
4 changed files with 68 additions and 49 deletions
|
|
@ -182,32 +182,30 @@ class Object(models.Model):
|
||||||
|
|
||||||
def get_user_account(self):
|
def get_user_account(self):
|
||||||
"""
|
"""
|
||||||
Returns the player object's account object.
|
Returns the player object's account object (User object).
|
||||||
"""
|
"""
|
||||||
if not self.is_player():
|
if not self.is_player():
|
||||||
return False
|
return False
|
||||||
return User.objects.get(id=self.id)
|
return User.objects.get(id=self.id)
|
||||||
|
|
||||||
def get_name(self, fullname=False):
|
def get_name(self, fullname=False, show_dbref=True, no_ansi=False):
|
||||||
"""
|
"""
|
||||||
Returns an object's name.
|
Returns an object's name.
|
||||||
"""
|
"""
|
||||||
|
if not no_ansi and self.ansi_name:
|
||||||
|
name_string = self.ansi_name
|
||||||
|
else:
|
||||||
|
name_string = self.name
|
||||||
|
|
||||||
|
if show_dbref:
|
||||||
|
dbref_string = "(#%s%s)" % (self.id, self.flag_string())
|
||||||
|
else:
|
||||||
|
dbref_string = ""
|
||||||
|
|
||||||
if fullname:
|
if fullname:
|
||||||
return "%s(#%s%s)" % (ansi.parse_ansi(self.name, strip_ansi=True),self.id, self.flag_string())
|
return "%s%s" % (ansi.parse_ansi(name_string, strip_ansi=no_ansi), dbref_string)
|
||||||
else:
|
else:
|
||||||
return "%s(#%s%s)" % (ansi.parse_ansi(self.name.split(';')[0], strip_ansi=True), self.id, self.flag_string())
|
return "%s%s" % (ansi.parse_ansi(name_string.split(';')[0], strip_ansi=no_ansi), dbref_string)
|
||||||
|
|
||||||
def get_ansiname(self, fullname=False):
|
|
||||||
"""
|
|
||||||
Returns an object's ANSI'd name.
|
|
||||||
"""
|
|
||||||
if self.ansi_name:
|
|
||||||
if fullname:
|
|
||||||
return "%s(#%s%s)" % (ansi.parse_ansi(self.ansi_name), self.id, self.flag_string())
|
|
||||||
else:
|
|
||||||
return "%s(#%s%s)" % (ansi.parse_ansi(self.ansi_name.split(';')[0]), self.id, self.flag_string())
|
|
||||||
else:
|
|
||||||
return self.get_name()
|
|
||||||
|
|
||||||
def set_description(self, new_desc):
|
def set_description(self, new_desc):
|
||||||
"""
|
"""
|
||||||
|
|
@ -501,13 +499,13 @@ class Object(models.Model):
|
||||||
"""
|
"""
|
||||||
if not quiet:
|
if not quiet:
|
||||||
if self.get_location():
|
if self.get_location():
|
||||||
self.get_location().emit_to_contents("%s has left." % (self.get_ansiname(),), exclude=self)
|
self.get_location().emit_to_contents("%s has left." % (self.get_name(),), exclude=self)
|
||||||
|
|
||||||
self.location = target
|
self.location = target
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
if not quiet:
|
if not quiet:
|
||||||
self.get_location().emit_to_contents("%s has arrived." % (self.get_ansiname(),), exclude=self)
|
self.get_location().emit_to_contents("%s has arrived." % (self.get_name(),), exclude=self)
|
||||||
|
|
||||||
def dbref_match(self, oname):
|
def dbref_match(self, oname):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ def cmd_inventory(cdat):
|
||||||
session.msg("You are carrying:")
|
session.msg("You are carrying:")
|
||||||
|
|
||||||
for item in pobject.get_contents():
|
for item in pobject.get_contents():
|
||||||
session.msg(" %s" % (item.get_ansiname(),))
|
session.msg(" %s" % (item.get_name(),))
|
||||||
|
|
||||||
money = int(pobject.get_attribute_value("MONEY", default=0))
|
money = int(pobject.get_attribute_value("MONEY", default=0))
|
||||||
if money == 1:
|
if money == 1:
|
||||||
|
|
@ -53,7 +53,7 @@ def cmd_look(cdat):
|
||||||
if len(results) > 1:
|
if len(results) > 1:
|
||||||
session.msg("More than one match found (please narrow target):")
|
session.msg("More than one match found (please narrow target):")
|
||||||
for result in results:
|
for result in results:
|
||||||
session.msg(" %s" % (result.get_ansiname(),))
|
session.msg(" %s" % (result.get_name(),))
|
||||||
return
|
return
|
||||||
elif len(results) == 0:
|
elif len(results) == 0:
|
||||||
session.msg("I don't see that here.")
|
session.msg("I don't see that here.")
|
||||||
|
|
@ -62,7 +62,7 @@ def cmd_look(cdat):
|
||||||
target_obj = results[0]
|
target_obj = results[0]
|
||||||
|
|
||||||
retval = "%s\r\n%s" % (
|
retval = "%s\r\n%s" % (
|
||||||
target_obj.get_ansiname(),
|
target_obj.get_name(),
|
||||||
target_obj.get_description(),
|
target_obj.get_description(),
|
||||||
)
|
)
|
||||||
session.msg(retval)
|
session.msg(retval)
|
||||||
|
|
@ -83,15 +83,15 @@ def cmd_look(cdat):
|
||||||
if con_players:
|
if con_players:
|
||||||
session.msg("%sPlayers:%s" % (ansi.ansi["hilite"], ansi.ansi["normal"],))
|
session.msg("%sPlayers:%s" % (ansi.ansi["hilite"], ansi.ansi["normal"],))
|
||||||
for player in con_players:
|
for player in con_players:
|
||||||
session.msg('%s' %(player.get_ansiname(),))
|
session.msg('%s' %(player.get_name(),))
|
||||||
if con_things:
|
if con_things:
|
||||||
session.msg("%sContents:%s" % (ansi.ansi["hilite"], ansi.ansi["normal"],))
|
session.msg("%sContents:%s" % (ansi.ansi["hilite"], ansi.ansi["normal"],))
|
||||||
for thing in con_things:
|
for thing in con_things:
|
||||||
session.msg('%s' %(thing.get_ansiname(),))
|
session.msg('%s' %(thing.get_name(),))
|
||||||
if con_exits:
|
if con_exits:
|
||||||
session.msg("%sExits:%s" % (ansi.ansi["hilite"], ansi.ansi["normal"],))
|
session.msg("%sExits:%s" % (ansi.ansi["hilite"], ansi.ansi["normal"],))
|
||||||
for exit in con_exits:
|
for exit in con_exits:
|
||||||
session.msg('%s' %(exit.get_ansiname(),))
|
session.msg('%s' %(exit.get_name(),))
|
||||||
|
|
||||||
def cmd_get(cdat):
|
def cmd_get(cdat):
|
||||||
"""
|
"""
|
||||||
|
|
@ -111,7 +111,7 @@ def cmd_get(cdat):
|
||||||
if len(results) > 1:
|
if len(results) > 1:
|
||||||
session.msg("More than one match found (please narrow target):")
|
session.msg("More than one match found (please narrow target):")
|
||||||
for result in results:
|
for result in results:
|
||||||
session.msg(" %s" % (result.get_ansiname(),))
|
session.msg(" %s" % (result.get_name(),))
|
||||||
return
|
return
|
||||||
elif len(results) == 0:
|
elif len(results) == 0:
|
||||||
session.msg("I don't see that here.")
|
session.msg("I don't see that here.")
|
||||||
|
|
@ -133,8 +133,8 @@ def cmd_get(cdat):
|
||||||
return
|
return
|
||||||
|
|
||||||
target_obj.move_to(pobject, quiet=True)
|
target_obj.move_to(pobject, quiet=True)
|
||||||
session.msg("You pick up %s." % (target_obj.get_ansiname(),))
|
session.msg("You pick up %s." % (target_obj.get_name(),))
|
||||||
pobject.get_location().emit_to_contents("%s picks up %s." % (pobject.get_ansiname(), target_obj.get_ansiname()), exclude=pobject)
|
pobject.get_location().emit_to_contents("%s picks up %s." % (pobject.get_name(), target_obj.get_name()), exclude=pobject)
|
||||||
|
|
||||||
def cmd_drop(cdat):
|
def cmd_drop(cdat):
|
||||||
"""
|
"""
|
||||||
|
|
@ -154,7 +154,7 @@ def cmd_drop(cdat):
|
||||||
if len(results) > 1:
|
if len(results) > 1:
|
||||||
session.msg("More than one match found (please narrow target):")
|
session.msg("More than one match found (please narrow target):")
|
||||||
for result in results:
|
for result in results:
|
||||||
session.msg(" %s" % (result.get_ansiname(),))
|
session.msg(" %s" % (result.get_name(),))
|
||||||
return
|
return
|
||||||
elif len(results) == 0:
|
elif len(results) == 0:
|
||||||
session.msg("You don't appear to be carrying that.")
|
session.msg("You don't appear to be carrying that.")
|
||||||
|
|
@ -168,8 +168,8 @@ def cmd_drop(cdat):
|
||||||
return
|
return
|
||||||
|
|
||||||
target_obj.move_to(pobject.get_location(), quiet=True)
|
target_obj.move_to(pobject.get_location(), quiet=True)
|
||||||
session.msg("You drop %s." % (target_obj.get_ansiname(),))
|
session.msg("You drop %s." % (target_obj.get_name(),))
|
||||||
pobject.get_location().emit_to_contents("%s drops %s." % (pobject.get_ansiname(), target_obj.get_ansiname()), exclude=pobject)
|
pobject.get_location().emit_to_contents("%s drops %s." % (pobject.get_name(), target_obj.get_name()), exclude=pobject)
|
||||||
|
|
||||||
def cmd_examine(cdat):
|
def cmd_examine(cdat):
|
||||||
"""
|
"""
|
||||||
|
|
@ -187,7 +187,7 @@ def cmd_examine(cdat):
|
||||||
if len(results) > 1:
|
if len(results) > 1:
|
||||||
session.msg("More than one match found (please narrow target):")
|
session.msg("More than one match found (please narrow target):")
|
||||||
for result in results:
|
for result in results:
|
||||||
session.msg(" %s" % (result.get_ansiname(),))
|
session.msg(" %s" % (result.get_name(),))
|
||||||
return
|
return
|
||||||
elif len(results) == 0:
|
elif len(results) == 0:
|
||||||
session.msg("I don't see that here.")
|
session.msg("I don't see that here.")
|
||||||
|
|
@ -195,7 +195,7 @@ def cmd_examine(cdat):
|
||||||
else:
|
else:
|
||||||
target_obj = results[0]
|
target_obj = results[0]
|
||||||
session.msg("%s\r\n%s" % (
|
session.msg("%s\r\n%s" % (
|
||||||
target_obj.get_ansiname(fullname=True),
|
target_obj.get_name(fullname=True),
|
||||||
target_obj.get_description(no_parsing=True),
|
target_obj.get_description(no_parsing=True),
|
||||||
))
|
))
|
||||||
session.msg("Type: %s Flags: %s" % (target_obj.get_type(), target_obj.get_flags()))
|
session.msg("Type: %s Flags: %s" % (target_obj.get_type(), target_obj.get_flags()))
|
||||||
|
|
@ -220,14 +220,14 @@ def cmd_examine(cdat):
|
||||||
if con_players or con_things:
|
if con_players or con_things:
|
||||||
session.msg("%sContents:%s" % (ansi.ansi["hilite"], ansi.ansi["normal"],))
|
session.msg("%sContents:%s" % (ansi.ansi["hilite"], ansi.ansi["normal"],))
|
||||||
for player in con_players:
|
for player in con_players:
|
||||||
session.msg('%s' % (player.get_ansiname(fullname=True),))
|
session.msg('%s' % (player.get_name(fullname=True),))
|
||||||
for thing in con_things:
|
for thing in con_things:
|
||||||
session.msg('%s' % (thing.get_ansiname(fullname=True),))
|
session.msg('%s' % (thing.get_name(fullname=True),))
|
||||||
|
|
||||||
if con_exits:
|
if con_exits:
|
||||||
session.msg("%sExits:%s" % (ansi.ansi["hilite"], ansi.ansi["normal"],))
|
session.msg("%sExits:%s" % (ansi.ansi["hilite"], ansi.ansi["normal"],))
|
||||||
for exit in con_exits:
|
for exit in con_exits:
|
||||||
session.msg('%s' %(exit.get_ansiname(fullname=True),))
|
session.msg('%s' %(exit.get_name(fullname=True),))
|
||||||
|
|
||||||
if not target_obj.is_room():
|
if not target_obj.is_room():
|
||||||
if target_obj.is_exit():
|
if target_obj.is_exit():
|
||||||
|
|
@ -285,7 +285,7 @@ def cmd_say(cdat):
|
||||||
"""
|
"""
|
||||||
session = cdat['session']
|
session = cdat['session']
|
||||||
|
|
||||||
if not functions_general.cmd_check_num_args(session, cdat['uinput']['splitted'], 1, errortext="Say What?"):
|
if not functions_general.cmd_check_num_args(session, cdat['uinput']['splitted'], 1, errortext="Say what?"):
|
||||||
return
|
return
|
||||||
|
|
||||||
session_list = session_mgr.get_session_list()
|
session_list = session_mgr.get_session_list()
|
||||||
|
|
@ -296,9 +296,27 @@ def cmd_say(cdat):
|
||||||
|
|
||||||
retval = "You say, '%s'" % (speech,)
|
retval = "You say, '%s'" % (speech,)
|
||||||
for player in players_present:
|
for player in players_present:
|
||||||
player.msg("%s says, '%s'" % (pobject.get_name(), speech,))
|
player.msg("%s says, '%s'" % (pobject.get_name(show_dbref=False), speech,))
|
||||||
|
|
||||||
session.msg(retval)
|
session.msg(retval)
|
||||||
|
|
||||||
|
def cmd_pose(cdat):
|
||||||
|
"""
|
||||||
|
Pose/emote command.
|
||||||
|
"""
|
||||||
|
session = cdat['session']
|
||||||
|
|
||||||
|
if not functions_general.cmd_check_num_args(session, cdat['uinput']['splitted'], 1, errortext="Do what?"):
|
||||||
|
return
|
||||||
|
|
||||||
|
session_list = session_mgr.get_session_list()
|
||||||
|
pobject = session.get_pobject()
|
||||||
|
speech = ' '.join(cdat['uinput']['splitted'][1:])
|
||||||
|
|
||||||
|
players_present = [player for player in session_list if player.get_pobject().get_location() == session.get_pobject().get_location()]
|
||||||
|
|
||||||
|
for player in players_present:
|
||||||
|
player.msg("%s %s" % (pobject.get_name(show_dbref=False), speech))
|
||||||
|
|
||||||
def cmd_help(cdat):
|
def cmd_help(cdat):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ def cmd_destroy(cdat):
|
||||||
if len(results) > 1:
|
if len(results) > 1:
|
||||||
session.msg("More than one match found (please narrow target):")
|
session.msg("More than one match found (please narrow target):")
|
||||||
for result in results:
|
for result in results:
|
||||||
session.msg(" %s" % (result.get_ansiname(),))
|
session.msg(" %s" % (result.get_name(),))
|
||||||
return
|
return
|
||||||
elif len(results) == 0:
|
elif len(results) == 0:
|
||||||
session.msg("I don't see that here.")
|
session.msg("I don't see that here.")
|
||||||
|
|
@ -119,7 +119,7 @@ def cmd_description(cdat):
|
||||||
if len(results) > 1:
|
if len(results) > 1:
|
||||||
session.msg("More than one match found (please narrow target):")
|
session.msg("More than one match found (please narrow target):")
|
||||||
for result in results:
|
for result in results:
|
||||||
session.msg(" %s" % (result.get_ansiname(),))
|
session.msg(" %s" % (result.get_name(),))
|
||||||
return
|
return
|
||||||
elif len(results) == 0:
|
elif len(results) == 0:
|
||||||
session.msg("I don't see that here.")
|
session.msg("I don't see that here.")
|
||||||
|
|
@ -154,7 +154,7 @@ def cmd_newpassword(cdat):
|
||||||
if len(results) > 1:
|
if len(results) > 1:
|
||||||
session.msg("More than one match found (please narrow target):")
|
session.msg("More than one match found (please narrow target):")
|
||||||
for result in results:
|
for result in results:
|
||||||
session.msg(" %s" % (result.get_ansiname(),))
|
session.msg(" %s" % (result.get_name(),))
|
||||||
elif len(results) == 0:
|
elif len(results) == 0:
|
||||||
session.msg("I don't see that here.")
|
session.msg("I don't see that here.")
|
||||||
elif not pobject.controls_other(results[0]):
|
elif not pobject.controls_other(results[0]):
|
||||||
|
|
@ -219,7 +219,7 @@ def cmd_name(cdat):
|
||||||
if len(results) > 1:
|
if len(results) > 1:
|
||||||
session.msg("More than one match found (please narrow target):")
|
session.msg("More than one match found (please narrow target):")
|
||||||
for result in results:
|
for result in results:
|
||||||
session.msg(" %s" % (result.get_ansiname(),))
|
session.msg(" %s" % (result.get_name(),))
|
||||||
return
|
return
|
||||||
elif len(results) == 0:
|
elif len(results) == 0:
|
||||||
session.msg("I don't see that here.")
|
session.msg("I don't see that here.")
|
||||||
|
|
@ -435,7 +435,7 @@ def cmd_unlink(cdat):
|
||||||
if len(results) > 1:
|
if len(results) > 1:
|
||||||
session.msg("More than one match found (please narrow target):")
|
session.msg("More than one match found (please narrow target):")
|
||||||
for result in results:
|
for result in results:
|
||||||
session.msg(" %s" % (result.get_ansiname(),))
|
session.msg(" %s" % (result.get_name(),))
|
||||||
return
|
return
|
||||||
elif len(results) == 0:
|
elif len(results) == 0:
|
||||||
session.msg("I don't see that here.")
|
session.msg("I don't see that here.")
|
||||||
|
|
@ -504,7 +504,7 @@ def cmd_teleport(cdat):
|
||||||
if len(results) > 1:
|
if len(results) > 1:
|
||||||
session.msg("More than one match found (please narrow target):")
|
session.msg("More than one match found (please narrow target):")
|
||||||
for result in results:
|
for result in results:
|
||||||
session.msg(" %s" % (result.get_ansiname(),))
|
session.msg(" %s" % (result.get_name(),))
|
||||||
elif len(results) == 0:
|
elif len(results) == 0:
|
||||||
session.msg("I don't see that here.")
|
session.msg("I don't see that here.")
|
||||||
return
|
return
|
||||||
|
|
@ -609,7 +609,7 @@ def cmd_find(cdat):
|
||||||
if len(results) > 0:
|
if len(results) > 0:
|
||||||
session.msg("Name matches for: %s" % (searchstring,))
|
session.msg("Name matches for: %s" % (searchstring,))
|
||||||
for result in results:
|
for result in results:
|
||||||
session.msg(" %s" % (result.get_ansiname(fullname=True),))
|
session.msg(" %s" % (result.get_name(fullname=True),))
|
||||||
session.msg("%d matches returned." % (len(results),))
|
session.msg("%d matches returned." % (len(results),))
|
||||||
else:
|
else:
|
||||||
session.msg("No name matches found for: %s" % (searchstring,))
|
session.msg("No name matches found for: %s" % (searchstring,))
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,14 @@ def check_all_sessions():
|
||||||
"""
|
"""
|
||||||
Check all currently connected sessions and see if any are dead.
|
Check all currently connected sessions and see if any are dead.
|
||||||
"""
|
"""
|
||||||
for sess in get_session_list():
|
pass
|
||||||
if not sess.writable() or not sess.readable():
|
#for sess in get_session_list():
|
||||||
print 'Problematic Session:'
|
## This doesn't seem to provide an accurate indication of timed out
|
||||||
print 'Readable ', sess.readable()
|
## sessions.
|
||||||
print 'Writable ', sess.writable()
|
#if not sess.writable() or not sess.readable():
|
||||||
|
# print 'Problematic Session:'
|
||||||
|
# print 'Readable ', sess.readable()
|
||||||
|
# print 'Writable ', sess.writable()
|
||||||
|
|
||||||
|
|
||||||
def remove_session(session):
|
def remove_session(session):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue