Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrates /obj/item/scratch to the new attack chain #28177

Merged
merged 2 commits into from
Feb 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions code/game/objects/items/scratch_card.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
icon = 'icons/obj/economy.dmi'
icon_state = "scard"
w_class = WEIGHT_CLASS_TINY
new_attack_chain = TRUE
/// Has this been scratched yet?
var/scratched = FALSE
/// The prob chance for it to be the winner card
var/winning_chance = 1
/// Is this the winner card?
var/winner = FALSE

/obj/item/scratch/attackby__legacy__attackchain(obj/item/I, mob/user, params)
/obj/item/scratch/item_interaction(mob/living/user, obj/item/used, list/modifiers)
. = ..()
if(scratched)
return
if(!(istype(I, /obj/item/card) || istype(I, /obj/item/coin))) // We scratch with cards or coins!

if(!(istype(used, /obj/item/card) || istype(used, /obj/item/coin))) // We scratch with cards or coins!
return

if(prob(winning_chance))
Expand All @@ -28,16 +30,18 @@
playsound(user, 'sound/items/scratching.ogg', 25, TRUE)
scratched = TRUE
update_icon(UPDATE_ICON_STATE)
return ITEM_INTERACT_COMPLETE

/obj/item/scratch/attack_obj__legacy__attackchain(obj/O, mob/living/user, params)
if(winner && istype(O, /obj/machinery/economy/atm))
playsound(user, 'sound/machines/ping.ogg', 50, TRUE)
O.atom_say("Congratulations for winning the lottery!")
var/obj/item/reward = new /obj/item/stack/spacecash/c1000
qdel(src)
user.put_in_hands(reward)
return
..()
/obj/item/scratch/interact_with_atom(atom/target, mob/living/user, list/modifiers)
if(!winner || !istype(target, /obj/machinery/economy/atm))
return ..()

playsound(user, 'sound/machines/ping.ogg', 50, TRUE)
target.atom_say("Congratulations for winning the lottery!")
var/obj/item/reward = new /obj/item/stack/spacecash/c1000
qdel(src)
user.put_in_hands(reward)
return ITEM_INTERACT_COMPLETE

/obj/item/storage/box/scratch_cards
name = "scratch cards box"
Expand Down