Skip to content

Commit

Permalink
money laundering
Browse files Browse the repository at this point in the history
  • Loading branch information
TobleroneSwordfish committed Apr 16, 2023
1 parent 5f62257 commit 0ba02f9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
22 changes: 16 additions & 6 deletions code/WorkInProgress/laundry.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down Expand Up @@ -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].")
Expand Down
17 changes: 17 additions & 0 deletions code/procs/helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions strings/changelog.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 0ba02f9

Please sign in to comment.