mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-11-22 14:38:03 +01:00
Add luck points
This commit is contained in:
parent
aa5fb92640
commit
991de5a5bb
3 changed files with 132 additions and 82 deletions
|
@ -211,6 +211,38 @@
|
|||
</div>
|
||||
</th>
|
||||
<td id="recovery-points-remaining">{{ character.recovery_points_remaining }}</td>
|
||||
<tr>
|
||||
<th scope="row">PC max</th>
|
||||
<td>{{ character.luck_points_max }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="top"
|
||||
data-bs-title="[1 dé de vie + {{ character.modifier_constitution|add:character.level }}] PV">
|
||||
PC restants
|
||||
<div class="btn-group btn-group-sm" role="group">
|
||||
<button
|
||||
hx-get="{% url "character:luck_points_change" pk=character.pk %}?value=-1"
|
||||
hx-target="#luck-points-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-danger">-</button>
|
||||
<button
|
||||
hx-get="{% url "character:luck_points_change" pk=character.pk %}?value=1"
|
||||
hx-target="#luck-points-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-success">+</button>
|
||||
<button
|
||||
hx-get="{% url "character:luck_points_change" pk=character.pk %}?value=max"
|
||||
hx-target="#luck-points-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-outline-success">max</button>
|
||||
</div>
|
||||
</th>
|
||||
<td id="luck-points-remaining">{{ character.luck_points_remaining }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
@ -12,6 +12,11 @@ urlpatterns = [
|
|||
views.character_recovery_points_change,
|
||||
name="recovery_points_change",
|
||||
),
|
||||
path(
|
||||
"<int:pk>/luck_points_change",
|
||||
views.character_luck_points_change,
|
||||
name="luck_points_change",
|
||||
),
|
||||
path("<int:pk>/notes_change", views.character_notes_change, name="notes_change"),
|
||||
path(
|
||||
"<int:pk>/equipment_change",
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue