Factorio: fix crude-oil related crashes (#552)
This commit is contained in:
parent
0c80cd017f
commit
86013328d6
|
@ -8,6 +8,7 @@ import random
|
||||||
from schema import Schema, And, Or, Optional
|
from schema import Schema, And, Or, Optional
|
||||||
from Utils import get_fuzzy_results
|
from Utils import get_fuzzy_results
|
||||||
|
|
||||||
|
|
||||||
class AssembleOptions(abc.ABCMeta):
|
class AssembleOptions(abc.ABCMeta):
|
||||||
def __new__(mcs, name, bases, attrs):
|
def __new__(mcs, name, bases, attrs):
|
||||||
options = attrs["options"] = {}
|
options = attrs["options"] = {}
|
||||||
|
|
|
@ -193,9 +193,18 @@ del (raw)
|
||||||
recipes = {}
|
recipes = {}
|
||||||
all_product_sources: Dict[str, Set[Recipe]] = {"character": set()}
|
all_product_sources: Dict[str, Set[Recipe]] = {"character": set()}
|
||||||
# add uranium mining to logic graph. TODO: add to automatic extractor for mod support
|
# add uranium mining to logic graph. TODO: add to automatic extractor for mod support
|
||||||
raw_recipes["uranium-ore"] = {"ingredients": {"sulfuric-acid": 1}, "products": {"uranium-ore": 1}, "category": "mining",
|
raw_recipes["uranium-ore"] = {
|
||||||
"energy": 2}
|
"ingredients": {"sulfuric-acid": 1},
|
||||||
raw_recipes["crude-oil"] = {"ingredients": {}, "products": {"crude-oil"}, "category": "basic-fluid"}
|
"products": {"uranium-ore": 1},
|
||||||
|
"category": "mining",
|
||||||
|
"energy": 2
|
||||||
|
}
|
||||||
|
raw_recipes["crude-oil"] = {
|
||||||
|
"ingredients": {},
|
||||||
|
"products": {"crude-oil": 1},
|
||||||
|
"category": "basic-fluid",
|
||||||
|
"energy": 1
|
||||||
|
}
|
||||||
|
|
||||||
# raw_recipes["iron-ore"] = {"ingredients": {}, "products": {"iron-ore": 1}, "category": "mining", "energy": 2}
|
# raw_recipes["iron-ore"] = {"ingredients": {}, "products": {"iron-ore": 1}, "category": "mining", "energy": 2}
|
||||||
# raw_recipes["copper-ore"] = {"ingredients": {}, "products": {"copper-ore": 1}, "category": "mining", "energy": 2}
|
# raw_recipes["copper-ore"] = {"ingredients": {}, "products": {"copper-ore": 1}, "category": "mining", "energy": 2}
|
||||||
|
|
|
@ -245,14 +245,16 @@ class Factorio(World):
|
||||||
ingredient = pool.pop()
|
ingredient = pool.pop()
|
||||||
if liquids_used == allow_liquids and ingredient in liquids:
|
if liquids_used == allow_liquids and ingredient in liquids:
|
||||||
continue # can't use this ingredient as we already have maximum liquid in our recipe.
|
continue # can't use this ingredient as we already have maximum liquid in our recipe.
|
||||||
|
ingredient_raw = 0
|
||||||
if ingredient in all_product_sources:
|
if ingredient in all_product_sources:
|
||||||
ingredient_recipe = min(all_product_sources[ingredient], key=lambda recipe: recipe.rel_cost)
|
ingredient_recipe = min(all_product_sources[ingredient], key=lambda recipe: recipe.rel_cost)
|
||||||
ingredient_raw = sum((count for ingredient, count in ingredient_recipe.base_cost.items()))
|
ingredient_raw = sum((count for ingredient, count in ingredient_recipe.base_cost.items()))
|
||||||
ingredient_energy = ingredient_recipe.total_energy
|
ingredient_energy = ingredient_recipe.total_energy
|
||||||
else:
|
else:
|
||||||
# assume simple ore TODO: remove if tree when mining data is harvested from Factorio
|
# assume simple ore TODO: remove if tree when mining data is harvested from Factorio
|
||||||
ingredient_raw = 1
|
|
||||||
ingredient_energy = 2
|
ingredient_energy = 2
|
||||||
|
if not ingredient_raw:
|
||||||
|
ingredient_raw = 1
|
||||||
if remaining_num_ingredients == 1:
|
if remaining_num_ingredients == 1:
|
||||||
max_raw = 1.1 * remaining_raw
|
max_raw = 1.1 * remaining_raw
|
||||||
min_raw = 0.9 * remaining_raw
|
min_raw = 0.9 * remaining_raw
|
||||||
|
|
|
@ -178,13 +178,13 @@ data:extend{new_tree_copy}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if recipe_time_scale %}
|
{% if recipe_time_scale %}
|
||||||
{%- for recipe_name, recipe in recipes.items() %}
|
{%- for recipe_name, recipe in recipes.items() %}
|
||||||
{%- if recipe.category != "mining" %}
|
{%- if recipe.category not in ("mining", "basic-fluid") %}
|
||||||
adjust_energy("{{ recipe_name }}", {{ flop_random(*recipe_time_scale) }})
|
adjust_energy("{{ recipe_name }}", {{ flop_random(*recipe_time_scale) }})
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
{% elif recipe_time_range %}
|
{% elif recipe_time_range %}
|
||||||
{%- for recipe_name, recipe in recipes.items() %}
|
{%- for recipe_name, recipe in recipes.items() %}
|
||||||
{%- if recipe.category != "mining" %}
|
{%- if recipe.category not in ("mining", "basic-fluid") %}
|
||||||
set_energy("{{ recipe_name }}", {{ flop_random(*recipe_time_range) }})
|
set_energy("{{ recipe_name }}", {{ flop_random(*recipe_time_range) }})
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
|
|
Loading…
Reference in New Issue