forked from Zistack/Satisfactory-Optimizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
well_recipe.py
147 lines (107 loc) · 3.06 KB
/
well_recipe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import commentjson
import utils
from machine import get_machine
from well_type import get_well_type
from item import get_item
from recipe import (
RawRecipe,
load_inputs,
load_outputs,
load_power_augmentation_factor
)
class WellRecipe:
def __init__ (
self,
pretty_name,
time,
machine,
power_consumption,
well_type,
resource,
purity_quantities,
input_quantities,
output_quantities,
power_augmentation_factor
):
self . pretty_name = pretty_name
self . time = time
self . machine = machine
self . power_consumption = power_consumption
self . well_type = well_type
self . resource = resource
self . purity_quantities = purity_quantities
self . input_quantities = input_quantities
self . output_quantities = output_quantities
self . power_augmentation_factor = power_augmentation_factor
def supports_overclocking (self):
return self . machine . supports_overclocking ()
def supports_productivity (self):
return self . machine . supports_productivity ()
def requires_somersloops (self):
return self . machine . supports_somersloops ()
def input_items (self):
return self . input_quantities . keys ()
def output_items (self):
return self . output_quantities . keys ()
def specialize (self, well_configuration):
pretty_name = (
self . pretty_name + ' ' + well_configuration . pretty_name
)
output_quantities = self . output_quantities . copy ()
resource_output_quantity = 0
for purity, count in well_configuration . purity_counts . items ():
resource_output_quantity += (
self . purity_quantities [purity] * count
)
if self . resource in output_quantities:
output_quantities [self . resource] += resource_output_quantity
else:
output_quantities [self . resource] = resource_output_quantity
return RawRecipe (
pretty_name,
self . time,
self . machine,
self . power_consumption,
well_configuration = well_configuration,
input_quantities = self . input_quantities,
output_quantities = output_quantities,
power_augmentation_factor = self . power_augmentation_factor
)
def load_purity_quantities (purity_quantities_data):
return dict (
(purity, utils . real (quantity))
for purity, quantity in purity_quantities_data . items ()
)
def load_well_recipe (
pretty_name,
recipe_data,
machines,
well_types,
items
):
time = utils . real (recipe_data ['time'])
machine = get_machine (recipe_data ['machine'], machines)
power_consumption = utils . real (recipe_data ['power_consumption'])
well_type = get_well_type (
recipe_data ['well_type'],
well_types
)
resource = get_item (recipe_data ['resource'], items)
purity_quantities = load_purity_quantities (
recipe_data ['purity_quantities']
)
input_quantities = load_inputs (recipe_data, items)
output_quantities = load_outputs (recipe_data, items)
power_augmentation_factor = load_power_augmentation_factor (recipe_data)
return WellRecipe (
pretty_name,
time,
machine,
power_consumption,
well_type,
resource,
purity_quantities,
input_quantities,
output_quantities,
power_augmentation_factor
)