def exit(self, args): """Remove a character from the scene with a staging note Parameters ---------- args : list(str) List of strings with subcommands Returns ------- list(str) - the response messages string array """ messages = [] self.check_scene() if not self.char and not self.char.category == 'Character': raise Exception(f'You have no active character.```css\n.d c "CHARACTER NAME"```') if not self.sc.started_on: raise Exception(f'***{self.sc.name}*** has not yet started. You may not enter.') if self.sc.ended_on: raise Exception(f'***{self.sc.name}*** has already ended. You missed it.') zones = list(Zone.filter(scene_id=str(self.sc.id), archived=False)) leaving = [z for z in zones if str(self.char.id) in z.characters] for l in leaving: messages.extend(zone_svc.player(('p', 'delete', self.char.name), self.channel, l, self.user)) self.note(('note', f'***{self.char.name}*** exits the _{l.name}_ zone')) if self.channel and self.channel.active_engagement: engagement = Engagement().get_by_id(self.channel.active_engagement) messages.extend(engagement_svc.player(('player', 'delete', self.char.name), self.channel, engagement, self.user)) messages.extend(self.player(('p', 'delete', self.char.name))) self.note(('note', f'***{self.char.name}*** exits the _{self.sc.name}_ scene')) return messages
def move(self, args): """Move a Character to the current zone Parameters ---------- args : list(str) List of strings with subcommands Returns ------- list(str) - the response messages string array """ messages = [] self.check_scene() if not self.char or (self.char and self.char.category != 'Character'): raise Exception(f'You have no active character.```css\n.d c "CHARACTER NAME"```') zones = list(Zone.filter(scene_id=str(self.sc.id), archived=False)) if len(args) == 1: leaving = [z for z in zones if str(self.char.id) in z.characters] leaving_str = f'You are currently in the _{leaving[0].name}_ zone.\n' if leaving else '' zones_string = '\n'.join([f'.d s move {z.name}' for z in zones]) raise Exception(f'{leaving_str}Which zone do you want?```css\n{zones_string}```') if not zones: raise Exception('There are no zones to move into.') if args[1] == 'to': zone_name = ' '.join(args[2:]) else: zone_name = ' '.join(args[1:]) zone = [z for z in zones if zone_name.lower() in z.character.name.lower()] if not zone: raise Exception(f'***{zone_name}*** not found in ***{self.sc.name}***') if len(zone) > 1: zones_string = '\n'.join([f'.d s move {z.name}' for z in zones]) raise Exception(f'Which zone do you want?```css\n{zones_string}```') if str(self.char.id) in zone[0].characters: raise Exception(f'***{self.char.name}*** is already in the _{zone[0].name}_ zone.') leaving = [z for z in zones if str(self.char.id) in z.characters] for l in leaving: messages.extend(zone_svc.player(('p', 'delete', self.char.name), self.channel, l, self.user)) self.note(('note', f'***{self.char.name}*** exits the _{l.name}_ zone')) messages.extend(zone_svc.player(('p', self.char.name), self.channel, zone[0], self.user)) self.note(('note', f'***{self.char.name}*** enters the _{zone[0].name}_ zone')) return messages