name-of-you-image

What is game_stat?

a small rust library for handling stats that can change with modifiers. Equipped an epic sword? Then your attack stats could increase by 40. Recieved a debuff? Your movement speed could decrease by 50%.

example code

rs let mut armor_stat: Stat<2> = Stat::new(10f32); { let _modifier_handle = armor_stat.add_modifier(StatModifier::Flat(5f32)); println!("armor_stat is: {} it should be 15!", armor_stat.value()); } println!("armor_stat is: {}, It should be 10!", armor_stat.value()); * This code creates a Stat<2>, meaning it can hold a maximum of 2 modifiers. (a design decision explained later) * armor_stat.value() returns our stat value based on what modifiers are active. * We add a flat modifier, it is valid as long as the _modifier_key exists, which is why our value goes back to 10 when it gets dropped from the stack

features

is it battle ready?

I have not used this library in any real project yet. My design choices sounds good on paper, but is it useful? Time will tell.

api design goals

gamestat is free and open source! All code in this repository is dual-licensed under either:

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.