From 8e4ec595e14800c3933bf1b6ded0ffd5e78e3471 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Wed, 2 Nov 2022 20:46:07 +0100 Subject: [PATCH] Separate attack and protection --- src/character/templates/character/view.html | 45 ++++++++++++++++++++- src/character/urls.py | 5 +++ src/character/views.py | 12 ++++++ 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/src/character/templates/character/view.html b/src/character/templates/character/view.html index 0cc748e..95af499 100644 --- a/src/character/templates/character/view.html +++ b/src/character/templates/character/view.html @@ -63,7 +63,7 @@
- + @@ -132,6 +132,47 @@ {{ character.attack_magic|modifier }} + +
Combat
Attaque
+
+
+ + + + + + + + +
Protection
+ Armure +
+ + + + +
+
+ {{ character.armor }} +
Bouclier @@ -200,7 +241,7 @@ Défense {{ character.defense }} diff --git a/src/character/urls.py b/src/character/urls.py index 852bdd2..3731ced 100644 --- a/src/character/urls.py +++ b/src/character/urls.py @@ -33,6 +33,11 @@ urlpatterns = [ views.character_shield_change, name="shield_change", ), + path( + "/armor_change/", + views.character_armor_change, + name="armor_change", + ), path( "/get_initiative/", views.character_get_initiative, diff --git a/src/character/views.py b/src/character/views.py index 5b96261..cec4101 100644 --- a/src/character/views.py +++ b/src/character/views.py @@ -119,6 +119,18 @@ def character_shield_change(request, pk: int): return trigger_client_event(response, "update_defense", {}) +@login_required +def character_armor_change(request, pk: int): + character = get_object_or_404( + Character.objects.filter(player=request.user).only("armor"), pk=pk + ) + value = get_updated_value(request, character.armor, float("inf")) + character.armor = value + character.save(update_fields=["armor"]) + response = HttpResponse(value) + return trigger_client_event(response, "update_defense", {}) + + @login_required def character_initiative_misc_change(request, pk: int): character = get_object_or_404(