diff --git a/src/character/templates/character/view.html b/src/character/templates/character/view.html index 7b4f1d2..185d3db 100644 --- a/src/character/templates/character/view.html +++ b/src/character/templates/character/view.html @@ -1,4 +1,5 @@ {% extends "common/base.html" %} +{% load character_extras %} {% block title %}{{ character.name }}{% endblock %} @@ -28,32 +29,32 @@ FOR {{ character.value_strength }} - {{ character.modifier_strength }} + {{ character.modifier_strength|modifier }} DEX {{ character.value_dexterity }} - {{ character.modifier_dexterity }} + {{ character.modifier_dexterity|modifier }} CON {{ character.value_constitution }} - {{ character.modifier_constitution }} + {{ character.modifier_constitution|modifier }} INT {{ character.value_intelligence }} - {{ character.modifier_intelligence }} + {{ character.modifier_intelligence|modifier }} SAG {{ character.value_wisdom }} - {{ character.modifier_wisdom }} + {{ character.modifier_wisdom|modifier }} CHA {{ character.value_charisma }} - {{ character.modifier_charisma }} + {{ character.modifier_charisma|modifier }} @@ -70,15 +71,15 @@ Att. contact - {{ character.attack_melee }} + {{ character.attack_melee|modifier }} Att. distance - {{ character.attack_range }} + {{ character.attack_range|modifier }} Att. magique - {{ character.attack_magic }} + {{ character.attack_magic|modifier }} Défense diff --git a/src/character/templatetags/__init__.py b/src/character/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/character/templatetags/character_extras.py b/src/character/templatetags/character_extras.py new file mode 100644 index 0000000..4af1ded --- /dev/null +++ b/src/character/templatetags/character_extras.py @@ -0,0 +1,11 @@ +from django import template + +register = template.Library() + + +@register.filter +def modifier(value): + if value > 0: + return f"+{value}" + else: + return value