add carac bonus

This commit is contained in:
Gabriel Augendre 2024-02-11 11:37:32 +01:00
parent effb578eba
commit 6caa31c553
6 changed files with 116 additions and 16 deletions

View file

@ -4,6 +4,8 @@
[tool.ruff] [tool.ruff]
src = ["src"] src = ["src"]
target-version = "py311" target-version = "py311"
[tool.ruff.lint]
select = ["ALL"] select = ["ALL"]
unfixable = ["T20", "RUF001", "RUF002", "RUF003"] unfixable = ["T20", "RUF001", "RUF002", "RUF003"]
@ -18,7 +20,7 @@ ignore = [
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
] ]
[tool.ruff.per-file-ignores] [tool.ruff.lint.per-file-ignores]
"**/tests/*" = [ "**/tests/*" = [
"S101", # Use of assert detected. "S101", # Use of assert detected.
"S106", # Possible hardcoded password. "S106", # Possible hardcoded password.
@ -36,10 +38,10 @@ ignore = [
"RUF001", # String contains ambiguous unicode character "RUF001", # String contains ambiguous unicode character
] ]
[tool.ruff.pydocstyle] [tool.ruff.lint.pydocstyle]
convention = "pep257" convention = "pep257"
[tool.ruff.mccabe] [tool.ruff.lint.mccabe]
max-complexity = 10 max-complexity = 10
[tool.pytest.ini_options] [tool.pytest.ini_options]

View file

@ -79,6 +79,12 @@ class CharacterForm(forms.ModelForm):
"value_intelligence", "value_intelligence",
"value_wisdom", "value_wisdom",
"value_charisma", "value_charisma",
"bonus_strength",
"bonus_dexterity",
"bonus_constitution",
"bonus_intelligence",
"bonus_wisdom",
"bonus_charisma",
"health_max", "health_max",
"racial_capability", "racial_capability",
"weapons", "weapons",

View file

@ -0,0 +1,61 @@
# Generated by Django 4.2.9 on 2024-02-11 10:29
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("character", "0043_character_paths"),
]
operations = [
migrations.AddField(
model_name="character",
name="bonus_charisma",
field=models.PositiveSmallIntegerField(
default=0,
verbose_name="bonus charisme",
),
),
migrations.AddField(
model_name="character",
name="bonus_constitution",
field=models.PositiveSmallIntegerField(
default=0,
verbose_name="bonus constitution",
),
),
migrations.AddField(
model_name="character",
name="bonus_dexterity",
field=models.PositiveSmallIntegerField(
default=0,
verbose_name="bonus dextérité",
),
),
migrations.AddField(
model_name="character",
name="bonus_intelligence",
field=models.PositiveSmallIntegerField(
default=0,
verbose_name="bonus intelligence",
),
),
migrations.AddField(
model_name="character",
name="bonus_strength",
field=models.PositiveSmallIntegerField(
default=0,
verbose_name="bonus force",
),
),
migrations.AddField(
model_name="character",
name="bonus_wisdom",
field=models.PositiveSmallIntegerField(
default=0,
verbose_name="bonus sagesse",
),
),
]

View file

@ -1 +1 @@
0043_character_paths 0044_character_bonus_charisma_and_more

View file

