mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-11-22 22:48:03 +01:00
Add shield
This commit is contained in:
parent
8a21e54179
commit
c20be28290
3 changed files with 49 additions and 0 deletions
|
@ -132,6 +132,38 @@
|
||||||
{{ character.attack_magic|modifier }}
|
{{ character.attack_magic|modifier }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">
|
||||||
|
Bouclier
|
||||||
|
<div class="btn-group btn-group-sm float-end" role="group">
|
||||||
|
<button
|
||||||
|
hx-get="{% url "character:shield_change" pk=character.pk %}?value=ko"
|
||||||
|
hx-target="#shield"
|
||||||
|
hx-swap="innerHTML"
|
||||||
|
type="button"
|
||||||
|
class="btn btn-outline-danger"><i class="fa-solid fa-battery-empty"></i></button>
|
||||||
|
<button
|
||||||
|
hx-get="{% url "character:shield_change" pk=character.pk %}?value=-1"
|
||||||
|
hx-target="#shield"
|
||||||
|
hx-swap="innerHTML"
|
||||||
|
type="button"
|
||||||
|
class="btn btn-danger"><i class="fa-solid fa-minus"></i></button>
|
||||||
|
<button
|
||||||
|
hx-get="{% url "character:shield_change" pk=character.pk %}?value=1"
|
||||||
|
hx-target="#shield"
|
||||||
|
hx-swap="innerHTML"
|
||||||
|
type="button"
|
||||||
|
class="btn btn-success"><i class="fa-solid fa-plus"></i></button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
disabled
|
||||||
|
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button>
|
||||||
|
</div>
|
||||||
|
</th>
|
||||||
|
<td id="shield">
|
||||||
|
{{ character.shield }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">
|
<th scope="row">
|
||||||
Divers défense
|
Divers défense
|
||||||
|
|
|
@ -28,6 +28,11 @@ urlpatterns = [
|
||||||
views.character_defense_misc_change,
|
views.character_defense_misc_change,
|
||||||
name="defense_misc_change",
|
name="defense_misc_change",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"<int:pk>/shield_change/",
|
||||||
|
views.character_shield_change,
|
||||||
|
name="shield_change",
|
||||||
|
),
|
||||||
path(
|
path(
|
||||||
"<int:pk>/get_initiative/",
|
"<int:pk>/get_initiative/",
|
||||||
views.character_get_initiative,
|
views.character_get_initiative,
|
||||||
|
|
|
@ -106,6 +106,18 @@ def character_defense_misc_change(request, pk: int):
|
||||||
return trigger_client_event(response, "update_defense", {})
|
return trigger_client_event(response, "update_defense", {})
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def character_shield_change(request, pk: int):
|
||||||
|
character = get_object_or_404(
|
||||||
|
Character.objects.filter(player=request.user).only("shield"), pk=pk
|
||||||
|
)
|
||||||
|
value = get_updated_value(request, character.shield, float("inf"))
|
||||||
|
character.shield = value
|
||||||
|
character.save(update_fields=["shield"])
|
||||||
|
response = HttpResponse(value)
|
||||||
|
return trigger_client_event(response, "update_defense", {})
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def character_initiative_misc_change(request, pk: int):
|
def character_initiative_misc_change(request, pk: int):
|
||||||
character = get_object_or_404(
|
character = get_object_or_404(
|
||||||
|
|
Loading…
Reference in a new issue