Skip to content

Value manipulation

Oinite edited this page Jun 15, 2026 · 1 revision

(mechanic from Cryptlib)

Value manipulation refers to the change of all values on a card's ability table and a playing card's base table. To manipulate the values on a card card, use Spectrallib.manipulate(card, args).

Manipulation types

By default, there are four ways to incorporate some value into each of a card's values (referred here as tbl_value). Given a table args where it defines the fields value a number (unless otherwise specified), and type a string, the manipulation types are as follows:

  • "+" - args.value is added onto each tbl_value
  • "X" - args.value is multiplied with each tbl_value
  • "^" - tbl_value is raised to the power of args.value
  • "hyper" - tbl_value is raised to the hyperpower of args.value, which should now be a table of the form {arrows = number, height = number}.

Alternatively, in args, the field func can be defined to override the manipulation types, allowing for the introduction of a unique method of value manipulation. func must be of the form function(tbl_value, args, is_big, num_key), and return a number.

By default, manipulation will be repeatedly applied onto tbl_value without consideration to its original value. args.dont_stack can be defined as true to temporarily reset tbl_value to its original value.

Value fallback

If args.value is not provided, a pseudorandom value will be chosen from a logarithmically distributed set of numbers. The range of this set is [args.min, args.max], but defaults to [G.GAME.modifiers.cry_misprint_min, G.GAME.modifiers.cry_misprint_max]; both variables default to 1 if undefined.

args.seed can be provided to seed the pseudorandom selection.

Functions

Spectrallib.log_random(seed, min, max) -> number

Selects a random number from a logarithmically distributed range. It is recommended that seed be the output of pseudoseed.

Spectrallib.manipulate(card, args) -> nil

Manipulates card's ability table and base table (where applicable). args is a table that takes the following fields:

  • value - Optional: A number, with some exceptions. If it is not provided, a random value will be generated from a logarithmically distributed range.
  • type - Optional: Determines how value is incorporated into each of a card's values (referred here as original_value). Can be one of the following strings:
    • "+" - value is added onto each original_value
    • "X" - value is multiplied with each original_value
    • "^" - original_value is raised to the power of value
    • "hyper" - original_value is raised to the hyperpower of value, which should now be a table of the form {arrows = number, height = number}.
  • min - Optional: If value is undefined, this is the minimum number for the random value.
  • max - Optional: If value is undefined, this is the maximum number for the random value.
  • seed - Optional: The seed for selecting the aforementioned random value.
  • func - Optional: Overrides type as its own way of incorporating value into each of a card's values.
  • dont_stack - Optional: If true, each of a card's values are temporarily reset before manipulation.
  • no_deck_effects - Optional: (todo figure out what deck_effects are for)
  • bypass_checks - Optional: (todo figure out what deck_effects are for)

Spectrallib.manipulate_table(card, ref_table, ref_value, args) -> nil

Manipulates the value ref_table[ref_value].

  • ref_table is a table in the Card card.
  • args is the same as Spectrallib.manipulate's args.

Spectrallib.manipulate_value(tbl_value, args, is_big, value_key) -> number

Perform a manipulation on some value tbl_value.

  • args is the same as Spectrallib.manipulate's args.
  • is_big is true if the manipulated tbl_value is allowed to be a BigNumber.
  • value_key would be the key mapped to tbl_value in their original table, if this function was called from the aforementioned Spectrallib.manipulate_table.

Clone this wiki locally