async def start_game(self, message: Message, roleplay: str, players: str): config = State.get_config(message.guild.id) if config and 'rp' in config and config['rp']: await message.channel.send( f'Cannot start roleplay, {config["rp"]} is already in progress.' ) return if roleplay not in self.bot.roleplays: await message.channel.send( f'Cannot start roleplay, unknown roleplay name {roleplay}' ) return loading_message = await message.channel.send(f'Setting up new game...') config = {'rp': roleplay, 'connections': {}} await self.bot.save_guild_config(message.guild, config) await self.bot.refresh_from_config(message.guild, config, True) await message.author.add_roles(State.get_admin_role(message.guild.id)) self.roleplay = self.bot.roleplays[roleplay] player_role = State.get_player_role(message.guild.id) for member in message.mentions: await member.add_roles(player_role) await self.move_force(message, self.roleplay.starting_room, None) await message.channel.send(f'The game begins.') await loading_message.delete() await message.delete()
async def end_game(self, message: Message): loading_message = await message.channel.send(f'Ending game...') config = {} guild: Guild = message.guild State.save_config(guild.id, config) State.save_plugins(guild.id, []) await self.bot.save_guild_config(guild, config) player_role = State.get_player_role(guild.id) observer_role = State.get_observer_role(guild.id) for player in player_role.members: await player.remove_roles(player_role) await player.add_roles(observer_role) await message.channel.send(f'The game ends.') await loading_message.delete() await message.delete() await self.bot.refresh_from_config(guild, config)
async def move_all(self, message: Message, room: str): for player in State.get_player_role(message.guild.id).members: await self._move_player(player, room)
async def mark_player(self, message: Message, user: str): await self._mark_with_role( message, State.get_player_role(message.guild.id), 'a player' )