Fix luck points

This commit is contained in:
Gabriel Augendre 2022-10-30 22:43:50 +01:00
parent eb3c54c54b
commit 3876351227
5 changed files with 24 additions and 8 deletions

View file

@ -0,0 +1,17 @@
# Generated by Django 4.1.2 on 2022-10-30 21:43
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("character", "0016_profile_mana_max_compute"),
]
operations = [
migrations.RemoveField(
model_name="character",
name="luck_points_max",
),
]

View file

@ -1 +1 @@
0016_profile_mana_max_compute 0017_remove_character_luck_points_max

View file

@ -130,9 +130,6 @@ class Character(models.Model):
) )
equipment = models.TextField(blank=True, verbose_name="équipement") equipment = models.TextField(blank=True, verbose_name="équipement")
luck_points_max = models.PositiveSmallIntegerField(
verbose_name="points de chance max"
)
luck_points_remaining = models.PositiveSmallIntegerField( luck_points_remaining = models.PositiveSmallIntegerField(
verbose_name="points de chance restants" verbose_name="points de chance restants"
) )
@ -250,6 +247,10 @@ class Character(models.Model):
def recovery_points_max(self) -> int: def recovery_points_max(self) -> int:
return 5 return 5
@property
def luck_points_max(self) -> int:
return 3 + self.modifier_charisma
def get_capabilities_by_path(self) -> dict[Path, list[Capability]]: def get_capabilities_by_path(self) -> dict[Path, list[Capability]]:
capabilities_by_path = collections.defaultdict(list) capabilities_by_path = collections.defaultdict(list)
for capability in self.capabilities.all(): for capability in self.capabilities.all():

View file

@ -211,9 +211,7 @@
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button> class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button>
</div> </div>
</th> </th>
<td data-bs-toggle="tooltip" <td>
data-bs-placement="left"
data-bs-title="[1 dé de vie + {{ character.modifier_constitution|add:character.level }}] PV">
<span id="recovery-points-remaining">{{ character.recovery_points_remaining }}</span> / {{ character.recovery_points_max }}</td> <span id="recovery-points-remaining">{{ character.recovery_points_remaining }}</span> / {{ character.recovery_points_max }}</td>
<tr> <tr>
<th scope="row"> <th scope="row">

View file

@ -56,7 +56,7 @@ def character_recovery_points_change(request: WSGIRequest, pk: int) -> HttpRespo
@login_required @login_required
def character_luck_points_change(request: WSGIRequest, pk: int) -> HttpResponse: def character_luck_points_change(request: WSGIRequest, pk: int) -> HttpResponse:
character = get_object_or_404( character = get_object_or_404(
Character.objects.only("luck_points_remaining", "luck_points_max"), pk=pk Character.objects.only("luck_points_remaining", "value_charisma"), pk=pk
) )
value = get_updated_value( value = get_updated_value(
request, character.luck_points_remaining, character.luck_points_max request, character.luck_points_remaining, character.luck_points_max