mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-06-05 22:31:04 +01:00
ad929ac3a9
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.
22 lines
788 B
Plaintext
22 lines
788 B
Plaintext
/obj/item/toy/cards/deck/kotahi
|
|
name = "\improper KOTAHI deck"
|
|
desc = "A deck of kotahi cards. House rules to argue over not included."
|
|
cardgame_desc = "KOTAHI game"
|
|
icon_state = "deck_kotahi_full"
|
|
deckstyle = "kotahi"
|
|
is_standard_deck = FALSE
|
|
|
|
/obj/item/toy/cards/deck/kotahi/Initialize(mapload)
|
|
. = ..()
|
|
for(var/colour in list("Red","Yellow","Green","Blue"))
|
|
initial_cards += "[colour] 0" //kotahi decks have only one colour of each 0, weird huh?
|
|
for(var/k in 0 to 1) //two of each colour of number
|
|
initial_cards += "[colour] skip"
|
|
initial_cards += "[colour] reverse"
|
|
initial_cards += "[colour] draw 2"
|
|
for(var/i in 1 to 9)
|
|
initial_cards += "[colour] [i]"
|
|
for(var/k in 0 to 3) //4 wilds and draw 4s
|
|
initial_cards += "Wildcard"
|
|
initial_cards += "Draw 4"
|