mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-30 07:27:57 +01:00
[TGUI] Space Credit Economy Overhaul + Supply Point -> Space Cash (#19209)
* initial edits * initial edits * converting shit over to machinery/economy * vending and mapping fixes * vending fix pt.2 * Converts Supply Economy to Use Space Credits instead of Supply Points * Job Payment, NanoBank, and Paychecks * clothing type path fixes (damn merge conflicts) * fixes map typepath issues * adjusts supply prices * Vendor Price Adjustments * account uplink terminal tweaks * please pass tests * Apply suggestions from code review Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> * reviews and bug fixes * Review Suggestions/Fixes and Request Console Rewrite * edits * vending changes for merge * typepath fix * final tweaks * proc ref fixes * Fixes and Tweaks from 2nd TM * rebuild TGUI * final tweaks * Apply suggestions from code review Co-authored-by: Farie82 <farie82@users.noreply.github.com> * requested reviews * tweaks * updates slot machine winnings * fixes * GC fixes * fixes * oops. still need to deconflict this * Apply suggestions from code review Co-authored-by: Farie82 <farie82@users.noreply.github.com> Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com> Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com> * requested changes and bug fixes * atm runtime fix * requested reviews * vend act stuff * attempt to pass tests * supply packs fix * user tochat -> debug log * FINAL FIXES * removes CC db stuff * Apply suggestions from code review Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Co-authored-by: Farie82 <farie82@users.noreply.github.com> Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com> Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
This commit is contained in:
co-authored by
AffectedArc07
Farie82
Henri215
Luc
parent
ae8accb766
commit
61145a02f8
@@ -1,54 +1,52 @@
|
||||
|
||||
/obj/machinery/arcade
|
||||
/obj/machinery/economy/arcade
|
||||
name = "Arcade Game"
|
||||
desc = "One of the most generic arcade games ever."
|
||||
icon = 'icons/obj/arcade.dmi'
|
||||
icon_state = "clawmachine_on"
|
||||
density = TRUE
|
||||
anchored = TRUE
|
||||
use_power = IDLE_POWER_USE
|
||||
idle_power_usage = 40
|
||||
|
||||
var/tokens = 0
|
||||
var/freeplay = FALSE //for debugging and admin kindness
|
||||
var/token_price = 0
|
||||
var/last_winner = null //for letting people who to hunt down and steal prizes from
|
||||
var/window_name = "arcade" //in case you want to change the window name for certain machines
|
||||
|
||||
/obj/machinery/arcade/Initialize(mapload)
|
||||
/obj/machinery/economy/arcade/Initialize(mapload)
|
||||
. = ..()
|
||||
if(type == /obj/machinery/arcade) //if you spawn the base-type, it will replace itself with a random subtype for randomness
|
||||
var/choice = pick(subtypesof(/obj/machinery/arcade))
|
||||
if(type == /obj/machinery/economy/arcade) //if you spawn the base-type, it will replace itself with a random subtype for randomness
|
||||
var/choice = pick(subtypesof(/obj/machinery/economy/arcade))
|
||||
new choice(loc)
|
||||
return INITIALIZE_HINT_QDEL
|
||||
|
||||
/obj/machinery/arcade/examine(mob/user)
|
||||
/obj/machinery/economy/arcade/examine(mob/user)
|
||||
. = ..()
|
||||
if(freeplay)
|
||||
. += "Someone enabled freeplay on this machine!"
|
||||
else
|
||||
if(token_price)
|
||||
. += "\The [src.name] costs [token_price] credits per play."
|
||||
. += "[src] costs [token_price] credits per play."
|
||||
if(!tokens)
|
||||
. += "\The [src.name] has no available play credits. Better feed the machine!"
|
||||
. += "[src] has no available play credits. Better feed the machine!"
|
||||
else if(tokens == 1)
|
||||
. += "\The [src.name] has only 1 play credit left!"
|
||||
. += "[src] has only 1 play credit left!"
|
||||
else
|
||||
. += "\The [src.name] has [tokens] play credits!"
|
||||
. += "[src] has [tokens] play credits!"
|
||||
|
||||
/obj/machinery/arcade/attack_hand(mob/user as mob)
|
||||
/obj/machinery/economy/arcade/attack_hand(mob/user)
|
||||
if(..())
|
||||
if(in_use && src == user.machine) //this one checks if they fell down/died and closes the game
|
||||
src.close_game()
|
||||
close_game()
|
||||
return
|
||||
if(in_use && src == user.machine) //this one just checks if they are playing so it doesn't eat tokens
|
||||
return
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/arcade/interact(mob/user as mob)
|
||||
/obj/machinery/economy/arcade/interact(mob/user)
|
||||
if(stat & BROKEN || panel_open)
|
||||
return
|
||||
if(!tokens && !freeplay)
|
||||
to_chat(user, "\The [src.name] doesn't have enough credits to play! Pay first!")
|
||||
to_chat(user, "\The [src] doesn't have enough credits to play! Pay first!")
|
||||
return
|
||||
if(!in_use && (tokens || freeplay))
|
||||
in_use = 1
|
||||
@@ -59,88 +57,56 @@
|
||||
to_chat(user, "Someone else is already playing this machine, please wait your turn!")
|
||||
return
|
||||
|
||||
/obj/machinery/arcade/attackby(obj/item/O, mob/user, params)
|
||||
/obj/machinery/economy/arcade/attackby(obj/item/O, mob/user, params)
|
||||
if(exchange_parts(user, O))
|
||||
return
|
||||
if(!freeplay)
|
||||
if(istype(O, /obj/item/card/id))
|
||||
var/obj/item/card/id/C = O
|
||||
if(pay_with_card(C))
|
||||
if(isspacecash(O))
|
||||
insert_cash(O, user, token_price)
|
||||
if(pay_with_cash(token_price, "Arcade Token Purchase", "DonkBook Gaming", user, account_database.vendor_account))
|
||||
tokens += 1
|
||||
return
|
||||
else if(istype(O, /obj/item/stack/spacecash))
|
||||
var/obj/item/stack/spacecash/C = O
|
||||
if(pay_with_cash(C, user))
|
||||
if(istype(O, /obj/item/card/id))
|
||||
if(pay_with_card(O, token_price, "Arcade Token Purchase", "DonkBook Gaming", user, account_database.vendor_account))
|
||||
tokens += 1
|
||||
return
|
||||
return ..()
|
||||
|
||||
/obj/machinery/arcade/screwdriver_act(mob/living/user, obj/item/I)
|
||||
/obj/machinery/economy/arcade/screwdriver_act(mob/living/user, obj/item/I)
|
||||
if(!anchored)
|
||||
return FALSE
|
||||
default_deconstruction_screwdriver(user, icon_state, icon_state, I)
|
||||
update_icon()
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/arcade/crowbar_act(mob/living/user, obj/item/I)
|
||||
/obj/machinery/economy/arcade/crowbar_act(mob/living/user, obj/item/I)
|
||||
if(!component_parts || !panel_open)
|
||||
return FALSE
|
||||
default_deconstruction_crowbar(user, I)
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/arcade/proc/pay_with_cash(obj/item/stack/spacecash/cashmoney, mob/user)
|
||||
if(cashmoney.amount < token_price)
|
||||
to_chat(user, "[bicon(cashmoney)] <span class='warning'>That is not enough money.</span>")
|
||||
return 0
|
||||
visible_message("<span class='info'>[usr] inserts a credit chip into [src].</span>")
|
||||
cashmoney.use(token_price)
|
||||
return 1
|
||||
|
||||
/obj/machinery/arcade/proc/pay_with_card(obj/item/card/id/I, mob/user)
|
||||
visible_message("<span class='info'>[usr] swipes a card through [src].</span>")
|
||||
var/datum/money_account/customer_account = attempt_account_access_nosec(I.associated_account_number)
|
||||
if(!customer_account)
|
||||
to_chat(user, "Error: Unable to access account. Please contact technical support if problem persists.")
|
||||
return 0
|
||||
|
||||
if(customer_account.suspended)
|
||||
to_chat(user, "Unable to access account: account suspended.")
|
||||
return 0
|
||||
|
||||
// Have the customer punch in the PIN before checking if there's enough money. Prevents people from figuring out acct is
|
||||
// empty at high security levels
|
||||
if(customer_account.security_level != 0) //If card requires pin authentication (ie seclevel 1 or 2)
|
||||
var/attempt_pin = input("Enter pin code", "Vendor transaction") as num
|
||||
customer_account = attempt_account_access(I.associated_account_number, attempt_pin, 2)
|
||||
|
||||
if(!customer_account)
|
||||
to_chat(user, "Unable to access account: incorrect credentials.")
|
||||
return 0
|
||||
|
||||
return customer_account.charge(token_price, null, "Purchase of [name] credit", name, name)
|
||||
|
||||
/obj/machinery/arcade/proc/start_play(mob/user as mob)
|
||||
/obj/machinery/economy/arcade/proc/start_play(mob/user as mob)
|
||||
user.set_machine(src)
|
||||
if(!freeplay)
|
||||
tokens -= 1
|
||||
|
||||
/obj/machinery/arcade/proc/close_game()
|
||||
in_use = 0
|
||||
/obj/machinery/economy/arcade/proc/close_game()
|
||||
in_use = FALSE
|
||||
for(var/mob/user in viewers(world.view, src)) // I don't know who you are.
|
||||
if(user.client && user.machine == src) // I will look for you,
|
||||
user.unset_machine() // I will find you,
|
||||
user << browse(null, "window=[window_name]") // And I will kill you.
|
||||
return
|
||||
|
||||
/obj/machinery/arcade/proc/win()
|
||||
/obj/machinery/economy/arcade/proc/win()
|
||||
return
|
||||
|
||||
/obj/machinery/arcade/process()
|
||||
/obj/machinery/economy/arcade/process()
|
||||
if(in_use)
|
||||
src.updateUsrDialog()
|
||||
updateUsrDialog()
|
||||
if(!in_use)
|
||||
src.close_game()
|
||||
close_game()
|
||||
|
||||
/obj/machinery/arcade/Destroy()
|
||||
src.close_game()
|
||||
/obj/machinery/economy/arcade/Destroy()
|
||||
close_game()
|
||||
return ..()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
GLOBAL_VAR(claw_game_html)
|
||||
|
||||
/obj/machinery/arcade/claw
|
||||
/obj/machinery/economy/arcade/claw
|
||||
name = "Claw Game"
|
||||
desc = "One of the most infuriating ways to win a toy."
|
||||
icon = 'icons/obj/arcade.dmi'
|
||||
@@ -17,7 +17,7 @@ GLOBAL_VAR(claw_game_html)
|
||||
'icons/obj/arcade_images/prize_inside.png',
|
||||
'icons/obj/arcade_images/prizeorbs.png')
|
||||
|
||||
/obj/machinery/arcade/claw/Initialize(mapload)
|
||||
/obj/machinery/economy/arcade/claw/Initialize(mapload)
|
||||
. = ..()
|
||||
machine_image = pick("_1", "_2")
|
||||
update_icon(UPDATE_ICON_STATE)
|
||||
@@ -33,13 +33,13 @@ GLOBAL_VAR(claw_game_html)
|
||||
if(!GLOB.claw_game_html)
|
||||
GLOB.claw_game_html = file2text('code/modules/arcade/crane.html')
|
||||
|
||||
/obj/machinery/arcade/claw/RefreshParts()
|
||||
/obj/machinery/economy/arcade/claw/RefreshParts()
|
||||
var/bin_upgrades = 0
|
||||
for(var/obj/item/stock_parts/matter_bin/B in component_parts)
|
||||
bin_upgrades = B.rating
|
||||
bonus_prize_chance = bin_upgrades * 5 //equals +5% chance per matter bin rating level (+20% with rating 4)
|
||||
|
||||
/obj/machinery/arcade/claw/update_icon_state()
|
||||
/obj/machinery/economy/arcade/claw/update_icon_state()
|
||||
if(stat & BROKEN)
|
||||
icon_state = "clawmachine[machine_image]_broken"
|
||||
else if(panel_open)
|
||||
@@ -49,7 +49,7 @@ GLOBAL_VAR(claw_game_html)
|
||||
else
|
||||
icon_state = "clawmachine[machine_image]_on"
|
||||
|
||||
/obj/machinery/arcade/claw/win()
|
||||
/obj/machinery/economy/arcade/claw/win()
|
||||
icon_state = "clawmachine[machine_image]_win"
|
||||
if(prob(bonus_prize_chance)) //double prize mania!
|
||||
atom_say("DOUBLE PRIZE!")
|
||||
@@ -60,7 +60,7 @@ GLOBAL_VAR(claw_game_html)
|
||||
playsound(loc, 'sound/arcade/win.ogg', 50, TRUE)
|
||||
addtimer(CALLBACK(src, TYPE_PROC_REF(/atom, update_icon), UPDATE_ICON_STATE), 10)
|
||||
|
||||
/obj/machinery/arcade/claw/start_play(mob/user as mob)
|
||||
/obj/machinery/economy/arcade/claw/start_play(mob/user as mob)
|
||||
..()
|
||||
user << browse_rsc('page.css')
|
||||
for(var/i in 1 to img_resources.len)
|
||||
@@ -75,7 +75,7 @@ GLOBAL_VAR(claw_game_html)
|
||||
popup.open()
|
||||
user.set_machine(src)
|
||||
|
||||
/obj/machinery/arcade/claw/Topic(href, list/href_list)
|
||||
/obj/machinery/economy/arcade/claw/Topic(href, list/href_list)
|
||||
if(..())
|
||||
return
|
||||
var/prize_won = null
|
||||
|
||||
Reference in New Issue
Block a user