mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Don't add units with invalid health values
This commit is contained in:
parent
af778309bf
commit
c5a0f7ad7f
1 changed files with 7 additions and 1 deletions
|
@ -5,6 +5,7 @@ import royalnet.utils as ru
|
||||||
from ..types import Faction
|
from ..types import Faction
|
||||||
from ..tables import DndBattleUnit
|
from ..tables import DndBattleUnit
|
||||||
from ..utils import get_active_battle
|
from ..utils import get_active_battle
|
||||||
|
from ..types import Health
|
||||||
|
|
||||||
|
|
||||||
class DndaddunitCommand(rc.Command):
|
class DndaddunitCommand(rc.Command):
|
||||||
|
@ -37,6 +38,11 @@ class DndaddunitCommand(rc.Command):
|
||||||
if len(units_with_same_name) != 0:
|
if len(units_with_same_name) != 0:
|
||||||
raise rc.InvalidInputError("A unit with the same name already exists.")
|
raise rc.InvalidInputError("A unit with the same name already exists.")
|
||||||
|
|
||||||
|
try:
|
||||||
|
health = Health.from_text(health)
|
||||||
|
except ValueError:
|
||||||
|
raise rc.InvalidInputError("Invalid health string.")
|
||||||
|
|
||||||
dbu = DndBattleUnitT(
|
dbu = DndBattleUnitT(
|
||||||
linked_character_id=None,
|
linked_character_id=None,
|
||||||
initiative=initiative,
|
initiative=initiative,
|
||||||
|
@ -54,4 +60,4 @@ class DndaddunitCommand(rc.Command):
|
||||||
f"joins the battle!")
|
f"joins the battle!")
|
||||||
|
|
||||||
if dbu.health.hidden:
|
if dbu.health.hidden:
|
||||||
await data.delete_invoking()
|
await data.delete_invoking()
|
||||||
|
|
Loading…
Reference in a new issue