Files
Bubberstation/code/modules/cards/deck/wizoff.dm
T
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

35 lines
1.6 KiB
Plaintext

//It's Wiz-Off, the wizard themed card game! It's modular too, in case you might want to make it Syndie, Sec and Clown themed or something stupid like that.
/obj/item/toy/cards/deck/wizoff
name = "\improper Wiz-Off deck"
desc = "A Wiz-Off deck. Fight an arcane battle for the fate of the universe: Draw 5! Play 5! Best of 5! A rules card is attached."
cardgame_desc = "Wiz-Off game"
icon_state = "deck_wizoff_full"
deckstyle = "wizoff"
is_standard_deck = FALSE
/obj/item/toy/cards/deck/wizoff/Initialize(mapload)
. = ..()
var/card_list = strings("wizoff.json", "wizard")
initial_cards += new /datum/deck_card/of_type(/obj/item/toy/singlecard/wizoff_ruleset) // ruleset should be the top card
for(var/card in card_list)
initial_cards += card
/obj/item/toy/singlecard/wizoff_ruleset
desc = "A ruleset for the playing card game Wiz-Off."
cardname = "Wizoff Ruleset"
deckstyle = "black"
has_unique_card_icons = FALSE
icon_state = "singlecard_down_black"
/obj/item/toy/singlecard/wizoff_ruleset/examine(mob/living/carbon/human/user)
. = ..()
. += span_notice("Remember the rules of Wiz-Off!")
. += span_info("Each player draws 5 cards.")
. += span_info("There are five rounds. Each round, a player selects a card to play, and the winner is selected based on the following rules:")
. += span_info("Defensive beats Offensive!")
. += span_info("Offensive beats Utility!")
. += span_info("Utility beats Defensive!")
. += span_info("If both players play the same type of spell, the higher number wins!")
. += span_info("The player who wins the most of the 5 rounds wins the game!")
. += span_notice("Now get ready to battle for the fate of the universe: Wiz-Off!")