Port over fermentation barrel, minor refactor of reagent container, add in wine power etc.

This commit is contained in:
variableundefined
2018-11-01 11:01:45 +08:00
parent 352f132c58
commit 7905b64076
36 changed files with 320 additions and 29 deletions
@@ -1236,3 +1236,107 @@
drink_icon = "synthignonglass"
drink_name = "Glass of Synthignon"
drink_desc = "Someone mixed good wine and robot booze. Romantic, but atrocious."
/datum/reagent/consumable/ethanol/fruit_wine
name = "Fruit Wine"
id = "fruit_wine"
description = "A wine made from grown plants."
color = "#FFFFFF"
alcohol_perc = 0.35
taste_message = "bad coding"
can_synth = FALSE
var/list/names = list("null fruit" = 1) //Names of the fruits used. Associative list where name is key, value is the percentage of that fruit.
var/list/tastes = list("bad coding" = 1) //List of tastes. See above.
/datum/reagent/consumable/ethanol/fruit_wine/on_new(list/data)
names = data["names"]
tastes = data["tastes"]
alcohol_perc = data["alcohol_perc"]
color = data["color"]
generate_data_info(data)
/datum/reagent/consumable/ethanol/fruit_wine/on_merge(list/data, amount)
var/diff = (amount/volume)
if(diff < 1)
color = BlendRGB(color, data["color"], diff/2) //The percentage difference over two, so that they take average if equal.
else
color = BlendRGB(color, data["color"], (1/diff)/2) //Adjust so it's always blending properly.
var/oldvolume = volume-amount
var/list/cachednames = data["names"]
for(var/name in names | cachednames)
names[name] = ((names[name] * oldvolume) + (cachednames[name] * amount)) / volume
var/list/cachedtastes = data["tastes"]
for(var/taste in tastes | cachedtastes)
tastes[taste] = ((tastes[taste] * oldvolume) + (cachedtastes[taste] * amount)) / volume
alcohol_perc *= oldvolume
var/newzepwr = data["alcohol_perc"] * amount
alcohol_perc += newzepwr
alcohol_perc /= volume //Blending alcohol percentage to volume.
generate_data_info(data)
/datum/reagent/consumable/ethanol/fruit_wine/proc/generate_data_info(list/data)
var/minimum_percent = 0.15 //Percentages measured between 0 and 1.
var/list/primary_tastes = list()
var/list/secondary_tastes = list()
drink_name = "glass of [name]"
drink_desc = description
for(var/taste in tastes)
switch(tastes[taste])
if(minimum_percent*2 to INFINITY)
primary_tastes += taste
if(minimum_percent to minimum_percent*2)
secondary_tastes += taste
var/minimum_name_percent = 0.35
name = ""
var/list/names_in_order = sortTim(names, /proc/cmp_numeric_dsc, TRUE)
var/named = FALSE
for(var/fruit_name in names)
if(names[fruit_name] >= minimum_name_percent)
name += "[fruit_name] "
named = TRUE
if(named)
name += "wine"
else
name = "mixed [names_in_order[1]] wine"
var/alcohol_description
switch(alcohol_perc)
if(1.2 to INFINITY)
alcohol_description = "suicidally strong"
if(0.9 to 1.2)
alcohol_description = "rather strong"
if(0.7 to 0.9)
alcohol_description = "strong"
if(0.4 to 0.7)
alcohol_description = "rich"
if(0.2 to 0.4)
alcohol_description = "mild"
if(0 to 0.2)
alcohol_description = "sweet"
else
alcohol_description = "watery" //How the hell did you get negative boozepwr?
var/list/fruits = list()
if(names_in_order.len <= 3)
fruits = names_in_order
else
for(var/i in 1 to 3)
fruits += names_in_order[i]
fruits += "other plants"
var/fruit_list = english_list(fruits)
description = "A [alcohol_description] wine brewed from [fruit_list]."
var/flavor = ""
if(!primary_tastes.len)
primary_tastes = list("[alcohol_description] alcohol")
flavor += english_list(primary_tastes)
if(secondary_tastes.len)
flavor += ", with a hint of "
flavor += english_list(secondary_tastes)
taste_message = flavor
if(holder.my_atom)
holder.my_atom.on_reagent_change()
@@ -95,7 +95,6 @@
spawn(5) reagents.clear_reagents()
return
else if(istype(target, /obj/structure/reagent_dispensers)) //A dispenser. Transfer FROM it TO us.
if(target.reagents && !target.reagents.total_volume)
to_chat(user, "<span class='warning'>[target] is empty and can't be refilled!</span>")
return
@@ -107,7 +106,7 @@
var/trans = target.reagents.trans_to(src, amount_per_transfer_from_this)
to_chat(user, "<span class='notice'>You fill [src] with [trans] unit\s of the contents of [target].</span>")
else if(target.is_open_container() && target.reagents) //Something like a glass. Player probably wants to transfer TO it.
else if(target.is_refillable() && is_drainable()) //Something like a glass. Player probably wants to transfer TO it.
if(!reagents.total_volume)
to_chat(user, "<span class='warning'>[src] is empty.</span>")
return