SMODS.Scoring_Parameter#
Used to add new scoring parameters that act like chips or mult in the base game
Required parameters:
keydefault_valueDefault value the parameter takes
Optional parameters (defaults):
prefix_config, dependencies(reference)colour = G.C.UI_MULT: Colour of the parameter in the game’s UIcalculation_keys: Validcalculatereturns for this parameter.hands: Defines the values this parameter takes for each Poker Hand.Each value in this table must be in the form
PokerHandKey = { modprefix_key = number, l_modprefix_key = number, s_modprefix_key = number }wheremodprefix_key(using your mod’s prefix and parameter’s key) is the starting value that is updated when levelled up,s_modprefix_keyis the starting value that is used for level up calculations andl_modprefix_keyis the amount gained when levelled up. The basic formula to calculate the amount isvalue = s_value + (level-1) * l_value.Example:
-- This parameter is only applied to hands that contain a flush. They all scale the same way hands = { ["Flush Five"] = {modprefix_key = 1, l_modprefix_key = 5, s_modprefix_key = 1}, ["Flush House"] = {modprefix_key = 1, l_modprefix_key = 5, s_modprefix_key = 1}, ["Straight Flush"] = {modprefix_key = 1, l_modprefix_key = 5, s_modprefix_key = 1}, ["Flush"] = {modprefix_key = 1, l_modprefix_key = 5, s_modprefix_key = 1}, }
API methods#
modify(self, amount)Used for custom behaviour when the parameter is modified. Do note that this function also updates the UI elements, so if you redefine it you should ensure that you keep this functionality.
If not defined, it simply adds
amountto the current value.Example of custom behaviour:
-- Parameter that doesn't reset each hand modify = function(self, amount) self.current = self.current + amount -- update the current value, used for final score calculation self.default_value = self.current -- update the default value update_hand_text({delay = 0}, {[self.key] = self.current}) -- update the UI end
calc_effect(self, effect, scored_card, key, amount, from_edition)Used for custom behaviour when a calculation key for the parameter is returned in
calculate.effect: Return table for that calculationscored_card: Card or object being scoredkey: The return key being calculatedamount: The value returned for that keyfrom_edition:trueif the effect comes from an edition
If not defined, it calls
modifywith theamount, juices up the scoring card and plays a default message on it.For more examples of how to use this function, take a look at the
chipsandmultScoring Parameters insrc/game_object.lua, orSMODS.calculate_individual_effectinsrc/utils.lua.
Util methods#
SMODS.get_scoring_parameter(key, flames)Gets the current value for the scoring parameter
key.flameis an flag to get the current value for flame animations.
SMODS.Scoring_Calculation#
Used to add new scoring calculation behavious between chips and mult.
Required parameters:
keyfunc(self, chips, mult, flames) -> numberCalculates the current score.
chipsandmultare the current value of those parameters andflamesistruewhen the score is being calculated for flame animations.To obtain any other scoring parameters in this function you can call
SMODS.get_scoring_parameter(key, flames).flamesmust be passed as the second argument for animations to work correctlyExample:
-- Substraction scoring calculation func = function(self, chips, mult, flames) return chips - mult end
Optional parameters (defaults):
prefix_config, dependencies(reference)text = 'X': Replaces the “X” symbol on the UI between the chips and mult boxescolour = G.C.RED: Sets the colour for the UI symbolconfig: Table for values that persist during the run. You can access it by usingself.configin the Scoring Calculation’s functions, orG.GAME.current_scoring_calculation.configanywhere else.parameters = {'chips', 'mult'}: A list of scoring parameters this Scoring Calculation applies to, anycalculatereturn for any other parameter will be ignored.
API methods#
replace_ui(self) -> tableUsed to replace the UI for the hand scoring boxes. Returns a UI node table. See
SMODS.GUI.hand_chips_containerinsrc/ui.luafor an example.
update_ui(self, container, chip_display, mult_display, operator)Called when the UI for the scoring boxes is being updated.
containeris the UIElement that contains the entire UI, whilechip_display,mult_displayandoperatorare the UIElements for the chip box, mult box and operator symbol respectively.Call
operator.UIBox:recalculate()to actually update the UI when you do any modification.
Util methods#
SMODS.set_scoring_calculation(key)Sets the current Scoring Calculation.
multiply(vanilla behaviour),addandexponentare already defined by SMODS.
SMODS.calculate_round_score(flames)Calculates the current hand score based on the current Scoring Calculation.
flamesis an internal flag used for flame animations.