async def begin(self, ctx, *args): """Begins combat in the channel the command is invoked. Usage: !init begin <ARGS (opt)> __Valid Arguments__ dyn (dynamic init; rerolls all initiatives at the start of a round) turnnotif (notifies the next player) -name <NAME> (names the combat)""" await Combat.ensure_unique_chan(ctx) options = {} args = argparse(args) if args.last('dyn', False, bool): # rerolls all inits at the start of each round options['dynamic'] = True if 'name' in args: options['name'] = args.last('name') if args.last('turnnotif', False, bool): options['turnnotif'] = True temp_summary_msg = await ctx.send("```Awaiting combatants...```") Combat.message_cache[temp_summary_msg.id] = temp_summary_msg # add to cache combat = Combat.new(str(ctx.channel.id), temp_summary_msg.id, str(ctx.author.id), options, ctx) await combat.final() try: await temp_summary_msg.pin() except: pass await ctx.send( f"Everyone roll for initiative!\n" f"If you have a character set up with SheetManager: `{ctx.prefix}init join`\n" f"If it's a 5e monster: `{ctx.prefix}init madd [monster name]`\n" f"Otherwise: `{ctx.prefix}init add [modifier] [name]`")
def from_character(cls, character, ctx): try: combat = Combat.from_ctx(ctx) except CombatNotFound: return None me = next((c for c in combat.get_combatants() if getattr(c, 'character_id', None) == character.id), None) if not me: return None return cls(combat, me)
def from_ctx(cls, ctx): try: combat = Combat.from_ctx_sync(ctx) except CombatNotFound: return None return cls(combat, None)