From 4a703dd7d34ade6d55d056d3b3441f281b4c080e Mon Sep 17 00:00:00 2001 From: CHOMPStation2 <58959929+CHOMPStation2@users.noreply.github.com> Date: Mon, 24 Jul 2023 01:01:05 -0700 Subject: [PATCH] [MIRROR] Simplified Coin Press (#6645) Co-authored-by: Casey Co-authored-by: CHOMPStation2 --- code/modules/economy/mint.dm | 241 ++++++----------------------------- 1 file changed, 40 insertions(+), 201 deletions(-) diff --git a/code/modules/economy/mint.dm b/code/modules/economy/mint.dm index db50578fe7..07bc1d22a7 100644 --- a/code/modules/economy/mint.dm +++ b/code/modules/economy/mint.dm @@ -1,210 +1,49 @@ /**********************Mint**************************/ /obj/machinery/mineral/mint name = "Coin press" + desc = "A relatively crude hand-operated coin press that turns sheets (or ingots, as the case may be) of materials into fresh coins. They're probably not going to be considered legal tender in most polities, but you might fool a vending machine with one..?

It looks like it'll accept silver, gold, diamond, iron, solid phoron, and uranium." icon = 'icons/obj/stationobjs.dmi' icon_state = "coinpress0" density = TRUE anchored = TRUE - var/obj/machinery/mineral/input = null - var/obj/machinery/mineral/output = null - var/amt_silver = 0 //amount of silver - var/amt_gold = 0 //amount of gold - var/amt_diamond = 0 - var/amt_iron = 0 - var/amt_phoron = 0 - var/amt_uranium = 0 - var/newCoins = 0 //how many coins the machine made in it's last load - var/processing = 0 - var/chosen = MAT_STEEL //which material will be used to make coins - var/coinsToProduce = 10 + var/coinsToProduce = 6 //how many coins do we make per sheet? a sheet is 2000 units whilst a coin is 250, and some material should be lost in the process + var/list/validMats = list("silver", "gold", "diamond", "iron", "phoron", "uranium") //what's valid stuff to make coins out of? - -/obj/machinery/mineral/mint/Initialize() - . = ..() - for (var/dir in cardinal) - input = locate(/obj/machinery/mineral/input, get_step(src, dir)) - if(input) - break - for (var/dir in cardinal) - output = locate(/obj/machinery/mineral/output, get_step(src, dir)) - if(output) - break - -/obj/machinery/mineral/mint/process() - if(!input) - return - - var/obj/item/stack/O = locate(/obj/item/stack, input.loc) - if(!O) - return - - var/processed = 1 - switch(O.get_material_name()) - if("gold") - amt_gold += 100 * O.get_amount() - if("silver") - amt_silver += 100 * O.get_amount() - if("diamond") - amt_diamond += 100 * O.get_amount() - if("phoron") - amt_phoron += 100 * O.get_amount() - if("uranium") - amt_uranium += 100 * O.get_amount() - if(MAT_STEEL) - amt_iron += 100 * O.get_amount() - else - processed = 0 - if(processed) - qdel(O) - -/obj/machinery/mineral/mint/attack_hand(user as mob) - - var/dat = "Coin Press
" - - if (!input) - dat += text("input connection status: ") - dat += text("NOT CONNECTED
") - if (!output) - dat += text("
output connection status: ") - dat += text("NOT CONNECTED
") - - dat += text("
Gold inserted: [amt_gold] ") - if (chosen == "gold") - dat += text("chosen") - else - dat += text("Choose") - dat += text("
Silver inserted: [amt_silver] ") - if (chosen == "silver") - dat += text("chosen") - else - dat += text("Choose") - dat += text("
Iron inserted: [amt_iron] ") - if (chosen == MAT_STEEL) - dat += text("chosen") - else - dat += text("Choose") - dat += text("
Diamond inserted: [amt_diamond] ") - if (chosen == "diamond") - dat += text("chosen") - else - dat += text("Choose") - dat += text("
Phoron inserted: [amt_phoron] ") - if (chosen == "phoron") - dat += text("chosen") - else - dat += text("Choose") - dat += text("
Uranium inserted: [amt_uranium] ") - if (chosen == "uranium") - dat += text("chosen") - else - dat += text("Choose") - - dat += text("

Will produce [coinsToProduce] [chosen] coins if enough materials are available.
") - //dat += text("The dial which controls the number of conins to produce seems to be stuck. A technician has already been dispatched to fix this.") - dat += text("-10 ") - dat += text("-5 ") - dat += text("-1 ") - dat += text("+1 ") - dat += text("+5 ") - dat += text("+10 ") - - dat += text("

In total this machine produced [newCoins] coins.") - dat += text("
Make coins") - user << browse("[dat]", "window=mint") - -/obj/machinery/mineral/mint/Topic(href, href_list) - if(..()) - return 1 - usr.set_machine(src) - src.add_fingerprint(usr) - if(processing==1) - to_chat(usr, "The machine is processing.") - return - if(href_list["choose"]) - chosen = href_list["choose"] - if(href_list["chooseAmt"]) - coinsToProduce = between(0, coinsToProduce + text2num(href_list["chooseAmt"]), 1000) - if(href_list["makeCoins"]) - var/temp_coins = coinsToProduce - if (src.output) - processing = 1; +/obj/machinery/mineral/mint/attackby(obj/item/stack/material/M as obj, mob/user as mob) + if(M.default_type in validMats) + user.visible_message("[user] starts to feed a sheet of [M.default_type] into \the [src].") + while(M.amount > 0) icon_state = "coinpress1" - var/obj/item/weapon/moneybag/M - switch(chosen) - if(MAT_STEEL) - while(amt_iron > 0 && coinsToProduce > 0) - if (locate(/obj/item/weapon/moneybag,output.loc)) - M = locate(/obj/item/weapon/moneybag,output.loc) - else - M = new/obj/item/weapon/moneybag(output.loc) - new/obj/item/weapon/coin/iron(M) - amt_iron -= 20 - coinsToProduce-- - newCoins++ - src.updateUsrDialog() - sleep(5); - if("gold") - while(amt_gold > 0 && coinsToProduce > 0) - if (locate(/obj/item/weapon/moneybag,output.loc)) - M = locate(/obj/item/weapon/moneybag,output.loc) - else - M = new/obj/item/weapon/moneybag(output.loc) - new /obj/item/weapon/coin/gold(M) - amt_gold -= 20 - coinsToProduce-- - newCoins++ - src.updateUsrDialog() - sleep(5); - if("silver") - while(amt_silver > 0 && coinsToProduce > 0) - if (locate(/obj/item/weapon/moneybag,output.loc)) - M = locate(/obj/item/weapon/moneybag,output.loc) - else - M = new/obj/item/weapon/moneybag(output.loc) - new /obj/item/weapon/coin/silver(M) - amt_silver -= 20 - coinsToProduce-- - newCoins++ - src.updateUsrDialog() - sleep(5); - if("diamond") - while(amt_diamond > 0 && coinsToProduce > 0) - if (locate(/obj/item/weapon/moneybag,output.loc)) - M = locate(/obj/item/weapon/moneybag,output.loc) - else - M = new/obj/item/weapon/moneybag(output.loc) - new /obj/item/weapon/coin/diamond(M) - amt_diamond -= 20 - coinsToProduce-- - newCoins++ - src.updateUsrDialog() - sleep(5); - if("phoron") - while(amt_phoron > 0 && coinsToProduce > 0) - if (locate(/obj/item/weapon/moneybag,output.loc)) - M = locate(/obj/item/weapon/moneybag,output.loc) - else - M = new/obj/item/weapon/moneybag(output.loc) - new /obj/item/weapon/coin/phoron(M) - amt_phoron -= 20 - coinsToProduce-- - newCoins++ - src.updateUsrDialog() - sleep(5); - if("uranium") - while(amt_uranium > 0 && coinsToProduce > 0) - if (locate(/obj/item/weapon/moneybag,output.loc)) - M = locate(/obj/item/weapon/moneybag,output.loc) - else - M = new/obj/item/weapon/moneybag(output.loc) - new /obj/item/weapon/coin/uranium(M) - amt_uranium -= 20 - coinsToProduce-- - newCoins++ - src.updateUsrDialog() - sleep(5) - icon_state = "coinpress0" - processing = 0; - coinsToProduce = temp_coins - src.updateUsrDialog() - return \ No newline at end of file + if(do_after(user, 2 SECONDS, src)) + M.amount-- + if(M.default_type == "silver") + while(coinsToProduce-- > 0) + new /obj/item/weapon/coin/silver(user.loc) + else if(M.default_type == "gold") + while(coinsToProduce-- > 0) + new /obj/item/weapon/coin/gold(user.loc) + else if(M.default_type == "diamond") + while(coinsToProduce-- > 0) + new /obj/item/weapon/coin/diamond(user.loc) + else if(M.default_type == "iron") + while(coinsToProduce-- > 0) + new /obj/item/weapon/coin/iron(user.loc) + else if(M.default_type == "phoron") + while(coinsToProduce-- > 0) + new /obj/item/weapon/coin/phoron(user.loc) + else if(M.default_type == "uranium") + while(coinsToProduce-- > 0) + new /obj/item/weapon/coin/uranium(user.loc) + src.visible_message("\The [src] rattles and dispenses several [M.default_type] coins!") + coinsToProduce = initial(coinsToProduce) + if(M.amount == 0) + icon_state = "coinpress0" + qdel(M) //clean it up just to be sure + src.visible_message("\The [src] has run out of usable materials.") + break + else + to_chat(usr,"\The [src] is hand-operated and requires your full attention!") + icon_state = "coinpress0" + break + else + src.visible_message("\The [src] doesn't look like it'll accept that material.") \ No newline at end of file