mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-27 05:57:24 +01:00
even more work
This commit is contained in:
+43
-66
@@ -34,108 +34,88 @@
|
||||
* */
|
||||
|
||||
/datum/recipe
|
||||
var/list/reagents // example: = list("berryjuice" = 5) // do not list same reagent twice
|
||||
var/list/items // example: = list(/obj/item/weapon/crowbar, /obj/item/weapon/welder) // place /foo/bar before /foo
|
||||
var/list/fruit // example: = list("fruit" = 3)
|
||||
var/result // example: = /obj/item/weapon/reagent_containers/food/snacks/donut
|
||||
var/time = 100 // 1/10 part of second
|
||||
var/list/reagents // example: = list("berryjuice" = 5) // do not list same reagent twice
|
||||
var/list/items // example: =list(/obj/item/weapon/crowbar, /obj/item/weapon/welder) // place /foo/bar before /foo
|
||||
var/result //example: = /obj/item/weapon/reagent_containers/food/snacks/donut
|
||||
var/time = 100 // 1/10 part of second
|
||||
var/byproduct // example: = /obj/item/weapon/kitchen/mould // byproduct to return, such as a mould or trash
|
||||
|
||||
|
||||
/datum/recipe/proc/check_reagents(datum/reagents/avail_reagents) //1=precisely, 0=insufficiently, -1=superfluous
|
||||
. = 1
|
||||
for(var/r_r in reagents)
|
||||
for (var/r_r in reagents)
|
||||
var/aval_r_amnt = avail_reagents.get_reagent_amount(r_r)
|
||||
if(!(abs(aval_r_amnt - reagents[r_r])<0.5)) //if NOT equals
|
||||
if(aval_r_amnt>reagents[r_r])
|
||||
if (!(abs(aval_r_amnt - reagents[r_r])<0.5)) //if NOT equals
|
||||
if (aval_r_amnt>reagents[r_r])
|
||||
. = -1
|
||||
else
|
||||
return 0
|
||||
if((reagents?(reagents.len):(0)) < avail_reagents.reagent_list.len)
|
||||
if ((reagents?(reagents.len):(0)) < avail_reagents.reagent_list.len)
|
||||
return -1
|
||||
return .
|
||||
|
||||
/datum/recipe/proc/check_fruit(obj/container)
|
||||
/datum/recipe/proc/check_items(obj/container) //1=precisely, 0=insufficiently, -1=superfluous
|
||||
if (!items)
|
||||
if (locate(/obj/) in container)
|
||||
return -1
|
||||
else
|
||||
return 1
|
||||
. = 1
|
||||
if(fruit && fruit.len)
|
||||
var/list/checklist = list()
|
||||
// You should trust Copy().
|
||||
checklist = fruit.Copy()
|
||||
for(var/obj/item/weapon/reagent_containers/food/snacks/grown/G in container)
|
||||
if(!G.seed || !G.seed.kitchen_tag || isnull(checklist[G.seed.kitchen_tag]))
|
||||
continue
|
||||
checklist[G.seed.kitchen_tag]--
|
||||
for(var/ktag in checklist)
|
||||
if(!isnull(checklist[ktag]))
|
||||
if(checklist[ktag] < 0)
|
||||
. = 0
|
||||
else if(checklist[ktag] > 0)
|
||||
. = -1
|
||||
break
|
||||
return .
|
||||
|
||||
/datum/recipe/proc/check_items(obj/container)
|
||||
. = 1
|
||||
if(items && items.len)
|
||||
var/list/checklist = list()
|
||||
checklist = items.Copy() // You should really trust Copy
|
||||
for(var/obj/O in container)
|
||||
if(istype(O,/obj/item/weapon/reagent_containers/food/snacks/grown))
|
||||
continue // Fruit is handled in check_fruit().
|
||||
var/found = 0
|
||||
for(var/i = 1; i < checklist.len+1; i++)
|
||||
var/item_type = checklist[i]
|
||||
if(istype(O,item_type))
|
||||
checklist.Cut(i, i+1)
|
||||
found = 1
|
||||
break
|
||||
if(!found)
|
||||
. = 0
|
||||
if(checklist.len)
|
||||
var/list/checklist = items.Copy()
|
||||
for (var/obj/O in container)
|
||||
var/found = 0
|
||||
for (var/type in checklist)
|
||||
if (istype(O,type))
|
||||
checklist-=type
|
||||
found = 1
|
||||
break
|
||||
if (!found)
|
||||
. = -1
|
||||
if (checklist.len)
|
||||
return 0
|
||||
return .
|
||||
|
||||
//general version
|
||||
/datum/recipe/proc/make(obj/container)
|
||||
var/obj/result_obj = new result(container)
|
||||
for(var/obj/O in (container.contents-result_obj))
|
||||
for (var/obj/O in (container.contents-result_obj))
|
||||
O.reagents.trans_to(result_obj, O.reagents.total_volume)
|
||||
qdel(O)
|
||||
container.reagents.clear_reagents()
|
||||
score_meals++
|
||||
return result_obj
|
||||
|
||||
// food-related
|
||||
/datum/recipe/proc/make_food(obj/container)
|
||||
var/obj/result_obj = new result(container)
|
||||
for(var/obj/O in (container.contents-result_obj))
|
||||
if(O.reagents)
|
||||
for (var/obj/O in (container.contents-result_obj))
|
||||
if (O.reagents)
|
||||
O.reagents.del_reagent("nutriment")
|
||||
O.reagents.update_total()
|
||||
O.reagents.trans_to(result_obj, O.reagents.total_volume)
|
||||
qdel(O)
|
||||
container.reagents.clear_reagents()
|
||||
score_meals++
|
||||
return result_obj
|
||||
|
||||
/proc/select_recipe(list/datum/recipe/avaiable_recipes, obj/obj, exact = 1)
|
||||
if(!exact)
|
||||
/proc/select_recipe(list/datum/recipe/avaiable_recipes, obj/obj, exact = 1 as num)
|
||||
if (!exact)
|
||||
exact = -1
|
||||
var/list/datum/recipe/possible_recipes = new
|
||||
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)
|
||||
for (var/datum/recipe/recipe in avaiable_recipes)
|
||||
if (recipe.check_reagents(obj.reagents)==exact && recipe.check_items(obj)==exact)
|
||||
possible_recipes+=recipe
|
||||
if(possible_recipes.len==0)
|
||||
if (possible_recipes.len==0)
|
||||
return null
|
||||
else if(possible_recipes.len==1)
|
||||
else if (possible_recipes.len==1)
|
||||
return possible_recipes[1]
|
||||
else //okay, let's select the most complicated recipe
|
||||
var/highest_count = 0
|
||||
var/r_count = 0
|
||||
var/i_count = 0
|
||||
. = possible_recipes[1]
|
||||
for(var/datum/recipe/recipe in possible_recipes)
|
||||
var/count = ((recipe.items)?(recipe.items.len):0) + ((recipe.reagents)?(recipe.reagents.len):0) + ((recipe.fruit)?(recipe.fruit.len):0)
|
||||
if(count >= highest_count)
|
||||
highest_count = count
|
||||
for (var/datum/recipe/recipe in possible_recipes)
|
||||
var/N_i = (recipe.items)?(recipe.items.len):0
|
||||
var/N_r = (recipe.reagents)?(recipe.reagents.len):0
|
||||
if (N_i > i_count || (N_i== i_count && N_r > r_count ))
|
||||
r_count = N_r
|
||||
i_count = N_i
|
||||
. = recipe
|
||||
return .
|
||||
|
||||
@@ -149,7 +129,4 @@
|
||||
var/count = 0
|
||||
if(items && items.len)
|
||||
count += items.len
|
||||
if(fruit && fruit.len)
|
||||
for(var/ktag in fruit)
|
||||
count += fruit[ktag]
|
||||
return count
|
||||
return count
|
||||
@@ -305,7 +305,7 @@ var/list/uplink_items = list()
|
||||
name = "Ambrosia Cruciatus Seeds"
|
||||
desc = "Part of the notorious Ambrosia family, this species is nearly indistinguishable from Ambrosia Vulgaris- but its' branches contain a revolting toxin. Eight units are enough to drive victims insane."
|
||||
reference = "BRO"
|
||||
item = /obj/item/seeds/ambrosiavulgarisseed/cruciatus
|
||||
item = /obj/item/seeds/ambrosia/cruciatus
|
||||
cost = 2
|
||||
job = list("Botanist")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user