Frank 59fe69d35d refactor: Unify PDF pagination system and rename templates
BREAKING CHANGE: Template names changed from page1_stats.html to page_1.html

## Phase 1: Unified Pagination Function
- Implemented PaginateMultiList() to replace PaginateSkills(), PaginateSpells(), and PaginatePage2PlayLists()
- Single metadata-driven function handles all list types (skills, weapons, spells, equipment)
- Properly handles filters (learned/unlearned/language) via template metadata
- Shares list trackers by ListType+Filter combination to avoid duplication
- Added comprehensive tests for all edge cases

## Phase 2: Template Naming Convention
- Renamed templates to be data-agnostic:
  - page1_stats.html -> page_1.html
  - page1.2_stats.html -> page_1.2.html
  - page2_play.html -> page_2.html
  - page2.2_play.html -> page_2.2.html
  - page3_spell.html -> page_3.html
  - page3.2_spell.html -> page_3.2.html
  - page4_equip.html -> page_4.html
- Updated GenerateContinuationTemplateName() for new naming (page_1.html -> page_1.2.html)
- Updated ExtractBaseTemplateName() to handle new format
- Updated all test files and source files with new template names

## Phase 3: Simplified RenderPageWithContinuations
- Removed hardcoded switch statements based on template names
- Replaced with generic dataMap and unified pagination call
- Extracted populatePageDataFromDistribution() to handle data mapping
- Template type detection now driven by metadata, not hardcoded names

## Benefits
-  Extensibility: Add new templates without code changes
-  Maintainability: One pagination algorithm instead of three
-  Clarity: Template names reflect page numbers, not content types
-  Flexibility: Templates can mix any data types
-  All 40+ tests passing

## Technical Details
- Added SkillsColumn3 and SkillsColumn4 fields to PageData for continuation pages
- Template metadata loaded from HTML comments drives pagination behavior
- Backward compatibility maintained for old template references in comments
2025-12-21 22:07:46 +01:00
2025-12-18 19:01:18 +01:00

BaMoRT

Bamort ist ein Ersatzwerkzeug für MOAM mit dem Schwerpunkt auf Charakterverwaltung für Rollenspiele. Das Projekt bietet ein einfaches, erweiterbares System zur Charaktererstellung, zum Erlernen neuer Fertigkeiten und zur Charakterentwicklung. Langfristiges Ziel ist es, die Regeln für Charaktererstellung und -weiterentwicklung aus dem Code zu extrahieren und ein austauschbares RegelwerkFramework bereitzustellen.

Ziele

  • Ein modernes, wartbares Ersatzwerkzeug für MOAM mit Fokus auf Charaktere bereitstellen.
  • Primäre Schwerpunkte:
    • Charaktererstellung (Attribute, abgeleitete Werte, Startfertigkeiten).
    • Charakterentwicklung (neue Fertigkeiten erlernen, bestehende Fertigkeiten verbessern).
  • Langfristig: Regeln für Generierung und Fortschritt im Code abbilden und ein Framework anbieten, mit dem verschiedene Regelwerke implementiert und gewechselt werden können.

Architekturüberblick

Monorepo mit zwei Hauptteilen: Backend und Frontend.

  • Backend

    • Sprache: Go (1.25+)
    • Frameworks: Gin (HTTP), GORM (ORM)
    • Zuständigkeiten: API, Geschäftslogik, Regelimplementierung, PDFExport
    • Typische Struktur: Module pro Domäne (character, pdfrender, equipment, ...)
    • Einstiegspunkt: cmd/main.go
  • Frontend

    • Framework: Vue 3 + Vite
    • State: Pinia Stores
    • i18n: Lokalisierungsdateien unter src/locales/
    • Zuständigkeiten: UI für Charaktere (Erstellung, Bearbeitung, Entwicklung), AdminWerkzeuge
  • Daten & DevOps

    • Datenbank: MariaDB für Entwicklung/Produktion; SQLite für Tests
    • Container: Docker Compose mit separaten DevContainern für Backend, Frontend und DB
    • PDFRendering: chromedp im pdfrenderModul (Chromium im Container erforderlich)

Kurze Entwicklerhinweise

  • Geschützte APIRouten liegen unter /api und erfordern JWTAuth.
  • Vorlagen für Charakterexport liegen in templates/ und sind per ENVVar TEMPLATES_DIR konfigurierbar.
  • DevDockerCompose für LiveReload verwenden:
    • Backend: bamort-backend-dev (Air, Port 8180)
    • Frontend: bamort-frontend-dev (Vite, Port 5173)
    • DB: bamort-mariadb-dev (MariaDB)

Tests

  • BackendTests nutzen testutils.SetupTestDB() und die Testumgebung (ENVIRONMENT=test).
  • NIEMALS main() in Testdateien hinzufügen; Tests müssen auf _test.go enden.
  • Beispielbefehle:
    • cd backend && go test -v ./character/
    • cd backend && go test -v ./pdfrender/ -run TestExportCharacterToPDF

Plan für erweiterbare Regelwerke

  • Kernidee: Regeln für Generierung und Fortschritt aus unstrukturierter Logik in modulare, versionierte RegelwerkPakete überführen.
  • Regelwerke sollen:
    • Validierungs und Generierungsschritte für Charaktere definieren.
    • Hooks für Lern und Fortschrittsalgorithmen von Fertigkeiten bereitstellen.
    • Laufzeitwahl ermöglichen (Konfiguration oder pro Kampagne).
  • Anfangs werden kanonische Regeln hartkodiert; spätere Refactorings extrahieren Schnittstellen und liefern BeispielRegelwerke.

Mitwirkung

  • KISS und TDD: zuerst fehlschlagende Tests schreiben, dann minimale Implementierung.
  • Neue UIStrings in beiden src/locales/de und src/locales/en ergänzen.
  • Änderungen modular pro Domänenmodul halten (BackendModulkonvention beachten).

Wo anfangen

  • backend/character — CharakterHandler und Routen
  • backend/models — Datenmodelle
  • backend/pdfrender — PDFTemplates und RenderingLogik
  • frontend/src/views — HauptUI für Charakterarbeiten

Lizenz

Lege eine passende LICENSEDatei im Repository an.

BaMoRT for english readers

Bamort is a replacement tool for MOAM focused on character management for roleplaying games. The project aims to provide a simple, extensible system for character creation, learning new skills, and character development, with a longterm goal of extracting the rules for character generation and advancement from code and exposing a pluggable ruleset framework.

Goals

  • Provide a modern, maintainable replacement for MOAM focused on characters.
  • First-class focus on:
    • Character creation (attributes, derived values, starting skills).
    • Character development (learning new skills, improving existing skills).
  • Long-term: encode generation & progression rules in code and offer a framework so different rulesets can be implemented and swapped.

Architecture overview

Monorepo with two primary parts: backend and frontend.

  • Backend

    • Language: Go (1.25+)
    • Frameworks: Gin (HTTP), GORM (ORM)
    • Responsibilities: API, business logic, rules implementation, PDF export
    • Typical layout: modules per domain (character, pdfrender, equipment, ...)
    • Entry point: cmd/main.go
  • Frontend

    • Framework: Vue 3 + Vite
    • State: Pinia stores
    • i18n: locale files under src/locales/
    • Responsibilities: character UI (creation, edit, development), admin tools
  • Data & Devops

    • Database: MariaDB for dev/prod; SQLite used for tests
    • Containers: Docker Compose with separate dev containers for backend, frontend, and DB
    • PDF rendering: chromedp in the pdfrender module (requires Chromium in container)

Quick dev notes

  • Protected API routes live under /api and require JWT auth.
  • Templates for character export are stored under templates/ and the directory can be configured via env var TEMPLATES_DIR.
  • Use the included docker-compose dev setup for live reload:
    • Backend: bamort-backend-dev (Air, port 8180)
    • Frontend: bamort-frontend-dev (Vite, port 5173)
    • DB: bamort-mariadb-dev (MariaDB)

Testing

  • Backend tests use testutils.SetupTestDB() and a test environment (ENVIRONMENT=test).
  • NEVER add a main() to test files; tests must end with _test.go.
  • Example commands:
    • cd backend && go test -v ./character/
    • cd backend && go test -v ./pdfrender/ -run TestExportCharacterToPDF

Extensible ruleset plan

  • Core idea: move rules for generation and progression from adhoc code into modular, versioned ruleset packages.
  • Rulesets should:
    • Define validation and generation steps for a character.
    • Expose hooks for skill learning and progression algorithms.
    • Be selectable at runtime (config or percampaign).
  • Early work will hardcode canonical rules; later refactors will extract interfaces and provide example alternate rulesets.

Contributing

  • Follow KISS and TDD: write failing tests first, implement minimal change.
  • Add translations to both src/locales/de and src/locales/en for new UI strings.
  • Keep changes modular per domain module (see backend module pattern).

Where to look first

  • backend/character — character handlers and routes
  • backend/models — data models
  • backend/pdfrender — PDF template system and rendering logic handlers and routes
  • frontend/src/views — primary UI entry points for character workflows

License

Choose an appropriate license for the project in a LICENSE file.

S
Description
No description provided
https://bamort.trokan.de
Readme 56 MiB
Languages
Go 66.5%
Vue 23.2%
HTML 5.5%
CSS 3%
JavaScript 1%
Other 0.8%