Add customizable RPG attributes and fix character stats editing
Features: - Made RPG attributes (STR/DEX/CON/INT/WIS/CHA) fully customizable - Added enable/disable toggle for entire RPG Attributes section - Users can add/remove/rename/toggle individual attributes - Custom attribute names now appear in AI prompts for dice rolls - Added proper CSS styling for attribute editor fields Bug Fixes: - Fixed character stat editing showing 0% on blur but saving correctly - Character stats now create Stats line if missing from AI response - Separated stat name from editable percentage value - Added value sanitization (removes %, validates 0-100 range) - Stats line now inserts before Thoughts line when created Technical: - Added buildAttributesString() helper in promptBuilder.js - Updated generateTrackerInstructions and generateContextualSummary - Restructured character stat HTML to prevent nested contenteditable - Enhanced updateCharacterField to handle missing Stats lines - Removed legacy default preset/regex import code
This commit is contained in:
@@ -179,10 +179,22 @@ export function renderUserStats() {
|
||||
html += '</div>'; // Close rpg-stats-left
|
||||
|
||||
// RPG Attributes section (dynamically generated from config)
|
||||
const rpgAttributes = config.rpgAttributes || [];
|
||||
const enabledAttributes = rpgAttributes.filter(attr => attr && attr.enabled && attr.name && attr.id);
|
||||
// Check if RPG Attributes section is enabled
|
||||
const showRPGAttributes = config.showRPGAttributes !== undefined ? config.showRPGAttributes : true;
|
||||
|
||||
if (enabledAttributes.length > 0) {
|
||||
if (showRPGAttributes) {
|
||||
// Use attributes from config, with fallback to defaults if not configured
|
||||
const rpgAttributes = (config.rpgAttributes && config.rpgAttributes.length > 0) ? config.rpgAttributes : [
|
||||
{ id: 'str', name: 'STR', enabled: true },
|
||||
{ id: 'dex', name: 'DEX', enabled: true },
|
||||
{ id: 'con', name: 'CON', enabled: true },
|
||||
{ id: 'int', name: 'INT', enabled: true },
|
||||
{ id: 'wis', name: 'WIS', enabled: true },
|
||||
{ id: 'cha', name: 'CHA', enabled: true }
|
||||
];
|
||||
const enabledAttributes = rpgAttributes.filter(attr => attr && attr.enabled && attr.name && attr.id);
|
||||
|
||||
if (enabledAttributes.length > 0) {
|
||||
html += `
|
||||
<div class="rpg-stats-right">
|
||||
<div class="rpg-classic-stats">
|
||||
@@ -208,6 +220,7 @@ export function renderUserStats() {
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
html += '</div>'; // Close rpg-stats-content
|
||||
|
||||
Reference in New Issue
Block a user