|
| 1 | +#define CARE_BASIC_CHECKUP "Basic Checkup" |
| 2 | +#define CARE_VACCINATION "Vaccination" |
| 3 | +#define CARE_MINOR_SURGERY "Minor Surgery" |
| 4 | +#define CARE_MAJOR_SURGERY "Major Surgery" |
| 5 | +#define CARE_EMERGENCY "Emergency Care" |
| 6 | +#define CARE_PRESCRIPTION "Prescription" |
| 7 | +#define CARE_MENTAL "Mental Health Consultataion" |
| 8 | + |
| 9 | +/// This machine is designed to encourage medical staff to charge patients exorbitant prices for basic care |
| 10 | +/obj/machinery/healthcare_computer |
| 11 | + name = "healthcare computer" |
| 12 | + desc = "A convenient and user-friendly computer interface for all of your healthcare needs." |
| 13 | + icon = 'yogstation/icons/obj/register.dmi' |
| 14 | + icon_state = "register" |
| 15 | + clicksound = "keyboard" |
| 16 | + anchored = TRUE |
| 17 | + density = TRUE |
| 18 | + resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF // death & taxes |
| 19 | + flags_1 = NODECONSTRUCT_1 |
| 20 | + var/obj/item/radio/radio |
| 21 | + var/current_price = 0 |
| 22 | + var/list/selected_care |
| 23 | + var/static/list/available_care |
| 24 | + var/department_tax = 0.08 |
| 25 | + |
| 26 | +/obj/machinery/healthcare_computer/Initialize(mapload) |
| 27 | + . = ..() |
| 28 | + radio = new(src) |
| 29 | + radio.keyslot = new /obj/item/encryptionkey/headset_med |
| 30 | + radio.subspace_transmission = TRUE |
| 31 | + radio.listening = FALSE |
| 32 | + radio.recalculateChannels() |
| 33 | + |
| 34 | + if(available_care && islist(available_care)) |
| 35 | + return |
| 36 | + |
| 37 | + available_care = list( |
| 38 | + CARE_BASIC_CHECKUP = floor(50 * (1.0 + department_tax)), |
| 39 | + CARE_VACCINATION = floor(75 * (1.0 + department_tax)), |
| 40 | + CARE_MINOR_SURGERY = floor(150 * (1.0 + department_tax)), |
| 41 | + CARE_MAJOR_SURGERY = floor(300 * (1.0 + department_tax)), |
| 42 | + CARE_EMERGENCY = floor(200 * (1.0 + department_tax)), |
| 43 | + CARE_PRESCRIPTION = floor(100 * (1.0 + department_tax)), |
| 44 | + CARE_MENTAL = floor(100 * (1.0 + department_tax)), |
| 45 | + ) |
| 46 | + |
| 47 | +/obj/machinery/healthcare_computer/attack_hand(mob/living/user, list/modifiers) |
| 48 | + . = ..() |
| 49 | + if(.) |
| 50 | + return |
| 51 | + if(!user.combat_mode && user.stat == CONSCIOUS) |
| 52 | + ui_interact(user) |
| 53 | + return . |
| 54 | + return |
| 55 | + |
| 56 | +/obj/machinery/healthcare_computer/ui_interact(mob/user, datum/tgui/ui) |
| 57 | + ui = SStgui.try_update_ui(user, src, ui) |
| 58 | + if(!is_operational()) |
| 59 | + return |
| 60 | + if (!ui) |
| 61 | + ui = new(user, src, "Healthcare", name) |
| 62 | + ui.open() |
| 63 | + |
| 64 | +/obj/machinery/healthcare_computer/ui_data(mob/user) |
| 65 | + . = ..() |
| 66 | + var/payee = "none" |
| 67 | + var/obj/item/card/id/card = user.get_idcard(TRUE) |
| 68 | + if(card?.registered_account?.account_holder) |
| 69 | + payee = card.registered_account.account_holder |
| 70 | + .["payee"] = payee |
| 71 | + .["current_price"] = current_price |
| 72 | + .["selected_care"] = selected_care |
| 73 | + .["available_care"] = available_care |
| 74 | + |
| 75 | +/obj/machinery/healthcare_computer/ui_act(action, list/params) |
| 76 | + if(..()) |
| 77 | + return TRUE |
| 78 | + if(!is_operational()) |
| 79 | + return |
| 80 | + |
| 81 | + switch(action) |
| 82 | + if("toggle_care") |
| 83 | + var/care_name = params["care"] |
| 84 | + if(!istext(care_name)) |
| 85 | + return |
| 86 | + if(!available_care[care_name]) |
| 87 | + return |
| 88 | + if(!selected_care) |
| 89 | + selected_care = list() |
| 90 | + if(care_name in selected_care) |
| 91 | + selected_care -= care_name |
| 92 | + current_price -= available_care[care_name] |
| 93 | + else |
| 94 | + selected_care |= care_name |
| 95 | + current_price += available_care[care_name] |
| 96 | + return TRUE |
| 97 | + if("pay_for_care") |
| 98 | + var/card = usr.get_idcard(TRUE) |
| 99 | + if(!card) |
| 100 | + return |
| 101 | + if(!charge_card(card)) |
| 102 | + return |
| 103 | + return TRUE |
| 104 | + |
| 105 | +/obj/machinery/healthcare_computer/proc/charge_card(obj/item/card/id/victim) |
| 106 | + if(!victim.registered_account) |
| 107 | + return FALSE |
| 108 | + if(current_price <= 0) |
| 109 | + return FALSE |
| 110 | + if(!selected_care || !islist(selected_care) || selected_care.len == 0) |
| 111 | + return FALSE |
| 112 | + if(!victim || !istype(victim)) |
| 113 | + return FALSE |
| 114 | + |
| 115 | + victim.registered_account._adjust_money(-current_price) // can't pay? it's ok, you'll just go into debt |
| 116 | + . = TRUE |
| 117 | + |
| 118 | + var/list/datum/bank_account/payouts = list() |
| 119 | + var/m_staff_amt = 0 |
| 120 | + for(var/datum/bank_account/account_id as anything in SSeconomy.bank_accounts) |
| 121 | + var/datum/bank_account/account = SSeconomy.bank_accounts[account_id] |
| 122 | + if(account.account_job && (account.account_job.title in GLOB.medical_positions)) |
| 123 | + payouts += account |
| 124 | + m_staff_amt += 1 |
| 125 | + |
| 126 | + var/datum/bank_account/med_account = SSeconomy.get_dep_account(ACCOUNT_MED) |
| 127 | + med_account.adjust_money(floor(current_price * department_tax)) |
| 128 | + var/after_tax = current_price * (1.0 - department_tax) |
| 129 | + |
| 130 | + var/payout_amt = floor(after_tax / m_staff_amt) |
| 131 | + for(var/datum/bank_account/medical_staff as anything in payouts) |
| 132 | + medical_staff.adjust_money(payout_amt) |
| 133 | + |
| 134 | + var/care = selected_care.Join(", ") |
| 135 | + radio.talk_into(src, "[victim.registered_account.account_holder] has paid for [care]. Medical staff have been paid [payout_amt]cr each.", RADIO_CHANNEL_MEDICAL) |
| 136 | + |
| 137 | + current_price = 0 |
| 138 | + selected_care = null |
| 139 | + |
| 140 | + say("Thank you for your patronage, [victim.registered_account.account_holder]! Medical staff have been paid and notified. You are entitled to the following: [care]") |
| 141 | + |
| 142 | + if(!victim.registered_account.has_money(-950)) // fraud prevention. id is shredded, debt remains on account |
| 143 | + victim.registered_account.bank_card_talk("Severe debt fraud detected! This ID will now self-destruct. Please contact a member of command to be issued a new ID.", TRUE) |
| 144 | + qdel(victim) |
| 145 | + playsound(src.loc, 'sound/items/pshred.ogg', 75, TRUE) |
| 146 | + else |
| 147 | + playsound(src.loc, 'sound/effects/cashregister.ogg', 20, TRUE) |
| 148 | + |
| 149 | +#undef CARE_BASIC_CHECKUP |
| 150 | +#undef CARE_VACCINATION |
| 151 | +#undef CARE_MINOR_SURGERY |
| 152 | +#undef CARE_MAJOR_SURGERY |
| 153 | +#undef CARE_EMERGENCY |
| 154 | +#undef CARE_PRESCRIPTION |
| 155 | +#undef CARE_MENTAL |
0 commit comments