-
Notifications
You must be signed in to change notification settings - Fork 39
Template-based rendering system for item and mob descriptions #420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Added: - ItemLookData struct with GetLookData() method for template data building - MobLookData struct with GetLookData() method for template data building - look-item.template for rendering item descriptions - look-mob.template for rendering mob descriptions - Screenreader variants for all new templates - Character template screenreader variants for description and inventory-look - Conditional equipment display in mob templates (only shows equipped items) Changed: - Look command to use templates for items and mobs instead of hardcoded strings - MobLookData Equipment field to pointer type for template method compatibility - Mob templates to only display equipment section when items are equipped Fixed: - Circular import issue by passing charmer name as parameter - Container reference removed from items package to avoid dependency issues
Added: - UserInterface config section with Formats and Display subsections - ShowEmptyEquipmentSlots config option to control equipment display - Config method ShouldShowEmptyEquipmentSlots() for checking the setting - Template function showEmptyEquipmentSlots to access config from templates - GetUserInterfaceConfig() helper function - "xxx is not wearing anything" message when mob has no equipment and showEmpty is false Changed: - Moved TextFormats config under UserInterface.Formats for better organization - Updated mob templates to respect ShowEmptyEquipmentSlots configuration - Equipment display now shows all slots when true (default), only equipped items when false Fixed: - Template conditionals to properly handle all equipment display scenarios - Both regular and screenreader templates now correctly show equipment based on config
Added: - Nil checks in Item.GetLookData() to handle nil items - Nil checks in Mob.GetLookData() to handle nil mobs - Division-by-zero protection for mob health calculations Changed: - Consolidated equipment display logic in mob templates from 3 blocks to 1 - Used template variables to control equipment slot visibility - Reduced code duplication in both standard and screenreader templates Removed: - TextFormats to UserInterface.Formats migration logic - Redundant equipment display blocks in mob templates Breaking Changes: - Users with custom config files must manually update TextFormats to UserInterface.Formats structure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments/questions/discussion - I haven't tested it yet, just going through the code.
@@ -191,6 +192,7 @@ func (c *Config) Validate() { | |||
c.FilePaths.Validate() | |||
c.GamePlay.Validate() | |||
c.Integrations.Validate() | |||
c.UserInterface.Validate() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do we get for the change from TextFormats to UserInterface?
Aside from a minor difference in naming, it seems like we're introducing some confusion or maintaining two paths? We may need a migration routine if this is the plan going forward, but if the only difference is a naming change, why bother?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for changing it was to clarify that entries here will change how the game looks to the player.
I've added an option to use the config file to show or hide empty eq slots in mobs and characters. This did not feel like it belonged just in "TextFormats" but at the same time, I wanted a single place for admins to handle look and feel of the game.
I actually made an automatic migration for it, but did not include it here as it felt somewhat overkill for an engine that is not yes in "real" production.
My thinking was that it's a relative simple change to make for game admins using the engine, and while it is breaking, it felt overkill to add extra code just to migrate this when a simple statement in the release notes could ask admins to change a simple thing in their own config override.
I can add a migration for it if you think that makes more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a template-based rendering system for item and mob descriptions, replacing hardcoded string generation with configurable template files and adding equipment display options.
- Template-based rendering system with
ItemLookData
andMobLookData
structs for building template data - New UserInterface configuration section with configurable equipment display settings
- Template files for both standard and screenreader-friendly item/mob descriptions
Reviewed Changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
internal/usercommands/look.go | Updates look command to use template-based rendering instead of hardcoded strings |
internal/templates/templatesfunctions.go | Adds showEmptyEquipmentSlots template function for config access |
internal/mobs/mobs.go | Adds MobLookData struct and GetLookData() method for template data |
internal/items/items.go | Adds ItemLookData struct and GetLookData() method for template data |
internal/configs/configs.go | Integrates new UserInterface config section |
internal/configs/config.userinterface.go | New configuration module for user interface settings |
_datafiles/world/default/templates/descriptions/* | Template files for item and mob descriptions with screenreader variants |
_datafiles/config.yaml | Updates config structure and moves TextFormats to UserInterface.Formats |
Changed: - Replaced boolean fields (IsWeapon, IsReadable, etc.) with Type and Subtype strings - Replaced IsCursed/IsEnchanted booleans with extensible Adjectives map - Updated templates to use string equality checks (e.g., {{if eq .Type "readable"}}) Fixed: - Corrected TimeoutMods YAML formatting from multi-line to single-line
I am making a few more changes to the code, just to clean things up a little. Moving this to a draft while I do it :) Let me know if the migration is still something you feel we should do. We can do it on the fly when we read the file, keeping compatibility with the old TextFormats but only when reading the config file, or we can make a mere elaborate system where we re-write the actual config file to support the new system permanently. |
Removed: - TextFormats struct definition and field from main Config struct - TextFormats.Validate() call from config validation process - config.textformats.go file containing backwards compatibility function - Duplicate configuration entries in server output Changed: - All references from GetTextFormatsConfig() to GetUserInterfaceConfig().Formats - Direct TextFormats field access to UserInterface.Formats field access - Config structure to use single source of truth for format settings Fixed: - Duplicate prompt settings appearing in server set command output - Confusion from having both TextFormats.Prompt and UserInterface.Formats.Prompt - Inconsistent config access patterns across the codebase Updated files: - internal/configs/configs.go - removed TextFormats field and validation - internal/mobcommands/go.go - updated to use GetUserInterfaceConfig().Formats - internal/usercommands/go.go - updated to use GetUserInterfaceConfig().Formats - internal/usercommands/history.go - updated to use GetUserInterfaceConfig().Formats - internal/usercommands/set.go - updated to use GetUserInterfaceConfig().Formats - internal/usercommands/start.go - updated to use GetUserInterfaceConfig().Formats - internal/users/inbox.go - updated direct access to UserInterface.Formats - internal/users/userrecord.prompt.go - updated to use GetUserInterfaceConfig().Formats - modules/gmcp/gmcp.Game.go - updated direct access to UserInterface.Formats
Summary
This PR introduces a template-based rendering system for item and mob descriptions, replacing hardcoded string generation with template files. The system includes configurable equipment display options and error handling for edge cases.
Changes
Added
Changed
Fixed
Removed
Configuration
The ShowEmptyEquipmentSlots option:
Breaking Changes