diff --git a/src/character/models/capabilities.py b/src/character/models/capabilities.py index 6314a85..40aec7e 100644 --- a/src/character/models/capabilities.py +++ b/src/character/models/capabilities.py @@ -119,6 +119,12 @@ class Capability(DocumentedModel, TimeStampedModel, models.Model): def natural_key(self): return (self.path_id, self.rank) + @property + def capability_points_cost(self) -> int: + if self.rank in [1, 2]: + return 1 + return 2 + class RacialCapabilityManager(models.Manager): def get_by_natural_key(self, name: str, race_id: int): diff --git a/src/character/models/character.py b/src/character/models/character.py index 431b8c6..f25bf56 100644 --- a/src/character/models/character.py +++ b/src/character/models/character.py @@ -332,6 +332,18 @@ class Character(models.Model): return 0 return self.mana_remaining / self.mana_max * 100 + @property + def capability_points_max(self) -> int: + return 2 * self.level + + @property + def capability_points_used(self) -> int: + return sum(cap.capability_points_cost for cap in self.capabilities.only("rank")) + + @property + def capability_points_remaining(self) -> int: + return self.capability_points_max - self.capability_points_used + def get_modifier_for_weapon(self, weapon: Weapon) -> int: modifier_map = { Weapon.Category.RANGE: self.modifier_dexterity, diff --git a/src/character/templates/character/character_details.html b/src/character/templates/character/character_details.html index 32cda83..15e80f6 100644 --- a/src/character/templates/character/character_details.html +++ b/src/character/templates/character/character_details.html @@ -484,7 +484,6 @@ {% include "character/snippets/character_details/equipment_display.html" %} -

Voies & Capacités

{% include "character/snippets/character_details/paths_and_capabilities.html" %} {% if character|managed_by:user %} diff --git a/src/character/templates/character/snippets/character_details/paths_and_capabilities.html b/src/character/templates/character/snippets/character_details/paths_and_capabilities.html index 25b9333..060e8b9 100644 --- a/src/character/templates/character/snippets/character_details/paths_and_capabilities.html +++ b/src/character/templates/character/snippets/character_details/paths_and_capabilities.html @@ -1,6 +1,7 @@ {% load character_extras %} {% load django_bootstrap5 %}
+

Voies & Capacités {{ character.capability_points_remaining }}

{% if character|managed_by:user %}
{% csrf_token %}