Working on character objects

This commit is contained in:
Mechseroms 2025-11-02 10:36:52 -06:00
parent 94bab9811b
commit 4358b68d6a
4 changed files with 541 additions and 225 deletions

222
backend/ATTRIBUTES.md Normal file
View File

@ -0,0 +1,222 @@
# D&D 5e Character Attributes
This document outlines all the core and expanded character attributes that should be tracked for D&D 5e gameplay. Attributes are grouped by category, reflecting dependencies and standard D&D 5e game structure.
---
## Base Attributes (Not Derived; static unless leveled up/class change)
- @name: Character name
- @level: Character level
- @race: Chosen race (grants features/traits)
- @subrace: Optional, for races with subtypes
- @class: Chosen class
- @subclass: Optional archetype/subclass
- @background: Character background (e.g., Soldier, Sage)
- @alignment: Law/Chaos & Good/Evil axis
- @size: (e.g., Medium, Small)
- @age: Character's age
- @gender: Gender identity
- @height: Physical height
- @weight: Physical weight
- @deity: (optional)
---
## Core Abilities (Derived, Priority 1—calculate first)
### Base Scores
- @strength::base
- @dexterity::base
- @constitution::base
- @intelligence::base
- @wisdom::base
- @charisma::base
- @armor::base
### Effective Scores (after modifiers, racial/class bonuses, etc.)
- @strength
- @dexterity
- @constitution
- @intelligence
- @wisdom
- @charisma
- @armor
### Modifiers
- @strength::modifier
- @dexterity::modifier
- @constitution::modifier
- @intelligence::modifier
- @wisdom::modifier
- @charisma::modifier
### General
- @proficiency: Proficiency bonus (scales with level)
- @inspiration: Boolean (True/False)
- @experience: XP points
---
## Proficiencies & Languages
- @proficiencies::armor
- @proficiencies::weapons
- @proficiencies::tools
- @languages
---
## Saving Throws (Priority 2)
- @strength_save
- @dexterity_save
- @constitution_save
- @intelligence_save
- @wisdom_save
- @charisma_save
---
## HP, Initiative, Related (Priority 2)
- @hp (current)
- @hp_max
- @hp_temp
- @hit_die (e.g., d8, d10; and total available)
- @initiative (includes initiative modifier)
- @armor (effective AC)
### Death Saves
- @deathsaves::successes
- @deathsaves::failures
---
## Resistances & Immunities (Priority 2)
- @fire_resistance
- @poison_resistance
- @psychic_resistance
- @cold_resistance
- @thunder_resistance
- @acid_resistance
- @force_resistance
- @radiant_resistance
- @necrotic_resistance
- @bludgeoning_resistance
- @piercing_resistance
- @slashing_resistance
- ... (more as needed)
- @immunities (list)
- @vulnerabilities (list)
---
## Senses & Mobility (Priority 2)
- @speed::base (default/unencumbered movement)
- @speed::type (flying, climbing, swimming—if applicable)
- @darkvision
- @blindsight
- @tremorsense
- @truesight
- @passive_perception
---
## Skills (Priority 2)
#### Strength
- @athletics
#### Dexterity
- @acrobatics
- @sleight_of_hand
- @stealth
#### Intelligence
- @arcana
- @history
- @investigation
- @nature
- @religion
#### Wisdom
- @animal_handling
- @insight
- @medicine
- @perception
- @survival
#### Charisma
- @deception
- @intimidation
- @performance
- @persuasion
---
## Passives / Post-Derived Attributes (Priority 3)
- @athletics#passive
- @acrobatics#passive
- @sleight_of_hand#passive
- @stealth#passive
- @arcana#passive
- @history#passive
- @investigation#passive
- @nature#passive
- @religion#passive
- @animal_handling#passive
- @insight#passive
- @medicine#passive
- @perception#passive
- @survival#passive
- @deception#passive
- @intimidation#passive
- @performance#passive
- @persuasion#passive
- @passive_perception
- @passive_investigation
- @passive_insight
---
## Spellcasting (if applicable)
- @spellcasting_ability (e.g., Intelligence)
- @spell_save_dc
- @spell_attack_bonus
- @known_spells (list)
- @prepared_spells (if required)
- @spell_slots (level-indexed: e.g., 1st:2, 2nd:1)
- @cantrips (list)
- @spellcasting_class
---
## Condition Tracking
- @exhaustion_level
- @conditions_active (list; e.g., blinded, charmed, frightened, etc.)
---
## Currency & Inventory
- @cp (copper)
- @sp (silver)
- @ep (electrum)
- @gp (gold)
- @pp (platinum)
- @equipment (list or structured)
---
## Features & Traits
- @features (class, race, background features—list)
- @feats (optional/variant rule)
- @traits (racial, personality, ideals, bonds, flaws)
- @personality_traits
- @ideals
- @bonds
- @flaws
---
## Others & Miscellaneous
- @notes (free text)
- @custom_attributes (dict or list)
---
This schema is suitable for comprehensive D&D 5e character management. Expand or contract as needed for house rules, modules, or additional systems.