@ -223,6 +223,31 @@ class Character(models.Model):
value_wisdom = models.PositiveSmallIntegerField(verbose_name="valeur sagesse") value_wisdom = models.PositiveSmallIntegerField(verbose_name="valeur sagesse")
value_charisma = models.PositiveSmallIntegerField(verbose_name="valeur charisme") value_charisma = models.PositiveSmallIntegerField(verbose_name="valeur charisme")
bonus_strength = models.PositiveSmallIntegerField(
default=0,
verbose_name="bonus force",
)
bonus_dexterity = models.PositiveSmallIntegerField(
default=0,
verbose_name="bonus dextérité",
)
bonus_constitution = models.PositiveSmallIntegerField(
default=0,
verbose_name="bonus constitution",
)
bonus_intelligence = models.PositiveSmallIntegerField(
default=0,
verbose_name="bonus intelligence",
)
bonus_wisdom = models.PositiveSmallIntegerField(
default=0,
verbose_name="bonus sagesse",
)
bonus_charisma = models.PositiveSmallIntegerField(
default=0,
verbose_name="bonus charisme",
)
health_max = models.PositiveSmallIntegerField(verbose_name="points de vie max") health_max = models.PositiveSmallIntegerField(verbose_name="points de vie max")
health_remaining = models.PositiveSmallIntegerField( health_remaining = models.PositiveSmallIntegerField(
verbose_name="points de vie restants", verbose_name="points de vie restants",
@ -314,27 +339,27 @@ class Character(models.Model):
@property @property
def modifier_strength(self) -> int: def modifier_strength(self) -> int:
return modifier(self.value_strength) return modifier(self.value_strength) + self.bonus_strength
@property @property
def modifier_dexterity(self) -> int: def modifier_dexterity(self) -> int:
return modifier(self.value_dexterity) return modifier(self.value_dexterity) + self.bonus_dexterity
@property @property
def modifier_constitution(self) -> int: def modifier_constitution(self) -> int:
return modifier(self.value_constitution) return modifier(self.value_constitution) + self.bonus_constitution
@property @property
def modifier_intelligence(self) -> int: def modifier_intelligence(self) -> int:
return modifier(self.value_intelligence) return modifier(self.value_intelligence) + self.bonus_intelligence
@property @property
def modifier_wisdom(self) -> int: def modifier_wisdom(self) -> int:
return modifier(self.value_wisdom) return modifier(self.value_wisdom) + self.bonus_wisdom
@property @property
def modifier_charisma(self) -> int: def modifier_charisma(self) -> int:
return modifier(self.value_charisma) return modifier(self.value_charisma) + self.bonus_charisma
@property @property
def modifier_initiative(self) -> int: def modifier_initiative(self) -> int:

View file

@ -31,12 +31,18 @@
</div> </div>
<h2>Compétences</h2> <h2>Compétences</h2>
<div class="row"> <div class="row">
<div class="col-md-2">{% bootstrap_field form.value_strength %}</div> <div class="col-lg-2 col-md-3 col-6">{% bootstrap_field form.value_strength %}</div>
<div class="col-md-2">{% bootstrap_field form.value_dexterity %}</div> <div class="col-lg-2 col-md-3 col-6">{% bootstrap_field form.bonus_strength %}</div>
<div class="col-md-2">{% bootstrap_field form.value_constitution %}</div> <div class="col-lg-2 col-md-3 col-6">{% bootstrap_field form.value_dexterity %}</div>
<div class="col-md-2">{% bootstrap_field form.value_intelligence %}</div> <div class="col-lg-2 col-md-3 col-6">{% bootstrap_field form.bonus_dexterity %}</div>
<div class="col-md-2">{% bootstrap_field form.value_wisdom %}</div> <div class="col-lg-2 col-md-3 col-6">{% bootstrap_field form.value_constitution %}</div>
<div class="col-md-2">{% bootstrap_field form.value_charisma %}</div> <div class="col-lg-2 col-md-3 col-6">{% bootstrap_field form.bonus_constitution %}</div>
<div class="col-lg-2 col-md-3 col-6">{% bootstrap_field form.value_intelligence %}</div>
<div class="col-lg-2 col-md-3 col-6">{% bootstrap_field form.bonus_intelligence %}</div>
<div class="col-lg-2 col-md-3 col-6">{% bootstrap_field form.value_wisdom %}</div>
<div class="col-lg-2 col-md-3 col-6">{% bootstrap_field form.bonus_wisdom %}</div>
<div class="col-lg-2 col-md-3 col-6">{% bootstrap_field form.value_charisma %}</div>
<div class="col-lg-2 col-md-3 col-6">{% bootstrap_field form.bonus_charisma %}</div>
</div> </div>
<h2>Protection</h2> <h2>Protection</h2>
<div class="row"> <div class="row">