Status update: I've pretty much finished implementing the primary and secondary character statistics logic.

In my current prototype, character statistics (both primary and secondary) are defined in two parts: a class which defines attributes common to all statistics of that type (e.g. strength), and a class which contains the value of a type of statistic for a particular character. This relationship is shown in the attached UML diagram.

In the more concrete case of primary statistics, instances of the PrimaryCharacterStatistic class define a particular primary statistic type. Thus, the "strength" statistic is defined as:

strength_statistic = PrimaryCharacterStatistic(

long_name='strength',

short_name='ST',

description='You know, muscle. Boom! Boom! Fiah Powah.',

)

While a character's strength statistic is given by:

character.statistics['strength'] = PrimaryStatisticValue(

statistic_type = strength_statistic,

value=50,

)

Secondary statistics work the same way, except they have a few additional attributes and methods which are used to calculate a display value (simply called 'value') used to display the secondary statistic value to the player, and a normalized value (on a scale of [0, 100]) used in calculations.

Notice that SecondaryStatisticValue does not allow the value attribute to be set through the constructor (value and normalized_value are read-only attributes as well) - the value is derived using the

*derive_value(normalized=True)* method, which queries the character's primary statistics to calculate the current value. Consequently, SecondaryStatisticValue instances must be attached to the character they belong to and store a weak reference to that character.

Uploaded with

ImageShack.us