mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 10:21:11 +00:00
Fix research tree
All functions tested and working.
This commit is contained in:
@@ -7,6 +7,29 @@
|
||||
/proc/worldtime2text(timestamp = world.time)
|
||||
return "[(round(timestamp / 36000) + 12) % 24]:[(timestamp / 600 % 60) < 10 ? add_zero(timestamp / 600 % 60, 1) : timestamp / 600 % 60]"
|
||||
|
||||
|
||||
/proc/formatTimeDuration(var/deciseconds)
|
||||
var/m = round(deciseconds / 600)
|
||||
var/s = (deciseconds % 600)/10
|
||||
var/h = round(m / 60)
|
||||
m = m % 60
|
||||
if(h>0)
|
||||
. += "[h]:"
|
||||
if(h>0 || m > 0)
|
||||
. += "[(m<10)?"0":""][m]:"
|
||||
. += "[(s<10)?"0":""][s]"
|
||||
|
||||
/proc/altFormatTimeDuration(var/deciseconds)
|
||||
var/m = round(deciseconds / 600)
|
||||
var/s = (deciseconds % 600)/10
|
||||
var/h = round(m / 60)
|
||||
m = m % 60
|
||||
if(h > 0)
|
||||
. += "[h]h "
|
||||
if(m > 0)
|
||||
. += "[m]m "
|
||||
. += "[s]s"
|
||||
|
||||
/proc/time_stamp()
|
||||
return time2text(world.timeofday, "hh:mm:ss")
|
||||
|
||||
|
||||
@@ -30,22 +30,27 @@
|
||||
avail_unlocks=list()
|
||||
for(var/datum/unlockable/U in get_avail_unlocks())
|
||||
if(!U.id) continue
|
||||
U.set_context(src)
|
||||
if(!U.unlocked && U.can_buy(src) && U.check_prerequisites(src))
|
||||
usable_unlocks[U.id]="\ref[U]"
|
||||
avail_unlocks[U.id]="\ref[U]"
|
||||
|
||||
/datum/research_tree/proc/get_thead()
|
||||
return "<th>Name</th><th>Cost</th>"
|
||||
/datum/research_tree/proc/start_table()
|
||||
return "<table class=\"prettytable\"><thead><th>Name</th><th>Cost</th><th>Time</th></thead>"
|
||||
|
||||
/datum/research_tree/proc/end_table()
|
||||
return "</table>"
|
||||
|
||||
/datum/research_tree/proc/display(var/mob/user)
|
||||
testing("Entering display...")
|
||||
var/html = "<h2>[title]</h2>[blurb]"
|
||||
html += "<table class=\"prettytable\"><thead>[get_thead()]</thead>"
|
||||
var/html = "<h2>[title]</h2><p>[blurb]</p>"
|
||||
html += start_table()
|
||||
load_usable_unlocks()
|
||||
for(var/id in usable_unlocks)
|
||||
var/datum/unlockable/U=locate(usable_unlocks[id])
|
||||
U.set_context(src)
|
||||
html += U.toTableRow(src,user)
|
||||
html += "</table>"
|
||||
html += end_table()
|
||||
|
||||
popup = new /datum/browser/clean(user, "\ref[src]_research", "Research Tree", 300, 300)
|
||||
popup.set_content(html)
|
||||
@@ -54,12 +59,12 @@
|
||||
/datum/research_tree/proc/close(var/mob/user)
|
||||
user << browse(null,"window=\ref[src]_research")
|
||||
|
||||
|
||||
/datum/research_tree/Topic(href, href_list)
|
||||
if("unlock" in href_list)
|
||||
var/mob/viewer = locate(href_list["user"])
|
||||
var/datum/unlockable/unlock = locate(usable_unlocks[href_list["unlock"]])
|
||||
if(!unlock)
|
||||
return
|
||||
unlock.set_context(src)
|
||||
unlock.unlock(src)
|
||||
display(viewer)
|
||||
@@ -3,8 +3,9 @@
|
||||
var/name=""
|
||||
var/desc=""
|
||||
var/cost=0 // Cost to unlock
|
||||
var/cost_units=""
|
||||
var/time=0 // Time to unlock
|
||||
var/unlocked=1
|
||||
var/unlocked=0
|
||||
//var/remove_on_detach=1
|
||||
|
||||
var/list/prerequisites=list()
|
||||
@@ -15,6 +16,7 @@
|
||||
tree = T
|
||||
|
||||
/datum/unlockable/proc/check_prerequisites()
|
||||
if(prerequisites.len>0)
|
||||
for(var/prereq in prerequisites)
|
||||
if(!(prereq in tree.unlocked))
|
||||
return 0
|
||||
@@ -49,7 +51,21 @@
|
||||
|
||||
|
||||
/datum/unlockable/proc/toTableRow(var/datum/research_tree/tree, var/mob/user)
|
||||
return "<tr><th><a href=\"?src=\ref[tree];user=\ref[user];unlock=[id]\">[name]</a></th><td>[desc]</td></tr>"
|
||||
return {"
|
||||
<tr>
|
||||
<th>
|
||||
<a href="?src=\ref[tree];user=\ref[user];unlock=[id]">[name]</a>
|
||||
</th>
|
||||
<th>
|
||||
[cost][cost_units]
|
||||
</th>
|
||||
<th>
|
||||
[altFormatTimeDuration(time)]
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">[desc]</td>
|
||||
</tr>"}
|
||||
|
||||
/**
|
||||
* additional checks to perform when unlocking things.
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
return borer_avail_unlocks
|
||||
|
||||
/datum/unlockable/borer
|
||||
cost_units = "C"
|
||||
var/remove_on_detach=1
|
||||
var/mob/living/simple_animal/borer/borer
|
||||
|
||||
@@ -52,7 +53,7 @@
|
||||
id = "inaprovaline"
|
||||
name = "Inaprovaline Secretion"
|
||||
desc = "Learn how to synthesize inaprovaline."
|
||||
cost = 20
|
||||
cost = 100
|
||||
time = 10 SECONDS
|
||||
chem_type = /datum/borer_chem/unlockable/inaprovaline
|
||||
|
||||
@@ -60,7 +61,7 @@
|
||||
id = "space_drugs"
|
||||
name = "Space Drug Secretion"
|
||||
desc = "Learn how to synthesize space drugs."
|
||||
cost = 10
|
||||
cost = 50
|
||||
time = 10 SECONDS
|
||||
chem_type = /datum/borer_chem/unlockable/space_drugs
|
||||
|
||||
@@ -68,7 +69,7 @@
|
||||
id = "paracetamol"
|
||||
name = "Paracetamol Secretion"
|
||||
desc = "Learn how to synthesize painkillers."
|
||||
cost = 20
|
||||
cost = 100
|
||||
time = 10 SECONDS
|
||||
chem_type = /datum/borer_chem/unlockable/paracetamol
|
||||
|
||||
@@ -77,7 +78,7 @@
|
||||
id = "kelotane"
|
||||
name = "Kelotane Secretion"
|
||||
desc = "Learn how to synthesize kelotane."
|
||||
cost = 20
|
||||
cost = 100
|
||||
time = 10 SECONDS
|
||||
chem_type = /datum/borer_chem/unlockable/kelotane
|
||||
|
||||
@@ -85,7 +86,7 @@
|
||||
id = "dermaline"
|
||||
name = "Dermaline Secretion"
|
||||
desc = "Learn how to synthesize dermaline."
|
||||
cost = 30
|
||||
cost = 150
|
||||
time = 20 SECONDS
|
||||
chem_type = /datum/borer_chem/unlockable/dermaline
|
||||
prerequisites=list("kelotane")
|
||||
@@ -95,7 +96,7 @@
|
||||
id = "dexalin"
|
||||
name = "Dexalin Secretion"
|
||||
desc = "Learn how to synthesize dexalin."
|
||||
cost = 20
|
||||
cost = 100
|
||||
time = 10 SECONDS
|
||||
chem_type = /datum/borer_chem/unlockable/dexalin
|
||||
|
||||
@@ -103,7 +104,7 @@
|
||||
id = "dexalinp"
|
||||
name = "Dexalin+ Secretion"
|
||||
desc = "Learn how to synthesize Dexalin+."
|
||||
cost = 30
|
||||
cost = 150
|
||||
time = 20 SECONDS
|
||||
chem_type = /datum/borer_chem/unlockable/dexalinp
|
||||
prerequisites=list("dexalin")
|
||||
@@ -150,7 +151,7 @@
|
||||
id = "sober"
|
||||
name = "Liver Function Boost"
|
||||
desc = "Your host's liver is able to handle massive quantities of alcohol."
|
||||
cost = 35
|
||||
cost = 200
|
||||
time = 30 SECONDS
|
||||
gene_name = "SOBER"
|
||||
|
||||
@@ -158,7 +159,7 @@
|
||||
id = "run"
|
||||
name = "Enhanced Metabolism"
|
||||
desc = "Modifies your host to run faster."
|
||||
cost = 30
|
||||
cost = 150
|
||||
time = 20 SECONDS
|
||||
gene_name = "INCREASERUN"
|
||||
prerequisites=list("sober")
|
||||
@@ -168,7 +169,7 @@
|
||||
id = "farsight"
|
||||
name = "Telephoto Vision"
|
||||
desc = "Adjusts your host's eyes to see farther."
|
||||
cost = 40
|
||||
cost = 200
|
||||
time = 1 MINUTES
|
||||
gene_name = "FARSIGHT"
|
||||
|
||||
@@ -176,7 +177,7 @@
|
||||
id = "run"
|
||||
name = "High-Energy Vision"
|
||||
desc = "Adjusts your host's eyes to see in the X-Ray spectrum."
|
||||
cost = 40
|
||||
cost = 200
|
||||
time = 2 MINUTES
|
||||
gene_name = "XRAYBLOCK"
|
||||
prerequisites=list("farsight")
|
||||
Reference in New Issue
Block a user