This document explains the enhanced character system with comprehensive data management and AI integration.
The character system consists of several integrated components:
character.js
) - Core character creation and managementcharacterDataManager.js
) - Data persistence and storagecharacterIntegration.js
) - Integration with game systemsThe main character management system that handles:
// Create a new character
const character = characterManager.createCharacter({
name: "Aelindra Moonwhisper",
race: "Elf",
class: "Ranger",
background: "Folk Hero"
});
// Get character sheet display
const sheet = characterManager.getCharacterSheet(character);
// Update character progression
characterManager.levelUpCharacter(character, newLevel);
Characters are stored with comprehensive information:
{
// Basic Identity
name: "Character Name",
race: "Race",
class: "Class",
background: "Background",
level: 1,
experience: 0,
// Core Statistics
stats: {
str: 10, dex: 10, con: 10,
int: 10, wis: 10, cha: 10
},
// Health and Vitals
health: {
current: 25,
maximum: 25,
temporary: 0
},
// Skills and Proficiencies
skills: {
"Acrobatics": { modifier: 2, proficient: true },
"Investigation": { modifier: 4, proficient: true }
// ... more skills
},
// Equipment and Inventory
inventory: [
{ name: "Longbow", type: "weapon", equipped: true },
{ name: "Leather Armor", type: "armor", equipped: true }
],
// Character Development
personality_traits: ["Trait 1", "Trait 2"],
ideals: ["Ideal"],
bonds: ["Bond"],
flaws: ["Flaw"]
}
The system supports multiple campaign settings:
Each setting includes:
// The system auto-initializes, but you can also manually initialize
await initializeCharacterSystem();
// Access the character data manager
const character = characterDataManager.character;
console.log(character.basic_info.name); // Character name
// Update character stats
characterDataManager.updateStat('str', 16);
characterDataManager.updateHealth(85, 120);
characterDataManager.addExperience(250);
// Manage inventory
const sword = {
name: "Magic Sword +1",
type: "weapon",
damage: "1d8+1",
magical: true
};
characterDataManager.addItem(sword);
// Quest management
const quest = {
title: "Save the Village",
description: "Rescue villagers from bandits",
objectives: [
{ description: "Find the bandit camp", completed: false },
{ description: "Defeat the bandit leader", completed: false }
]
};
characterDataManager.addQuest(quest);
The system automatically integrates with your existing DiceTales code:
// Character creation is automatically enhanced
// When character creation completes, detailed data is created
// AI system gets enhanced context
const aiContext = characterDataManager.getAIContext();
// Returns comprehensive character info for AI interactions
// Inventory tracking is enhanced
// When AI adds items, they're automatically stored in detailed format
// Experience and leveling work seamlessly
// Level ups automatically update all dependent values
// Get character information
const basicInfo = characterDataManager.getBasicInfo();
const stats = characterDataManager.getStats();
const health = characterDataManager.getHealth();
const items = characterDataManager.getAllItems();
// Update character data
characterDataManager.updateStat('dex', 14);
characterDataManager.addExperience(100);
characterDataManager.updateHealth(currentHP, maxHP);
// Quest management
characterDataManager.addQuest(questData);
characterDataManager.completeQuest('quest_id', 'success');
// Campaign flags
characterDataManager.setCampaignFlag('met_king', true);
const hasMetKing = characterDataManager.getCampaignFlag('met_king');
// Save/load
characterDataManager.saveCharacter();
await characterDataManager.loadCharacter();
The character.json follows this high-level structure:
{
"version": "2.0.0",
"metadata": { /* Creation/update info */ },
"basic_info": { /* Name, class, level, etc. */ },
"campaign_setting": { /* Setting type and details */ },
"ability_scores": { /* Stats, modifiers, setting names */ },
"health_and_vitals": { /* HP, AC, initiative, etc. */ },
"class_features": { /* Class abilities and features */ },
"skills": { /* All skills with proficiencies */ },
"equipment": { /* Detailed item tracking */ },
"progression": { /* XP, level progression */ },
"personality": { /* Traits, ideals, bonds, flaws */ },
"backstory": { /* Background and personal history */ },
"roleplay_notes": { /* Voice, motivations, quirks */ },
"campaign_data": { /* Quests, NPCs, locations */ },
"game_mechanics": { /* Initiative, saves, conditions */ },
"ai_context": { /* AI personality hints */ },
"import_export": { /* Compatibility settings */ }
}
If you have an existing character in the old system:
You can customize the character data by:
character.json
directly for detailed changescharacterDataManager
methods in your codeCharacterDataManager
class with new methodsThe system supports exporting character data for:
// Export character
const exportData = characterDataManager.exportCharacter('json');
// Save to file (in a full application)
const blob = new Blob([exportData], { type: 'application/json' });
// ... handle file download
// Import character (from file input)
await characterDataManager.loadCharacter('./path/to/character.json');
The character system is designed to be powerful yet easy to use, providing a comprehensive foundation for character management in DiceTales.