RUFAS.routines.feed_storage.feed_manager module#

RUFAS.routines.feed_storage.feed_manager.CROP_TO_STORAGE_MAPPING: Dict[CropCategory, type[List[Storage]]] = {CropCategory.ALFALFA: [<class 'RUFAS.routines.feed_storage.hay.Hay'>, <class 'RUFAS.routines.feed_storage.silage.Silage'>, <class 'RUFAS.routines.feed_storage.baleage.Baleage'>], CropCategory.CORN: [<class 'RUFAS.routines.feed_storage.grain.Grain'>, <class 'RUFAS.routines.feed_storage.silage.Silage'>], CropCategory.GRASS: [<class 'RUFAS.routines.feed_storage.hay.Hay'>, <class 'RUFAS.routines.feed_storage.silage.Silage'>, <class 'RUFAS.routines.feed_storage.baleage.Baleage'>], CropCategory.SMALL_GRAIN: [<class 'RUFAS.routines.feed_storage.hay.Hay'>, <class 'RUFAS.routines.feed_storage.grain.Grain'>, <class 'RUFAS.routines.feed_storage.silage.Silage'>, <class 'RUFAS.routines.feed_storage.baleage.Baleage'>], CropCategory.SOY: [<class 'RUFAS.routines.feed_storage.grain.Grain'>]}#

Maps each StorageType enum element to the associated Storage subclass.

class RUFAS.routines.feed_storage.feed_manager.FeedManager#

Bases: object

Manages the feed storage, handling crop reception, purchasing, degradation processing, feed distribution, and querying available feeds.

Attributes#

active_storagesDict[StorageType, Storage]

A dictionary mapping storage types to their corresponding active storage objects.

__init__()#
_query_result_factory(crop_category: CropCategory, crop_type: CropType, amount: float) Dict[str, CropCategory | CropType | float]#
receive_crop(harvested_crop: HarvestedCrop, storage_type: StorageType) None#

Receives a harvested crop and assigns it to a storage unit.

Parameters#

harvested_cropHarvestedCrop

The harvested crop to be stored.

storage_typeStorageType

The type of storage to use for this crop.

Raises#

ValueError

If the crop type is not compatible with the storage type.

process_degradations(weather: Weather, time: RufasTime) None#

Processes the degradation of all stored feeds over time.

give_feed(amount: float, crop_type: CropType) float#

Distributes feed to the Animal module based on the FIFO principle.

Parameters#

amountfloat

The amount of feed to distribute.

crop_typeCropType

The type of crop to distribute.

Returns#

float

The actual amount of feed distributed.

query_available_feeds(query_crop_types: List[CropType] | None = None, query_crop_categories: List[CropCategory] | None = None, query_storage_types: List[StorageType] | None = None) List[Dict[str, CropCategory | CropType | float]]#

Queries the available amount of feed in storage.

Parameters#

query_crop_typesList[CropType], optional, default=None

The types of crop to query (if None, all crop types are queried).

query_crop_categoriesList[CropCategory], optional, default=None

The categories of crop to query (if None, all crop categories are queried).

query_storage_typesList[StorageType], optional, default=None

The types of storage to query (if None, all storages types are queried).

Returns#

List[QUERY_RESULT_DATA_TYPE]

The amount of available feed, either as a total or for a specific crop type.

purchase_feed() None#

The purchase feed logic is currently in the Animal Module. We will move it to here.

setup_stored_feeds(feeds_info: dict[str, dict[str, str | float]], time: RufasTime) None#

Sets up HarvestedCrops for the Feed Manager to degrade, if running end-to-end testing.