/charcurse, /uncharcurse and /charids commands.

Curses a player to only be able to use the given characters.
This commit is contained in:
Cerapter 2018-09-03 19:15:59 +02:00
parent becf58dd4f
commit c395b9132e
3 changed files with 79 additions and 1 deletions

View File

@ -358,6 +358,9 @@ class AOProtocol(asyncio.Protocol):
if self.client.area.is_iniswap(self.client, pre, anim, folder) and folder != self.client.get_char_name():
self.client.send_host_message("Iniswap is blocked in this area")
return
if len(self.client.charcurse) > 0 and folder != self.client.get_char_name():
self.client.send_host_message("You may not iniswap while you are charcursed!")
return
if not self.client.area.blankposting_allowed and text == ' ':
self.client.send_host_message("Blankposting is forbidden in this area!")
return

View File

@ -48,6 +48,7 @@ class ClientManager:
self.evi_list = []
self.disemvowel = False
self.shaken = False
self.charcurse = []
self.muted_global = False
self.muted_adverts = False
self.is_muted = False
@ -119,6 +120,10 @@ class ClientManager:
def change_character(self, char_id, force=False):
if not self.server.is_valid_char_id(char_id):
raise ClientError('Invalid Character ID.')
if len(self.charcurse) > 0:
if not char_id in self.charcurse:
raise ClientError('Character not available.')
force = True
if not self.area.is_char_available(char_id):
if force:
for client in self.area.clients:
@ -312,7 +317,10 @@ class ClientManager:
self.send_done()
def get_available_char_list(self):
avail_char_ids = set(range(len(self.server.char_list))) - set([x.char_id for x in self.area.clients])
if len(self.charcurse) > 0:
avail_char_ids = set(range(len(self.server.char_list))) and set(self.charcurse)
else:
avail_char_ids = set(range(len(self.server.char_list))) - set([x.char_id for x in self.area.clients])
char_list = [-1] * len(self.server.char_list)
for x in avail_char_ids:
char_list[x] = 0

View File

@ -904,6 +904,73 @@ def ooc_cmd_unshake(client, arg):
else:
client.send_host_message('No targets found.')
def ooc_cmd_charcurse(client, arg):
if not client.is_mod:
raise ClientError('You must be authorized to do that.')
elif len(arg) == 0:
raise ArgumentError('You must specify a target (an ID) and at least one character ID. Consult /charids for the character IDs.')
elif len(arg) == 1:
raise ArgumentError('You must specific at least one character ID. Consult /charids for the character IDs.')
try:
targets = client.server.client_manager.get_targets(client, TargetType.ID, int(arg[0]), False)
except:
raise ArgumentError('You must specify a valid target! Make sure it is a valid ID.')
if targets:
for c in targets:
log_msg = ' ' + str(c.get_ip()) + ' to'
part_msg = ' [' + str(c.id) + '] to'
args = arg[1:].split()
for raw_cid in args:
try:
cid = int(raw_cid)
c.charcurse.append(cid)
part_msg += ' ' + str(client.server.char_list[cid]) + ','
log_msg += ' ' + str(client.server.char_list[cid]) + ','
except:
ArgumentError('' + str(raw_cid) + ' does not look like a valid character ID.')
part_msg = part_msg[:-1]
part_msg += '.'
log_msg = log_msg[:-1]
log_msg += '.'
c.char_select()
logger.log_server('Charcursing' + log_msg, client)
logger.log_mod('Charcursing' + log_msg, client)
client.send_host_message('Charcursed' + part_msg)
else:
client.send_host_message('No targets found.')
def ooc_cmd_uncharcurse(client, arg):
if not client.is_mod:
raise ClientError('You must be authorized to do that.')
elif len(arg) == 0:
raise ArgumentError('You must specify a target (an ID).')
try:
targets = client.server.client_manager.get_targets(client, TargetType.ID, int(arg[0]), False)
except:
raise ArgumentError('You must specify a valid target! Make sure it is a valid ID.')
if targets:
for c in targets:
if len(c.charcurse) > 0:
c.charcurse = []
logger.log_server('Uncharcursing {}.'.format(c.get_ip()), client)
logger.log_mod('Uncharcursing {}.'.format(c.get_ip()), client)
client.send_host_message('Uncharcursed [{}].'.format(c.id))
c.char_select()
else:
client.send_host_message('[{}] is not charcursed.'.format(c.id))
else:
client.send_host_message('No targets found.')
def ooc_cmd_charids(client, arg):
if not client.is_mod:
raise ClientError('You must be authorized to do that.')
if len(arg) != 0:
raise ArgumentError("This command doesn't take any arguments")
msg = 'Here is a list of all available characters on the server:'
for c in range(0, len(client.server.char_list)):
msg += '\n[' + str(c) + '] ' + client.server.char_list[c]
client.send_host_message(msg)
def ooc_cmd_blockdj(client, arg):
if not client.is_mod:
raise ClientError('You must be authorized to do that.')