@@ -7,12 +7,50 @@ import (
77 "github.com/darklab8/fl-darkstat/configs/configs_mapped/parserutils/semantic"
88)
99
10+ type AffiliationBonus struct {
11+ FactionNickname * semantic.String
12+ BonusMultiplier * semantic.Float
13+ }
14+
15+ type ConsumedAlt struct {
16+ Amount * semantic.Int
17+ Items []* semantic.String
18+ }
19+
20+ type ProducedItem struct {
21+ Nickname * semantic.String
22+ Amount * semantic.Int
23+ }
24+
25+ type Produced struct {
26+ ProducedItem
27+ FactionProduced map [string ]* ProducedItem
28+ }
29+
30+ type Catalyst struct {
31+ Nickname * semantic.String
32+ Amount * semantic.Int
33+ }
34+ type Consumed struct {
35+ Nickname * semantic.String
36+ Amount * semantic.Int
37+ }
38+
1039type CommodityRecipe struct {
1140 semantic.Model
1241 Nickname * semantic.String
1342 CraftType * semantic.String
14- ProcucedItem []* semantic.String
15- ConsumedItem []* semantic.String
43+ ProducedItem []* Produced
44+ ConsumedItem []* Consumed
45+
46+ Catalysts []* Catalyst
47+ ConsumedAlt []* ConsumedAlt
48+ ShortCutNum * semantic.Int
49+ CookingRate * semantic.Int
50+ RequiredLevel * semantic.Int
51+ AffiliationBonus []* AffiliationBonus
52+ LoopProduction * semantic.Bool
53+ Restricted * semantic.Bool
1654}
1755
1856type Config struct {
@@ -32,35 +70,96 @@ func Read(input_file *iniload.IniLoader) *Config {
3270 for _ , recipe_info := range input_file .SectionMap ["[recipe]" ] {
3371
3472 recipe := & CommodityRecipe {
35- Nickname : semantic .NewString (recipe_info , cfg .Key ("nickname" ), semantic .WithLowercaseS (), semantic .WithoutSpacesS ()),
36- CraftType : semantic .NewString (recipe_info , cfg .Key ("craft_type" ), semantic .WithLowercaseS (), semantic .WithoutSpacesS ()),
73+ Nickname : semantic .NewString (recipe_info , cfg .Key ("nickname" ), semantic .WithLowercaseS (), semantic .WithoutSpacesS ()),
74+ CraftType : semantic .NewString (recipe_info , cfg .Key ("craft_type" ), semantic .WithLowercaseS (), semantic .WithoutSpacesS ()),
75+ CookingRate : semantic .NewInt (recipe_info , cfg .Key ("cooking_rate" )),
76+ RequiredLevel : semantic .NewInt (recipe_info , cfg .Key ("reqlevel" )),
77+ LoopProduction : semantic .NewBool (recipe_info , cfg .Key ("loop_production" ), semantic .IntBool ),
78+ Restricted : semantic .NewBool (recipe_info , cfg .Key ("restricted" ), semantic .StrBool ),
79+ ShortCutNum : semantic .NewInt (recipe_info , cfg .Key ("shortcut_number" )),
3780 }
3881 recipe .Map (recipe_info )
3982
40- for produced_index , _ := range recipe_info .ParamMap [cfg .Key ("produced_item" )] {
41-
42- recipe .ProcucedItem = append (recipe .ProcucedItem ,
43- semantic .NewString (recipe_info , cfg .Key ("produced_item" ), semantic .WithLowercaseS (), semantic .WithoutSpacesS (), semantic .OptsS (semantic .Index (produced_index ))))
83+ for index , _ := range recipe_info .ParamMap [cfg .Key ("produced_item" )] {
84+ item := & Produced {
85+ ProducedItem : ProducedItem {
86+ Nickname : semantic .NewString (recipe_info , cfg .Key ("produced_item" ), semantic .WithLowercaseS (), semantic .WithoutSpacesS (), semantic .OptsS (semantic .Index (index ))),
87+ Amount : semantic .NewInt (recipe_info , cfg .Key ("produced_item" ), semantic .Order (1 ), semantic .Index (index )),
88+ },
89+ }
90+ recipe .ProducedItem = append (recipe .ProducedItem , item )
91+ }
92+ for index , _ := range recipe_info .ParamMap [cfg .Key ("catalyst" )] {
93+ item := & Catalyst {
94+ Nickname : semantic .NewString (recipe_info , cfg .Key ("catalyst" ), semantic .WithLowercaseS (), semantic .WithoutSpacesS (), semantic .OptsS (semantic .Index (index ))),
95+ Amount : semantic .NewInt (recipe_info , cfg .Key ("catalyst" ), semantic .Order (1 ), semantic .Index (index )),
96+ }
97+ recipe .Catalysts = append (recipe .Catalysts , item )
4498 }
4599 for produced_index , produced_affiliation_info := range recipe_info .ParamMap [cfg .Key ("produced_affiliation" )] {
46- for i := 0 ; i < len (produced_affiliation_info .Values ); i += 3 {
47- recipe .ProcucedItem = append (recipe .ProcucedItem ,
48- semantic .NewString (recipe_info , cfg .Key ("produced_affiliation" ), semantic .WithLowercaseS (), semantic .WithoutSpacesS (), semantic .OptsS (semantic .Index (produced_index ), semantic .Order (i ))))
100+ produced := & Produced {
101+ ProducedItem : ProducedItem {
102+ Nickname : semantic .NewString (recipe_info , cfg .Key ("produced_affiliation" ), semantic .WithLowercaseS (), semantic .WithoutSpacesS (), semantic .OptsS (semantic .Index (produced_index ), semantic .Order (0 ))),
103+ Amount : semantic .NewInt (recipe_info , cfg .Key ("produced_affiliation" ), semantic .Index (produced_index ), semantic .Order (1 )),
104+ },
105+
106+ FactionProduced : make (map [string ]* ProducedItem ),
107+ }
108+ for i := 2 ; i < len (produced_affiliation_info .Values ); i += 3 {
109+ faction := semantic .NewString (recipe_info , cfg .Key ("produced_affiliation" ), semantic .WithLowercaseS (), semantic .WithoutSpacesS (), semantic .OptsS (semantic .Index (produced_index ), semantic .Order (i )))
110+ produced_instead := & ProducedItem {
111+ Nickname : semantic .NewString (recipe_info , cfg .Key ("produced_affiliation" ), semantic .WithLowercaseS (), semantic .WithoutSpacesS (), semantic .OptsS (semantic .Index (produced_index ), semantic .Order (i + 1 ))),
112+ Amount : semantic .NewInt (recipe_info , cfg .Key ("produced_affiliation" ), semantic .Index (produced_index ), semantic .Order (i + 2 )),
113+ }
114+ produced .FactionProduced [faction .Get ()] = produced_instead
49115 }
116+ recipe .ProducedItem = append (recipe .ProducedItem , produced )
117+ }
118+ for index , _ := range recipe_info .ParamMap [cfg .Key ("affiliation_bonus" )] {
119+ bonus := & AffiliationBonus {
120+ FactionNickname : semantic .NewString (recipe_info , cfg .Key ("affiliation_bonus" ), semantic .WithLowercaseS (), semantic .WithoutSpacesS (), semantic .OptsS (semantic .Index (index ))),
121+ BonusMultiplier : semantic .NewFloat (recipe_info , cfg .Key ("affiliation_bonus" ), semantic .Precision (2 ), semantic .OptsF (semantic .Order (1 ), semantic .Index (index ))),
122+ }
123+ recipe .AffiliationBonus = append (recipe .AffiliationBonus , bonus )
50124 }
51125
52- for consumed_index , _ := range recipe_info .ParamMap [cfg .Key ("consumed" )] {
126+ for index , param := range recipe_info .ParamMap [cfg .Key ("consumed_dynamic_alt" )] {
127+ consum_alt := & ConsumedAlt {
128+ Amount : semantic .NewInt (recipe_info , cfg .Key ("consumed_dynamic_alt" ), semantic .Index (index )),
129+ }
53130
54- recipe .ConsumedItem = append (recipe .ConsumedItem ,
55- semantic .NewString (recipe_info , cfg .Key ("consumed" ), semantic .WithLowercaseS (), semantic .WithoutSpacesS (), semantic .OptsS (semantic .Index (consumed_index ))))
131+ for order , _ := range param .Values {
132+ if order == 0 {
133+ continue
134+ }
56135
136+ consum_alt .Items = append (consum_alt .Items ,
137+ semantic .NewString (recipe_info ,
138+ cfg .Key ("consumed_dynamic_alt" ),
139+ semantic .WithLowercaseS (),
140+ semantic .WithoutSpacesS (),
141+ semantic .OptsS (semantic .Index (index ), semantic .Order (order )),
142+ ),
143+ )
144+ }
145+
146+ recipe .ConsumedAlt = append (recipe .ConsumedAlt , consum_alt )
147+ }
148+
149+ for index , _ := range recipe_info .ParamMap [cfg .Key ("consumed" )] {
150+ item := & Consumed {
151+ Nickname : semantic .NewString (recipe_info , cfg .Key ("consumed" ), semantic .WithLowercaseS (), semantic .WithoutSpacesS (), semantic .OptsS (semantic .Index (index ))),
152+ Amount : semantic .NewInt (recipe_info , cfg .Key ("consumed" ), semantic .Order (1 ), semantic .Index (index )),
153+ }
154+ recipe .ConsumedItem = append (recipe .ConsumedItem , item )
57155 }
156+
58157 conf .Recipes = append (conf .Recipes , recipe )
59158 for _ , consumed := range recipe .ConsumedItem {
60- conf .RecipePerConsumed [consumed .Get ()] = append (conf .RecipePerConsumed [consumed .Get ()], recipe )
159+ conf .RecipePerConsumed [consumed .Nickname . Get ()] = append (conf .RecipePerConsumed [consumed . Nickname .Get ()], recipe )
61160 }
62- for _ , produced := range recipe .ProcucedItem {
63- conf .RecipePerProduced [produced .Get ()] = append (conf .RecipePerProduced [produced .Get ()], recipe )
161+ for _ , produced := range recipe .ProducedItem {
162+ conf .RecipePerProduced [produced .Nickname . Get ()] = append (conf .RecipePerProduced [produced . Nickname .Get ()], recipe )
64163 }
65164 }
66165
0 commit comments