2020-03-04 18:29:33 +00:00
|
|
|
from typing import *
|
|
|
|
import royalnet.commands as rc
|
|
|
|
from ..tables import DndBattleUnit
|
2020-03-16 22:21:24 +00:00
|
|
|
from .abstract import DndBattleTargetCommand
|
2020-03-04 18:29:33 +00:00
|
|
|
|
|
|
|
|
2020-03-16 22:21:24 +00:00
|
|
|
class DnddeathsaveCommand(DndBattleTargetCommand):
|
2020-03-04 18:29:33 +00:00
|
|
|
name: str = "dnddeathsave"
|
|
|
|
|
2020-03-16 22:21:24 +00:00
|
|
|
description: str = "Add a death save result to a target in the currently active battle."
|
2020-03-04 18:29:33 +00:00
|
|
|
|
2020-03-16 22:21:24 +00:00
|
|
|
syntax: str = "{target} {s|f}"
|
2020-03-04 18:29:33 +00:00
|
|
|
|
|
|
|
aliases = ["deathsave", "ddeathsave", "ds", "dds", "dndds"]
|
|
|
|
|
2020-03-16 22:21:24 +00:00
|
|
|
async def _change(self, unit: DndBattleUnit, args: List[str]):
|
2020-03-04 18:29:33 +00:00
|
|
|
health = unit.health
|
2020-03-16 22:21:24 +00:00
|
|
|
if args[0][0] == "s":
|
2020-03-04 18:29:33 +00:00
|
|
|
health.deathsave_success()
|
2020-03-16 22:21:24 +00:00
|
|
|
elif args[0][0] == "f":
|
2020-03-04 18:29:33 +00:00
|
|
|
health.deathsave_failure()
|
|
|
|
else:
|
2020-03-16 22:21:24 +00:00
|
|
|
raise rc.InvalidInputError(f"Unknown result type [c]{args[0][0]}[/c].")
|
2020-03-04 18:29:33 +00:00
|
|
|
unit.health = health
|