62 Commits

Author SHA1 Message Date
111f4b3d0d add Scene Music GM module: mood-based CC0-1.0 background tracks, /api/music/manifest, /music static, MoodMusic player in GMKit 2026-07-17 08:03:44 +02:00
ad7ce9dc22 Security fix: GM authorized from server-side session via x-session-id header
- New database/auth.js: shared server-side GM check using session store
- database/server.js: crypto-random session generation, server-side session
  storage, GM auth from session instead of x-gm-secret header
- database/routes/playerRoutes.js: GM-only endpoints use server-side auth
- database/routes/sessionRoutes.js: session creation/lookup endpoints
- database/routes/bestiaryRoutes.js: GM auth from server-side session
- database/routes/rulesRoutes.js: GM auth from server-side session
- src/App.js: send x-session-id header with API requests
- src/components/BestiaryTab.jsx: use session-based GM auth
2026-07-16 23:03:52 +02:00
184b6e4371 feat: major Deathwatch Roller overhaul with bestiary, mission, and player management
- src/components/DeathwatchRoller.jsx: +1495 lines, core roller
  component with expanded dice mechanics, character sheets, and
  mission tracking
- src/components/BestiaryTab.jsx: +158 lines, enemy bestiary with
  stat blocks and encounter builder
- src/components/MissionTab.jsx: +43 lines, mission briefing and
  objective tracking
- src/App.js: route updates for new tabs
- database/routes/missionRoutes.js: backend mission state routes
- src/tests/: new test files for roller reset, bestiary, mission,
  player management, requisition shop, and full mission playthrough
2026-07-15 19:37:07 +02:00
b2dd5a44d3 feat: expand Simulation tab with combat simulation and replay
- src/components/SimulationTab.jsx: +544 lines, combat simulation
  UI with horde combat, player actions, and replay functionality
- database/routes/simulationRoutes.js: +681 lines, backend routes
  for simulation state management and combat resolution
- src/tests/simulationTabReplay.test.js: replay functionality tests
- src/tests/hordeCombatFourPlayersFiveHordes.test.js: multi-player
  horde combat scenario tests
- src/tests/hordeCombatPlayerMainWeapon.test.js: player weapon
  damage calculation tests
2026-07-15 19:36:38 +02:00
93fee15e32 Fix player weapon damage/types: christoffer weapons had empty damage, claes Power Fist type fixed 2026-07-02 18:20:33 +02:00
19f4dd0cca Fix bestiary data: sync profiles, armour, movement from stats; fix cross-contaminated entries 2026-07-02 17:36:41 +02:00
8225997107 Persist mission scene session state 2026-07-02 11:55:12 +02:00
0fa8c39c4d Update mission roller and simulation flow 2026-07-02 11:48:38 +02:00
2a8d72eb1e Add fate-point support to skill and combat rollers
Players can spend a fate point to re-roll, add +10, or add a degree of
success to their most recent roll. Spends are persisted to the player's
sheet via a new atomic POST /api/players/:name/spend-fate endpoint
(read-modify-write that preserves password and other tabInfo).

- rollHelpers.applyFateToTest: shared recompute for a test result
- useFate hook: loads current/total fate, spends + persists
- FateControls: shared current/total display + Re-roll/+10/+DoS buttons
- SkillRoller and the combat roller each track their last roll and
  replace it in history when fate is spent; combat also recomputes hits.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-30 13:44:46 +02:00
c4c622c1b7 Remove orphaned SQLite-era scripts
Delete 17 one-off migration/admin scripts that imported the removed
./sqlite-db module. None are referenced by the app, package.json, or CI;
they broke at the SQLite->MariaDB migration. No live code imports
sqlite-db anymore.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-30 12:19:15 +02:00
15785f2e70 Remove dead SQLite-era session middleware and healthcheck
Sessions are served from MariaDB via sessionModel.js + routes/sessionRoutes.
These files were orphaned by the SQLite->MariaDB migration:

- requireSession.js: unused (no importers), still required ./sqlite-db
- healthcheck.js: required removed ./sqlite-db; would crash every run
- server-healthcheck.yml: scheduled the broken healthcheck every 15 min

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-30 12:18:21 +02:00
c28187decd Add standard scene actions and fix sim fire modes 2026-06-30 10:19:50 +02:00
44b2e283bd Add ammo and combat profiles to simulations 2026-06-30 10:08:10 +02:00
c54fd6c8fd Gate player skill conditions in missions 2026-06-30 09:07:55 +02:00
b6cff53b8e Add rules-based squad tactics checks 2026-06-29 14:00:19 +02:00
3aebcf8f0e Add examples to rules reference 2026-06-29 13:45:32 +02:00
fe884ac543 Prepare Deathwatch session tools 2026-06-29 13:37:02 +02:00
4630272171 feat: Error reports create GitHub Issues (alexpolo1/dwroller) 2026-06-25 18:56:30 +02:00
c0fc0d1aab fix: ErrorReports build errors - fix confirm/window.confirm and App.js JSX syntax 2026-06-25 18:45:20 +02:00
5c4c65abd7 Add error reporting system - logged-in users can submit bug reports, GM can resolve 2026-06-25 18:29:49 +02:00
7873f450da feat: rules midgame priority system, mission enhancements, and requisition shop improvements
- Add midgame priority ranking for rules (midgamePriority field)
- Enhance rules search to support midgame filtering and sorting
- Improve mission simulation and midgame tracking
- Fix RequisitionShop player name handling
- Add rules midplay simulation tests
- Update MissionTab with midgame scene tracking
- Add backend logging for rules updates
2026-06-24 12:09:25 +02:00
2a63e43120 feat: simulation difficulty control (Recruit → Legendary)
5 tiers selectable in Sim Lab config panel. Each tier scales enemy
wounds/BS/AP, adds check penalties, adjusts max combat rounds,
inter-scene healing chance, fear bonus, and adds a 3rd Elite Guard
enemy at Brutal+. Difficulty stored in DB (difficulty_level column)
and shown as a badge in the sidebar and report header.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-24 11:04:17 +02:00
a666b8b4b4 feat: Simulation Lab — GM tab to run and review mission simulations
Backend:
- Add `simulations` table to MariaDB (mission, players, result, XP,
  roll feed, player cards, scene log, findings — all persisted as JSON)
- simulationHelpers: save / getAll / getById / delete
- simulationRoutes.js: POST /api/simulations (run engine + save),
  GET /api/simulations (list), GET /:id (full report), DELETE /:id
- Simulation engine: d100 dice, fear tests, combat rounds with
  initiative, conditions, damage, fate re-rolls, skill checks,
  auto-assign checks to best-stat player, enemy pools from scene data,
  per-player report cards with grade A-D, hero moments, shame list

Frontend:
- SimulationTab.jsx: GM-only tab with sidebar list of past runs,
  "Run New Simulation" config panel (pick mission + players),
  collapsible scene log, player report cards, filterable roll feed,
  findings panel
- App.js: import SimulationTab, add "⚙ Sim Lab" nav button (GM only)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-24 10:31:27 +02:00
cdfd147f02 feat: Mission Tab — 11 playthrough fixes + 4 follow-up findings
All 11 issues from 4-player simulation of The Hunt for Fabius Bile:
1. Roll feed visible to all players (no GM auth guard)
2. Scene text gated by revealed flag; GM explicit reveal per scene
3. GM can add NPC/enemy entries to initiative tracker
4. Round counter synced to Dice Roller via localStorage + custom event
5. Check reward text hidden until player has rolled
6. Checks assignable to specific player via Scene Secrets ⚙ options
7. Fear test quick-roll panel with WP input appears when fearRating > 0
8. Decision checks show textarea/Declare instead of d100 roll button
9. Fate point re-roll: one per check per scene, resets on scene advance
10. Player poll reduced from 8s to 4s, combined mission + roll feed poll
11. Mission complete banner with scene stats and GM outcome notes field

4 follow-up findings from second simulation run:
- Finding #1: Activate mission now initialises revealed:false on all scenes
  so players never see scene text before the GM narrates
- Finding #2: Fear penalty auto-applied to WP display; button shows
  effective (penalised) target rather than raw WP input
- Finding #3: RollFeedRow moved outside component to avoid re-mount on
  every render; onDelete passed as prop
- Finding #4: Removed duplicate "Open for Players" quick-button from
  Scene Checks left panel — Scene Secrets is the sole entry point

New files:
- src/tests/missionPlaythrough.test.js — full GM+4-player simulation
  test suite covering all 11 issues and 4 findings (39 test cases)
