1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-24 03:54:20 +00:00
royalnet/rpgpack/commands/dndextra.py

34 lines
946 B
Python
Raw Normal View History

2020-03-04 18:29:33 +00:00
from typing import *
import royalnet
import royalnet.commands as rc
import royalnet.utils as ru
from ..tables import DndBattleUnit
from ..utils import find_unit_in_current_battle
class DndextraCommand(rc.Command):
name: str = "dndextra"
description: str = "Change the extras for a unit in the current battle."
syntax: str = "[name] {extra}"
aliases = ["extra", "dextra"]
async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None:
name = args.optional(0)
extra = " ".join(args[1:])
if name is not None:
unit: Optional[DndBattleUnit] = await find_unit_in_current_battle(data, name)
else:
unit = None
if unit is None:
extra = " ".join(args)
unit: Optional[DndBattleUnit] = await find_unit_in_current_battle(data, None)
unit.extra = extra
await data.session_commit()
await data.reply(f"{unit}")