Files
Paradise/code/modules/arcade/arcade_base.dm
warriorstar-orion 525c68d617 Attack chain, initial setup. (pull *immediately* for *any* TM issues) (#26834)
* refactor: Attack chain, initial setup.

* migrate curtain to make dreamchecker happy

* update thurible

* don't call attacked_by separately for legacy attack chain

* remove duplicate proc

* condense similar code, put allowances for legacy code in new procs

* update docs, include diagram source

* add comment on how to update diagram

* fix admonition

* mindflayer updates

* remove commented out code

* clarify all steps

* after_attack should be overridable

* whoops

* retrofit recent changes

* duh, can't restrict this yet because of tool_acts

* i hate ore bags with the fire of a thousand suns

* return correct value for object attack logic

* Various cleanups.

We don't want to attempt to pull stuff out of `/obj/item/attackby`,
because those pieces are part of the related objects' migrations, not
`/obj/item` itself. Attempting to do this causes knockon effects where
things expected to call e.g. `/obj/item/storage/attackby` in the call
chain were not ferried over to the new item interaction code, because
the related objects hadn't actually been migrated over yet.

I've used refactoring /obj/vehicle as the example for migrating
`attackby` methods instead.

* simplify some argument names

* fuck it

* make it do the thing

* Rename CI module call

* Prove that CI works

* improve test output

* aaand fix it again

* fix curtain tool interactions

* fix compile error

* fix compile error

* Better docs, introduce migration plan tool.
2024-12-02 23:36:36 +00:00

112 lines
3.3 KiB
Plaintext

/obj/machinery/economy/arcade
name = "Arcade Game"
desc = "One of the most generic arcade games ever."
icon = 'icons/obj/arcade.dmi'
icon_state = "clawmachine_1_on"
idle_power_consumption = 40
var/tokens = 0
var/freeplay = FALSE //for debugging and admin kindness
var/token_price = 0
var/window_name = "arcade" //in case you want to change the window name for certain machines
/obj/machinery/economy/arcade/Initialize(mapload)
. = ..()
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/economy/arcade/examine(mob/user)
. = ..()
if(freeplay)
. += "Someone enabled freeplay on this machine!"
else
if(token_price)
. += "[src] costs [token_price] credits per play."
if(!tokens)
. += "[src] has no available play credits. Better feed the machine!"
else if(tokens == 1)
. += "[src] has only 1 play credit left!"
else
. += "[src] has [tokens] play credits!"
/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
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/economy/arcade/interact(mob/user)
if(stat & BROKEN || panel_open)
return
if(!tokens && !freeplay)
to_chat(user, "\The [src] doesn't have enough credits to play! Pay first!")
return
if(!in_use && (tokens || freeplay))
in_use = 1
start_play(user)
return
if(in_use)
if(src != user.machine)
to_chat(user, "Someone else is already playing this machine, please wait your turn!")
return
/obj/machinery/economy/arcade/attackby__legacy__attackchain(obj/item/O, mob/user, params)
if(!freeplay)
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
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/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/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/economy/arcade/proc/start_play(mob/user as mob)
user.set_machine(src)
if(!freeplay)
tokens -= 1
/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/economy/arcade/proc/win()
return
/obj/machinery/economy/arcade/process()
if(in_use)
updateUsrDialog()
if(!in_use)
close_game()
/obj/machinery/economy/arcade/Destroy()
close_game()
return ..()