diff --git a/code/__defines/supply.dm b/code/__defines/supply.dm new file mode 100644 index 00000000000..81b32d703d0 --- /dev/null +++ b/code/__defines/supply.dm @@ -0,0 +1,19 @@ +// Supply shuttle status defines +#define SUP_SHUTTLE_ERROR -1 // Error state +#define SUP_SHUTTLE_DOCKED 0 +#define SUP_SHUTTLE_UNDOCKED 1 +#define SUP_SHUTTLE_DOCKING 2 +#define SUP_SHUTTLE_UNDOCKING 3 +#define SUP_SHUTTLE_TRANSIT 4 +#define SUP_SHUTTLE_AWAY 5 + +// Supply computer access levels +#define SUP_SEND_SHUTTLE 0x1 // Send the shuttle back and forth +#define SUP_ACCEPT_ORDERS 0x2 // Accept orders +#define SUP_CONTRABAND 0x4 // Able to order contraband supply packs + +// Supply_order status values +#define SUP_ORDER_REQUESTED "Requested" +#define SUP_ORDER_APPROVED "Approved" +#define SUP_ORDER_DENIED "Denied" +#define SUP_ORDER_SHIPPED "Shipped" \ No newline at end of file diff --git a/code/controllers/Processes/supply.dm b/code/controllers/Processes/supply.dm index 5b3e4f6f2b1..139f0923d15 100644 --- a/code/controllers/Processes/supply.dm +++ b/code/controllers/Processes/supply.dm @@ -8,15 +8,22 @@ //Computers are in /code/game/machinery/computer/supply.dm /datum/supply_order - var/ordernum - var/datum/supply_packs/object = null - var/orderedby = null - var/comment = null + var/ordernum // Unfabricatable index + var/index // Fabricatable index + var/datum/supply_pack/object = null + var/cost // Cost of the supply pack (Fabricatable) (Changes not reflected when purchasing supply packs, this is cosmetic only) + var/name // Name of the supply pack datum (Fabricatable) + var/ordered_by = null // Who requested the order + var/comment = null // What reason was given for the order + var/approved_by = null // Who approved the order + var/ordered_at // Date and time the order was requested at + var/approved_at // Date and time the order was approved at + var/status // [Requested, Accepted, Denied, Shipped] /datum/exported_crate var/name var/value - + var/list/contents var/datum/controller/supply/supply_controller = new() @@ -25,25 +32,30 @@ var/datum/controller/supply/supply_controller = new() var/points = 50 var/points_per_process = 1.5 var/points_per_slip = 2 - var/points_per_platinum = 5 // 5 points per sheet - var/points_per_phoron = 5 var/points_per_money = 0.02 // 1 point for $50 //control var/ordernum - var/list/shoppinglist = list() - var/list/requestlist = list() - var/list/supply_packs = list() - var/list/exported_crates = list() + var/list/shoppinglist = list() // Approved orders + var/list/supply_pack = list() // All supply packs + var/list/exported_crates = list() // Crates sent from the station + var/list/order_history = list() // History of orders, showing edits made by users + var/list/adm_order_history = list() // Complete history of all orders, for admin use + var/list/adm_export_history = list() // Complete history of all crates sent back on the shuttle, for admin use //shuttle movement var/movetime = 1200 var/datum/shuttle/ferry/supply/shuttle + var/list/material_points_conversion = list( // Any materials not named in this list are worth 0 points + "phoron" = 5, + "platinum" = 5 + ) + /datum/controller/supply/New() ordernum = rand(1,9000) - for(var/typepath in (typesof(/datum/supply_packs) - /datum/supply_packs)) - var/datum/supply_packs/P = new typepath() - supply_packs[P.name] = P + for(var/typepath in subtypesof(/datum/supply_pack)) + var/datum/supply_pack/P = new typepath() + supply_pack[P.name] = P /datum/controller/process/supply/setup() name = "supply controller" @@ -80,23 +92,17 @@ var/datum/controller/supply/supply_controller = new() callHook("sell_shuttle", list(area_shuttle)); - var/phoron_count = 0 - var/plat_count = 0 - var/money_count = 0 - - exported_crates = list() - for(var/atom/movable/MA in area_shuttle) if(MA.anchored) continue + var/datum/exported_crate/EC = new /datum/exported_crate() + EC.name = "\proper[MA.name]" + EC.value = 0 + EC.contents = list() + // Must be in a crate! if(istype(MA,/obj/structure/closet/crate)) - var/oldpoints = points - var/oldphoron = phoron_count - var/oldplatinum = plat_count - var/oldmoney = money_count - var/obj/structure/closet/crate/CR = MA callHook("sell_crate", list(CR, area_shuttle)) @@ -104,44 +110,64 @@ var/datum/controller/supply/supply_controller = new() var/find_slip = 1 for(var/atom/A in CR) + EC.contents[++EC.contents.len] = list( + "object" = "\proper[A.name]", + "value" = 0, + "quantity" = 1 + ) + // Sell manifests if(find_slip && istype(A,/obj/item/weapon/paper/manifest)) var/obj/item/weapon/paper/manifest/slip = A if(!slip.is_copy && slip.stamped && slip.stamped.len) //yes, the clown stamp will work. clown is the highest authority on the station, it makes sense points += points_per_slip + EC.contents[EC.contents.len]["value"] = points_per_slip find_slip = 0 continue // Sell phoron and platinum if(istype(A, /obj/item/stack)) var/obj/item/stack/P = A - switch(P.get_material_name()) - if("phoron") - phoron_count += P.get_amount() - if("platinum") - plat_count += P.get_amount() + if(material_points_conversion[P.get_material_name()]) + EC.contents[EC.contents.len]["value"] = P.get_amount() * material_points_conversion[P.get_material_name()] + EC.contents[EC.contents.len]["quantity"] = P.get_amount() + EC.value += EC.contents[EC.contents.len]["value"] + //Sell spacebucks if(istype(A, /obj/item/weapon/spacecash)) var/obj/item/weapon/spacecash/cashmoney = A - money_count += cashmoney.worth + EC.contents[EC.contents.len]["value"] = cashmoney.worth * points_per_money + EC.contents[EC.contents.len]["quantity"] = cashmoney.worth + EC.value += EC.contents[EC.contents.len]["value"] - var/datum/exported_crate/EC = new /datum/exported_crate() - EC.name = CR.name - EC.value = points - oldpoints - EC.value += (phoron_count - oldphoron) * points_per_phoron - EC.value += (plat_count - oldplatinum) * points_per_platinum - EC.value += (money_count - oldmoney) * points_per_money - exported_crates += EC + + + // Make a log of it, but it wasn't shipped properly, and so isn't worth anything + else + EC.contents = list( + "error" = "Error: Product was improperly packaged. Payment rendered null under terms of agreement." + ) + + exported_crates += EC + points += EC.value + + // Duplicate the receipt for the admin-side log + var/datum/exported_crate/adm = new() + adm.name = EC.name + adm.value = EC.value + adm.contents = deepCopyList(EC.contents) + adm_export_history += adm qdel(MA) - points += phoron_count * points_per_phoron - points += plat_count * points_per_platinum - points += money_count * points_per_money - //Buying /datum/controller/supply/proc/buy() + var/list/shoppinglist = list() + for(var/datum/supply_order/SO in order_history) + if(SO.status == SUP_ORDER_APPROVED) + shoppinglist += SO + if(!shoppinglist.len) return @@ -165,17 +191,16 @@ var/datum/controller/supply/supply_controller = new() continue clear_turfs += T - for(var/S in shoppinglist) + for(var/datum/supply_order/SO in shoppinglist) if(!clear_turfs.len) break var/i = rand(1,clear_turfs.len) var/turf/pickedloc = clear_turfs[i] clear_turfs.Cut(i,i+1) - shoppinglist -= S - var/datum/supply_order/SO = S - var/datum/supply_packs/SP = SO.object + SO.status = SUP_ORDER_SHIPPED + var/datum/supply_pack/SP = SO.object var/obj/A = new SP.containertype(pickedloc) A.name = "[SP.containername] [SO.comment ? "([SO.comment])":"" ]" @@ -202,8 +227,8 @@ var/datum/controller/supply/supply_controller = new() log_debug("Supply pack with invalid access restriction [SP.access] encountered!") var/list/contains - if(istype(SP,/datum/supply_packs/randomised)) - var/datum/supply_packs/randomised/SPR = SP + if(istype(SP,/datum/supply_pack/randomised)) + var/datum/supply_pack/randomised/SPR = SP contains = list() if(SPR.contains.len) for(var/j=1,j<=SPR.num_contained,j++) @@ -227,3 +252,141 @@ var/datum/controller/supply/supply_controller = new() slip.info += "CHECK CONTENTS AND STAMP BELOW THE LINE TO CONFIRM RECEIPT OF GOODS