How yoshimoshi4/dndsim works
Purpose and Entry Point
DnDSim is a desktop tactical RPG/battle simulator and content editor. It models characters, enemies, items, terrain, party setup, and turn-based grid combat using local JSON-backed saves. Main.java is the application entry point; UI/AppController.java is the likely top-level navigation/controller boundary.
Application Navigation and Screens
The UI is organized as JavaFX-style views for the main menu, character sheets, asset editing, battle setup, battle execution, and victory presentation. Controllers/views coordinate user-driven transitions rather than exposing a network API.
• UI/AppController.java
• UI/MainMenuView.java
• UI/AssetEditorView.java
• UI/CharacterSheetView.java
• UI/Battle/BattleView.java
Domain Model and Persistence
Objects/Entity.java defines shared entity behavior, with combatants and map objects specialized into enemies, pickups, and terrain. EntityRes contains serializable resource/domain definitions for character sheets, status, inventory/item categories, and party composition. JSON save directories are the persistent content store, likely read/written through Gson.
• Objects/Entity.java
• Objects/Enemy.java
• EntityRes/CharSheet.java
• EntityRes/ItemDatabase.java
• saves/entities/party/Hana_Shiroi.json
• saves/party.json
Assets, Inventory, and Content Editing
Items are polymorphic resource records—weapon, armor, accessory, consumable, ammunition, crafting, and key items—with abilities and type adaptation supporting JSON deserialization. The asset editor and databases make game content editable independently of active battles.
• EntityRes/Item.java
• EntityRes/ItemTypeAdapter.java
• EntityRes/Weapon.java
• EntityRes/ItemAbility.java
• UI/AssetEditorView.java
• saves/items/weapons/Shortbarrel_Shotgun.json
Battle Grid and Map Assembly
Battle setup creates a grid populated by entities, pickups, and terrain. BattleGrid holds the logical board while BattleGridCanvas and shape/theme classes render it. Terrain definitions are local JSON content mediated by a terrain database.
• UI/Battle/BattleGrid.java
• UI/Battle/BattleGridCanvas.java
• Objects/GridObject.java
• Objects/TerrainObject.java
• UI/TerrainDatabase.java
• saves/terrain/Acid.json
Combat and Turn Lifecycle
BattleState is the central mutable battle-session boundary. CombatManager resolves combat actions against state/grid/entities, while TurnManager controls turn order and progression. UI bindings and panels project battle state into health displays, timeline, dice interaction, and terminal victory flow.
• UI/Battle/BattleState.java
• UI/Battle/CombatManager.java
• UI/Battle/TurnManager.java
• UI/Battle/EntityHealthBinding.java
• UI/Battle/TimelinePane.java
• UI/Battle/VictoryView.java
Rendering, Assets, and Runtime Dependencies
The runtime is Java with JavaFX UI libraries. Gson provides JSON serialization, and Ikonli supplies icon rendering. Sprite and CSS resources support visual presentation; no server, database, or cloud service is represented.
• lib/gson-2.10.1.jar
• lib/ikonli-javafx-12.4.0.jar
• UI/SpriteUtils.java
• resources/sprites/party
• resources/styles/dark-theme.css
Components 20
JavaFX UI
Desktop navigation, editing, and battle presentation.
- Application entry
Main.java - App controller · Top-level boundary for user-driven screen transitions.
UI/AppController.java - Main menu
UI/MainMenuView.java - Character sheet
UI/CharacterSheetView.java - Asset editor · Edits reusable game content independently of battles.
UI/AssetEditorView.java - Battle view
UI/Battle/BattleView.java
Domain & Content
Shared game entities, character data, and item definitions.
- Entity hierarchy · Shared behavior for combatants and map objects.
Objects/Entity.java - Enemy
Objects/Enemy.java - Character & party data
EntityRes/CharSheet.java - Polymorphic items · Item categories and abilities are adapted for JSON deserialization.
EntityRes/Item.java - Item type adapter
EntityRes/ItemTypeAdapter.java
Battle Runtime
Grid assembly, mutable session state, and turn resolution.
- Battle grid · Logical board populated with entities, pickups, and terrain.
UI/Battle/BattleGrid.java - Terrain objects
Objects/TerrainObject.java - Battle state · Central boundary for an active battle session.
UI/Battle/BattleState.java - Combat manager
UI/Battle/CombatManager.java - Turn manager
UI/Battle/TurnManager.java - Grid canvas
UI/Battle/BattleGridCanvas.java - Battle HUD & victory · Projects health, timeline, dice interaction, and terminal results.
UI/Battle/VictoryView.java
Local Resources
JSON saves and visual resources bundled with the desktop app.
- JSON save content · Local party, entity, item, and terrain definitions.
saves/party.json - Sprites & dark theme
resources/styles/dark-theme.css
Connections 27
- Application entry → App controller: starts
- App controller → Main menu: navigates
- App controller → Character sheet: navigates
- App controller → Asset editor: navigates
- App controller → Battle view: navigates
- Entity hierarchy → Enemy: specializes
- Character & party data → Entity hierarchy: defines combatants
- Item type adapter → Polymorphic items: deserializes
- Asset editor → Polymorphic items: edits
- Asset editor → JSON save content: reads / writes
- Character sheet → Character & party data: edits
- JSON save content → Character & party data: loads
- JSON save content → Polymorphic items: loads
- JSON save content → Terrain objects: loads
- Battle view → Battle state: drives
- Battle state → Battle grid: owns session board
- Battle grid → Entity hierarchy: places
- Battle grid → Terrain objects: places
- Combat manager → Battle state: resolves actions
- Turn manager → Battle state: advances turns
- Battle view → Combat manager: submits actions
- Battle view → Turn manager: uses turn order
- Grid canvas → Battle grid: renders
- Battle view → Grid canvas: contains
- Battle HUD & victory → Battle state: projects
- Battle view → Battle HUD & victory: shows
- Sprites & dark theme → Grid canvas: styles sprites