diff --git a/code/WorkInProgress/laundry.dm b/code/WorkInProgress/laundry.dm index e470735e7fe07..18d6be89dd5f0 100644 --- a/code/WorkInProgress/laundry.dm +++ b/code/WorkInProgress/laundry.dm @@ -79,11 +79,21 @@ src.UpdateIcon() else // drying is done! processing_items.Remove(src) - for (var/obj/item/clothing/C in src.contents) - C.stains = null - C.delStatus("freshly_laundered") // ...and this is the price we pay for being cheeky - C.changeStatus("freshly_laundered", rand(2,4) MINUTES) - C.UpdateName() + for (var/obj/item/item in src.contents) + if (istype(item, /obj/item/clothing)) + var/obj/item/clothing/clothing = item + clothing.stains = null + clothing.delStatus("freshly_laundered") // ...and this is the price we pay for being cheeky + clothing.changeStatus("freshly_laundered", rand(2,4) MINUTES) + clothing.UpdateName() + else if (istype(item, /obj/item/spacecash)) + var/obj/item/spacecash/cash = item + var/list/amounts = random_split(cash.amount, min(rand(3,6), cash.amount - 1)) + for (var/amount in amounts) + if (amount >= cash.amount) + break + var/obj/item/spacecash/newcash = cash.split_stack(amount) + newcash.set_loc(src) src.cycle = POST src.cycle_current = 0 src.visible_message("[src] lets out a happy beep!") @@ -174,7 +184,7 @@ src.visible_message("[user] tries [his_or_her(user)] best to put [W] into [src], but [W] is stuck to [him_or_her(user)]!") return else - if (istype(W, /obj/item/clothing)) + if (istype(W, /obj/item/clothing) || istype(W, /obj/item/spacecash)) user.u_equip(W) W.set_loc(src) src.visible_message("[user] puts [W] into [src].") diff --git a/code/procs/helpers.dm b/code/procs/helpers.dm index f2ae1de0239c2..7b054557ee99d 100644 --- a/code/procs/helpers.dm +++ b/code/procs/helpers.dm @@ -2672,3 +2672,20 @@ proc/connectdirs_to_byonddirs(var/connectdir_bitflag) /// For runtime logs- returns the above plus ref /proc/identify_object(datum/thing) return "[log_object(thing)] \ref[thing]" // actual datum + +///Returns `amount` evenly distributed random integers that sum to `N` +/proc/random_split(sum, amount) + if (amount >= sum || sum <= 0) + CRASH("Invalid arguments to random split") + var/list/points = list(sum) + for (var/i in 1 to (amount - 1)) + var/next_number = rand(1, sum) + while (next_number in points) + next_number = rand(1, sum) + points += next_number + sortList(points) + . = list() + var/prev = 0 + for (var/point in points) + . += point - prev + prev = point diff --git a/strings/changelog.txt b/strings/changelog.txt index c16ddb13922d8..ab9c377ca7fa1 100644 --- a/strings/changelog.txt +++ b/strings/changelog.txt @@ -1,5 +1,7 @@ (t)sun apr 16 23 +(u)LeahTheTech +(+)Money can now be laundered. (u)Kubius (p)13586 (e)🪲🆕⚖📦🌠|C-Bug, C-Feature, C-Balance, A-Game-Objects, A-Events