Module rpgstat::attributes[][src]

Expand description

Attributes

These are definitions of abstract terms into code

Rate

Rate of occurance

use rpgstat::attributes::Rate;
let yes:Rate = Rate::Always;
assert_eq!(yes.worked(), true);
let no:Rate = Rate::None;
assert_eq!(no.worked(), false);
let hmmm:Rate = Rate::Some;
// who knows....

Effectiveness

We can easily find the value of an effectiveness:

use rpgstat::attributes::{Effectiveness, Value};
let hp:i32 = 50;
// later on we use an item and check the effectiveness of it
assert_eq!(Effectiveness::Half.value(hp), 25);

This effectiveness can be stored in a struct and you could implement a wrapper for value(T):

use rpgstat::attributes::{Effectiveness, Value};

pub struct Item {
    pub name:String,
    pub amount:i32,
    pub effectiveness:Effectiveness,
}
impl Item {
    // much easier to use now!
    pub fn value(&self) -> i32 {
        self.effectiveness.value(self.amount)
    }
}

Stage

use rpgstat::attributes::{Stage, Value};
let stage:Stage = Stage::Baby.value(15);
//
assert_eq!(stage, Stage::Teen);

Structs

Enums

This is the ‘stage’ of life the creature is in Stages of life are similar to Pokemon evolution, however our creatures cannot change species randomly Using a life stage is based in real life, rather than the random changing into some other species thing

Traits