Files
Bubberstation/code/modules/cards/deck/blank.dm
Mothblocks ad929ac3a9 Lazily initialize decks of cards instead of initializing thousands of cards at once (.09s drop in init times) (#70999)
We're getting into the less than 0.1s realm of low hanging fruits now.

Decks of cards were initializing thousands of cards at once, not unlike
[paper bins](https://github.com/tgstation/tgstation/pull/69586) or
[circuit components](https://github.com/tgstation/tgstation/pull/69664).

Cards are more complicated than paper bins since we can't just keep a
count, and managing individual card object lifetimes is significantly
more complicated than incrementing/decrementing a number. Thus, the
logic here is slightly different.

Decks now have an `initial_cards` variable which can take card names
(which is most implementers), and for special decks, can specify an
interface that is basically a lazy function for creating a card atom.

When anything needs any real card atom, we just generate them all. The
runtime cost of this is extremely small, and affects neither dev cycles
(the motivation for the change) or ongoing rounds.
2022-11-22 08:21:29 +01:00

27 lines
682 B
Plaintext

/obj/item/toy/cards/deck/blank
name = "custom deck of cards"
desc = "A deck of playing cards that can be customized with writing."
cardgame_desc = "custom card game"
icon_state = "deck_white_full"
deckstyle = "white"
has_unique_card_icons = FALSE
is_standard_deck = FALSE
decksize = 25
can_play_52_card_pickup = FALSE
/obj/item/toy/cards/deck/blank/black
icon_state = "deck_black_full"
deckstyle = "black"
/obj/item/toy/cards/deck/blank/Initialize(mapload)
. = ..()
for(var/_ in 1 to decksize)
initial_cards += /datum/deck_card/blank
/datum/deck_card/blank
name = "blank card"
/datum/deck_card/blank/update_card(obj/item/toy/singlecard/card)
card.blank = TRUE