Uplink item buy limit mechanism (#14999)

This commit is contained in:
DreamySkrell
2022-11-12 23:08:54 +01:00
committed by GitHub
parent 56515acc8b
commit ecb5a8e769
7 changed files with 49 additions and 6 deletions
+3 -1
View File
@@ -70,8 +70,10 @@
/datum/uplink_item/item/tools/personal_shield
name = "Personal Shield"
desc = "A personal shield that, when kept in your hand and activated, will protect its user from five projectile shots."
desc = "A personal shield that, when kept in your hand and activated, will protect its user from five projectile shots. \
This can only be bought once."
item_cost = 1
item_limit = 1
path = /obj/item/device/personal_shield
/datum/uplink_item/item/tools/hacking_tool
+1 -1
View File
@@ -29,7 +29,7 @@
/datum/uplink_item/item/implants/imp_uplink
name = "Uplink Implant"
path = /obj/item/storage/box/syndie_kit/imp_uplink
path = /obj/item/implanter/uplink
/datum/uplink_item/item/implants/imp_uplink/New()
..()
+7
View File
@@ -61,6 +61,13 @@
item_cost = 1
path = /obj/item/storage/firstaid/regular
/datum/uplink_item/item/medical/firstaid
name = "Standard First-Aid Kit (Free)"
item_cost = 0
item_limit = 1
path = /obj/item/storage/firstaid/regular
desc = "You can claim this first-aid kit only once."
/datum/uplink_item/item/medical/advfirstaid
name = "Advanced First-Aid Kit"
item_cost = 1
+15
View File
@@ -29,6 +29,7 @@ var/datum/uplink/uplink
var/name
var/desc
var/item_cost = 0
var/item_limit = 999 // how many times can this item be bought from a uplink (high limit is not shown in the uplink gui)
var/datum/uplink_category/category // Item category
var/list/datum/antagonist/antag_roles // Antag roles this item is displayed to. If empty, display to all.
var/list/datum/antagonist/antag_job // Antag job this item is displayed to, if empty, display to all.
@@ -53,6 +54,14 @@ var/datum/uplink/uplink
if(!goods)
return
var/obj/item/implanter/implanter = goods
if(istype(implanter))
var/obj/item/implant/uplink/uplink_implant = implanter.imp
if(istype(uplink_implant))
var/obj/item/device/uplink/hidden/hidden_uplink = uplink_implant.hidden_uplink
if(istype(hidden_uplink))
hidden_uplink.purchase_log = U.purchase_log
purchase_log(U)
U.uses -= cost
U.used_TC += cost
@@ -66,8 +75,14 @@ var/datum/uplink/uplink
if(cost(U.uses) > U.uses)
return 0
if(items_left(U) <= 0)
return 0
return can_view(U)
/datum/uplink_item/proc/items_left(obj/item/device/uplink/U)
return item_limit - U.purchase_log[src]
/datum/uplink_item/proc/can_view(obj/item/device/uplink/U)
// Making the assumption that if no uplink was supplied, then we don't care about antag roles
if(!U || (!length(antag_roles) && !antag_job))