Skip to content

SMODS.Enhancement

Casimir Eisenach edited this page Feb 6, 2025 · 4 revisions

API Documentation: SMODS.Enhancement

Class prefix: m

  • Required parameters:
  • Optional parameters (defaults):
    • atlas = 'centers', pos = { x = 0, y = 0 } (reference)
    • config = {}, no_collection, prefix_config, dependencies, display_size, pixel_size (reference)
      • The following base values for config are supported and will be scored automatically:
      {
      	bonus,
          bonus_chips,
      	mult,
      	x_mult,
      	p_dollars,
          h_mult,
          h_x_mult,
      }
      • Note: discovered and unlocked on enhancements are currently unsupported.
    • replace_base_card: If true, don't draw base card sprite or give base card chips.
    • no_rank: If true, enhanced card has no rank.
    • no_suit: If true, enhanced card has no suit.
    • overrides_base_rank: If true, enhancement cannot be generated by Grim, Familiar and Incantation (enhancements with no_rank set to true are automatically assigned this property).
    • any_suit: If true, enhanced card counts as any suit.
    • always_scores: If true, enhanced card always counts in scoring.
    • 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) -> number
    • Used to modify the weight of enhancement on certain conditions.
  • 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_pool returns true and all other checks are met.
    • When called from generate_card_ui, the _append key is passed as args.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

  • SMODS.poll_enhancement(args) (defaults)
    • args.key, the key used to generate the seed
    • args.type_key, an optional key used to generate the specific enhancement seed
    • args.mod, multiplying modifier to the base rate (40%)
    • args.guaranteed, if true, enhancement is guaranteed
    • args.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_joker is called for each joker with context = { 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): Returns true if 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).
Clone this wiki locally