mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-02-07 06:48:44 +00:00
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.
36 lines
1.5 KiB
Plaintext
36 lines
1.5 KiB
Plaintext
// CARDS AGAINST SPESS
|
|
// This is a parody of Cards Against Humanity (https://en.wikipedia.org/wiki/Cards_Against_Humanity)
|
|
// which is licensed under CC BY-NC-SA 2.0, the full text of which can be found at the following URL:
|
|
// https://creativecommons.org/licenses/by-nc-sa/2.0/legalcode
|
|
// Original code by Zuhayr, Polaris Station, ported with modifications
|
|
/obj/item/toy/cards/deck/cas
|
|
name = "\improper CAS deck (white)"
|
|
desc = "A deck for the game Cards Against Spess, still popular after all these centuries. Warning: may include traces of broken fourth wall. This is the white deck."
|
|
cardgame_desc = "Cards Against Spess game"
|
|
icon_state = "deck_white_full"
|
|
deckstyle = "white"
|
|
has_unique_card_icons = FALSE
|
|
is_standard_deck = FALSE
|
|
decksize = 150
|
|
can_play_52_card_pickup = FALSE
|
|
|
|
/obj/item/toy/cards/deck/cas/black
|
|
name = "\improper CAS deck (black)"
|
|
desc = "A deck for the game Cards Against Spess, still popular after all these centuries. Warning: may include traces of broken fourth wall. This is the black deck."
|
|
icon_state = "deck_black_full"
|
|
deckstyle = "black"
|
|
decksize = 50
|
|
|
|
GLOBAL_LIST_INIT(card_decks, list(
|
|
black = world.file2list("strings/cas_black.txt"),
|
|
white = world.file2list("strings/cas_white.txt")
|
|
))
|
|
|
|
/obj/item/toy/cards/deck/cas/Initialize(mapload)
|
|
. = ..()
|
|
var/list/cards_against_space = GLOB.card_decks[deckstyle]
|
|
var/list/possible_cards = cards_against_space.Copy()
|
|
|
|
for(var/i in 1 to decksize)
|
|
initial_cards += pick_n_take(possible_cards)
|