1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . ComponentModel ;
4
+ using System . Linq ;
5
+ using System . Runtime . CompilerServices ;
6
+ using System . Text ;
7
+ using EDEngineer . Models . Utils ;
8
+ using Newtonsoft . Json ;
9
+
10
+ namespace EDEngineer . Models
11
+ {
12
+ public class Blueprint
13
+ {
14
+ private static readonly Dictionary < string , string > technicalTypes = new Dictionary < string , string >
15
+ {
16
+ [ "Frame Shift Drive" ] = "hyperdrive" ,
17
+ [ "Heat Sink Launcher" ] = "heatsinklauncher" ,
18
+ [ "Collector Limpet Controller" ] = "dronecontrol_collection" ,
19
+ [ "Prospector Limpet Controller" ] = "dronecontrol_prospector" ,
20
+ [ "Fuel Transfer Limpet Controller" ] = "dronecontrol_fuel" ,
21
+ [ "Hatch Breaker Limpet Controller" ] = "dronecontrol_resourcesiphon" ,
22
+ [ "Thrusters" ] = "engine" ,
23
+ [ "Pulse Laser" ] = "pulselaser" ,
24
+ [ "Beam Laser" ] = "beamlaser" ,
25
+ [ "Shield Booster" ] = "shieldbooster" ,
26
+ [ "Shield Generator" ] = "shieldgenerator" ,
27
+ [ "Sensors" ] = "sensors" ,
28
+ [ "Plasma Accelerator" ] = "plasmaaccelerator" ,
29
+ [ "Life Support" ] = "lifesupport" ,
30
+ [ "Hull Reinforcement Package" ] = "hullreinforcement" ,
31
+ [ "Power Distributor" ] = "powerdistributor" ,
32
+ [ "Power Plant" ] = "powerplant" ,
33
+ [ "Multi-cannon" ] = "multicannon" ,
34
+ [ "Kill Warrant Scanner" ] = "crimescanner" ,
35
+ [ "Rail Gun" ] = "railgun" ,
36
+ [ "Burst Laser" ] = "pulselaserburst"
37
+ } ;
38
+
39
+ public string Type { get ; }
40
+
41
+ [ JsonIgnore ]
42
+ public string TechnicalType => technicalTypes . TryGetValue ( Type , out var result ) ? result : Type ;
43
+
44
+ public string ShortenedType
45
+ {
46
+ get
47
+ {
48
+ switch ( Type )
49
+ {
50
+ case "Electronic Countermeasure" :
51
+ return "ECM" ;
52
+ case "Hull Reinforcement Package" :
53
+ return "Hull" ;
54
+ case "Frame Shift Drive Interdictor" :
55
+ return "FSD Interdictor" ;
56
+ case "Prospector Limpet Controller" :
57
+ return "Prospector LC" ;
58
+ case "Fuel Transfer Limpet Controller" :
59
+ return "Fuel Transfer LC" ;
60
+ case "Hatch Breaker Limpet Controller" :
61
+ return "Hatch Breaker LC" ;
62
+ case "Collector Limpet Controller" :
63
+ return "Collector LC" ;
64
+ case "Auto Field-Maintenance Unit" :
65
+ return "AFMU" ;
66
+ default :
67
+ return Type ;
68
+ }
69
+ }
70
+ }
71
+ public string BlueprintName { get ; }
72
+ public IReadOnlyCollection < string > Engineers { get ; }
73
+ public IReadOnlyCollection < BlueprintIngredient > Ingredients { get ; }
74
+ public int ? Grade { get ; }
75
+ public IReadOnlyCollection < BlueprintEffect > Effects { get ; }
76
+ public Guid ? CoriolisGuid { get ; set ; }
77
+
78
+
79
+ [ JsonIgnore ]
80
+ public BlueprintCategory Category
81
+ {
82
+ get
83
+ {
84
+ if ( Engineers . FirstOrDefault ( ) == "@Synthesis" )
85
+ {
86
+ return BlueprintCategory . Synthesis ;
87
+ }
88
+
89
+ if ( Type == "Unlock" )
90
+ {
91
+ return BlueprintCategory . Unlock ;
92
+ }
93
+
94
+ if ( Engineers . FirstOrDefault ( ) == "@Technology" )
95
+ {
96
+ return BlueprintCategory . Technology ;
97
+ }
98
+
99
+ if ( Grade == null )
100
+ {
101
+ return BlueprintCategory . Experimental ;
102
+ }
103
+
104
+ return BlueprintCategory . Module ;
105
+ }
106
+ }
107
+
108
+ public Blueprint (
109
+ string type ,
110
+ string blueprintName ,
111
+ int ? grade ,
112
+ IReadOnlyCollection < BlueprintIngredient > ingredients ,
113
+ IReadOnlyCollection < string > engineers ,
114
+ IReadOnlyCollection < BlueprintEffect > effects ,
115
+ Guid ? coriolisGuid )
116
+ {
117
+ Type = type ;
118
+ BlueprintName = blueprintName ;
119
+ Grade = grade ;
120
+ Engineers = engineers ;
121
+ Ingredients = ingredients ;
122
+ Effects = effects ;
123
+ CoriolisGuid = coriolisGuid ;
124
+
125
+ }
126
+
127
+ private int ComputeCraftCount ( Func < BlueprintIngredient , int > countExtractor )
128
+ {
129
+ return Ingredients . Any ( ) ? Ingredients . Min ( i => countExtractor ( i ) / i . Size ) : 0 ;
130
+ }
131
+
132
+ private double ComputeProgress ( Func < BlueprintIngredient , int > countExtractor )
133
+ {
134
+ return Ingredients . Sum (
135
+ ingredient =>
136
+ Math . Min ( 1 , countExtractor ( ingredient ) / ( double ) ingredient . Size ) / Ingredients . Count ) * 100 ;
137
+ }
138
+
139
+ public override string ToString ( )
140
+ {
141
+ return $ "G{ Grade } [{ Type } ] { BlueprintName } ";
142
+ }
143
+
144
+ public string GradeString => Grade != null ? $ "G{ Grade } " : "🔹" ;
145
+
146
+ private string Prefix
147
+ {
148
+ get
149
+ {
150
+ switch ( Category )
151
+ {
152
+ case BlueprintCategory . Synthesis :
153
+ return $ "SYN ";
154
+ case BlueprintCategory . Experimental :
155
+ return $ "EXP ";
156
+ case BlueprintCategory . Technology :
157
+ return $ "TEC ";
158
+ case BlueprintCategory . Unlock :
159
+ return $ "ULK ";
160
+ default :
161
+ return $ "" ;
162
+ }
163
+ }
164
+ }
165
+
166
+
167
+ public object ToSerializable ( )
168
+ {
169
+ return new
170
+ {
171
+ BlueprintName ,
172
+ Type ,
173
+ Grade
174
+ } ;
175
+ }
176
+
177
+ public bool HasSameIngredients ( IReadOnlyCollection < BlueprintIngredient > ingredients )
178
+ {
179
+ return ingredients . Count == Ingredients . Count && ingredients . All ( Ingredients . Contains ) ;
180
+ }
181
+ }
182
+ }
0 commit comments