-
Notifications
You must be signed in to change notification settings - Fork 6
Deck redeeming
(mechanic from Entropy)
Decks can be redeemed to apply their effects to the current run, mid-run. If a card has a center set to a deck (i.e. Card:set_ability(deck_key)), a button to redeem it can be clicked.
If CardSleeves is installed, sleeves can also be redeemed. For convenient documentation, only decks will be referred to, but many of the principles described here also apply to sleeves.
Note
This API does not implement naturally-occurring deck cards.
To be specific, the following will occur when redeeming a deck:
- The deck's
applyfunction will be called.- If a sleeve is redeemed, the first argument in
applywill point to the sleeve's center. - Otherwise, the first argument is nil.
- If a sleeve is redeemed, the first argument in
- Each value in the deck's
configtable will be interpreted and applied accordingly. - Additional effects are performed for Checkered Deck/Sleeve.
- The following calculation context is sent out:
{
pull_card = true,
card = deck
}The table Spectrallib.deck_config_apply_effects describes how to interpret each value in a deck's config table, depending on the associated key. Values of the table Spectrallib.deck_config_apply_effects are functions of the form function (deck_center, value), where deck_center is an SMODS.Back, and value is the config value.
If your mod adds a custom config key, it is recommended to also add to this table. The following config keys are implemented by default:
handsdiscardsjoker_slothand_sizedollarsspectral_ratejokersvoucherconsumablesvouchersconsumable_slotante_scalingboosters_in_shopno_interestextra_hand_bonusextra_discard_bonusno_facesrandomize_rank_suit
Applies the effects of a redeemed deck. e should be of the following form:
e = {
config = {
ref_table = card
}
}where card is the card that is used to redeem a deck.
Redeems a deck, playing its corresponding animation in the process.
Generates the UI to display redeemed decks in the Run Info menu. Used internally.
This API hooks the following functions:
-
SMODS.calculate_context- In addition to calling the run's deck'scalculatefunction, thecalculatefunction of each redeemed deck is also called. -
Back.trigger_effect- Ditto, for vanilla decks (specifically Anaglyph Deck and Plasma Deck).