161
backend/character.py Normal file
View File

@ -0,0 +1,161 @@
from dataclasses import dataclass, field
from typing import List, Dict, Any
@dataclass
class Character:
name: str = ""
level: int = 0
race: str = ""
subrace: str = ""
class_: str = ""
subclass: str = ""
background: str = ""
alignment: str = ""
size: str = ""
age: int = 0
gender: str = ""
height: str = ""
weight: int = 0
deity: str = ""
strength_base: int = 0
dexterity_base: int = 0
constitution_base: int = 0
intelligence_base: int = 0
wisdom_base: int = 0
charisma_base: int = 0
armor_base: int = 0
strength: int = 0
dexterity: int = 0
constitution: int = 0
intelligence: int = 0
wisdom: int = 0
charisma: int = 0
armor: int = 0
strength_modifier: int = 0
dexterity_modifier: int = 0
constitution_modifier: int = 0
intelligence_modifier: int = 0
wisdom_modifier: int = 0
charisma_modifier: int = 0
proficiency: int = 0
inspiration: bool = False
experience: int = 0
proficiencies_armor: List[str] = field(default_factory=list)
proficiencies_weapons: List[str] = field(default_factory=list)
proficiencies_tools: List[str] = field(default_factory=list)
languages: List[str] = field(default_factory=list)
strength_save: int = 0
dexterity_save: int = 0
constitution_save: int = 0
intelligence_save: int = 0
wisdom_save: int = 0
charisma_save: int = 0
hp: int = 0
hp_max: int = 0
hp_temp: int = 0
hit_die: str = ""
initiative: int = 0
deathsaves_successes: int = 0
deathsaves_failures: int = 0
fire_resistance: bool = False
poison_resistance: bool = False
psychic_resistance: bool = False
cold_resistance: bool = False
thunder_resistance: bool = False
acid_resistance: bool = False
force_resistance: bool = False
radiant_resistance: bool = False
necrotic_resistance: bool = False
bludgeoning_resistance: bool = False
piercing_resistance: bool = False
slashing_resistance: bool = False
immunities: List[str] = field(default_factory=list)
vulnerabilities: List[str] = field(default_factory=list)
speed_base: int = 0
speed_type: List[str] = field(default_factory=list)
darkvision: int = 0
blindsight: int = 0
tremorsense: int = 0
truesight: int = 0
passive_perception: int = 0
athletics: int = 0
acrobatics: int = 0
sleight_of_hand: int = 0
stealth: int = 0
arcana: int = 0
history: int = 0
investigation: int = 0
nature: int = 0
religion: int = 0
animal_handling: int = 0
insight: int = 0
medicine: int = 0
perception: int = 0
survival: int = 0
deception: int = 0
intimidation: int = 0
performance: int = 0
persuasion: int = 0
athletics_passive: int = 0
acrobatics_passive: int = 0
sleight_of_hand_passive: int = 0
stealth_passive: int = 0
arcana_passive: int = 0
history_passive: int = 0
investigation_passive: int = 0
nature_passive: int = 0
religion_passive: int = 0
animal_handling_passive: int = 0
insight_passive: int = 0
medicine_passive: int = 0
perception_passive: int = 0
survival_passive: int = 0
deception_passive: int = 0
intimidation_passive: int = 0
performance_passive: int = 0
persuasion_passive: int = 0
passive_perception: int = 0
passive_investigation: int = 0
passive_insight: int = 0
spellcasting_ability: str = ""
spell_save_dc: int = 0
spell_attack_bonus: int = 0
known_spells: List[str] = field(default_factory=list)
prepared_spells: List[str] = field(default_factory=list)
spell_slots: Dict[str, Any] = field(default_factory=dict)
cantrips: List[str] = field(default_factory=list)
spellcasting_class: str = ""
exhaustion_level: int = 0
conditions_active: List[str] = field(default_factory=list)
cp: int = 0
sp: int = 0
ep: int = 0
gp: int = 0
pp: int = 0
equipment: List[str] = field(default_factory=list)
features: List[str] = field(default_factory=list)
feats: List[str] = field(default_factory=list)
traits: List[str] = field(default_factory=list)
personality_traits: List[str] = field(default_factory=list)
ideals: List[str] = field(default_factory=list)
bonds: List[str] = field(default_factory=list)
flaws: List[str] = field(default_factory=list)
notes: str = ""
custom_attributes: Dict[str, Any] = field(default_factory=dict)

