Files
Bubberstation/code/modules/cards/deck/tarot.dm
SkyratBot 8e15637406 [MIRROR] Drawing from an empty tarot card deck no longer causes runtimes [MDB IGNORE] (#20035)
* Drawing from an empty tarot card deck no longer causes runtimes (#74160)

## About The Pull Request
Does as the title says. When drawing from an empty deck, the deck would
have a chance to preform a transformation on a card that doesn't exist.
This PR makes it so that if there is no card, the code returns `FALSE`.
### Mapping March
Ckey to receive rewards: N/A

## Why It's Good For The Game
Runtimes aren't a good thing to have in the game.
## Changelog
🆑
fix: drawing from an empty tarot card deck no longer causes runtimes
/🆑

* Drawing from an empty tarot card deck no longer causes runtimes

---------

Co-authored-by: Pinta <68373373+softcerv@users.noreply.github.com>
2023-03-25 01:06:03 -07:00

69 lines
2.7 KiB
Plaintext

#define TAROT_GHOST_TIMER (666 SECONDS) // this translates into 11 mins and 6 seconds
//These cards certainly won't tell the future, but you can play some nice games with them.
/obj/item/toy/cards/deck/tarot
name = "tarot game deck"
desc = "A full 78 card game deck of tarot cards. Complete with 4 suites of 14 cards, and a full suite of trump cards."
cardgame_desc = "tarot card reading"
icon_state = "deck_tarot_full"
deckstyle = "tarot"
is_standard_deck = FALSE
/obj/item/toy/cards/deck/tarot/Initialize(mapload)
. = ..()
for(var/suit in list("Hearts", "Pikes", "Clovers", "Tiles"))
for(var/i in 1 to 10)
initial_cards += "[i] of [suit]"
for(var/person in list("Valet", "Chevalier", "Dame", "Roi"))
initial_cards += "[person] of [suit]"
for(var/trump in list("The Magician", "The High Priestess", "The Empress", "The Emperor", "The Hierophant", "The Lover", "The Chariot", "Justice", "The Hermit", "The Wheel of Fortune", "Strength", "The Hanged Man", "Death", "Temperance", "The Devil", "The Tower", "The Star", "The Moon", "The Sun", "Judgement", "The World", "The Fool"))
initial_cards += trump
/obj/item/toy/cards/deck/tarot/draw(mob/user)
. = ..()
if(prob(50))
var/obj/item/toy/singlecard/card = .
if(!card)
return FALSE
var/matrix/M = matrix()
M.Turn(180)
card.transform = M
/obj/item/toy/cards/deck/tarot/haunted
name = "haunted tarot game deck"
desc = "A spooky looking tarot deck. You can sense a supernatural presence linked to the cards..."
/// ghost notification cooldown
COOLDOWN_DECLARE(ghost_alert_cooldown)
/obj/item/toy/cards/deck/tarot/haunted/on_wield(obj/item/source, mob/living/carbon/user)
. = ..()
ADD_TRAIT(user, TRAIT_SIXTHSENSE, MAGIC_TRAIT)
to_chat(user, span_notice("The veil to the underworld is opened. You can sense the dead souls calling out..."))
if(!COOLDOWN_FINISHED(src, ghost_alert_cooldown))
return
COOLDOWN_START(src, ghost_alert_cooldown, TAROT_GHOST_TIMER)
notify_ghosts(
"Someone has begun playing with a [src.name] in [get_area(src)]!",
source = src,
header = "Haunted Tarot Deck",
ghost_sound = 'sound/effects/ghost2.ogg',
notify_volume = 75,
action = NOTIFY_ORBIT,
)
/obj/item/toy/cards/deck/tarot/haunted/on_unwield(obj/item/source, mob/living/carbon/user)
. = ..()
REMOVE_TRAIT(user, TRAIT_SIXTHSENSE, MAGIC_TRAIT)
to_chat(user, span_notice("The veil to the underworld closes shut. You feel your senses returning to normal."))
/obj/item/toy/cards/deck/tarot/haunted/dropped(mob/living/carbon/user, silent)
. = ..()
if(wielded)
REMOVE_TRAIT(user, TRAIT_SIXTHSENSE, MAGIC_TRAIT)
to_chat(user, span_notice("The veil to the underworld closes shut. You feel your senses returning to normal."))
#undef TAROT_GHOST_TIMER