Rewrite supply packs/cargo orders

This commit is contained in:
Bjorn Neergaard
2016-02-07 04:45:55 -06:00
parent ddab6823d3
commit 4ef2667ff2
17 changed files with 1997 additions and 818 deletions
+33 -41
View File
@@ -59,31 +59,23 @@
if(!SSshuttle.shoppinglist.len)
return
var/list/emptyTurfs = list()
var/list/empty_turfs = list()
for(var/turf/simulated/floor/T in areaInstance)
if(T.density || T.contents.len)
continue
emptyTurfs += T
empty_turfs += T
for(var/datum/supply_order/SO in SSshuttle.shoppinglist)
if(!SO.object)
if(!empty_turfs.len)
continue
if(SO.object.cost > SSshuttle.points)
if(SO.pack.cost > SSshuttle.points)
continue
var/errors = 0
if(prob(5))
errors |= MANIFEST_ERROR_COUNT
if(prob(5))
errors |= MANIFEST_ERROR_NAME
if(prob(5))
errors |= MANIFEST_ERROR_ITEM
var/turf/T = pick_n_take(emptyTurfs)
SO.createObject(T, errors)
SSshuttle.points -= SO.object.cost
SSshuttle.points -= SO.pack.cost
SSshuttle.shoppinglist -= SO
SSshuttle.orderhistory += SO
SO.generate(pick_n_take(empty_turfs))
/obj/docking_port/mobile/supply/proc/sell()
var/crates = 0
@@ -104,48 +96,48 @@
if(!AM.contents.len)
SSshuttle.sold_atoms += " (empty)"
else
var/slip_found = FALSE
var/manifest_found = FALSE
for(var/atom/movable/thing in AM)
SSshuttle.sold_atoms += " [thing.name]"
if(!slip_found && istype(thing, /obj/item/weapon/paper/manifest))
var/obj/item/weapon/paper/manifest/slip = thing
if(slip.stamped && slip.stamped.len)
slip_found = TRUE
if(!manifest_found && istype(thing, /obj/item/weapon/paper/manifest))
var/obj/item/weapon/paper/manifest/manifest = thing
if(manifest.stamped && manifest.stamped.len)
manifest_found = TRUE
var/denied = FALSE
for(var/stamp in slip.stamped)
for(var/stamp in manifest.stamped)
if(stamp == /obj/item/weapon/stamp/denied)
denied = TRUE
break
if(slip.erroneous && denied) // Caught a mistake by Centcom.
pointsEarned = slip.points - SSshuttle.points_per_crate
if(manifest.errors && denied) // Caught a mistake by Centcom.
pointsEarned = manifest.order_cost - SSshuttle.points_per_crate
SSshuttle.points += pointsEarned // Give a full refund (minus the crate).
msg += "[pointsEarned]: Station correctly denied package [slip.ordernumber]: "
if(slip.erroneous & MANIFEST_ERROR_NAME)
msg += "+[pointsEarned]: Station correctly denied package #[manifest.order_id]: "
if(manifest.errors & MANIFEST_ERROR_NAME)
msg += "Destination station incorrect. "
else if(slip.erroneous & MANIFEST_ERROR_COUNT)
msg += "Packages incorrectly counted. "
else if(slip.erroneous & MANIFEST_ERROR_ITEM)
else if(manifest.errors & MANIFEST_ERROR_CONTENTS)
msg += "Contents incorrectly counted. "
else if(manifest.errors & MANIFEST_ERROR_ITEM)
msg += "Package incomplete. "
msg += "Points refunded."
else if(!slip.erroneous && !denied) // Approved a slip correctly.
pointsEarned = SSshuttle.points_per_slip
else if(!manifest.errors && !denied) // Approved a manifest correctly.
pointsEarned = SSshuttle.points_per_manifest
SSshuttle.points += pointsEarned
msg += "+[pointsEarned]: Package [slip.ordernumber] accorded."
else if(slip.erroneous) // You done goofed.
pointsEarned = -SSshuttle.points_per_slip
msg += "+[pointsEarned]: Package [manifest.order_id] accorded."
else if(manifest.errors) // You done goofed.
pointsEarned = -SSshuttle.points_per_manifest
SSshuttle.points += pointsEarned
msg += "[pointsEarned]: Station erroneously approved package [slip.ordernumber]: "
if(slip.erroneous & MANIFEST_ERROR_NAME)
msg += "[pointsEarned]: Station erroneously approved package #[manifest.order_id]: "
if(manifest.errors & MANIFEST_ERROR_NAME)
msg += "Destination station incorrect."
else if(slip.erroneous & MANIFEST_ERROR_COUNT)
msg += "Packages incorrectly counted."
else if(slip.erroneous & MANIFEST_ERROR_ITEM)
else if(manifest.errors & MANIFEST_ERROR_CONTENTS)
msg += "Contents incorrectly counted. "
else if(manifest.errors & MANIFEST_ERROR_ITEM)
msg += "We found unshipped items on our dock."
msg += " Be more vigilant."
else
pointsEarned = round(SSshuttle.points_per_crate - slip.points)
pointsEarned = round(SSshuttle.points_per_crate - manifest.order_cost)
SSshuttle.points += pointsEarned
msg += "[pointsEarned]: Station erroneously denied package [slip.ordernumber]."
msg += "[pointsEarned]: Station errorsly denied package #[manifest.order_id]."
// Sell plasma
if(istype(thing, /obj/item/stack/sheet/mineral/plasma))