GameStat

Trait GameStat 

Source
pub trait GameStat {
    // Required methods
    fn get_value(&self) -> isize;
    fn change_value(&mut self, value: isize);
    fn from_value(value: isize) -> Self
       where Self: Sized;

    // Provided methods
    fn to_100(&self) -> isize { ... }
    fn to_10(&self) -> isize { ... }
    fn to_delta(&self) -> String { ... }
}
Expand description

A stat is a game value that can be converted to two different normalised ranges - a 100-point range for “gaming” logic and a 10-point range for “roll & UI” logic. The trait also exposes the underlying raw value and its visibility.

Required Methods§

Source

fn get_value(&self) -> isize

Return the raw integer value, always bound to 0-70

Source

fn change_value(&mut self, value: isize)

Return the raw integer value, always bound to 0-70

Source

fn from_value(value: isize) -> Self
where Self: Sized,

Create a Gamestat from it’s underlying value

Provided Methods§

Source

fn to_100(&self) -> isize

Convert the raw integer to a 50-point scale.

Source

fn to_10(&self) -> isize

Convert the raw integer to a 10-point scale.

Source

fn to_delta(&self) -> String

As a colored delta (when the stat is used as a delta)

Implementors§