RPG Stat library
Cargo.toml
rpgstat="2.0"
This is fairly exhaustive and links to most things you can use. The library is stil a WIP as the battle system is rudimentary in the current form. TOML format with serde is supported.
Stats
The Stats are broken down into categories Basic
, Normal
, and Advanced
Basic
contains only the most needed for a generic game
Your file needs:
use rpgstat::stats::Basic as Stats
- id
- xp
- xp_next
- level
- gp
- hp
- mp
- hp_max
- mp_max
- speed
Normal
includes a few more for the generic RPG battle system as well as everything in Basic
Your file needs:
use rpgstat::stats::Normal as Stats
- atk
- def
- m_atk
- m_def
Advanced
contains the finer details seen in tabletop RPG stats as well as everything in Normal
and Basic
Your file needs:
use rpgstat::stats::Advanced as Stats
- agility
- strength
- dexterity
- constitution
- intelligence
- charisma
- wisdom
- age
Serde + TOML/INI
Yes you can use serde with any of the assets/characters/ files provided. You can use them in your custom structs.
You can implement Premade Stats to have mystruct.hp()
instead of something like below mystruct.stats.hp
use File;
use Read;
use *;
use ;
use Legendary;
use Basic as Stats;
use Builder;
let filename = "assets/characters/EasterBilby.ini";
match open
Custom toml/ini with serde
use ;
use ;
use Basic as Class;
use Basic as Stats;
// example program
const INI_FILE:&str = r#"name="test"
class="Hero"
effectiveness="None"
image="/path/to/file"
[stats]
id = 1
hp = 10
mp = 10
xp = 10
level = 1
hp_max = 10
mp_max = 10
xp_next = 10
gp = 10
speed = 10
atk = 10
def = 10
m_atk = 10
m_def = 10
agi = 10
str = 10
int = 10
dex = 10
con = 10
char = 10
wis = 10
age = 10"#;
let decoded: OccasionalEnemy = from_str.unwrap;
assert_eq!;
assert_eq!;
// Value trait used here:
assert_eq!;
assert_eq!;
assert_eq!;
Builder
Since the 1.X version rpg-stat
has come with a Builder
trait.
The builder trait is being implemented for all the enumerations like the rpgstat::class::*
as well as rpgstat::creature::*
This allows you to do:
// feel free to use `Normal` or `Advanced` instead of `Basic`
use Basic as Stats;
use Basic as Class;
use Animal;
// this is the thing we need!
use Builder;
// get bear stats for our program
// get Hero stats for our program
// TODO make them meet...
Build your own!
If you are not into making stats from things I made, you can implement your own builder:
use Basic as BasicStats;
use Normal as NormalStats;
use Advanced as AdvancedStats;
use Builder;
use ;
// gee maybe I should make stats for these awesome libre characters
Classes
The Classes are broken down into categories Basic
, Normal
, and Advanced
The Basic
class is either Hero
or Enemy
Your file needs:
use rpgstat::class::Basic as Class
The Normal
class includes a range of character classes for a battle game.
Your file needs:
use rpgstat::class::Normal as Class
Advanced
includes more characters for a game with interactive roles, not simply a game of battle.
Your file needs:
use rpgstat::class::Advanced as Class
The stat Builder
is implemented for all the classes and can be used easily:
use Normal as Stats;
use Normal as Class;
// *Use this*
use Builder;
// get Hero stats for our program
Creatures
Compare
The Compare trait is implemented for Normal
according to this chart:
use Normal as Type;
// to check effectiveness
use Compare;
// need effectiveness too!
use Effectiveness;
let rock = Rock;
let wind = Wind;
assert_eq!;
assert_eq!;
Special
These are names of Special
moves.
use Normal as Special;
let grind:Special = Grind;
You can get the prebuilt mp_cost()
:
use ManaCost;
use Normal as Special;
let grind:Special = Grind;
assert_eq!;
Effect
This composes the various Effects in-game related to a character's Stats
Attributes
These are definitions of abstract terms into code
Rate
Rate of occurance
use Rate;
let yes:Rate = Always;
assert_eq!;
let no:Rate = None;
assert_eq!;
let hmmm:Rate = Some;
// who knows....
Effectiveness
This effectiveness can be stored in a struct and you could implement a wrapper for value(T)
:
use ;
use ;
let hp:i32 = 50;
// later on we use an item and check the effectiveness of it
assert_eq!;
Stage
use Stage;
This includes the Stage<T>
of life. This is similar to things like "evolution" in creature raising games, but based on reality. In real life no creature evolves randomly in front of someone, however they do get older and change their "form". There are eight forms:
- Baby
- Toddler
- Kid
- Teen
- Young
- Grown
- Older
- Old
use Stage;
let stage: = current;
// Yup 15 is teen
assert_eq!;
Body
Currently with the makesvg
feature, Body contains the VectorView
trait which creates vector (SVG) images from parameters.
Work will go into implementing this for other things, such as type.
RPG Stat command line tool
WIP
Ideally, this will use clap
and support some very specific stat traits only.
AFAIK the interface will end up looking like:
rpgstat class normal Archer stat normal hp
That said none of the work has been started yet, and I am open to input.