1
Fork 0
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:
Steffo 2020-03-15 14:42:42 +01:00
parent af778309bf
commit c5a0f7ad7f

View file

@ -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,