Add support for temporary hit points
Closed this issue · 1 comments
Having temporary hit points is surprisingly more common than I expected, so we should finally add support for it.
Temporary hit points are explained here: https://www.dndbeyond.com/sources/basic-rules/combat#TemporaryHitPoints
We should add a temp_hp
attribute to combatants. It can default to 0, with a minimum of 0.
The cur_hp
getter should return the sum of _cur_hp
and temp_hp
.
The cur_hp
setter should be modified to check if the new value
is less than _cur_hp
, and if so, deduct as much of the difference as it can from temp_hp
, with the remainder from difference - temp_hp
applied to the _cur_hp
. If we get this right here, it means that we don't have to change any of the code that adjusts cur_hp
!
temp_hp
should be emitted into the toml when saving player state, and should be reloaded when loading the party.
We can optionally add a temp_hp
command to set the temp_hp
on a combatant, or we can lean on the existing alter
command which would already be able to do alter <combatant> temp_hp <value>
.
I punted on writing a new command for setting temp_hp
for now since I can just do alter <combatant> temp_hp <value>
and it works fine as long as the value provided is a non-negative integer.