ability
ability
Defines PlayerCharacter
abilities and their modifiers.
An Ability is an inherent trait possessed by every PlayerCharacter. There are several ability types, each of which can provide modifiers (bonuses or penalties) that affect gameplay mechanics like dice rolls or other properties of the character. For example, a high Dexterity score can make the character harder to hit in combat due to an AC modifier, and the character might know an additional language or two because they also have a high Intelligence score.
Usage:
You typically wouldn't create an instance of an Ability directly. Instead, you create an
instance of PlayerCharacter, and its abilities are instantiated as attributes
of the PlayerCharacter
instance automatically. You can then "roll" the character's ability scores by calling a method
on PlayerCharacter
.
from osrlib.enums import CharacterClassType
from osrlib.player_character import PlayerCharacter
def test_doc_player_character_create():
# Create a fighter PC and roll their abilities and hit points (HP)
fighter_pc = PlayerCharacter("Sckricko", CharacterClassType.FIGHTER)
fighter_pc.roll_abilities()
fighter_pc.roll_hp()
Ability
Ability(score: int)
Bases: ABC
Abstract base class for character abilities.
Attributes:
-
score
(int
) –The raw ability score.
-
modifiers
(dict
) –A mapping of the ability's modifier types to modifier values based on the ability score.
Parameters:
-
score
(int
) –The raw ability score.
from_dict
classmethod
get_earned_xp_adjustment
get_earned_xp_adjustment() -> float
Calculate the experience points adjustment based on the ability score.
Determines the percentage adjustment to experience points earned, based on the character's ability score. This adjustment can be positive or negative depending on the score.
Returns:
-
float
(float
) –The experience point adjustment as a decimal percentage.
Charisma
Charisma(score: int)
Constitution
Constitution(score: int)
Bases: Ability
Represents the Constitution ability for characters.
Constitution measures stamina, endurance, and overall health.
Modifiers:
- HP (ModifierType.HP): Modifies hit point (HP) rolls. For example, when initially rolling the character or when the character gains a level.
Parameters:
-
score
(int
) –The raw ability score.
Dexterity
Dexterity(score: int)
Bases: Ability
Represents the Dexterity ability for characters.
Dexterity measures agility, reflexes, and coordination.
Modifiers:
- TO_HIT (ModifierType.TO_HIT): Modifies ranged attack rolls.
- AC (ModifierType.AC): Modifies armor class (lower is better).
- INITIATIVE (ModifierType.INITIATIVE): Modifies initiative rolls.
Parameters:
-
score
(int
) –The raw ability score.
Intelligence
Intelligence(score: int)
Bases: Ability
Represents the Intelligence ability for characters.
Intelligence is a measure of problem-solving ability, linguistic capability, and magical aptitude.
Modifiers: - LANGUAGES (ModifierType.LANGUAGES): Modifies the number of additional languages the character can read and write.
Parameters:
-
score
(int
) –The raw ability score.
Strength
Strength(score: int)
Bases: Ability
Represents the Strength ability for characters.
Strength measures muscle power and the ability to use that power. It primarily influences hand-to-hand combat and opening doors.
Modifiers:
- TO_HIT (
ModifierType.TO_HIT
): Modifies melee (hand-to-hand) attack rolls. - DAMAGE (
ModifierType.DAMAGE
): Modifies damage in melee combat. - OPEN_DOORS (
ModifierType.OPEN_DOORS
): Modifies chances of opening stuck doors.
Parameters:
-
score
(int
) –The raw ability score.
Wisdom
Wisdom(score: int)