mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-11-22 22:48:03 +01:00
Improve notes display & fix character creation defaults
This commit is contained in:
parent
b12ea84db4
commit
d80172e96a
11 changed files with 149 additions and 14 deletions
17
poetry.lock
generated
17
poetry.lock
generated
|
@ -399,6 +399,17 @@ python-versions = "*"
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
ansicon = {version = "*", markers = "platform_system == \"Windows\""}
|
ansicon = {version = "*", markers = "platform_system == \"Windows\""}
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "markdown"
|
||||||
|
version = "3.4.1"
|
||||||
|
description = "Python implementation of Markdown."
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
testing = ["coverage", "pyyaml"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "model-bakery"
|
name = "model-bakery"
|
||||||
version = "1.9.0"
|
version = "1.9.0"
|
||||||
|
@ -905,7 +916,7 @@ h11 = ">=0.9.0,<1"
|
||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "1.1"
|
lock-version = "1.1"
|
||||||
python-versions = ">=3.10.0, <4"
|
python-versions = ">=3.10.0, <4"
|
||||||
content-hash = "96bceed911ff3dca55ddfc85bf7d48e9056111b55aad6e05da5d3ebd2e9a60aa"
|
content-hash = "df8aa35ecf2515691ed8ffdccbfb63f503c9330db3cd806d7dc8a8689f64328e"
|
||||||
|
|
||||||
[metadata.files]
|
[metadata.files]
|
||||||
ansicon = [
|
ansicon = [
|
||||||
|
@ -1255,6 +1266,10 @@ jinxed = [
|
||||||
{file = "jinxed-1.2.0-py2.py3-none-any.whl", hash = "sha256:cfc2b2e4e3b4326954d546ba6d6b9a7a796ddcb0aef8d03161d005177eb0d48b"},
|
{file = "jinxed-1.2.0-py2.py3-none-any.whl", hash = "sha256:cfc2b2e4e3b4326954d546ba6d6b9a7a796ddcb0aef8d03161d005177eb0d48b"},
|
||||||
{file = "jinxed-1.2.0.tar.gz", hash = "sha256:032acda92d5c57cd216033cbbd53de731e6ed50deb63eb4781336ca55f72cda5"},
|
{file = "jinxed-1.2.0.tar.gz", hash = "sha256:032acda92d5c57cd216033cbbd53de731e6ed50deb63eb4781336ca55f72cda5"},
|
||||||
]
|
]
|
||||||
|
markdown = [
|
||||||
|
{file = "Markdown-3.4.1-py3-none-any.whl", hash = "sha256:08fb8465cffd03d10b9dd34a5c3fea908e20391a2a90b88d66362cb05beed186"},
|
||||||
|
{file = "Markdown-3.4.1.tar.gz", hash = "sha256:3b809086bb6efad416156e00a0da66fe47618a5d6918dd688f53f40c8e4cfeff"},
|
||||||
|
]
|
||||||
model-bakery = [
|
model-bakery = [
|
||||||
{file = "model_bakery-1.9.0-py2.py3-none-any.whl", hash = "sha256:93ac818df49377d4f14316105028fa95231474bf268d6017e420e5d4b74d54fd"},
|
{file = "model_bakery-1.9.0-py2.py3-none-any.whl", hash = "sha256:93ac818df49377d4f14316105028fa95231474bf268d6017e420e5d4b74d54fd"},
|
||||||
{file = "model_bakery-1.9.0.tar.gz", hash = "sha256:99571801a26b85b8dcba7f0ad39750aeb2f2477fe770d2291823e16788785000"},
|
{file = "model_bakery-1.9.0.tar.gz", hash = "sha256:99571801a26b85b8dcba7f0ad39750aeb2f2477fe770d2291823e16788785000"},
|
||||||
|
|
|
@ -19,6 +19,7 @@ psycopg2-binary = ">=2.8"
|
||||||
whitenoise = ">=6.2"
|
whitenoise = ">=6.2"
|
||||||
uWSGI = ">=2.0.21"
|
uWSGI = ">=2.0.21"
|
||||||
selenium = ">=4.5.0"
|
selenium = ">=4.5.0"
|
||||||
|
Markdown = ">=3.2"
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.dev-dependencies]
|
||||||
django-debug-toolbar = ">=3.2"
|
django-debug-toolbar = ">=3.2"
|
||||||
|
|
22
src/character/migrations/0021_alter_character_notes.py
Normal file
22
src/character/migrations/0021_alter_character_notes.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
# Generated by Django 4.1.2 on 2022-10-30 23:39
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("character", "0020_alter_weapon_category"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="character",
|
||||||
|
name="notes",
|
||||||
|
field=models.TextField(
|
||||||
|
blank=True,
|
||||||
|
default="### Traits personnalisés\n\n### Objectifs\n\n### Langages\n\n### Historique\n\n### Handicaps\n\n### Alignement\n\n### Relations\n\n### Religion\n",
|
||||||
|
verbose_name="notes",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
18
src/character/migrations/0022_alter_character_level.py
Normal file
18
src/character/migrations/0022_alter_character_level.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 4.1.2 on 2022-10-30 23:40
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("character", "0021_alter_character_notes"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="character",
|
||||||
|
name="level",
|
||||||
|
field=models.PositiveSmallIntegerField(default=1, verbose_name="niveau"),
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,28 @@
|
||||||
|
# Generated by Django 4.1.2 on 2022-10-30 23:40
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("character", "0022_alter_character_level"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="character",
|
||||||
|
name="armor",
|
||||||
|
field=models.PositiveSmallIntegerField(default=0, verbose_name="armure"),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="character",
|
||||||
|
name="defense_misc",
|
||||||
|
field=models.SmallIntegerField(default=0, verbose_name="divers défense"),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="character",
|
||||||
|
name="shield",
|
||||||
|
field=models.PositiveSmallIntegerField(default=0, verbose_name="bouclier"),
|
||||||
|
),
|
||||||
|
]
|
25
src/character/migrations/0024_alter_character_notes.py
Normal file
25
src/character/migrations/0024_alter_character_notes.py
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# Generated by Django 4.1.2 on 2022-10-30 23:42
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
(
|
||||||
|
"character",
|
||||||
|
"0023_alter_character_armor_alter_character_defense_misc_and_more",
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="character",
|
||||||
|
name="notes",
|
||||||
|
field=models.TextField(
|
||||||
|
blank=True,
|
||||||
|
default="#### Traits personnalisés\n\n#### Objectifs\n\n#### Langages\n\n#### Historique\n\n#### Handicaps\n\n#### Alignement\n\n#### Relations\n\n#### Religion\n",
|
||||||
|
verbose_name="notes",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -1 +1 @@
|
||||||
0020_alter_weapon_category
|
0024_alter_character_notes
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
|
import markdown
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models.functions import Lower
|
from django.db.models.functions import Lower
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
@ -49,6 +50,8 @@ class Race(DocumentedModel, UniquelyNamedModel, TimeStampedModel, models.Model):
|
||||||
|
|
||||||
|
|
||||||
def modifier(value: int) -> int:
|
def modifier(value: int) -> int:
|
||||||
|
if not value:
|
||||||
|
return 0
|
||||||
if 1 < value < 10:
|
if 1 < value < 10:
|
||||||
value -= 1
|
value -= 1
|
||||||
value -= 10
|
value -= 10
|
||||||
|
@ -60,6 +63,25 @@ class CharacterManager(models.Manager):
|
||||||
return self.get(name=name, player_id=player_id)
|
return self.get(name=name, player_id=player_id)
|
||||||
|
|
||||||
|
|
||||||
|
DEFAULT_NOTES = """
|
||||||
|
#### Traits personnalisés
|
||||||
|
|
||||||
|
#### Objectifs
|
||||||
|
|
||||||
|
#### Langages
|
||||||
|
|
||||||
|
#### Historique
|
||||||
|
|
||||||
|
#### Handicaps
|
||||||
|
|
||||||
|
#### Alignement
|
||||||
|
|
||||||
|
#### Relations
|
||||||
|
|
||||||
|
#### Religion
|
||||||
|
""".lstrip()
|
||||||
|
|
||||||
|
|
||||||
class Character(models.Model):
|
class Character(models.Model):
|
||||||
class Gender(models.TextChoices):
|
class Gender(models.TextChoices):
|
||||||
MALE = "M", "Mâle"
|
MALE = "M", "Mâle"
|
||||||
|
@ -86,7 +108,7 @@ class Character(models.Model):
|
||||||
related_name="characters",
|
related_name="characters",
|
||||||
verbose_name="profil",
|
verbose_name="profil",
|
||||||
)
|
)
|
||||||
level = models.PositiveSmallIntegerField(verbose_name="niveau")
|
level = models.PositiveSmallIntegerField(verbose_name="niveau", default=1)
|
||||||
|
|
||||||
gender = models.CharField(
|
gender = models.CharField(
|
||||||
max_length=1, choices=Gender.choices, default=Gender.OTHER, verbose_name="genre"
|
max_length=1, choices=Gender.choices, default=Gender.OTHER, verbose_name="genre"
|
||||||
|
@ -122,9 +144,9 @@ class Character(models.Model):
|
||||||
"character.Weapon", blank=True, verbose_name="armes"
|
"character.Weapon", blank=True, verbose_name="armes"
|
||||||
)
|
)
|
||||||
|
|
||||||
armor = models.PositiveSmallIntegerField(verbose_name="armure")
|
armor = models.PositiveSmallIntegerField(verbose_name="armure", default=0)
|
||||||
shield = models.PositiveSmallIntegerField(verbose_name="bouclier")
|
shield = models.PositiveSmallIntegerField(verbose_name="bouclier", default=0)
|
||||||
defense_misc = models.SmallIntegerField(verbose_name="divers défense")
|
defense_misc = models.SmallIntegerField(verbose_name="divers défense", default=0)
|
||||||
|
|
||||||
capabilities = models.ManyToManyField(
|
capabilities = models.ManyToManyField(
|
||||||
"character.Capability", blank=True, verbose_name="capacités"
|
"character.Capability", blank=True, verbose_name="capacités"
|
||||||
|
@ -148,7 +170,7 @@ class Character(models.Model):
|
||||||
default=5, verbose_name="points de récupération restants"
|
default=5, verbose_name="points de récupération restants"
|
||||||
)
|
)
|
||||||
|
|
||||||
notes = models.TextField(blank=True, verbose_name="notes")
|
notes = models.TextField(blank=True, verbose_name="notes", default=DEFAULT_NOTES)
|
||||||
damage_reduction = models.TextField(blank=True, verbose_name="réduction de dégâts")
|
damage_reduction = models.TextField(blank=True, verbose_name="réduction de dégâts")
|
||||||
|
|
||||||
objects = CharacterManager()
|
objects = CharacterManager()
|
||||||
|
@ -277,3 +299,7 @@ class Character(models.Model):
|
||||||
key=lambda x: x[0].name,
|
key=lambda x: x[0].name,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_formatted_notes(self) -> str:
|
||||||
|
md = markdown.Markdown(extensions=["extra", "nl2br"])
|
||||||
|
return md.convert(self.notes)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div class="row" id="notes">
|
<div class="mt-3" id="notes">
|
||||||
<h4 class="mt-3">
|
<h2>
|
||||||
Notes
|
Notes
|
||||||
<a hx-get="{% url "character:notes_change" pk=character.pk %}"
|
<a hx-get="{% url "character:notes_change" pk=character.pk %}"
|
||||||
hx-target="#notes"
|
hx-target="#notes"
|
||||||
|
@ -8,6 +8,6 @@
|
||||||
>
|
>
|
||||||
<i class="fa-solid fa-pen-to-square"></i> Edit
|
<i class="fa-solid fa-pen-to-square"></i> Edit
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
</h2>
|
||||||
{{ character.notes|linebreaks }}
|
{{ character.get_formatted_notes|safe }}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<div class="row" id="notes">
|
<div class="mt-3" id="notes">
|
||||||
<form>
|
<form>
|
||||||
<h4 class="mt-3">
|
<h4>
|
||||||
Notes
|
Notes
|
||||||
<a hx-post="{% url "character:notes_change" pk=character.pk %}"
|
<a hx-post="{% url "character:notes_change" pk=character.pk %}"
|
||||||
hx-target="#notes"
|
hx-target="#notes"
|
||||||
|
|
|
@ -335,7 +335,7 @@
|
||||||
{% include "character/equipment_display.html" %}
|
{% include "character/equipment_display.html" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h4>Voies & Capacités</h4>
|
<h2>Voies & Capacités</h2>
|
||||||
<div class="row gy-3">
|
<div class="row gy-3">
|
||||||
{% for path, capabilities in character.get_capabilities_by_path.items %}
|
{% for path, capabilities in character.get_capabilities_by_path.items %}
|
||||||
<div class="col-xl-3 col-md-6">
|
<div class="col-xl-3 col-md-6">
|
||||||
|
|
Loading…
Reference in a new issue