Character Stats Design Document - wwestlake/Labyrinth GitHub Wiki

Character Stats Design Document

Overview

This document outlines the design and implementation of character stats in the Labyrinth game. The stats, which are currently represented as simple integers, will be enhanced to become more dynamic objects. Each stat will include a base value, potential buffs and debuffs, a total value, timestamps to track when buffs and debuffs are applied, and durations to manage their expiration.


Stat Object Structure

Each stat will be represented as an object that encapsulates the following properties:

  1. Base Value:

    • Definition: The core value of the stat as determined by the initial dice rolls and any permanent modifiers (e.g., from character class or leveling up).
    • Purpose: This value serves as the foundation upon which any temporary buffs or debuffs are applied.
  2. Buff Value:

    • Definition: A positive modifier that temporarily increases the stat value.
    • Purpose: Buffs enhance the stat for a limited duration, providing a temporary advantage to the character.
    • Management: Buffs will have an associated timestamp and duration. The timestamp records when the buff was applied, and the duration specifies how long the buff lasts.
  3. Debuff Value:

    • Definition: A negative modifier that temporarily decreases the stat value.
    • Purpose: Debuffs reduce the stat for a limited duration, representing temporary disadvantages such as injuries or curses.
    • Management: Debuffs will also have an associated timestamp and duration, similar to buffs.
  4. Total Value:

    • Definition: The current effective value of the stat, calculated as: [ \text{Total Value} = \text{Base Value} + \text{Buff Value} - \text{Debuff Value} ]
    • Purpose: This value is used in all calculations involving the stat during gameplay, representing the character's current capability.
  5. Timestamps and Durations for Buffs and Debuffs:

    • Definition: Each buff and debuff will include a timestamp indicating when it was applied and a duration that determines how long it lasts.
    • Purpose: Timestamps and durations allow the system to automatically manage the expiration of buffs and debuffs, ensuring that temporary effects do not persist indefinitely.

Stat Object Lifecycle

  1. Initialization:

    • When a character is created, each stat object is initialized with a Base Value determined by the dice rolls and any permanent modifiers.
    • Buff Value and Debuff Value are initialized to 0, with no active durations.
  2. Applying Buffs and Debuffs:

    • Buffs and debuffs can be applied through various in-game effects, such as spells, abilities, or environmental factors.
    • When a buff or debuff is applied, the Buff Value or Debuff Value is updated, and a timestamp and duration are recorded.
    • The Total Value is recalculated immediately after applying any buff or debuff.
  3. Expiration of Buffs and Debuffs:

    • Buffs and debuffs are temporary. The system will regularly check the timestamps and durations associated with each buff and debuff to determine if they have expired.
    • Once a buff or debuff expires, the corresponding value is reset to 0, and the Total Value is recalculated.
  4. Stat Usage in Gameplay:

    • The Total Value of each stat is used in all relevant gameplay mechanics, such as combat, skill checks, and other interactions.
    • The dynamic nature of buffs and debuffs ensures that characters’ capabilities can fluctuate based on in-game events.

Stat Object Design

The Stat class will encapsulate all the properties and behaviors mentioned above. Here’s a conceptual overview of how the class will function:

  • Properties:

    • int BaseValue
    • int BuffValue
    • int DebuffValue
    • int TotalValue
    • DateTime BuffTimestamp
    • TimeSpan BuffDuration
    • DateTime DebuffTimestamp
    • TimeSpan DebuffDuration
  • Methods:

    • ApplyBuff(int value, TimeSpan duration)
    • ApplyDebuff(int value, TimeSpan duration)
    • CheckBuffExpiration()
    • CheckDebuffExpiration()
    • RecalculateTotalValue()

Managing Buffs and Debuffs

  1. Applying Effects:

    • Effects that modify stats will interface with the Stat object’s methods to apply buffs or debuffs.
    • The duration of these effects will be managed internally, ensuring that they expire as expected.
  2. Expiration Check:

    • A background process or scheduled task will periodically check all active buffs and debuffs to see if they have expired based on their timestamps and durations.
    • Expired effects will be removed, and the Total Value will be recalculated to reflect the current state.
  3. User Interface Considerations:

    • Players should be able to see their current stats, including any active buffs and debuffs.
    • The UI should clearly indicate when buffs or debuffs are active, their remaining durations, and when they are expected to expire.

Conclusion

This design enhances the current stat system by transforming simple numeric values into dynamic objects that can be influenced by in-game events. The introduction of buffs, debuffs, and their management through timestamps and durations provides a deeper level of gameplay, allowing for temporary changes in character performance that can be strategically utilized by players. This system lays the groundwork for a more complex and engaging character development experience in the Labyrinth game.