Architecture Document for Character Management - wwestlake/Labyrinth GitHub Wiki

3. Architecture Document for Character Management

Overview:

This document outlines the architecture for managing characters in the Labyrinth game, including how characters are structured, how experience points and leveling work, and how stat management is handled.

Character Class Structure:

  • Character (Abstract Base Class)
    • Properties:
      • Id: Unique identifier for the character.
      • Name: Character's name.
      • Level: Current level of the character.
      • ExperiencePoints: Current XP of the character.
      • CurrentRoomId: ID of the room where the character is currently located.
    • Stats:
      • Health, Mana, Strength, Dexterity, Constitution, Intelligence, Wisdom, Charisma, Luck: Instances of the Stat class, representing the character’s core attributes.
    • Methods:
      • ExecuteAttack, ExecuteDefend, ExecuteUseAbility: Default actions for attacking, defending, and using abilities.
      • UpdateStats: Recalculates total stat values, considering buffs and debuffs.
      • AddExperience: Adds XP to the character and checks for level-up.
      • CheckLevelUp: Determines if the character has enough XP to level up.
      • LevelUp: Handles the process of leveling up and allocating bonus points.
      • CalculateXpNeededForNextLevel: Calculates the XP required to reach the next level.

PlayerCharacter:

  • Inherits from Character.
  • Additional Properties:
    • CharacterClass: The class of the character (e.g., Warrior, Mage).
    • UserId: The ID of the user who controls this character.
  • Methods:
    • Custom implementations or extensions of ExecuteAttack, ExecuteDefend, ExecuteUseAbility as needed for specific character classes.

NonPlayerCharacter:

  • Inherits from Character.
  • Additional Properties:
    • AggressionLevel: Determines the NPC's tendency to engage in combat.
  • Methods:
    • Default behavior implementations for attacking, defending, and using abilities.

Stat Management:

  • Stat Class:
    • Manages base values, buffs, debuffs, and total values.
    • Handles the application and expiration of buffs and debuffs over time.
    • Recalculates the total value whenever buffs or debuffs are modified.

Experience and Leveling System:

  • Experience Points:

    • Gained through actions such as combat, quests, and exploration.
    • Experience resets to zero after each level-up.
    • The required XP for leveling up increases exponentially to reflect increasing difficulty.
  • Leveling Up:

    • Triggers additional rewards such as bonus points for stat improvement.
    • Players allocate bonus points to their stats, permanently improving them.
    • The system may incorporate diminishing returns or caps on stat improvement to ensure balanced gameplay.

Handling Character Classes:

  • CharacterClass Enum:
    • Defines available character classes such as Warrior, Mage, Rogue, etc.
    • Each class may have unique starting stats, abilities, and leveling bonuses.

Data Persistence:

  • MongoDB:
    • Characters are stored in a MongoDB database, with ObjectIds used for unique identification.
    • Character stats, experience points, and levels are persisted to ensure continuity between sessions.

Extensions and Future Enhancements:

  • Additional Classes: More character classes can be added as the game expands.
  • Special Abilities: Introduce class-specific abilities and spells that can be unlocked at certain levels.
  • Advanced Stat Management: Implement more complex systems for managing buffs, debuffs, and other temporary effects.