mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-13 03:33:21 +00:00
Well, now the kitchen can't produce ANYTHING, not just regular
food. No runtimes though. Progress.
This commit is contained in:
@@ -40,7 +40,7 @@
|
|||||||
var/result // example: = /obj/item/weapon/reagent_containers/food/snacks/donut/normal
|
var/result // example: = /obj/item/weapon/reagent_containers/food/snacks/donut/normal
|
||||||
var/time = 100 // 1/10 part of second
|
var/time = 100 // 1/10 part of second
|
||||||
|
|
||||||
/datum/recipe/proc/check_reagents(var/datum/reagents/avail_reagents) //1=precisely, 0=insufficiently, -1=superfluous
|
/datum/recipe/proc/check_reagents(var/datum/reagents/avail_reagents)
|
||||||
. = 1
|
. = 1
|
||||||
for (var/r_r in reagents)
|
for (var/r_r in reagents)
|
||||||
var/aval_r_amnt = avail_reagents.get_reagent_amount(r_r)
|
var/aval_r_amnt = avail_reagents.get_reagent_amount(r_r)
|
||||||
@@ -54,28 +54,27 @@
|
|||||||
return .
|
return .
|
||||||
|
|
||||||
/datum/recipe/proc/check_fruit(var/obj/container)
|
/datum/recipe/proc/check_fruit(var/obj/container)
|
||||||
if(!fruit)
|
|
||||||
. = 1
|
. = 1
|
||||||
return 1
|
if(fruit && fruit.len)
|
||||||
|
var/list/checklist = list()
|
||||||
var/list/checklist = fruit.Copy()
|
for(var/fruittype in fruit) // I do not trust Copy().
|
||||||
|
checklist[fruittype] = fruit[fruittype]
|
||||||
for(var/obj/item/weapon/reagent_containers/food/snacks/grown/G in container)
|
for(var/obj/item/weapon/reagent_containers/food/snacks/grown/G in container)
|
||||||
if(!G.seed)
|
if(!G.seed || !G.seed.kitchen_tag || isnull(checklist[G.seed.kitchen_tag]) || checklist[G.seed.kitchen_tag] <= 0)
|
||||||
return
|
|
||||||
if(!G.seed.kitchen_tag || !checklist[G.seed.kitchen_tag] || checklist[G.seed.kitchen_tag] <= 0)
|
|
||||||
continue
|
continue
|
||||||
checklist[G.seed.kitchen_tag]--
|
checklist[G.seed.kitchen_tag]--
|
||||||
|
|
||||||
for(var/ktag in checklist)
|
for(var/ktag in checklist)
|
||||||
if(checklist[ktag] && checklist[ktag] > 0)
|
if(!isnull(checklist[ktag]))
|
||||||
|
if(checklist[ktag] < 0)
|
||||||
. = -1
|
. = -1
|
||||||
return -1
|
else if(checklist[ktag] > 0)
|
||||||
|
. = 0
|
||||||
|
break
|
||||||
return .
|
return .
|
||||||
|
|
||||||
/datum/recipe/proc/check_items(var/obj/container as obj) //1=precisely, 0=insufficiently, -1=superfluous
|
/datum/recipe/proc/check_items(var/obj/container as obj)
|
||||||
if (!items)
|
|
||||||
return 1
|
|
||||||
. = 1
|
. = 1
|
||||||
|
if (items && items.len)
|
||||||
var/list/checklist = items.Copy()
|
var/list/checklist = items.Copy()
|
||||||
for(var/obj/O in container)
|
for(var/obj/O in container)
|
||||||
var/found = 0
|
var/found = 0
|
||||||
@@ -87,7 +86,7 @@
|
|||||||
if (!found)
|
if (!found)
|
||||||
. = -1
|
. = -1
|
||||||
if (checklist.len)
|
if (checklist.len)
|
||||||
return 0
|
. = 0
|
||||||
return .
|
return .
|
||||||
|
|
||||||
//general version
|
//general version
|
||||||
@@ -111,9 +110,11 @@
|
|||||||
container.reagents.clear_reagents()
|
container.reagents.clear_reagents()
|
||||||
return result_obj
|
return result_obj
|
||||||
|
|
||||||
/proc/select_recipe(var/list/datum/recipe/avaiable_recipes, var/obj/obj as obj, var/exact = 1 as num)
|
/proc/select_recipe(var/list/datum/recipe/avaiable_recipes, var/obj/obj as obj, var/exact)
|
||||||
if (!exact)
|
if (!exact)
|
||||||
exact = -1
|
exact = -1
|
||||||
|
else
|
||||||
|
exact = 1
|
||||||
var/list/datum/recipe/possible_recipes = new
|
var/list/datum/recipe/possible_recipes = new
|
||||||
for (var/datum/recipe/recipe in avaiable_recipes)
|
for (var/datum/recipe/recipe in avaiable_recipes)
|
||||||
if (recipe.check_reagents(obj.reagents)==exact && recipe.check_items(obj)==exact && recipe.check_fruit(obj)==exact)
|
if (recipe.check_reagents(obj.reagents)==exact && recipe.check_items(obj)==exact && recipe.check_fruit(obj)==exact)
|
||||||
@@ -123,14 +124,11 @@
|
|||||||
else if (possible_recipes.len==1)
|
else if (possible_recipes.len==1)
|
||||||
return possible_recipes[1]
|
return possible_recipes[1]
|
||||||
else //okay, let's select the most complicated recipe
|
else //okay, let's select the most complicated recipe
|
||||||
var/r_count = 0
|
var/highest_count = 0
|
||||||
var/i_count = 0
|
|
||||||
. = possible_recipes[1]
|
. = possible_recipes[1]
|
||||||
for (var/datum/recipe/recipe in possible_recipes)
|
for (var/datum/recipe/recipe in possible_recipes)
|
||||||
var/N_i = (recipe.items)?(recipe.items.len):0
|
var/count = ((recipe.items)?(recipe.items.len):0) + ((recipe.reagents)?(recipe.reagents.len):0) + ((recipe.fruit)?(recipe.fruit.len):0)
|
||||||
var/N_r = (recipe.reagents)?(recipe.reagents.len):0
|
if (count >= highest_count)
|
||||||
if (N_i > i_count || (N_i== i_count && N_r > r_count ))
|
highest_count = count
|
||||||
r_count = N_r
|
|
||||||
i_count = N_i
|
|
||||||
. = recipe
|
. = recipe
|
||||||
return .
|
return .
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Reference in New Issue
Block a user