Skip to content

Commit

Permalink
Fix recipe to producer mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
mitaa committed Oct 8, 2024
1 parent 5ddd5e0 commit 8222be2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/production_planner/cells/ingredient.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def get(self) -> CellValue:
clamp_count = self.data.node_main.clamp.value.count
if abs(abs(value) - abs(clamp_count)) > 0.01:
# FIXME: DataTable doesn't seem to handle strikethrough very well (small part of the next row is shifted to this one)
# TODO: use rich.text.Text with strikethrough style to show the clamped value
return CellValue(value, text=f"{value} !", clamped=True)
else:
return CellValue(value, clamped=True)
Expand Down
2 changes: 1 addition & 1 deletion src/production_planner/core/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def update_module(self, modulefile: ModuleFile) -> Optional:

MODULE_PRODUCER = _ModuleProducer(
"Module",
abstract=True,
is_abstract=True,
is_miner=False,
is_pow_gen=False,
max_mk=0,
Expand Down
17 changes: 10 additions & 7 deletions src/production_planner/core/producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@


class Producer:
def __init__(self, name, *, is_miner, is_pow_gen, max_mk, base_power, recipes, description, abstract=False):
self.abstract = abstract
def __init__(self, name, *, is_miner, is_pow_gen, max_mk, base_power, recipes, description, is_abstract=False, is_primary=True):
self.is_abstract = is_abstract
self.is_primary = is_primary
self.name = name
self.is_miner = is_miner
self.is_pow_gen = is_pow_gen
Expand All @@ -45,10 +46,11 @@ def update_recipe_map(self):
self.recipe_map = {}
for recipe in self.recipes:
self.recipe_map[recipe.name] = recipe
recipe.recipe_to_producer_map[recipe] = self
if self.is_primary:
recipe.recipe_to_producer_map[recipe] = self

def __str__(self):
if self.abstract:
if self.is_abstract:
return f"<{self.name}>"
else:
return self.name
Expand Down Expand Up @@ -101,7 +103,7 @@ def add(self, k, v):

EMPTY_PRODUCER = Producer(
"",
abstract=False,
is_abstract=False,
is_miner=False,
is_pow_gen=False,
max_mk=0,
Expand All @@ -112,7 +114,7 @@ def add(self, k, v):

SUMMARY_PRODUCER = Producer(
"Summary",
abstract=False,
is_abstract=False,
is_miner=False,
is_pow_gen=False,
max_mk=0,
Expand Down Expand Up @@ -140,7 +142,8 @@ def all_recipes_producer():

prod = Producer(
"<ALL RECIPES>",
abstract=True,
is_abstract=True,
is_primary=False,
is_miner=False,
is_pow_gen=False,
max_mk=0,
Expand Down
2 changes: 1 addition & 1 deletion tests
Submodule tests updated 1 files
+15 −0 test_recipe.py

0 comments on commit 8222be2

Please sign in to comment.