rpg_stat/
armor.rs

1/*!
2# Armor
3
4Use stats::Builder to get some basic premade armor stats
5
6```
7use rpg_stat::armor::Basic as Armor;
8use rpg_stat::stats::Basic as Stats;
9use rpg_stat::stats::Builder;
10let armor = Armor::Good;
11let stats:Stats<f64> = armor.build_basic(0.0, 1.0);
12assert_eq!(stats.hp, 5.0);
13```
14These enums can be combined with other modules, such as Element to create an elemental armor
15
16*/
17use std::fmt;
18use std::fmt::Debug;
19
20use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub, SubAssign};
21extern crate num;
22
23use serde::{Deserialize, Serialize};
24
25#[cfg(feature = "fltkform")]
26use fltk::{prelude::*, *};
27#[cfg(feature = "fltkform")]
28use fltk_form_derive::*;
29#[cfg(feature = "fltkform")]
30use fltk_form::FltkForm;
31
32// our modules
33use crate::random::Random;
34use crate::stats::Basic as BasicStats;
35use crate::stats::Normal as NormalStats;
36use crate::stats::Advanced as AdvancedStats;
37use crate::stats::Builder;
38
39#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
40#[cfg_attr(feature = "fltkform", derive(FltkForm))]
41/* 
42# Basic Armor
43
44
45*/
46pub enum Basic {
47    /// Good Armor
48    Good,
49    /// Better Armor
50    Better,
51    /// Best Armor
52    Best,
53    /// Epic Armor
54    Epic,
55    /// Legendary Armor
56    Legendary,
57    /// No armor
58    None,
59}
60impl Default for Basic {
61    fn default() -> Self {
62        Self::None
63    }
64}
65impl fmt::Display for Basic {
66    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
67        let v:String;
68        match *self {
69            Basic::Good => v = String::from("Good"),
70            Basic::Better => v = String::from("Better"),
71            Basic::Best => v = String::from("Best"),
72            Basic::Epic => v = String::from("Epic"),
73            Basic::Legendary => v = String::from("Legendary"),
74            _=> v = String::from("None"),
75        }
76        write!(f, "{}", v.as_str())
77    }
78}
79impl Random for Basic {
80    type Type = Basic;
81    fn random_type(&self) -> Self::Type {
82        let max = 5;
83        let val = self.random_rate(max);
84        match val {
85            0 => Basic::Good,
86            1 => Basic::Better,
87            2 => Basic::Best,
88            3 => Basic::Epic,
89            4 => Basic::Legendary,
90            _=> Basic::None,
91        }
92    }
93    
94}
95impl<T:Copy
96    + Default
97    + Debug
98    + AddAssign
99    + Add<Output = T>
100    + Div<Output = T>
101    + DivAssign
102    + Mul<Output = T>
103    + MulAssign
104    + Neg<Output = T>
105    + Rem<Output = T>
106    + RemAssign
107    + Sub<Output = T>
108    + SubAssign
109    + std::cmp::PartialOrd
110    + num::NumCast> Builder<T> for Basic {
111    fn build_basic(&self, id:T, level:T) -> BasicStats<T>{
112        let mut hp:T = num::cast(0).unwrap();
113        let mut mp:T = num::cast(0).unwrap();
114        let mut xp:T = num::cast(0).unwrap();
115        let xp_next:T = num::cast(0).unwrap();
116        let mut gp:T = num::cast(0).unwrap();
117        let mut speed:T = num::cast(0).unwrap();
118        match *self {
119            Basic::Good => {
120                xp = num::cast(1).unwrap();
121                hp = num::cast(5).unwrap();
122                mp = num::cast(5).unwrap();
123                speed = num::cast(1).unwrap();
124            },
125            Basic::Better => {
126                xp = num::cast(7).unwrap();
127                hp = num::cast(35).unwrap();
128                mp = num::cast(35).unwrap();
129                speed = num::cast(2).unwrap();
130            },
131            Basic::Best => {
132                xp = num::cast(14).unwrap();
133                hp = num::cast(70).unwrap();
134                mp = num::cast(70).unwrap();
135                speed = num::cast(4).unwrap();
136            },
137            Basic::Epic => {
138                xp = num::cast(28).unwrap();
139                hp = num::cast(105).unwrap();
140                mp = num::cast(105).unwrap();
141                speed = num::cast(7).unwrap();
142            },
143            Basic::Legendary => {
144                xp = num::cast(50).unwrap();
145                hp = num::cast(200).unwrap();
146                mp = num::cast(200).unwrap();
147                speed = num::cast(10).unwrap();
148            },
149            _=> (),
150        }
151        let mut stats = BasicStats {
152            id,
153            xp,
154            xp_next,
155            level,
156            gp,
157            hp,
158            mp,
159            hp_max:hp,
160            mp_max:mp,
161            speed,
162        };
163        stats.level_up();
164        stats
165        
166    }
167    fn build_normal(&self, id:T, level:T) -> NormalStats<T>{
168        let mut hp:T = num::cast(0).unwrap();
169        let mp:T = num::cast(0).unwrap();
170        let mut xp:T = num::cast(0).unwrap();
171        let xp_next:T = num::cast(0).unwrap();
172        let mut gp:T = num::cast(0).unwrap();
173        let mut speed:T = num::cast(0).unwrap();
174        let mut atk:T = num::cast(0).unwrap();
175        let mut def:T = num::cast(0).unwrap();
176        let mut m_atk:T = num::cast(0).unwrap();
177        let mut m_def:T = num::cast(0).unwrap();
178        match *self {
179            Basic::Good => {
180                xp = num::cast(4).unwrap();
181                hp = num::cast(4).unwrap();
182                def = num::cast(10).unwrap();
183                m_def = num::cast(10).unwrap();
184            },
185            Basic::Better => {
186                xp = num::cast(9).unwrap();
187                hp = num::cast(7).unwrap();
188                speed = num::cast(1).unwrap();
189                atk = num::cast(5).unwrap();
190                def = num::cast(50).unwrap();
191                m_def = num::cast(50).unwrap();
192            },
193            Basic::Best => {
194                xp = num::cast(16).unwrap();
195                hp = num::cast(12).unwrap();
196                speed = num::cast(2).unwrap();
197                atk = num::cast(15).unwrap();
198                def = num::cast(100).unwrap();
199                m_def = num::cast(100).unwrap();
200            },
201            Basic::Epic => {
202                xp = num::cast(27).unwrap();
203                hp = num::cast(50).unwrap();
204                speed = num::cast(4).unwrap();
205                atk = num::cast(70).unwrap();
206                def = num::cast(200).unwrap();
207                m_atk = num::cast(25).unwrap();
208                m_def = num::cast(300).unwrap();
209            },
210            Basic::Legendary => {
211                xp = num::cast(51).unwrap();
212                hp = num::cast(115).unwrap();
213                speed = num::cast(10).unwrap();
214                atk = num::cast(150).unwrap();
215                def = num::cast(350).unwrap();
216                m_atk = num::cast(100).unwrap();
217                m_def = num::cast(450).unwrap();
218            },
219            _=> (),
220        }
221        let mut stats = NormalStats {
222            id,
223            xp,
224            xp_next,
225            level,
226            gp,
227            hp,
228            mp,
229            hp_max:hp,
230            mp_max:mp,
231            speed,
232            atk,
233            def,
234            m_atk,
235            m_def,
236        };
237        stats.level_up();
238        stats
239    }
240    fn build_advanced(&self, id:T, level:T) -> AdvancedStats<T>{
241        let mut hp:T = num::cast(0).unwrap();
242        let mut mp:T = num::cast(0).unwrap();
243        let mut xp:T = num::cast(0).unwrap();
244        let xp_next:T = num::cast(0).unwrap();
245        let gp:T = num::cast(0).unwrap();
246        let mut speed:T = num::cast(0).unwrap();
247        let mut atk:T = num::cast(0).unwrap();
248        let mut def:T = num::cast(0).unwrap();
249        let mut m_atk:T = num::cast(0).unwrap();
250        let mut m_def:T = num::cast(0).unwrap();
251        let mut agility:T = num::cast(0).unwrap();
252        let mut strength:T = num::cast(0).unwrap();
253        let mut dexterity:T = num::cast(0).unwrap();
254        let mut constitution:T = num::cast(0).unwrap();
255        let intelligence:T = num::cast(0).unwrap();
256        let mut charisma:T = num::cast(0).unwrap();
257        let wisdom:T = num::cast(0).unwrap();
258        let age:T = num::cast(0).unwrap();
259        match *self {
260            Basic::Good => {
261                xp = num::cast(4).unwrap();
262                hp = num::cast(4).unwrap();
263                def = num::cast(10).unwrap();
264                m_def = num::cast(10).unwrap();
265                strength = num::cast(5).unwrap();
266                constitution = num::cast(5).unwrap();
267                charisma = num::cast(2).unwrap();
268            },
269            Basic::Better => {
270                xp = num::cast(9).unwrap();
271                hp = num::cast(7).unwrap();
272                speed = num::cast(1).unwrap();
273                atk = num::cast(5).unwrap();
274                def = num::cast(50).unwrap();
275                m_def = num::cast(50).unwrap();
276                strength = num::cast(10).unwrap();
277                constitution = num::cast(12).unwrap();
278                charisma = num::cast(7).unwrap();
279            },
280            Basic::Best => {
281                xp = num::cast(16).unwrap();
282                hp = num::cast(12).unwrap();
283                speed = num::cast(2).unwrap();
284                atk = num::cast(15).unwrap();
285                def = num::cast(100).unwrap();
286                m_def = num::cast(100).unwrap();
287                strength = num::cast(25).unwrap();
288                constitution = num::cast(20).unwrap();
289                charisma = num::cast(12).unwrap();
290            },
291            Basic::Epic => {
292                xp = num::cast(27).unwrap();
293                hp = num::cast(50).unwrap();
294                speed = num::cast(4).unwrap();
295                atk = num::cast(70).unwrap();
296                def = num::cast(200).unwrap();
297                m_atk = num::cast(25).unwrap();
298                m_def = num::cast(300).unwrap();
299                strength = num::cast(40).unwrap();
300                constitution = num::cast(30).unwrap();
301                charisma = num::cast(25).unwrap();
302            },
303            Basic::Legendary => {
304                xp = num::cast(51).unwrap();
305                hp = num::cast(115).unwrap();
306                speed = num::cast(10).unwrap();
307                atk = num::cast(150).unwrap();
308                def = num::cast(350).unwrap();
309                m_atk = num::cast(100).unwrap();
310                m_def = num::cast(450).unwrap();
311                agility = num::cast(10).unwrap();
312                strength = num::cast(100).unwrap();
313                constitution = num::cast(70).unwrap();
314                charisma = num::cast(52).unwrap();
315                dexterity = num::cast(10).unwrap();
316            },
317            _=> (),
318        }
319        let mut stats = AdvancedStats {
320            id,
321            xp,
322            xp_next,
323            level,
324            gp,
325            hp,
326            mp,
327            hp_max:hp,
328            mp_max:mp,
329            speed,
330            atk,
331            def,
332            m_atk,
333            m_def,
334            agility,
335            strength,
336            dexterity,
337            constitution,
338            intelligence,
339            charisma,
340            wisdom,
341            age,
342        };
343        stats.level_up();
344        stats
345    }
346}
347#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
348#[cfg_attr(feature = "fltkform", derive(FltkForm))]
349/* 
350# Normal
351
352*/
353pub enum Normal {
354    /// Hood
355    Hood,
356    /// Jaw
357    Jaw,
358    /// Joint
359    Joint,
360    /// Collar
361    Collar,
362    /// UpperArm
363    UpperArm,
364    /// Elbow
365    Elbow,
366    /// Pants
367    Pants,
368    /// Belly
369    Belly,
370    /// Chestplate
371    Chestplate,
372    /// Torso
373    Torso,
374    /// Hip
375    Hip,
376    /// Knee
377    Knee,
378    /// Shin
379    Shin,
380    /// Shoe
381    Shoe,
382    /// Shoulder
383    Shoulder,
384    /// Forearm
385    Forearm,
386    /// Hand
387    Hand,
388    /// Shirt
389    Shirt,
390    /// Head
391    Head,
392    /// Neck
393    Neck,
394    /// Face
395    Face,
396    /// Coat
397    Coat,
398    /// Thigh
399    Thigh,
400    /// No armor
401    None,
402}
403impl Default for Normal {
404    fn default() -> Self {
405        Self::None
406    }
407}
408impl fmt::Display for Normal {
409    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
410        let v:String;
411        match *self {
412            Normal::Hood => v = String::from("Hood"),
413            Normal::Jaw => v = String::from("Jaw"),
414            Normal::Joint => v = String::from("Joint"),
415            Normal::Collar => v = String::from("Collar"),
416            Normal::UpperArm => v = String::from("UpperArm"),
417            Normal::Elbow => v = String::from("Elbow"),
418            Normal::Pants => v = String::from("Pants"),
419            Normal::Belly => v = String::from("Belly"),
420            Normal::Chestplate => v = String::from("Chestplate"),
421            Normal::Torso => v = String::from("Torso"),
422            Normal::Hip => v = String::from("Hip"),
423            Normal::Knee => v = String::from("Knee"),
424            Normal::Shin => v = String::from("Shin"),
425            Normal::Shoe => v = String::from("Shoe"),
426            Normal::Shoulder => v = String::from("Shoulder"),
427            Normal::Forearm => v = String::from("Forearm"),
428            Normal::Hand => v = String::from("Hand"),
429            Normal::Shirt => v = String::from("Shirt"),
430            Normal::Head => v = String::from("Head"),
431            Normal::Neck => v = String::from("Neck"),
432            Normal::Face => v = String::from("Face"),
433            Normal::Coat => v = String::from("Coat"),
434            Normal::Thigh => v = String::from("Thigh"),
435            _=> v = String::from("None"),
436        }
437        write!(f, "{}", v.as_str())
438    }
439}
440impl Random for Normal {
441    type Type = Normal;
442    fn random_type(&self) -> Self::Type {
443        let max = 23;
444        let val = self.random_rate(max);
445        match val {
446            0 => Normal::Hood,
447            1 => Normal::Jaw,
448            2 => Normal::Joint,
449            3 => Normal::Collar,
450            4 => Normal::UpperArm,
451            5 => Normal::Elbow,
452            6 => Normal::Pants,
453            7 => Normal::Belly,
454            8 => Normal::Chestplate,
455            9 => Normal::Torso,
456            10 => Normal::Hip,
457            11 => Normal::Knee,
458            12 => Normal::Shin,
459            13 => Normal::Shoe,
460            14 => Normal::Shoulder,
461            15 => Normal::Forearm,
462            16 => Normal::Hand,
463            17 => Normal::Shirt,
464            18 => Normal::Head,
465            19 => Normal::Neck,
466            20 => Normal::Face,
467            21 => Normal::Coat,
468            22 => Normal::Thigh,
469            _=> Normal::None,
470        }
471    }
472    
473}
474#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
475#[cfg_attr(feature = "fltkform", derive(FltkForm))]
476/* 
477# Advanced
478
479*/
480pub enum Advanced {
481   /// Hood armor
482   Hood,
483   /// Jaw / throat armor
484   Bevor,
485   /// Circular plate armor protecting various areas
486   Rondel,
487   /// Collar armor
488   Gorget,
489   /// Upper arm armor below the shoulder armor
490   Rerebrace,
491   /// Elbow Armor
492   Couter,
493   /// Pant armor
494   Chausses,
495   /// Belly armor
496   Plackart,
497   /// Thigh armor
498   Cuisses,
499   /// Front torso armor
500   Chestplate,
501   /// Torso armor
502   Curiass,
503   /// Waist and hip armor
504   Fauld,
505   /// Knee armor
506   Poleyn,
507   /// Shin armor
508   Greaves,
509   /// Shoe armor
510   Sabaton,
511   /// Shoulder / upper arm guard
512   Spaulders,
513   /// Shoulder / armpit (back/chest optional) armor
514   Pauldron,
515   /// Forearm guard
516   Vambrace,
517   /// Hand guard
518   Gauntlets,
519   /// Shirt armor
520   Hauberk,
521   /// Head Armor
522   Helmet,
523   /// Neck Armor
524   Neckguard,
525   /// Face armor
526   Faceplate,
527   /// The coat worn over armor
528   Coat,
529   /// Hanging upper thigh plate armor
530   Tasset,
531   /// No armor
532   None,
533}
534impl Default for Advanced {
535    fn default() -> Self {
536        Self::None
537    }
538}
539impl fmt::Display for Advanced {
540    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
541        let v:String;
542        match *self {
543            Advanced::Hood => v = String::from("Hood"),
544            Advanced::Bevor => v = String::from("Bevor"),
545            Advanced::Rondel => v = String::from("Rondel"),
546            Advanced::Gorget => v = String::from("Gorget"),
547            Advanced::Rerebrace => v = String::from("Rerebrace"),
548            Advanced::Couter => v = String::from("Couter"),
549            Advanced::Chausses => v = String::from("Chausses"),
550            Advanced::Plackart => v = String::from("Plackart"),
551            Advanced::Cuisses => v = String::from("Cuisses"),
552            Advanced::Chestplate => v = String::from("Chestplate"),
553            Advanced::Curiass => v = String::from("Curiass"),
554            Advanced::Fauld => v = String::from("Fauld"),
555            Advanced::Poleyn => v = String::from("Poleyn"),
556            Advanced::Greaves => v = String::from("Greaves"),
557            Advanced::Sabaton => v = String::from("Sabaton"),
558            Advanced::Spaulders => v = String::from("Spaulders"),
559            Advanced::Pauldron => v = String::from("Pauldron"),
560            Advanced::Vambrace => v = String::from("Vambrace"),
561            Advanced::Gauntlets => v = String::from("Gauntlets"),
562            Advanced::Hauberk => v = String::from("Hauberk"),
563            Advanced::Helmet => v = String::from("Helmet"),
564            Advanced::Neckguard => v = String::from("Neckguard"),
565            Advanced::Faceplate => v = String::from("Faceplate"),
566            Advanced::Coat => v = String::from("Coat"),
567            Advanced::Tasset => v = String::from("Tasset"),
568            _=> v = String::from("None"),
569        }
570        write!(f, "{}", v.as_str())
571    }
572}
573impl Random for Advanced {
574    type Type = Advanced;
575    fn random_type(&self) -> Self::Type {
576        let max = 25;
577        let val = self.random_rate(max);
578        match val {
579            0 => Advanced::Hood,
580            1 => Advanced::Bevor,
581            2 => Advanced::Rondel,
582            3 => Advanced::Gorget,
583            4 => Advanced::Rerebrace,
584            5 => Advanced::Couter,
585            6 => Advanced::Chausses,
586            7 => Advanced::Plackart,
587            8 => Advanced::Cuisses,
588            9 => Advanced::Chestplate,
589            10 => Advanced::Curiass,
590            11 => Advanced::Fauld,
591            12 => Advanced::Poleyn,
592            13 => Advanced::Greaves,
593            14 => Advanced::Sabaton,
594            15 => Advanced::Spaulders,
595            16 => Advanced::Pauldron,
596            17 => Advanced::Vambrace,
597            18 => Advanced::Gauntlets,
598            19 => Advanced::Hauberk,
599            20 => Advanced::Helmet,
600            21 => Advanced::Neckguard,
601            22 => Advanced::Faceplate,
602            23 => Advanced::Coat,
603            24 => Advanced::Tasset,
604            _=> Advanced::None,
605        }
606    }
607    
608}
609impl<T:Copy
610    + Default
611    + Debug
612    + AddAssign
613    + Add<Output = T>
614    + Div<Output = T>
615    + DivAssign
616    + Mul<Output = T>
617    + MulAssign
618    + Neg<Output = T>
619    + Rem<Output = T>
620    + RemAssign
621    + Sub<Output = T>
622    + SubAssign
623    + std::cmp::PartialOrd
624    + num::NumCast> Builder<T> for Advanced {
625    fn build_basic(&self, id:T, level:T) -> BasicStats<T>{
626        let mut hp:T = num::cast(0).unwrap();
627        let mut mp:T = num::cast(0).unwrap();
628        let mut xp:T = num::cast(0).unwrap();
629        let xp_next:T = num::cast(0).unwrap();
630        let mut gp:T = num::cast(0).unwrap();
631        let mut speed:T = num::cast(0).unwrap();
632        match *self {
633            //TODO
634            _=> {
635                xp = num::cast(50).unwrap();
636                hp = num::cast(200).unwrap();
637                mp = num::cast(200).unwrap();
638                speed = num::cast(10).unwrap();
639            },
640        }
641        let mut stats = BasicStats {
642            id,
643            xp,
644            xp_next,
645            level,
646            gp,
647            hp,
648            mp,
649            hp_max:hp,
650            mp_max:mp,
651            speed,
652        };
653        stats.level_up();
654        stats
655        
656    }
657    fn build_normal(&self, id:T, level:T) -> NormalStats<T>{
658        let mut hp:T = num::cast(0).unwrap();
659        let mp:T = num::cast(0).unwrap();
660        let mut xp:T = num::cast(0).unwrap();
661        let xp_next:T = num::cast(0).unwrap();
662        let mut gp:T = num::cast(0).unwrap();
663        let mut speed:T = num::cast(0).unwrap();
664        let mut atk:T = num::cast(0).unwrap();
665        let mut def:T = num::cast(0).unwrap();
666        let mut m_atk:T = num::cast(0).unwrap();
667        let mut m_def:T = num::cast(0).unwrap();
668        match *self {
669            //TODO
670            _=> {
671                xp = num::cast(51).unwrap();
672                hp = num::cast(115).unwrap();
673                speed = num::cast(10).unwrap();
674                atk = num::cast(150).unwrap();
675                def = num::cast(350).unwrap();
676                m_atk = num::cast(100).unwrap();
677                m_def = num::cast(450).unwrap();
678            },
679        }
680        let mut stats = NormalStats {
681            id,
682            xp,
683            xp_next,
684            level,
685            gp,
686            hp,
687            mp,
688            hp_max:hp,
689            mp_max:mp,
690            speed,
691            atk,
692            def,
693            m_atk,
694            m_def,
695        };
696        stats.level_up();
697        stats
698    }
699    fn build_advanced(&self, id:T, level:T) -> AdvancedStats<T>{
700        let mut hp:T = num::cast(0).unwrap();
701        let mut mp:T = num::cast(0).unwrap();
702        let mut xp:T = num::cast(0).unwrap();
703        let xp_next:T = num::cast(0).unwrap();
704        let gp:T = num::cast(0).unwrap();
705        let mut speed:T = num::cast(0).unwrap();
706        let mut atk:T = num::cast(0).unwrap();
707        let mut def:T = num::cast(0).unwrap();
708        let mut m_atk:T = num::cast(0).unwrap();
709        let mut m_def:T = num::cast(0).unwrap();
710        let mut agility:T = num::cast(0).unwrap();
711        let mut strength:T = num::cast(0).unwrap();
712        let mut dexterity:T = num::cast(0).unwrap();
713        let mut constitution:T = num::cast(0).unwrap();
714        let intelligence:T = num::cast(0).unwrap();
715        let mut charisma:T = num::cast(0).unwrap();
716        let wisdom:T = num::cast(0).unwrap();
717        let age:T = num::cast(0).unwrap();
718        match *self {
719            //TODO
720            _=> {
721                xp = num::cast(51).unwrap();
722                hp = num::cast(115).unwrap();
723                speed = num::cast(10).unwrap();
724                atk = num::cast(150).unwrap();
725                def = num::cast(350).unwrap();
726                m_atk = num::cast(100).unwrap();
727                m_def = num::cast(450).unwrap();
728                agility = num::cast(10).unwrap();
729                strength = num::cast(100).unwrap();
730                constitution = num::cast(70).unwrap();
731                charisma = num::cast(52).unwrap();
732                dexterity = num::cast(10).unwrap();
733            },
734        }
735        let mut stats = AdvancedStats {
736            id,
737            xp,
738            xp_next,
739            level,
740            gp,
741            hp,
742            mp,
743            hp_max:hp,
744            mp_max:mp,
745            speed,
746            atk,
747            def,
748            m_atk,
749            m_def,
750            agility,
751            strength,
752            dexterity,
753            constitution,
754            intelligence,
755            charisma,
756            wisdom,
757            age,
758        };
759        stats.level_up();
760        stats
761    }
762}
763#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
764#[cfg_attr(feature = "fltkform", derive(FltkForm))]
765/* 
766# Armor
767
768*/
769pub enum Armor {
770   /// Hood armor
771   Hood,
772   /// Jaw / throat armor
773   Bevor,
774   /// Circular plate armor protecting various areas
775   Rondel,
776   /// Collar armor
777   Gorget,
778   /// Upper arm armor below the shoulder armor
779   Rerebrace,
780   /// Elbow Armor
781   Couter,
782   /// Pant armor
783   Chausses,
784   /// Belly armor
785   Plackart,
786   /// Thigh armor
787   Cuisses,
788   /// Front torso armor
789   Chestplate,
790   /// Torso armor
791   Curiass,
792   /// Waist and hip armor
793   Fauld,
794   /// Knee armor
795   Poleyn,
796   /// Shin armor
797   Greaves,
798   /// Shoe armor
799   Sabaton,
800   /// Shoulder / upper arm guard
801   Spaulders,
802   /// Shoulder / armpit (back/chest optional) armor
803   Pauldron,
804   /// Forearm guard
805   Vambrace,
806   /// Hand guard
807   Gauntlets,
808   /// Shirt armor
809   Hauberk,
810   /// Head Armor
811   Helmet,
812   /// Neck Armor
813   Neckguard,
814   /// Face armor
815   Faceplate,
816   /// The coat worn over armor
817   Coat,
818   /// Hanging upper thigh plate armor
819   Tasset,
820   /// No armor
821   None,
822}
823impl Default for Armor {
824    fn default() -> Self {
825        Self::None
826    }
827}
828impl fmt::Display for Armor {
829    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
830        let v:String;
831        match *self {
832            Armor::Hood => v = String::from("Hood"),
833            Armor::Bevor => v = String::from("Bevor"),
834            Armor::Rondel => v = String::from("Rondel"),
835            Armor::Gorget => v = String::from("Gorget"),
836            Armor::Rerebrace => v = String::from("Rerebrace"),
837            Armor::Couter => v = String::from("Couter"),
838            Armor::Chausses => v = String::from("Chausses"),
839            Armor::Plackart => v = String::from("Plackart"),
840            Armor::Cuisses => v = String::from("Cuisses"),
841            Armor::Chestplate => v = String::from("Chestplate"),
842            Armor::Curiass => v = String::from("Curiass"),
843            Armor::Fauld => v = String::from("Fauld"),
844            Armor::Poleyn => v = String::from("Poleyn"),
845            Armor::Greaves => v = String::from("Greaves"),
846            Armor::Sabaton => v = String::from("Sabaton"),
847            Armor::Spaulders => v = String::from("Spaulders"),
848            Armor::Pauldron => v = String::from("Pauldron"),
849            Armor::Vambrace => v = String::from("Vambrace"),
850            Armor::Gauntlets => v = String::from("Gauntlets"),
851            Armor::Hauberk => v = String::from("Hauberk"),
852            Armor::Helmet => v = String::from("Helmet"),
853            Armor::Neckguard => v = String::from("Neckguard"),
854            Armor::Faceplate => v = String::from("Faceplate"),
855            Armor::Coat => v = String::from("Coat"),
856            Armor::Tasset => v = String::from("Tasset"),
857            _=> v = String::from("None"),
858        }
859        write!(f, "{}", v.as_str())
860    }
861}
862impl Random for Armor {
863    type Type = Armor;
864    fn random_type(&self) -> Self::Type {
865        let max = 25;
866        let val = self.random_rate(max);
867        match val {
868            0 => Armor::Hood,
869            1 => Armor::Bevor,
870            2 => Armor::Rondel,
871            3 => Armor::Gorget,
872            4 => Armor::Rerebrace,
873            5 => Armor::Couter,
874            6 => Armor::Chausses,
875            7 => Armor::Plackart,
876            8 => Armor::Cuisses,
877            9 => Armor::Chestplate,
878            10 => Armor::Curiass,
879            11 => Armor::Fauld,
880            12 => Armor::Poleyn,
881            13 => Armor::Greaves,
882            14 => Armor::Sabaton,
883            15 => Armor::Spaulders,
884            16 => Armor::Pauldron,
885            17 => Armor::Vambrace,
886            18 => Armor::Gauntlets,
887            19 => Armor::Hauberk,
888            20 => Armor::Helmet,
889            21 => Armor::Neckguard,
890            22 => Armor::Faceplate,
891            23 => Armor::Coat,
892            24 => Armor::Tasset,
893            _=> Armor::None,
894        }
895    }
896    
897}