158
backend/template.json Normal file
View File

@ -0,0 +1,158 @@
{
"name": "",
"level": 0,
"race": "",
"subrace": "",
"class": "",
"subclass": "",
"background": "",
"alignment": "",
"size": "",
"age": 0,
"gender": "",
"height": "",
"weight": 0,
"deity": "",
"strength_base": 0,
"dexterity_base": 0,
"constitution_base": 0,
"intelligence_base": 0,
"wisdom_base": 0,
"charisma_base": 0,
"armor_base": 0,
"strength": 0,
"dexterity": 0,
"constitution": 0,
"intelligence": 0,
"wisdom": 0,
"charisma": 0,
"armor": 0,
"strength_modifier": 0,
"dexterity_modifier": 0,
"constitution_modifier": 0,
"intelligence_modifier": 0,
"wisdom_modifier": 0,
"charisma_modifier": 0,
"proficiency": 0,
"inspiration": false,
"experience": 0,
"proficiencies_armor": [],
"proficiencies_weapons": [],
"proficiencies_tools": [],
"languages": [],
"strength_save": 0,
"dexterity_save": 0,
"constitution_save": 0,
"intelligence_save": 0,
"wisdom_save": 0,
"charisma_save": 0,
"hp": 0,
"hp_max": 0,
"hp_temp": 0,
"hit_die": "",
"initiative": 0,
"deathsaves_successes": 0,
"deathsaves_failures": 0,
"fire_resistance": false,
"poison_resistance": false,
"psychic_resistance": false,
"cold_resistance": false,
"thunder_resistance": false,
"acid_resistance": false,
"force_resistance": false,
"radiant_resistance": false,
"necrotic_resistance": false,
"bludgeoning_resistance": false,
"piercing_resistance": false,
"slashing_resistance": false,
"immunities": [],
"vulnerabilities": [],
"speed_base": 0,
"speed_type": [],
"darkvision": 0,
"blindsight": 0,
"tremorsense": 0,
"truesight": 0,
"passive_perception": 0,
"athletics": 0,
"acrobatics": 0,
"sleight_of_hand": 0,
"stealth": 0,
"arcana": 0,
"history": 0,
"investigation": 0,
"nature": 0,
"religion": 0,
"animal_handling": 0,
"insight": 0,
"medicine": 0,
"perception": 0,
"survival": 0,
"deception": 0,
"intimidation": 0,
"performance": 0,
"persuasion": 0,
"athletics_passive": 0,
"acrobatics_passive": 0,
"sleight_of_hand_passive": 0,
"stealth_passive": 0,
"arcana_passive": 0,
"history_passive": 0,
"investigation_passive": 0,
"nature_passive": 0,
"religion_passive": 0,
"animal_handling_passive": 0,
"insight_passive": 0,
"medicine_passive": 0,
"perception_passive": 0,
"survival_passive": 0,
"deception_passive": 0,
"intimidation_passive": 0,
"performance_passive": 0,
"persuasion_passive": 0,
"passive_perception": 0,
"passive_investigation": 0,
"passive_insight": 0,
"spellcasting_ability": "",
"spell_save_dc": 0,
"spell_attack_bonus": 0,
"known_spells": [],
"prepared_spells": [],
"spell_slots": {},
"cantrips": [],
"spellcasting_class": "",
"exhaustion_level": 0,
"conditions_active": [],
"cp": 0,
"sp": 0,
"ep": 0,
"gp": 0,
"pp": 0,
"equipment": [],
"features": [],
"feats": [],
"traits": [],
"personality_traits": [],
"ideals": [],
"bonds": [],
"flaws": [],
"notes": "",
"custom_attributes": {}
}

