Stats implementation

From Post-Apocalyptic RPG wiki

Jump to: navigation, search

Wip code proposal.png This article features a work in progress code proposal.

A work in progress code proposal is incomplete, but is being actively worked on. The proposal may be in various stages of development, from a somewhat organized idea dump to a fully-formed proposal that just needs a quick spell check.

This document proposes how the implement primary, secondary character stats and skills, as documented in Character_generation_and_stats.



Code design

UML diagram (parital)
  • Statistic
    Instances of this class provide the general information (name, description, ...) about one primary statistic, secondary statistic, or skill.
  • StatisticLevel
    Instances of this class represent one primary statistic, secondary statistic, or skill of one particular character (player character or NPC). Methods: addModifier(key, modifier) and removeModifier(key). This method will behave like a number, by implementing __float__, to make calculations easy.
  • SkillLevel
    This is a subclass of StatisticLevel, only used for skills. SkillLevel has an additional method to add experience, where addExperience(1) means "add an average amount of experience".
    Note: a skill is considered a kind of statistic, because a skill has all the properties from statistic.
  • SecondaryStatisticManager
    This is class calculates the secondary stats, based on primary stats.

Proposal implementation



  • The above skill classes will allow us to implement the statistics system in a simple way.
  • This implementation uses little inheritance.
Personal tools