mirror of
https://github.com/evennia/evennia.git
synced 2026-03-28 02:36:32 +01:00
MUX-style @chown implemented.
This commit is contained in:
parent
462628ab55
commit
1a3942edac
3 changed files with 61 additions and 0 deletions
|
|
@ -75,6 +75,7 @@ GLOBAL_CMD_TABLE.add_command("@ccreate", commands.comsys.cmd_ccreate,
|
|||
priv_tuple=("objects.add_commchannel")),
|
||||
GLOBAL_CMD_TABLE.add_command("@cdestroy", commands.comsys.cmd_cdestroy,
|
||||
priv_tuple=("objects.delete_commchannel")),
|
||||
GLOBAL_CMD_TABLE.add_command("@chown", commands.objmanip.cmd_chown),
|
||||
GLOBAL_CMD_TABLE.add_command("@cemit", commands.comsys.cmd_cemit),
|
||||
GLOBAL_CMD_TABLE.add_command("@clist", commands.comsys.cmd_clist),
|
||||
GLOBAL_CMD_TABLE.add_command("@create", commands.objmanip.cmd_create,
|
||||
|
|
|
|||
|
|
@ -368,6 +368,59 @@ def cmd_open(command):
|
|||
new_object = Object.objects.create_object(odat)
|
||||
|
||||
session.msg("You open an unlinked exit - %s" % (new_object,))
|
||||
|
||||
def cmd_chown(command):
|
||||
"""
|
||||
Changes the ownership of an object. The new owner specified must be a
|
||||
player object.
|
||||
|
||||
Forms:
|
||||
@chown <Object>=<NewOwner>
|
||||
"""
|
||||
session = command.session
|
||||
pobject = session.get_pobject()
|
||||
|
||||
if not command.command_argument:
|
||||
session.msg("Change the ownership of what?")
|
||||
return
|
||||
|
||||
eq_args = command.command_argument.split('=', 1)
|
||||
target_name = eq_args[0]
|
||||
owner_name = eq_args[1]
|
||||
|
||||
if len(target_name) == 0:
|
||||
session.msg("Change the ownership of what?")
|
||||
return
|
||||
|
||||
if len(eq_args) > 1:
|
||||
target_obj = Object.objects.standard_plr_objsearch(session, target_name)
|
||||
# Use standard_plr_objsearch to handle duplicate/nonexistant results.
|
||||
if not target_obj:
|
||||
return
|
||||
|
||||
if not pobject.controls_other(target_obj):
|
||||
session.msg(defines_global.NOCONTROL_MSG)
|
||||
return
|
||||
|
||||
owner_obj = Object.objects.standard_plr_objsearch(session, owner_name)
|
||||
# Use standard_plr_objsearch to handle duplicate/nonexistant results.
|
||||
if not owner_obj:
|
||||
return
|
||||
|
||||
if not owner_obj.is_player():
|
||||
session.msg("Only players may own objects.")
|
||||
return
|
||||
if target_obj.is_player():
|
||||
session.msg("You may not change the ownership of player objects.")
|
||||
return
|
||||
|
||||
target_obj.set_owner(owner_obj)
|
||||
session.msg("%s now owns %s." % (owner_obj, target_obj))
|
||||
|
||||
else:
|
||||
# We haven't provided a target.
|
||||
session.msg("Who should be the new owner of the object?")
|
||||
return
|
||||
|
||||
def cmd_link(command):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -304,6 +304,13 @@ class Object(models.Model):
|
|||
"""
|
||||
self.home = new_home
|
||||
self.save()
|
||||
|
||||
def set_owner(self, new_owner):
|
||||
"""
|
||||
Sets an object's owner.
|
||||
"""
|
||||
self.owner = new_owner
|
||||
self.save()
|
||||
|
||||
def set_name(self, new_name):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue