21 KiB
Adventures with Emmy - System Overview & AI Agent Guidelines
Project Identity
System Name: Adventures with Emmy (AwE)
ID: fvtt-adventures-with-emmy
Version: 13.0.0 (Foundry VTT System)
Author: Uberwald (LeRatierBretonnien)
Purpose: STEM Education Role-Playing Game
License: MIT
System Overview
What is Adventures with Emmy?
Adventures with Emmy is a Foundry Virtual Tabletop (FVTT) system designed for educational role-playing with a focus on STEM (Science, Technology, Engineering, Mathematics) education. It provides a ruleset and digital tools for running tabletop RPGs that teach and reinforce STEM concepts through gameplay.
The system uses a d20-based mechanics with unique attributes, fields of study, specializations, and abilities that reflect scientific and mathematical disciplines.
Core Concepts
| Concept | Description |
|---|---|
| Fields | Areas of study (Biologist, Chemist, Engineer, Mathematician, Physicist) |
| Attributes | Core character stats: Agility (AGI), Awareness (AWA), Fitness (FIT), Influence (INF) |
| Specializations | Sub-disciplines within fields |
| Archetypes | Character archetypes with prerequisite levels |
| Abilities | Powers and actions with costs (Δ = Action cost) |
| Flow Points | Resource for powering special abilities |
| Conditions | Status effects (Edge, Hampered, Inhibited, Jumbled, etc.) |
| Kits | Equipment bundles for character classes |
| Traits | Descriptive tags for abilities and items |
Character Attributes
- Agility (AGI) - Physical dexterity and coordination
- Awareness (AWA) - Perception and observation skills
- Fitness (FIT) - Physical strength and endurance
- Influence (INF) - Social and leadership abilities
Each attribute has:
boostLevel(0-7): Permanent boosts from background/field/level progressionbonus: Manual +/- modifiersmod: Calculated aslevel + boostLevel + bonusdc: Difficulty Class =10 + mod
Project Structure
fvtt-adventures-with-emmy/
├── adventures-with-emmy.mjs # Main system entry point
├── system.json # System manifest
├── module/
│ ├── config/
│ │ ├── system.mjs # System constants (ATTRIBUTES, CONDITIONS, TRAITS, etc.)
│ │ └── trait-descriptions.json # Tooltip descriptions for traits
│ ├── models/
│ │ ├── _module.mjs # Model exports
│ │ ├── character.mjs # Hero character data model
│ │ ├── creature.mjs # NPC/creature data model
│ │ ├── ability.mjs # Ability item model
│ │ ├── field.mjs # Field of study model
│ │ ├── specialization.mjs # Specialization model
│ │ ├── archetype.mjs # Archetype model
│ │ ├── background.mjs # Background model
│ │ ├── kit.mjs # Kit/equipment bundle model
│ │ ├── weapon.mjs # Weapon model
│ │ ├── equipment.mjs # Equipment model
│ │ ├── skill.mjs # Skill model
│ │ └── effect.mjs # Effect model
│ ├── documents/
│ │ ├── _module.mjs # Document exports
│ │ ├── actor.mjs # Actor document class
│ │ ├── item.mjs # Item document class
│ │ ├── roll.mjs # Custom Roll class with outcome calculation
│ │ ├── chat-message.mjs # Chat message handling
│ │ └── combatant.mjs # Combatant document
│ └── applications/
│ ├── _module.mjs # Application exports
│ ├── sheets/ # Character/Item sheet classes
│ │ ├── base-actor-sheet.mjs
│ │ ├── character-sheet.mjs
│ │ ├── creature-sheet.mjs
│ │ ├── base-item-sheet.mjs
│ │ └── [all item type sheets]
│ └── hud/ # Token Action HUD integration
│ ├── constants.js # HUD group definitions
│ ├── system-manager.js # HUD system manager
│ ├── action-handler.js # Builds action lists for HUD
│ ├── roll-handler.js # Handles roll actions from HUD
│ ├── defaults.js # Default HUD settings
│ └── settings.js # HUD-specific settings
├── templates/ # Handlebars templates
│ ├── chat-message.hbs # Roll/damage chat output
│ ├── roll-dialog.hbs # Roll configuration dialog
│ ├── ability-use.hbs # Ability usage chat card
│ ├── character-*.hbs # Character sheet tabs
│ ├── creature-*.hbs # Creature sheet tabs
│ └── [item templates] # Individual item sheet templates
├── lang/
│ └── en.json # English localization
├── css/
│ └── adventures-with-emmy.css # System styles
├── packs-system/ # Compendium packs
├── assets/ # Static assets (condition icons, etc.)
├── gulpfile.js # CSS compilation
├── eslint.config.mjs # ESLint configuration
└── package.json # Development dependencies
File Counts
- Source Files: 66 (excluding node_modules)
- Models: 12
- Documents: 5
- Applications/Sheets: 12
- Applications/HUD: 6
- Templates: 24
- Config: 2
Technical Architecture
Technology Stack
| Component | Technology |
|---|---|
| Platform | Foundry Virtual Tabletop v13 |
| Language | JavaScript (ES Modules - .mjs) |
| Templates | Handlebars (.hbs) |
| Styles | CSS (compiled from LESS via Gulp) |
| Data Format | JSON |
| Module System | ES6 Modules |
Integration Points
-
Token Action HUD Core Module
- Required module:
token-action-hud-corev2.0+ - Provides action buttons for characters in the HUD
- Integration via
tokenActionHudCoreApiReadyhook - Action groups: attributes, hp, flow, weapons, conditions, abilities, kits, utility
- Required module:
-
Foundry VTT API
- Extends
Actor,Item,Roll,ChatMessage,Combatant - Custom data models using
foundry.abstract.TypeDataModel - Uses Foundry's schema field system
- Extends
-
Custom Roll System
- Extended
AwERollclass with outcome calculation - Degrees of success: Critical Success, Success, Failure, Critical Failure
- Support for rolling twice (take higher/lower)
- Automatic damage roll on hit
- Extended
Data Models
Actor Types
- character - Player heroes with full STEM capabilities
- creature - NPCs and monsters
Item Types
- specialization - Field specializations
- ability - Character abilities with costs
- field - Field of study items
- archetype - Character archetypes
- background - Character backgrounds
- kit - Equipment kits
- weapon - Weapon items
- equipment - General equipment
- skill - Skill items
- effect - Active effects
Key Features
1. Attribute System
- Four core attributes (Agility, Awareness, Fitness, Influence)
- Each attribute has boost levels (0-7) from progression
- Manual bonus/penalty support
- Derived modifier and DC calculations
2. Roll Mechanics
- d20-based checks with modifiers
- Automatic outcome calculation (critical success/failure based on DC ±10)
- Natural 20/1 auto-upgrade/downgrade
- Support for situational bonuses (-5 to +5)
- Knowledge bonuses from items
- Condition bonuses/penalties
- Roll twice options (take higher/lower)
3. Action Economy
- Δ (Delta) - Action cost system
- Costs: Free, One (Δ), Two (ΔΔ), Three (ΔΔΔ), Reaction (↩), Variable
- Flow Point costs for special abilities
- Daily ability tracking
4. Combat Integration
- Weapon attack rolls with automatic damage
- Critical hits double damage dice
- Condition system with status effect icons
- Token Action HUD support
5. STEM-Specific Features
- Fields: Biologist, Chemist, Engineer, Mathematician, Physicist
- Mathematician Subfields: Electromagnetic, Geometry, Gravity, Numerical, Paradox, Probability
- Engineer Specializations: Computer, Electrical, Mechanical
- Trait System: Extensive tagging for abilities (attack, flow, hypothesis, intensive, kit, linguistic, manipulate, review, traversal, velocity, etc.)
6. Resource Management
- Hit Points (HP) with temp HP
- Flow Points (FP) with temp FP
- Daily ability tracking
- Long rest mechanics
7. Token Action HUD Features
- Attribute displays with modifiers
- HP tracking with +/-
- Flow Point tracking with +/-
- Weapon lists with attack modifiers
- Condition toggles
- Ability lists with costs and usage tracking
- Kit usage
- Utility actions (Long Rest, End Turn)
Development Standards
Code Style
-
File Naming:
- Module files:
kebab-case.mjs - Classes:
PascalCasewithAwEprefix (e.g.,AwECharacter) - Constants:
UPPER_SNAKE_CASE - Variables/Functions:
camelCase
- Module files:
-
ESLint Configuration:
- Uses
@eslint/jswith custom config ineslint.config.mjs - Includes
eslint-plugin-jsdocfor documentation - Prettier integration for formatting
- Uses
-
Imports:
- Use ES6
import/exportsyntax - Relative paths from module root
- Module aggregation in
_module.mjsfiles
- Use ES6
-
Documentation:
- JSDoc comments for classes and methods
- Inline comments for complex logic
- English language for code comments
File Organization
- models/: Data schema definitions
- documents/: Foundry document classes
- applications/: UI components and sheets
- templates/: Handlebars templates
- config/: System configuration and constants
Build Process
- CSS: Compiled from LESS using Gulp
- No Bundling: Files loaded individually via Foundry's ES module system
- Hot Reload: Configured for CSS, HBS, JSON files
AI Agent Guidelines
For Code Modification Agents
✅ DO:
-
Follow Existing Patterns
- Match the code style and structure of existing files
- Use the same naming conventions (AwE prefix for classes)
- Maintain consistent import/export patterns
-
Use Foundry VTT APIs
- Extend appropriate base classes (
TypeDataModel,Actor,Item, etc.) - Use
foundry.data.fieldsfor schema definitions - Follow Foundry's data model patterns
- Extend appropriate base classes (
-
Maintain Data Integrity
- Always define schemas in model files
- Use proper field types (NumberField, StringField, SchemaField, etc.)
- Set appropriate initial values and constraints (min/max)
-
Preserve Existing Functionality
- Don't modify files without understanding their dependencies
- Test changes against the full system
- Ensure backward compatibility
-
Document Changes
- Add JSDoc comments for new methods
- Update any affected documentation
- Note any breaking changes
❌ DON'T:
-
Modify Core Foundry Files
- Only modify files within the
fvtt-adventures-with-emmydirectory - Never edit Foundry VTT core files
- Only modify files within the
-
Break Existing Schemas
- Don't change field types without migration plans
- Don't remove required fields
- Don't change field names without updating all references
-
Introduce External Dependencies
- Only use libraries already in package.json
- Avoid jQuery (use native DOM APIs)
- Prefer Foundry's built-in utilities
-
Hardcode Localization Strings
- Use
game.i18n.localize()for all user-facing text - Add new strings to
lang/en.json - Use localization keys, not raw text
- Use
-
Modify Without Testing
- Always verify changes work in Foundry VTT
- Test with both character and creature actors
- Test with various item types
For Token Action HUD Agents
HUD Integration Rules:
-
Dependency:
- All HUD code is in
module/applications/hud/ - Requires
token-action-hud-corev2.0+ - Integration via
tokenActionHudCoreApiReadyhook
- All HUD code is in
-
Action Groups:
- Defined in
constants.js - Built in
action-handler.js - Each group has:
id,name,type
- Defined in
-
Adding New Actions:
- Add to appropriate build method in
action-handler.js - Use encoded values with delimiter (e.g.,
['ability', id].join(this.delimiter)) - Include proper tooltips and info displays
- Add to appropriate build method in
-
Roll Handlers:
- Defined in
roll-handler.js - Registered in
system-manager.js - Handle roll actions from HUD buttons
- Defined in
For Documentation Agents
Documentation Standards:
-
File Location:
- System documentation:
_docs/directory - API documentation: Include in JSDoc comments
- User documentation: Markdown files in
_docs/
- System documentation:
-
Code Documentation:
- Use JSDoc format
- Document parameters and return types
- Include examples where helpful
-
User Documentation:
- Explain STEM concepts clearly
- Provide examples for gameplay
- Include screenshots where possible
For Testing Agents
Test Areas:
-
Roll Mechanics
- Test outcome calculation (critical success/failure boundaries)
- Test modifier application
- Test condition bonuses
- Test roll twice functionality
-
Data Models
- Test schema validation
- Test derived data calculation
- Test default values
-
Sheets
- Test rendering with various data states
- Test form submissions
- Test tab switching
-
HUD Integration
- Test action building for different actor types
- Test action execution
- Test visibility and permissions
-
Combat
- Test weapon attack rolls
- Test damage calculation
- Test critical hits
- Test condition application
Common Tasks
Adding a New Item Type
-
Create Model (
module/models/new-type.mjs):import { SYSTEM } from "../config/system.mjs" export default class AwENewType extends foundry.abstract.TypeDataModel { static defineSchema() { const fields = foundry.data.fields return { description: new fields.HTMLField({ required: true, textSearch: true }), // Add other fields... } } prepareDerivedData() { // Calculate derived fields } } -
Export in _module.mjs:
export { default as AwENewType } from "./new-type.mjs" -
Add to system.json:
"Item": { "newType": { "htmlFields": ["description"] } } -
Create Sheet (
module/applications/sheets/new-type-sheet.mjs):- Extend
base-item-sheet.mjs - Define template path
- Handle form submission
- Extend
-
Register Sheet in
adventures-with-emmy.mjs:foundry.documents.collections.Items.registerSheet( "fvtt-adventures-with-emmy", applications.AwENewTypeSheet, { types: ["newType"], makeDefault: true } ) -
Create Template (
templates/new-type.hbs):- Use existing templates as reference
- Include all relevant fields
-
Add Localization in
lang/en.json:"TYPES.Item.newType": "New Type", "AWEMMY.Item.NewType": "New Type"
Adding a New Attribute
-
Add to config/system.mjs:
export const ATTRIBUTES = { ...existing, newAttr: { id: "newAttr", abbrev: "NEW", label: "AWEMMY.Attribute.NewAttr" } } -
Update Character Model:
- Modify
module/models/character.mjsto include new attribute in schema
- Modify
-
Update Sheets:
- Add attribute display to character sheet templates
- Add attribute to creature sheet if applicable
-
Update HUD:
- Add to
action-handler.js#buildAttributes()method - Add to
constants.jsif needed
- Add to
-
Add Localization:
- Add label to
lang/en.json
- Add label to
Adding a New Condition
-
Add to config/system.mjs:
export const CONDITIONS = { ...existing, newCondition: { id: "newCondition", label: "AWEMMY.Condition.NewCondition" } } -
Create Icon:
- Add SVG file to
assets/conditions/newCondition.svg
- Add SVG file to
-
Update HUD:
- Add to
#buildConditions()inaction-handler.js
- Add to
-
Add Localization:
- Add label and description to
lang/en.json
- Add label and description to
-
Handle in Actor:
- Add condition bonus logic to
actor.mjsif needed
- Add condition bonus logic to
Best Practices
Performance
-
Minimize DOM Queries:
- Cache selectors when possible
- Use event delegation for dynamic elements
-
Async/Await:
- Use async/await for all Foundry API calls
- Handle errors appropriately
-
Data Access:
- Cache frequently accessed data
- Use
this.actorinstead ofgame.actors.get()when available
User Experience
-
Feedback:
- Provide notifications for important actions
- Use
ui.notifications.info/warn/errorappropriately
-
Accessibility:
- Use semantic HTML in templates
- Provide alt text for images
- Ensure sufficient color contrast
-
Localization:
- Always use localization keys
- Support right-to-left languages in templates
Security
-
User Input:
- Sanitize all user input
- Use Foundry's HTML sanitization for rich text
-
Permissions:
- Check permissions before performing actions
- Use
game.user.isGMfor GM-only features
-
Data Validation:
- Validate all incoming data
- Use schema validation for model data
Debugging Tips
Common Issues
-
Schema Errors:
- Check field definitions match usage
- Verify initial values are valid
- Ensure required fields are present
-
Roll Calculation Problems:
- Verify modifier calculation in
roll.mjs - Check outcome computation logic
- Test with known DC values
- Verify modifier calculation in
-
HUD Not Showing Actions:
- Verify Token Action HUD Core is installed
- Check
tokenActionHudCoreApiReadyhook fires - Ensure action groups are registered
-
Sheet Rendering Issues:
- Check template paths are correct
- Verify data is passed to template
- Use browser dev tools to inspect rendered HTML
Debugging Tools
-
Foundry Console:
CONFIG.debug = truefor additional logging- Use
console.log()for debugging (visible in F12 console)
-
Browser Dev Tools:
- Inspect elements and styles
- Check network requests
- Debug JavaScript execution
-
Foundry VTT Developer Mode:
- Enable in Foundry settings
- Provides additional debugging capabilities
Resources
Official Documentation
Project Resources
- Repository: https://www.uberwald.me/gitea/uberwald/fvtt-adventures-with-emmy.git
- Issue Tracker: Use repository issue tracker
- Discord: LeRatierBretonnien (Author)
Development Tools
- ESLint: For code quality checking
- Prettier: For code formatting
- Gulp: For CSS compilation
- Foundry VTT CLI: For packaging and distribution
Quick Reference
System Constants
| Constant | Location | Purpose |
|---|---|---|
SYSTEM_ID |
config/system.mjs | System identifier |
ATTRIBUTES |
config/system.mjs | Core character attributes |
CONDITIONS |
config/system.mjs | Status effects |
ABILITY_COST |
config/system.mjs | Action cost types |
ABILITY_TYPE |
config/system.mjs | Ability categories |
TRAITS |
config/system.mjs | Allowed trait list |
TRAIT_DESCRIPTIONS |
trait-descriptions.json | Trait tooltips |
Key Methods
| Class | Method | Purpose |
|---|---|---|
AwEActor |
rollWeapon() |
Roll weapon attack |
AwEActor |
rollAttribute() |
Roll attribute check |
AwEActor |
useAbility() |
Activate an ability |
AwEActor |
useKit() |
Use a kit item |
AwEActor |
longRest() |
Perform long rest |
AwERoll |
prompt() |
Show roll dialog |
AwERoll |
computeOutcome() |
Calculate success degree |
Hooks
| Hook | Location | Purpose |
|---|---|---|
init |
adventures-with-emmy.mjs | System initialization |
ready |
adventures-with-emmy.mjs | System ready |
tokenActionHudCoreApiReady |
adventures-with-emmy.mjs | HUD integration |
renderChatMessageHTML |
adventures-with-emmy.mjs | Damage roll buttons |
Version History
- v13.0.0 - Current version (Foundry VTT v13 compatibility)
- Previous versions support Foundry VTT v12 and earlier
Contact & Support
For questions, issues, or contributions:
- Author: LeRatierBretonnien (Discord)
- Repository: https://www.uberwald.me/gitea/uberwald/fvtt-adventures-with-emmy.git
- Foundry VTT Package: Available in Foundry's package manager
This AGENTS.md file provides comprehensive guidance for AI agents and developers working on the Adventures with Emmy system. Always refer to the latest version of this file and the actual source code for the most accurate information.