- src/tests/missionTab.test.js — player/GM view isolation tests
- src/utils/diceRoller.js — shared d100/degrees/clampTarget utilities
- tests/missionRoutes.test.js — backend mission route unit tests
- tests/playerRoutesLogin.test.js — player login route tests
- tests/sessionRoutes.test.js — session validation tests

Note: React unit tests require jsdom; segfaults on ARM64 (Raspberry Pi)
due to a known jsdom/Node 20 incompatibility on aarch64. Tests pass on
x86 CI. Backend integration tests (tests/) run normally.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-24 00:25:51 +02:00
cd180aad5b fix: CI tests - switch login to text input, fix session validation regex, fix playerManagement test 2026-06-23 15:33:36 +02:00
d610fa08fb fix: GM login - include GM in dropdown, auto-fill password, fix session validation regex 2026-06-23 15:18:33 +02:00
5b022a6426 Save mission 'The Hunt for Fabius Bile' to DB
- 10 scenes, 59 enemies, High threat, 4 players
- Includes all combat encounters, social, investigation, puzzle, epilogue
2026-06-23 14:52:34 +02:00
bfe3489060 Update player sheets with proper Deathwatch data
- All players: Adept renown (1 RP), 15 wounds, fate=1, full characteristics
- anders: Blood Angels Devastator, Heavy Bolter + Bolt Pistol
- christoffer: Ultramarines Chaplain (Hero, 3 RP), Crozius Arcanum + Bolt Pistol
- claes: Ultramarines Sergeant, Bolter + Chainsword + Power Fist + Bolt Pistol
- phillip: Ultramarines Space Marine, Bolter + Chainsword + Bolt Pistol
2026-06-23 14:48:26 +02:00
254ba5bd1d Fix login UI: add user dropdown selector, fix build syntax error
- Replace username text input with dropdown selector for player login
- Fix unescaped apostrophe in MissionSimTab.jsx (Emperor's -> double quotes)
- Fix em-dash encoding issues in MissionSimTab.jsx
- Update player password to 1234 in .env
2026-06-23 14:43:51 +02:00
fe1b77ec68 Add mission persistence: missions table, API routes, and history UI
- MariaDB missions table with scenes JSON
- /api/missions CRUD routes
- MissionTab saves completed missions to DB
- Mission history panel in UI

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 10:07:46 +02:00
a4cabbd2b8 Clean rules database and add documentation
- Remove OCR noise, credits, and duplicates from rules-database.json (288→255 rules)
- Add clean_rules.py script for rule cleanup
- Add CLAUDE.md, docs/, and update README with documentation links

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-22 17:35:36 +02:00
e511bff882 Add weapon images, full rule scraping, and expanded quick reference
- scripts/generate-weapon-images.js: AI image generation for weapon cards
  supporting HuggingFace FLUX.1-schnell, OpenAI DALL-E 3, and Gemini Imagen;
  images served from public/weapon-images/ via new static route in server.js
- public/cards.html: load manifest.json and show AI art on weapon cards
- scripts/scrape-rules-from-pdfs.py: PyMuPDF scraper extracting full rule
  text from all five rulebook PDFs with bold-span heading detection
- scripts/tag-and-dedup-rules.js: standalone dedup helper (JS-side grouping)
- database/routes/rulesRoutes.js: remove content truncation in search/random,
  add admin dedup endpoint (JS-side, fast), fix RulesTab to fetch full content
- src/components/RulesTab.jsx: fetch full rule content on modal open
- public/print.html: expanded quick reference with pre-gen character stat
  blocks (Sepheran + Lucian), Astartes traits sheet with correct derived SBs
  and TBs, full Critical Hit Tables for all 4 locations × 4 damage types

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-01 22:50:50 +01:00
768fdfd419 Add PM2 restart_delay and max_restarts to prevent crash-loop spam
When DB_PASSWORD is missing on startup, server exits and PM2 was
restarting every ~660ms flooding backend.log with ER_ACCESS_DENIED_ERROR.
Now waits 5s between restarts and caps at 10 attempts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-01 18:31:32 +01:00
6c9bde7710 Remove obsolete one-shot import scripts
import-rules.js, import-armour.js, import-all.js were used once during
initial data import and have been superseded by the scripts/ directory.
All hardcoded wrong passwords (dwroller2025).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-01 18:27:47 +01:00
1e361301ad Fix rules search ranking and import clean skills/talents from Core Rulebook
- Add search relevance scoring: exact title > title prefix > title contains > Core Rulebook source > content match
- Add DB_PASSWORD env var to pm2.config.js so server can connect to MariaDB
- Add update-rules-from-sources.py: imports 45 skills from CSV and 44 talents from CR.txt, removes garbage advance-table entries
- Add fix-talent-titles.py: normalises OCR-garbled talent titles, removes 28 duplicates, fixes 65 entries
- Add cleanup-skill-dupes.py: removes duplicate skills from csv-import/fandom/sanitized sources, recategorises 55 lore entries

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-01 18:25:08 +01:00
43d0becdf6 Fix missing DB table, rules column, GM endpoints, and logout
- Add rules table to createTables() with auto-seed from rules-database.json
- Fix page_num → page column mapping in rulesRoutes.js
- Fix INSERT column names in rulesHelpers.create() and stagingHelpers
- Add POST /api/sessions/logout endpoint
- Add GM endpoints: set-xp, set-xp-spent, set-rp, set-renown,
  add-or-update, reset-password, DELETE gm/delete/:name
- All GM endpoints require x-gm-secret header (403 otherwise)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-01 18:08:30 +01:00
4130ab7766 Update MariaDB config to use remote database server
Switch from localhost to Synology NAS (192.168.1.113:3307) for
centralized database hosting.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-01 18:08:29 +01:00
alexpolo1
bf98d44a45 security: remove hardcoded database credentials and auth secrets
- Replace hardcoded DB_PASSWORD 'dwroller2025' with process.env.DB_PASSWORD
- Replace hardcoded GM_SECRET 'bongo' with process.env.GM_SECRET
- Replace hardcoded GM_PASSWORD with process.env.GM_PASSWORD
- Replace hardcoded PLAYER_PASSWORD '1234' with process.env.PLAYER_PASSWORD
- Update .env.example to document required environment variables
- Apply changes to all backend routes, database modules, and React components
- Update test files to use environment variables for credentials
- Ensure .env remains in .gitignore for production safety

This fix addresses critical security vulnerabilities where database
credentials and authentication secrets were exposed in source code.
2026-03-01 09:24:24 +01:00
35335a32d3 Refactor UI components for improved styling and consistency
- Updated RequisitionShop component styles for a cohesive dark theme.
- Enhanced RulesTab component with consistent dark styling and improved button visibility.
- Modified XPBar component to align with new dark theme aesthetics.
- Adjusted global styles in index.css to support the new design.
- Added comprehensive DEVELOPMENT_GUIDE.md for project setup, deployment, and maintenance instructions.
2025-12-11 21:15:14 +01:00
d84ca39e61 refactor: Migrate database from SQLite to MariaDB
Database Migration:
- Add MariaDB connection configuration and initialization (mariadb.js)
- Create MariaDB schema update script (mariadb-schema-update.sql)
- Add migration scripts for SQLite to MariaDB transition:
  * migrate-sqlite-to-mariadb.js: Main migration script
  * migrate-inventory-to-gear.js: Inventory schema migration
- Remove SQLite-specific implementation files and databases

Route Updates:
- Update all route handlers to use MariaDB instead of SQLite
- Migrate routes: playerRoutes, sessionRoutes, shopRoutes, bestiaryRoutes, rulesRoutes, rulesStagingRoutes, weaponsRoutes
- Remove SQLite-specific route files (playerRoutes-sqlite.js, sessionRoutes-sqlite.js)
- Update server.js to initialize MariaDB and register new weapon routes

Backend Scripts:
- Remove old SQLite migration scripts (migrate-to-sqlite.js, server-sqlite.js)
- Delete obsolete database utility scripts from backup-scripts/

Frontend Updates:
- Update logger utility for improved error handling and debugging
- Enhance PlayerManagement component with better state management
- Improve RequisitionShop component for MariaDB integration
- Update DeathwatchRoller with performance improvements
- Add login test suite (login.test.js)
- Add XP progression utility (xpProgression.js)
- Update dependencies in package.json and package-lock.json

This migration improves:
- Database scalability and performance
- Transaction support for complex operations
- Better data integrity and ACID compliance
- Simplified deployment and backup procedures
2025-12-11 19:20:44 +01:00
a5a6b963fa feat: Add PlayerManagement GM interface and clean repository
- Add comprehensive PlayerManagement component for GMs
- Add all GM API endpoints for player CRUD operations
- Add comprehensive test suite with 14 tests
- Clean up .gitignore to exclude logs, backups, core dumps
- Update README with setup instructions and documentation
- Add setup.sh script for easy project initialization

This provides a complete GM interface for managing players without
the large files that were blocking the previous push.
2025-09-05 11:05:53 +02:00
copilot-swe-agent[bot]
0f44d56c63 Fix CI pipeline by separating unit and integration tests
Co-authored-by: alexpolo1 <14327609+alexpolo1@users.noreply.github.com>
2025-08-24 20:40:59 +00:00
copilot-swe-agent[bot]
b7df2c1e49 Initial analysis of CI pipeline issues
Co-authored-by: alexpolo1 <14327609+alexpolo1@users.noreply.github.com>
2025-08-24 20:35:40 +00:00
8c280bdacc feat: Update package.json scripts and add new dependencies for improved functionality 2025-08-21 22:46:12 +02:00
b6135640e1 Refactor code structure for improved readability and maintainability 2025-08-20 15:29:22 +02:00
9d53410aab Add migration script to import JSON data into SQLite database
- Created a new script `migrate-to-sqlite.js` to migrate data from JSON files into a SQLite database.
- Implemented functions to read JSON files safely and handle errors.
- Established database schema with tables for armour, weapons, bestiary, and rules.
- Added logic to insert data from JSON files into the corresponding database tables.
- Included backup functionality for the existing database before migration.
- Logged import totals and sample data from each table for verification.
- Added a new script `check-shop-stats.js` to fetch and log item statistics from the database.
2025-08-17 19:14:29 +02:00
4c1b19fb8c feat: Implement bestiary routes for data retrieval and management
- Added bestiaryRoutes.js to handle API endpoints for fetching enemies, full bestiary data, and statistics.
- Implemented caching mechanism for bestiary data with a 5-minute expiration.
- Created transformation functions for bestiary entries to standardize data format for the dice roller.
- Added admin-only endpoint to force reload bestiary data with GM authentication.

chore: Create scripts for analyzing and cleaning bestiary data

- Developed analyze-bestiary-quality.js to review data quality and identify duplicates or inconsistencies.
- Implemented clean-bestiary-fields.js to extract and clean specific fields from bestiary entries, reducing text duplication.
- Created clean-corrupted-bestiary.js to remove corrupted entries based on defined patterns.
- Generated a comprehensive database-cleanup-report.md summarizing the cleaning process and results.

build: Add fast build script for streamlined deployment

- Introduced fast-build.sh to facilitate quick builds and PM2 reloads without reinstalling dependencies.

test: Add GM authentication logic test

- Created test-gm-auth.js to verify the correctness of GM authentication logic with various test cases.
2025-08-17 18:15:39 +02:00
caf8a03553 feat: Add scripts for upserting and validating bestiary data
- Implemented `upsert-allewis-from-5001.js` to fetch and update Allewis data from API.
- Created `upsert-missing-movement-from-5001.js` to fill missing movement and wounds data from API.
- Developed `upsert-missing-movement-from-pdfs.js` to extract movement and wounds from PDF text.
- Added `upsert-missing-profiles-from-pdfs.js` to fill missing profiles from PDF data.
- Introduced `upsert-missing-wounds-from-pdfs.js` to update wounds data from PDF sources.
- Created `validate-bestiary.js` to validate the structure of the bestiary JSON.
- Updated `BestiaryTab.jsx` component to display bestiary data with improved structure and search functionality.
- Added tests for `BestiaryTab` to ensure proper rendering and functionality.
2025-08-17 16:21:00 +02:00
671865d100 feat: enhance build process and testing workflow
- Updated package.json scripts to include separate unit and integration tests before building.
- Added a new script `test-build-test` to run tests before and after the build process.
- Introduced a new local CI/CD script for streamlined local development and testing.
- Refactored PlayerTab component to normalize skills data structure and added tooltips for Space Marine and Power Armour abilities.
- Added named export for Tooltip in DeathwatchRoller for reuse in other components.
2025-08-16 15:14:28 +02:00
b6320ceff6 Remove MongoDB; add PM2 scripts, CI, tests; fix PlayerTab hooks; add pm2 smoke-test 2025-08-16 13:01:30 +02:00