Display states on character card

This commit is contained in:
Gabriel Augendre 2022-11-06 14:42:29 +01:00
parent cd2ab27f3a
commit 9033c8453c
7 changed files with 24 additions and 8 deletions

View file

@ -15,6 +15,9 @@
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/src/public" />
<excludeFolder url="file://$MODULE_DIR$/src/test_reports" />
<excludeFolder url="file://$MODULE_DIR$/src/character/tests/test_reports" />
</content> </content>
<orderEntry type="jdk" jdkName="Python 3.10 (charasheet)" jdkType="Python SDK" /> <orderEntry type="jdk" jdkName="Python 3.10 (charasheet)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />

View file

@ -5,10 +5,6 @@
{% block title %}{{ character.name }}{% endblock %} {% block title %}{{ character.name }}{% endblock %}
{% block head_end %}
<link rel="stylesheet" href="{% static "character/style.css" %}">
{% endblock %}
{% block content %} {% block content %}
<h1>{{ character.name }}</h1> <h1>{{ character.name }}</h1>
<p> <p>

View file

@ -7,7 +7,19 @@
<p class="card-text"> <p class="card-text">
{{ character.race.name }} {{ character.profile.name }} niv. {{ character.level }}<br> {{ 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> {{ 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 }} PV {{ character.health_remaining }}/{{ character.health_max }}, PM {{ character.mana_remaining }}/{{ character.mana_max }}<br>
{% with character.states.all as character_states %}
{% for state in all_states %}
<img src="{{ state.icon_url }}" alt="{{ state.name }}" height="25" width="25"
data-bs-toggle="tooltip"
data-bs-placement="top"
data-bs-title="{{ state.name }} : {{ state.description }}"
{% if state in character_states %}
class="state-enabled"
{% endif %}
>
{% endfor %}
{% endwith %}
</p> </p>
{% if character.player == user %} {% if character.player == user %}
<div class="btn-group btn-group-sm"> <div class="btn-group btn-group-sm">

View file

@ -13,7 +13,8 @@ def characters_list(request):
context = { context = {
"characters": Character.objects.owned_by(request.user).select_related( "characters": Character.objects.owned_by(request.user).select_related(
"race", "profile" "race", "profile"
) ),
"all_states": HarmfulState.objects.all(),
} }
return render(request, "character/characters_list.html", context) return render(request, "character/characters_list.html", context)

View file

@ -16,6 +16,7 @@
touch-action: manipulation; touch-action: manipulation;
} }
</style> </style>
<link rel="stylesheet" href="{% static "style.css" %}">
{% block head_end %} {% block head_end %}
{% endblock %} {% endblock %}
</head> </head>

View file

@ -2,7 +2,7 @@ from django.contrib import messages
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.shortcuts import get_object_or_404, redirect, render from django.shortcuts import get_object_or_404, redirect, render
from character.models import Character from character.models import Character, HarmfulState
from party.forms import PartyForm from party.forms import PartyForm
from party.models import Party from party.models import Party
@ -35,7 +35,10 @@ def party_create(request):
@login_required @login_required
def party_details(request, pk): def party_details(request, pk):
party = get_object_or_404(Party.objects.related_to(request.user), pk=pk) party = get_object_or_404(Party.objects.related_to(request.user), pk=pk)
context = {"party": party} context = {
"party": party,
"all_states": HarmfulState.objects.all(),
}
return render(request, "party/party_details.html", context) return render(request, "party/party_details.html", context)