rpg_stat/
class.rs

1/*!
2# Character Class
3
4This abstraction can be as `Basic` as `Hero` or `Enemy`
5You can even use the fully `Advanced` version to use the entire class realm.
6
7## Builder
8
9Make anything pretty easily from built in classes `Basic`, `Normal`, and `Advanced`
10
11```
12use rpg_stat::stats::Builder;
13use rpg_stat::stats::Basic as Stat;
14use rpg_stat::class::Basic as Class;
15
16let class:Class = Class::Hero;
17let stat:Stat<f64> = class.build_basic(0.0, 1.0);
18```
19
20### Build a `Basic` stat
21
22This is what the code does for `Hero`
23
24```
25type T = f64;
26let hp:T = num::cast(10).unwrap();
27let mp:T = num::cast(5).unwrap();
28let xp:T = num::cast(1).unwrap();
29let xp_next:T = num::cast(10).unwrap();
30let gp:T = num::cast(5).unwrap();
31let speed:T = num::cast(10).unwrap();
32```
33
34### Build a `Normal` stat
35
36This is what the code does for `Hero`
37
38```
39type T = f64;
40let hp:T = num::cast(10).unwrap();
41let mp:T = num::cast(5).unwrap();
42let xp:T = num::cast(1).unwrap();
43let xp_next:T = num::cast(10).unwrap();
44let gp:T = num::cast(5).unwrap();
45let speed:T = num::cast(10).unwrap();
46let atk:T = num::cast(10).unwrap();
47let def:T = num::cast(10).unwrap();
48let m_atk:T = num::cast(10).unwrap();
49let m_def:T = num::cast(10).unwrap();
50```
51
52### Build a `Advanced` stat
53
54This is what the code does for `Hero`
55
56```
57type T = f64;
58let hp:T = num::cast(10).unwrap();
59let mp:T = num::cast(5).unwrap();
60let xp:T = num::cast(1).unwrap();
61let xp_next:T = num::cast(10).unwrap();
62let gp:T = num::cast(5).unwrap();
63let speed:T = num::cast(10).unwrap();
64let atk:T = num::cast(10).unwrap();
65let def:T = num::cast(10).unwrap();
66let m_atk:T = num::cast(10).unwrap();
67let m_def:T = num::cast(10).unwrap();
68let agility:T = num::cast(10).unwrap();
69let strength:T = num::cast(10).unwrap();
70let dexterity:T = num::cast(10).unwrap();
71let constitution:T = num::cast(10).unwrap();
72let intelligence:T = num::cast(10).unwrap();
73let charisma:T = num::cast(10).unwrap();
74let wisdom:T = num::cast(10).unwrap();
75let age:T = num::cast(10).unwrap();
76```
77
78*/
79use std::fmt;
80use serde::{Deserialize, Serialize};
81use std::ops::{Add, AddAssign,  Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub, SubAssign};
82use std::fmt::Debug;
83
84#[cfg(feature = "fltkform")]
85use fltk::{prelude::*, *};
86#[cfg(feature = "fltkform")]
87use fltk_form_derive::*;
88#[cfg(feature = "fltkform")]
89use fltk_form::FltkForm;
90
91// RPG Stat
92use crate::stats::Basic as BasicStats;
93use crate::stats::Normal as NormalStats;
94use crate::stats::Advanced as AdvancedStats;
95use crate::stats::Builder;
96use crate::random::*;
97
98/*
99Alignement allows for the creation of multile outcomes in situations
100
101This is a WIP currently
102
103*/
104#[allow(unused)]
105#[derive(Clone, PartialEq, Copy, Debug, Serialize, Deserialize)]
106#[cfg_attr(feature = "fltkform", derive(FltkForm))]
107pub enum Alignment {
108    Light,
109    Dark,
110    Undecided,
111}
112impl Default for Alignment {
113    fn default() -> Self {
114        Self::Undecided
115    }
116}
117impl fmt::Display for Alignment {
118    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
119        let v:String;
120        match *self {
121            Alignment::Light => v = String::from("Light"),
122            Alignment::Dark => v = String::from("Dark"),
123            Alignment::Undecided => v = String::from("Undecided"),
124        }
125        write!(f, "{}", v.as_str())
126    }
127}
128
129/*
130# Basic Class
131
132Default to making an `Enemy`, because there are honestly few `Hero`s in games
133
134## Builder
135
136Make anything pretty easily from built in classes
137
138```
139use rpg_stat::stat::Builder;
140use rpg_stat::stat::Basic as Stat;
141use rpg_stat::class::Basic as Class;
142
143let class:Class = Class::Hero;
144let stat:Stat<f64> = class.build_basic();
145```
146
147*/
148#[allow(unused)]
149#[derive(Clone, PartialEq, Copy, Debug, Serialize, Deserialize)]
150#[cfg_attr(feature = "fltkform", derive(FltkForm))]
151pub enum Basic {
152    /// Obviously the protagonist
153    Hero,
154    /// Obviously the antagonist
155    Enemy,
156}
157impl Default for Basic {
158    fn default() -> Self {
159        Self::Enemy
160    }
161}
162impl fmt::Display for Basic {
163    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
164        let v:String;
165        match *self {
166            Basic::Hero => v = String::from("Hero"),
167            Basic::Enemy => v = String::from("Enemy"),
168        }
169        write!(f, "{}", v.as_str())
170    }
171}
172impl<T:Copy
173    + Default
174    + Debug
175    + AddAssign
176    + Add<Output = T>
177    + Div<Output = T>
178    + DivAssign
179    + Mul<Output = T>
180    + MulAssign
181    + Neg<Output = T>
182    + Rem<Output = T>
183    + RemAssign
184    + Sub<Output = T>
185    + SubAssign
186    + std::cmp::PartialOrd
187    + num::NumCast> Builder<T> for Basic {
188    fn build_basic(&self, id:T, level:T) -> BasicStats<T>{
189        let mut hp:T = num::cast(10).unwrap();
190        let mut mp:T = num::cast(5).unwrap();
191        let mut xp:T = num::cast(1).unwrap();
192        let mut xp_next:T = num::cast(10).unwrap();
193        let mut gp:T = num::cast(5).unwrap();
194        let mut speed:T = num::cast(10).unwrap();
195        match *self {
196            Basic::Hero => {},
197            Basic::Enemy => {
198                xp = num::cast(1).unwrap();
199                xp_next =num::cast(10).unwrap();
200                hp = num::cast(5).unwrap();
201                mp = num::cast(5).unwrap();
202                speed = num::cast(7).unwrap();
203            },
204        }
205        hp *= level;
206        mp *= level;
207        // TODO fixme:
208        xp *= level;
209        // TODO fixme:
210        xp_next *= level;
211        gp *= level;
212        speed += level;
213        BasicStats {
214            id,
215            xp,
216            xp_next,
217            level,
218            gp,
219            hp,
220            mp,
221            hp_max:hp,
222            mp_max:mp,
223            speed,
224        }
225        
226    }
227    fn build_normal(&self, id:T, level:T) -> NormalStats<T>{
228        let mut hp:T = num::cast(10).unwrap();
229        let mut mp:T = num::cast(5).unwrap();
230        let mut xp:T = num::cast(1).unwrap();
231        let mut xp_next:T = num::cast(10).unwrap();
232        let mut gp:T = num::cast(5).unwrap();
233        let mut speed:T = num::cast(10).unwrap();
234        let atk:T = num::cast(10).unwrap();
235        let def:T = num::cast(10).unwrap();
236        let m_atk:T = num::cast(10).unwrap();
237        let m_def:T = num::cast(10).unwrap();
238        match *self {
239            Basic::Hero => {},
240            Basic::Enemy => {
241                xp = num::cast(1).unwrap();
242                xp_next =num::cast(10).unwrap();
243                hp = num::cast(5).unwrap();
244                mp = num::cast(5).unwrap();
245                speed = num::cast(7).unwrap();
246            },
247        }
248        hp *= level;
249        mp *= level;
250        // TODO fixme:
251        xp *= level;
252        // TODO fixme:
253        xp_next *= level;
254        gp *= level;
255        speed += level;
256        NormalStats {
257            id,
258            xp,
259            xp_next,
260            level,
261            gp,
262            hp,
263            mp,
264            hp_max:hp,
265            mp_max:mp,
266            speed,
267            atk,
268            def,
269            m_atk,
270            m_def,
271        }
272    }
273    fn build_advanced(&self, id:T, level:T) -> AdvancedStats<T>{
274        let mut hp:T = num::cast(10).unwrap();
275        let mut mp:T = num::cast(5).unwrap();
276        let mut xp:T = num::cast(1).unwrap();
277        let mut xp_next:T = num::cast(10).unwrap();
278        let mut gp:T = num::cast(5).unwrap();
279        let mut speed:T = num::cast(10).unwrap();
280        let atk:T = num::cast(10).unwrap();
281        let def:T = num::cast(10).unwrap();
282        let m_atk:T = num::cast(10).unwrap();
283        let m_def:T = num::cast(10).unwrap();
284        let agility:T = num::cast(10).unwrap();
285        let strength:T = num::cast(10).unwrap();
286        let dexterity:T = num::cast(10).unwrap();
287        let constitution:T = num::cast(10).unwrap();
288        let intelligence:T = num::cast(10).unwrap();
289        let charisma:T = num::cast(10).unwrap();
290        let wisdom:T = num::cast(10).unwrap();
291        let age:T = num::cast(10).unwrap();
292        match *self {
293            Basic::Hero => {},
294            Basic::Enemy => {
295                xp = num::cast(1).unwrap();
296                xp_next =num::cast(10).unwrap();
297                hp = num::cast(5).unwrap();
298                mp = num::cast(5).unwrap();
299                speed = num::cast(7).unwrap();
300            },
301        }
302        hp *= level;
303        mp *= level;
304        // TODO fixme:
305        xp *= level;
306        // TODO fixme:
307        xp_next *= level;
308        gp *= level;
309        speed += level;
310        AdvancedStats {
311            id,
312            xp,
313            xp_next,
314            level,
315            gp,
316            hp,
317            mp,
318            hp_max:hp,
319            mp_max:mp,
320            speed,
321            atk,
322            def,
323            m_atk,
324            m_def,
325            agility,
326            strength,
327            dexterity,
328            constitution,
329            intelligence,
330            charisma,
331            wisdom,
332            age,
333        }
334    }
335}
336/*
337# The "Normal" type of class
338
339This can be used in combination with `Basic` if both sides are the same, to provide PvP, or soldier battle scenarios
340
341To use this alone something like `Soldier` could be the enemies in that scenario, or however one sees fit.
342
343You can couple these things with `Alignment` to produce variations on Monks, Elementals, Alchemists, etc..
344
345## Builder
346
347Make anything pretty easily from built in classes
348
349```
350use rpg_stat::stat::Builder;
351use rpg_stat::stat::Normal as Stat;
352use rpg_stat::class::Normal as Class;
353
354let class:Class = Class::Archer;
355let stat:Stat<f64> = class.build_normal();
356```
357
358*/
359#[allow(unused)]
360#[derive(Clone, PartialEq, Copy, Debug, Serialize, Deserialize)]
361#[cfg_attr(feature = "fltkform", derive(FltkForm))]
362pub enum Normal {
363    /// Full of concotions to both heal and harm.
364    Alchemist,
365    /// Aw, shoot you are good!
366    Archer,
367    /// Devoted to studying the elements and harnessing their powers
368    Elemental,
369    /// Generally this is the good guy in the story...
370    Knight,
371    /// Devoted to reading really old books and figuring out really old combinations of substances
372    Monk,
373    /// Into life magic, which overcomes death magic
374    Priest,
375    /// This is the default, because a lot of RPG games involve the `Soldier` in a dungeon being an enemy for whatever reason...
376    Soldier,
377    /// Incredibly stealthy, this rounded character can survive any environment
378    Ranger,
379    /// The elite female warriors from the deepest coldest winters
380    Valkyrie,
381}
382impl Default for Normal {
383    fn default() -> Self {
384        Self::Soldier
385    }
386}
387impl fmt::Display for  Normal{
388    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
389        let v:String;
390        match *self {
391            Normal::Alchemist => v = String::from("Alchemist"),
392            Normal::Archer => v = String::from("Archer"),
393            Normal::Elemental => v = String::from("Elemental"),
394            Normal::Knight => v = String::from("Knight"),
395            Normal::Monk => v = String::from("Monk"),
396            Normal::Priest => v = String::from("Priest"),
397            Normal::Soldier => v = String::from("Soldier"),
398            Normal::Ranger => v = String::from("Ranger"),
399            Normal::Valkyrie => v = String::from("Valkyrie"),
400        }
401        write!(f, "{}", v.as_str())
402    }
403}
404impl<T:Copy
405    + Default
406    + Debug
407    + AddAssign
408    + Add<Output = T>
409    + Div<Output = T>
410    + DivAssign
411    + Mul<Output = T>
412    + MulAssign
413    + Neg<Output = T>
414    + Rem<Output = T>
415    + RemAssign
416    + Sub<Output = T>
417    + SubAssign
418    + std::cmp::PartialOrd
419    + num::NumCast> Builder<T> for Normal {
420    /// Build a `Basic` stat
421    fn build_basic(&self, id:T, level:T) -> BasicStats<T>{
422        let mut hp:T;
423        let mut mp:T;
424        let mut xp:T = num::cast(1).unwrap();
425        let mut xp_next:T = num::cast(10).unwrap();
426        let mut gp:T = num::cast(5).unwrap();
427        let mut speed:T;
428        match *self {
429            Normal::Alchemist => {
430                hp =  num::cast(40).unwrap();
431                mp =  num::cast(16).unwrap();
432                speed =  num::cast(5).unwrap();
433            },
434            Normal::Archer => {
435                hp =  num::cast(50).unwrap();
436                mp =  num::cast(25).unwrap();
437                speed =  num::cast(5).unwrap();
438            },
439            Normal::Knight => {
440                hp =  num::cast(50).unwrap();
441                mp =  num::cast(20).unwrap();
442                speed =  num::cast(7).unwrap();
443            },
444            Normal::Monk => {
445                hp = num::cast(50).unwrap();
446                mp = num::cast(20).unwrap();
447                speed = num::cast(5).unwrap();
448            },
449            Normal::Elemental => {
450                hp = num::cast(70).unwrap();
451                mp = num::cast(40).unwrap();
452                speed = num::cast(4).unwrap();
453            },
454            Normal::Priest => {
455                hp = num::cast(60).unwrap();
456                mp = num::cast(10).unwrap();
457                speed = num::cast(4).unwrap();
458            },
459            Normal::Soldier => {
460                hp = num::cast(90).unwrap();
461                mp = num::cast(0).unwrap();
462                speed = num::cast(5).unwrap();
463            },
464            Normal::Ranger => {
465                hp = num::cast(40).unwrap();
466                mp = num::cast(70).unwrap();
467                speed = num::cast(8).unwrap();
468            },
469            Normal::Valkyrie => {
470                hp = num::cast(50).unwrap();
471                mp = num::cast(10).unwrap();
472                speed = num::cast(7).unwrap();
473            },
474        }
475        hp *= level;
476        mp *= level;
477        // TODO fixme:
478        xp *= level;
479        // TODO fixme:
480        xp_next *= level;
481        gp *= level;
482        speed += level;
483        BasicStats {
484            id,
485            xp,
486            xp_next,
487            level,
488            gp,
489            hp,
490            mp,
491            hp_max:hp,
492            mp_max:mp,
493            speed,
494        }
495        
496    }
497    // Build a `Normal` stat
498    fn build_normal(&self, id:T, level:T) -> NormalStats<T>{
499        let mut hp:T;
500        let mut mp:T;
501        let mut xp:T = num::cast(1).unwrap();
502        let mut xp_next:T = num::cast(10).unwrap();
503        let mut gp:T = num::cast(5).unwrap();
504        let mut speed:T;
505        let mut atk:T;
506        let mut def:T;
507        let mut m_atk:T;
508        let mut m_def:T;
509        match *self {
510            Normal::Alchemist => {
511                hp =  num::cast(40).unwrap();
512                mp =  num::cast(16).unwrap();
513                atk =  num::cast(14).unwrap();
514                def =  num::cast(30).unwrap();
515                m_atk =  num::cast(20).unwrap();
516                m_def =  num::cast(30).unwrap();
517                speed =  num::cast(5).unwrap();
518            },
519            Normal::Archer => {
520                hp =  num::cast(50).unwrap();
521                mp =  num::cast(25).unwrap();
522                atk =  num::cast(15).unwrap();
523                def =  num::cast(10).unwrap();
524                m_atk =  num::cast(15).unwrap();
525                m_def =  num::cast(35).unwrap();
526                speed =  num::cast(5).unwrap();
527            },
528            Normal::Knight => {
529                hp =  num::cast(50).unwrap();
530                mp =  num::cast(20).unwrap();
531                atk =  num::cast(20).unwrap();
532                def =  num::cast(20).unwrap();
533                m_atk =  num::cast(20).unwrap();
534                m_def =  num::cast(20).unwrap();
535                speed =  num::cast(7).unwrap();
536            },
537            Normal::Monk => {
538                hp = num::cast(50).unwrap();
539                mp = num::cast(20).unwrap();
540                atk = num::cast(10).unwrap();
541                def = num::cast(15).unwrap();
542                m_atk = num::cast(5).unwrap();
543                m_def = num::cast(40).unwrap();
544                speed = num::cast(5).unwrap();
545            },
546            Normal::Elemental => {
547                hp = num::cast(70).unwrap();
548                mp = num::cast(40).unwrap();
549                atk = num::cast(1).unwrap();
550                def = num::cast(8).unwrap();
551                m_atk = num::cast(30).unwrap();
552                m_def = num::cast(1).unwrap();
553                speed = num::cast(4).unwrap();
554            },
555            Normal::Priest => {
556                hp = num::cast(60).unwrap();
557                mp = num::cast(10).unwrap();
558                atk = num::cast(20).unwrap();
559                def = num::cast( 10).unwrap();
560                m_atk = num::cast(10).unwrap();
561                m_def = num::cast(40).unwrap();
562                speed = num::cast(4).unwrap();
563            },
564            Normal::Soldier => {
565                hp = num::cast(90).unwrap();
566                mp = num::cast(0).unwrap();
567                atk = num::cast(30).unwrap();
568                def = num::cast(12).unwrap();
569                m_atk = num::cast(0).unwrap();
570                m_def = num::cast(18).unwrap();
571                speed = num::cast(5).unwrap();
572            },
573            Normal::Ranger => {
574                hp = num::cast(40).unwrap();
575                mp = num::cast(70).unwrap();
576                atk = num::cast(15).unwrap();
577                def = num::cast( 9).unwrap();
578                m_atk = num::cast(11).unwrap();
579                m_def = num::cast(30).unwrap();
580                speed = num::cast(8).unwrap();
581            },
582            Normal::Valkyrie => {
583                hp = num::cast(50).unwrap();
584                mp = num::cast(10).unwrap();
585                atk = num::cast(20).unwrap();
586                def = num::cast(20).unwrap();
587                m_atk = num::cast(20).unwrap();
588                m_def = num::cast(30).unwrap();
589                speed = num::cast(7).unwrap();
590            },
591        }
592        hp *= level;
593        mp *= level;
594        // TODO fixme:
595        xp *= level;
596        // TODO fixme:
597        xp_next *= level;
598        gp *= level;
599        speed += level;
600        atk += level;
601        m_atk += level;
602        def += level;
603        m_def += level;
604        NormalStats {
605            id,
606            xp,
607            xp_next,
608            level,
609            gp,
610            hp,
611            mp,
612            hp_max:hp,
613            mp_max:mp,
614            speed,
615            atk,
616            def,
617            m_atk,
618            m_def,
619        }
620    }
621
622    // Build an `Advanced` stat
623    fn build_advanced(&self, id:T, level:T) -> AdvancedStats<T>{
624        let mut hp:T;
625        let mut mp:T;
626        let mut xp:T = num::cast(1).unwrap();
627        let mut xp_next:T = num::cast(10).unwrap();
628        let mut gp:T = num::cast(5).unwrap();
629        let mut speed:T;
630        let mut atk:T;
631        let mut def:T;
632        let mut m_atk:T;
633        let mut m_def:T;
634        let mut agility:T;
635        let mut strength:T;
636        let mut dexterity:T;
637        let mut constitution:T;
638        let mut intelligence:T;
639        let mut charisma:T;
640        let mut wisdom:T;
641        let age:T;
642        match *self {
643           Normal::Alchemist => {
644                hp =  num::cast(40).unwrap();
645                mp =  num::cast(16).unwrap();
646                atk =  num::cast(14).unwrap();
647                def =  num::cast(30).unwrap();
648                m_atk =  num::cast(20).unwrap();
649                m_def =  num::cast(30).unwrap();
650                speed =  num::cast(5).unwrap();
651                agility = num::cast(10).unwrap();
652                strength = num::cast(10).unwrap();
653                dexterity = num::cast(10).unwrap();
654                constitution = num::cast(10).unwrap();
655                intelligence = num::cast(10).unwrap();
656                charisma = num::cast(10).unwrap();
657                wisdom = num::cast(10).unwrap();
658                age = num::cast(40).unwrap();
659            },
660            Normal::Archer => {
661                hp =  num::cast(50).unwrap();
662                mp =  num::cast(25).unwrap();
663                atk =  num::cast(15).unwrap();
664                def =  num::cast(10).unwrap();
665                m_atk =  num::cast(15).unwrap();
666                m_def =  num::cast(35).unwrap();
667                speed =  num::cast(5).unwrap();
668                agility = num::cast(10).unwrap();
669                strength = num::cast(10).unwrap();
670                dexterity = num::cast(10).unwrap();
671                constitution = num::cast(10).unwrap();
672                intelligence = num::cast(10).unwrap();
673                charisma = num::cast(10).unwrap();
674                wisdom = num::cast(10).unwrap();
675                age = num::cast(40).unwrap();
676            },
677            Normal::Knight => {
678                hp =  num::cast(50).unwrap();
679                mp =  num::cast(20).unwrap();
680                atk =  num::cast(20).unwrap();
681                def =  num::cast(20).unwrap();
682                m_atk =  num::cast(20).unwrap();
683                m_def =  num::cast(20).unwrap();
684                speed =  num::cast(7).unwrap();
685                agility = num::cast(10).unwrap();
686                strength = num::cast(10).unwrap();
687                dexterity = num::cast(10).unwrap();
688                constitution = num::cast(10).unwrap();
689                intelligence = num::cast(10).unwrap();
690                charisma = num::cast(10).unwrap();
691                wisdom = num::cast(10).unwrap();
692                age = num::cast(40).unwrap();
693            },
694            Normal::Monk => {
695                hp = num::cast(50).unwrap();
696                mp = num::cast(20).unwrap();
697                atk = num::cast(10).unwrap();
698                def = num::cast(15).unwrap();
699                m_atk = num::cast(5).unwrap();
700                m_def = num::cast(40).unwrap();
701                speed = num::cast(5).unwrap();
702                agility = num::cast(10).unwrap();
703                strength = num::cast(10).unwrap();
704                dexterity = num::cast(10).unwrap();
705                constitution = num::cast(10).unwrap();
706                intelligence = num::cast(10).unwrap();
707                charisma = num::cast(10).unwrap();
708                wisdom = num::cast(10).unwrap();
709                age = num::cast(40).unwrap();
710            },
711            Normal::Elemental => {
712                hp = num::cast(70).unwrap();
713                mp = num::cast(40).unwrap();
714                atk = num::cast(1).unwrap();
715                def = num::cast(8).unwrap();
716                m_atk = num::cast(30).unwrap();
717                m_def = num::cast(1).unwrap();
718                speed = num::cast(4).unwrap();
719                agility = num::cast(10).unwrap();
720                strength = num::cast(10).unwrap();
721                dexterity = num::cast(10).unwrap();
722                constitution = num::cast(10).unwrap();
723                intelligence = num::cast(10).unwrap();
724                charisma = num::cast(10).unwrap();
725                wisdom = num::cast(10).unwrap();
726                age = num::cast(40).unwrap();
727            },
728            Normal::Priest => {
729                hp = num::cast(60).unwrap();
730                mp = num::cast(10).unwrap();
731                atk = num::cast(20).unwrap();
732                def = num::cast( 10).unwrap();
733                m_atk = num::cast(10).unwrap();
734                m_def = num::cast(40).unwrap();
735                speed = num::cast(4).unwrap();
736                agility = num::cast(10).unwrap();
737                strength = num::cast(10).unwrap();
738                dexterity = num::cast(10).unwrap();
739                constitution = num::cast(10).unwrap();
740                intelligence = num::cast(10).unwrap();
741                charisma = num::cast(10).unwrap();
742                wisdom = num::cast(10).unwrap();
743                age = num::cast(40).unwrap();
744            },
745            Normal::Soldier => {
746                hp = num::cast(90).unwrap();
747                mp = num::cast(0).unwrap();
748                atk = num::cast(30).unwrap();
749                def = num::cast(12).unwrap();
750                m_atk = num::cast(0).unwrap();
751                m_def = num::cast(18).unwrap();
752                speed = num::cast(5).unwrap();
753                agility = num::cast(10).unwrap();
754                strength = num::cast(10).unwrap();
755                dexterity = num::cast(10).unwrap();
756                constitution = num::cast(10).unwrap();
757                intelligence = num::cast(10).unwrap();
758                charisma = num::cast(10).unwrap();
759                wisdom = num::cast(10).unwrap();
760                age = num::cast(40).unwrap();
761            },
762            Normal::Ranger => {
763                hp = num::cast(40).unwrap();
764                mp = num::cast(70).unwrap();
765                atk = num::cast(15).unwrap();
766                def = num::cast( 9).unwrap();
767                m_atk = num::cast(11).unwrap();
768                m_def = num::cast(30).unwrap();
769                speed = num::cast(8).unwrap();
770                agility = num::cast(10).unwrap();
771                strength = num::cast(10).unwrap();
772                dexterity = num::cast(10).unwrap();
773                constitution = num::cast(10).unwrap();
774                intelligence = num::cast(10).unwrap();
775                charisma = num::cast(10).unwrap();
776                wisdom = num::cast(10).unwrap();
777                age = num::cast(40).unwrap();
778            },
779            Normal::Valkyrie => {
780                hp = num::cast(50).unwrap();
781                mp = num::cast(10).unwrap();
782                atk = num::cast(20).unwrap();
783                def = num::cast(20).unwrap();
784                m_atk = num::cast(20).unwrap();
785                m_def = num::cast(30).unwrap();
786                speed = num::cast(7).unwrap();
787                agility = num::cast(10).unwrap();
788                strength = num::cast(10).unwrap();
789                dexterity = num::cast(10).unwrap();
790                constitution = num::cast(10).unwrap();
791                intelligence = num::cast(10).unwrap();
792                charisma = num::cast(10).unwrap();
793                wisdom = num::cast(10).unwrap();
794                age = num::cast(40).unwrap();
795            },
796        }
797        hp *= level;
798        mp *= level;
799        // TODO fixme:
800        xp *= level;
801        // TODO fixme:
802        xp_next *= level;
803        gp *= level;
804        speed += level;
805        speed += level;
806        atk += level;
807        m_atk += level;
808        def += level;
809        m_def += level;
810        agility += level;
811        strength += level;
812        dexterity += level;
813        constitution += level;
814        intelligence += level;
815        charisma += level;
816        wisdom += level;
817        AdvancedStats {
818            id,
819            xp,
820            xp_next,
821            level,
822            gp,
823            hp,
824            mp,
825            hp_max:hp,
826            mp_max:mp,
827            speed,
828            atk,
829            def,
830            m_atk,
831            m_def,
832            agility,
833            strength,
834            dexterity,
835            constitution,
836            intelligence,
837            charisma,
838            wisdom,
839            age,
840        }
841    }
842}
843/*
844# Advanced
845
846
847*/
848#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
849#[cfg_attr(feature = "fltkform", derive(FltkForm))]
850///  `Advanced`
851pub enum Advanced {
852    /// Adventurer - 
853    Adventurer,
854    /// Artisan - 
855    Artisan,
856    /// Clergy - 
857    Clergy,
858    /// Governmental - 
859    Governmental,
860    /// Sailor - 
861    Sailor,
862    /// Worker - 
863    Worker,
864    /// Hoarder - 
865    Hoarder,
866    /// Community - 
867    Community,
868    /// Sport - 
869    Sport,
870    /// Solo - 
871    Solo,
872    /// Research - 
873    Research,
874    /// Scientist - 
875    Scientist,
876    /// Engineer - 
877    Engineer,
878    /// Clown - 
879    Clown,
880    /// Musician - 
881    Musician,
882    /// Baker - 
883    Baker,
884    /// Gardener - 
885    Gardener,
886    /// Boring - 
887    Boring,
888    /// Random - 
889    Random,
890    /// Gambler - 
891    Gambler,
892    /// Bicyclist - 
893    Bicyclist,
894    /// SkateBoarder - 
895    SkateBoarder,
896    /// Climber - 
897    Climber,
898    /// Watcher - 
899    Watcher,
900    /// Spy - 
901    Spy,
902    /// Shinobi - 
903    Shinobi,
904    /// Samurai - 
905    Samurai,
906    /// Shaolin - 
907    Shaolin,
908    /// Knitter - 
909    Knitter,
910    /// Crocheter - 
911    Crocheter,
912    /// Student - 
913    Student,
914    /// Teacher - 
915    Teacher,
916    /// Spiritual - 
917    Spiritual,
918    /// Farmer - 
919    Farmer,
920    /// Metallurgist - 
921    Metallurgist,
922    /// Archivist - 
923    Archivist,
924    /// Janitor - 
925    Janitor,
926    /// Cook - 
927    Cook,
928    /// Florist - 
929    Florist,
930    /// HomeMaker - 
931    HomeMaker,
932    /// Actor - 
933    Actor,
934    /// GameMaker - 
935    GameMaker,
936    None,
937}
938impl Default for Advanced {
939    fn default() -> Self {
940        Self::None
941    }
942}
943impl fmt::Display for Advanced {
944    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
945        let v:String;
946        match *self {
947            Advanced::Adventurer => v = String::from("Adventurer"),
948            Advanced::Artisan => v = String::from("Artisan"),
949            Advanced::Clergy => v = String::from("Clergy"),
950            Advanced::Governmental => v = String::from("Governmental"),
951            Advanced::Sailor => v = String::from("Sailor"),
952            Advanced::Worker => v = String::from("Worker"),
953            Advanced::Hoarder => v = String::from("Hoarder"),
954            Advanced::Community => v = String::from("Community"),
955            Advanced::Sport => v = String::from("Sport"),
956            Advanced::Solo => v = String::from("Solo"),
957            Advanced::Research => v = String::from("Research"),
958            Advanced::Scientist => v = String::from("Scientist"),
959            Advanced::Engineer => v = String::from("Engineer"),
960            Advanced::Clown => v = String::from("Clown"),
961            Advanced::Musician => v = String::from("Musician"),
962            Advanced::Baker => v = String::from("Baker"),
963            Advanced::Gardener => v = String::from("Gardener"),
964            Advanced::Boring => v = String::from("Boring"),
965            Advanced::Random => v = String::from("Random"),
966            Advanced::Gambler => v = String::from("Gambler"),
967            Advanced::Bicyclist => v = String::from("Bicyclist"),
968            Advanced::SkateBoarder => v = String::from("SkateBoarder"),
969            Advanced::Climber => v = String::from("Climber"),
970            Advanced::Watcher => v = String::from("Watcher"),
971            Advanced::Spy => v = String::from("Spy"),
972            Advanced::Shinobi => v = String::from("Shinobi"),
973            Advanced::Samurai => v = String::from("Samurai"),
974            Advanced::Shaolin => v = String::from("Shaolin"),
975            Advanced::Knitter => v = String::from("Knitter"),
976            Advanced::Crocheter => v = String::from("Crocheter"),
977            Advanced::Student => v = String::from("Student"),
978            Advanced::Teacher => v = String::from("Teacher"),
979            Advanced::Spiritual => v = String::from("Spiritual"),
980            Advanced::Farmer => v = String::from("Farmer"),
981            Advanced::Metallurgist => v = String::from("Metallurgist"),
982            Advanced::Archivist => v = String::from("Archivist"),
983            Advanced::Janitor => v = String::from("Janitor"),
984            Advanced::Cook => v = String::from("Cook"),
985            Advanced::Florist => v = String::from("Florist"),
986            Advanced::HomeMaker => v = String::from("HomeMaker"),
987            Advanced::Actor => v = String::from("Actor"),
988            Advanced::GameMaker => v = String::from("GameMaker"),
989            _=> v = String::from("None"),
990        }
991        write!(f, "{}", v.as_str())
992    }
993}
994impl Random for Advanced {
995    type Type = Advanced;
996    fn random_type(&self) -> Self::Type {
997        let max = 42;
998        let val = self.random_rate(max);
999        match val {
1000            0 => Advanced::Adventurer,
1001            1 => Advanced::Artisan,
1002            2 => Advanced::Clergy,
1003            3 => Advanced::Governmental,
1004            4 => Advanced::Sailor,
1005            5 => Advanced::Worker,
1006            6 => Advanced::Hoarder,
1007            7 => Advanced::Community,
1008            8 => Advanced::Sport,
1009            9 => Advanced::Solo,
1010            10 => Advanced::Research,
1011            11 => Advanced::Scientist,
1012            12 => Advanced::Engineer,
1013            13 => Advanced::Clown,
1014            14 => Advanced::Musician,
1015            15 => Advanced::Baker,
1016            16 => Advanced::Gardener,
1017            17 => Advanced::Boring,
1018            18 => Advanced::Random,
1019            19 => Advanced::Gambler,
1020            20 => Advanced::Bicyclist,
1021            21 => Advanced::SkateBoarder,
1022            22 => Advanced::Climber,
1023            23 => Advanced::Watcher,
1024            24 => Advanced::Spy,
1025            25 => Advanced::Shinobi,
1026            26 => Advanced::Samurai,
1027            27 => Advanced::Shaolin,
1028            28 => Advanced::Knitter,
1029            29 => Advanced::Crocheter,
1030            30 => Advanced::Student,
1031            31 => Advanced::Teacher,
1032            32 => Advanced::Spiritual,
1033            33 => Advanced::Farmer,
1034            34 => Advanced::Metallurgist,
1035            35 => Advanced::Archivist,
1036            36 => Advanced::Janitor,
1037            37 => Advanced::Cook,
1038            38 => Advanced::Florist,
1039            39 => Advanced::HomeMaker,
1040            40 => Advanced::Actor,
1041            41 => Advanced::GameMaker,
1042            _=> Advanced::None,
1043        }
1044    }
1045    
1046}