Mi2dRPGamEng/resources/logic/health_ticks.py

19 lines
673 B
Python

from __future__ import annotations
from engine.character import Character
from engine.defs import DefRegistry
def apply_bleeding_tick(character: Character, registry: DefRegistry, ticks: int) -> None:
"""Every body part that's been lost (removed=True) bleeds at its def's bleeding_speed per tick."""
if ticks <= 0:
return
total_loss = 0.0
for part in character.body_parts:
if not part.removed:
continue
part_def = registry.get_body_part_def(part.part_def_id)
total_loss += part_def.bleeding_speed * ticks
if total_loss:
character.blood_percentage = max(0.0, character.blood_percentage - total_loss)