Files
Bubberstation/code/modules/modular_computers/file_system/programs/coupon.dm
MrMelbert 5df4de3f71 [MDB Ignore] Re-add hop console second ID slot (#92157)
## About The Pull Request

<img width="491" height="301" alt="image"
src="https://github.com/user-attachments/assets/a3b5b19f-edf5-4de9-9201-9cbfab9e8827"
/>

Mod computers with the access changing software installed have a
secondary ID slot once again. This ID slot doesn't contribute to access.
You can insert IDs into the slot with right click and remove them with
alt-right click.

Also removes the "New IDs and you" memo paper. 

Also tweaks PDA on_deconstruct so contents are dropped on when they're
deconstructed with assembly.

Fixes #92151

## Why It's Good For The Game

Changing IDs is very unnecessarily clunky with the one slot. Insert hop
id, log in, remove hop id, insert crew id, change access, remove crew
id, log out.

We had it right back when we had two slots. Insert hop ID, insert crew
id, log in. It just works.

This also allows for mobile HoPs to change access without necessitating
removing their ID from their PDA.

Other changes: 

The "New IDs and you" memo is very old. They haven't been new for 4
years now. I don't think anyone reads it and they served their purpose.

I found it odd that, if your PDA was melted or blown up, it would delete
your ID. If this is a hold-over from old PDA behavior feel free to let
me know but otherwise it seems sensible that it'd spit out the contents
as you would expect.

## Changelog

🆑 Melbert
qol: The access changing software (the HoP console) now has ID two slots
again (one for the HoP's id and one for the ID being changed). You can
insert IDs in the secondary slot via the UI or right click, and remove
them via the UI or alt-right click.
qol: If your PDA is destroyed via acid or bombs, your ID (and similar
contents such as disks) are spit out instead of being deleted
del: Deletes the "New IDs and you" memo in the HoP's office. They
haven't been new for 4 years.
fix: Engineering sub-tab in the access changing software no longer looks
messed up
fix: Fix reversed alt-click logic for mod pcs
/🆑
2025-08-11 19:08:18 +00:00

121 lines
4.8 KiB
Plaintext

#define COUPON_PAPER_USE 1
#define COUPON_TONER_USE 0.250
///A program that enables the user to redeem randomly generated coupons for several cargo packs (mostly goodies).
/datum/computer_file/program/coupon
filename = "couponmaster"
filedesc = "Coupon Master"
downloader_category = PROGRAM_CATEGORY_SUPPLY
extended_desc = "Program for receiving discounts for several cargo goodies. After redeeming a coupon, hit a photocopier with your PDA to print it."
program_flags = PROGRAM_ON_NTNET_STORE | PROGRAM_REQUIRES_NTNET
size = 5
tgui_id = "NtosCouponMaster"
program_icon = "ticket"
can_run_on_flags = PROGRAM_PDA //It relies on the PDA messenger to let you know of new codes
detomatix_resistance = DETOMATIX_RESIST_MALUS
/datum/computer_file/program/coupon/on_install()
. = ..()
///set the discount_coupons list, which means SSmodular_computers will now begin to periodically produce new coupon codes.
LAZYINITLIST(SSmodular_computers.discount_coupons)
ADD_TRAIT(computer, TRAIT_MODPC_HALVED_DOWNLOAD_SPEED, REF(src)) //All that glitters is not gold
/datum/computer_file/program/coupon/Destroy()
if(computer)
REMOVE_TRAIT(computer, TRAIT_MODPC_HALVED_DOWNLOAD_SPEED, REF(src))
return ..()
/datum/computer_file/program/coupon/ui_data(mob/user)
var/list/data = list()
data["printed_coupons"] = list()
data["redeemed_coupons"] = list()
data["valid_id"] = FALSE
var/obj/item/card/id/user_id = computer.stored_id
if(user_id?.registered_account.add_to_accounts)
for(var/datum/coupon_code/coupon as anything in user_id.registered_account.redeemed_coupons)
var/list/coupon_data = list(
"goody" = initial(coupon.discounted_pack.name),
"discount" = coupon.discount*100,
)
if(coupon.printed)
data["printed_coupons"] += list(coupon_data)
else
data["redeemed_coupons"] += list(coupon_data)
data["valid_id"] = TRUE
return data
/datum/computer_file/program/coupon/ui_act(action, params, datum/tgui/ui, datum/ui_state/state)
. = ..()
var/obj/item/card/id/user_id = computer.stored_id
if(!(user_id?.registered_account.add_to_accounts))
return TRUE
switch(action)
if("redeem")
var/code = params["code"]
if(!length(code))
return TRUE
var/datum/coupon_code/coupon = SSmodular_computers.discount_coupons[code]
if(isnull(coupon))
user_id.registered_account.bank_card_talk("Invalid coupon code.", TRUE)
return TRUE
if(coupon.expires_in && coupon.expires_in < world.time)
user_id.registered_account.bank_card_talk("Expired coupon code.", TRUE)
return TRUE
if(coupon in user_id.registered_account.redeemed_coupons)
user_id.registered_account.bank_card_talk("Coupon [code] already redeemed.", TRUE)
return TRUE
coupon.copy(user_id.registered_account)
var/static/list/goodbye = list(
"Have a wonderful day.",
"Don't forget to print it.",
"Time to get shopping!",
"Enjoy your discount!",
"Congratulations!",
"Bye Bye~.",
)
user_id.registered_account.bank_card_talk("Coupon [code] redeemed. [pick(goodbye)]", TRUE)
//Well, guess you're redeeming something else too.
if(prob(40) && computer.used_capacity < computer.max_capacity)
var/datum/computer_file/warez = new()
warez.filename = random_string(rand(6, 12), GLOB.alphabet + GLOB.alphabet_upper + GLOB.numerals)
warez.filetype = pick("DAT", "XXX", "TMP", "FILE", "MNT", "MINER", "SYS", "PNG.EXE")
warez.size = min(rand(1, 4), computer.max_capacity - computer.used_capacity)
if(prob(25))
warez.undeletable = TRUE
computer.store_file(warez)
/**
* Normally, modular PCs can be print paper already, but I find this additional step
* to be less lazy and fitting to the "I gotta go print it before it expires" aspect of it.
*/
/datum/computer_file/program/coupon/tap(atom/tapped_atom, mob/living/user, list/modifiers)
if(!istype(tapped_atom, /obj/machinery/photocopier))
return FALSE
var/obj/item/card/id/user_id = computer.stored_id
if(!(user_id?.registered_account))
computer.balloon_alert(user, "no bank account found!")
return TRUE
var/obj/machinery/photocopier/copier = tapped_atom
if(copier.check_busy(user))
return TRUE
var/num_coupons = 0
for(var/datum/coupon_code/coupon as anything in user_id.registered_account.redeemed_coupons)
if(!coupon.printed)
num_coupons++
if(!num_coupons)
computer.balloon_alert(user, "no coupon available!")
return TRUE
copier.do_copies(CALLBACK(src, PROC_REF(print_coupon), user_id.registered_account), user, COUPON_PAPER_USE, COUPON_TONER_USE, num_coupons)
return TRUE
/datum/computer_file/program/coupon/proc/print_coupon(datum/bank_account/account)
var/datum/coupon_code/coupon
for(var/datum/coupon_code/possible_coupon as anything in account.redeemed_coupons)
if(!possible_coupon.printed)
coupon = possible_coupon
break
return coupon?.generate()
#undef COUPON_PAPER_USE
#undef COUPON_TONER_USE