mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-11-26 08:28:04 +01:00
Separate attack and protection
This commit is contained in:
parent
df07ff357a
commit
8e4ec595e1
3 changed files with 60 additions and 2 deletions
|
@ -63,7 +63,7 @@
|
|||
<div class="col-sm-12 col-md-6 col-lg-6 col-xl">
|
||||
<table id="fight-table" class="table table-hover table-sm">
|
||||
<thead>
|
||||
<tr><th scope="col" colspan="2">Combat</th></tr>
|
||||
<tr><th scope="col" colspan="2">Attaque</th></tr>
|
||||
</thead>
|
||||
<tbody class="table-group-divider">
|
||||
<tr>
|
||||
|
@ -132,6 +132,47 @@
|
|||
{{ character.attack_magic|modifier }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-6 col-lg-6 col-xl">
|
||||
<table id="fight-table" class="table table-hover table-sm">
|
||||
<thead>
|
||||
<tr><th scope="col" colspan="2">Protection</th></tr>
|
||||
</thead>
|
||||
<tbody class="table-group-divider">
|
||||
<tr>
|
||||
<th scope="row">
|
||||
Armure
|
||||
<div class="btn-group btn-group-sm float-end" role="group">
|
||||
<button
|
||||
hx-get="{% url "character:armor_change" pk=character.pk %}?value=ko"
|
||||
hx-target="#armor"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-outline-danger"><i class="fa-solid fa-battery-empty"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:armor_change" pk=character.pk %}?value=-1"
|
||||
hx-target="#armor"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-danger"><i class="fa-solid fa-minus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:armor_change" pk=character.pk %}?value=1"
|
||||
hx-target="#armor"
|
||||
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="armor">
|
||||
{{ character.armor }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
Bouclier
|
||||
|
@ -200,7 +241,7 @@
|
|||
<th scope="row">Défense</th>
|
||||
<td data-bs-toggle="tooltip"
|
||||
data-bs-placement="left"
|
||||
data-bs-title="10 + {{ character.armor }} (armure) + {{ character.shield }} (bouclier) + {{ character.modifier_dexterity }} (mod. DEX) + {{ character.defense_misc }} (divers)"
|
||||
data-bs-title="10 + armure + bouclier + mod. DEX + divers"
|
||||
hx-get="{% url "character:get_defense" pk=character.pk %}"
|
||||
hx-trigger="update_defense from:#fight-table">
|
||||
{{ character.defense }}
|
||||
|
|
|
@ -33,6 +33,11 @@ urlpatterns = [
|
|||
views.character_shield_change,
|
||||
name="shield_change",
|
||||
),
|
||||
path(
|
||||
"<int:pk>/armor_change/",
|
||||
views.character_armor_change,
|
||||
name="armor_change",
|
||||
),
|
||||
path(
|
||||
"<int:pk>/get_initiative/",
|
||||
views.character_get_initiative,
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue