Files
Paradise/code/game/objects/items/scratch_card.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

51 lines
1.6 KiB
Plaintext

/obj/item/scratch
name = "scratch card"
desc = "Scratch this with a card or coin to discover if you are the winner!"
icon = 'icons/obj/economy.dmi'
icon_state = "scard"
w_class = WEIGHT_CLASS_TINY
/// 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)
. = ..()
if(scratched)
return
if(!(istype(I, /obj/item/card) || istype(I, /obj/item/coin))) // We scratch with cards or coins!
return
if(prob(winning_chance))
to_chat(user, "<span class='notice'>Congratulations! Redeem your prize at the nearest ATM!</span>")
icon_state = "scard_winner"
winner = TRUE
else
to_chat(user, "Good luck next time.")
icon_state = "scard_loser"
playsound(user, 'sound/items/scratching.ogg', 25, TRUE)
scratched = TRUE
update_icon(UPDATE_ICON_STATE)
/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/storage/box/scratch_cards
name = "scratch cards box"
desc = "Try your luck with five scratch cards!"
w_class = WEIGHT_CLASS_SMALL
can_hold = list(/obj/item/scratch)
/obj/item/storage/box/scratch_cards/populate_contents()
for(var/i in 1 to 5)
new /obj/item/scratch(src)