From 991de5a5bb20d04613a6546a256d1cdb45d6cdfe Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sun, 30 Oct 2022 22:02:21 +0100 Subject: [PATCH] Add luck points --- src/character/templates/character/view.html | 196 ++++++++++++-------- src/character/urls.py | 5 + src/character/views.py | 13 ++ 3 files changed, 132 insertions(+), 82 deletions(-) diff --git a/src/character/templates/character/view.html b/src/character/templates/character/view.html index 3d301bd..8345bee 100644 --- a/src/character/templates/character/view.html +++ b/src/character/templates/character/view.html @@ -211,91 +211,123 @@ {{ character.recovery_points_remaining }} - - - - - -
-
-
-
{{ character.racial_capability.name }}
-
-

{{ character.racial_capability.description|capfirst }}

-
+ + PC max + {{ character.luck_points_max }} + + + + PC restants +
+ + + +
+ + {{ character.luck_points_remaining }} + + +
-
- - - - - - - - - - - {% for weapon in character.weapons.all %} - - - - - - - {% empty %} - - - - {% endfor %} - -
ArmeAttaqueDMSpécial
{{ weapon.name }}1D20 +{{ weapon.damage }}{{ weapon.special }}
Aucune arme
-
-
-
-
-
-
Équipement
-
- {% include "character/equipment_display.html" %} -
- -
-
-
-

Voies & Capacités

-
- {% for path, capabilities in character.get_capabilities_by_path.items %} -
+
+
-
{{ path.display_name }}
- {% if path.notes %} -
{{ path.notes }}
- {% endif %} -
    - {% for capability in capabilities %} -
  • - - {{ capability.rank }}. - {{ capability.name }} - {% if capability.spell %}{% endif %} - {% if capability.limited %}{% endif %} -
    - {{ capability.description }} -
  • - {% endfor %} -
+
{{ character.racial_capability.name }}
+
+

{{ character.racial_capability.description|capfirst }}

+
- {% endfor %} -
-

Notes

-
- {% include "character/notes_display.html" %} -
+
+ + + + + + + + + + + {% for weapon in character.weapons.all %} + + + + + + + {% empty %} + + + + {% endfor %} + +
ArmeAttaqueDMSpécial
{{ weapon.name }}1D20 +{{ weapon.damage }}{{ weapon.special }}
Aucune arme
+
+
+
+
+
+
Équipement
+
+ {% include "character/equipment_display.html" %} +
+ +
+
+
+

Voies & Capacités

+
+ {% for path, capabilities in character.get_capabilities_by_path.items %} +
+
+
{{ path.display_name }}
+ {% if path.notes %} +
{{ path.notes }}
+ {% endif %} +
    + {% for capability in capabilities %} +
  • + + {{ capability.rank }}. + {{ capability.name }} + {% if capability.spell %}{% endif %} + {% if capability.limited %}{% endif %} +
    + {{ capability.description }} +
  • + {% endfor %} +
+
+
+ {% endfor %} +
+

Notes

+
+ {% include "character/notes_display.html" %} +
{% endblock %} diff --git a/src/character/urls.py b/src/character/urls.py index c35f445..f1944f0 100644 --- a/src/character/urls.py +++ b/src/character/urls.py @@ -12,6 +12,11 @@ urlpatterns = [ views.character_recovery_points_change, name="recovery_points_change", ), + path( + "/luck_points_change", + views.character_luck_points_change, + name="luck_points_change", + ), path("/notes_change", views.character_notes_change, name="notes_change"), path( "/equipment_change", diff --git a/src/character/views.py b/src/character/views.py index e5e110d..c44ce61 100644 --- a/src/character/views.py +++ b/src/character/views.py @@ -53,6 +53,19 @@ def character_recovery_points_change(request: WSGIRequest, pk: int) -> HttpRespo return HttpResponse(value) +@login_required +def character_luck_points_change(request: WSGIRequest, pk: int) -> HttpResponse: + character = get_object_or_404( + Character.objects.only("luck_points_remaining", "luck_points_max"), pk=pk + ) + value = get_updated_value( + request, character.luck_points_remaining, character.luck_points_max + ) + character.luck_points_remaining = value + character.save(update_fields=["luck_points_remaining"]) + return HttpResponse(value) + + def get_updated_value( request: WSGIRequest, remaining_value: int, max_value: int ) -> int: