Character Generator Design Document - wwestlake/Labyrinth GitHub Wiki
Character Generator Design Document
Overview
This document outlines the design of the character generation system in the Labyrinth game. The system will allow players to create a new character by rolling stats, assigning bonus points, and selecting a character class. The system aims to provide a mix of randomness and player choice, creating a balanced yet customizable character creation experience.
Character Generation Process
-
Stat Generation:
- Random Stat Rolls:
- Each character will have six core stats: Strength, Dexterity, Constitution, Intelligence, Wisdom, and Charisma.
- Stats are generated by rolling three six-sided dice (3d6) for each stat, producing a value between 3 and 18.
- Using the DiceRollingService:
- The
DiceRollingService
will handle the rolling of dice. It will be used to generate each of the character's core stats. - Example: For each stat, the service will be called with
numberOfSides = 6
andnumberOfDice = 3
, and the result will be stored in the corresponding stat field.
- The
- Random Stat Rolls:
-
Bonus Point Allocation:
- Initial Bonus Points:
- After the stats are rolled, the player is given an additional 25 points to allocate freely among the six stats.
- Reallocating Points:
- Players can remove points from one stat and add them to another. The removed points are added to the pool of bonus points, allowing the player to redistribute them as they see fit.
- Rules Engine Integration:
- The rules engine can be used to enforce constraints on the allocation process, such as ensuring that no stat exceeds a maximum value or drops below a minimum value.
- Initial Bonus Points:
-
Character Class Selection:
- Class Options:
- Players will choose a class for their character, such as Warrior, Mage, Rogue, etc. Each class may have specific requirements or bonuses for certain stats.
- Class Stat Modifiers:
- Upon selecting a class, the character's stats may be modified based on class-specific bonuses or penalties.
- Rules Engine for Class Validation:
- The rules engine will validate that the character meets the requirements for the selected class, such as minimum stat thresholds.
- Class Options:
-
Character Customization:
- Name and Appearance:
- Players can choose a name for their character and possibly customize their appearance, though the latter may be limited to predefined options.
- Starting Equipment:
- Based on the selected class, the character may start with certain items or equipment. This can be predefined or influenced by the rules engine.
- Name and Appearance:
Character Generation Service Design
-
Service Responsibilities:
- Stat Rolling:
- The service will use
DiceRollingService
to roll the initial stats for a new character.
- The service will use
- Bonus Point Allocation:
- The service will handle the logic for distributing and redistributing bonus points based on player input.
- Class Selection and Validation:
- The service will provide methods for selecting a character class and will use the rules engine to ensure the character meets the class requirements.
- Final Character Creation:
- Once the character is fully created and validated, the service will save the character to the database.
- Stat Rolling:
-
Endpoints:
- POST
/api/character/create
:- Endpoint to initiate character creation. It will roll the stats and return the initial character setup to the player.
- POST
/api/character/allocate-points
:- Endpoint to allow players to allocate bonus points to their character’s stats.
- POST
/api/character/select-class
:- Endpoint to select and validate the character’s class.
- POST
/api/character/finalize
:- Endpoint to finalize character creation and save it to the database.
- POST
Validation and Rules
-
Stat Allocation Constraints:
- The rules engine will enforce constraints on stat allocations, such as ensuring that no stat exceeds 18 or falls below 3 after the allocation of bonus points.
- The engine will also ensure that the total points allocated match the number available.
-
Class Selection Rules:
- The rules engine will check that the character’s stats meet the minimum requirements for the chosen class.
- The engine will apply any class-specific bonuses or penalties to the character’s stats upon selection.
Conclusion
This design document outlines the key components and workflow for the character generation system in the Labyrinth game. The system combines random stat generation with player-driven customization, allowing for a diverse range of character builds. The integration of a rules engine ensures that the character creation process is both flexible and balanced, adhering to the game’s design principles.