Files
levels0 f5fc272810 Random recipe logging (and other stuff) (#96148)
## About The Pull Request
-Log outcomes of random recipe init
* Whether recipe failed to load, and why
* Whether recipe failed to generate, and why
* Whether recipe regenerated due to conflicts, and how many attempts it
took

-Stop saving random recipe results to the persistence file
* They aren't randomized anyway

-Split recipe loading and recipe generation into separate procs
* It was kind of a mess
* This way, you can regenerate recipe without qdel'ing it and then
reinitializing

-Generate recipe if it failed to load
* We used to qdel it instead

-Consider recipe generation to be a failure if there aren't enough valid
ingredients or catalysts
* We used to only check whether possible ingredient list is empty
* Since the possible ingredient/catalyst lists don't change from round
to round, this could probably be made into a unit test in the future

-Reorganize random recipe conflict checks to make them more streamlined
* I had to do it in order to log regeneration outcomes

-Fix bugs which won't ever matter anyway
* optimal_ph_max no longer rolls above 14
* optimal_ph_max can no longer be below optimal_ph_min + 1 (we used to
check for CHEMICAL_MIN_PH + 1, which is just 1)
## Why It's Good For The Game

Logs help spot&diagnose issues which might not come up when testing
locally, like the issue where timestamps wouldn't update which was fixed
by #95895
## Changelog
🆑
fix: random recipes can no longer have upper pH bound above 14
/🆑

---------

Co-authored-by: l0 <-->
2026-06-03 08:04:56 +02:00

30 lines
1.0 KiB
Plaintext

///Saves all randomized recipes.
/datum/controller/subsystem/persistence/proc/save_randomized_recipes()
var/json_file = file("data/RandomizedChemRecipes.json")
var/list/file_data = list()
//asert globchems done
for(var/randomized_type in subtypesof(/datum/chemical_reaction/randomized))
var/datum/chemical_reaction/randomized/R = GLOB.chemical_reactions_list[randomized_type]
if(!R)
continue
file_data["[R.type]"] = list(
timestamp = R.created,
required_reagents = R.required_reagents,
required_catalysts = R.required_catalysts,
is_cold_recipe = R.is_cold_recipe,
required_temp = R.required_temp,
optimal_temp = R.optimal_temp,
overheat_temp = R.overheat_temp,
thermic_constant = R.thermic_constant,
optimal_ph_min = R.optimal_ph_min,
optimal_ph_max = R.optimal_ph_max,
determin_ph_range = R.determin_ph_range,
H_ion_release = R.H_ion_release,
purity_min = R.purity_min,
required_container = R.required_container
)
fdel(json_file)
WRITE_FILE(json_file, json_encode(file_data))