Merge pull request #11634 from Markolie/laborstacker

Updates the prison labor point system
This commit is contained in:
variableundefined
2019-07-09 18:21:58 +08:00
committed by GitHub
7 changed files with 227 additions and 143 deletions
@@ -32,6 +32,7 @@ GLOBAL_LIST_INIT(glass_recipes, list ( \
created_window = /obj/structure/window/basic
full_window = /obj/structure/window/full/basic
merge_type = /obj/item/stack/sheet/glass
point_value = 1
/obj/item/stack/sheet/glass/fifty
amount = 50
@@ -90,6 +91,7 @@ GLOBAL_LIST_INIT(reinforced_glass_recipes, list ( \
created_window = /obj/structure/window/reinforced
full_window = /obj/structure/window/full/reinforced
merge_type = /obj/item/stack/sheet/rglass
point_value = 4
/obj/item/stack/sheet/rglass/cyborg
materials = list()
@@ -113,6 +115,7 @@ GLOBAL_LIST_INIT(pglass_recipes, list ( \
origin_tech = "plasmatech=2;materials=2"
created_window = /obj/structure/window/plasmabasic
full_window = /obj/structure/window/full/plasmabasic
point_value = 19
/obj/item/stack/sheet/plasmaglass/New(loc, amount)
recipes = GLOB.pglass_recipes
@@ -154,6 +157,7 @@ GLOBAL_LIST_INIT(prglass_recipes, list ( \
created_window = /obj/structure/window/plasmareinforced
full_window = /obj/structure/window/full/plasmareinforced
armor = list("melee" = 20, "bullet" = 0, "laser" = 0, "energy" = 0, "bomb" = 0, "bio" = 0, "rad" = 0)
point_value = 23
/obj/item/stack/sheet/plasmarglass/New(loc, amount)
recipes = GLOB.prglass_recipes
@@ -144,6 +144,7 @@ var/global/list/datum/stack_recipe/snow_recipes = list(
origin_tech = "materials=6"
sheettype = "diamond"
materials = list(MAT_DIAMOND=MINERAL_MATERIAL_AMOUNT)
point_value = 25
/obj/item/stack/sheet/mineral/diamond/New()
..()
@@ -156,6 +157,7 @@ var/global/list/datum/stack_recipe/snow_recipes = list(
origin_tech = "materials=5"
sheettype = "uranium"
materials = list(MAT_URANIUM=MINERAL_MATERIAL_AMOUNT)
point_value = 20
/obj/item/stack/sheet/mineral/uranium/New()
..()
@@ -170,6 +172,7 @@ var/global/list/datum/stack_recipe/snow_recipes = list(
materials = list(MAT_PLASMA=MINERAL_MATERIAL_AMOUNT)
burn_state = FLAMMABLE
burntime = 5
point_value = 20
/obj/item/stack/sheet/mineral/plasma/New()
..()
@@ -196,6 +199,7 @@ var/global/list/datum/stack_recipe/snow_recipes = list(
origin_tech = "materials=4"
sheettype = "gold"
materials = list(MAT_GOLD=MINERAL_MATERIAL_AMOUNT)
point_value = 20
/obj/item/stack/sheet/mineral/gold/New()
..()
@@ -208,6 +212,7 @@ var/global/list/datum/stack_recipe/snow_recipes = list(
origin_tech = "materials=4"
sheettype = "silver"
materials = list(MAT_SILVER=MINERAL_MATERIAL_AMOUNT)
point_value = 20
/obj/item/stack/sheet/mineral/silver/New()
..()
@@ -220,6 +225,7 @@ var/global/list/datum/stack_recipe/snow_recipes = list(
origin_tech = "materials=4"
sheettype = "bananium"
materials = list(MAT_BANANIUM=MINERAL_MATERIAL_AMOUNT)
point_value = 50
/obj/item/stack/sheet/mineral/bananium/New(loc, amount=null)
..()
@@ -233,6 +239,7 @@ var/global/list/datum/stack_recipe/snow_recipes = list(
sheettype = "tranquillite"
materials = list(MAT_TRANQUILLITE=MINERAL_MATERIAL_AMOUNT)
wall_allowed = FALSE //no tranquilite walls in code
point_value = 50
/obj/item/stack/sheet/mineral/tranquillite/New(loc, amount=null)
..()
@@ -253,6 +260,7 @@ var/global/list/datum/stack_recipe/snow_recipes = list(
throw_range = 3
sheettype = "titanium"
materials = list(MAT_TITANIUM=MINERAL_MATERIAL_AMOUNT)
point_value = 20
var/global/list/datum/stack_recipe/titanium_recipes = list (
new/datum/stack_recipe("titanium tile", /obj/item/stack/tile/mineral/titanium, 1, 4, 20),
@@ -282,6 +290,7 @@ var/global/list/datum/stack_recipe/titanium_recipes = list (
throw_range = 3
sheettype = "plastitanium"
materials = list(MAT_TITANIUM=2000, MAT_PLASMA=2000)
point_value = 45
var/global/list/datum/stack_recipe/plastitanium_recipes = list (
new/datum/stack_recipe("plas-titanium tile", /obj/item/stack/tile/mineral/plastitanium, 1, 4, 20),
@@ -105,6 +105,7 @@ var/global/list/datum/stack_recipe/metal_recipes = list(
flags = CONDUCT
origin_tech = "materials=1"
merge_type = /obj/item/stack/sheet/metal
point_value = 2
/obj/item/stack/sheet/metal/cyborg
materials = list()
@@ -151,6 +152,7 @@ var/global/list/datum/stack_recipe/plasteel_recipes = list(
flags = CONDUCT
origin_tech = "materials=2"
merge_type = /obj/item/stack/sheet/plasteel
point_value = 23
/obj/item/stack/sheet/plasteel/New(var/loc, var/amount=null)
recipes = plasteel_recipes
@@ -9,22 +9,10 @@
attack_verb = list("bashed", "battered", "bludgeoned", "thrashed", "smashed")
var/perunit = MINERAL_MATERIAL_AMOUNT
var/sheettype = null //this is used for girders in the creation of walls/false walls
var/point_value = 0 //turn-in value for the gulag stacker - loosely relative to its rarity.
var/created_window = null //apparently glass sheets don't share a base type for glass specifically, so each had to define these vars individually
var/full_window = null //moving the var declaration to here so this can be checked cleaner until someone is willing to make them share a base type properly
usesound = 'sound/items/deconstruct.ogg'
toolspeed = 1
var/wall_allowed = TRUE //determines if sheet can be used in wall construction or not.
// Since the sheetsnatcher was consolidated into weapon/storage/bag we now use
// item/attackby() properly, making this unnecessary
/*/obj/item/stack/sheet/attackby(obj/item/W as obj, mob/user as mob, params)
if(istype(W, /obj/item/storage/bag/sheetsnatcher))
var/obj/item/storage/bag/sheetsnatcher/S = W
if(!S.mode)
S.add(src,user)
else
for(var/obj/item/stack/sheet/stack in locate(src.x,src.y,src.z))
S.add(stack,user)
..()*/
+133 -129
View File
@@ -1,3 +1,5 @@
GLOBAL_LIST(labor_sheet_values)
/**********************Prisoners' Console**************************/
/obj/machinery/mineral/labor_claim_console
@@ -5,153 +7,153 @@
desc = "A stacking console with an electromagnetic writer, used to track ore mined by prisoners."
icon = 'icons/obj/machines/mining_machines.dmi'
icon_state = "console"
density = 0
anchored = 1
var/obj/machinery/mineral/stacking_machine/laborstacker/machine = null
density = FALSE
var/obj/machinery/mineral/stacking_machine/laborstacker/stacking_machine = null
var/machinedir = SOUTH
var/obj/item/card/id/prisoner/inserted_id
var/obj/machinery/door/airlock/release_door
var/door_tag = "prisonshuttle"
var/use_release_door = 0
var/obj/item/radio/intercom/announcer
/obj/machinery/mineral/labor_claim_console/New()
..()
/obj/machinery/mineral/labor_claim_console/Initialize()
. = ..()
announcer = new /obj/item/radio/intercom(null)
announcer.config(list("Security" = 0))
locate_stacking_machine()
spawn(7)
src.machine = locate(/obj/machinery/mineral/stacking_machine, get_step(src, machinedir))
var/t
for(var/obj/machinery/door/airlock/d in range(5,src))
t = d.id_tag
if(t == src.door_tag)
src.release_door = d
if(machine && (release_door || !use_release_door))
machine.CONSOLE = src
if(!GLOB.labor_sheet_values)
var/sheet_list = list()
for(var/sheet_type in subtypesof(/obj/item/stack/sheet))
var/obj/item/stack/sheet/sheet = sheet_type
if(!initial(sheet.point_value) || (initial(sheet.merge_type) && initial(sheet.merge_type) != sheet_type)) //ignore no-value sheets and x/fifty subtypes
continue
sheet_list += list(list("ore" = initial(sheet.name), "value" = initial(sheet.point_value)))
GLOB.labor_sheet_values = sheet_list
/obj/machinery/mineral/labor_claim_console/Destroy()
. = ..()
QDEL_NULL(announcer)
/proc/cmp_sheet_list(list/a, list/b)
return a["value"] - b["value"]
/obj/machinery/mineral/labor_claim_console/attackby(obj/item/I, mob/user, params)
if(istype(I, /obj/item/card/id/prisoner))
if(!inserted_id)
if(!user.unEquip(I))
return
I.forceMove(src)
inserted_id = I
to_chat(user, "<span class='notice'>You insert [I].</span>")
SSnanoui.update_uis(src)
return
else
qdel(src)
to_chat(user, "<span class='notice'>There's an ID inserted already.</span>")
return ..()
/obj/machinery/mineral/labor_claim_console/attack_hand(mob/user)
ui_interact(user)
/obj/machinery/mineral/labor_claim_console/attack_ghost(mob/user)
attack_hand(user)
/obj/machinery/mineral/labor_claim_console/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "labor_claim_console.tmpl", name, 450, 625, state)
ui.open()
/obj/machinery/mineral/labor_claim_console/ui_data(mob/user)
var/list/data = list()
var/can_go_home = FALSE
data["emagged"] = (emagged) ? TRUE : FALSE
if(inserted_id)
data["id"] = inserted_id
data["id_name"] = inserted_id.registered_name
data["points"] = inserted_id.points
data["goal"] = inserted_id.goal
if(check_auth())
can_go_home = TRUE
if(stacking_machine)
data["unclaimed_points"] = stacking_machine.points
data["ores"] = GLOB.labor_sheet_values
data["can_go_home"] = can_go_home
return data
/obj/machinery/mineral/labor_claim_console/Topic(href, href_list)
if(..())
return TRUE
if(href_list["handle_id"])
if(inserted_id)
if(!usr.put_in_hands(inserted_id))
inserted_id.forceMove(get_turf(src))
inserted_id = null
else
var/obj/item/I = usr.get_active_hand()
if(istype(I, /obj/item/card/id/prisoner))
if(!usr.unEquip(I))
return
I.forceMove(src)
inserted_id = I
if(href_list["claim_points"])
inserted_id.points += stacking_machine.points
stacking_machine.points = 0
to_chat(usr, "Points transferred.")
if(href_list["move_shuttle"])
if(!alone_in_area(get_area(src), usr))
to_chat(usr, "<span class='warning'>Prisoners are only allowed to be released while alone.</span>")
else
switch(SSshuttle.moveShuttle("laborcamp", "laborcamp_home", TRUE))
if(1)
to_chat(usr, "<span class='notice'>Shuttle not found.</span>")
if(2)
to_chat(usr, "<span class='notice'>Shuttle already at station.</span>")
if(3)
to_chat(usr, "<span class='notice'>No permission to dock could be granted.</span>")
else
if(!(emagged))
var/message = "[inserted_id.registered_name] has returned to the station. Minerals and Prisoner ID card ready for retrieval."
announcer.autosay(message, "Labor Camp Controller", "Security")
to_chat(usr, "<span class='notice'>Shuttle received message and will be sent shortly.</span>")
return TRUE
/obj/machinery/mineral/labor_claim_console/proc/check_auth()
if(emagged) return 1 //Shuttle is emagged, let any ol' person through
if(emagged)
return TRUE //Shuttle is emagged, let any ol' person through
return (istype(inserted_id) && inserted_id.points >= inserted_id.goal) //Otherwise, only let them out if the prisoner's reached his quota.
/obj/machinery/mineral/labor_claim_console/proc/locate_stacking_machine()
stacking_machine = locate(/obj/machinery/mineral/stacking_machine, get_step(src, machinedir))
if(stacking_machine)
stacking_machine.CONSOLE = src
else
qdel(src)
/obj/machinery/mineral/labor_claim_console/attack_hand(user as mob)
var/dat
dat += text("<b>Point Claim Console</b><br><br>")
if(emagged) //Shit's broken
dat += text("<b>QU&#t0A In%aL*D</b><br>")
else if(istype(inserted_id)) //There's an ID in there.
dat += text("ID: [inserted_id.registered_name] <A href='?src=[UID()];choice=eject'>Eject ID.</A><br>")
dat += text("Points Collected:[inserted_id.points]<br>")
dat += text("Point Quota: [inserted_id.goal] - Reach your quota to earn your release<br>")
dat += text("Unclaimed Collection Points: [machine.points]. <A href='?src=[UID()];choice=claim'>Claim points.</A><br>")
else //No ID in sight. Complain about it.
dat += text("No ID inserted. <A href='?src=[UID()];choice=insert'>Insert ID.</A><br>")
if(check_auth())
dat += text("<A href='?src=[UID()];choice=station'>Proceed to station.</A><br>")
if(use_release_door)
dat += text("<A href='?src=[UID()];choice=release'>Open release door.</A><br>")
if(machine)
dat += text("<HR><b>Mineral Value List:</b><BR>[machine.get_ore_values()]")
user << browse("[dat]", "window=console_stacking_machine")
/obj/machinery/mineral/labor_claim_console/attackby(obj/item/I as obj, mob/user as mob, params)
if(istype(I, /obj/item/card/id))
return attack_hand(user)
..()
/obj/machinery/mineral/labor_claim_console/emag_act(user as mob)
emag(user)
/obj/machinery/mineral/labor_claim_console/proc/emag(mob/user as mob)
if(!emagged)
emagged = 1
/obj/machinery/mineral/labor_claim_console/emag_act(mob/user)
if(!(emagged))
emagged = TRUE
to_chat(user, "<span class='warning'>PZZTTPFFFT</span>")
/obj/machinery/mineral/labor_claim_console/Topic(href, href_list)
usr.set_machine(src)
src.add_fingerprint(usr)
if(href_list["choice"])
if(istype(inserted_id)) //Sanity check against href spoofs
if(href_list["choice"] == "eject")
inserted_id.loc = loc
inserted_id.verb_pickup()
inserted_id = null
if(href_list["choice"] == "claim")
inserted_id.points += machine.points
machine.points = 0
to_chat(src, "Points transferred.")
else if(href_list["choice"] == "insert")
var/obj/item/card/id/prisoner/I = usr.get_active_hand()
if(istype(I))
usr.drop_item()
I.loc = src
inserted_id = I
else
to_chat(usr, "<span class='warning'>Invalid ID.</span>")
if(check_auth()) //Sanity check against hef spoofs
if(href_list["choice"] == "station")
if(!alone_in_area(get_area(src), usr))
to_chat(usr, "<span class='warning'>Prisoners are only allowed to be released while alone.</span>")
else
switch(SSshuttle.moveShuttle("laborcamp","laborcamp_home"))
if(1)
to_chat(usr, "<span class='notice'>Shuttle not found</span>")
if(2)
to_chat(usr, "<span class='notice'>Shuttle already at station</span>")
if(3)
to_chat(usr, "<span class='notice'>No permission to dock could be granted.</span>")
else
var/message = "[inserted_id.registered_name] has returned to the station. Minerals and Prisoner ID card ready for retrieval."
announcer.autosay(message, "Labor Camp Controller", "Security")
to_chat(usr, "<span class='notice'>Shuttle received message and will be sent shortly.</span>")
if(href_list["choice"] == "release")
if(alone_in_area(get_area(loc), usr))
var/obj/docking_port/stationary/S = SSshuttle.getDock("laborcamp_home")
if(S && S.get_docked())
if(release_door && release_door.density)
release_door.open()
else
to_chat(usr, "<span class='warning'>Prisoners can only be released while docked with the station.</span>")
else
to_chat(usr, "<span class='warning'>Prisoners are only allowed to be released while alone.</span>")
src.updateUsrDialog()
return
/**********************Prisoner Collection Unit**************************/
/obj/machinery/mineral/stacking_machine/laborstacker
var/points = 0 //The unclaimed value of ore stacked. Value for each ore loosely relative to its rarity.
var/list/ore_values = list(("glass" = 1), ("metal" = 2), ("solid plasma" = 20), ("plasteel" = 23), ("reinforced glass" = 4), ("gold" = 20), ("silver" = 20), ("uranium" = 20), ("diamond" = 25), ("bananium" = 50), ("tranquillite" = 50))
/obj/machinery/mineral/stacking_machine/laborstacker/proc/get_ore_values()
var/dat = "<table border='0' width='200'>"
for(var/ore in ore_values)
var/value = ore_values[ore]
dat += "<tr><td>[capitalize(ore)]</td><td>[value]</td></tr>"
dat += "</table>"
return dat
var/points = 0 //The unclaimed value of ore stacked.
/obj/machinery/mineral/stacking_machine/laborstacker/process_sheet(obj/item/stack/sheet/inp)
if(istype(inp))
var/n = inp.name
var/a = inp.amount
if(n in ore_values)
points += ore_values[n] * a
points += inp.point_value * inp.amount
..()
/obj/machinery/mineral/stacking_machine/laborstacker/attackby(obj/item/I, mob/living/user)
if(istype(I, /obj/item/stack/sheet) && user.canUnEquip(I))
var/obj/item/stack/sheet/inp = I
points += inp.point_value * inp.amount
return ..()
/**********************Point Lookup Console**************************/
/obj/machinery/mineral/labor_points_checker
@@ -159,13 +161,15 @@
desc = "A console used by prisoners to check the progress on their quotas. Simply swipe a prisoner ID."
icon = 'icons/obj/machines/mining_machines.dmi'
icon_state = "console"
density = 0
anchored = 1
density = FALSE
/obj/machinery/mineral/labor_points_checker/attack_hand(mob/user)
user.examine(src)
. = ..()
if(.)
return
user.examinate(src)
/obj/machinery/mineral/labor_points_checker/attackby(obj/item/I as obj, mob/user as mob, params)
/obj/machinery/mineral/labor_points_checker/attackby(obj/item/I, mob/user, params)
if(istype(I, /obj/item/card/id))
if(istype(I, /obj/item/card/id/prisoner))
var/obj/item/card/id/prisoner/prisoner_id = I
@@ -175,5 +179,5 @@
to_chat(user, "<span class='notice'>Collect points by bringing smelted minerals to the Labor Shuttle stacking machine. Reach your quota to earn your release.</span>")
else
to_chat(user, "<span class='warning'>Error: Invalid ID</span>")
return
..()
else
return ..()
+1
View File
@@ -66,6 +66,7 @@ var/global/list/datum/stack_recipe/bluespace_crystal_recipes = list(new/datum/st
attack_verb = list("bluespace polybashed", "bluespace polybattered", "bluespace polybludgeoned", "bluespace polythrashed", "bluespace polysmashed")
toolspeed = 1
usesound = 'sound/items/deconstruct.ogg'
point_value = 30
/obj/item/stack/sheet/bluespace_crystal/New()
..()
+76
View File
@@ -0,0 +1,76 @@
<!--
Title: Point Claim Console
Used In File(s): \code\modules\mining\laborcamp\laborstacker.dm
-->
<style>
.statusLabel {
width: 200px;
}
.pointsValue {
float: left;
margin-right: 10px;
}
.centerButton {
float: none;
}
</style>
<h1>Ore values</h1>
<div class='statusDisplay'>
{{for data.ores}}
<div class="line">
<div class='statusLabel'>
{{:value.ore}}:
</div>
<div class='statusValue'>
{{:value.value}}
</div>
</div>
{{/for}}
</div>
<h1>Points</h1>
<div class='statusDisplay'>
<div class="line">
<div class='statusLabel'>
ID:
</div>
<div class='statusValue'>
{{:helper.link(data.id ? data.id_name : '-------------', null, { 'handle_id' : 1 })}}
</div>
</div>
{{if data.id}}
<div class="line">
<div class='statusLabel'>
Points collected:
</div>
<div class='statusValue'>
{{:data.points}}
</div>
</div>
<div class="line">
<div class='statusLabel'>
Goal:
</div>
<div class='statusValue'>
{{:data.goal}}
</div>
</div>
<div class="line">
<div class='statusLabel'>
Unclaimed points:
</div>
<div class='statusValue'>
<div class="pointsValue">{{:data.unclaimed_points}}</div>
{{:helper.link('Claim points', null, { 'claim_points' : 1 }, data.unclaimed_points ? null : 'disabled')}}
</div>
</div>
{{/if}}
</div>
<div class='statusDisplay'>
{{:helper.link('Move shuttle', null, { 'move_shuttle' : 1 }, data.can_go_home ? null : 'disabled', 'link centerButton')}}
</div>