# Foundry VTT + Pathfinder 1e Development Environment > **A complete development environment for creating custom macros and automating Foundry VTT with Pathfinder 1e** > > **Version**: 1.0.0 | **Last Updated**: 2025-01-30 | **Repository**: [Gitea](https://gitea.gowlershome.dyndns.org/Gowler/FoundryVTT.git) --- ## ๐ŸŽฏ Quick Start **New to this project?** Start here: **[QUICKSTART.md](QUICKSTART.md)** (5-minute read) **Need complete details?** See: **[CLAUDE.md](CLAUDE.md)** (comprehensive project guide) --- ## ๐Ÿ“‹ What This Project Includes This is a professional development environment for Foundry VTT + Pathfinder 1e that combines: ### Core Components โœ… **Foundry VTT v11.315** - Complete Electron-based virtual tabletop platform - Express.js server backend with NeDB database - PIXI.js canvas rendering system - Socket.io real-time multiplayer support โœ… **Pathfinder 1e System v10.8** - Full PF1 game rules implementation - Character sheets and NPC templates - Spell and feat compendiums - Automated action resolution system - Built with Vite + ES Modules + TypeScript โœ… **Custom Macros & Automation** - Arcane Pool enhancement system (Magus class feature) - Haste buff automation with attack interception - Reusable macro patterns and templates - Dialog-based user interfaces โœ… **AI-Assisted Development** - Claude Code integration with 8 MCP servers - Semantic code navigation (Serena) - Complex problem solving (Sequential Thinking) - Real-time library documentation (Context7) - Persistent project memory (Knowledge Graph) --- ## ๐Ÿš€ Getting Started ### 1. Prerequisites - **Foundry VTT License** (required to download official builds) - **Node.js** v16-19 (for PF1 system development) - **npm** (Node Package Manager) - **Git** (version control) - **Visual Studio Code** (recommended IDE) ### 2. Initial Setup ```bash # Navigate to project root cd "C:\DEV\Foundry2\Foundry_VTT" # Install PF1 system dependencies cd src/foundryvtt-pathfinder1-v10.8 npm install # Build the PF1 system npm run build # Or use watch mode for development npm run build:watch ``` ### 3. Running Foundry VTT ```bash # Option 1: Run Foundry directly cd src/FoundryVTT-11.315 .\foundryvtt.exe # Option 2: Launch via Node.js node resources/app/main.js ``` ### 4. Creating & Using Macros 1. Open Foundry VTT 2. Click "Macro Directory" in the sidebar 3. Create a new macro (type: Script) 4. Copy content from `src/macro.js` or `src/macro_haste.js` 5. Save and drag to hotbar --- ## ๐Ÿ“ Project Structure ``` Foundry_VTT/ โ”œโ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ FoundryVTT-11.315/ # Foundry core application โ”‚ โ”‚ โ”œโ”€โ”€ resources/app/ # Electron app resources โ”‚ โ”‚ โ”œโ”€โ”€ node_modules/ # Foundry dependencies โ”‚ โ”‚ โ””โ”€โ”€ Data/ # User worlds & data (gitignored) โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ foundryvtt-pathfinder1-v10.8/# PF1 system module โ”‚ โ”‚ โ”œโ”€โ”€ module/ # System source code (ES modules) โ”‚ โ”‚ โ”œโ”€โ”€ packs/ # Compendium databases โ”‚ โ”‚ โ”œโ”€โ”€ public/system.json # System manifest โ”‚ โ”‚ โ”œโ”€โ”€ package.json # Dev dependencies & scripts โ”‚ โ”‚ โ””โ”€โ”€ vite.config.js # Build configuration โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ macro.js # Arcane Pool macro โ”‚ โ”œโ”€โ”€ macro_haste.js # Haste automation macro โ”‚ โ””โ”€โ”€ zeratal.json # Example character data โ”‚ โ”œโ”€โ”€ CLAUDE.md # Complete project documentation โ”œโ”€โ”€ QUICKSTART.md # Quick start guide โ”œโ”€โ”€ README.md # This file โ”œโ”€โ”€ .claude/ # Claude Code configuration โ”œโ”€โ”€ .mcp.json # MCP servers configuration โ””โ”€โ”€ .git/ # Git repository ``` **See [CLAUDE.md](CLAUDE.md) for detailed project structure and file descriptions.** --- ## ๐Ÿ› ๏ธ Development Workflow ### Building the PF1 System ```bash cd src/foundryvtt-pathfinder1-v10.8 # Production build npm run build # Development build with hot reload npm run build:watch # Lint code npm run lint # Format code npm run format ``` ### Creating a New Macro All macros follow the IIFE (Immediately Invoked Function Expression) pattern: ```javascript (async () => { // 1. Validation if (!token) { ui.notifications.warn("You must select a token!"); return; } // 2. Data access const actor = token.actor; const arcanePool = actor.system.resources.classFeat_arcanePool; // 3. Business logic async function doSomething() { // Implementation } // 4. Execute await doSomething(); // 5. User feedback ui.notifications.info("Done!"); })(); ``` **See [CLAUDE.md ยง Macro Development Patterns](CLAUDE.md#macro-development-patterns) for detailed macro examples.** ### Debugging Macros Press **F12** to open browser console: - Use **Console** tab for logs and errors - Use **Network** tab for API calls - Add `console.log()` for debugging - Check error messages in notifications ### Testing Changes 1. Make changes to PF1 system or macros 2. Run `npm run build` to rebuild 3. Reload Foundry VTT (F5) 4. Test macros or features 5. Check console (F12) for errors --- ## ๐Ÿ“š Documentation | Document | Purpose | Read Time | |----------|---------|-----------| | **[CLAUDE.md](CLAUDE.md)** | Complete project guide & API reference | 30 min | | **[QUICKSTART.md](QUICKSTART.md)** | Quick start setup guide | 5 min | | **[Manual_dmgtracking.md](Manual_dmgtracking.md)** | Damage tracking implementation | Reference | | **[ARCANE_POOL_ANALYSIS.md](ARCANE_POOL_ANALYSIS.md)** | Arcane Pool macro analysis | Reference | --- ## ๐ŸŽฎ Foundry VTT & PF1 API ### Global Objects (Available in Macros) ```javascript game // Main game instance game.actors // Actor collection game.items // Item collection game.scenes // Scene collection game.macros // Macro collection game.settings // Settings registry ui // UI manager ui.notifications // Toast notifications ui.chat // Chat sidebar canvas // Canvas rendering system CONFIG // Global configuration CONFIG.PF1 // PF1-specific config ``` ### Common API Patterns ```javascript // Get documents const actor = game.actors.get(actorId); const item = game.items.getName("Item Name"); const doc = fromUuidSync("Actor.abc123.Item.def456"); // Update documents await actor.update({ "system.hp.value": 50, "system.attributes.ac.total": 25 }); // Find items const buffs = actor.items.filter(i => i.type === "buff"); const haste = actor.items.find(i => i.name === "Haste"); // Use hooks Hooks.on("updateActor", (actor, change, options, userId) => { console.log(`${actor.name} was updated`); }); ``` **See [CLAUDE.md ยง Foundry VTT API Reference](CLAUDE.md#foundry-vtt-api-reference) for complete API documentation.** --- ## ๐Ÿ”ง Git Workflow ### Check Status ```bash git status # Show working tree status git log --oneline # Show recent commits git diff # Show unstaged changes ``` ### Make Changes ```bash # Create feature branch git checkout -b feature/my-feature # Make changes... # Commit git add src/ git commit -m "feat(macro): add new feature" # Push git push -u origin feature/my-feature ``` ### Commit Message Format Follow [Conventional Commits](https://www.conventionalcommits.org/): ``` ():