@@ -25,6 +25,8 @@ const SKILL_NAME_MSG_BASE: MessageId = 100;
2525const SKILL_DESCR_MSG_BASE : MessageId = 200 ;
2626const SKILL_FORMULA_MSG_BASE : MessageId = 300 ;
2727const LEVEL_UP_MSG : MessageId = 600 ;
28+ const PERK_NAME_MSG_BASE : MessageId = 101 ;
29+ const PERK_DESCR_MSG_BASE : MessageId = 1101 ;
2830
2931struct Tagged {
3032 tagged : bool ,
@@ -43,8 +45,10 @@ impl Default for Tagged {
4345pub struct Stats {
4446 stat_msgs : Messages ,
4547 skill_msgs : Messages ,
48+ perk_msgs : Messages ,
4649 stat_defs : EnumMap < Stat , StatDef > ,
4750 skill_defs : EnumMap < Skill , SkillDef > ,
51+ perk_defs : EnumMap < Perk , PerkDef > ,
4852 traits : EnumMap < Trait , bool > ,
4953 perks : HashMap < ProtoId , EnumMap < Perk , bool > > ,
5054 tagged : EnumMap < Skill , Tagged > ,
@@ -58,13 +62,18 @@ impl Stats {
5862 let skill_msgs = Messages :: read_file ( fs, language, "game/skill.msg" ) ?;
5963 let skill_defs = SkillDef :: defaults ( ) ;
6064
65+ let perk_msgs = Messages :: read_file ( fs, language, "game/perk.msg" ) ?;
66+ let perk_defs = PerkDef :: defaults ( ) ;
67+
6168 let mut perks = HashMap :: new ( ) ;
6269 perks. insert ( ProtoId :: DUDE , Default :: default ( ) ) ;
6370 Ok ( Self {
6471 stat_msgs,
6572 skill_msgs,
73+ perk_msgs,
6674 stat_defs,
6775 skill_defs,
76+ perk_defs,
6877 traits : Default :: default ( ) ,
6978 perks,
7079 tagged : Default :: default ( ) ,
@@ -83,6 +92,14 @@ impl Stats {
8392 & self . skill_msgs . get ( SKILL_FORMULA_MSG_BASE + skill as MessageId ) . unwrap ( ) . text
8493 }
8594
95+ pub fn perk_name ( & self , perk : Perk ) -> & bstr {
96+ & self . perk_msgs . get ( PERK_NAME_MSG_BASE + perk as MessageId ) . unwrap ( ) . text
97+ }
98+
99+ pub fn perk_description ( & self , perk : Perk ) -> & bstr {
100+ & self . perk_msgs . get ( PERK_DESCR_MSG_BASE + perk as MessageId ) . unwrap ( ) . text
101+ }
102+
86103 pub fn has_perk ( & self , perk : Perk , pid : ProtoId ) -> bool {
87104 self . perks . get ( & pid) . map ( |m| m[ perk] ) . unwrap_or ( false )
88105 }
0 commit comments