RecipeElement module

class RecipeElement.RecipeElement(recipes)[source]

Bases: object

Abstract class that implements shared behaviours between elements that use recipes

Parameters:

recipes (Dictionary) – Contains the recipes that the assemblers in the blueprint will use, for each recipe it has a list of the items it requires and which rate in items/min needs and the outputting item and rate.

initialize_map_dictionaries(recipes)[source]

Creates the dictionaries that map the item names to item ids and vice-versa

Parameters:

recipes (Dictionary) – Contains the recipes that the assemblers in the blueprint will use, for each recipe it has a list of the items it requires and which rate in items/min needs and the outputting item and rate.

Returns:

A dictionary that for each item name (key), has its id (value), and a dictionary that for each item id (key), has its name (value)

Return type:

Dictionary, Dictionary

input_recipe_values()[source]

Creates a matrix that each row represents a recipe and each column the items, the value each cell takes is the amount of items used by the recipe (0 if not used)

Returns:

A matrix with the amount of items each recipe uses

Return type:

Array[Array]

is_recipe_input(recipe_name, item_name)[source]

Checks if the item_name is an input of the recipe_name

Parameters:
  • recipe_name (String) – Recipe name

  • item_name (String) – Item name

Returns:

True if the item_name is an input of recipe_name, false otherwise

Return type:

Bool

is_recipe_output(recipe_name, item_name)[source]

Checks if the item_name is an output of the recipe_name

Parameters:
  • recipe_name (String) – Recipe name

  • item_name (String) – Item name

Returns:

True if the item_name is an output of recipe_name, false otherwise

Return type:

Bool

memory_item_id(item_id)[source]

Given a item id returns its name if the name exists or -1 if it doesn’t

Parameters:

item_id (Int) – Item id

Returns:

The mapped name to the id

Return type:

String

model_item_id(item_id)[source]

Given a item name returns its id if the name exists or -1 if it doesn’t

Parameters:

item_id (String) – Item name

Returns:

The mapped id to the name

Return type:

Int

output_recipe_values()[source]

Creates a matrix that each row represents a recipe and each column the items, the value each cell takes is the amount of items produced by the recipe (0 if not produced)

Returns:

A matrix with the amount of items each recipe produces

Return type:

Array[Array]