Merge pull request #9061 from Anasari/TGRefundPort

Port over Fox's refactored syndicate item refund from TG.
This commit is contained in:
Crazy Lemon
2018-08-22 22:51:12 -07:00
committed by GitHub
6 changed files with 51 additions and 36 deletions
+25 -17
View File
@@ -12,7 +12,7 @@ var/list/world_uplinks = list()
var/welcome // Welcoming menu message
var/uses // Numbers of crystals
var/hidden_crystals = 0
var/list/ItemsCategory // List of categories with lists of items
var/list/uplink_items // List of categories with lists of items
var/list/ItemsReference // List of references with an associated item
var/list/nanoui_items // List of items for NanoUI use
var/nanoui_menu = 0 // The current menu we are in
@@ -32,7 +32,7 @@ var/list/world_uplinks = list()
..()
welcome = ticker.mode.uplink_welcome
uses = ticker.mode.uplink_uses
ItemsCategory = get_uplink_items()
uplink_items = get_uplink_items()
world_uplinks += src
@@ -57,14 +57,14 @@ var/list/world_uplinks = list()
dat += "<I>Each item costs a number of telecrystals as indicated by the number following its name.</I><br>"
var/category_items = 1
for(var/category in ItemsCategory)
for(var/category in uplink_items)
if(category_items < 1)
dat += "<i>We apologize, as you could not afford anything from this category.</i><br>"
dat += "<br>"
dat += "<b>[category]</b><br>"
category_items = 0
for(var/datum/uplink_item/I in ItemsCategory[category])
for(var/datum/uplink_item/I in uplink_items[category])
if(I.cost > uses)
continue
if(I.job && I.job.len)
@@ -87,9 +87,9 @@ var/list/world_uplinks = list()
var/list/nano = new
var/list/reference = new
for(var/category in ItemsCategory)
for(var/category in uplink_items)
nano[++nano.len] = list("Category" = category, "items" = list())
for(var/datum/uplink_item/I in ItemsCategory[category])
for(var/datum/uplink_item/I in uplink_items[category])
if(I.job && I.job.len)
if(!(I.job.Find(job)))
continue
@@ -117,6 +117,9 @@ var/list/world_uplinks = list()
if(..())
return 1
if(href_list["refund"])
refund(usr)
if(href_list["buy_item"] == "random")
var/datum/uplink_item/UI = chooseRandomItem()
href_list["buy_item"] = UI.reference
@@ -142,6 +145,22 @@ var/list/world_uplinks = list()
return 1
/obj/item/uplink/proc/refund(mob/user as mob)
var/obj/item/I = user.get_active_hand()
if(I) // Make sure there's actually something in the hand before even bothering to check
for(var/category in uplink_items)
for(var/item in uplink_items[category])
var/datum/uplink_item/UI = item
var/path = UI.refund_path || UI.item
var/cost = UI.refund_amount || UI.cost
if(I.type == path && UI.refundable && I.check_uplink_validity())
uses += cost
used_TC -= cost
to_chat(user, "<span class='notice'>[I] refunded.</span>")
qdel(I)
return
..()
// HIDDEN UPLINK - Can be stored in anything but the host item has to have a trigger for it.
/* How to create an uplink in 3 easy steps!
@@ -287,17 +306,6 @@ var/list/world_uplinks = list()
return 1
return 0
//Refund proc for the borg teleporter (later I'll make a general refund proc if there is demand for it)
/obj/item/radio/uplink/attackby(obj/item/W as obj, mob/user as mob, params)
if(istype(W, /obj/item/antag_spawner/borg_tele))
var/obj/item/antag_spawner/borg_tele/S = W
if(!S.used && !S.checking)
hidden_uplink.uses += S.TC_cost
qdel(S)
to_chat(user, "<span class='notice'>Teleporter refunded.</span>")
else
to_chat(user, "<span class='notice'>This teleporter is already used, or is currently being used.</span>")
// PRESET UPLINKS
// A collection of preset uplinks.
//
+3
View File
@@ -303,3 +303,6 @@ a {
.["Make speed process"] = "?_src_=vars;makespeedy=[UID()]"
else
.["Make normal process"] = "?_src_=vars;makenormalspeed=[UID()]"
/obj/proc/check_uplink_validity()
return 1