Skip to content

Commit

Permalink
Migrates /obj/item/scratch to the new attack chain (#28177)
Browse files Browse the repository at this point in the history
* Update scratch_card.dm

* Update scratch_card.dm
  • Loading branch information
Fordoxia authored Feb 5, 2025
1 parent e7cada2 commit eab51e1
Showing 1 changed file with 15 additions and 11 deletions.
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

0 comments on commit eab51e1

Please sign in to comment.