mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-11-05 06:13:55 +01:00
Add progress bars to display health and mana in list
This commit is contained in:
parent
d37b1496bc
commit
ec9912b22a
2 changed files with 27 additions and 2 deletions
|
@ -306,6 +306,18 @@ class Character(models.Model):
|
|||
def luck_points_max(self) -> int:
|
||||
return 3 + self.modifier_charisma
|
||||
|
||||
@property
|
||||
def health_remaining_percent(self) -> float:
|
||||
if self.health_max == 0:
|
||||
return 0
|
||||
return self.health_remaining / self.health_max * 100
|
||||
|
||||
@property
|
||||
def mana_remaining_percent(self) -> float:
|
||||
if self.mana_max == 0:
|
||||
return 0
|
||||
return self.mana_remaining / self.mana_max * 100
|
||||
|
||||
def get_modifier_for_weapon(self, weapon: Weapon) -> int:
|
||||
modifier_map = {
|
||||
Weapon.Category.RANGE: self.modifier_dexterity,
|
||||
|
|
|
@ -7,8 +7,21 @@
|
|||
</h5>
|
||||
<p class="card-text">
|
||||
{{ character.race.name }} {{ character.profile.name }} niv. {{ character.level }}<br>
|
||||
{{ character.get_gender_display }}, {{ character.age }} ans, {{ character.height_m }}m, {{ character.weight }}kg<br>
|
||||
PV {{ character.health_remaining }}/{{ character.health_max }}, PM {{ character.mana_remaining }}/{{ character.mana_max }}<br>
|
||||
{{ character.get_gender_display }}, {{ character.age }} ans, {{ character.height_m }}m, {{ character.weight }}kg
|
||||
</p>
|
||||
<div class="progress">
|
||||
<div class="progress-bar bg-success" style="width: {{ character.health_remaining_percent|floatformat:"0" }}%">
|
||||
PV : {{ character.health_remaining }}/{{ character.health_max }}
|
||||
</div>
|
||||
</div>
|
||||
{% if character.mana_max > 0 %}
|
||||
<div class="progress mt-1">
|
||||
<div class="progress-bar bg-primary" style="width: {{ character.mana_remaining_percent|floatformat:"0" }}%">
|
||||
PM : {{ character.mana_remaining }}/{{ character.mana_max }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<p class="card-text mt-3">
|
||||
{% with character.states.all as character_states %}
|
||||
{% for state in all_states %}
|
||||
<img src="{{ state.icon_url }}" alt="{{ state.name }}" height="25" width="25"
|
||||
|
|
Loading…
Reference in a new issue