Merge pull request #8839 from Spookerton/spkrtn/fix/no-infinite-tc

correct uplink item cost behavior
This commit is contained in:
Atermonera
2022-11-20 13:35:00 -08:00
committed by GitHub
5 changed files with 18 additions and 17 deletions
+4 -7
View File
@@ -32,13 +32,10 @@
name = "Random Items"
desc = "Buys you as many random items you can afford. Convenient packaging NOT included."
/datum/uplink_item/item/badassery/random_many/cost(obj/item/uplink/U, mob/M)
if(istype(M))
return max(1, M.mind?.tcrystals)
if(istype(M, /datum/mind))
var/datum/mind/m = M
return max(1, m.tcrystals)
return max(1, M)
/datum/uplink_item/item/badassery/random_many/cost(obj/item/uplink/U, available_telecrystals)
return max(1, available_telecrystals)
/datum/uplink_item/item/badassery/random_many/get_goods(var/obj/item/uplink/U, var/loc, var/mob/M)
var/list/bought_items = list()
+2 -2
View File
@@ -35,5 +35,5 @@
/datum/uplink_item/item/telecrystal/all
name = "Telecrystals - Empty Uplink"
/datum/uplink_item/item/telecrystal/all/cost(obj/item/uplink/U, mob/M)
return max(1, M.mind.tcrystals)
/datum/uplink_item/item/telecrystal/all/cost(obj/item/uplink/uplink, available_telecrystals)
return max(1, available_telecrystals)
+4 -4
View File
@@ -75,10 +75,10 @@ var/global/datum/uplink/uplink = new()
return TRUE
/datum/uplink_item/proc/cost(obj/item/uplink/U, mob/M)
. = item_cost
if(U)
. = U.get_item_cost(src, .)
/datum/uplink_item/proc/cost(obj/item/uplink/uplink, available_telecrystals)
if (uplink)
return uplink.GetAdjustedCost(src, item_cost)
return item_cost
/datum/uplink_item/proc/description()
return desc
+7 -3
View File
@@ -27,8 +27,12 @@
. = ..()
addtimer(CALLBACK(src, .proc/next_offer), offer_time) //It seems like only the /hidden type actually makes use of this...
/obj/item/uplink/get_item_cost(var/item_type, var/item_cost)
return (discount_item && (item_type == discount_item)) ? max(1, round(item_cost*discount_amount)) : item_cost
/obj/item/uplink/proc/GetAdjustedCost(datum/uplink_item/item, current_cost)
if (item == discount_item)
return max(1, round(current_cost * discount_amount))
return current_cost
/obj/item/uplink/proc/next_offer()
return //Stub, used on children.
@@ -169,7 +173,7 @@
"items" = (category == selected_cat ? list() : null)
)
for(var/datum/uplink_item/item in category.items)
var/cost = item.cost(src, user) || "???"
var/cost = item.cost(src, user.mind.tcrystals) || "???"
cat["items"] += list(list(
"name" = item.name,
"cost" = cost,
@@ -34,7 +34,7 @@ var/global/datum/uplink_random_selection/all_uplink_selection = new/datum/uplink
if(!prob(RI.keep_probability))
continue
var/datum/uplink_item/I = uplink.items_assoc[RI.uplink_item]
if(I.cost(U) > telecrystals)
if(I.cost(U, telecrystals) > telecrystals)
continue
if(bought_items && (I in bought_items) && !prob(RI.reselect_probability))
continue