mirror of
https://github.com/Threnklyn/dungeon-sheets.git
synced 2026-06-07 13:15:53 +02:00
Fixed a bug where skill names with spaces were not recognized as proficient.
This commit is contained in:
+11
-1
@@ -1,6 +1,7 @@
|
||||
import math
|
||||
from collections import namedtuple
|
||||
from math import ceil
|
||||
import logging
|
||||
|
||||
from dungeonsheets.armor import Armor, HeavyArmor, NoArmor, NoShield, Shield
|
||||
from dungeonsheets.features import (
|
||||
@@ -27,6 +28,9 @@ from dungeonsheets.features import (
|
||||
from dungeonsheets.weapons import Weapon
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def mod_str(modifier):
|
||||
"""Converts a modifier to a string, eg 2 -> '+2'."""
|
||||
return "{:+d}".format(modifier)
|
||||
@@ -85,10 +89,14 @@ class Skill:
|
||||
self.character = entity
|
||||
|
||||
def __get__(self, entity, owner):
|
||||
log.debug("Getting skill '%s' for '%s'",
|
||||
self.skill_name, entity.name)
|
||||
ability = getattr(entity, self.ability_name)
|
||||
modifier = ability.modifier
|
||||
# Check for proficiency
|
||||
is_proficient = self.skill_name in entity.skill_proficiencies
|
||||
proficiencies = [p.replace("_", " ") for p in entity.skill_proficiencies]
|
||||
is_proficient = self.skill_name in proficiencies
|
||||
log.debug("%s is proficient in %s: %s", entity.name, self.skill_name, is_proficient)
|
||||
if is_proficient:
|
||||
modifier += entity.proficiency_bonus
|
||||
elif entity.has_feature(JackOfAllTrades):
|
||||
@@ -101,6 +109,8 @@ class Skill:
|
||||
is_expert = self.skill_name in entity.skill_expertise
|
||||
if is_expert:
|
||||
modifier += entity.proficiency_bonus
|
||||
log.debug("'%s' modifier for '%s': %d",
|
||||
self.skill_name, entity.name, modifier)
|
||||
return modifier
|
||||
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ class TestStats(TestCase):
|
||||
class MyClass(character.Character):
|
||||
dexterity = stats.Ability(14)
|
||||
acrobatics = stats.Skill(ability="dexterity")
|
||||
sleight_of_hand = stats.Skill(ability="dexterity")
|
||||
skill_proficiencies = []
|
||||
proficiency_bonus = 2
|
||||
|
||||
@@ -80,3 +81,6 @@ class TestStats(TestCase):
|
||||
# Check for a proficiency
|
||||
my_class.skill_proficiencies = ["acrobatics"]
|
||||
self.assertEqual(my_class.acrobatics, 4)
|
||||
# Check for a proficiency with spaces in the name
|
||||
my_class.skill_proficiencies = ["sleight_of_hand"]
|
||||
self.assertEqual(my_class.sleight_of_hand, 4)
|
||||
|
||||
Reference in New Issue
Block a user