SMODS.Enhancement#
Class prefix: m
Required parameters:
keyloc_txtor localization entry (reference)
Optional parameters (defaults):
atlas = 'centers', pos = { x = 0, y = 0 }, soul_pos, soul_atlas(reference)config = {}, no_collection, prefix_config, dependencies, display_size, pixel_size, badge_colour, badge_text_colour(reference)The following base values for
configare supported and will be scored automatically and unconditionally:{ bonus, -- Extra chips x_chips, -- Chips multiplier, nil (not defined), 0 or 1 is treated as 1. mult, -- Extra additive mult x_mult, -- Mult multiplier, nil (not defined), 0 or 1 is treated as 1. h_chips, -- Chips when held in hand during scoring h_x_chips, -- Chips multiplier when held in hand during scoring, nil (not defined), 0 or 1 is treated as 1. h_mult, -- Additive mult when held in hand during scoring h_x_mult, -- Mult multiplier when held in hand during scoring, nil (not defined), 0 or 1 is treated as 1. p_dollars -- Dollars granted when scored h_dollars -- Dollars granted when held in hand at the end of the round }
For conditionally granting any of these values, use a
calculatefunction instead!Note:
discoveredandunlockedon enhancements are currently unsupported.
pools: List of keys to ObjectTypes this center should be injected intoExpects a list of keys like this:
{ ["Foo"] = true, ["Bar"] = true, }
replace_base_card: Iftrue, don’t draw base card sprite or give base card chips.no_rank: Iftrue, enhanced card has no rank.no_suit: Iftrue, enhanced card has no suit.overrides_base_rank: Iftrue, enhancement cannot be generated by Grim, Familiar and Incantation (enhancements withno_rankset to true are automatically assigned this property).any_suit: Iftrue, enhanced card counts as any suit.shatters: Iftrue, enhanced card breaks on destruction like a Glass Card.always_scores: Iftrue, enhanced card always counts in scoring.never_scores: Iftrue, enhanced card never counts in scoring (supersedesalways_scores).weight: The weighting of the enhancement, follows same rules as other weighted objects (default weight is 5).
API methods#
calculate(self, card, context)(reference)loc_vars, locked_loc_vars, generate_ui(reference)get_weight(self) -> numberReturns weight. Use for finer control over the enhancement’s weight.
set_ability(self, card, initial, delay_sprites)Set up initial ability values or manipulate sprites in an advanced way.
in_pool(self, args) -> bool, { allow_duplicates = bool }Define custom logic for when a card is allowed to spawn. A card can spawn if
in_poolreturns true and all other checks are met.When called from
get_current_pool, the_appendkey is passed asargs.source.
update(self, card, dt)For actions that happen every frame.
set_sprites(self, card, front)For advanced sprite manipulation that happens when a card is created or loaded.
set_badges(self, card, badges)Add additional badges, leaving existing badges intact. This function doesn’t return; add badges by appending to
badges.Avoid overwriting existing elements. It will cause text to appear on the top left corner of your screen instead.
Function for creating badges:
create_badge(_string, _badge_col, _text_col, scaling)_string: Text displayed on the badge._badge_col = G.C.GREEN: Background colour._text_col = G.C.WHITE: Text colour._scaling = 1: Relative size of the badge.
Example:
{ set_badges = function(self, card, badges) badges[#badges+1] = create_badge(localize('k_your_string'), G.C.RED, G.C.BLACK, 1.2 ) end, }
set_card_type_badge(self, card, badges)Same as
set_badges, but bypasses creation of the card type / rarity badge, allowing you to replace it with a custom one.
draw(self, card, layer)Draws the sprite and shader of the card.
Util methods#
Card:set_ability(center, initial, delay_sprites):Used for changing the center of a card, you can use this function to set an enhancement.
center: key of the enhancement to turn the card into (usec_basefor no enhancement).initial: boolean (advanced) internal value for when the card is createddelay_sprites: boolean delays the visuals of the enhancement, useful for applying enhancements during calculations
SMODS.poll_enhancement(args)(defaults)args.key, the key used to generate the seedargs.type_key, an optional key used to generate the specific enhancement seedargs.mod, multiplying modifier to the base rate (40%)args.guaranteed, iftrue, enhancement is guaranteedargs.options, can be used to provide fixed options to the pool{ keys }, a table of keys as strings, respects original weight values{ {key = string, weight = number} }, a table of tables, with key and weight pairs
SMODS.get_enhancements(card, extra_only): Returns a table indexed by keys of enhancements that the given card has.Card:calculate_jokeris called for each joker withcontext = { check_enhancement = true, other_card = card }, expecting return tables in the same format to add extra enhancements. No other ways to give a card multiple enhancements are currently supported.If
extra_only == true, the card’s base enhancement is excluded.
SMODS.has_enhancement(card, key): Returnstrueif the given card has the specified enhancement, either as its natural enhancement or an extra enhancement from jokers.SMODS.has_no_suit(card): Returns true if a card doesn’t have any suit due to its enhancements (e.g., Stone Cards).SMODS.has_any_suit(card): Returns true if a card can be used as any suit due to its enhancements (e.g., Wild Cards).Cards with enhancement effects both for having no suit and for having any suit can be used as any suit.
SMODS.has_no_rank(card): Returns true if a card doesn’t have any rank due to its enhancements (e.g., Stone Cards).SMODS.always_scores(card): Returns true if a card always scores due to its enhancements (e.g., Stone Cards).SMODS.never_scores(card): Returns true if the card cannot be scored.