View File

@ -1,225 +0,0 @@
{
"$schema": "https://opencode.ai/theme.json",
"defs": {
"color0": "{color0}",
"color1": "{color1}",
"color2": "{color2}",
"color3": "{color3}",
"color4": "{color4}",
"color5": "{color5}",
"color6": "{color6}",
"color7": "{color7}",
"color8": "{color8}",
"color9": "{color9}",
"color10": "{color10}",
"color11": "{color11}",
"color12": "{color12}",
"color13": "{color13}",
"color14": "{color14}",
"color15": "{color15}",
"background": "{background}",
"foreground": "{foreground}"
},
"theme": {
"primary": {
"dark": "color4",
"light": "color12"
},
"secondary": {
"dark": "color5",
"light": "color13"
},
"accent": {
"dark": "color6",
"light": "color6"
},
"error": {
"dark": "color1",
"light": "color9"
},
"warning": {
"dark": "color3",
"light": "color11"
},
"success": {
"dark": "color2",
"light": "color10"
},
"info": {
"dark": "color4",
"light": "color12"
},
"text": {
"dark": "foreground",
"light": "color0"
},
"textMuted": {
"dark": "color8",
"light": "color7"
},
"background": {
"dark": "background",
"light": "color15"
},
"backgroundPanel": {
"dark": "color8",
"light": "color7"
},
"backgroundElement": {
"dark": "color0",
"light": "color15"
},
"border": {
"dark": "color8",
"light": "color7"
},
"borderActive": {
"dark": "color7",
"light": "color8"
},
"borderSubtle": {
"dark": "color8",
"light": "color7"
},
"diffAdded": {
"dark": "color2",
"light": "color10"
},
"diffRemoved": {
"dark": "color1",
"light": "color9"
},
"diffContext": {
"dark": "color8",
"light": "color7"
},
"diffHunkHeader": {
"dark": "color8",
"light": "color7"
},
"diffHighlightAdded": {
"dark": "color2",
"light": "color10"
},
"diffHighlightRemoved": {
"dark": "color1",
"light": "color9"
},
"diffAddedBg": {
"dark": "color0",
"light": "color15"
},
"diffRemovedBg": {
"dark": "color0",
"light": "color15"
},
"diffContextBg": {
"dark": "color8",
"light": "color7"
},
"diffLineNumber": {
"dark": "color8",
"light": "color7"
},
"diffAddedLineNumberBg": {
"dark": "color0",
"light": "color15"
},
"diffRemovedLineNumberBg": {
"dark": "color0",
"light": "color15"
},
"markdownText": {
"dark": "foreground",
"light": "color0"
},
"markdownHeading": {
"dark": "color4",
"light": "color12"
},
"markdownLink": {
"dark": "color6",
"light": "color14"
},
"markdownLinkText": {
"dark": "color4",
"light": "color12"
},
"markdownCode": {
"dark": "color2",
"light": "color10"
},
"markdownBlockQuote": {
"dark": "color8",
"light": "color7"
},
"markdownEmph": {
"dark": "color3",
"light": "color11"
},
"markdownStrong": {
"dark": "color5",
"light": "color13"
},
"markdownHorizontalRule": {
"dark": "color8",
"light": "color7"
},
"markdownListItem": {
"dark": "color6",
"light": "color14"
},
"markdownListEnumeration": {
"dark": "color2",
"light": "color10"
},
"markdownImage": {
"dark": "color6",
"light": "color14"
},
"markdownImageText": {
"dark": "color2",
"light": "color10"
},
"markdownCodeBlock": {
"dark": "color0",
"light": "color15"
},
"syntaxComment": {
"dark": "color8",
"light": "color7"
},
"syntaxKeyword": {
"dark": "color4",
"light": "color12"
},
"syntaxFunction": {
"dark": "color6",
"light": "color14"
},
"syntaxVariable": {
"dark": "color5",
"light": "color13"
},
"syntaxString": {
"dark": "color2",
"light": "color10"
},
"syntaxNumber": {
"dark": "color3",
"light": "color11"
},
"syntaxType": {
"dark": "color4",
"light": "color12"
},
"syntaxOperator": {
"dark": "color1",
"light": "color9"
},
"syntaxPunctuation": {
"dark": "foreground",
"light": "color0"
}
}
}