diff --git a/.gitignore b/.gitignore index 906cf67..063b3c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -**/lovely*.log \ No newline at end of file +**/lovely*.log +lovely/ \ No newline at end of file diff --git a/lovely/dump/back.lua b/lovely/dump/back.lua index 11de902..997b2bc 100644 --- a/lovely/dump/back.lua +++ b/lovely/dump/back.lua @@ -1,4 +1,4 @@ -LOVELY_INTEGRITY = 'cd00b45ad63b1eaa00d4924a1eed9a6a330e531d1440767ad8b6703f1eec6dbf' +LOVELY_INTEGRITY = 'd3c881055f5938773f6b44e7c8b207117963612b2eaf889f5b7ef8b61e1143cd' --Class Back = Object:extend() @@ -130,16 +130,9 @@ end function Back:trigger_effect(args) if not args then return end local obj = self.effect.center - if type(obj.calculate) == 'function' then - local o = {obj:calculate(self, args)} - if next(o) ~= nil then return unpack(o) end - elseif type(obj.trigger_effect) == 'function' then - -- kept for compatibility + if obj.trigger_effect and type(obj.trigger_effect) == 'function' then local o = {obj:trigger_effect(args)} - if next(o) ~= nil then - sendWarnMessage(('Found `trigger_effect` function on SMODS.Back object "%s". This field is deprecated; please use `calculate` instead.'):format(obj.key), 'Back') - return unpack(o) - end + if o then return unpack(o) end end if self.name == 'Anaglyph Deck' and args.context == 'eval' and G.GAME.last_blind and G.GAME.last_blind.boss then @@ -208,33 +201,14 @@ end function Back:apply_to_run() local obj = self.effect.center if obj.apply and type(obj.apply) == 'function' then - obj:apply(self) + obj:apply() end - if self.effect.config.jokers then - delay(0.4) - G.E_MANAGER:add_event(Event({ - func = function() - for k, v in ipairs(self.effect.config.jokers) do - local card = create_card('Joker', G.jokers, nil, nil, nil, nil, v, 'deck') - card:add_to_deck() - G.jokers:emplace(card) - card:start_materialize() - end - return true - end - })) - end if self.effect.config.voucher then G.GAME.used_vouchers[self.effect.config.voucher] = true G.GAME.cry_owned_vouchers[self.effect.config.voucher] = true G.GAME.starting_voucher_count = (G.GAME.starting_voucher_count or 0) + 1 - G.E_MANAGER:add_event(Event({ - func = function() - Card.apply_to_run(nil, G.P_CENTERS[self.effect.config.voucher]) - return true - end - })) + Card.apply_to_run(nil, G.P_CENTERS[self.effect.config.voucher]) end if self.effect.config.hands then G.GAME.starting_params.hands = G.GAME.starting_params.hands + self.effect.config.hands @@ -292,12 +266,7 @@ function Back:apply_to_run() G.GAME.used_vouchers[v ] = true G.GAME.cry_owned_vouchers[v ] = true G.GAME.starting_voucher_count = (G.GAME.starting_voucher_count or 0) + 1 - G.E_MANAGER:add_event(Event({ - func = function() - Card.apply_to_run(nil, G.P_CENTERS[v]) - return true - end - })) + Card.apply_to_run(nil, G.P_CENTERS[v]) end end if self.name == 'Checkered Deck' then diff --git a/lovely/dump/blind.lua b/lovely/dump/blind.lua index 1a7d1ae..3559228 100644 --- a/lovely/dump/blind.lua +++ b/lovely/dump/blind.lua @@ -1,4 +1,4 @@ -LOVELY_INTEGRITY = '2c00c26e55b0f21d108e0353b98757a950fc433f1f9951ac8a454c589450b12c' +LOVELY_INTEGRITY = 'ceaf7d365cb8eac62c7dcf3be1ef07cc6b0dac3977bde52960496d7f844a668d' --class Blind = Moveable:extend() @@ -606,7 +606,7 @@ function Blind:debuff_hand(cards, hand, handname, check) end if self.name == 'The Arm' then self.triggered = false - if to_big(G.GAME.hands[handname].level) > to_big(1) then + if G.GAME.hands[handname].level > 1 then self.triggered = true if not check then level_up_hand(self.children.animatedSprite, handname, nil, -1) diff --git a/lovely/dump/card.lua b/lovely/dump/card.lua index 4cc4096..8cb98aa 100644 --- a/lovely/dump/card.lua +++ b/lovely/dump/card.lua @@ -1,4 +1,4 @@ -LOVELY_INTEGRITY = 'b7b1bb9e3088ca71ed96c4b7bdaf1ec1c67106c37ba37b8f4aef385f8743a60b' +LOVELY_INTEGRITY = 'd333bdf58ea96ab32bdb8d74d1b3a666732aeed72e1f1374e45a87d167ad1109' --class Card = Moveable:extend() @@ -46,9 +46,9 @@ function Card:init(X, Y, W, H, card, center, params) self:set_base(card, true) self.discard_pos = { - r = 0, - x = 0, - y = 0, + r = 3.6*(math.random()-0.5), + x = math.random(), + y = math.random() } self.facing = 'front' @@ -227,12 +227,6 @@ function Card:set_sprites(_center, _front) if _center.name == 'Square Joker' and (_center.discovered or self.bypass_discovery_center) then self.children.center.scale.y = self.children.center.scale.x end - if _center.pixel_size and _center.pixel_size.h and (_center.discovered or self.bypass_discovery_center) then - self.children.center.scale.y = self.children.center.scale.y*(_center.pixel_size.h/95) - end - if _center.pixel_size and _center.pixel_size.w and (_center.discovered or self.bypass_discovery_center) then - self.children.center.scale.x = self.children.center.scale.x*(_center.pixel_size.w/71) - end end if _center.soul_pos then @@ -347,20 +341,6 @@ function Card:set_ability(center, initial, delay_sprites) self.T.h = H self.T.w = W end - if center.display_size and center.display_size.h and (center.discovered or self.bypass_discovery_center) then - H = H*(center.display_size.h/95) - self.T.h = H - elseif center.pixel_size and center.pixel_size.h and (center.discovered or self.bypass_discovery_center) then - H = H*(center.pixel_size.h/95) - self.T.h = H - end - if center.display_size and center.display_size.w and (center.discovered or self.bypass_discovery_center) then - W = W*(center.display_size.w/71) - self.T.w = W - elseif center.pixel_size and center.pixel_size.w and (center.discovered or self.bypass_discovery_center) then - W = W*(center.pixel_size.w/71) - self.T.w = W - end if delay_sprites then G.E_MANAGER:add_event(Event({ @@ -477,6 +457,7 @@ function Card:set_ability(center, initial, delay_sprites) self.ability.loyalty_remaining = self.ability.extra.every end + self.ability.cry_prob = 1 self.base_cost = center.cost or 1 self.ability.hands_played_at_create = G.GAME and G.GAME.hands_played or 0 @@ -628,14 +609,6 @@ function Card:set_seal(_seal, silent, immediate) self.seal = nil if _seal then self.seal = _seal - self.ability.seal = {} - for k, v in pairs(G.P_SEALS[_seal].config or {}) do - if type(v) == 'table' then - self.ability.seal[k] = copy_table(v) - else - self.ability.seal[k] = v - end - end if not silent then G.CONTROLLER.locks.seal = true local sound = G.P_SEALS[_seal].sound or {sound = 'gold_seal', per = 1.2, vol = 0.4} @@ -908,21 +881,10 @@ function Card:generate_UIBox_unlock_table(hidden) return generate_card_ui(self.config.center, nil, loc_vars, 'Locked') end -function Card:generate_UIBox_ability_table(vars_only) +function Card:generate_UIBox_ability_table() local card_type, hide_desc = self.ability.set or "None", nil local loc_vars = nil local main_start, main_end = nil,nil - if self.ability.name == 'cry-Machine Code' then - --"Create a random // glitched consumable" - main_start = { - randomchar(codechars6), - randomchar(codechars6), - randomchar(codechars6), - randomchar(codechars6), - randomchar(codechars6), - randomchar(codechars6), - } - end local no_badge = nil if not self.bypass_lock and self.config.center.unlocked ~= false and @@ -957,7 +919,7 @@ function Card:generate_UIBox_ability_table(vars_only) elseif self.ability.name == 'Fortune Teller' then loc_vars = {self.ability.extra, (G.GAME.consumeable_usage_total and G.GAME.consumeable_usage_total.tarot or 0)} elseif self.ability.name == 'Steel Joker' then loc_vars = {self.ability.extra, 1 + self.ability.extra*(self.ability.steel_tally or 0)} elseif self.ability.name == 'Chaos the Clown' then loc_vars = {self.ability.extra} - elseif self.ability.name == 'Space Joker' then loc_vars = {''..(G.GAME and G.GAME.probabilities.normal or 1), self.ability.extra} + elseif self.ability.name == 'Space Joker' then loc_vars = {cry_prob(self.ability.cry_prob, self.ability.extra, self.ability.cry_rigged), self.ability.extra} elseif self.ability.name == 'Stone Joker' then loc_vars = {self.ability.extra, self.ability.extra*(self.ability.stone_tally or 0)} elseif self.ability.name == 'Drunkard' then loc_vars = {self.ability.d_size} elseif self.ability.name == 'Green Joker' then loc_vars = {self.ability.extra.hand_add, self.ability.extra.discard_sub, self.ability.mult} @@ -977,18 +939,6 @@ function Card:generate_UIBox_ability_table(vars_only) elseif self.ability.name == 'Four Fingers' then elseif self.ability.name == 'Ceremonial Dagger' then loc_vars = {self.ability.mult} elseif self.ability.name == 'Banner' then loc_vars = {self.ability.extra} - elseif self.ability.name == 'cry-Error' then - if G.GAME and G.GAME.pseudorandom and G.STAGE == G.STAGES.RUN then - cry_error_msgs[#cry_error_msgs].string = "%%" .. predict_card_for_shop() - else - cry_error_msgs[#cry_error_msgs].string = "%%J6" - end - main_start = { - {n=G.UIT.O, config={object = DynaText({string = cry_error_operators, colours = {G.C.DARK_EDITION,},pop_in_rate = 9999999, silent = true, random_element = true, pop_delay = 0.30, scale = 0.32, min_cycle_time = 0})}}, - {n=G.UIT.O, config={object = DynaText({string = cry_error_numbers, colours = {G.C.DARK_EDITION,},pop_in_rate = 9999999, silent = true, random_element = true, pop_delay = 0.33, scale = 0.32, min_cycle_time = 0})}}, - {n=G.UIT.O, config={object = DynaText({string = cry_error_msgs, - colours = {G.C.UI.TEXT_DARK},pop_in_rate = 9999999, silent = true, random_element = true, pop_delay = 0.4011, scale = 0.32, min_cycle_time = 0})}}, - } elseif self.ability.name == 'Misprint' then local r_mults = {} for i = self.ability.extra.min, self.ability.extra.max do @@ -1006,18 +956,18 @@ function Card:generate_UIBox_ability_table(vars_only) elseif self.ability.name == 'Mystic Summit' then loc_vars = {self.ability.extra.mult, self.ability.extra.d_remaining} elseif self.ability.name == 'Marble Joker' then elseif self.ability.name == 'Loyalty Card' then loc_vars = {self.ability.extra.Xmult, self.ability.extra.every + 1, localize{type = 'variable', key = (self.ability.loyalty_remaining == 0 and 'loyalty_active' or 'loyalty_inactive'), vars = {self.ability.loyalty_remaining}}} - elseif self.ability.name == '8 Ball' then loc_vars = {''..(G.GAME and G.GAME.probabilities.normal or 1),self.ability.extra} + elseif self.ability.name == '8 Ball' then loc_vars = {cry_prob(self.ability.cry_prob, self.ability.extra, self.ability.cry_rigged),self.ability.extra} elseif self.ability.name == 'Dusk' then loc_vars = {self.ability.extra+1} elseif self.ability.name == 'Raised Fist' then elseif self.ability.name == 'Fibonacci' then loc_vars = {self.ability.extra} elseif self.ability.name == 'Scary Face' then loc_vars = {self.ability.extra} elseif self.ability.name == 'Abstract Joker' then loc_vars = {self.ability.extra, (G.jokers and G.jokers.cards and #G.jokers.cards or 0)*self.ability.extra} elseif self.ability.name == 'Delayed Gratification' then loc_vars = {self.ability.extra} - elseif self.ability.name == 'Gros Michel' then loc_vars = {self.ability.extra.mult, ''..(G.GAME and G.GAME.probabilities.normal or 1), self.ability.extra.odds} + elseif self.ability.name == 'Gros Michel' then loc_vars = {self.ability.extra.mult, cry_prob(self.ability.cry_prob, self.ability.extra.odds, self.ability.cry_rigged), self.ability.extra.odds} elseif self.ability.name == 'Even Steven' then loc_vars = {self.ability.extra} elseif self.ability.name == 'Odd Todd' then loc_vars = {self.ability.extra} elseif self.ability.name == 'Scholar' then loc_vars = {self.ability.extra.mult, self.ability.extra.chips} - elseif self.ability.name == 'Business Card' then loc_vars = {''..(G.GAME and G.GAME.probabilities.normal or 1), self.ability.extra} + elseif self.ability.name == 'Business Card' then loc_vars = {cry_prob(self.ability.cry_prob, self.ability.extra, self.ability.cry_rigged),self.ability.extra} elseif self.ability.name == 'Supernova' then elseif self.ability.name == 'Spare Trousers' then loc_vars = {self.ability.extra, localize('Two Pair', 'poker_hands'), self.ability.mult} elseif self.ability.name == 'Superposition' then loc_vars = {self.ability.extra} @@ -1033,7 +983,7 @@ function Card:generate_UIBox_ability_table(vars_only) elseif self.ability.name == 'Hiker' then loc_vars = {self.ability.extra} elseif self.ability.name == 'To Do List' then loc_vars = {self.ability.extra.dollars, localize(self.ability.to_do_poker_hand, 'poker_hands')} elseif self.ability.name == 'Smeared Joker' then - elseif self.ability.name == 'Blueprint' or self.ability.name == 'cry-oldblueprint' then + elseif self.ability.name == 'Blueprint' then self.ability.blueprint_compat_ui = self.ability.blueprint_compat_ui or ''; self.ability.blueprint_compat_check = nil main_end = (self.area and self.area == G.jokers) and { {n=G.UIT.C, config={align = "bm", minh = 0.4}, nodes={ @@ -1055,7 +1005,7 @@ function Card:generate_UIBox_ability_table(vars_only) elseif self.ability.name == 'Throwback' then loc_vars = {self.ability.extra, self.ability.x_mult} elseif self.ability.name == 'Hanging Chad' then loc_vars = {self.ability.extra} elseif self.ability.name == 'Rough Gem' then loc_vars = {self.ability.extra} - elseif self.ability.name == 'Bloodstone' then loc_vars = {''..(G.GAME and G.GAME.probabilities.normal or 1), self.ability.extra.odds, self.ability.extra.Xmult} + elseif self.ability.name == 'Bloodstone' then loc_vars = {cry_prob(self.ability.cry_prob, self.ability.extra.odds, self.ability.cry_rigged), self.ability.extra.odds, self.ability.extra.Xmult} elseif self.ability.name == 'Arrowhead' then loc_vars = {self.ability.extra} elseif self.ability.name == 'Onyx Agate' then loc_vars = {self.ability.extra} elseif self.ability.name == 'Glass Joker' then loc_vars = {self.ability.extra, self.ability.x_mult} @@ -1070,7 +1020,7 @@ function Card:generate_UIBox_ability_table(vars_only) elseif self.ability.name == 'The Duo' or self.ability.name == 'The Trio' or self.ability.name == 'The Family' or self.ability.name == 'The Order' or self.ability.name == 'The Tribe' then loc_vars = {self.ability.x_mult, localize(self.ability.type, 'poker_hands')} - elseif self.ability.name == 'Cavendish' then loc_vars = {self.ability.extra.Xmult, ''..(G.GAME and G.GAME.probabilities.normal or 1), self.ability.extra.odds} + elseif self.ability.name == 'Cavendish' then loc_vars = {self.ability.extra.Xmult, cry_prob(self.ability.cry_prob, self.ability.extra.odds, self.ability.cry_rigged), self.ability.extra.odds} elseif self.ability.name == 'Card Sharp' then loc_vars = {self.ability.extra.Xmult} elseif self.ability.name == 'Red Card' then loc_vars = {self.ability.extra, self.ability.mult} elseif self.ability.name == 'Madness' then loc_vars = {self.ability.extra, self.ability.x_mult} @@ -1102,10 +1052,10 @@ function Card:generate_UIBox_ability_table(vars_only) elseif self.ability.name == 'Gift Card' then loc_vars = {self.ability.extra} elseif self.ability.name == 'Turtle Bean' then loc_vars = {self.ability.extra.h_size, self.ability.extra.h_mod} elseif self.ability.name == 'Erosion' then loc_vars = {self.ability.extra, math.max(0,self.ability.extra*(G.playing_cards and (G.GAME.starting_deck_size - #G.playing_cards) or 0)), G.GAME.starting_deck_size} - elseif self.ability.name == 'Reserved Parking' then loc_vars = {self.ability.extra.dollars, ''..(G.GAME and G.GAME.probabilities.normal or 1), self.ability.extra.odds} + elseif self.ability.name == 'Reserved Parking' then loc_vars = {self.ability.extra.dollars, cry_prob(self.ability.cry_prob, self.ability.extra.odds, self.ability.cry_rigged), self.ability.extra.odds} elseif self.ability.name == 'Mail-In Rebate' then loc_vars = {self.ability.extra, localize(G.GAME.current_round.mail_card.rank, 'ranks')} elseif self.ability.name == 'To the Moon' then loc_vars = {self.ability.extra} - elseif self.ability.name == 'Hallucination' then loc_vars = {G.GAME.probabilities.normal, self.ability.extra} + elseif self.ability.name == 'Hallucination' then loc_vars = {cry_prob(self.ability.cry_prob, self.ability.extra, self.ability.cry_rigged), self.ability.extra} elseif self.ability.name == 'Lucky Cat' then loc_vars = {self.ability.extra, self.ability.x_mult} elseif self.ability.name == 'Baseball Card' then loc_vars = {self.ability.extra} elseif self.ability.name == 'Bull' then loc_vars = {self.ability.extra, self.ability.extra*math.max(0,G.GAME.dollars) or 0} @@ -1122,7 +1072,7 @@ function Card:generate_UIBox_ability_table(vars_only) elseif self.ability.name == 'Campfire' then loc_vars = {self.ability.extra, self.ability.x_mult} elseif self.ability.name == 'Stuntman' then loc_vars = {self.ability.extra.chip_mod, self.ability.extra.h_size} elseif self.ability.name == 'Invisible Joker' then loc_vars = {self.ability.extra, self.ability.invis_rounds} - elseif self.ability.name == 'Brainstorm' or self.config.center.key == 'j_cry_gemino' then + elseif self.ability.name == 'Brainstorm' then self.ability.blueprint_compat_ui = self.ability.blueprint_compat_ui or ''; self.ability.blueprint_compat_check = nil main_end = (self.area and self.area == G.jokers) and { {n=G.UIT.C, config={align = "bm", minh = 0.4}, nodes={ @@ -1146,7 +1096,6 @@ function Card:generate_UIBox_ability_table(vars_only) elseif self.ability.name == 'Perkeo' then loc_vars = {self.ability.extra} end end - if vars_only then return loc_vars, main_start, main_end end local badges = {} if (card_type ~= 'Locked' and card_type ~= 'Undiscovered' and card_type ~= 'Default') or self.debuff then badges.card_type = card_type @@ -1164,7 +1113,7 @@ function Card:generate_UIBox_ability_table(vars_only) end end if self.seal then badges[#badges + 1] = string.lower(self.seal)..'_seal' end - if self.ability.eternal then badges[#badges + 1] = 'eternal' end + if self.ability.eternal and not self.ability.cry_absolute then badges[#badges + 1] = 'eternal' end if self.ability.perishable and not layer then loc_vars = loc_vars or {}; loc_vars.perish_tally=self.ability.perish_tally badges[#badges + 1] = 'perishable' @@ -1239,7 +1188,7 @@ function Card:get_chip_mult() if self.debuff then return 0 end if self.ability.set == 'Joker' then return 0 end if self.ability.effect == "Lucky Card" then - if pseudorandom('lucky_mult') < G.GAME.probabilities.normal/5 then + if pseudorandom('lucky_mult') < cry_prob(self.ability.cry_prob, 5, self.ability.cry_rigged)/5 then self.lucky_trigger = true return self.ability.mult else @@ -1271,6 +1220,9 @@ function Card:get_edition() if self.debuff then return end if self.edition then local ret = {card = self} + if self.edition.p_dollars then + ret.p_dollars_mod = self.edition.p_dollars + end if self.edition.x_mult then ret.x_mult_mod = self.edition.x_mult end @@ -1330,7 +1282,7 @@ function Card:get_p_dollars() end if self.ability.p_dollars > 0 then if self.ability.effect == "Lucky Card" then - if pseudorandom('lucky_money') < G.GAME.probabilities.normal/15 then + if pseudorandom('lucky_money') < cry_prob(self.ability.cry_prob, 15, self.ability.cry_rigged)/15 then self.lucky_trigger = true ret = ret + self.ability.p_dollars end @@ -1686,7 +1638,10 @@ function Card:use_consumeable(area, copier) ease_dollars(self.ability.extra.dollars) end delay(0.3) - SMODS.calculate_context({ remove_playing_cards = true, removed = destroyed_cards }) + for i = 1, #G.jokers.cards do + G.jokers.cards[i]:calculate_joker({remove_playing_cards = true, removed = destroyed_cards}) + end + G.GAME.selected_back:trigger_effect({context = 'remove_playing_cards', removed = destroyed_cards}) end if self.ability.name == 'The Fool' then G.E_MANAGER:add_event(Event({trigger = 'after', delay = 0.4, func = function() @@ -1785,7 +1740,7 @@ function Card:use_consumeable(area, copier) if self.ability.name == 'The Wheel of Fortune' or self.ability.name == 'Ectoplasm' or self.ability.name == 'Hex' then local temp_pool = (self.ability.name == 'The Wheel of Fortune' and self.eligible_strength_jokers) or ((self.ability.name == 'Ectoplasm' or self.ability.name == 'Hex') and self.eligible_editionless_jokers) or {} - if self.ability.name == 'Ectoplasm' or self.ability.name == 'Hex' or pseudorandom('wheel_of_fortune') < G.GAME.probabilities.normal/self.ability.extra then + if self.ability.name == 'Ectoplasm' or self.ability.name == 'Hex' or pseudorandom('wheel_of_fortune') < cry_prob(self.ability.cry_prob, self.ability.extra, self.ability.cry_rigged)/self.ability.extra then if self.ability.name == 'The Wheel of Fortune' then self.cry_wheel_success = true end G.E_MANAGER:add_event(Event({trigger = 'after', delay = 0.4, func = function() local over = false @@ -1931,8 +1886,18 @@ function Card:sell_card() if self.children.use_button then self.children.use_button:remove(); self.children.use_button = nil end if self.children.sell_button then self.children.sell_button:remove(); self.children.sell_button = nil end - local eval, post = eval_card(self, {selling_self = true}) - SMODS.trigger_effects({eval, post}, self) + if self.config.center.set == 'Joker' then + if G.GAME.jokers_sold then + local contained = false + for i = 1, #G.GAME.jokers_sold do + if self.config.center.key == G.GAME.jokers_sold[i] then contained = true end + end + if not contained then table.insert(G.GAME.jokers_sold, self.config.center.key) end + else + G.GAME.jokers_sold = {self.config.center.key} + end + end + self:calculate_joker{selling_self = true} G.E_MANAGER:add_event(Event({trigger = 'after', delay = 0.2,func = function() if not G.GAME.modifiers.cry_no_sell_value then play_sound('coin2') end @@ -1990,14 +1955,15 @@ end function Card:calculate_dollar_bonus() if self.debuff then return end - local obj = self.config.center - if obj.calc_dollar_bonus and type(obj.calc_dollar_bonus) == 'function' then - return obj:calc_dollar_bonus(self) - end if self.ability.set == "Joker" then if self.ability.name == 'Golden Joker' then return self.ability.extra end + --asdf + local obj = self.config.center + if obj.calc_dollar_bonus and type(obj.calc_dollar_bonus) == 'function' then + return obj:calc_dollar_bonus(self) + end if self.ability.name == 'Cloud 9' and self.ability.nine_tally and self.ability.nine_tally > 0 then return self.ability.extra*(self.ability.nine_tally) end @@ -2051,6 +2017,7 @@ function Card:open() end G.GAME.pack_choices = self.config.center.config.choose or 1 + G.GAME.pack_choices = ((self.ability.choose and self.ability.extra) and math.min(math.floor(self.ability.extra), self.ability.choose)) or 1 if G.GAME.modifiers.cry_misprint_min then G.GAME.pack_size = self.ability.extra if G.GAME.pack_size < 1 then G.GAME.pack_size = 1 end @@ -2187,7 +2154,10 @@ end end end})) - SMODS.calculate_context({open_booster = true, card = self}) + for i = 1, #G.jokers.cards do + G.jokers.cards[i]:calculate_joker({open_booster = true, card = self}) + end + G.GAME.selected_back:trigger_effect({context = 'open_booster', card = self}) if G.GAME.modifiers.inflation then G.GAME.inflation = G.GAME.inflation + 1 @@ -2244,14 +2214,18 @@ function Card:redeem() inc_career_stat('c_vouchers_bought', 1) set_voucher_usage(self) check_for_unlock({type = 'run_redeem'}) - G.GAME.current_round.voucher = nil + -- G.GAME.current_round.voucher = nil + if self.shop_cry_bonusvoucher then G.GAME.cry_bonusvouchersused[self.shop_cry_bonusvoucher] = true end G.GAME.current_round.cry_voucher_edition = nil G.GAME.current_round.cry_voucher_stickers = {eternal = false, perishable = false, rental = false, pinned = false, banana = false} self:apply_to_run() delay(0.6) - SMODS.calculate_context({buying_card = true, card = self}) + for i = 1, #G.jokers.cards do + G.jokers.cards[i]:calculate_joker({buying_card = true, card = self}) + end + G.GAME.selected_back:trigger_effect({context = 'buying_card', card = self}) if G.GAME.modifiers.inflation then G.GAME.inflation = G.GAME.inflation + 1 G.E_MANAGER:add_event(Event({func = function() @@ -2275,16 +2249,13 @@ function Card:redeem() end function Card:apply_to_run(center) -local card_to_save = self and copy_card(self) or Card(0, 0, G.CARD_W, G.CARD_H, G.P_CARDS.empty, center) -card_to_save.VT.x, card_to_save.VT.y = G.vouchers.T.x, G.vouchers.T.y -G.vouchers:emplace(card_to_save) local center_table = { name = center and center.name or self and self.ability.name, - extra = self and self.config and self.config.center_key and G.GAME and G.GAME.cry_voucher_centers and G.GAME.cry_voucher_centers[self.config.center_key] and G.GAME.cry_voucher_centers[self.config.center_key].config.extra + extra = self and G.GAME.cry_voucher_centers[self.config.center_key].config.extra or center and center.config.extra } local obj = center or self.config.center if obj.redeem and type(obj.redeem) == 'function' then - obj:redeem(card_to_save) + obj:redeem(self) return end if center_table.name == 'Overstock' or center_table.name == 'Overstock Plus' then G.E_MANAGER:add_event(Event({func = function() @@ -2649,10 +2620,7 @@ function Card:calculate_seal(context) if self.debuff then return nil end local obj = G.P_SEALS[self.seal] or {} if obj.calculate and type(obj.calculate) == 'function' then local o = obj:calculate(self, context) - if o then - if not o.card then o.card = self end - return o - end + if o then return o end end if context.repetition then if self.seal == 'Red' then @@ -2663,7 +2631,7 @@ function Card:calculate_seal(context) } end end - if context.discard and context.other_card == self then + if context.discard then if self.seal == 'Purple' and #G.consumeables.cards + G.GAME.consumeable_buffer < G.consumeables.config.card_limit then G.GAME.consumeable_buffer = G.GAME.consumeable_buffer + 1 G.E_MANAGER:add_event(Event({ @@ -2677,7 +2645,6 @@ function Card:calculate_seal(context) return true end)})) card_eval_status_text(self, 'extra', nil, nil, nil, {message = localize('k_plus_tarot'), colour = G.C.PURPLE}) - return nil, true end end end @@ -2704,13 +2671,31 @@ function Card:calculate_perishable() end function Card:calculate_joker(context) +for k, v in pairs(SMODS.Stickers) do + if self.ability[v.key] then + if v.calculate and type(v.calculate) == 'function' then + local override_card = v:calculate(self, context) + if override_card then return override_card end + end + end +end if self.debuff then return nil end local obj = self.config.center if self.ability.set ~= "Enhanced" and obj.calculate and type(obj.calculate) == 'function' then local o, t = obj:calculate(self, context) if o or t then return o, t end end + if self.ability.set == "Planet" and not self.debuff then + if context.joker_main then + if G.GAME.used_vouchers.v_observatory and self.ability.consumeable.hand_type == context.scoring_name then + return { + message = localize{type = 'variable', key = 'a_xmult', vars = {G.GAME.cry_voucher_centers['v_observatory'].config.extra}}, + Xmult_mod = G.GAME.cry_voucher_centers['v_observatory'].config.extra + } + end + end + end if self.ability.set == "Joker" and not self.debuff then if self.ability.name == "Blueprint" then local other_joker = nil @@ -2719,14 +2704,15 @@ function Card:calculate_joker(context) end if other_joker and other_joker ~= self and not context.no_blueprint then context.blueprint = (context.blueprint and (context.blueprint + 1)) or 1 + context.copy_depth = (context.copy_depth and (context.copy_depth + 1)) or 1 context.blueprint_card = context.blueprint_card or self if context.blueprint > #G.jokers.cards + 1 then return end - local other_joker_ret = other_joker:calculate_joker(context) - context.blueprint = nil - local eff_card = context.blueprint_card or self - context.blueprint_card = nil + context.no_callback = true + local other_joker_ret, trig = other_joker:calculate_joker(context) if other_joker_ret then - other_joker_ret.card = eff_card + other_joker_ret.card = context.blueprint_card or self + context.no_callback = not (context.copy_depth <= 1) + context.copy_depth = context.copy_depth - 1; other_joker_ret.colour = G.C.BLUE return other_joker_ret end @@ -2736,14 +2722,15 @@ function Card:calculate_joker(context) local other_joker = G.jokers.cards[1] if other_joker and other_joker ~= self and not context.no_blueprint then context.blueprint = (context.blueprint and (context.blueprint + 1)) or 1 + context.copy_depth = (context.copy_depth and (context.copy_depth + 1)) or 1 context.blueprint_card = context.blueprint_card or self if context.blueprint > #G.jokers.cards + 1 then return end - local other_joker_ret = other_joker:calculate_joker(context) - context.blueprint = nil - local eff_card = context.blueprint_card or self - context.blueprint_card = nil + context.no_callback = true + local other_joker_ret, trig = other_joker:calculate_joker(context) if other_joker_ret then - other_joker_ret.card = eff_card + other_joker_ret.card = context.blueprint_card or self + context.no_callback = not (context.copy_depth <= 1) + context.copy_depth = context.copy_depth - 1; other_joker_ret.colour = G.C.RED return other_joker_ret end @@ -2751,7 +2738,7 @@ function Card:calculate_joker(context) end if context.open_booster then if self.ability.name == 'Hallucination' and #G.consumeables.cards + G.GAME.consumeable_buffer < G.consumeables.config.card_limit then - if pseudorandom('halu'..G.GAME.round_resets.ante) < G.GAME.probabilities.normal/self.ability.extra then + if pseudorandom('halu'..G.GAME.round_resets.ante) < cry_prob(self.ability.cry_prob, self.ability.extra, self.ability.cry_rigged)/self.ability.extra then G.GAME.consumeable_buffer = G.GAME.consumeable_buffer + 1 G.E_MANAGER:add_event(Event({ trigger = 'before', @@ -2764,7 +2751,6 @@ function Card:calculate_joker(context) return true end)})) card_eval_status_text(self, 'extra', nil, nil, nil, {message = localize('k_plus_tarot'), colour = G.C.PURPLE}) - return nil, true end end elseif context.buying_card then @@ -3164,6 +3150,7 @@ function Card:calculate_joker(context) if not Talisman.config_file.disable_anims then G.E_MANAGER:add_event(Event({func = (function() G.GAME.dollar_buffer = 0; return true end)})) else G.GAME.dollar_buffer = 0 end return { message = localize('$')..self.ability.extra, + dollars = self.ability.extra, colour = G.C.MONEY } end @@ -3196,7 +3183,6 @@ function Card:calculate_joker(context) end })) return { - card = self, message = localize('k_eaten_ex'), colour = G.C.FILTER } @@ -3204,7 +3190,6 @@ function Card:calculate_joker(context) self.ability.x_mult = self.ability.x_mult - self.ability.extra return { delay = 0.2, - card = self, message = localize{type='variable',key='a_xmult_minus',vars={self.ability.extra}}, colour = G.C.RED } @@ -3215,7 +3200,6 @@ function Card:calculate_joker(context) self.ability.yorick_discards = self.ability.extra.discards self.ability.x_mult = self.ability.x_mult + self.ability.extra.xmult return { - card = self, delay = 0.2, message = localize{type='variable',key='a_xmult',vars={self.ability.x_mult}}, colour = G.C.RED @@ -3346,7 +3330,6 @@ function Card:calculate_joker(context) end })) return { - card = self, message = localize('k_eaten_ex'), colour = G.C.FILTER } @@ -3445,7 +3428,7 @@ function Card:calculate_joker(context) end if self.ability.name == 'Gros Michel' or self.ability.name == 'Cavendish' then - if pseudorandom(self.ability.name == 'Cavendish' and 'cavendish' or 'gros_michel') < G.GAME.probabilities.normal/self.ability.extra.odds then + if pseudorandom(self.ability.name == 'Cavendish' and 'cavendish' or 'gros_michel') < cry_prob(self.ability.cry_prob, self.ability.extra.odds, self.ability.cry_rigged)/self.ability.extra.odds then G.E_MANAGER:add_event(Event({ func = function() play_sound('tarot1') @@ -3532,7 +3515,7 @@ function Card:calculate_joker(context) end end if self.ability.name == '8 Ball' and #G.consumeables.cards + G.GAME.consumeable_buffer < G.consumeables.config.card_limit then - if (context.other_card:get_id() == 8) and (pseudorandom('8ball') < G.GAME.probabilities.normal/self.ability.extra) then + if (context.other_card:get_id() == 8) and (pseudorandom('8ball') < cry_prob(self.ability.cry_prob, self.ability.extra, self.ability.cry_rigged)/self.ability.extra) then G.GAME.consumeable_buffer = G.GAME.consumeable_buffer + 1 return { extra = {focus = self, message = localize('k_plus_tarot'), func = function() @@ -3602,7 +3585,7 @@ function Card:calculate_joker(context) end if self.ability.name == 'Business Card' and context.other_card:is_face() and - pseudorandom('business') < G.GAME.probabilities.normal/self.ability.extra then + pseudorandom('business') < cry_prob(self.ability.cry_prob, self.ability.extra, self.ability.cry_rigged)/self.ability.extra then G.GAME.dollar_buffer = (G.GAME.dollar_buffer or 0) + 2 if not Talisman.config_file.disable_anims then G.E_MANAGER:add_event(Event({func = (function() G.GAME.dollar_buffer = 0; return true end)})) else G.GAME.dollar_buffer = 0 end return { @@ -3674,7 +3657,7 @@ function Card:calculate_joker(context) end if self.ability.name == 'Bloodstone' and context.other_card:is_suit("Hearts") and - pseudorandom('bloodstone') < G.GAME.probabilities.normal/self.ability.extra.odds then + pseudorandom('bloodstone') < cry_prob(self.ability.cry_prob, self.ability.extra.odds, self.ability.cry_rigged)/self.ability.extra.odds then return { x_mult = self.ability.extra.Xmult, card = self @@ -3729,7 +3712,7 @@ function Card:calculate_joker(context) end if self.ability.name == 'Reserved Parking' and context.other_card:is_face() and - pseudorandom('parking') < G.GAME.probabilities.normal/self.ability.extra.odds then + pseudorandom('parking') < cry_prob(self.ability.cry_prob, self.ability.extra.odds, self.ability.cry_rigged)/self.ability.extra.odds then if context.other_card.debuff then return { message = localize('k_debuffed'), @@ -3849,7 +3832,7 @@ function Card:calculate_joker(context) card = self } end - if self.ability.name == 'Space Joker' and pseudorandom('space') < G.GAME.probabilities.normal/self.ability.extra then + if self.ability.name == 'Space Joker' and pseudorandom('space') < cry_prob(self.ability.cry_prob, self.ability.extra, self.ability.cry_rigged)/self.ability.extra then return { card = self, level_up = true, @@ -3926,6 +3909,7 @@ function Card:calculate_joker(context) if not Talisman.config_file.disable_anims then G.E_MANAGER:add_event(Event({func = (function() G.GAME.dollar_buffer = 0; return true end)})) else G.GAME.dollar_buffer = 0 end return { message = localize('$')..self.ability.extra.dollars, + dollars = self.ability.extra.dollars, colour = G.C.MONEY } end @@ -4154,6 +4138,7 @@ function Card:calculate_joker(context) if not Talisman.config_file.disable_anims then G.E_MANAGER:add_event(Event({func = (function() G.GAME.dollar_buffer = 0; return true end)})) else G.GAME.dollar_buffer = 0 end return { message = localize('$')..self.ability.extra, + dollars = self.ability.extra, colour = G.C.MONEY } end @@ -4171,7 +4156,7 @@ function Card:calculate_joker(context) } end if self.ability.name == 'Vagabond' and #G.consumeables.cards + G.GAME.consumeable_buffer < G.consumeables.config.card_limit then - if to_big(G.GAME.dollars) <= to_big(self.ability.extra) then + if G.GAME.dollars <= self.ability.extra then G.GAME.consumeable_buffer = G.GAME.consumeable_buffer + 1 G.E_MANAGER:add_event(Event({ trigger = 'before', @@ -4363,7 +4348,7 @@ function Card:calculate_joker(context) colour = G.C.MULT } end - if self.ability.name == 'Bull' and to_big(G.GAME.dollars + (G.GAME.dollar_buffer or 0)) > to_big(0) then + if self.ability.name == 'Bull' and (G.GAME.dollars + (G.GAME.dollar_buffer or 0)) > 0 then return { message = localize{type='variable',key='a_chips',vars={self.ability.extra*math.max(0,(G.GAME.dollars + (G.GAME.dollar_buffer or 0))) }}, chip_mod = self.ability.extra*math.max(0,(G.GAME.dollars + (G.GAME.dollar_buffer or 0))), @@ -4473,7 +4458,7 @@ function Card:calculate_joker(context) Xmult_mod = self.ability.extra.Xmult, } end - if self.ability.name == 'Bootstraps' and to_big(math.floor((G.GAME.dollars + (G.GAME.dollar_buffer or 0))/self.ability.extra.dollars)) >= to_big(1) then + if self.ability.name == 'Bootstraps' and math.floor((G.GAME.dollars + (G.GAME.dollar_buffer or 0))/self.ability.extra.dollars) >= 1 then return { message = localize{type='variable',key='a_mult',vars={self.ability.extra.mult*math.floor((G.GAME.dollars + (G.GAME.dollar_buffer or 0))/self.ability.extra.dollars)}}, mult_mod = self.ability.extra.mult*math.floor((G.GAME.dollars + (G.GAME.dollar_buffer or 0))/self.ability.extra.dollars) @@ -4663,18 +4648,11 @@ function Card:update(dt) end end end - if self.config.center.key == 'j_cry_gemino' then - other_joker = G.jokers.cards[1] - if other_joker and other_joker ~= self and not (Card.no(other_joker, "immutable", true)) then - self.ability.blueprint_compat = 'compatible' - else - self.ability.blueprint_compat = 'incompatible' - end end - if self.ability.name == 'Blueprint' or self.ability.name == 'cry-oldblueprint' or self.ability.name == 'Brainstorm' then + if self.ability.name == 'Blueprint' or self.ability.name == 'Brainstorm' then local other_joker = nil if self.ability.name == 'Brainstorm' then other_joker = G.jokers.cards[1] - elseif self.ability.name == 'Blueprint' or self.ability.name == 'cry-oldblueprint' then + elseif self.ability.name == 'Blueprint' then for i = 1, #G.jokers.cards do if G.jokers.cards[i] == self then other_joker = G.jokers.cards[i+1] end end @@ -4795,6 +4773,7 @@ function Card:draw(layer) self.hover_tilt = 1 if not self.states.visible then return end + if self.VT.x < -3 or self.VT.x > G.TILE_W + 2.5 then return end if (layer == 'shadow' or layer == 'both') then self.ARGS.send_to_shader = self.ARGS.send_to_shader or {} @@ -4891,9 +4870,6 @@ function Card:draw(layer) if (self.config.center.undiscovered and not self.config.center.undiscovered.no_overlay) or not( SMODS.UndiscoveredSprites[self.ability.set] and SMODS.UndiscoveredSprites[self.ability.set].no_overlay) then shared_sprite:draw_shader('dissolve', nil, nil, nil, self.children.center, scale_mod, rotate_mod) else - if SMODS.UndiscoveredSprites[self.ability.set] and SMODS.UndiscoveredSprites[self.ability.set].overlay_sprite then - SMODS.UndiscoveredSprites[self.ability.set].overlay_sprite:draw_shader('dissolve', nil, nil, nil, self.children.center, scale_mod, rotate_mod) - end end end @@ -5123,7 +5099,7 @@ function Card:draw(layer) end for k, v in pairs(self.children) do - if not v.custom_draw and k ~= 'focused_ui' and k ~= "front" and k ~= "back" and k ~= "soul_parts" and k ~= "center" and k ~= 'floating_sprite' and k~= "shadow" and k~= "use_button" and k ~= 'buy_button' and k ~= 'buy_and_use_button' and k~= "debuff" and k ~= 'price' and k~= 'particles' and k ~= 'h_popup' then v:draw() end + if not v.custom_draw and k ~= 'focused_ui' and k ~= "front" and k ~= "back" and k ~= "soul_parts" and k ~= "center" and k ~= 'floating_sprite' and k ~= 'floating_sprite2' and k~= "shadow" and k~= "use_button" and k ~= 'buy_button' and k ~= 'buy_and_use_button' and k~= "debuff" and k ~= 'price' and k~= 'particles' and k ~= 'h_popup' then v:draw() end end if (layer == 'card' or layer == 'both') and self.area == G.hand then @@ -5209,6 +5185,8 @@ function Card:save() label = self.label, playing_card = self.playing_card, base = self.base, + shop_voucher = self.shop_voucher, + shop_cry_bonusvoucher = self.shop_cry_bonusvoucher, ability = self.ability, pinned = self.pinned, edition = self.edition, @@ -5281,16 +5259,6 @@ function Card:load(cardTable, other_card) self.T.h = H*scale self.T.w = W*scale end - if self.config.center.display_size and self.config.center.display_size.h then - self.T.h = H*(self.config.center.display_size.h/95) - elseif self.config.center.pixel_size and self.config.center.pixel_size.h then - self.T.h = H*(self.config.center.pixel_size.h/95) - end - if self.config.center.display_size and self.config.center.display_size.w then - self.T.w = W*(self.config.center.display_size.w/71) - elseif self.config.center.pixel_size and self.config.center.pixel_size.w then - self.T.w = W*(self.config.center.pixel_size.w/71) - end self.VT.h = self.T.H self.VT.w = self.T.w @@ -5324,6 +5292,8 @@ function Card:load(cardTable, other_card) self.ignore_base_shader = cardTable.ignore_base_shader or {} self.ignore_shadow = cardTable.ignore_shadow or {} + self.shop_voucher = cardTable.shop_voucher + self.shop_cry_bonusvoucher = cardTable.shop_cry_bonusvoucher self.ability = cardTable.ability self.pinned = cardTable.pinned self.edition = cardTable.edition diff --git a/lovely/dump/cardarea.lua b/lovely/dump/cardarea.lua index 06918dc..343cc8d 100644 --- a/lovely/dump/cardarea.lua +++ b/lovely/dump/cardarea.lua @@ -1,4 +1,4 @@ -LOVELY_INTEGRITY = '0825b896143c8e8c22c2c18adfc937960d407b986f1c18addc68bedde1768967' +LOVELY_INTEGRITY = 'e8693aca875516bf9cb3c84fcb6f392131135da095f221f2ef0e6ac727b926df' --Class CardArea = Moveable:extend() @@ -32,6 +32,9 @@ function CardArea:init(X, Y, W, H, config) end function CardArea:emplace(card, location, stay_flipped) +if self == G.jokers then + Cartomancer.handle_joker_added(card) +end if card.edition and card.edition.card_limit and (self == G.hand) then self.config.real_card_limit = (self.config.real_card_limit or self.config.card_limit) + card.edition.card_limit self.config.card_limit = math.max(0, self.config.real_card_limit) @@ -323,6 +326,9 @@ function CardArea:draw() } end self.children.area_uibox:draw() + if self == G.jokers then + Cartomancer.add_visibility_controls() + end end self:draw_boundingrect() @@ -425,15 +431,39 @@ function CardArea:align_cards() end if (self == G.hand or self == G.deck or self == G.discard or self == G.play) and G.view_deck and G.view_deck[1] and G.view_deck[1].cards then return end if self.config.type == 'deck' then + local display_limit + if not Cartomancer.SETTINGS.compact_deck_enabled then + display_limit = 999999 + else + display_limit = Cartomancer.SETTINGS.compact_deck_visible_cards + end + local deck_height = (self.config.deck_height or 0.15)/52 + local total_cards = #self.cards <= display_limit and #self.cards or display_limit -- limit height + local fixedX, fixedY, fixedR = nil, nil, nil + for k, card in ipairs(self.cards) do if card.facing == 'front' then card:flip() end - + if not card.states.drag.is then - card.T.x = self.T.x + 0.5*(self.T.w - card.T.w) + self.shadow_parrallax.x*deck_height*(#self.cards/(self == G.deck and 1 or 2) - k) + 0.9*self.shuffle_amt*(1 - k*0.01)*(k%2 == 1 and 1 or -0) - card.T.y = self.T.y + 0.5*(self.T.h - card.T.h) + self.shadow_parrallax.y*deck_height*(#self.cards/(self == G.deck and 1 or 2) - k) - card.T.r = 0 + 0.3*self.shuffle_amt*(1 + k*0.05)*(k%2 == 1 and 1 or -0) - card.T.x = card.T.x + card.shadow_parrallax.x/30 + if fixedX then + card.T.x = fixedX + card.T.y = fixedY + card.T.r = fixedR -- rotation + card.states.visible = false + else + card.T.x = self.T.x + 0.5*(self.T.w - card.T.w) + self.shadow_parrallax.x*deck_height*(total_cards/(self == G.deck and 1 or 2) - k) + 0.9*self.shuffle_amt*(1 - k*0.01)*(k%2 == 1 and 1 or -0) + card.T.y = self.T.y + 0.5*(self.T.h - card.T.h) + self.shadow_parrallax.y*deck_height*(total_cards/(self == G.deck and 1 or 2) - k) + card.T.r = 0 + 0.3*self.shuffle_amt*(1 + k*0.05)*(k%2 == 1 and 1 or -0) + card.T.x = card.T.x + card.shadow_parrallax.x/30 + card.states.visible = true + + if k >= display_limit then + fixedX = card.T.x + fixedY = card.T.y + fixedR = card.T.r + end + end end end end @@ -521,7 +551,18 @@ function CardArea:align_cards() end table.sort(self.cards, function (a, b) return a.T.x + a.T.w/2 - 100*(a.pinned and a.sort_id or 0) < b.T.x + b.T.w/2 - 100*(b.pinned and b.sort_id or 0) end) end - if self.config.type == 'joker' or self.config.type == 'title_2' then + if self == G.jokers and G.jokers.cart_jokers_expanded then + local align_cards = Cartomancer.expand_G_jokers() + + -- This should work fine without cryptid. But because cryptid's patch is priority=0, it has to be this way + if not G.GAME.modifiers.cry_conveyor then + table.sort(self.cards, function (a, b) return a.T.x + a.T.w/2 - 100*(a.pinned and a.sort_id or 0) < b.T.x + b.T.w/2 - 100*(b.pinned and b.sort_id or 0) end) + end + + if align_cards then + G.jokers:hard_set_cards() + end + elseif self.config.type == 'joker' or self.config.type == 'title_2' then for k, card in ipairs(self.cards) do if not card.states.drag.is then card.T.r = 0.1*(-#self.cards/2 - 0.5 + k)/(#self.cards)+ (G.SETTINGS.reduced_motion and 0 or 1)*0.02*math.sin(2*G.TIMERS.REAL+card.T.x) @@ -612,6 +653,9 @@ function CardArea:draw_card_from(area, stay_flipped, discarded_only) if area == G.discard then card.T.r = 0 end + if self == G.hand and not card.states.visible then + card.states.visible = true + end local stay_flipped = G.GAME and G.GAME.blind and G.GAME.blind:stay_flipped(self, card) if (self == G.hand) and G.GAME.modifiers.flipped_cards then if pseudorandom(pseudoseed('flipped_card')) < 1/G.GAME.modifiers.flipped_cards then diff --git a/lovely/dump/engine/controller.lua b/lovely/dump/engine/controller.lua index 51aa67c..3af61ba 100644 --- a/lovely/dump/engine/controller.lua +++ b/lovely/dump/engine/controller.lua @@ -1,4 +1,4 @@ -LOVELY_INTEGRITY = 'd9e5d51702216f37d8d0de3c89deb8d1a47bcad6430594945df872f263a14c04' +LOVELY_INTEGRITY = 'd36e3953c2739cd4ea15794fb5e4031a2dac09fc33baadd0a2820e4726891304' ---@class Controller Controller = Object:extend() @@ -768,6 +768,12 @@ function Controller:button_release_update(button, dt) end function Controller:key_press_update(key, dt) + if key == "escape" and Cartomancer.INTERNAL_in_config then + Cartomancer.INTERNAL_in_config = false + if not Cartomancer.use_smods() then + Cartomancer.save_config() + end + end if key == "escape" and G.ACTIVE_MOD_UI then G.FUNCS.exit_mods() end @@ -822,7 +828,7 @@ function Controller:key_press_update(key, dt) end end end - if not _RELEASE_MODE then + if not _RELEASE_MODE and require("debugplus.core").isOkayToHandleDebugForKey(key) then if key == 'tab' and not G.debug_tools then G.debug_tools = UIBox{ definition = create_UIBox_debug_tools(), @@ -853,6 +859,8 @@ function Controller:key_press_update(key, dt) add_joker(_card.config.center.key) _card:set_sprites(_card.config.center) end + local debugplus = require("debugplus.core") + debugplus.handleSpawn(self, _card) if _card.ability.consumeable and G.consumeables and #G.consumeables.cards < G.consumeables.config.card_limit then add_joker(_card.config.center.key) _card:set_sprites(_card.config.center) @@ -904,13 +912,17 @@ function Controller:key_press_update(key, dt) if key == "space" then live_test() end + local debugplus = require("debugplus.core") + debugplus.handleKeys(self, key, dt) if key == 'v' then if not G.prof then G.prof = require "engine/profile"; G.prof.start() else G.prof:stop(); print(G.prof.report()); G.prof = nil end + debugplus.profileMessage() end if key == "p" then G.SETTINGS.perf_mode = not G.SETTINGS.perf_mode + debugplus.togglePerfUI() end end end diff --git a/lovely/dump/engine/save_manager.lua b/lovely/dump/engine/save_manager.lua deleted file mode 100644 index 693b4b2..0000000 --- a/lovely/dump/engine/save_manager.lua +++ /dev/null @@ -1,102 +0,0 @@ -LOVELY_INTEGRITY = 'a0a6222d417538f9ac51e6de9e5324e3e68a85bbdc35ead9c5c98bc11cb475e4' - -require "love.system" - -if (love.system.getOS() == 'OS X' ) and (jit.arch == 'arm64' or jit.arch == 'arm') then jit.off() end - -require "love.timer" -require "love.thread" -require 'love.filesystem' -require "engine/object" -require "engine/string_packer" - ---vars needed for sound manager thread -CHANNEL = love.thread.getChannel("save_request") -function tal_compress_and_save(_file, _data, talisman) - local save_string = type(_data) == 'table' and STR_PACK(_data) or _data - local fallback_save = STR_PACK({GAME = {won = true}}) --just bare minimum to not crash, maybe eventually display some info? - if talisman == 'bignumber' then - fallback_save = "if not BigMeta then " .. fallback_save - elseif talisman == 'omeganum' then - fallback_save = "if not OmegaMeta then " .. fallback_save - else - fallback_save = "if BigMeta or OmegaMeta then " .. fallback_save - end - fallback_save = fallback_save .. " end" - save_string = fallback_save .. " " .. save_string - save_string = love.data.compress('string', 'deflate', save_string, 1) - love.filesystem.write(_file,save_string) -end - - while true do - --Monitor the channel for any new requests - local request = CHANNEL:demand() -- Value from channel - if request then - if request.type == 'kill' then return end - --Saves progress for settings, unlocks, alerts and discoveries - if request.type == 'save_progress' then - local prefix_profile = (request.save_progress.SETTINGS.profile or 1)..'' - if not love.filesystem.getInfo(prefix_profile) then love.filesystem.createDirectory( prefix_profile ) end - prefix_profile = prefix_profile..'/' - - if not love.filesystem.getInfo(prefix_profile..'meta.jkr') then - love.filesystem.append( prefix_profile..'meta.jkr', 'return {}' ) - end - - local meta = STR_UNPACK(get_compressed(prefix_profile..'meta.jkr') or 'return {}') - meta.unlocked = meta.unlocked or {} - meta.discovered = meta.discovered or {} - meta.alerted = meta.alerted or {} - - local _append = false - - for k, v in pairs(request.save_progress.UDA) do - if string.find(v, 'u') and not meta.unlocked[k] then - meta.unlocked[k] = true - _append = true - end - if string.find(v, 'd') and not meta.discovered[k] then - meta.discovered[k] = true - _append = true - end - if string.find(v, 'a') and not meta.alerted[k] then - meta.alerted[k] = true - _append = true - end - end - if _append then compress_and_save( prefix_profile..'meta.jkr', STR_PACK(meta)) end - - compress_and_save('settings.jkr', request.save_progress.SETTINGS) - compress_and_save(prefix_profile..'profile.jkr', request.save_progress.PROFILE) - - CHANNEL:push('done') - --Saves the settings file - elseif request.type == 'save_settings' then - compress_and_save('settings.jkr', request.save_settings) - compress_and_save(request.profile_num..'/profile.jkr', request.save_profile) - --Saves the metrics file - elseif request.type == 'save_metrics' then - compress_and_save('metrics.jkr', request.save_metrics) - --Saves any notifications - elseif request.type == 'save_notify' then - local prefix_profile = (request.profile_num or 1)..'' - if not love.filesystem.getInfo(prefix_profile) then love.filesystem.createDirectory( prefix_profile ) end - prefix_profile = prefix_profile..'/' - - if not love.filesystem.getInfo(prefix_profile..'unlock_notify.jkr') then love.filesystem.append( prefix_profile..'unlock_notify.jkr', '') end - local unlock_notify = get_compressed(prefix_profile..'unlock_notify.jkr') or '' - - if request.save_notify and not string.find(unlock_notify, request.save_notify) then - compress_and_save( prefix_profile..'unlock_notify.jkr', unlock_notify..request.save_notify..'\n') - end - - --Saves the run - elseif request.type == 'save_run' then - local prefix_profile = (request.profile_num or 1)..'' - if not love.filesystem.getInfo(prefix_profile) then love.filesystem.createDirectory( prefix_profile ) end - prefix_profile = prefix_profile..'/' - - tal_compress_and_save(prefix_profile..'save.jkr', request.save_table, request.talisman) - end - end -end diff --git a/lovely/dump/engine/ui.lua b/lovely/dump/engine/ui.lua index 2821d3a..fa684a8 100644 --- a/lovely/dump/engine/ui.lua +++ b/lovely/dump/engine/ui.lua @@ -1,4 +1,4 @@ -LOVELY_INTEGRITY = 'ed73ce7b68b17bbbc04af6cf80e1577d8c38357ce87c6952cf5f2319cb9a578d' +LOVELY_INTEGRITY = '435a9e8ef1b3d548ef4488606196332b7d61c0a33e2dd2225ca6c7f97e3ec32b' --Class UIBox = Moveable:extend() @@ -990,6 +990,7 @@ function UIElement:click() G.NO_MOD_CURSOR_STACK = nil if self.config.choice then + local chosen_temp = self.config.chosen local chosen_temp = self.config.chosen local choices = self.UIBox:get_group(nil, self.config.group) for k, v in pairs(choices) do diff --git a/lovely/dump/functions/UI_definitions.lua b/lovely/dump/functions/UI_definitions.lua index 0014d7b..5dacb9d 100644 --- a/lovely/dump/functions/UI_definitions.lua +++ b/lovely/dump/functions/UI_definitions.lua @@ -1,10 +1,12 @@ -LOVELY_INTEGRITY = 'c4606c194e720d427e9e0e1b2181bd1cd60d72f540c2377514fa195a2271958b' +LOVELY_INTEGRITY = '824fe1307b104cf5bc0a6245ef8c8e76db9af62d790ab2106537987e589dd59b' --Create a global UIDEF that contains all UI definition functions\ --As a rule, these contain functions that return a table T representing the definition for a UIBox G.UIDEF = {} function create_UIBox_debug_tools() +local debugplus = require("debugplus.core") +debugplus.registerButtons() G.debug_tool_config = G.debug_tool_config or {} G.FUNCS.DT_add_money = function() if G.STAGE == G.STAGES.RUN then ease_dollars(10) end end G.FUNCS.DT_add_round = function() if G.STAGE == G.STAGES.RUN then ease_round(1) end end @@ -94,7 +96,40 @@ function create_UIBox_debug_tools() {n=G.UIT.T, config={text = "Hover over any Joker/Playing card", scale = 0.25, colour = G.C.WHITE, shadow = true}} }}, {n=G.UIT.R, config={align = "cm", padding = 0.05}, nodes={ - {n=G.UIT.T, config={text = "and press [Q] to cycle Edition", scale = 0.25, colour = G.C.WHITE, shadow = true}} + {n=G.UIT.T, config={text = "hold [" .. require("debugplus.util").ctrlText .. "] (togglable in config)", scale = 0.25, colour = G.C.WHITE, shadow = true}} + }}, + {n=G.UIT.R, config={align = "cm", padding = 0.05}, nodes={ + {n=G.UIT.T, config={text = "and press [Q] to cycle Edition", scale = 0.25, colour = G.C.WHITE, shadow = true}} + }}, + {n=G.UIT.R, config={align = "cm", padding = 0.05}, nodes={ + {n=G.UIT.T, config={text = "press [W] to cycle Enhancement", scale = 0.25, colour = G.C.WHITE, shadow = true}} + }}, + {n=G.UIT.R, config={align = "cm", padding = 0.05}, nodes={ + {n=G.UIT.T, config={text = "press [E] to cycle Seal", scale = 0.25, colour = G.C.WHITE, shadow = true}} + }}, + {n=G.UIT.R, config={align = "cm", padding = 0.05}, nodes={ + {n=G.UIT.T, config={text = "press [A/S/D] to toggle Eternal/Perishable/Rental", scale = 0.2, colour = G.C.WHITE, shadow = true}} + }}, + {n=G.UIT.R, config={align = "cm", padding = 0.05}, nodes={ + {n=G.UIT.T, config={text = "press [F] to toggle Coupon (make free)", scale = 0.25, colour = G.C.WHITE, shadow = true}} + }}, + {n=G.UIT.R, config={align = "cm", padding = 0.05}, nodes={ + {n=G.UIT.T, config={text = "press [R/C] to destroy/copy card", scale = 0.25, colour = G.C.WHITE, shadow = true}} + }}, + {n=G.UIT.R, config={align = "cm", padding = 0.05}, nodes={ + {n=G.UIT.T, config={text = "press [M] to reload atlases", scale = 0.25, colour = G.C.WHITE, shadow = true}} + }}, + {n=G.UIT.R, config={align = "cm", padding = 0.05}, nodes={ + {n=G.UIT.T, config={text = "press [UP/DOWN] to cycle rank", scale = 0.2, colour = G.C.WHITE, shadow = true}} + }}, + {n=G.UIT.R, config={align = "cm", padding = 0.00}, nodes={ + {n=G.UIT.T, config={text = "press [RIGHT/LEFT] to cycle suit", scale = 0.2, colour = G.C.WHITE, shadow = true}} + }}, + {n=G.UIT.R, config={align = "cm", padding = 0.05}, nodes={ + {n=G.UIT.T, config={text = "press [z] plus [1-3] to save a save state", scale = 0.2, colour = G.C.WHITE, shadow = true}} + }}, + {n=G.UIT.R, config={align = "cm", padding = 0.00}, nodes={ + {n=G.UIT.T, config={text = "press [x] plus [1-3] to load a save state", scale = 0.2, colour = G.C.WHITE, shadow = true}} }}, }}, {n=G.UIT.R, config={align = "cm", padding = 0.05}, nodes={ @@ -126,6 +161,8 @@ function create_UIBox_debug_tools() UIBox_button{ label = {"+1 Discard"}, button = "DT_add_discard", minw = 1.7, minh = 0.4, scale = 0.35}, UIBox_button{ label = {"Boss Reroll"}, button = "DT_reroll_boss", minw = 1.7, minh = 0.4, scale = 0.35}, UIBox_button{ label = {"Background"}, button = "DT_toggle_background", minw = 1.7, minh = 0.4, scale = 0.35}, + UIBox_button{ label = {"Win Blind"}, button = "DT_win_blind", minw = 1.7, minh = 0.4, scale = 0.35}, + UIBox_button{ label = {"Double Tag"}, button = "DT_double_tag", minw = 1.7, minh = 0.4, scale = 0.35}, }}, {n=G.UIT.C, config={align = "cm", padding = 0.15}, nodes={ UIBox_button{ label = {"+10 chips"}, button = "DT_add_chips", minw = 1.7, minh = 0.4, scale = 0.35}, @@ -262,15 +299,6 @@ function G.UIDEF.use_and_sell_buttons(card) }}, }} end - if card.ability.consumeable and booster_obj and booster_obj.select_card then - if (card.area == G.pack_cards and G.pack_cards) then - return {n=G.UIT.ROOT, config = {padding = 0, colour = G.C.CLEAR}, nodes={ - {n=G.UIT.R, config={ref_table = card, r = 0.08, padding = 0.1, align = "bm", minw = 0.5*card.T.w - 0.15, maxw = 0.9*card.T.w - 0.15, minh = 0.3*card.T.h, hover = true, shadow = true, colour = G.C.UI.BACKGROUND_INACTIVE, one_press = true, button = 'use_card', func = 'can_select_from_booster'}, nodes={ - {n=G.UIT.T, config={text = localize('b_select'),colour = G.C.UI.TEXT_LIGHT, scale = 0.45, shadow = true}} - }}, - }} - end - end if card.ability.consumeable then if (card.area == G.pack_cards and G.pack_cards) then return { @@ -519,6 +547,7 @@ function G.UIDEF.deck_preview(args) end local suit_map = {'Spades', 'Hearts', 'Clubs', 'Diamonds'} + local SUITS_SORTED = Cartomancer.tablecopy(SUITS) local stones = nil local rank_name_mapping = {'A','K','Q','J','10',9,8,7,6,5,4,3,2} @@ -1010,6 +1039,7 @@ end end function create_UIBox_buttons() + if G.hand and G.hand.cart_sorting == nil then G.hand.cart_sorting = true end local text_scale = 0.45 local button_height = 1.3 local play_button = {n=G.UIT.C, config={id = 'play_button', align = "tm", minw = 2.5, padding = 0.3, r = 0.1, hover = true, colour = G.C.BLUE, button = "play_cards_from_highlighted", one_press = true, shadow = true, func = 'can_play'}, nodes={ @@ -1031,6 +1061,9 @@ end {n=G.UIT.C, config={align = "cm", padding = 0.1, r = 0.1, colour =G.C.UI.TRANSPARENT_DARK, outline = 1.5, outline_colour = mix_colours(G.C.WHITE,G.C.JOKER_GREY, 0.7), line_emboss = 1}, nodes={ {n=G.UIT.R, config={align = "cm", padding = 0}, nodes={ {n=G.UIT.R, config={align = "cm", padding = 0}, nodes={ + Cartomancer.SETTINGS.improved_hand_sorting and + create_toggle{ col = true, label = localize('b_sort_hand'), label_scale = text_scale*0.8, scale = 0.30, w = 0, shadow = true, ref_table = G.hand, ref_value = 'cart_sorting', callback = function () G.FUNCS.cartomancer_sort_hand_off() end } + or {n=G.UIT.T, config={text = localize('b_sort_hand'), scale = text_scale*0.8, colour = G.C.UI.TEXT_LIGHT}} }}, {n=G.UIT.R, config={align = "cm", padding = 0.1}, nodes={ @@ -1985,11 +2018,11 @@ function create_slider(args) local t = {n=G.UIT.C, config={align = "cm", minw = args.w, min_h = args.h, padding = 0.1, r = 0.1, colour = G.C.CLEAR, focus_args = {type = 'slider'}}, nodes={ {n=G.UIT.C, config={align = "cl", minw = args.w, r = 0.1,min_h = args.h,collideable = true, hover = true, colour = G.C.BLACK,emboss = 0.05,func = 'slider', refresh_movement = true}, nodes={ - {n=G.UIT.B, config={w=startval,h=args.h, r = 0.1, colour = args.colour, ref_table = args, refresh_movement = true}}, + {n=G.UIT.B, config={id = args.id, w=startval,h=args.h, r = 0.1, colour = args.colour, ref_table = args, refresh_movement = true}}, }}, - {n=G.UIT.C, config={align = "cm", minh = args.h,r = 0.1, minw = 0.8, colour = args.colour,shadow = true}, nodes={ + not args.hide_val and {n=G.UIT.C, config={align = "cm", minh = args.h,r = 0.1, minw = 0.8, colour = args.colour,shadow = true}, nodes={ {n=G.UIT.T, config={ref_table = args, ref_value = 'text', scale = args.text_scale, colour = G.C.UI.TEXT_LIGHT, decimal_places = args.decimal_places}} - }}, + }} or nil }} if args.label then t = {n=G.UIT.R, config={align = "cm", minh = 1, minw = 1, padding = 0.1*args.label_scale, colour = G.C.CLEAR}, nodes={ @@ -2395,6 +2428,21 @@ function create_UIBox_settings() tab_definition_function_args = 'Audio' } + if not require("debugplus.config").SMODSLoaded then + tabs[#tabs+1] = { + label = "DebugPlus", + tab_definition_function = require("debugplus.config").fakeConfigTab, + } + end + local settings_icon = Cartomancer.add_settings_icon() + if settings_icon then + tabs[#tabs+1] = { + colour = G.C.MONEY, + custom_button = {settings_icon}, + tab_definition_function = Cartomancer.config_tab, + tab_definition_function_args = '' + } + end local t = create_UIBox_generic_options({back_func = 'options',contents = {create_tabs( {tabs = tabs, tab_h = 7.05, @@ -2654,46 +2702,27 @@ function G.UIDEF.custom_deck_tab(_suit) local rankCount = 0 local lookup = {} -for i, s in ipairs(SMODS.Suit:obj_list(true)) do - local options = G.COLLABS.options[s.key] - for i = 1, #options do - local skin = SMODS.DeckSkins[options[i]] - if skin.palettes and not (skin.display_ranks or skin.ranks) then - for _, p in ipairs(skin.palettes) do - local p_ranks = p.display_ranks or p.ranks - for j = 1, #p_ranks do - if not lookup[p_ranks[j]] then - lookup[p_ranks[j]] = true - rankCount = rankCount + 1 - end - end - end - elseif not skin.palettes and (skin.display_ranks or skin.ranks) then - local ranks = skin.display_ranks or skin.ranks - for j = 1, #ranks do - if not lookup[skin.ranks[j]] then - lookup[skin.ranks[j]] = true - rankCount = rankCount + 1 - end - end +local options = G.COLLABS.options[_suit] +for i = 2, #options do + local skin = SMODS.DeckSkins[options[i]] + for j = 1, #skin.ranks do + if not lookup[skin.ranks[j]] then + lookup[skin.ranks[j]] = true + rankCount = rankCount + 1 end - end end -G.cdds_cards = CardArea( +local face_cards = CardArea( 0,0, math.min(math.max(rankCount*G.CARD_W*0.6, 4*G.CARD_W), 10*G.CARD_W), - 1.4*G.CARD_H, + 1.4*G.CARD_H, {card_limit = rankCount, type = 'title', highlight_limit = 0}) -G.cdds_cards.rankCount = rankCount - - table.insert(t, {n=G.UIT.R, config={align = "cm", colour = G.C.BLACK, r = 0.1, padding = 0.07, no_fill = true}, nodes={ - {n=G.UIT.O, config={object = G.cdds_cards}} + {n=G.UIT.O, config={object = face_cards}} }} ) @@ -2715,25 +2744,26 @@ G.cdds_cards.rankCount = rankCount create_option_cycle({options = loc_options, w = 5.5, cycle_shoulders = true, curr_suit = _suit, opt_callback = 'change_collab', current_option = current_option, colour = G.C.RED, focus_args = {snap_to = true, nav = 'wide'}}), }} ) - local deckskin_key = G.COLLABS.options[_suit][current_option] - - local palette_loc_options = SMODS.DeckSkin.get_palette_loc_options(deckskin_key, _suit) - - local selected_palette = 1 - for i, v in ipairs(G.COLLABS.colour_palettes[deckskin_key]) do - if G.SETTINGS.colour_palettes[_suit] == v then - selected_palette = i - end - end - - table.insert(t, - {n=G.UIT.R, config={align = "cm", id = 'palette_selector'}, nodes={ - create_option_cycle({options = palette_loc_options, w = 5.5, cycle_shoulders = false, curr_suit = _suit, curr_skin = deckskin_key, opt_callback = 'change_colour_palette', current_option = selected_palette, colour = G.C.ORANGE, focus_args = {snap_to = true, nav = 'wide'}}), - }} - ) + table.insert(t, create_toggle({label = localize('b_high_contrast_cards'), ref_table = G.SETTINGS, ref_value = 'colourblind_option', callback = G.FUNCS.refresh_contrast_mode})) local faces = {'K','Q','J'} - G.FUNCS.update_collab_cards(current_option, _suit, true) + local rank = SMODS.Ranks['2'] +local cards = {} +local smodSuit = SMODS.Suits[_suit] +repeat + if lookup[rank.key] then + local card_code = smodSuit.card_key .. '_' .. rank.card_key + local card = Card(0,0, G.CARD_W*1.2, G.CARD_H*1.2, G.P_CARDS[card_code], G.P_CENTERS.c_base) + card.no_ui = true + + cards[#cards + 1] = card + end + rank = SMODS.Ranks[rank.next[1]] +until rank == SMODS.Ranks['2'] + +for i = #cards, 1, -1 do + face_cards:emplace(cards[i]) +end return {n=G.UIT.ROOT, config={align = "cm", padding = 0, colour = G.C.CLEAR, r = 0.1, minw = 7, minh = 4.2}, nodes=t} @@ -3195,8 +3225,8 @@ function create_UIBox_current_hand_row(handname, simple) (not simple and {n=G.UIT.R, config={align = "cm", padding = 0.05, r = 0.1, colour = darken(G.C.JOKER_GREY, 0.1), emboss = 0.05, hover = true, force_focus = true, on_demand_tooltip = {text = localize(handname, 'poker_hand_descriptions'), filler = {func = create_UIBox_hand_tip, args = handname}}}, nodes={ {n=G.UIT.C, config={align = "cl", padding = 0, minw = 5}, nodes={ - {n=G.UIT.C, config={align = "cm", padding = 0.01, r = 0.1, colour = G.C.HAND_LEVELS[to_big(math.min(7, G.GAME.hands[handname].level)):to_number()], minw = 1.5, outline = 0.8, outline_colour = G.C.WHITE}, nodes={ - {n=G.UIT.T, config={text = localize('k_level_prefix')..number_format(G.GAME.hands[handname].level), scale = 0.5, colour = G.C.UI.TEXT_DARK}} + {n=G.UIT.C, config={align = "cm", padding = 0.01, r = 0.1, colour = G.C.HAND_LEVELS[math.min(7, G.GAME.hands[handname].level)], minw = 1.5, outline = 0.8, outline_colour = G.C.WHITE}, nodes={ + {n=G.UIT.T, config={text = localize('k_level_prefix')..G.GAME.hands[handname].level, scale = 0.5, colour = G.C.UI.TEXT_DARK}} }}, {n=G.UIT.C, config={align = "cm", minw = 4.5, maxw = 4.5}, nodes={ {n=G.UIT.T, config={text = ' '..localize(handname,'poker_hands'), scale = 0.45, colour = G.C.UI.TEXT_LIGHT, shadow = true}} @@ -3395,37 +3425,59 @@ function G.UIDEF.view_deck(unplayed_only) Diamonds = {}, } local suit_map = {'Spades', 'Hearts', 'Clubs', 'Diamonds'} + local SUITS_SORTED = Cartomancer.tablecopy(SUITS) for k, v in ipairs(G.playing_cards) do - table.insert(SUITS[v.base.suit], v) + local greyed + if unplayed_only and not ((v.area and v.area == G.deck) or v.ability.wheel_flipped) then + greyed = true + end + local card_string = v:cart_to_string() + if greyed then + card_string = card_string .. "Greyed" + end + if greyed and Cartomancer.SETTINGS.deck_view_hide_drawn_cards then + -- Ignore this card. + elseif not SUITS[v.base.suit][card_string] then + table.insert(SUITS_SORTED[v.base.suit], card_string) + + local _scale = 0.7 + local copy = copy_card(v, nil, _scale) + + copy.greyed = greyed + copy.stacked_quantity = 1 + + SUITS[v.base.suit][card_string] = copy + else + local stacked_card = SUITS[v.base.suit][card_string] + stacked_card.stacked_quantity = stacked_card.stacked_quantity + 1 + end end for j = 1, 4 do - if SUITS[suit_map[j]][1] then + if SUITS_SORTED[suit_map[j]][1] then local view_deck = CardArea( G.ROOM.T.x + 0.2*G.ROOM.T.w/2,G.ROOM.T.h, 6.5*G.CARD_W, 0.6*G.CARD_H, - {card_limit = #SUITS[suit_map[j]], type = 'title', view_deck = true, highlight_limit = 0, card_w = G.CARD_W*0.7, draw_layers = {'card'}}) + {card_limit = #SUITS_SORTED[suit_map[j]], type = 'title', view_deck = true, highlight_limit = 0, card_w = G.CARD_W*0.7, draw_layers = {'card'}}) table.insert(deck_tables, {n=G.UIT.R, config={align = "cm", padding = 0}, nodes={ {n=G.UIT.O, config={object = view_deck}} }} ) - for i = 1, #SUITS[suit_map[j]] do - if SUITS[suit_map[j]][i] then - local greyed, _scale = nil, 0.7 - if unplayed_only and not ((SUITS[suit_map[j]][i].area and SUITS[suit_map[j]][i].area == G.deck) or SUITS[suit_map[j]][i].ability.wheel_flipped) then - greyed = true - end - local copy = copy_card(SUITS[suit_map[j]][i],nil, _scale) - copy.greyed = greyed - copy.T.x = view_deck.T.x + view_deck.T.w/2 - copy.T.y = view_deck.T.y - - copy:hard_set_T() - view_deck:emplace(copy) - end + for i = 1, #SUITS_SORTED[suit_map[j]] do + local card_string = SUITS_SORTED[suit_map[j]][i] + local card = SUITS[suit_map[j]][card_string] + + card.T.x = view_deck.T.x + view_deck.T.w/2 + card.T.y = view_deck.T.y + card:create_quantity_display() + + card:hard_set_T() + view_deck:emplace(card) + end + end end @@ -3539,6 +3591,7 @@ function G.UIDEF.view_deck(unplayed_only) {n=G.UIT.C, config={align = "cm", padding = 0.1, r = 0.1, colour = G.C.BLACK, emboss = 0.05}, nodes=deck_tables} }}, {n=G.UIT.R, config={align = "cm", minh = 0.8, padding = 0.05}, nodes={ + not unplayed_only and Cartomancer.add_unique_count() or nil, modded and {n=G.UIT.R, config={align = "cm"}, nodes={ {n=G.UIT.C, config={padding = 0.3, r = 0.1, colour = mix_colours(G.C.BLUE, G.C.WHITE,0.7)}, nodes = {}}, {n=G.UIT.T, config={text =' '..localize('ph_deck_preview_effective'),colour = G.C.WHITE, scale =0.3}}, @@ -3620,6 +3673,7 @@ function G.UIDEF.used_vouchers() card.ability.order = vv.order card:start_materialize(nil, silent) silent = true + if not G.GAME.voucher_edition_index then G.GAME.voucher_edition_index = {} end if G.GAME.voucher_edition_index[card.ability.name] then -- i just made it a function so i can look at it less local edition = cry_edition_to_table(G.GAME.voucher_edition_index[card.ability.name]) if edition then @@ -4257,9 +4311,20 @@ function create_UIBox_your_collection_blinds(exit) end) })) + local min_ante = 1 + local max_ante = 16 + local spacing = 1 - 15*0.06 + if G.GAME and G.GAME.round_resets and G.GAME.round_resets.ante then + local current_ante = G.GAME.round_resets.ante + + if current_ante > 8 then + min_ante = current_ante - 8 + 1 + max_ante = current_ante + 8 + end + end local ante_amounts = {} - for i = 1, math.min(16, math.max(16, G.PROFILES[G.SETTINGS.profile].high_scores.furthest_ante.amt)) do - local spacing = 1 - math.min(20, math.max(15, G.PROFILES[G.SETTINGS.profile].high_scores.furthest_ante.amt))*0.06 + for i = min_ante, max_ante do + -- :3 if spacing > 0 and i > 1 then ante_amounts[#ante_amounts+1] = {n=G.UIT.R, config={minh = spacing}, nodes={}} end @@ -6364,6 +6429,13 @@ function UIBox_button(args) local but_UI_label = {} local button_pip = nil + if args.dynamic_label then + but_UI_label = {} + + table.insert(but_UI_label, {n=G.UIT.R, config={align = "cm", padding = 0, minw = args.minw, maxw = args.maxw}, nodes={ + {n=G.UIT.T, config={ref_table = args.dynamic_label, ref_value = 'text', scale = args.scale, colour = args.text_colour, shadow = args.shadow, focus_args = button_pip and args.focus_args or nil, func = button_pip,}} + }}) + end for k, v in ipairs(args.label) do if k == #args.label and args.focus_args and args.focus_args.set_button_pip then button_pip ='set_button_pip' @@ -6388,7 +6460,7 @@ function UIBox_button(args) padding = args.padding or 0, r = 0.1, hover = true, - colour = args.colour, + colour = args.ref_table and args.ref_table.colour or args.colour, -- Cartomancer one_press = args.one_press, button = (args.button ~= 'nil') and args.button or nil, choice = args.choice, @@ -6402,6 +6474,6 @@ function UIBox_button(args) ref_table = args.ref_table, mid = args.mid }, nodes= - but_UI_label + args.ref_table and args.ref_table.custom_button or but_UI_label -- Cartomancer }}} end diff --git a/lovely/dump/functions/button_callbacks.lua b/lovely/dump/functions/button_callbacks.lua index ecaa550..ca7e464 100644 --- a/lovely/dump/functions/button_callbacks.lua +++ b/lovely/dump/functions/button_callbacks.lua @@ -1,4 +1,4 @@ -LOVELY_INTEGRITY = 'e36471bd79b456102440b1c69061665aed2f0a92e67cfd840d15eafe4e55be17' +LOVELY_INTEGRITY = '4a318253e70cba949d05bfb650e28bf79699539c4f0e57a07f3ad3d649a8688b' --Moves the tutorial to the next step in queue -- @@ -55,7 +55,7 @@ end ---@param e {} --**e** Is the UIE that called this function G.FUNCS.can_buy = function(e) - if (to_big(e.config.ref_table.cost) > to_big(G.GAME.dollars) - to_big(G.GAME.bankrupt_at)) and (e.config.ref_table.cost > 0) then + if (e.config.ref_table.cost > G.GAME.dollars - G.GAME.bankrupt_at) and (e.config.ref_table.cost > 0) then e.config.colour = G.C.UI.BACKGROUND_INACTIVE e.config.button = nil else @@ -77,7 +77,7 @@ end ---@param e {} --**e** Is the UIE that called this function G.FUNCS.can_buy_and_use = function(e) - if (((to_big(e.config.ref_table.cost) > to_big(G.GAME.dollars) - to_big(G.GAME.bankrupt_at)) and (e.config.ref_table.cost > 0)) or (not e.config.ref_table:can_use_consumeable())) then + if (((e.config.ref_table.cost > G.GAME.dollars - G.GAME.bankrupt_at) and (e.config.ref_table.cost > 0)) or (not e.config.ref_table:can_use_consumeable())) then e.UIBox.states.visible = false e.config.colour = G.C.UI.BACKGROUND_INACTIVE e.config.button = nil @@ -96,7 +96,7 @@ end ---@param e {} --**e** Is the UIE that called this function G.FUNCS.can_redeem = function(e) - if to_big(e.config.ref_table.cost) > to_big(G.GAME.dollars) - to_big(G.GAME.bankrupt_at) then + if e.config.ref_table.cost > G.GAME.dollars - G.GAME.bankrupt_at then e.config.colour = G.C.UI.BACKGROUND_INACTIVE e.config.button = nil else @@ -111,7 +111,7 @@ end ---@param e {} --**e** Is the UIE that called this function G.FUNCS.can_open = function(e) - if (e.config.ref_table.cost) > 0 and (to_big(e.config.ref_table.cost) > to_big(G.GAME.dollars) - to_big(G.GAME.bankrupt_at)) then + if (e.config.ref_table.cost) > 0 and (e.config.ref_table.cost > G.GAME.dollars - G.GAME.bankrupt_at) then e.config.colour = G.C.UI.BACKGROUND_INACTIVE e.config.button = nil else @@ -2020,12 +2020,12 @@ G.FUNCS.flame_handler = function(e) local exptime = math.exp(-0.4*G.real_dt) if to_big(G.ARGS.score_intensity.earned_score) >= to_big(G.ARGS.score_intensity.required_score) and to_big(G.ARGS.score_intensity.required_score) > to_big(0) then - _F.intensity = ((G.pack_cards and not G.pack_cards.REMOVED) or (G.TAROT_INTERRUPT)) and 0 or math.max(0., math.log(G.ARGS.score_intensity.earned_score, 5)-2) + _F.intensity = ((G.pack_cards and not G.pack_cards.REMOVED) or (G.TAROT_INTERRUPT)) and 0 or Cartomancer.get_flames_intensity() else _F.intensity = 0 end - _F.timer = _F.timer + G.real_dt*(1 + _F.intensity*0.2) + _F.timer = Cartomancer.handle_flames_timer(_F.timer, _F.intensity) if _F.intensity_vel < 0 then _F.intensity_vel = _F.intensity_vel*(1 - 10*G.real_dt) end _F.intensity_vel = (1-exptime)*(_F.intensity - _F.real_intensity)*G.real_dt*25 + exptime*_F.intensity_vel _F.real_intensity = math.max(0, _F.real_intensity + _F.intensity_vel) @@ -2078,7 +2078,7 @@ end end G.FUNCS.can_reroll = function(e) - if ((to_big(G.GAME.dollars)-to_big(G.GAME.bankrupt_at)) - to_big(G.GAME.current_round.reroll_cost) < to_big(0)) and G.GAME.current_round.reroll_cost ~= 0 then + if ((G.GAME.dollars-G.GAME.bankrupt_at) - G.GAME.current_round.reroll_cost < 0) and G.GAME.current_round.reroll_cost ~= 0 then e.config.colour = G.C.UI.BACKGROUND_INACTIVE e.config.button = nil --e.children[1].children[1].config.shadow = false @@ -2220,29 +2220,30 @@ end nc = obj:keep_on_use(card) end end - if card.area and (not nc or card.area == G.pack_cards) then card.area:remove_card(card) end + if not nc and card.area then card.area:remove_card(card) end - if booster_obj and booster_obj.select_card then - local area = type(booster_obj.select_card) == 'table' and (booster_obj.select_card[e.config.ref_table.ability.set] or nil) or booster_obj.select_card - G[area]:emplace(card) - play_sound('card1', 0.8, 0.6) - play_sound('generic1') - dont_dissolve = true - delay_fac = 0.2 - elseif card.ability.consumeable then - if nc then - if area then area:remove_from_highlighted(card) end - play_sound('cardSlide2', nil, 0.3) - dont_dissolve = true - end - if (G.STATE == G.STATES.TAROT_PACK or G.STATE == G.STATES.PLANET_PACK or G.STATE == G.STATES.SPECTRAL_PACK or G.STATE == G.STATES.SMODS_BOOSTER_OPENED) then + if card.ability.consumeable then + if G.STATE == G.STATES.TAROT_PACK or G.STATE == G.STATES.PLANET_PACK or G.STATE == G.STATES.SPECTRAL_PACK or G.STATE == G.STATES.SMODS_BOOSTER_OPENED then card.T.x = G.hand.T.x + G.hand.T.w/2 - card.T.w/2 card.T.y = G.hand.T.y + G.hand.T.h/2 - card.T.h/2 - 0.5 discover_card(card.config.center) - elseif not nc then draw_card(G.hand, G.play, 1, 'up', true, card, nil, mute) end + elseif nc then + area:remove_from_highlighted(card) + play_sound('cardSlide2', nil, 0.3) + dont_dissolve = true + else draw_card(G.hand, G.play, 1, 'up', true, card, nil, mute) end delay(0.2) e.config.ref_table:use_consumeable(area) - SMODS.calculate_context({using_consumeable = true, consumeable = card, area = card.from_area}) + if card.edition and card.edition.key then + local ed = SMODS.Centers[card.edition.key] + if ed.calculate and type(ed.calculate) == 'function' then + ed:calculate(card, {from_consumable = true}) + end + end + for i = 1, #G.jokers.cards do + G.jokers.cards[i]:calculate_joker({using_consumeable = true, consumeable = card}) + end + G.GAME.selected_back:trigger_effect({context = 'using_consumeable', consumeable = card}) elseif card.ability.set == 'Enhanced' or card.ability.set == 'Default' then G.playing_card = (G.playing_card and G.playing_card + 1) or 1 G.deck:emplace(card) @@ -2293,8 +2294,6 @@ end prev_state == G.STATES.SPECTRAL_PACK or prev_state == G.STATES.STANDARD_PACK or prev_state == G.STATES.SMODS_BOOSTER_OPENED or prev_state == G.STATES.BUFFOON_PACK) and G.booster_pack then - if nc and area == G.pack_cards then G.pack_cards:remove_card(card); G.consumeables:emplace(card) end - booster_obj = nil if area == G.consumeables or area == G.hand then G.booster_pack.alignment.offset.y = G.booster_pack.alignment.offset.py G.booster_pack.alignment.offset.py = nil @@ -2346,7 +2345,12 @@ end G.FUNCS.sell_card = function(e) local card = e.config.ref_table card:sell_card() - SMODS.calculate_context({selling_card = true, card = card}) + for i = 1, #G.jokers.cards do + if G.jokers.cards[i] ~= card then + G.jokers.cards[i]:calculate_joker({selling_card = true, card = card}) + end + end + G.GAME.selected_back:trigger_effect({context = 'selling_card', card = card}) end G.FUNCS.can_confirm_contest_name = function(e) @@ -2438,7 +2442,6 @@ G.FUNCS.buy_from_shop = function(e) trigger = 'after', delay = 0.1, func = function() - c1.from_area = c1.area c1.area:remove_card(c1) c1:add_to_deck() if c1.children.price then c1.children.price:remove() end @@ -2459,11 +2462,7 @@ G.FUNCS.buy_from_shop = function(e) else G.jokers:emplace(c1) end - G.E_MANAGER:add_event(Event({func = function() - local eval, post = eval_card(c1, {buying_card = true, card = c1}) - SMODS.trigger_effects({eval, post}, c1) - return true - end})) + G.E_MANAGER:add_event(Event({func = function() c1:calculate_joker({buying_card = true, card = c1}) return true end})) end --Tallies for unlocks G.GAME.round_scores.cards_purchased.amt = G.GAME.round_scores.cards_purchased.amt + 1 @@ -2477,7 +2476,10 @@ G.FUNCS.buy_from_shop = function(e) G.GAME.current_round.jokers_purchased = G.GAME.current_round.jokers_purchased + 1 end - SMODS.calculate_context({buying_card = true, card = c1}) + for i = 1, #G.jokers.cards do + G.jokers.cards[i]:calculate_joker({buying_card = true, card = c1}) + end + G.GAME.selected_back:trigger_effect({context = 'buying_card', card = c1}) if G.GAME.modifiers.inflation then G.GAME.inflation = G.GAME.inflation + 1 @@ -2509,7 +2511,10 @@ end stop_use() G.CONTROLLER.locks.toggle_shop = true if G.shop then - SMODS.calculate_context({ending_shop = true}) + for i = 1, #G.jokers.cards do + G.jokers.cards[i]:calculate_joker({ending_shop = true}) + end + G.GAME.selected_back:trigger_effect({context = 'ending_shop'}) G.E_MANAGER:add_event(Event({ trigger = 'immediate', func = function() @@ -2582,8 +2587,10 @@ end end G.FUNCS.skip_booster = function(e) - booster_obj = nil - SMODS.calculate_context({skipping_booster = true}) + for i = 1, #G.jokers.cards do + G.jokers.cards[i]:calculate_joker({skipping_booster = true}) + end + G.GAME.selected_back:trigger_effect({context = 'skipping_booster'}) G.FUNCS.end_consumeable(e) end @@ -2614,7 +2621,11 @@ end delay(0.2*delayfac) G.E_MANAGER:add_event(Event({trigger = 'after',delay = 0.2*delayfac, func = function() - G.FUNCS.draw_from_hand_to_deck() + if not G.GAME.USING_RUN then + G.FUNCS.draw_from_hand_to_deck() + else + G.FUNCS.draw_from_hand_to_run() + end G.E_MANAGER:add_event(Event({trigger = 'after',delay = 0.2*delayfac, func = function() if G.shop and G.shop.alignment.offset.py then @@ -2791,7 +2802,10 @@ end trigger = 'immediate', func = function() delay(0.3) - SMODS.calculate_context({skip_blind = true}) + for i = 1, #G.jokers.cards do + G.jokers.cards[i]:calculate_joker({skip_blind = true}) + end + G.GAME.selected_back:trigger_effect({context = 'skip_blind'}) save_run() for i = 1, #G.GAME.tags do G.GAME.tags[i]:apply_to_run({type = 'immediate'}) @@ -2806,7 +2820,7 @@ end end G.FUNCS.reroll_boss_button = function(e) - if ((G.GAME.dollars-G.GAME.bankrupt_at) - cry_cheapest_boss_reroll() >= 0) and + if ((to_big(G.GAME.dollars)-to_big(G.GAME.bankrupt_at)) - to_big(cry_cheapest_boss_reroll()) >= to_big(0)) and (G.GAME.used_vouchers["v_retcon"] or (G.GAME.used_vouchers["v_directors_cut"] and not G.GAME.round_resets.boss_rerolled)) then e.config.colour = G.C.RED @@ -2822,16 +2836,6 @@ end end G.FUNCS.reroll_boss = function(e) - if not G.blind_select_opts then - G.GAME.round_resets.boss_rerolled = true - if not G.from_boss_tag then ease_dollars(-cry_cheapest_boss_reroll()) end - G.from_boss_tag = nil - G.GAME.round_resets.blind_choices.Boss = get_new_boss() - for i = 1, #G.GAME.tags do - if G.GAME.tags[i]:apply_to_run({type = 'new_blind_choice'}) then break end - end - return true - end stop_use() G.GAME.round_resets.boss_rerolled = true if not G.from_boss_tag then ease_dollars(-cry_cheapest_boss_reroll()) end @@ -2931,7 +2935,10 @@ end G.CONTROLLER.interrupt.focus = false G.CONTROLLER.locks.shop_reroll = false G.CONTROLLER:recall_cardarea_focus('shop_jokers') - SMODS.calculate_context({reroll_shop = true}) + for i = 1, #G.jokers.cards do + G.jokers.cards[i]:calculate_joker({reroll_shop = true}) + end + G.GAME.selected_back:trigger_effect({context = 'reroll_shop'}) return true end })) diff --git a/lovely/dump/functions/common_events.lua b/lovely/dump/functions/common_events.lua index f6fee75..a4d23a6 100644 --- a/lovely/dump/functions/common_events.lua +++ b/lovely/dump/functions/common_events.lua @@ -1,4 +1,4 @@ -LOVELY_INTEGRITY = 'ab00e08d711a2c3f72976a640fd09ce67bc5a2fbcc3a1d480a50325ec883c75e' +LOVELY_INTEGRITY = 'ab88a2edb6834f9903a71e4d3886fdab11953bd163c30e4b5640c2bb3712b019' function set_screen_positions() if G.STAGE == G.STAGES.RUN then @@ -75,7 +75,7 @@ function ease_dollars(mod, instant) mod = mod or 0 local text = '+'..localize('$') local col = G.C.MONEY - if to_big(mod) < to_big(0) then + if mod < 0 then text = '-'..localize('$') col = G.C.RED else @@ -120,7 +120,7 @@ function ease_discard(mod, instant, silent) mod = math.max(-G.GAME.current_round.discards_left, mod) local text = '+' local col = G.C.GREEN - if to_big(mod) < to_big(0) then + if mod < 0 then text = '' col = G.C.RED end @@ -159,7 +159,7 @@ function ease_hands_played(mod, instant) mod = mod or 0 local text = '+' local col = G.C.GREEN - if to_big(mod) < to_big(0) then + if mod < 0 then text = '' col = G.C.RED end @@ -200,7 +200,7 @@ function ease_ante(mod) mod = mod or 0 local text = '+' local col = G.C.IMPORTANT - if to_big(mod) < to_big(0) then + if mod < 0 then text = '-' col = G.C.RED end @@ -235,7 +235,7 @@ function ease_round(mod) mod = mod or 0 local text = '+' local col = G.C.IMPORTANT - if to_big(mod) < to_big(0) then + if mod < 0 then text = '' col = G.C.RED end @@ -405,6 +405,9 @@ function draw_card(from, to, percent, dir, sort, card, delay, mute, stay_flipped if card then if from then card = from:remove_card(card) end if card then drawn = true end + if card and to == G.hand and not card.states.visible then + card.states.visible = true + end local stay_flipped = G.GAME and G.GAME.blind and G.GAME.blind:stay_flipped(to, card) if G.GAME.modifiers.flipped_cards and to == G.hand then if pseudorandom(pseudoseed('flipped_card')) < 1/G.GAME.modifiers.flipped_cards then @@ -484,7 +487,7 @@ function level_up_hand(card, hand, instant, amount) G.GAME.hands[hand].mult = math.max(G.GAME.hands[hand].mult * (universum_mod)^amount, 1) G.GAME.hands[hand].chips = math.max(G.GAME.hands[hand].chips * (universum_mod)^amount, 1) end - if not instant and not Talisman.config_file.disable_anims then + if not instant then G.E_MANAGER:add_event(Event({trigger = 'after', delay = 0.2, func = function() play_sound('tarot1') if card and card.juice_up then card:juice_up(0.8, 0.5) end @@ -574,8 +577,8 @@ function update_hand_text(config, vals) G.GAME.current_round.current_hand.hand_level = vals.level else G.GAME.current_round.current_hand.hand_level = ' '..localize('k_lvl')..tostring(vals.level) - if is_number(vals.level) then - G.hand_text_area.hand_level.config.colour = G.C.HAND_LEVELS[to_big(math.min(vals.level, 7)):to_number()] + if type(vals.level) == 'number' then + G.hand_text_area.hand_level.config.colour = G.C.HAND_LEVELS[math.min(vals.level, 7)] else G.hand_text_area.hand_level.config.colour = G.C.HAND_LEVELS[1] end @@ -594,57 +597,39 @@ function update_hand_text(config, vals) end function eval_card(card, context) - if card.ability.set ~= 'Joker' and card.debuff then return {}, {} end + local enhancement_calculated = false + local center = card.config.center context = context or {} local ret = {} if context.repetition_only then - if card.ability.set == 'Enhanced' then - local enhancement = card:calculate_enhancement(context) - if enhancement then - ret.enhancement = enhancement - end + if card.ability.set == 'Enhanced' and center.calculate and type(center.calculate) == 'function' then + center:calculate(card, context, ret) + enhancement_calculated = true end - if card.edition then - local edition = card:calculate_edition(context) - if edition then - ret.edition = edition - end + local seals = card:calculate_seal(context) + if seals then + ret.seals = seals end - if card.seal then - local seals = card:calculate_seal(context) - if seals then - ret.seals = seals - end - end - for k,v in pairs(SMODS.Stickers) do - local sticker = card:calculate_sticker(context, k) - if sticker then - ret[v] = sticker - end - end - - -- TARGET: evaluate your own repetition effects return ret end - if context.cardarea == G.play and context.main_scoring then - ret.playing_card = {} + if context.cardarea == G.play then local chips = card:get_chip_bonus() - if chips ~= 0 then - ret.playing_card.chips = chips + if chips > 0 then + ret.chips = chips end - + local mult = card:get_chip_mult() - if mult ~= 0 then - ret.playing_card.mult = mult + if mult > 0 then + ret.mult = mult end - + local x_mult = card:get_chip_x_mult(context) if x_mult > 0 then - ret.playing_card.x_mult = x_mult + ret.x_mult = x_mult end - + local x_chips = card:get_chip_x_bonus() if x_chips > 0 then ret.x_chips = x_chips @@ -691,95 +676,76 @@ function eval_card(card, context) end local p_dollars = card:get_p_dollars() if p_dollars > 0 then - ret.playing_card.p_dollars = p_dollars + ret.p_dollars = p_dollars + end + + if card.ability.set == 'Enhanced' and center.calculate and type(center.calculate) == 'function' then + center:calculate(card, context, ret) + enhancement_calculated = true end - - -- TARGET: main scoring on played cards - local jokers = card:calculate_joker(context) if jokers then ret.jokers = jokers end - - local edition = card:calculate_edition(context) + + local edition = card:get_edition(context) if edition then ret.edition = edition end end - if context.end_of_round and context.cardarea == G.hand and context.playing_card_end_of_round then - local end_of_round = card:get_end_of_round_effect(context) - if end_of_round then - ret.end_of_round = end_of_round - end - end - if context.cardarea == G.hand and context.main_scoring then - ret.playing_card = {} + if context.cardarea == G.hand then local h_mult = card:get_chip_h_mult() - if h_mult ~= 0 then - ret.playing_card.h_mult = h_mult + if h_mult > 0 then + ret.h_mult = h_mult end - + local h_x_mult = card:get_chip_h_x_mult() if h_x_mult > 0 then - ret.playing_card.x_mult = h_x_mult + ret.x_mult = h_x_mult end - - -- TARGET: main scoring on held cards + if card.ability.set == 'Enhanced' and center.calculate and type(center.calculate) == 'function' then + center:calculate(card, context, ret) + enhancement_calculated = true + end local jokers = card:calculate_joker(context) if jokers then ret.jokers = jokers end end - if card.ability.set == 'Enhanced' then - local enhancement = card:calculate_enhancement(context) - if enhancement then - ret.enhancement = enhancement + if not card.ability.extra_enhancement and card.edition and card.edition.key then + local ed = SMODS.Centers[card.edition.key] + if ed.calculate and type(ed.calculate) == 'function' then + context.from_playing_card = true + ed:calculate(card, context) + context.from_playing_card = nil end end - if card.edition then - local edition = card:calculate_edition(context) - if edition then - ret.edition = edition - end + if not enhancement_calculated and card.ability.set == 'Enhanced' and center.calculate and type(center.calculate) == 'function' then + center:calculate(card, context, ret) + enhancement_calculated = true end - if card.seal and not card.ability.extra_enhancement then - local seals = card:calculate_seal(context) - if seals then - ret.seals = seals - end + local seals = not card.ability.extra_enhancement and card:calculate_seal(context) + if seals then + ret.seals = seals end - for k,v in pairs(SMODS.Stickers) do - local sticker = card:calculate_sticker(context, k) - if sticker then - ret[v] = sticker + if context.cardarea == G.jokers or context.card == G.consumeables then + local jokers = nil + if context.edition then + jokers = card:get_edition(context) + elseif context.other_joker then + jokers = context.other_joker:calculate_joker(context) + else + jokers = card:calculate_joker(context) end - end - - -- TARGET: evaluate your own general effects - local post_trig = {} - local areas = SMODS.get_card_areas('jokers') - local area_set = {} - for _,v in ipairs(areas) do area_set[v] = true end - if card.area and area_set[card.area] then - local jokers, triggered = card:calculate_joker(context) - if jokers or triggered then + if jokers then ret.jokers = jokers - if not (context.retrigger_joker_check or context.retrigger_joker) then - local retriggers = SMODS.calculate_retriggers(card, context, ret) - if next(retriggers) then - ret.retriggers = retriggers - end - end - if not context.post_trigger and not context.retrigger_joker_check and SMODS.optional_features.post_trigger then - SMODS.calculate_context({blueprint_card = context.blueprint_card, post_trigger = true, other_card = card, other_context = context, other_ret = ret}, post_trig) - end end end - - return ret, post_trig + + return ret end function set_alerts() @@ -919,14 +885,7 @@ function card_eval_status_text(card, eval_type, amt, percent, dir, extra) local y_off = 0.15*G.CARD_H if card.area == G.jokers or card.area == G.consumeables then y_off = 0.05*card.T.h - elseif card == G.deck then - y_off = -0.05*G.CARD_H - card_aligned = 'tm' - elseif card.area == G.discard or card.area == G.vouchers then - y_off = card.area == G.discard and -0.35*G.CARD_H or -0.65*G.CARD_H - card = G.deck.cards[1] or G.deck - card_aligned = 'tm' - elseif card.area == G.hand or card.area == G.deck then + elseif card.area == G.hand then y_off = -0.05*G.CARD_H card_aligned = 'tm' elseif card.area == G.play then @@ -951,35 +910,27 @@ function card_eval_status_text(card, eval_type, amt, percent, dir, extra) sound = 'chips1' amt = amt colour = G.C.CHIPS - text = localize{type='variable',key='a_chips'..(to_big(amt) 60 then + if num_dollars > 60 or num_dollars < -60 then + local dollar_string if num_dollars < 0 then --if negative + dollar_string = '-'..localize('$')..(num_dollars*-1) G.E_MANAGER:add_event(Event({ trigger = 'before',delay = 0.38, func = function() G.round_eval:add_child( {n=G.UIT.R, config={align = "cm", id = 'dollar_row_'..(dollar_row+1)..'_'..config.name}, nodes={ - {n=G.UIT.O, config={object = DynaText({string = {'-'..localize('$')..format_ui_value(-num_dollars)}, colours = {G.C.MONEY}, shadow = true, pop_in = 0, scale = 0.65, float = true})}} + {n=G.UIT.O, config={object = DynaText({string = {localize('$')..(num_dollars*-1)}, colours = {G.C.MONEY}, shadow = true, pop_in = 0, scale = 0.65, float = true})}} }}, G.round_eval:get_UIE_by_ID('dollar_'..config.name)) play_sound('coin3', 0.9+0.2*math.random(), 0.7) @@ -1254,6 +1204,7 @@ function add_round_eval_row(config) end })) else --if positive + dollar_string = localize('$')..num_dollars G.E_MANAGER:add_event(Event({ trigger = 'before',delay = 0.38, func = function() @@ -1342,7 +1293,7 @@ function change_shop_size(mod) if not G.GAME.shop then return end G.GAME.shop.joker_max = G.GAME.shop.joker_max + mod if G.shop_jokers and G.shop_jokers.cards then - if to_big(mod) < to_big(0) then + if mod < 0 then --Remove jokers in shop for i = #G.shop_jokers.cards, G.GAME.shop.joker_max+1, -1 do if G.shop_jokers.cards[i] then @@ -1474,7 +1425,7 @@ function check_for_unlock(args) end end if args.type == 'money' then - if to_big(G.GAME.dollars) >= to_big(400) then + if G.GAME.dollars >= 400 then unlock_achievement('nest_egg') end end @@ -1511,7 +1462,7 @@ function check_for_unlock(args) end end if args.type == 'upgrade_hand' then - if to_big(args.level) >= to_big(10) then + if args.level >= 10 then unlock_achievement('retrograde') end end @@ -1748,7 +1699,7 @@ function check_for_unlock(args) end end if args.type == 'money' then - if to_big(card.unlock_condition.extra) <= to_big(G.GAME.dollars) then + if card.unlock_condition.extra <= G.GAME.dollars then ret = true unlock_card(card) end @@ -1938,8 +1889,7 @@ function fetch_achievements() G.ACHIEVEMENTS[kk].earned = true end end - end - if G.F_NO_ACHIEVEMENTS then return end + end if G.F_NO_ACHIEVEMENTS then return end --|FROM LOCAL SETTINGS FILE --|------------------------------------------------------- @@ -1974,32 +1924,15 @@ function fetch_achievements() end function unlock_achievement(achievement_name) - if G.PROFILES[G.SETTINGS.profile].all_unlocked and (G.ACHIEVEMENTS and G.ACHIEVEMENTS[achievement_name] and not G.ACHIEVEMENTS[achievement_name].bypass_all_unlocked and SMODS.config.achievements < 3) or (SMODS.config.achievements < 3 and (G.GAME.seeded or G.GAME.challenge)) then return true end + if G.PROFILES[G.SETTINGS.profile].all_unlocked and (G.ACHIEVEMENTS and G.ACHIEVEMENTS[achievement_name] and not G.ACHIEVEMENTS[achievement_name].bypass_all_unlocked and SMODS.config.achievements < 3) or (SMODS.config.achievements < 3 and (G.GAME.seeded or G.GAME.challenge)) then return end G.E_MANAGER:add_event(Event({ no_delete = true, blockable = false, blocking = false, func = function() if G.STATE ~= G.STATES.HAND_PLAYED then - if G.PROFILES[G.SETTINGS.profile].all_unlocked and (G.ACHIEVEMENTS and G.ACHIEVEMENTS[achievement_name] and not G.ACHIEVEMENTS[achievement_name].bypass_all_unlocked and SMODS.config.achievements < 3) or (SMODS.config.achievements < 3 and (G.GAME.seeded or G.GAME.challenge)) then return true end + if G.PROFILES[G.SETTINGS.profile].all_unlocked and (G.ACHIEVEMENTS and G.ACHIEVEMENTS[achievement_name] and not G.ACHIEVEMENTS[achievement_name].bypass_all_unlocked and SMODS.config.achievements < 3) or (SMODS.config.achievements < 3 and (G.GAME.seeded or G.GAME.challenge)) then return end local achievement_set = false - if not G.ACHIEVEMENTS then fetch_achievements() end - G.SETTINGS.ACHIEVEMENTS_EARNED[achievement_name] = true - G:save_progress() - - if G.ACHIEVEMENTS[achievement_name] and G.ACHIEVEMENTS[achievement_name].mod then - if not G.ACHIEVEMENTS[achievement_name].earned then - --|THIS IS THE FIRST TIME THIS ACHIEVEMENT HAS BEEN EARNED - achievement_set = true - G.FILE_HANDLER.force = true - end - G.ACHIEVEMENTS[achievement_name].earned = true - end - - if achievement_set then - notify_alert(achievement_name) - return true - end if G.F_NO_ACHIEVEMENTS and not (G.ACHIEVEMENTS[achievement_name] or {}).mod then return true end --|LOCAL SETTINGS FILE @@ -2253,7 +2186,6 @@ function get_current_pool(_type, _rarity, _legendary, _append) if _type == 'Joker' then _rarity = (_legendary and 4) or (type(_rarity) == "number" and ((_rarity > 0.95 and 3) or (_rarity > 0.7 and 2) or 1)) or _rarity -_rarity = ({Common = 1, Uncommon = 2, Rare = 3, Legendary = 4})[_rarity] or _rarity local rarity = _rarity or SMODS.poll_rarity("Joker", 'rarity'..G.GAME.round_resets.ante..(_append or '')) _starting_pool, _pool_key = G.P_JOKER_RARITY_POOLS[rarity], 'Joker'..rarity..((not _legendary and _append) or '') @@ -2353,6 +2285,7 @@ local rarity = _rarity or SMODS.poll_rarity("Joker", 'rarity'..G.GAME.round_rese if v.no_pool_flag and G.GAME.pool_flags[v.no_pool_flag] then add = nil end if v.yes_pool_flag and not G.GAME.pool_flags[v.yes_pool_flag] then add = nil end + if v.key == 'j_cry_filler' and _append == 'rta' then add = nil end if v.in_pool and type(v.in_pool) == 'function' then add = in_pool and (add or pool_opts.override_base_checks) @@ -2531,15 +2464,6 @@ function copy_card(other, new_card, card_scale, playing_card, strip_edition) end check_for_unlock({type = 'have_edition'}) new_card:set_seal(other.seal, true) - if other.seal then - for k, v in pairs(other.ability.seal or {}) do - if type(v) == 'table' then - new_card.ability.seal[k] = copy_table(v) - else - new_card.ability.seal[k] = v - end - end - end if other.params then new_card.params = other.params new_card.params.playing_card = playing_card @@ -2892,13 +2816,10 @@ function generate_card_ui(_c, full_UI_table, specific_vars, card_type, badges, h else local res = {} if _c.locked_loc_vars and type(_c.locked_loc_vars) == 'function' then - local _card = _c.create_fake_card and _c:create_fake_card() - res = _c:locked_loc_vars(info_queue, _card) or {} + res = _c:locked_loc_vars(info_queue) or {} loc_vars = res.vars or {} specific_vars = specific_vars or {} specific_vars.not_hidden = res.not_hidden or specific_vars.not_hidden - if res.main_start then desc_nodes[#desc_nodes+1] = res.main_start end - main_end = res.main_end or main_end elseif _c.name == 'Golden Ticket' then elseif _c.name == 'Mr. Bones' then loc_vars = {_c.unlock_condition.extra, G.PROFILES[G.SETTINGS.profile].career_stats.c_losses} elseif _c.name == 'Acrobat' then loc_vars = {_c.unlock_condition.extra, G.PROFILES[G.SETTINGS.profile].career_stats.c_hands_played} @@ -2974,16 +2895,6 @@ function generate_card_ui(_c, full_UI_table, specific_vars, card_type, badges, h elseif specific_vars and specific_vars.debuffed then localize{type = 'other', key = 'debuffed_'..(specific_vars.playing_card and 'playing_card' or 'default'), nodes = desc_nodes} elseif _c.set == 'Joker' then - if not card then - local ability = copy_table(cfg) - ability.set = 'Joker' - ability.name = _c.name - local ret = {Card.generate_UIBox_ability_table({ ability = ability, config = { center = _c }, bypass_lock = true}, true)} - specific_vars = ret[1] - if ret[2] then desc_nodes[#desc_nodes+1] = ret[2] end - main_end = ret[3] - end - if _c.name == 'Stone Joker' or _c.name == 'Marble Joker' then info_queue[#info_queue+1] = G.P_CENTERS.m_stone elseif _c.name == 'Steel Joker' then info_queue[#info_queue+1] = G.P_CENTERS.m_steel elseif _c.name == 'Glass Joker' then info_queue[#info_queue+1] = G.P_CENTERS.m_glass @@ -3008,7 +2919,6 @@ function generate_card_ui(_c, full_UI_table, specific_vars, card_type, badges, h if specific_vars and specific_vars.sticker then info_queue[#info_queue+1] = {key = string.lower(specific_vars.sticker)..'_sticker', set = 'Other'} end localize{type = 'descriptions', key = _c.key, set = _c.set, nodes = desc_nodes, vars = specific_vars or {}} elseif _c.set == 'Tag' then - specific_vars = specific_vars or Tag.get_uibox_table({ name = _c.name, config = _c.config, ability = { orbital_hand = '['..localize('k_poker_hand')..']' }}, nil, true) if _c.name == 'Negative Tag' then info_queue[#info_queue+1] = G.P_CENTERS.e_negative elseif _c.name == 'Foil Tag' then info_queue[#info_queue+1] = G.P_CENTERS.e_foil elseif _c.name == 'Holographic Tag' then info_queue[#info_queue+1] = G.P_CENTERS.e_holo @@ -3036,10 +2946,10 @@ function generate_card_ui(_c, full_UI_table, specific_vars, card_type, badges, h elseif _c.name == "Telescope" or _c.name == "Observatory" then loc_vars = {cfg.extra} elseif _c.name == "Clearance Sale" or _c.name == "Liquidation" then loc_vars = {cfg.extra} end - localize{type = 'descriptions', key = _c.key, set = _c.set, nodes = desc_nodes, vars = _c.vars or loc_vars} + localize{type = 'descriptions', key = _c.key, set = _c.set, nodes = desc_nodes, vars = loc_vars} elseif _c.set == 'Edition' then loc_vars = {cfg.extra} - localize{type = 'descriptions', key = _c.key, set = _c.set, nodes = desc_nodes, vars = _c.vars or loc_vars} + localize{type = 'descriptions', key = _c.key, set = _c.set, nodes = desc_nodes, vars = loc_vars} elseif _c.set == 'Default' and specific_vars then if specific_vars.nominal_chips then localize{type = 'other', key = 'card_chips', nodes = desc_nodes, vars = {specific_vars.nominal_chips}} @@ -3053,13 +2963,13 @@ function generate_card_ui(_c, full_UI_table, specific_vars, card_type, badges, h end if _c.effect == 'Mult Card' then loc_vars = {cfg.mult} elseif _c.effect == 'Wild Card' then - elseif _c.effect == 'Glass Card' then loc_vars = {cfg.Xmult, G.GAME.probabilities.normal, cfg.extra} + elseif _c.effect == 'Glass Card' then loc_vars = {cfg.Xmult, cfg.cry_prob and cry_prob(cfg.cry_prob, cfg.extra, cfg.cry_rigged) or G.GAME.probabilities.normal, cfg.extra} elseif _c.effect == 'Steel Card' then loc_vars = {cfg.h_x_mult} elseif _c.effect == 'Stone Card' then loc_vars = {((specific_vars and specific_vars.bonus_chips) or cfg.bonus)} elseif _c.effect == 'Gold Card' then loc_vars = {cfg.h_dollars} - elseif _c.effect == 'Lucky Card' then loc_vars = {G.GAME.probabilities.normal, cfg.mult, 5, cfg.p_dollars, 15} + elseif _c.effect == 'Lucky Card' then loc_vars = {cfg.cry_prob and cry_prob(cfg.cry_prob, 15, cfg.cry_rigged) or G.GAME.probabilities.normal, cfg.mult, 5, cfg.p_dollars, 15} end - localize{type = 'descriptions', key = _c.key, set = _c.set, nodes = desc_nodes, vars = _c.vars or loc_vars} + localize{type = 'descriptions', key = _c.key, set = _c.set, nodes = desc_nodes, vars = loc_vars} if _c.name ~= 'Stone Card' and ((specific_vars and specific_vars.bonus_chips) or (cfg.bonus ~= 0 and cfg.bonus)) then localize{type = 'other', key = 'card_extra_chips', nodes = desc_nodes, vars = {((specific_vars and specific_vars.bonus_chips) or cfg.bonus)}} end @@ -3092,10 +3002,10 @@ function generate_card_ui(_c, full_UI_table, specific_vars, card_type, badges, h if _c.name == 'Familiar' or _c.name == 'Grim' or _c.name == 'Incantation' then loc_vars = {cfg.extra} elseif _c.name == 'Immolate' then loc_vars = {cfg.extra.destroy, cfg.extra.dollars} elseif _c.name == 'Hex' then info_queue[#info_queue+1] = G.P_CENTERS.e_polychrome - elseif _c.name == 'Talisman' then info_queue[#info_queue+1] = G.P_SEALS['gold_seal'] or G.P_SEALS[SMODS.Seal.badge_to_key['gold_seal'] or ''] - elseif _c.name == 'Deja Vu' then info_queue[#info_queue+1] = G.P_SEALS['red_seal'] or G.P_SEALS[SMODS.Seal.badge_to_key['red_seal'] or ''] - elseif _c.name == 'Trance' then info_queue[#info_queue+1] = G.P_SEALS['blue_seal'] or G.P_SEALS[SMODS.Seal.badge_to_key['blue_seal'] or ''] - elseif _c.name == 'Medium' then info_queue[#info_queue+1] = G.P_SEALS['purple_seal'] or G.P_SEALS[SMODS.Seal.badge_to_key['purple_seal'] or ''] + elseif _c.name == 'Talisman' then info_queue[#info_queue+1] = {key = 'gold_seal', set = 'Other'} + elseif _c.name == 'Deja Vu' then info_queue[#info_queue+1] = {key = 'red_seal', set = 'Other'} + elseif _c.name == 'Trance' then info_queue[#info_queue+1] = {key = 'blue_seal', set = 'Other'} + elseif _c.name == 'Medium' then info_queue[#info_queue+1] = {key = 'purple_seal', set = 'Other'} elseif _c.name == 'Ankh' then if G.jokers and G.jokers.cards then for k, v in ipairs(G.jokers.cards) do @@ -3116,13 +3026,13 @@ function generate_card_ui(_c, full_UI_table, specific_vars, card_type, badges, h info_queue[#info_queue+1] = G.P_CENTERS.e_holo info_queue[#info_queue+1] = G.P_CENTERS.e_polychrome end - localize{type = 'descriptions', key = _c.key, set = _c.set, nodes = desc_nodes, vars = _c.vars or loc_vars} + localize{type = 'descriptions', key = _c.key, set = _c.set, nodes = desc_nodes, vars = loc_vars} elseif _c.set == 'Planet' then loc_vars = { G.GAME.hands[cfg.hand_type].level,localize(cfg.hand_type, 'poker_hands'), G.GAME.hands[cfg.hand_type].l_mult, G.GAME.hands[cfg.hand_type].l_chips, - colours = {(to_big(G.GAME.hands[cfg.hand_type].level)==to_big(1) and G.C.UI.TEXT_DARK or G.C.HAND_LEVELS[to_big(math.min(7, G.GAME.hands[cfg.hand_type].level)):to_number()])} + colours = {(G.GAME.hands[cfg.hand_type].level==1 and G.C.UI.TEXT_DARK or G.C.HAND_LEVELS[math.min(7, G.GAME.hands[cfg.hand_type].level)])} } - localize{type = 'descriptions', key = _c.key, set = _c.set, nodes = desc_nodes, vars = _c.vars or loc_vars} + localize{type = 'descriptions', key = _c.key, set = _c.set, nodes = desc_nodes, vars = loc_vars} elseif _c.set == 'Tarot' then if _c.name == "The Fool" then local fool_c = G.GAME.last_tarot_planet and G.P_CENTERS[G.GAME.last_tarot_planet] or nil @@ -3148,7 +3058,7 @@ function generate_card_ui(_c, full_UI_table, specific_vars, card_type, badges, h elseif _c.name == "The Chariot" then loc_vars = {cfg.max_highlighted, localize{type = 'name_text', set = 'Enhanced', key = cfg.mod_conv}}; info_queue[#info_queue+1] = G.P_CENTERS[cfg.mod_conv] elseif _c.name == "Justice" then loc_vars = {cfg.max_highlighted, localize{type = 'name_text', set = 'Enhanced', key = cfg.mod_conv}}; info_queue[#info_queue+1] = G.P_CENTERS[cfg.mod_conv] elseif _c.name == "The Hermit" then loc_vars = {cfg.extra} - elseif _c.name == "The Wheel of Fortune" then loc_vars = {G.GAME.probabilities.normal, cfg.extra}; info_queue[#info_queue+1] = G.P_CENTERS.e_foil; info_queue[#info_queue+1] = G.P_CENTERS.e_holo; info_queue[#info_queue+1] = G.P_CENTERS.e_polychrome; + elseif _c.name == "The Wheel of Fortune" then loc_vars = {cfg.cry_prob and cry_prob(cfg.cry_prob, cfg.extra, cfg.cry_rigged) or G.GAME.probabilities.normal, cfg.extra}; info_queue[#info_queue+1] = G.P_CENTERS.e_foil; info_queue[#info_queue+1] = G.P_CENTERS.e_holo; info_queue[#info_queue+1] = G.P_CENTERS.e_polychrome; elseif _c.name == "Strength" then loc_vars = {cfg.max_highlighted} elseif _c.name == "The Hanged Man" then loc_vars = {cfg.max_highlighted} elseif _c.name == "Death" then loc_vars = {cfg.max_highlighted} @@ -3170,7 +3080,7 @@ function generate_card_ui(_c, full_UI_table, specific_vars, card_type, badges, h elseif _c.name == "Judgement" then elseif _c.name == "The World" then loc_vars = {cfg.max_highlighted, localize(cfg.suit_conv, 'suits_plural'), colours = {G.C.SUITS[cfg.suit_conv]}} end - localize{type = 'descriptions', key = _c.key, set = _c.set, nodes = desc_nodes, vars = _c.vars or loc_vars} + localize{type = 'descriptions', key = _c.key, set = _c.set, nodes = desc_nodes, vars = loc_vars} end if main_end then @@ -3212,23 +3122,23 @@ function generate_card_ui(_c, full_UI_table, specific_vars, card_type, badges, h info_queue[#info_queue + 1] = G.P_CENTERS[v] end if G.P_CENTERS['e_'..v] and G.P_CENTERS['e_'..v].set == 'Edition' then - local t = {key = 'e_'..v, set = 'Edition', config = {}} - info_queue[#info_queue + 1] = t - if G.P_CENTERS['e_'..v].loc_vars and type(G.P_CENTERS['e_'..v].loc_vars) == 'function' then - local res = G.P_CENTERS['e_'..v]:loc_vars(info_queue, card) or {} - t.vars = res.vars - t.key = res.key or t.key - t.set = res.set or t.set - end + info_queue[#info_queue + 1] = G.P_CENTERS['e_'..v] end - local seal = G.P_SEALS[v] or G.P_SEALS[SMODS.Seal.badge_to_key[v] or ''] - if seal then - info_queue[#info_queue+1] = seal + local seal = SMODS.Seals[v] or SMODS.Seal.badge_to_key[v] and SMODS.Seals[SMODS.Seal.badge_to_key[v]] + if seal and seal.generate_ui ~= 0 then + local t = { key = v, set = 'Other' } + info_queue[#info_queue+1] = t + if seal.loc_vars and type(seal.loc_vars) == 'function' then + local res = seal:loc_vars(info_queue, card) or {} + t.vars = res.vars + t.key = res.key or t.key + t.set = res.set or t.set + end else - if v == 'gold_seal' then info_queue[#info_queue+1] = G.P_SEALS['gold_seal'] or G.P_SEALS[SMODS.Seal.badge_to_key['gold_seal'] or ''] end - if v == 'blue_seal' then info_queue[#info_queue+1] = G.P_SEALS['blue_seal'] or G.P_SEALS[SMODS.Seal.badge_to_key['blue_seal'] or ''] end - if v == 'red_seal' then info_queue[#info_queue+1] = G.P_SEALS['red_seal'] or G.P_SEALS[SMODS.Seal.badge_to_key['red_seal'] or ''] end - if v == 'purple_seal' then info_queue[#info_queue+1] = G.P_SEALS['purple_seal'] or G.P_SEALS[SMODS.Seal.badge_to_key['purple_seal'] or ''] end + if v == 'gold_seal' then info_queue[#info_queue+1] = {key = 'gold_seal', set = 'Other'} end + if v == 'blue_seal' then info_queue[#info_queue+1] = {key = 'blue_seal', set = 'Other'} end + if v == 'red_seal' then info_queue[#info_queue+1] = {key = 'red_seal', set = 'Other'} end + if v == 'purple_seal' then info_queue[#info_queue+1] = {key = 'purple_seal', set = 'Other'} end end local sticker = SMODS.Stickers[v] if sticker then diff --git a/lovely/dump/functions/misc_functions.lua b/lovely/dump/functions/misc_functions.lua index 8c30e57..a283c96 100644 --- a/lovely/dump/functions/misc_functions.lua +++ b/lovely/dump/functions/misc_functions.lua @@ -1,4 +1,4 @@ -LOVELY_INTEGRITY = '947c501831366deb5e5f19e43dac710ed1309c3fcf0da962c8524122a4e9a142' +LOVELY_INTEGRITY = '3062e877afa10107b5e3bbd8ec9b301a451c24f4ae132c36908811e861037ba4' --Updates all display information for all displays for a given screenmode. Returns the key for the resolution option cycle -- @@ -818,7 +818,7 @@ function modulate_sound(dt) for k, v in pairs(G.ARGS.ambient_sounds) do AC[k] = AC[k] or {} AC[k].per = (k == 'ambientOrgan1') and 0.7 or (k == 'ambientFire1' and 1.1) or (k == 'ambientFire2' and 1.05) or 1 - AC[k].vol = (not G.video_organ and G.STATE == G.STATES.SPLASH) and 0 or AC[k].vol and v.volfunc(AC[k].vol) or 0 + AC[k].vol = Cartomancer.handle_flames_volume((not G.video_organ and G.STATE == G.STATES.SPLASH) and 0 or AC[k].vol and v.volfunc(AC[k].vol) or 0) end G.ARGS.push = G.ARGS.push or {} @@ -1577,6 +1577,14 @@ function save_with_action(action) G.action = nil end +function cry_prob(owned, den, rigged) + prob = G.GAME and G.GAME.probabilities.normal or 1 + if rigged then + return den + else + return prob*owned + end +end function save_run() if G.F_NO_SAVING == true then return end local cardAreas = {} @@ -1984,73 +1992,24 @@ end function get_front_spriteinfo(_front) if _front and _front.suit and G.SETTINGS.CUSTOM_DECK and G.SETTINGS.CUSTOM_DECK.Collabs then local collab = G.SETTINGS.CUSTOM_DECK.Collabs[_front.suit] - if collab then + if collab and collab ~= 'default' then local deckSkin = SMODS.DeckSkins[collab] if deckSkin then - if deckSkin.outdated then - local hasRank = false - for i = 1, #deckSkin.ranks do - if deckSkin.ranks[i] == _front.value then hasRank = true break end - end - if hasRank then - local atlas = G.ASSET_ATLAS[G.SETTINGS.colour_palettes[_front.suit] == 'hc' and deckSkin.hc_atlas or deckSkin.lc_atlas] - if atlas then - if deckSkin.pos_style == 'collab' then - return atlas, G.COLLABS.pos[_front.value] - elseif deckSkin.pos_style == 'suit' then - return atlas, { x = _front.pos.x, y = 0} - elseif deckSkin.pos_style == 'deck' then - return atlas, _front.pos - elseif deckSkin.pos_style == 'ranks' or nil then - for i, rank in ipairs(deckSkin.ranks) do - if rank == _front.value then - return atlas, { x = i - 1, y = 0} - end - end - end - end - end - return G.ASSET_ATLAS[G.SETTINGS.colour_palettes[_front.suit] == 'hc' and _front.hc_atlas or _front.lc_atlas or {}] or G.ASSET_ATLAS[_front.atlas] or G.ASSET_ATLAS["cards_"..(G.SETTINGS.colour_palettes[_front.suit] == 'hc' and 2 or 1)], _front.pos - else - local palette = deckSkin.palette_map and deckSkin.palette_map[G.SETTINGS.colour_palettes[_front.suit] or ''] or (deckSkin.palettes or {})[1] - local hasRank = false - for i = 1, #palette.ranks do - if palette.ranks[i] == _front.value then hasRank = true break end - end - if hasRank then - local atlas = G.ASSET_ATLAS[palette.atlas] - if type(palette.pos_style) == "table" then - if palette.pos_style[_front.value] then - if palette.pos_style[_front.value].atlas then - atlas = G.ASSET_ATLAS[palette.pos_style[_front.value].atlas] - end - if palette.pos_style[_front.value].pos then - return atlas, palette.pos_style[_front.value].pos - end - elseif palette.pos_style.fallback_style then - if palette.pos_style.fallback_style == 'collab' then - return atlas, G.COLLABS.pos[_front.value] - elseif palette.pos_style.fallback_style == 'suit' then - return atlas, { x = _front.pos.x, y = 0} - elseif palette.pos_style.fallback_style == 'deck' then - return atlas, _front.pos - end - end - elseif palette.pos_style == 'collab' then + local hasRank = false + for i = 1, #deckSkin.ranks do + if deckSkin.ranks[i] == _front.value then hasRank = true break end + end + if hasRank then + local atlas = G.ASSET_ATLAS[G.SETTINGS.colourblind_option and deckSkin.hc_atlas or deckSkin.lc_atlas] + if atlas then + if deckSkin.posStyle == 'collab' then return atlas, G.COLLABS.pos[_front.value] - elseif palette.pos_style == 'suit' then + elseif deckSkin.posStyle == 'suit' then return atlas, { x = _front.pos.x, y = 0} - elseif palette.pos_style == 'deck' then + elseif deckSkin.posStyle == 'deck' then return atlas, _front.pos - elseif palette.pos_style == 'ranks' or nil then - for i, rank in ipairs(palette.ranks) do - if rank == _front.value then - return atlas, { x = i - 1, y = 0} - end - end end end - return G.ASSET_ATLAS[palette.hc_default and _front.hc_atlas or _front.lc_atlas or {}] or G.ASSET_ATLAS[_front.atlas] or G.ASSET_ATLAS["cards_"..(palette.hc_default and 2 or 1)], _front.pos end end end diff --git a/lovely/dump/functions/state_events.lua b/lovely/dump/functions/state_events.lua index acc06e7..1897130 100644 --- a/lovely/dump/functions/state_events.lua +++ b/lovely/dump/functions/state_events.lua @@ -1,7 +1,7 @@ -LOVELY_INTEGRITY = '444830d91f018dc97aacd41f468f575ea3ad4eea5095b8d83a79bd7e8a40c1ff' +LOVELY_INTEGRITY = 'cafd95906db3619524c557a8c0e342367b9d6be2cb63f6f88e533f34308391bc' function win_game() - if (not G.GAME.seeded and not G.GAME.challenge) or SMODS.config.seeded_unlocks then + if not G.GAME.seeded and not G.GAME.challenge then set_joker_win() set_deck_win() @@ -13,6 +13,7 @@ function win_game() check_for_unlock({type = 'win_deck'}) check_for_unlock({type = 'win_stake'}) check_for_unlock({type = 'win'}) + check_for_unlock({type = 'cry_win_with_hand', hand = G.GAME.last_hand_played}) inc_career_stat('c_wins', 1) end @@ -70,7 +71,7 @@ function win_game() end) })) - if (not G.GAME.seeded and not G.GAME.challenge) or SMODS.config.seeded_unlocks then + if not G.GAME.seeded and not G.GAME.challenge then G.PROFILES[G.SETTINGS.profile].stake = math.max(G.PROFILES[G.SETTINGS.profile].stake or 1, (G.GAME.stake or 1)+1) end G:save_progress() @@ -103,11 +104,25 @@ G.GAME.cry_exploit_override = nil if to_big(G.GAME.chips) >= to_big(G.GAME.blind.chips) then game_over = false end - -- context.end_of_round calculations - SMODS.saved = false - SMODS.calculate_context({end_of_round = true, game_over = game_over }) - if SMODS.saved then game_over = false end - -- TARGET: main end_of_round evaluation + for i = 1, #G.playing_cards do + local CARD = G.playing_cards[i] + CARD.cry_debuff_immune = false + end + for i = 1, #G.jokers.cards do + local eval = nil + eval = G.jokers.cards[i]:calculate_joker({end_of_round = true, game_over = game_over, callback = function(card, eval) + if eval then + if eval.saved then + game_over = false + end + card_eval_status_text(card, 'jokers', nil, nil, nil, eval) + end + end}) + + G.jokers.cards[i]:calculate_rental() + G.jokers.cards[i]:calculate_perishable() + end + G.GAME.selected_back:trigger_effect({context = 'end_of_round', game_over = game_over}) if G.GAME.voucher_sticker_index then if G.GAME.voucher_sticker_index.perishable then for k, v in pairs(G.GAME.voucher_sticker_index.perishable) do @@ -277,10 +292,106 @@ G.GAME.cry_exploit_override = nil end) })) end - for _,v in ipairs(SMODS.get_card_areas('playing_cards', 'end_of_round')) do - SMODS.calculate_end_of_round_effects({ cardarea = v, end_of_round = true }) + if scoring_hand then + local unscoring_hand = {} + for i = 1, #G.play.cards do + local is_scoring = false + for j = 1, #scoring_hand do + if G.play.cards[i] == scoring_hand[j] then + is_scoring = true + end + end + if not is_scoring then + unscoring_hand[#unscoring_hand+1] = G.play.cards[i] + end + end + for i = 1, #unscoring_hand do + unscoring_hand[i]:calculate_seal{unscoring = true} + end end + for i=1, #G.hand.cards do + --Check for hand doubling + local reps = {1} + local j = 1 + while j <= #reps do + local percent = (i-0.999)/(#G.hand.cards-0.998) + (j-1)*0.1 + if reps[j] ~= 1 then card_eval_status_text((reps[j].jokers or reps[j].seals).card, 'jokers', nil, nil, nil, (reps[j].jokers or reps[j].seals)) end + + --calculate the hand effects + local effects = {G.hand.cards[i]:get_end_of_round_effect()} + G.hand.cards[i]:calculate_rental() + G.hand.cards[i]:calculate_perishable() + local extra_enhancements = SMODS.get_enhancements(G.hand.cards[i], true) + local old_ability = copy_table(G.hand.cards[i].ability) + local old_center = G.hand.cards[i].config.center + local old_center_key = G.hand.cards[i].config.center_key + for k, _ in pairs(extra_enhancements) do + if G.P_CENTERS[k] then + G.hand.cards[i]:set_ability(G.P_CENTERS[k]) + G.hand.cards[i].ability.extra_enhancement = k + effects[#effects+1] = G.hand.cards[i]:get_end_of_round_effect() + end + end + G.hand.cards[i].ability = old_ability + G.hand.cards[i].config.center = old_center + G.hand.cards[i].config.center_key = old_center_key + G.hand.cards[i]:set_sprites(old_center) + for k=1, #G.jokers.cards do + --calculate the joker individual card effects + local eval = G.jokers.cards[k]:calculate_joker({cardarea = G.hand, other_card = G.hand.cards[i], individual = true, end_of_round = true, callback = function(card, eval, retrigger) + if eval then + table.insert(effects, eval) +effects[#effects].from_retrigger = retrigger +end end, no_retrigger_anim = true}) + end + + if reps[j] == 1 then + --Check for hand doubling + --From Red seal + local eval = eval_card(G.hand.cards[i], {end_of_round = true,cardarea = G.hand, repetition = true, repetition_only = true}) + if next(eval) and (next(effects[1]) or #effects > 1) then + for h = 1, eval.seals.repetitions do + reps[#reps+1] = eval + end + end + + --from Jokers + for j=1, #G.jokers.cards do + --calculate the joker effects + local eval = eval_card(G.jokers.cards[j], {cardarea = G.hand, other_card = G.hand.cards[i], repetition = true, end_of_round = true, card_effects = effects, callback = function(card, ret) eval = {jokers = ret} + if next(eval) then + for h = 1, eval.jokers.repetitions do + reps[#reps+1] = eval + end + end end}) + end + end + + for ii = 1, #effects do + --if this effect came from a joker + if effects[ii].card and not Talisman.config_file.disable_anims then + G.E_MANAGER:add_event(Event({ + trigger = 'immediate', + func = (function() effects[ii].card:juice_up(0.7);return true end) + })) + end + + --If dollars + if effects[ii].h_dollars then + ease_dollars(effects[ii].h_dollars) + card_eval_status_text(G.hand.cards[i], 'dollars', effects[ii].h_dollars, percent) + end + + --Any extras + if effects[ii].extra then + card_eval_status_text(G.hand.cards[i], 'extra', nil, percent, nil, effects[ii].extra) + end + end + j = j + 1 + end + end + delay(0.3) local i = 1 @@ -343,6 +454,11 @@ G.GAME.cry_exploit_override = nil if not G.GAME.modifiers.cry_no_vouchers then if not G.GAME.modifiers.cry_voucher_restock_antes or G.GAME.round_resets.ante % G.GAME.modifiers.cry_voucher_restock_antes == 0 then G.GAME.current_round.voucher = get_next_voucher_key() + G.GAME.current_round.cry_bonusvouchers = {} + G.GAME.cry_bonusvouchersused = {} -- i'm not sure why i'm putting these in two separate tables but it doesn't matter much + for i = 1, G.GAME.cry_bonusvouchercount do + G.GAME.current_round.cry_bonusvouchers[i] = get_next_voucher_key() + end end else very_fair_quip = pseudorandom_element(G.localization.misc.very_fair_quips, pseudoseed("cry_very_fair")) @@ -466,9 +582,14 @@ function new_round() end G.GAME.current_round.semicolon = false - SMODS.calculate_context({setting_blind = true, blind = G.GAME.round_resets.blind}) - - -- TARGET: setting_blind effects + for i = 1, #G.playing_cards do + local CARD = G.playing_cards[i] + CARD.cry_debuff_immune = false + end + for i = 1, #G.jokers.cards do + G.jokers.cards[i]:calculate_joker({setting_blind = true, blind = G.GAME.round_resets.blind}) + end + G.GAME.selected_back:trigger_effect({context = 'setting_blind', blind = G.GAME.round_resets.blind}) delay(0.4) G.E_MANAGER:add_event(Event({ @@ -513,6 +634,7 @@ G.FUNCS.draw_from_deck_to_hand = function(e) hand_space = math.min(#G.deck.cards, 3) end delay(0.3) + if not G.GAME.USING_RUN then for i=1, hand_space do --draw cards from deckL if G.STATE == G.STATES.TAROT_PACK or G.STATE == G.STATES.SPECTRAL_PACK then draw_card(G.deck,G.hand, i*100/hand_space,'up', true) @@ -520,6 +642,18 @@ G.FUNCS.draw_from_deck_to_hand = function(e) draw_card(G.deck,G.hand, i*100/hand_space,'up', true) end end +else + for i = 1, #G.cry_runarea.cards do + draw_card(G.cry_runarea,G.hand, i*100/#G.cry_runarea.cards,'up', true) + end +end + +G.FUNCS.draw_from_hand_to_run = function(e) -- might as well just slap this here + local hand_count = #G.hand.cards + for i=1, hand_count do --draw cards from deck + draw_card(G.hand, G.cry_runarea, i*100/hand_count,'down', nil, nil, 0.08) + end +end end G.FUNCS.discard_cards_from_highlighted = function(e, hook) @@ -537,24 +671,33 @@ G.FUNCS.discard_cards_from_highlighted = function(e, hook) update_hand_text({immediate = true, nopulse = true, delay = 0}, {mult = 0, chips = 0, level = '', handname = ''}) table.sort(G.hand.highlighted, function(a,b) return a.T.x < b.T.x end) inc_career_stat('c_cards_discarded', highlighted_count) - SMODS.calculate_context({pre_discard = true, full_hand = G.hand.highlighted, hook = hook}) - - -- TARGET: pre_discard + for i = 1, #G.hand.cards do + eval_card(G.hand.cards[i], {pre_discard = true, full_hand = G.hand.highlighted, hook = hook}) + end + for j = 1, #G.jokers.cards do + G.jokers.cards[j]:calculate_joker({pre_discard = true, full_hand = G.hand.highlighted, hook = hook}) + end local cards = {} local destroyed_cards = {} for i=1, highlighted_count do - G.hand.highlighted[i]:calculate_seal({discard = true}) local removed = false - local effects = {} - SMODS.calculate_context({discard = true, other_card = G.hand.highlighted[i], full_hand = G.hand.highlighted}, effects) - SMODS.trigger_effects(effects) - for _, eval in pairs(effects) do - if type(eval) == 'table' then - for key, eval2 in pairs(eval) do - if key == 'remove' or (type(eval2) == 'table' and eval2.remove) then removed = true end - end - end + local eval = nil + eval = eval_card(G.hand.highlighted[i], {discard = true, full_hand = G.hand.highlighted}) + if eval and eval.remove then + removed = true + card_eval_status_text(G.hand.highlighted[i], 'jokers', nil, 1, nil, eval) end + for j = 1, #G.jokers.cards do + local eval = nil + eval = G.jokers.cards[j]:calculate_joker({discard = true, other_card = G.hand.highlighted[i], full_hand = G.hand.highlighted, callback = function(card, eval) + if eval then + if eval.remove then removed = true end + card_eval_status_text(card, 'jokers', nil, 1, nil, eval) + end + end}) + + end + G.GAME.selected_back:trigger_effect({context = 'discard', other_card = G.hand.highlighted[i], full_hand = G.hand.highlighted}) table.insert(cards, G.hand.highlighted[i]) if removed then destroyed_cards[#destroyed_cards + 1] = G.hand.highlighted[i] @@ -569,12 +712,11 @@ G.FUNCS.discard_cards_from_highlighted = function(e, hook) end end - -- context.remove_playing_cards from discard - if destroyed_cards[1] then - SMODS.calculate_context({remove_playing_cards = true, removed = destroyed_cards}) + if destroyed_cards[1] then + for j=1, #G.jokers.cards do + eval_card(G.jokers.cards[j], {cardarea = G.jokers, remove_playing_cards = true, removed = destroyed_cards}) + end end - - -- TARGET: effects after cards destroyed in discard G.GAME.round_scores.cards_discarded.amt = G.GAME.round_scores.cards_discarded.amt + #cards check_for_unlock({type = 'discard_custom', cards = cards}) @@ -755,8 +897,8 @@ G.FUNCS.evaluate_play = function(e) highlight_card(scoring_hand[i],(i-0.999)/5,'up') end - percent = 0.3 - percent_delta = 0.08 + local percent = 0.3 + local percent_delta = 0.08 if G.GAME.current_round.current_hand.handname ~= disp_text then delay(0.3) end update_hand_text({sound = G.GAME.current_round.current_hand.handname ~= disp_text and 'button' or nil, volume = 0.4, immediate = true, nopulse = nil, @@ -776,10 +918,19 @@ G.FUNCS.evaluate_play = function(e) end local hand_text_set = false - -- context.before calculations - SMODS.calculate_context({full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, before = true}) - - -- TARGET: effects before scoring starts + for i=1, #G.jokers.cards do + --calculate the joker effects + local effects = eval_card(G.jokers.cards[i], {cardarea = G.jokers, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, before = true, callback = function(card, ret) effects = {jokers = ret} + if effects.jokers then + card_eval_status_text(card, 'jokers', nil, percent, nil, effects.jokers) + percent = percent + percent_delta + if effects.jokers.level_up then + level_up_hand(card, text) + end + end + end}) + end + G.GAME.selected_back:trigger_effect({context = 'before_hand', full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands}) mult = mod_mult(cry_ascend(G.GAME.hands[text].mult)) hand_chips = mod_chips(cry_ascend(G.GAME.hands[text].chips)) @@ -789,95 +940,876 @@ G.FUNCS.evaluate_play = function(e) mult, hand_chips, modded = G.GAME.blind:modify_hand(G.play.cards, poker_hands, text, mult, hand_chips) mult, hand_chips = mod_mult(mult), mod_chips(hand_chips) if modded then update_hand_text({sound = 'chips2', modded = modded}, {chips = hand_chips, mult = mult}) end - delay(0.3) - for _, v in ipairs(SMODS.get_card_areas('playing_cards')) do - SMODS.calculate_main_scoring({cardarea = v, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands}, v == G.play and scoring_hand or nil) - delay(0.3) - end - - --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- - --Joker Effects - --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- - percent = percent + percent_delta - for _, area in ipairs(SMODS.get_card_areas('jokers')) do for _, _card in ipairs(area.cards) do - local effects = {} - -- remove base game joker edition calc - local eval = eval_card(_card, {cardarea = G.jokers, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, edition = true, pre_joker = true}) - if eval.edition then effects[#effects+1] = eval end - - - -- Calculate context.joker_main - local joker_eval, post = eval_card(_card, {cardarea = G.jokers, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, joker_main = true}) - if next(joker_eval) then - if joker_eval.edition then joker_eval.edition = {} end - table.insert(effects, joker_eval) - for _, v in ipairs(post) do effects[#effects+1] = v end - if joker_eval.retriggers then - for rt = 1, #joker_eval.retriggers do - local rt_eval, rt_post = eval_card(_card, {cardarea = G.jokers, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, joker_main = true, retrigger_joker = true}) - table.insert(effects, {joker_eval.retriggers[rt]}) - table.insert(effects, rt_eval) - for _, v in ipairs(rt_post) do effects[#effects+1] = v end - end + for i=1, #scoring_hand do + --add cards played to list + if not SMODS.has_no_rank(scoring_hand[i]) then + G.GAME.cards_played[scoring_hand[i].base.value].total = G.GAME.cards_played[scoring_hand[i].base.value].total + 1 + if not SMODS.has_no_suit(scoring_hand[i]) then + G.GAME.cards_played[scoring_hand[i].base.value].suits[scoring_hand[i].base.suit] = true end end - - -- Calculate context.other_joker effects - for _, _area in ipairs(SMODS.get_card_areas('jokers')) do - for _, _joker in ipairs(_area.cards) do - local other_key = 'other_unknown' - if _card.ability.set == 'Joker' then other_key = 'other_joker' end - if _card.ability.consumeable then other_key = 'other_consumeable' end - if _card.ability.set == 'Voucher' then other_key = 'other_voucher' end - -- TARGET: add context.other_something identifier to your cards - local joker_eval,post = eval_card(_joker, {full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, [other_key] = _card, other_main = _card }) - if next(joker_eval) then - if joker_eval.edition then joker_eval.edition = {} end - joker_eval.jokers.juice_card = _joker - table.insert(effects, joker_eval) - for _, v in ipairs(post) do effects[#effects+1] = v end - if joker_eval.retriggers then - for rt = 1, #joker_eval.retriggers do - local rt_eval, rt_post = eval_card(_card, {full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, [other_key] = _card, retrigger_joker = true}) - table.insert(effects, {joker_eval.retriggers[rt]}) - table.insert(effects, rt_eval) - for _, v in ipairs(rt_post) do effects[#effects+1] = v end + --if card is debuffed + if scoring_hand[i].debuff then + G.GAME.blind.triggered = true + G.E_MANAGER:add_event(Event({ + trigger = 'immediate', + func = (function() SMODS.juice_up_blind();return true end) + })) + card_eval_status_text(scoring_hand[i], 'debuff') + else + --Check for play doubling + local reps = {1} + + --From Red seal + local eval = eval_card(scoring_hand[i], {repetition_only = true,cardarea = G.play, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, repetition = true}) + if next(eval) then + for h = 1, eval.seals.repetitions do + reps[#reps+1] = eval + end + end + --From jokers + for j=1, #G.jokers.cards do + --calculate the joker effects + local eval = eval_card(G.jokers.cards[j], {cardarea = G.play, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, other_card = scoring_hand[i], repetition = true, callback = function(card, ret) eval = {jokers = ret} + if next(eval) and eval.jokers then + if not eval.jokers.repetitions then eval.jokers.repetitions = 0 end + for h = 1, eval.jokers.repetitions do + reps[#reps+1] = eval + end + end end}) + end + --From edition + if scoring_hand[i].edition and scoring_hand[i].edition.key then + local ed = SMODS.Centers[scoring_hand[i].edition.key] + if ed.config and ed.config.retriggers then + for h = 1, ed.config.retriggers do + reps[#reps+1] = {seals = { + message = localize("k_again_ex"), + card = scoring_hand[i] + }} + end + end + if ed.calculate and type(ed.calculate) == 'function' then + local check = ed:calculate(scoring_hand[i], {retrigger_edition_check = true, cardarea = G.play, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, other_card = scoring_hand[i], repetition = true}) + if check and type(check) == 'table' and next(check) then + for j = 1, check.repetitions do + reps[#reps+1] = {seals = check} end end end end + for j=1,#reps do + percent = percent + percent_delta + if reps[j] ~= 1 and (not scoring_hand or not scoring_hand[i] or not scoring_hand[i].will_shatter) then + card_eval_status_text((reps[j].jokers or reps[j].seals).card, 'jokers', nil, nil, nil, (reps[j].jokers or reps[j].seals)) + end + + --calculate the hand effects + local effects = {eval_card(scoring_hand[i], {cardarea = G.play, full_hand = G.play.cards, scoring_hand = scoring_hand, poker_hand = text})} + local post_effect = {seals = effects[1].seals, edition = effects[1].edition} + effects[1].seals = nil + effects[1].edition = nil + local extra_enhancements = SMODS.get_enhancements(scoring_hand[i], true) + local old_ability = copy_table(scoring_hand[i].ability) + local old_center = scoring_hand[i].config.center + local old_center_key = scoring_hand[i].config.center_key + for k, _ in pairs(extra_enhancements) do + if G.P_CENTERS[k] then + scoring_hand[i]:set_ability(G.P_CENTERS[k]) + scoring_hand[i].ability.extra_enhancement = k + effects[#effects+1] = eval_card(scoring_hand[i], {cardarea = G.play, full_hand = G.play.cards, scoring_hand = scoring_hand, poker_hand = text, extra_enhancement = true}) + end + end + effects[#effects+1] = post_effect + scoring_hand[i].ability = old_ability + scoring_hand[i].config.center = old_center + scoring_hand[i].config.center_key = old_center_key + scoring_hand[i]:set_sprites(old_center) + for k=1, #G.jokers.cards do + --calculate the joker individual card effects + local eval = G.jokers.cards[k]:calculate_joker({cardarea = G.play, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, other_card = scoring_hand[i], individual = true, callback = function(card, eval, retrigger) + if eval then + table.insert(effects, eval) +effects[#effects].from_retrigger = retrigger +end end, no_retrigger_anim = true}) + + end + scoring_hand[i].lucky_trigger = nil + + for ii = 1, #effects do + --If chips added, do chip add event and add the chips to the total + if effects[ii].chips then + if effects[ii].card then juice_card(effects[ii].card) end + hand_chips = mod_chips(hand_chips + effects[ii].chips) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(scoring_hand[i], 'chips', effects[ii].chips, percent) + end + + --If mult added, do mult add event and add the mult to the total + if effects[ii].mult then + if effects[ii].card then juice_card(effects[ii].card) end + mult = mod_mult(mult + effects[ii].mult) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(scoring_hand[i], 'mult', effects[ii].mult, percent) + end + + --If play dollars added, add dollars to total + if effects[ii].p_dollars then + if effects[ii].card then juice_card(effects[ii].card) end + ease_dollars(effects[ii].p_dollars) + card_eval_status_text(scoring_hand[i], 'dollars', effects[ii].p_dollars, percent) + end + + --If dollars added, add dollars to total + if effects[ii].dollars then + if effects[ii].card then juice_card(effects[ii].card) end + ease_dollars(effects[ii].dollars) + card_eval_status_text(scoring_hand[i], 'dollars', effects[ii].dollars, percent) + end + + --Any extra effects + if effects[ii].extra then + if effects[ii].card then juice_card(effects[ii].card) end + local extras = {mult = false, hand_chips = false} + if effects[ii].extra.mult_mod then mult =mod_mult( mult + effects[ii].extra.mult_mod);extras.mult = true end + if effects[ii].extra.chip_mod then hand_chips = mod_chips(hand_chips + effects[ii].extra.chip_mod);extras.hand_chips = true end + if effects[ii].extra.swap then + local old_mult = mult + mult = mod_mult(hand_chips) + hand_chips = mod_chips(old_mult) + extras.hand_chips = true; extras.mult = true + end + if effects[ii].extra.func then effects[ii].extra.func() end + update_hand_text({delay = 0}, {chips = extras.hand_chips and hand_chips, mult = extras.mult and mult}) + card_eval_status_text(scoring_hand[i], 'extra', nil, percent, nil, effects[ii].extra) + end + + if effects[ii].seals then + if effects[ii].seals.chips then + if effects[ii].card then juice_card(effects[ii].card) end + hand_chips = mod_chips(hand_chips + effects[ii].seals.chips) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(scoring_hand[i], 'chips', effects[ii].seals.chips, percent) + end + + if effects[ii].seals.mult then + if effects[ii].card then juice_card(effects[ii].card) end + mult = mod_mult(mult + effects[ii].seals.mult) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(scoring_hand[i], 'mult', effects[ii].seals.mult, percent) + end + + if effects[ii].seals.p_dollars then + if effects[ii].card then juice_card(effects[ii].card) end + ease_dollars(effects[ii].seals.p_dollars) + card_eval_status_text(scoring_hand[i], 'dollars', effects[ii].seals.p_dollars, percent) + end + + if effects[ii].seals.dollars then + if effects[ii].card then juice_card(effects[ii].card) end + ease_dollars(effects[ii].seals.dollars) + card_eval_status_text(scoring_hand[i], 'dollars', effects[ii].seals.dollars, percent) + end + + if effects[ii].seals.x_mult then + if effects[ii].card then juice_card(effects[ii].card) end + mult = mod_mult(mult*effects[ii].seals.x_mult) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(scoring_hand[i], 'x_mult', effects[ii].seals.x_mult, percent) + end + + if effects[ii].seals.func then + effects[ii].seals.func() + end + end + + --If x_mult added, do mult add event and mult the mult to the total + if effects[ii].x_mult then + if effects[ii].card then juice_card(effects[ii].card) end + mult = mod_mult(mult*effects[ii].x_mult) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(scoring_hand[i], 'x_mult', effects[ii].x_mult, percent) + if next(find_joker("cry-Exponentia")) then + for _, v in pairs(find_joker("cry-Exponentia")) do + local old = v.ability.extra.Emult + v.ability.extra.Emult = v.ability.extra.Emult + v.ability.extra.Emult_mod + card_eval_status_text(v, 'extra', nil, nil, nil, {message = localize{type='variable',key='a_powmult',vars={number_format(to_big(v.ability.extra.Emult))}}}) + exponentia_scale_mod(v, v.ability.extra.Emult_mod, old, v.ability.extra.Emult) + end + end + end + + if effects[ii].x_chips then + mod_percent = true + if effects[ii].card then juice_card(effects[ii].card) end + hand_chips = mod_chips(hand_chips*effects[ii].x_chips) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(scoring_hand[i], 'x_chips', effects[ii].x_chips, percent) + end + if effects[ii].e_chips then + mod_percent = true + if effects[ii].card then juice_card(effects[ii].card) end + hand_chips = mod_chips(hand_chips^effects[ii].e_chips) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(scoring_hand[i], 'e_chips', effects[ii].e_chips, percent) + end + if effects[ii].ee_chips then + mod_percent = true + if effects[ii].card then juice_card(effects[ii].card) end + hand_chips = mod_chips(hand_chips:arrow(2, effects[ii].ee_chips)) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(scoring_hand[i], 'ee_chips', effects[ii].ee_chips, percent) + end + if effects[ii].eee_chips then + mod_percent = true + if effects[ii].card then juice_card(effects[ii].card) end + hand_chips = mod_chips(hand_chips:arrow(3, effects[ii].eee_chips)) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(scoring_hand[i], 'eee_chips', effects[ii].eee_chips, percent) + end + if effects[ii].hyper_chips and type(effects[ii].hyper_chips) == 'table' then + mod_percent = true + if effects[ii].card then juice_card(effects[ii].card) end + hand_chips = mod_chips(hand_chips:arrow(effects[ii].hyper_chips[1], effects[ii].hyper_chips[2])) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(scoring_hand[i], 'hyper_chips', effects[ii].hyper_chips, percent) + end + if effects[ii].e_mult then + mod_percent = true + if effects[ii].card then juice_card(effects[ii].card) end + mult = mod_mult(mult^effects[ii].e_mult) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(scoring_hand[i], 'e_mult', effects[ii].e_mult, percent) + end + if effects[ii].ee_mult then + mod_percent = true + if effects[ii].card then juice_card(effects[ii].card) end + mult = mod_mult(mult:arrow(2, effects[ii].ee_mult)) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(scoring_hand[i], 'ee_mult', effects[ii].ee_mult, percent) + end + if effects[ii].eee_mult then + mod_percent = true + if effects[ii].card then juice_card(effects[ii].card) end + mult = mod_mult(mult:arrow(3, effects[ii].eee_mult)) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(scoring_hand[i], 'eee_mult', effects[ii].eee_mult, percent) + end + if effects[ii].hyper_mult and type(effects[ii].hyper_mult) == 'table' then + mod_percent = true + if effects[ii].card then juice_card(effects[ii].card) end + mult = mod_mult(mult:arrow(effects[ii].hyper_mult[1], effects[ii].hyper_mult[2])) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(scoring_hand[i], 'hyper_mult', effects[ii].hyper_mult, percent) + end + + --calculate the card edition effects + if effects[ii].edition then + if effects[ii].edition.chip_mod then + hand_chips = mod_chips(hand_chips + effects[ii].edition.chip_mod) + local key_switch = (effects[ii].edition.chip_mod > 0 and 'a_chips' or 'a_chips_minus') + card_eval_status_text(scoring_hand[i], 'extra', nil, percent, nil, { + message = localize{type='variable', key=key_switch, vars={math.abs(effects[ii].edition.chip_mod)}}, + chip_mod = true, + colour = G.C.DARK_EDITION, + edition = true + }) + update_hand_text({delay = 0}, {chips = hand_chips}) + end + if effects[ii].edition.mult_mod then + mult = mult + effects[ii].edition.mult_mod + card_eval_status_text(scoring_hand[i], 'extra', nil, percent, nil, { + message = localize{type='variable', key='a_mult', vars={effects[ii].edition.mult_mod}}, + mult_mod = true, + colour = G.C.DARK_EDITION, + edition = true + }) + update_hand_text({delay = 0}, {mult = mult}) + end + if effects[ii].edition.x_mult_mod then + mult = mult * effects[ii].edition.x_mult_mod + card_eval_status_text(scoring_hand[i], 'extra', nil, percent, nil, { + message = localize{type='variable', key='a_xmult', vars={effects[ii].edition.x_mult_mod}}, + x_mult_mod = true, + colour = G.C.DARK_EDITION, + edition = true + }) + update_hand_text({delay = 0}, {mult = mult}) + end + if scoring_hand and scoring_hand[i] and scoring_hand[i].edition then + local trg = scoring_hand[i] + local edi = trg.edition + if edi.x_chips then + hand_chips = mod_chips(hand_chips * edi.x_chips) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(trg, 'extra', nil, percent, nil, + {message = 'X'.. edi.x_chips ..' Chips', + edition = true, + x_chips = true}) + end + if edi.e_chips then + hand_chips = mod_chips(hand_chips ^ edi.e_chips) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(trg, 'extra', nil, percent, nil, + {message = '^'.. edi.e_chips ..' Chips', + edition = true, + e_chips = true}) + end + if edi.ee_chips then + hand_chips = mod_chips(hand_chips:arrow(2, edi.ee_chips)) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(trg, 'extra', nil, percent, nil, + {message = '^^'.. edi.ee_chips ..' Chips', + edition = true, + ee_chips = true}) + end + if edi.eee_chips then + hand_chips = mod_chips(hand_chips:arrow(3, edi.eee_chips)) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(trg, 'extra', nil, percent, nil, + {message = '^^^'.. edi.eee_chips ..' Chips', + edition = true, + eee_chips = true}) + end + if edi.hyper_chips and type(edi.hyper_chips) == 'table' then + hand_chips = mod_chips(hand_chips:arrow(edi.hyper_chips[1], edi.hyper_chips[2])) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(trg, 'extra', nil, percent, nil, + {message = (edi.hyper_chips[1] > 5 and ('{' .. edi.hyper_chips[1] .. '}') or string.rep('^', edi.hyper_chips[1])) .. edi.hyper_chips[2] ..' Chips', + edition = true, + eee_chips = true}) + end + if edi.e_mult then + mult = mod_mult(mult ^ edi.e_mult) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(trg, 'extra', nil, percent, nil, + {message = '^'.. edi.e_mult ..' Mult', + edition = true, + e_mult = true}) + end + if edi.ee_mult then + mult = mod_mult(mult:arrow(2, edi.ee_mult)) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(trg, 'extra', nil, percent, nil, + {message = '^^'.. edi.ee_mult ..' Mult', + edition = true, + ee_mult = true}) + end + if edi.eee_mult then + mult = mod_mult(mult:arrow(3, edi.eee_mult)) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(trg, 'extra', nil, percent, nil, + {message = '^^^'.. edi.eee_mult ..' Mult', + edition = true, + eee_mult = true}) + end + if edi.hyper_mult and type(edi.hyper_mult) == 'table' then + mult = mod_mult(mult:arrow(edi.hyper_mult[1], edi.hyper_mult[2])) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(trg, 'extra', nil, percent, nil, + {message = (edi.hyper_mult[1] > 5 and ('{' .. edi.hyper_mult[1] .. '}') or string.rep('^', edi.hyper_mult[1])) .. edi.hyper_mult[2] ..' Mult', + edition = true, + hyper_mult = true}) + end + end + if effects[ii].edition.p_dollars_mod then + if effects[ii].card then juice_card(effects[ii].card) end + ease_dollars(effects[ii].edition.p_dollars_mod) + card_eval_status_text(scoring_hand[i], 'dollars', effects[ii].edition.p_dollars_mod, percent) + end + if not effects[ii].edition then + hand_chips = mod_chips(hand_chips + (effects[ii].edition.chip_mod or 0)) + mult = mult + (effects[ii].edition.mult_mod or 0) + mult = mod_mult(mult*(effects[ii].edition.x_mult_mod or 1)) + update_hand_text({delay = 0}, { + chips = effects[ii].edition.chip_mod and hand_chips or nil, + mult = (effects[ii].edition.mult_mod or effects[ii].edition.x_mult_mod) and mult or nil, + }) + card_eval_status_text(scoring_hand[i], 'extra', nil, percent, nil, { + message = (effects[ii].edition.chip_mod and localize{type='variable',key='a_chips',vars={effects[ii].edition.chip_mod}}) or + (effects[ii].edition.mult_mod and localize{type='variable',key='a_mult',vars={effects[ii].edition.mult_mod}}) or + (effects[ii].edition.x_mult_mod and localize{type='variable',key='a_xmult',vars={effects[ii].edition.x_mult_mod}}), + chip_mod = effects[ii].edition.chip_mod, + mult_mod = effects[ii].edition.mult_mod, + x_mult_mod = effects[ii].edition.x_mult_mod, + colour = G.C.DARK_EDITION, + edition = true})end + end + if effects[ii].from_retrigger then + card_eval_status_text(effects[ii].from_retrigger.card, 'jokers', nil, nil, nil, effects[ii].from_retrigger) + end + +end + end + end + end + + delay(0.3) + local mod_percent = false + if scoring_hand then + local unscoring_hand = {} + for i = 1, #G.play.cards do + local is_scoring = false + for j = 1, #scoring_hand do + if G.play.cards[i] == scoring_hand[j] then + is_scoring = true + end + end + if not is_scoring then + unscoring_hand[#unscoring_hand+1] = G.play.cards[i] + end + end + for i = 1, #unscoring_hand do + unscoring_hand[i]:calculate_seal{unscoring = true} + end + end + for i=1, #G.hand.cards do + if mod_percent then percent = percent + percent_delta end + mod_percent = false + + --Check for hand doubling + local reps = {1} + local j = 1 + while j <= #reps do + if reps[j] ~= 1 and (not scoring_hand or not scoring_hand[i] or not scoring_hand[i].will_shatter) then + card_eval_status_text((reps[j].jokers or reps[j].seals).card, 'jokers', nil, nil, nil, (reps[j].jokers or reps[j].seals)) + percent = percent + percent_delta + end + + --calculate the hand effects + local effects = {eval_card(G.hand.cards[i], {cardarea = G.hand, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands})} + local extra_enhancements = SMODS.get_enhancements(G.hand.cards[i], true) + local old_ability = copy_table(G.hand.cards[i].ability) + local old_center = G.hand.cards[i].config.center + local old_center_key = G.hand.cards[i].config.center_key + for k, _ in pairs(extra_enhancements) do + if G.P_CENTERS[k] then + G.hand.cards[i]:set_ability(G.P_CENTERS[k]) + G.hand.cards[i].ability.extra_enhancement = k + effects[#effects+1] = eval_card(G.hand.cards[i], {cardarea = G.hand, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, extra_enhancement = true}) + end + end + G.hand.cards[i].ability = old_ability + G.hand.cards[i].config.center = old_center + G.hand.cards[i].config.center_key = old_center_key + G.hand.cards[i]:set_sprites(old_center) + + for k=1, #G.jokers.cards do + --calculate the joker individual card effects + local eval = G.jokers.cards[k]:calculate_joker({cardarea = G.hand, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, other_card = G.hand.cards[i], individual = true, callback = function(card, eval, retrigger) + if eval then + mod_percent = true + table.insert(effects, eval) +effects[#effects].from_retrigger = retrigger +end end, no_retrigger_anim = true}) + + end + + if reps[j] == 1 then + --Check for hand doubling + + --From Red seal + local eval = eval_card(G.hand.cards[i], {repetition_only = true,cardarea = G.hand, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, repetition = true, card_effects = effects}) + if next(eval) and (next(effects[1]) or #effects > 1) then + for h = 1, eval.seals.repetitions do + reps[#reps+1] = eval + end + end + + --From Joker + for j=1, #G.jokers.cards do + --calculate the joker effects + local eval = eval_card(G.jokers.cards[j], {cardarea = G.hand, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, other_card = G.hand.cards[i], repetition = true, card_effects = effects, callback = function(card, ret) eval = {jokers = ret} + if next(eval) then + for h = 1, eval.jokers.repetitions do + reps[#reps+1] = eval + end + end end}) + end + end + + for ii = 1, #effects do + --if this effect came from a joker + if effects[ii].card and not Talisman.config_file.disable_anims then + mod_percent = true + G.E_MANAGER:add_event(Event({ + trigger = 'immediate', + func = (function() effects[ii].card:juice_up(0.7);return true end) + })) + end + + --If hold mult added, do hold mult add event and add the mult to the total + + --If dollars added, add dollars to total + if effects[ii].dollars then + ease_dollars(effects[ii].dollars) + card_eval_status_text(G.hand.cards[i], 'dollars', effects[ii].dollars, percent) + end + + if effects[ii].h_mult then + mod_percent = true + mult = mod_mult(mult + effects[ii].h_mult) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(G.hand.cards[i], 'h_mult', effects[ii].h_mult, percent) + end + if effects[ii].h_chips then + if effects[ii].card then juice_card(effects[ii].card) end + hand_chips = mod_chips(hand_chips + effects[ii].h_chips) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(effects[ii].card, 'chips', effects[ii].h_chips, percent) + end + + if effects[ii].x_mult then + mod_percent = true + mult = mod_mult(mult*effects[ii].x_mult) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(G.hand.cards[i], 'x_mult', effects[ii].x_mult, percent) + if next(find_joker("cry-Exponentia")) then + for _, v in pairs(find_joker("cry-Exponentia")) do + local old = v.ability.extra.Emult + v.ability.extra.Emult = v.ability.extra.Emult + v.ability.extra.Emult_mod + card_eval_status_text(v, 'extra', nil, nil, nil, {message = localize{type='variable',key='a_powmult',vars={number_format(to_big(v.ability.extra.Emult))}}}) + exponentia_scale_mod(v, v.ability.extra.Emult_mod, old, v.ability.extra.Emult) + end + end + end + + if effects[ii].x_chips then + mod_percent = true + hand_chips = mod_chips(hand_chips*effects[ii].x_chips) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(G.hand.cards[i], 'x_chips', effects[ii].x_chips, percent) + end + if effects[ii].e_chips then + mod_percent = true + hand_chips = mod_chips(hand_chips^effects[ii].e_chips) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(G.hand.cards[i], 'e_chips', effects[ii].e_chips, percent) + end + if effects[ii].ee_chips then + mod_percent = true + hand_chips = mod_chips(hand_chips:arrow(2, effects[ii].ee_chips)) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(G.hand.cards[i], 'ee_chips', effects[ii].ee_chips, percent) + end + if effects[ii].eee_chips then + mod_percent = true + hand_chips = mod_chips(hand_chips:arrow(3, effects[ii].eee_chips)) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(G.hand.cards[i], 'eee_chips', effects[ii].eee_chips, percent) + end + if effects[ii].hyper_chips and type(effects[ii].hyper_chips) == 'table' then + mod_percent = true + hand_chips = mod_chips(hand_chips:arrow(effects[ii].hyper_chips[1], effects[ii].hyper_chips[2])) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(G.hand.cards[i], 'hyper_chips', effects[ii].hyper_chips, percent) + end + if effects[ii].e_mult then + mod_percent = true + mult = mod_mult(mult^effects[ii].e_mult) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(G.hand.cards[i], 'e_mult', effects[ii].e_mult, percent) + end + if effects[ii].ee_mult then + mod_percent = true + mult = mod_mult(mult:arrow(2, effects[ii].ee_mult)) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(G.hand.cards[i], 'ee_mult', effects[ii].ee_mult, percent) + end + if effects[ii].eee_mult then + mod_percent = true + mult = mod_mult(mult:arrow(3, effects[ii].eee_mult)) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(G.hand.cards[i], 'eee_mult', effects[ii].eee_mult, percent) + end + if effects[ii].hyper_mult and type(effects[ii].hyper_mult) == 'table' then + mod_percent = true + mult = mod_mult(mult:arrow(effects[ii].hyper_mult[1], effects[ii].hyper_mult[2])) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(G.hand.cards[i], 'hyper_mult', effects[ii].hyper_mult, percent) + end + + if effects[ii].message then + mod_percent = true + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(G.hand.cards[i], 'extra', nil, percent, nil, effects[ii]) + end + if effects[ii].from_retrigger then + card_eval_status_text(effects[ii].from_retrigger.card, 'jokers', nil, nil, nil, effects[ii].from_retrigger) + end + +end + j = j +1 + end + end + --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- + --Joker Effects + --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- + percent = percent + percent_delta + local numcards = #G.jokers.cards + #G.consumeables.cards + if G.GAME.modifiers.cry_beta then numcards = #G.jokers.cards end + for i=1, numcards do + local _card = G.jokers.cards[i] or G.consumeables.cards[i - #G.jokers.cards] + --calculate the joker edition effects + local edition_effects = eval_card(_card, {cardarea = G.jokers, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, edition = true}) + if not edition_effects then edition_effects = {} end + if edition_effects.jokers then + edition_effects.jokers.edition = true + if edition_effects.jokers.p_dollars_mod then + ease_dollars(edition_effects.jokers.p_dollars_mod) + card_eval_status_text(_card, 'dollars', edition_effects.jokers.p_dollars_mod, percent) + end + if edition_effects.jokers.chip_mod then + hand_chips = mod_chips(hand_chips + edition_effects.jokers.chip_mod) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(_card, 'jokers', nil, percent, nil, { + message = localize{type='variable',key='a_chips',vars={edition_effects.jokers.chip_mod}}, + chip_mod = edition_effects.jokers.chip_mod, + colour = G.C.EDITION, + edition = true}) + if (effects and effects[ii] and effects[ii].edition and effects[ii].edition.x_mult_mod or edition_effects and edition_effects.jokers and edition_effects.jokers.x_mult_mod) and next(find_joker("cry-Exponentia")) then + for _, v in pairs(find_joker("cry-Exponentia")) do + local old = v.ability.extra.Emult + v.ability.extra.Emult = v.ability.extra.Emult + v.ability.extra.Emult_mod + card_eval_status_text(v, 'extra', nil, nil, nil, {message = localize{type='variable',key='a_powmult',vars={number_format(to_big(v.ability.extra.Emult))}}}) + exponentia_scale_mod(v, v.ability.extra.Emult_mod, old, v.ability.extra.Emult) + end + end + end + if edition_effects.jokers.mult_mod then + mult = mod_mult(mult + edition_effects.jokers.mult_mod) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(_card, 'jokers', nil, percent, nil, { + message = localize{type='variable',key='a_mult',vars={edition_effects.jokers.mult_mod}}, + mult_mod = edition_effects.jokers.mult_mod, + colour = G.C.DARK_EDITION, + edition = true}) + if (effects and effects[ii] and effects[ii].edition and effects[ii].edition.x_mult_mod or edition_effects and edition_effects.jokers and edition_effects.jokers.x_mult_mod) and next(find_joker("cry-Exponentia")) then + for _, v in pairs(find_joker("cry-Exponentia")) do + local old = v.ability.extra.Emult + v.ability.extra.Emult = v.ability.extra.Emult + v.ability.extra.Emult_mod + card_eval_status_text(v, 'extra', nil, nil, nil, {message = localize{type='variable',key='a_powmult',vars={number_format(to_big(v.ability.extra.Emult))}}}) + exponentia_scale_mod(v, v.ability.extra.Emult_mod, old, v.ability.extra.Emult) + end + end + end + percent = percent+percent_delta end - -- calculate edition multipliers - local eval = eval_card(_card, {cardarea = G.jokers, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, edition = true, post_joker = true}) - if eval.edition then effects[#effects+1] = eval end + --calculate the joker effects + local effects = eval_card(_card, {cardarea = G.jokers, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, joker_main = true, callback = function(_card, ret) effects = {jokers = ret} + G.GAME.selected_back:trigger_effect({context = 'joker_main', joker = _card, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands}) - SMODS.trigger_effects(effects, _card) - local deck_effect = G.GAME.selected_back:trigger_effect({full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, other_joker = _card.ability.set == 'Joker' and _card or false, other_consumeable = _card.ability.set ~= 'Joker' and _card or false}) - if deck_effect then SMODS.calculate_effect(deck_effect, G.deck.cards[1] or G.deck) end - end end + --Any Joker effects + if effects.jokers then + local extras = {mult = false, hand_chips = false} + if effects.jokers.mult_mod then mult = mod_mult(mult + effects.jokers.mult_mod);extras.mult = true end + if effects.jokers.chip_mod then hand_chips = mod_chips(hand_chips + effects.jokers.chip_mod);extras.hand_chips = true end + if effects.jokers.Xmult_mod then mult = mod_mult(mult*effects.jokers.Xmult_mod);extras.mult = true end + if effects.jokers.Emult_mod then mult = mod_mult(mult^effects.jokers.Emult_mod);extras.mult = true end + if effects.jokers.EEmult_mod then mult = mod_mult(mult:arrow(2, effects.jokers.EEmult_mod));extras.mult = true end + if effects.jokers.EEEmult_mod then mult = mod_mult(mult:arrow(3, effects.jokers.EEEmult_mod));extras.mult = true end + if effects.jokers.hypermult_mod and type(effects.jokers.hypermult_mod) == 'table' then mult = mod_mult(mult:arrow(effects.jokers.hypermult_mod[1], effects.jokers.hypermult_mod[2]));extras.mult = true end + if effects.jokers.Xchip_mod then hand_chips = mod_chips(hand_chips*effects.jokers.Xchip_mod);extras.hand_chips = true end + if effects.jokers.Echip_mod then hand_chips = mod_chips(hand_chips^effects.jokers.Echip_mod);extras.hand_chips = true end + if effects.jokers.EEchip_mod then hand_chips = mod_chips(hand_chips:arrow(2, effects.jokers.EEchip_mod));extras.hand_chips = true end + if effects.jokers.EEEchip_mod then hand_chips = mod_chips(hand_chips:arrow(3, effects.jokers.EEEchip_mod));extras.hand_chips = true end + if effects.jokers.hyperchip_mod and type(effects.jokers.hyperchip_mod) == 'table' then hand_chips = mod_chips(hand_chips:arrow(effects.jokers.hyperchip_mod[1], effects.jokers.hyperchip_mod[2]));extras.hand_chips = true end + update_hand_text({delay = 0}, {chips = extras.hand_chips and hand_chips, mult = extras.mult and mult}) + card_eval_status_text(_card, 'jokers', nil, percent, nil, effects.jokers) + if effects.jokers.Xmult_mod and effects.jokers.Xmult_mod ~= 1 and next(find_joker("cry-Exponentia")) then + for _, v in pairs(find_joker("cry-Exponentia")) do + local old = v.ability.extra.Emult + v.ability.extra.Emult = v.ability.extra.Emult + v.ability.extra.Emult_mod + card_eval_status_text(v, 'extra', nil, nil, nil, {message = localize{type='variable',key='a_powmult',vars={number_format(to_big(v.ability.extra.Emult))}}}) + exponentia_scale_mod(v, v.ability.extra.Emult_mod, old, v.ability.extra.Emult) + end + end + percent = percent+percent_delta + end + + end}) + --Joker on Joker effects + for _, v in ipairs(G.jokers.cards) do + local effect = v:calculate_joker({full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, other_joker = _card, callback = function(v, effect) + if effect then + local extras = {mult = false, hand_chips = false} + if effect.mult_mod then mult = mod_mult(mult + effect.mult_mod);extras.mult = true end + if effect.chip_mod then hand_chips = mod_chips(hand_chips + effect.chip_mod);extras.hand_chips = true end + if effect.Xmult_mod then mult = mod_mult(mult*effect.Xmult_mod);extras.mult = true end + if effect.Emult_mod then mult = mod_mult(mult^effect.Emult_mod);extras.mult = true end + if effect.EEmult_mod then mult = mod_mult(mult:arrow(2, effect.EEmult_mod));extras.mult = true end + if effect.EEEmult_mod then mult = mod_mult(mult:arrow(3, effect.EEEmult_mod));extras.mult = true end + if effect.hypermult_mod and type(effect.hypermult_mod) == 'table' then mult = mod_mult(mult:arrow(effect.hypermult_mod[1], effect.hypermult_mod[2]));extras.mult = true end + if effect.Xchip_mod then hand_chips = mod_chips(hand_chips*effect.Xchip_mod);extras.hand_chips = true end + if effect.Echip_mod then hand_chips = mod_chips(hand_chips^effect.Echip_mod);extras.hand_chips = true end + if effect.EEchip_mod then hand_chips = mod_chips(hand_chips:arrow(2, effect.EEchip_mod));extras.hand_chips = true end + if effect.EEEchip_mod then hand_chips = mod_chips(hand_chips:arrow(3, effect.EEEchip_mod));extras.hand_chips = true end + if effect.hyperchip_mod and type(effect.hyperchip_mod) == 'table' then hand_chips = mod_chips(hand_chips:arrow(effect.hyperchip_mod[1], effect.hyperchip_mod[2]));extras.hand_chips = true end + if extras.mult or extras.hand_chips then update_hand_text({delay = 0}, {chips = extras.hand_chips and hand_chips, mult = extras.mult and mult}) end + if extras.mult or extras.hand_chips then card_eval_status_text(v, 'jokers', nil, percent, nil, effect) end + if effects.Xmult_mod and next(find_joker("cry-Exponentia")) then + for _, v in pairs(find_joker("cry-Exponentia")) do + local old = v.ability.extra.Emult + v.ability.extra.Emult = v.ability.extra.Emult + v.ability.extra.Emult_mod + card_eval_status_text(v, 'extra', nil, nil, nil, {message = localize{type='variable',key='a_powmult',vars={number_format(to_big(v.ability.extra.Emult))}}}) + exponentia_scale_mod(v, v.ability.extra.Emult_mod, old, v.ability.extra.Emult) + end + end + if effect.Xmult_mod and effect.Xmult_mod ~= 1 and next(find_joker("cry-Exponentia")) then + for _, v in pairs(find_joker("cry-Exponentia")) do + local old = v.ability.extra.Emult + v.ability.extra.Emult = v.ability.extra.Emult + v.ability.extra.Emult_mod + card_eval_status_text(v, 'extra', nil, nil, nil, {message = localize{type='variable',key='a_powmult',vars={number_format(to_big(v.ability.extra.Emult))}}}) + exponentia_scale_mod(v, v.ability.extra.Emult_mod, old, v.ability.extra.Emult) + end + end + percent = percent+percent_delta + end end}) end if edition_effects.jokers then + if edition_effects.jokers.x_mult_mod then + mult = mod_mult(mult*edition_effects.jokers.x_mult_mod) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(_card, 'jokers', nil, percent, nil, { + message = localize{type='variable',key='a_xmult',vars={edition_effects.jokers.x_mult_mod}}, + x_mult_mod = edition_effects.jokers.x_mult_mod, + colour = G.C.EDITION, + edition = true}) + end + if G.jokers.cards and G.jokers.cards[i] and G.jokers.cards[i].edition then + local trg = G.jokers.cards[i] + local edi = trg.edition + if edi.x_chips then + hand_chips = mod_chips(hand_chips * edi.x_chips) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(trg, 'extra', nil, percent, nil, + {message = 'X'.. edi.x_chips ..' Chips', + edition = true, + x_chips = true}) + end + if edi.e_chips then + hand_chips = mod_chips(hand_chips ^ edi.e_chips) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(trg, 'extra', nil, percent, nil, + {message = '^'.. edi.e_chips ..' Chips', + edition = true, + e_chips = true}) + end + if edi.ee_chips then + hand_chips = mod_chips(hand_chips:arrow(2, edi.ee_chips)) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(trg, 'extra', nil, percent, nil, + {message = '^^'.. edi.ee_chips ..' Chips', + edition = true, + ee_chips = true}) + end + if edi.eee_chips then + hand_chips = mod_chips(hand_chips:arrow(3, edi.eee_chips)) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(trg, 'extra', nil, percent, nil, + {message = '^^^'.. edi.eee_chips ..' Chips', + edition = true, + eee_chips = true}) + end + if edi.hyper_chips and type(edi.hyper_chips) == 'table' then + hand_chips = mod_chips(hand_chips:arrow(edi.hyper_chips[1], edi.hyper_chips[2])) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(trg, 'extra', nil, percent, nil, + {message = (edi.hyper_chips[1] > 5 and ('{' .. edi.hyper_chips[1] .. '}') or string.rep('^', edi.hyper_chips[1])) .. edi.hyper_chips[2] ..' Chips', + edition = true, + eee_chips = true}) + end + if edi.e_mult then + mult = mod_mult(mult ^ edi.e_mult) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(trg, 'extra', nil, percent, nil, + {message = '^'.. edi.e_mult ..' Mult', + edition = true, + e_mult = true}) + end + if edi.ee_mult then + mult = mod_mult(mult:arrow(2, edi.ee_mult)) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(trg, 'extra', nil, percent, nil, + {message = '^^'.. edi.ee_mult ..' Mult', + edition = true, + ee_mult = true}) + end + if edi.eee_mult then + mult = mod_mult(mult:arrow(3, edi.eee_mult)) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(trg, 'extra', nil, percent, nil, + {message = '^^^'.. edi.eee_mult ..' Mult', + edition = true, + eee_mult = true}) + end + if edi.hyper_mult and type(edi.hyper_mult) == 'table' then + mult = mod_mult(mult:arrow(edi.hyper_mult[1], edi.hyper_mult[2])) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(trg, 'extra', nil, percent, nil, + {message = (edi.hyper_mult[1] > 5 and ('{' .. edi.hyper_mult[1] .. '}') or string.rep('^', edi.hyper_mult[1])) .. edi.hyper_mult[2] ..' Mult', + edition = true, + hyper_mult = true}) + end + end + edition_effects.jokers.x_mult_mod = nil + if edition_effects.jokers.x_mult_mod then + mult = mod_mult(mult*edition_effects.jokers.x_mult_mod) + update_hand_text({delay = 0}, {mult = mult}) + card_eval_status_text(_card, 'jokers', nil, percent, nil, { + message = localize{type='variable',key='a_xmult',vars={edition_effects.jokers.x_mult_mod}}, + x_mult_mod = edition_effects.jokers.x_mult_mod, + colour = G.C.EDITION, + edition = true}) + if (effects and effects[ii] and effects[ii].edition and effects[ii].edition.x_mult_mod or edition_effects and edition_effects.jokers and edition_effects.jokers.x_mult_mod) and next(find_joker("cry-Exponentia")) then + for _, v in pairs(find_joker("cry-Exponentia")) do + local old = v.ability.extra.Emult + v.ability.extra.Emult = v.ability.extra.Emult + v.ability.extra.Emult_mod + card_eval_status_text(v, 'extra', nil, nil, nil, {message = localize{type='variable',key='a_powmult',vars={number_format(to_big(v.ability.extra.Emult))}}}) + exponentia_scale_mod(v, v.ability.extra.Emult_mod, old, v.ability.extra.Emult) + end + end + end + percent = percent+percent_delta + end + end - -- context.final_scoring_step calculations - SMODS.calculate_context({full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, final_scoring_step = true}) - - -- TARGET: effects before deck final_scoring_step local nu_chip, nu_mult = G.GAME.selected_back:trigger_effect{context = 'final_scoring_step', chips = hand_chips, mult = mult} mult = mod_mult(nu_mult or mult) hand_chips = mod_chips(nu_chip or hand_chips) local cards_destroyed = {} - for _,v in ipairs(SMODS.get_card_areas('playing_cards', 'destroying_cards')) do - SMODS.calculate_destroying_cards({ full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, cardarea = v }, cards_destroyed, v == G.play and scoring_hand or nil) - end - - -- context.remove_playing_cards calculations - if cards_destroyed[1] then - SMODS.calculate_context({scoring_hand = scoring_hand, remove_playing_cards = true, removed = cards_destroyed}) - end - - -- TARGET: effects when cards are removed - + for i=1, #scoring_hand do + local destroyed = nil + --un-highlight all cards + highlight_card(scoring_hand[i],(i-0.999)/(#scoring_hand-0.998),'down') + for j = 1, #G.jokers.cards do + destroyed = G.jokers.cards[j]:calculate_joker({destroying_card = scoring_hand[i], full_hand = G.play.cards, callback = function(card, ret) if ret then destroyed=true end end}) + if destroyed then break end + end + + if SMODS.has_enhancement(scoring_hand[i], 'm_glass') and not scoring_hand[i].debuff and pseudorandom('glass') < cry_prob(scoring_hand[i].ability.cry_prob, scoring_hand[i].ability.extra or G.P_CENTERS.m_glass.config.extra, scoring_hand[i].ability.cry_rigged)/(scoring_hand[i].ability.name == 'Glass Card' and scoring_hand[i].ability.extra or G.P_CENTERS.m_glass.config.extra) then + destroyed = true + end + + if scoring_hand[i].will_shatter then destroyed = true end + if scoring_hand[i]:calculate_seal({destroying_card = scoring_hand[i], full_hand = G.play.cards}) and not scoring_hand[i].ability.eternal then + destroyed = true + end + + if destroyed then + if SMODS.has_enhancement(scoring_hand[i], 'm_glass') then + scoring_hand[i].shattered = true + else + scoring_hand[i].destroyed = true + end + cards_destroyed[#cards_destroyed+1] = scoring_hand[i] + end + end + for j=1, #G.jokers.cards do + eval_card(G.jokers.cards[j], {cardarea = G.jokers, remove_playing_cards = true, removed = cards_destroyed}) + end + G.GAME.selected_back:trigger_effect({context = 'remove_playing_cards', removed = cards_destroyed}) local glass_shattered = {} for k, v in ipairs(cards_destroyed) do @@ -916,10 +1848,17 @@ G.FUNCS.evaluate_play = function(e) --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- --Joker Debuff Effects --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- - -- context.debuffed_hand calculations - SMODS.calculate_context({full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, debuffed_hand = true}) - - -- TARGET: effects after hand debuffed by blind + for i=1, #G.jokers.cards do + + --calculate the joker effects + local effects = eval_card(G.jokers.cards[i], {cardarea = G.jokers, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, debuffed_hand = true, callback = function(card, ret) effects = {jokers = ret} + + --Any Joker effects + if effects.jokers then + card_eval_status_text(card, 'jokers', nil, percent, nil, effects.jokers) + percent = percent+percent_delta + end + end}) end end G.E_MANAGER:add_event(Event({ trigger = 'after',delay = 0.4, @@ -964,11 +1903,17 @@ G.FUNCS.evaluate_play = function(e) })) delay(0.3) - -- context.after calculations - SMODS.calculate_context({full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, after = true}) - - -- TARGET: effects after hand evaluation + for i=1, #G.jokers.cards do + --calculate the joker after hand played effects + local effects = eval_card(G.jokers.cards[i], {cardarea = G.jokers, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, after = true, callback = function(card, ret) effects = {jokers = ret} + if effects.jokers then + card_eval_status_text(card, 'jokers', nil, percent, nil, effects.jokers) + percent = percent + percent_delta + end + end + }) end + G.E_MANAGER:add_event(Event({ trigger = 'immediate', func = (function() @@ -1068,18 +2013,16 @@ G.FUNCS.evaluate_round = function() pitch = pitch + 0.06 dollars = dollars + G.GAME.current_round.discards_left*(G.GAME.modifiers.money_per_discard) end - local i = 0 - for _, area in ipairs(SMODS.get_card_areas('jokers')) do - for _, _card in ipairs(area.cards) do - local ret = _card:calculate_dollar_bonus() - - -- TARGET: calc_dollar_bonus per card - if ret then - i = i+1 - add_round_eval_row({dollars = ret, bonus = true, name='joker'..i, pitch = pitch, card = _card}) - pitch = pitch + 0.06 - dollars = dollars + ret - end + for i = 1, #G.playing_cards do + local CARD = G.playing_cards[i] + CARD.cry_debuff_immune = false + end + for i = 1, #G.jokers.cards do + local ret = G.jokers.cards[i]:calculate_dollar_bonus() + if ret then + add_round_eval_row({dollars = ret, bonus = true, name='joker'..i, pitch = pitch, card = G.jokers.cards[i]}) + pitch = pitch + 0.06 + dollars = dollars + ret end end for i = 1, #G.GAME.tags do @@ -1090,7 +2033,7 @@ G.FUNCS.evaluate_round = function() dollars = dollars + ret.dollars end end - if to_big(G.GAME.dollars) >= to_big(5) and not G.GAME.modifiers.no_interest and G.GAME.cry_payload then + if G.GAME.dollars >= 5 and not G.GAME.modifiers.no_interest and G.GAME.cry_payload then add_round_eval_row({bonus = true, payload = G.GAME.cry_payload, name='interest_payload', pitch = pitch, dollars = G.GAME.interest_amount*G.GAME.cry_payload*math.min(math.floor(G.GAME.dollars/5), G.GAME.interest_cap/5)}) pitch = pitch + 0.06 if not G.GAME.seeded and not G.GAME.challenge then @@ -1103,10 +2046,10 @@ G.FUNCS.evaluate_round = function() check_for_unlock({type = 'interest_streak'}) dollars = dollars + G.GAME.interest_amount*G.GAME.cry_payload*math.min(math.floor(G.GAME.dollars/5), G.GAME.interest_cap/5) G.GAME.cry_payload = nil - elseif to_big(G.GAME.dollars) >= to_big(5) and not G.GAME.modifiers.no_interest then + elseif G.GAME.dollars >= 5 and not G.GAME.modifiers.no_interest then add_round_eval_row({bonus = true, name='interest', pitch = pitch, dollars = G.GAME.interest_amount*math.min(math.floor(G.GAME.dollars/5), G.GAME.interest_cap/5)}) pitch = pitch + 0.06 - if (not G.GAME.seeded and not G.GAME.challenge) or SMODS.config.seeded_unlocks then + if not G.GAME.seeded and not G.GAME.challenge then if G.GAME.interest_amount*math.min(math.floor(G.GAME.dollars/5), G.GAME.interest_cap/5) == G.GAME.interest_amount*G.GAME.interest_cap/5 then G.PROFILES[G.SETTINGS.profile].career_stats.c_round_interest_cap_streak = G.PROFILES[G.SETTINGS.profile].career_stats.c_round_interest_cap_streak + 1 else diff --git a/lovely/dump/game.lua b/lovely/dump/game.lua index 0582f02..d7f96cf 100644 --- a/lovely/dump/game.lua +++ b/lovely/dump/game.lua @@ -1,4 +1,4 @@ -LOVELY_INTEGRITY = 'fff73090942942422c5293599c9a5f94fd18419e9275888a510770e6688dd01c' +LOVELY_INTEGRITY = '6ce2fb7d4e93be5cc027ce62976490e8adadb9539ab9eecba2f579bc9b8dc2e5' --Class Game = Object:extend() @@ -109,7 +109,109 @@ function Game:start_up() boot_timer('window init', 'savemanager') --call the save manager to wait for any save requests G.SAVE_MANAGER = { - thread = love.thread.newThread('engine/save_manager.lua'), + thread = love.thread.newThread([[require "love.system" + + if (love.system.getOS() == 'OS X' ) and (jit.arch == 'arm64' or jit.arch == 'arm') then jit.off() end + + require "love.timer" + require "love.thread" + require 'love.filesystem' + require "engine/object" + require "engine/string_packer" + + --vars needed for sound manager thread + CHANNEL = love.thread.getChannel("save_request") + + talisman = "]] .. Talisman.config_file.break_infinity .. [[" + + --untested + function tal_compress_and_save(_file, _data) + local save_string = type(_data) == 'table' and STR_PACK(_data) or _data + local fallback_save = STR_PACK({GAME = {won = true}}) --just bare minimum to not crash, maybe eventually display some info? + if talisman == 'bignumber' then + fallback_save = "if not BigMeta then " .. fallback_save + elseif talisman == 'omeganum' then + fallback_save = "if not OmegaMeta then " .. fallback_save + else + fallback_save = "if BigMeta or OmegaMeta then " .. fallback_save + end + fallback_save = fallback_save .. " end" + save_string = fallback_save .. " " .. save_string + save_string = love.data.compress('string', 'deflate', save_string, 1) + love.filesystem.write(_file,save_string) + end + + while true do + --Monitor the channel for any new requests + local request = CHANNEL:demand() -- Value from channel + if request then + --Saves progress for settings, unlocks, alerts and discoveries + if request.type == 'save_progress' then + local prefix_profile = (request.save_progress.SETTINGS.profile or 1)..'' + if not love.filesystem.getInfo(prefix_profile) then love.filesystem.createDirectory( prefix_profile ) end + prefix_profile = prefix_profile..'/' + + if not love.filesystem.getInfo(prefix_profile..'meta.jkr') then + love.filesystem.append( prefix_profile..'meta.jkr', 'return {}' ) + end + + local meta = STR_UNPACK(get_compressed(prefix_profile..'meta.jkr') or 'return {}') + meta.unlocked = meta.unlocked or {} + meta.discovered = meta.discovered or {} + meta.alerted = meta.alerted or {} + + local _append = false + + for k, v in pairs(request.save_progress.UDA) do + if string.find(v, 'u') and not meta.unlocked[k] then + meta.unlocked[k] = true + _append = true + end + if string.find(v, 'd') and not meta.discovered[k] then + meta.discovered[k] = true + _append = true + end + if string.find(v, 'a') and not meta.alerted[k] then + meta.alerted[k] = true + _append = true + end + end + if _append then compress_and_save( prefix_profile..'meta.jkr', STR_PACK(meta)) end + + compress_and_save('settings.jkr', request.save_progress.SETTINGS) + compress_and_save(prefix_profile..'profile.jkr', request.save_progress.PROFILE) + + CHANNEL:push('done') + --Saves the settings file + elseif request.type == 'save_settings' then + compress_and_save('settings.jkr', request.save_settings) + compress_and_save(request.profile_num..'/profile.jkr', request.save_profile) + --Saves the metrics file + elseif request.type == 'save_metrics' then + compress_and_save('metrics.jkr', request.save_metrics) + --Saves any notifications + elseif request.type == 'save_notify' then + local prefix_profile = (request.profile_num or 1)..'' + if not love.filesystem.getInfo(prefix_profile) then love.filesystem.createDirectory( prefix_profile ) end + prefix_profile = prefix_profile..'/' + + if not love.filesystem.getInfo(prefix_profile..'unlock_notify.jkr') then love.filesystem.append( prefix_profile..'unlock_notify.jkr', '') end + local unlock_notify = get_compressed(prefix_profile..'unlock_notify.jkr') or '' + + if request.save_notify and not string.find(unlock_notify, request.save_notify) then + compress_and_save( prefix_profile..'unlock_notify.jkr', unlock_notify..request.save_notify..'\n') + end + + --Saves the run + elseif request.type == 'save_run' then + local prefix_profile = (request.profile_num or 1)..'' + if not love.filesystem.getInfo(prefix_profile) then love.filesystem.createDirectory( prefix_profile ) end + prefix_profile = prefix_profile..'/' + + tal_compress_and_save(prefix_profile..'save.jkr', request.save_table) + end + end + end]]), channel = love.thread.getChannel('save_request') } G.SAVE_MANAGER.thread:start(2) @@ -220,6 +322,7 @@ function Game:start_up() end end set_profile_progress() + Cartomancer.load_mod_file('internal/localization.lua', 'localization') boot_timer('prep stage', 'splash prep',1) self:splash_screen() boot_timer('splash prep', 'end',1) @@ -1252,7 +1355,7 @@ function Game:prep_stage(new_stage, new_state, new_game_obj) self.CONTROLLER.locks[k] = nil end if new_game_obj then self.GAME = self:init_game_object() end - if Talisman and Talisman.igo then self.GAME = Talisman.igo(self.GAME) end + if new_game_obj and Talisman and Talisman.igo then self.GAME = Talisman.igo(self.GAME) end self.STAGE = new_stage or self.STAGES.MAIN_MENU self.STATE = new_state or self.STATES.MENU self.STATE_COMPLETE = false @@ -1449,12 +1552,12 @@ function Game:splash_screen() local option = math.random(#mcard) local chosenoption = mcard[option] if chosenoption == "j_cry_biggestm" or chosenoption == "j_cry_reverse" then --These don't render properly; replace these with loopy instead - SC = Card(G.ROOM.T.w/2 - SC_scale*G.CARD_W/2, 10. + G.ROOM.T.h/2 - SC_scale*G.CARD_H/2, SC_scale*G.CARD_W, SC_scale*G.CARD_H, G.P_CARDS.empty, G.P_CENTERS['j_cry_loopy']) + SC = Card(G.ROOM.T.w/2 - SC_scale*G.CARD_W/2, 10. + G.ROOM.T.h/2 - SC_scale*G.CARD_H/2, SC_scale*G.CARD_W, SC_scale*G.CARD_H, G.P_CARDS.empty, G.P_CENTERS['j_cry_loopy'],{bypass_discovery_center = true, bypass_discovery_ui = true}) else - SC = Card(G.ROOM.T.w/2 - SC_scale*G.CARD_W/2, 10. + G.ROOM.T.h/2 - SC_scale*G.CARD_H/2, SC_scale*G.CARD_W, SC_scale*G.CARD_H, G.P_CARDS.empty, G.P_CENTERS[chosenoption]) + SC = Card(G.ROOM.T.w/2 - SC_scale*G.CARD_W/2, 10. + G.ROOM.T.h/2 - SC_scale*G.CARD_H/2, SC_scale*G.CARD_W, SC_scale*G.CARD_H, G.P_CARDS.empty, G.P_CENTERS[chosenoption],{bypass_discovery_center = true, bypass_discovery_ui = true}) end else - SC = Card(G.ROOM.T.w/2 - SC_scale*G.CARD_W/2, 10. + G.ROOM.T.h/2 - SC_scale*G.CARD_H/2, SC_scale*G.CARD_W, SC_scale*G.CARD_H, G.P_CARDS.empty, G.P_CENTERS['j_jolly']) + SC = Card(G.ROOM.T.w/2 - SC_scale*G.CARD_W/2, 10. + G.ROOM.T.h/2 - SC_scale*G.CARD_H/2, SC_scale*G.CARD_W, SC_scale*G.CARD_H, G.P_CARDS.empty, G.P_CENTERS['j_jolly'],{bypass_discovery_center = true, bypass_discovery_ui = true}) end end SC.T.y = G.ROOM.T.h/2 - SC_scale*G.CARD_H/2 @@ -1948,6 +2051,10 @@ function Game:init_game_object() pseudorandom = {}, starting_deck_size = 52, ecto_minus = 1, + cry_bonusvouchercount = 0, + cry_bonusvouchersused = {}, + voucher_edition_index = {}, + voucher_sticker_index = {eternal = {}, perishable = {}, rental = {}, pinned = {}, banana = {}}, -- might as well pack_size = 2, skips = 0, STOP_USE = 0, @@ -2008,6 +2115,9 @@ function Game:init_game_object() hand_level = '' }, used_packs = {}, + cry_bonusvouchers = {}, + cry_voucher_stickers = {eternal = false, perishable = false, rental = false, pinned = false, banana = false}, + cry_voucher_edition = {}, cards_flipped = 0, round_text = 'Round ', idol_card = {suit = 'Spades', rank = 'Ace'}, @@ -2090,13 +2200,20 @@ function Game:start_run(args) local selected_back = saveTable and saveTable.BACK.name or (args.challenge and args.challenge.deck and args.challenge.deck.type) or (self.GAME.viewed_back and self.GAME.viewed_back.name) or self.GAME.selected_back and self.GAME.selected_back.name or 'Red Deck' selected_back = get_deck_from_name(selected_back) self.GAME = saveTable and saveTable.GAME or self:init_game_object() - if Talisman and Talisman.igo then self.GAME = Talisman.igo(self.GAME) end + if (not saveTable or not saveTable.GAME) and Talisman and Talisman.igo then self.GAME = Talisman.igo(self.GAME) end Handy.UI.init() self.GAME.modifiers = self.GAME.modifiers or {} self.GAME.stake = args.stake or self.GAME.stake or 1 self.GAME.STOP_USE = 0 self.GAME.selected_back = Back(selected_back) self.GAME.selected_back_key = selected_back + G.GAME.cry_voucher_centers = {} + for k, v in pairs(G.P_CENTERS) do + if v.set == 'Voucher' then + G.GAME.cry_voucher_centers[k] = {config = {}} + G.GAME.cry_voucher_centers[k].config = copy_table(v.config) + end + end G.C.UI_CHIPS[1], G.C.UI_CHIPS[2], G.C.UI_CHIPS[3], G.C.UI_CHIPS[4] = G.C.BLUE[1], G.C.BLUE[2], G.C.BLUE[3], G.C.BLUE[4] G.C.UI_MULT[1], G.C.UI_MULT[2], G.C.UI_MULT[3], G.C.UI_MULT[4] = G.C.RED[1], G.C.RED[2], G.C.RED[3], G.C.RED[4] @@ -2216,13 +2333,6 @@ function Game:start_run(args) end G.GAME.chips_text = '' - G.GAME.cry_voucher_centers = {} - for k, v in pairs(G.P_CENTERS) do - if v.set == 'Voucher' then - G.GAME.cry_voucher_centers[k] = {config = {}} - G.GAME.cry_voucher_centers[k].config = copy_table(v.config) - end - end if not saveTable then if args.seed then self.GAME.seeded = true end @@ -2261,6 +2371,9 @@ function Game:start_run(args) if not self.GAME.modifiers.cry_no_vouchers then if not G.GAME.modifiers.cry_voucher_restock_antes or G.GAME.round_resets.ante % G.GAME.modifiers.cry_voucher_restock_antes == 0 then self.GAME.current_round.voucher = G.SETTINGS.tutorial_progress and G.SETTINGS.tutorial_progress.forced_voucher or get_next_voucher_key() + for i = 1, self.GAME.cry_bonusvouchercount do + self.GAME.current_round.cry_bonusvouchers[i] = get_next_voucher_key() + end end else very_fair_quip = pseudorandom_element(G.localization.misc.very_fair_quips, pseudoseed("cry_very_fair")) @@ -2348,11 +2461,6 @@ function Game:start_run(args) 0, 0, CAI.discard_W,CAI.discard_H, {card_limit = 1e308, type = 'discard'}) - self.vouchers = CardArea( - G.discard.T.x, G.discard.T.y, - G.discard.T.w, G.discard.T.h, - { type = "discard", card_limit = 1e308 } - ) self.deck = CardArea( 0, 0, CAI.deck_W,CAI.deck_H, @@ -2553,6 +2661,7 @@ function Game:start_run(args) reset_blinds() end + Cartomancer.update_tags_visibility() G.FUNCS.blind_chip_UI_scale(G.hand_text_area.blind_chips) self.HUD:recalculate() @@ -2589,7 +2698,7 @@ function Game:update(dt) self.TIMERS.BACKGROUND = self.TIMERS.BACKGROUND + dt*(G.ARGS.spin and G.ARGS.spin.amount or 0) self.real_dt = dt - if self.real_dt > 0.05 then print('LONG DT @ '..math.floor(G.TIMERS.REAL)..': '..self.real_dt) end + if require('debugplus.config').getValue('enableLongDT') and self.real_dt > 0.05 then print('LONG DT @ '..math.floor(G.TIMERS.REAL)..': '..self.real_dt) end if not G.fbf or G.new_frame then G.new_frame = false @@ -2607,7 +2716,7 @@ function Game:update(dt) if G.STATE ~= G.ACC_state then G.ACC = 0 end G.ACC_state = G.STATE - if (G.STATE == G.STATES.HAND_PLAYED) or (G.STATE == G.STATES.NEW_ROUND) then + if (G.STATE == G.STATES.HAND_PLAYED) or (G.STATE == G.STATES.NEW_ROUND) or Incantation and Incantation.accelerate then G.ACC = math.min((G.ACC or 0) + dt*0.2*self.SETTINGS.GAMESPEED, 16) elseif Handy.insta_cash_out.is_skipped then G.ACC = 999 else @@ -2667,7 +2776,23 @@ function Game:update(dt) end - if G.GAME.USING_RUN then self.STATE = self.STATES.SHOP end + if G.GAME.USING_RUN then + if not (self.STATE == self.STATES.STANDARD_PACK or self.STATE == self.STATES.BUFFOON_PACK or self.STATE == self.STATES.PLANET_PACK or self.STATE == self.STATES.TAROT_PACK or self.STATE == self.STATES.SPECTRAL_PACK or self.STATE == self.STATES.SMODS_BOOSTER_OPENED) then -- do you are have stupid + self.STATE = self.STATES.SHOP + end + if G.GAME.blind then G.GAME.blind:change_colour() end -- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + if G.load_cry_runarea then + G.cry_runarea = CardArea( + G.discard.T.x, + G.discard.T.y, + G.discard.T.w, + G.discard.T.h, + { type = "discard", card_limit = 1e100 } + ) + G.cry_runarea:load(G.load_cry_runarea) + G.load_cry_runarea = nil + end + end if self.STATE == self.STATES.SELECTING_HAND then if (not G.hand.cards[1]) and G.deck.cards[1] then G.STATE = G.STATES.DRAW_TO_HAND @@ -2851,7 +2976,6 @@ function Game:update(dt) if G.FILE_HANDLER.run then G.SAVE_MANAGER.channel:push({ type = 'save_run', - talisman = Talisman.config_file.break_infinity, save_table = G.ARGS.save_run, profile_num = G.SETTINGS.profile}) G.SAVED_GAME = nil @@ -3107,11 +3231,23 @@ love.graphics.pop() timer_checkpoint('canvas', 'draw') - if not _RELEASE_MODE and G.DEBUG and not G.video_control and G.F_VERBOSE then + if require("debugplus.config").getValue("showHUD") and not G.video_control and G.F_VERBOSE then love.graphics.push() love.graphics.setColor(0, 1, 1,1) local fps = love.timer.getFPS( ) - love.graphics.print("Current FPS: "..fps, 10, 10) + do + local otherSize = 0 + for k,v in pairs(G.E_MANAGER.queues or {}) do + if k ~= 'base' then + otherSize = otherSize + #v + end + end + if otherSize ~= 0 then + love.graphics.print(string.format("Current FPS: %d\nBase event queue: %d\nOther event queues: %d", fps, #(G.E_MANAGER.queues and G.E_MANAGER.queues.base or {}), otherSize), 10, 10) + else + love.graphics.print(string.format("Current FPS: %d\nBase event queue: %d", fps, #(G.E_MANAGER.queues and G.E_MANAGER.queues.base or {})), 10, 10) + end + end if G.check and G.SETTINGS.perf_mode then local section_h = 30 @@ -3130,6 +3266,10 @@ love.graphics.pop() end love.graphics.rectangle('fill', 10+poll_w*kk, 20 + v_off, 5*poll_w, -(vv)*resolution) end + v_off = v_off + section_h + end + local v_off = v_off - section_h * #b.checkpoint_list + for k, v in ipairs(b.checkpoint_list) do love.graphics.setColor(a == 2 and 0.5 or 1, a == 2 and 1 or 0.5, 1,1) love.graphics.print(v.label..': '..(string.format("%.2f",1000*(v.average or 0)))..'\n', 10, -section_h + 30 + v_off) v_off = v_off + section_h @@ -3299,20 +3439,48 @@ function Game:update_shop(dt) end end G.shop_vouchers:emplace(card) - end + end for i = 1, #G.GAME.current_round.cry_bonusvouchers do + if not G.GAME.cry_bonusvouchersused[i] then + local card = Card(G.shop_vouchers.T.x + G.shop_vouchers.T.w/2, + G.shop_vouchers.T.y, G.CARD_W, G.CARD_H, G.P_CARDS.empty, G.P_CENTERS[G.GAME.current_round.cry_bonusvouchers[i]],{bypass_discovery_center = true, bypass_discovery_ui = true}) + card.shop_cry_bonusvoucher = i + cry_misprintize(card) + if G.GAME.events.ev_cry_choco2 then + card.misprint_cost_fac = (card.misprint_cost_fac or 1) * 2 + card:set_cost() + end + if G.GAME.modifiers.cry_enable_flipped_in_shop and pseudorandom('cry_flip_vouch'..G.GAME.round_resets.ante) > 0.7 then + card.cry_flipped = true + end + create_shop_card_ui(card, 'Voucher', G.shop_vouchers) + card:start_materialize() + if G.GAME.current_round.cry_voucher_edition then -- eh why not + card:set_edition(G.GAME.current_round.cry_voucher_edition, true, true) + end + G.shop_vouchers.config.card_limit = G.shop_vouchers.config.card_limit + 1 -- does this actually matter/even get reset??? i'm confused but whatever + G.shop_vouchers:emplace(card) + end +end + end - if G.GAME.events.ev_cry_choco10 and not G.load_shop_vouchers then - local card = create_card('Joker', G.jokers, true, nil, nil, nil, nil, 'cry_antique') - cry_misprintize(card) - card.misprint_cost_fac = 50/card.cost - card:set_cost() - create_shop_card_ui(card, 'Voucher', G.shop_vouchers) - card:start_materialize() - card.ability.cry_antique = true - G.shop_vouchers.config.card_limit = G.shop_vouchers.config.card_limit + 1 - G.shop_vouchers:emplace(card) + if G.GAME.events.ev_cry_choco10 then + local add = true + for k, v in pairs(G.shop_vouchers.cards) do -- G.load_shop_vouchers is already set to nil here, just do a normal check + if v.ability.cry_antique then add = false end + end + if add then + local card = create_card('Joker', G.jokers, true, nil, nil, nil, nil, 'cry_antique') + cry_misprintize(card) + card.misprint_cost_fac = 50/card.cost + card:set_cost() + create_shop_card_ui(card, 'Voucher', G.shop_vouchers) + card:start_materialize() + card.ability.cry_antique = true + G.shop_vouchers.config.card_limit = G.shop_vouchers.config.card_limit + 1 + G.shop_vouchers:emplace(card) + end end if G.load_shop_booster then nosave_shop = true @@ -3461,9 +3629,14 @@ end if G.GAME.current_round.hands_played == 0 and G.GAME.current_round.discards_used == 0 and G.GAME.facing_blind then - SMODS.calculate_context({first_hand_drawn = true}) + for i = 1, #G.hand.cards do + eval_card(G.hand.cards[i], {first_hand_drawn = true}) end - SMODS.calculate_context({hand_drawn = true}) + for i = 1, #G.jokers.cards do + G.jokers.cards[i]:calculate_joker({first_hand_drawn = true}) + end + G.GAME.selected_back:trigger_effect({context = 'first_hand_drawn'}) + end G.E_MANAGER:add_event(Event({ trigger = 'immediate', diff --git a/lovely/dump/main.lua b/lovely/dump/main.lua index d827f38..b241497 100644 --- a/lovely/dump/main.lua +++ b/lovely/dump/main.lua @@ -1,4 +1,148 @@ -LOVELY_INTEGRITY = '7a80102588959caa0bf8986947ac508ff87fd856221043d85aeb54a472571ab0' +LOVELY_INTEGRITY = 'b2c04153038fd7e4525be3be1bc642bcab91ec38fb988d0c5db268f85955e1dd' + + +local Cartomancer_replacements = { + { + find = [[ + for k, v in ipairs%(G%.playing_cards%) do + if v%.base%.suit then table%.insert%(SUITS%[v%.base%.suit%], v%) end]], + -- Steamodded<0917b + find_alt = [[ + for k, v in ipairs%(G%.playing_cards%) do + table%.insert%(SUITS%[v%.base%.suit%], v%)]], + place = [[ +local SUITS_SORTED = Cartomancer.tablecopy(SUITS) +for k, v in ipairs(G.playing_cards) do + if v.base.suit then + local greyed + if unplayed_only and not ((v.area and v.area == G.deck) or v.ability.wheel_flipped) then + greyed = true + end + local card_string = v:cart_to_string() + if greyed then + card_string = card_string .. "Greyed" -- for some reason format doesn't work and final string is `sGreyed` + end + if greyed and Cartomancer.SETTINGS.deck_view_hide_drawn_cards then + -- Ignore this card. + elseif not Cartomancer.SETTINGS.deck_view_stack_enabled then + -- Don't stack cards + local _scale = 0.7 + local copy = copy_card(v, nil, _scale) + + copy.greyed = greyed + copy.stacked_quantity = 1 + table.insert(SUITS_SORTED[v.base.suit], copy) + + elseif not SUITS[v.base.suit][card_string] then + -- Initiate stack + table.insert(SUITS_SORTED[v.base.suit], card_string) + + local _scale = 0.7 + local copy = copy_card(v, nil, _scale) + + copy.greyed = greyed + copy.stacked_quantity = 1 + + SUITS[v.base.suit][card_string] = copy + else + -- Stack cards + local stacked_card = SUITS[v.base.suit][card_string] + stacked_card.stacked_quantity = stacked_card.stacked_quantity + 1 + end + end]] + }, + + { + find = "card_limit = #SUITS%[suit_map%[j%]%],", + place = "card_limit = #SUITS_SORTED[suit_map[j]]," + }, + + { + find = [[ +for i = 1%, %#SUITS%[suit_map%[j%]%] do + if SUITS%[suit_map%[j%]%]%[i%] then + local greyed%, _scale = nil%, 0%.7 + if unplayed_only and not %(%(SUITS%[suit_map%[j%]%]%[i%]%.area and SUITS%[suit_map%[j%]%]%[i%]%.area == G%.deck%) or SUITS%[suit_map%[j%]%]%[i%]%.ability%.wheel_flipped%) then + greyed = true + end + local copy = copy_card%(SUITS%[suit_map%[j%]%]%[i%]%, nil%, _scale%) + copy%.greyed = greyed + copy%.T%.x = view_deck%.T%.x %+ view_deck%.T%.w %/ 2 + copy%.T%.y = view_deck%.T%.y + + copy:hard_set_T%(%) + view_deck:emplace%(copy%) + end + end]], + place = [[ +for i = 1%, %#SUITS_SORTED%[suit_map%[j%]%] do + local card + if not Cartomancer.SETTINGS.deck_view_stack_enabled then + card = SUITS_SORTED%[suit_map%[j%]%]%[i%] + else + local card_string = SUITS_SORTED%[suit_map%[j%]%]%[i%] + card = SUITS%[suit_map%[j%]%]%[card_string%] + end + + card%.T%.x = view_deck%.T%.x %+ view_deck%.T%.w%/2 + card%.T%.y = view_deck%.T%.y + card:create_quantity_display%(%) + + card:hard_set_T%(%) + view_deck:emplace%(card%) +end]] + }, + + { + find = ' modded and {n = G.UIT.R, config = {align = "cm"}, nodes = {', + place = [=[ + not unplayed_only and Cartomancer.add_unique_count() or nil, + modded and {n = G.UIT.R, config = {align = "cm"}, nodes = {]=] + }, + +} + + +-- Mom, can we have lovely patches for overrides.lua? +-- No, we have lovely patches at home + +-- Lovely patches at home: + +local Cartomancer_nfs_read +local Cartomancer_nfs_read_override = function (containerOrName, nameOrSize, sizeOrNil) + local data, size = Cartomancer_nfs_read(containerOrName, nameOrSize, sizeOrNil) + + if type(containerOrName) ~= "string" then + return data, size + end + local overrides = '/overrides.lua' + if containerOrName:sub(-#overrides) ~= overrides then + return data, size + end + + local replaced = 0 + local total_replaced = 0 + for _, v in ipairs(Cartomancer_replacements) do + data, replaced = string.gsub(data, v.find, v.place) + + if replaced == 0 and v.find_alt then + data, replaced = string.gsub(data, v.find_alt, v.place) + end + + if replaced == 0 then + print("Failed to replace " .. v.find .. " for overrides.lua") + else + total_replaced = total_replaced + 1 + end + end + + print("Totally applied " .. total_replaced .. " replacements to overrides.lua") + + -- We no longer need this override + NFS.read = Cartomancer_nfs_read + + return data, size +end --- STEAMODDED CORE --- MODULE STACKTRACE @@ -500,7 +644,7 @@ function getDebugInfoForCrash() local versionFile = love.filesystem.read("version.jkr") if versionFile then version = versionFile:match("[^\n]*") .. " (best guess)" - else + else version = "???" end end @@ -511,18 +655,18 @@ function getDebugInfoForCrash() modded_version = reqVersion else modded_version = "???" - end + end end - + local info = "Additional Context:\nBalatro Version: " .. version .. "\nModded Version: " .. (modded_version) local major, minor, revision, codename = love.getVersion() info = info .. string.format("\nLÖVE Version: %d.%d.%d", major, minor, revision) + local lovely_success, lovely = pcall(require, "lovely") if lovely_success then info = info .. "\nLovely Version: " .. lovely.version end - info = info .. "\nPlatform: " .. (love.system.getOS() or "???") if SMODS and SMODS.Mods then local mod_strings = "" local lovely_strings = "" @@ -857,6 +1001,10 @@ injectStackTrace() -- --------MOD CORE API STACKTRACE END----------- if (love.system.getOS() == 'OS X' ) and (jit.arch == 'arm64' or jit.arch == 'arm') then jit.off() end +do + local logger = require("debugplus.logger") + logger.registerLogHandler() +end require "engine/object" require "bit" require "engine/string_packer" @@ -942,11 +1090,15 @@ function love.run() end Cryptid = {} +Cryptid.enabled = {} Cryptid.memepack = {} Cryptid.aliases = {} Cryptid.food = {} Cryptid.M_jokers = {} Cryptid.Megavouchers = {} +function cry_format(...) + return ... +end function love.load() G:start_up() --Steam integration @@ -1002,10 +1154,17 @@ function love.draw() --Perf monitoring checkpoint timer_checkpoint(nil, 'draw', true) G:draw() + do + local console = require("debugplus.console") + console.doConsoleRender() + timer_checkpoint('DebugPlus Console', 'draw') + end end function love.keypressed(key) if Handy.controller.process_key(key, false) then return end +local console = require("debugplus.console") +if not console.consoleHandleKey(key) then return end if not _RELEASE_MODE and G.keybind_mapping[key] then love.gamepadpressed(G.CONTROLLER.keyboard_controller, G.keybind_mapping[key]) else G.CONTROLLER:set_HID_flags('mouse') @@ -1269,7 +1428,6 @@ SMODS.id = 'Steamodded' SMODS.version = MODDED_VERSION:gsub('%-STEAMODDED', '') SMODS.can_load = true SMODS.meta_mod = true -SMODS.config_file = 'config.lua' -- Include lovely and nativefs modules local nativefs = require "nativefs" @@ -1325,6 +1483,10 @@ end SMODS.path = find_self(SMODS.MODS_DIR, 'core.lua', '--- STEAMODDED CORE') +Cartomancer_nfs_read = NFS.read +NFS.read = Cartomancer_nfs_read_override + + for _, path in ipairs { "src/ui.lua", "src/index.lua", @@ -3612,9 +3774,7 @@ if Talisman.config_file.break_infinity then v.s_mult = to_big(v.s_mult) v.l_chips = to_big(v.l_chips) v.l_mult = to_big(v.l_mult) - v.level = to_big(v.level) end - obj.starting_params.dollars = to_big(obj.starting_params.dollars) return obj end @@ -3636,11 +3796,6 @@ if Talisman.config_file.break_infinity then if type(x) == 'table' then return x:floor() end return mf(x) end - local mc = math.ceil - function math.ceil(x) - if type(x) == 'table' then return x:ceil() end - return mc(x) - end local l10 = math.log10 function math.log10(x) @@ -3756,25 +3911,6 @@ if Talisman.config_file.break_infinity then end--]] --going to hold off on modifying this until proper save loading exists end - local ics = inc_career_stat - -- This is used often for unlocks, so we can't just prevent big money from being added - -- Also, I'm completely overriding this, since I don't think any mods would want to change it - function inc_career_stat(stat, mod) - if G.GAME.seeded or G.GAME.challenge then return end - if not G.PROFILES[G.SETTINGS.profile].career_stats[stat] then G.PROFILES[G.SETTINGS.profile].career_stats[stat] = 0 end - G.PROFILES[G.SETTINGS.profile].career_stats[stat] = G.PROFILES[G.SETTINGS.profile].career_stats[stat] + (mod or 0) - -- Make sure this isn't ever a talisman number - if type(G.PROFILES[G.SETTINGS.profile].career_stats[stat]) == 'table' then - if G.PROFILES[G.SETTINGS.profile].career_stats[stat] > to_big(1e300) then - G.PROFILES[G.SETTINGS.profile].career_stats[stat] = to_big(1e300) - elseif G.PROFILES[G.SETTINGS.profile].career_stats[stat] < to_big(-1e300) then - G.PROFILES[G.SETTINGS.profile].career_stats[stat] = to_big(-1e300) - end - G.PROFILES[G.SETTINGS.profile].career_stats[stat] = G.PROFILES[G.SETTINGS.profile].career_stats[stat]:to_number() - end - G:save_settings() - end - local sn = scale_number function scale_number(number, scale, max, e_switch_point) if not Big then return sn(number, scale, max, e_switch_point) end @@ -3934,8 +4070,8 @@ function tal_uht(config, vals) G.GAME.current_round.current_hand.hand_level = vals.level else G.GAME.current_round.current_hand.hand_level = ' '..localize('k_lvl')..tostring(vals.level) - if is_number(vals.level) then - G.hand_text_area.hand_level.config.colour = G.C.HAND_LEVELS[to_big(math.min(vals.level, 7)):to_number()] + if type(vals.level) == 'number' then + G.hand_text_area.hand_level.config.colour = G.C.HAND_LEVELS[math.min(vals.level, 7)] else G.hand_text_area.hand_level.config.colour = G.C.HAND_LEVELS[1] end @@ -3969,145 +4105,135 @@ function Game:update(dt) Talisman.dollar_update = false end end -Talisman.F_NO_COROUTINE = false --easy disabling for bugfixing, since the coroutine can make it hard to see where errors are -if not Talisman.F_NO_COROUTINE then - --scoring coroutine - local oldplay = G.FUNCS.evaluate_play +--scoring coroutine +local oldplay = G.FUNCS.evaluate_play - function G.FUNCS.evaluate_play() - G.SCORING_COROUTINE = coroutine.create(oldplay) - G.LAST_SCORING_YIELD = love.timer.getTime() - G.CARD_CALC_COUNTS = {} -- keys = cards, values = table containing numbers - local success, err = coroutine.resume(G.SCORING_COROUTINE) - if not success then - error(err) +function G.FUNCS.evaluate_play() + G.SCORING_COROUTINE = coroutine.create(oldplay) + G.LAST_SCORING_YIELD = love.timer.getTime() + G.CARD_CALC_COUNTS = {} -- keys = cards, values = table containing numbers + local success, err = coroutine.resume(G.SCORING_COROUTINE) + if not success then + error(err) + end +end + + +local oldupd = love.update +function love.update(dt, ...) + oldupd(dt, ...) + if G.SCORING_COROUTINE then + if collectgarbage("count") > 1024*1024 then + collectgarbage("collect") end - end + if coroutine.status(G.SCORING_COROUTINE) == "dead" then + G.SCORING_COROUTINE = nil + G.FUNCS.exit_overlay_menu() + local totalCalcs = 0 + for i, v in pairs(G.CARD_CALC_COUNTS) do + totalCalcs = totalCalcs + v[1] + end + G.GAME.LAST_CALCS = totalCalcs + else + G.SCORING_TEXT = nil + if not G.OVERLAY_MENU then + G.scoring_text = {"Calculating...", "", "", ""} + G.SCORING_TEXT = { + {n = G.UIT.C, nodes = { + {n = G.UIT.R, config = {padding = 0.1, align = "cm"}, nodes = { + {n=G.UIT.O, config={object = DynaText({string = {{ref_table = G.scoring_text, ref_value = 1}}, colours = {G.C.UI.TEXT_LIGHT}, shadow = true, pop_in = 0, scale = 1, silent = true})}}, + }},{n = G.UIT.R, nodes = { + {n=G.UIT.O, config={object = DynaText({string = {{ref_table = G.scoring_text, ref_value = 2}}, colours = {G.C.UI.TEXT_LIGHT}, shadow = true, pop_in = 0, scale = 0.4, silent = true})}}, + }},{n = G.UIT.R, nodes = { + {n=G.UIT.O, config={object = DynaText({string = {{ref_table = G.scoring_text, ref_value = 3}}, colours = {G.C.UI.TEXT_LIGHT}, shadow = true, pop_in = 0, scale = 0.4, silent = true})}}, + }},{n = G.UIT.R, nodes = { + {n=G.UIT.O, config={object = DynaText({string = {{ref_table = G.scoring_text, ref_value = 4}}, colours = {G.C.UI.TEXT_LIGHT}, shadow = true, pop_in = 0, scale = 0.4, silent = true})}}, + }}}}} + G.FUNCS.overlay_menu({ + definition = + {n=G.UIT.ROOT, minw = G.ROOM.T.w*5, minh = G.ROOM.T.h*5, config={align = "cm", padding = 9999, offset = {x = 0, y = -3}, r = 0.1, colour = {G.C.GREY[1], G.C.GREY[2], G.C.GREY[3],0.7}}, nodes= G.SCORING_TEXT}, + config = {align="cm", offset = {x=0,y=0}, major = G.ROOM_ATTACH, bond = 'Weak'} + }) + else - - local oldupd = love.update - function love.update(dt, ...) - oldupd(dt, ...) - if G.SCORING_COROUTINE then - if collectgarbage("count") > 1024*1024 then - collectgarbage("collect") - end - if coroutine.status(G.SCORING_COROUTINE) == "dead" then - G.SCORING_COROUTINE = nil - G.FUNCS.exit_overlay_menu() - local totalCalcs = 0 - for i, v in pairs(G.CARD_CALC_COUNTS) do - totalCalcs = totalCalcs + v[1] - end - G.GAME.LAST_CALCS = totalCalcs - G.GAME.LAST_CALC_TIME = G.CURRENT_CALC_TIME - else - G.SCORING_TEXT = nil - if not G.OVERLAY_MENU then - G.scoring_text = {"Calculating...", "", "", ""} - G.SCORING_TEXT = { - {n = G.UIT.C, nodes = { - {n = G.UIT.R, config = {padding = 0.1, align = "cm"}, nodes = { - {n=G.UIT.O, config={object = DynaText({string = {{ref_table = G.scoring_text, ref_value = 1}}, colours = {G.C.UI.TEXT_LIGHT}, shadow = true, pop_in = 0, scale = 1, silent = true})}}, - }},{n = G.UIT.R, nodes = { - {n=G.UIT.O, config={object = DynaText({string = {{ref_table = G.scoring_text, ref_value = 2}}, colours = {G.C.UI.TEXT_LIGHT}, shadow = true, pop_in = 0, scale = 0.4, silent = true})}}, - }},{n = G.UIT.R, nodes = { - {n=G.UIT.O, config={object = DynaText({string = {{ref_table = G.scoring_text, ref_value = 3}}, colours = {G.C.UI.TEXT_LIGHT}, shadow = true, pop_in = 0, scale = 0.4, silent = true})}}, - }},{n = G.UIT.R, nodes = { - {n=G.UIT.O, config={object = DynaText({string = {{ref_table = G.scoring_text, ref_value = 4}}, colours = {G.C.UI.TEXT_LIGHT}, shadow = true, pop_in = 0, scale = 0.4, silent = true})}}, - }}}}} - G.FUNCS.overlay_menu({ - definition = - {n=G.UIT.ROOT, minw = G.ROOM.T.w*5, minh = G.ROOM.T.h*5, config={align = "cm", padding = 9999, offset = {x = 0, y = -3}, r = 0.1, colour = {G.C.GREY[1], G.C.GREY[2], G.C.GREY[3],0.7}}, nodes= G.SCORING_TEXT}, - config = {align="cm", offset = {x=0,y=0}, major = G.ROOM_ATTACH, bond = 'Weak'} - }) - else - - if G.OVERLAY_MENU and G.scoring_text then - local totalCalcs = 0 - for i, v in pairs(G.CARD_CALC_COUNTS) do - totalCalcs = totalCalcs + v[1] - end - local jokersYetToScore = #G.jokers.cards + #G.play.cards - #G.CARD_CALC_COUNTS - G.CURRENT_CALC_TIME = (G.CURRENT_CALC_TIME or 0) + dt - G.scoring_text[1] = "Calculating..." - G.scoring_text[2] = "Elapsed calculations: "..tostring(totalCalcs).." ("..tostring(number_format(G.CURRENT_CALC_TIME)).."s)" - G.scoring_text[3] = "Cards yet to score: "..tostring(jokersYetToScore) - G.scoring_text[4] = "Calculations last played hand: " .. tostring(G.GAME.LAST_CALCS or "Unknown") .." ("..tostring(G.GAME.LAST_CALC_TIME and number_format(G.GAME.LAST_CALC_TIME) or "???").."s)" + if G.OVERLAY_MENU and G.scoring_text then + local totalCalcs = 0 + for i, v in pairs(G.CARD_CALC_COUNTS) do + totalCalcs = totalCalcs + v[1] end + local jokersYetToScore = #G.jokers.cards + #G.play.cards - #G.CARD_CALC_COUNTS + G.scoring_text[1] = "Calculating..." + G.scoring_text[2] = "Elapsed calculations: "..tostring(totalCalcs) + G.scoring_text[3] = "Cards yet to score: "..tostring(jokersYetToScore) + G.scoring_text[4] = "Calculations last played hand: " .. tostring(G.GAME.LAST_CALCS or "Unknown") + end - end - --this coroutine allows us to stagger GC cycles through - --the main source of waste in terms of memory (especially w joker retriggers) is through local variables that become garbage - --this practically eliminates the memory overhead of scoring - --event queue overhead seems to not exist if Talismans Disable Scoring Animations is off. - --event manager has to wait for scoring to finish until it can keep processing events anyways. + end + --this coroutine allows us to stagger GC cycles through + --the main source of waste in terms of memory (especially w joker retriggers) is through local variables that become garbage + --this practically eliminates the memory overhead of scoring + --event queue overhead seems to not exist if Talismans Disable Scoring Animations is off. + --event manager has to wait for scoring to finish until it can keep processing events anyways. - - G.LAST_SCORING_YIELD = love.timer.getTime() - - local success, msg = coroutine.resume(G.SCORING_COROUTINE) - if not success then - error(msg) - end - end - end + + G.LAST_SCORING_YIELD = love.timer.getTime() + + local success, msg = coroutine.resume(G.SCORING_COROUTINE) + if not success then + error(msg) + end + end + end +end + + + +TIME_BETWEEN_SCORING_FRAMES = 0.03 -- 30 fps during scoring +-- we dont want overhead from updates making scoring much slower +-- originally 10 fps, I think 30 fps is a good way to balance it while making it look smooth, too +--wrap everything in calculating contexts so we can do more things with it +Talisman.calculating_joker = false +Talisman.calculating_score = false +Talisman.calculating_card = false +Talisman.dollar_update = false +local ccj = Card.calculate_joker +function Card:calculate_joker(context) + --scoring coroutine + G.CURRENT_SCORING_CARD = self + G.CARD_CALC_COUNTS = G.CARD_CALC_COUNTS or {} + if G.CARD_CALC_COUNTS[self] then + G.CARD_CALC_COUNTS[self][1] = G.CARD_CALC_COUNTS[self][1] + 1 + else + G.CARD_CALC_COUNTS[self] = {1, 1} end + if G.LAST_SCORING_YIELD and ((love.timer.getTime() - G.LAST_SCORING_YIELD) > TIME_BETWEEN_SCORING_FRAMES) and coroutine.running() then + coroutine.yield() + end + Talisman.calculating_joker = true + local ret = ccj(self, context) - TIME_BETWEEN_SCORING_FRAMES = 0.03 -- 30 fps during scoring - -- we dont want overhead from updates making scoring much slower - -- originally 10 fps, I think 30 fps is a good way to balance it while making it look smooth, too - --wrap everything in calculating contexts so we can do more things with it + if ret and type(ret) == "table" and ret.repetitions then + G.CARD_CALC_COUNTS[ret.card] = G.CARD_CALC_COUNTS[ret.card] or {1,1} + G.CARD_CALC_COUNTS[ret.card][2] = G.CARD_CALC_COUNTS[ret.card][2] + ret.repetitions + end Talisman.calculating_joker = false + return ret +end +local cuc = Card.use_consumable +function Card:use_consumable(x,y) + Talisman.calculating_score = true + local ret = cuc(self, x,y) Talisman.calculating_score = false - Talisman.calculating_card = false - Talisman.dollar_update = false - local ccj = Card.calculate_joker - function Card:calculate_joker(context) - --scoring coroutine - G.CURRENT_SCORING_CARD = self - G.CARD_CALC_COUNTS = G.CARD_CALC_COUNTS or {} - if G.CARD_CALC_COUNTS[self] then - G.CARD_CALC_COUNTS[self][1] = G.CARD_CALC_COUNTS[self][1] + 1 - else - G.CARD_CALC_COUNTS[self] = {1, 1} - end - - - if G.LAST_SCORING_YIELD and ((love.timer.getTime() - G.LAST_SCORING_YIELD) > TIME_BETWEEN_SCORING_FRAMES) and coroutine.running() then - coroutine.yield() - end - Talisman.calculating_joker = true - local ret, trig = ccj(self, context) - - if ret and type(ret) == "table" and ret.repetitions then - if not ret.card then - G.CARD_CALC_COUNTS.other = G.CARD_CALC_COUNTS.other or {1,1} - G.CARD_CALC_COUNTS.other[2] = G.CARD_CALC_COUNTS.other[2] + ret.repetitions - else - G.CARD_CALC_COUNTS[ret.card] = G.CARD_CALC_COUNTS[ret.card] or {1,1} - G.CARD_CALC_COUNTS[ret.card][2] = G.CARD_CALC_COUNTS[ret.card][2] + ret.repetitions - end - end - Talisman.calculating_joker = false - return ret, trig - end - local cuc = Card.use_consumable - function Card:use_consumable(x,y) - Talisman.calculating_score = true - local ret = cuc(self, x,y) - Talisman.calculating_score = false - return ret - end - local gfep = G.FUNCS.evaluate_play - G.FUNCS.evaluate_play = function(e) - Talisman.calculating_score = true - local ret = gfep(e) - Talisman.calculating_score = false - return ret - end + return ret +end +local gfep = G.FUNCS.evaluate_play +G.FUNCS.evaluate_play = function(e) + Talisman.calculating_score = true + local ret = gfep(e) + Talisman.calculating_score = false + return ret end --[[local ec = eval_card function eval_card() @@ -4202,7 +4328,7 @@ local edo = ease_dollars function ease_dollars(mod, instant) if Talisman.config_file.disable_anims then--and (Talisman.calculating_joker or Talisman.calculating_score or Talisman.calculating_card) then mod = mod or 0 - if to_big(mod) < to_big(0) then inc_career_stat('c_dollars_earned', mod) end + if mod < 0 then inc_career_stat('c_dollars_earned', mod) end G.GAME.dollars = G.GAME.dollars + mod Talisman.dollar_update = true else return edo(mod, instant) end @@ -4217,13 +4343,11 @@ function safe_str_unpack(str) if success then return result else - print("[Talisman] Error unpacking string: " .. result) - print(tostring(str)) + print("Error unpacking string: " .. result) return nil end else - print("[Talisman] Error loading string: " .. err) - print(tostring(str)) + print("Error loading string: " .. err) return nil end end @@ -4252,207 +4376,6 @@ function G.FUNCS.evaluate_round() end end -local g_start_run = Game.start_run -function Game:start_run(args) - local ret = g_start_run(self, args) - self.GAME.round_resets.ante_disp = self.GAME.round_resets.ante_disp or number_format(self.GAME.round_resets.ante) - return ret -end - --- Steamodded calculation API: add extra operations -if SMODS and SMODS.calculate_individual_effect then - local smods_xchips = false - for _, v in pairs(SMODS.calculation_keys) do - if v == 'x_chips' then - smods_xchips = true - break - end - end - local scie = SMODS.calculate_individual_effect - function SMODS.calculate_individual_effect(effect, scored_card, key, amount, from_edition) - -- For some reason, some keys' animations are completely removed - -- I think this is caused by a lovely patch conflict - --if key == 'chip_mod' then key = 'chips' end - --if key == 'mult_mod' then key = 'mult' end - --if key == 'Xmult_mod' then key = 'x_mult' end - local ret = scie(effect, scored_card, key, amount, from_edition) - if ret then - return ret - end - if not smods_xchips and (key == 'x_chips' or key == 'xchips' or key == 'Xchip_mod') and amount ~= 1 then - if effect.card then juice_card(effect.card) end - hand_chips = mod_chips(hand_chips * amount) - update_hand_text({delay = 0}, {chips = hand_chips, mult = mult}) - if not effect.remove_default_message then - if from_edition then - card_eval_status_text(scored_card, 'jokers', nil, percent, nil, {message = "X"..amount, colour = G.C.EDITION, edition = true}) - elseif key ~= 'Xchip_mod' then - if effect.xchip_message then - card_eval_status_text(scored_card or effect.card or effect.focus, 'extra', nil, percent, nil, effect.xchip_message) - else - card_eval_status_text(scored_card or effect.card or effect.focus, 'x_chips', amount, percent) - end - end - end - return true - end - - if (key == 'e_chips' or key == 'echips' or key == 'Echip_mod') and amount ~= 1 then - if effect.card then juice_card(effect.card) end - hand_chips = mod_chips(hand_chips ^ amount) - update_hand_text({delay = 0}, {chips = hand_chips, mult = mult}) - if not effect.remove_default_message then - if from_edition then - card_eval_status_text(scored_card, 'jokers', nil, percent, nil, {message = "^"..amount, colour = G.C.EDITION, edition = true}) - elseif key ~= 'Echip_mod' then - if effect.echip_message then - card_eval_status_text(scored_card or effect.card or effect.focus, 'extra', nil, percent, nil, effect.echip_message) - else - card_eval_status_text(scored_card or effect.card or effect.focus, 'e_chips', amount, percent) - end - end - end - return true - end - - if (key == 'ee_chips' or key == 'eechips' or key == 'EEchip_mod') and amount ~= 1 then - if effect.card then juice_card(effect.card) end - hand_chips = mod_chips(hand_chips:arrow(2, amount)) - update_hand_text({delay = 0}, {chips = hand_chips, mult = mult}) - if not effect.remove_default_message then - if from_edition then - card_eval_status_text(scored_card, 'jokers', nil, percent, nil, {message = "^^"..amount, colour = G.C.EDITION, edition = true}) - elseif key ~= 'EEchip_mod' then - if effect.eechip_message then - card_eval_status_text(scored_card or effect.card or effect.focus, 'extra', nil, percent, nil, effect.eechip_message) - else - card_eval_status_text(scored_card or effect.card or effect.focus, 'ee_chips', amount, percent) - end - end - end - return true - end - - if (key == 'eee_chips' or key == 'eeechips' or key == 'EEEchip_mod') and amount ~= 1 then - if effect.card then juice_card(effect.card) end - hand_chips = mod_chips(hand_chips:arrow(3, amount)) - update_hand_text({delay = 0}, {chips = hand_chips, mult = mult}) - if not effect.remove_default_message then - if from_edition then - card_eval_status_text(scored_card, 'jokers', nil, percent, nil, {message = "^^^"..amount, colour = G.C.EDITION, edition = true}) - elseif key ~= 'EEEchip_mod' then - if effect.eeechip_message then - card_eval_status_text(scored_card or effect.card or effect.focus, 'extra', nil, percent, nil, effect.eeechip_message) - else - card_eval_status_text(scored_card or effect.card or effect.focus, 'eee_chips', amount, percent) - end - end - end - return true - end - - if (key == 'hyper_chips' or key == 'hyperchips' or key == 'hyperchip_mod') and type(amount) == 'table' then - if effect.card then juice_card(effect.card) end - hand_chips = mod_chips(hand_chips:arrow(amount[1], amount[2])) - update_hand_text({delay = 0}, {chips = hand_chips, mult = mult}) - if not effect.remove_default_message then - if from_edition then - card_eval_status_text(scored_card, 'jokers', nil, percent, nil, {message = (amount[1] > 5 and ('{' .. amount[1] .. '}') or string.rep('^', amount[1])) .. amount[2], colour = G.C.EDITION, edition = true}) - elseif key ~= 'hyperchip_mod' then - if effect.hyperchip_message then - card_eval_status_text(scored_card or effect.card or effect.focus, 'extra', nil, percent, nil, effect.hyperchip_message) - else - card_eval_status_text(scored_card or effect.card or effect.focus, 'hyper_chips', amount, percent) - end - end - end - return true - end - - if (key == 'e_mult' or key == 'emult' or key == 'Emult_mod') and amount ~= 1 then - if effect.card then juice_card(effect.card) end - mult = mod_chips(mult ^ amount) - update_hand_text({delay = 0}, {chips = hand_chips, mult = mult}) - if not effect.remove_default_message then - if from_edition then - card_eval_status_text(scored_card, 'jokers', nil, percent, nil, {message = "^"..amount.." Mult", colour = G.C.EDITION, edition = true}) - elseif key ~= 'Emult_mod' then - if effect.emult_message then - card_eval_status_text(scored_card or effect.card or effect.focus, 'extra', nil, percent, nil, effect.emult_message) - else - card_eval_status_text(scored_card or effect.card or effect.focus, 'e_mult', amount, percent) - end - end - end - return true - end - - if (key == 'ee_mult' or key == 'eemult' or key == 'EEmult_mod') and amount ~= 1 then - if effect.card then juice_card(effect.card) end - mult = mod_chips(mult:arrow(2, amount)) - update_hand_text({delay = 0}, {chips = hand_chips, mult = mult}) - if not effect.remove_default_message then - if from_edition then - card_eval_status_text(scored_card, 'jokers', nil, percent, nil, {message = "^^"..amount.." Mult", colour = G.C.EDITION, edition = true}) - elseif key ~= 'EEmult_mod' then - if effect.eemult_message then - card_eval_status_text(scored_card or effect.card or effect.focus, 'extra', nil, percent, nil, effect.eemult_message) - else - card_eval_status_text(scored_card or effect.card or effect.focus, 'ee_mult', amount, percent) - end - end - end - return true - end - - if (key == 'eee_mult' or key == 'eeemult' or key == 'EEEmult_mod') and amount ~= 1 then - if effect.card then juice_card(effect.card) end - mult = mod_chips(mult:arrow(3, amount)) - update_hand_text({delay = 0}, {chips = hand_chips, mult = mult}) - if not effect.remove_default_message then - if from_edition then - card_eval_status_text(scored_card, 'jokers', nil, percent, nil, {message = "^^^"..amount.." Mult", colour = G.C.EDITION, edition = true}) - elseif key ~= 'EEEmult_mod' then - if effect.eeemult_message then - card_eval_status_text(scored_card or effect.card or effect.focus, 'extra', nil, percent, nil, effect.eeemult_message) - else - card_eval_status_text(scored_card or effect.card or effect.focus, 'eee_mult', amount, percent) - end - end - end - return true - end - - if (key == 'hyper_mult' or key == 'hypermult' or key == 'hypermult_mod') and type(amount) == 'table' then - if effect.card then juice_card(effect.card) end - mult = mod_chips(mult:arrow(amount[1], amount[2])) - update_hand_text({delay = 0}, {chips = hand_chips, mult = mult}) - if not effect.remove_default_message then - if from_edition then - card_eval_status_text(scored_card, 'jokers', nil, percent, nil, {message = ((amount[1] > 5 and ('{' .. amount[1] .. '}') or string.rep('^', amount[1])) .. amount[2]).." Mult", colour = G.C.EDITION, edition = true}) - elseif key ~= 'hypermult_mod' then - if effect.hypermult_message then - card_eval_status_text(scored_card or effect.card or effect.focus, 'extra', nil, percent, nil, effect.hypermult_message) - else - card_eval_status_text(scored_card or effect.card or effect.focus, 'hyper_mult', amount, percent) - end - end - end - return true - end - end - for _, v in ipairs({'e_mult', 'e_chips', 'ee_mult', 'ee_chips', 'eee_mult', 'eee_chips', 'hyper_mult', 'hyper_chips', - 'emult', 'echips', 'eemult', 'eechips', 'eeemult', 'eeechips', 'hypermult', 'hyperchips', - 'Emult_mod', 'Echip_mod', 'EEmult_mod', 'EEchip_mod', 'EEEmult_mod', 'EEEchip_mod', 'hypermult_mod', 'hyperchip_mod'}) do - table.insert(SMODS.calculation_keys, v) - end - if not smods_xchips then - for _, v in ipairs({'x_chips', 'xchips', 'Xchip_mod'}) do - table.insert(SMODS.calculation_keys, v) - end - end -end - --some debugging functions --[[local callstep=0 function printCallerInfo() @@ -4470,3 +4393,79 @@ function EventManager:add_event(x,y,z) printCallerInfo() return emae(self,x,y,z) end--]] + +require 'cartomancer.init' + +Cartomancer.path = assert( + Cartomancer.find_self('cartomancer.lua'), + "Failed to find mod folder. Make sure that `Cartomancer` folder has `cartomancer.lua` file!" +) + +Cartomancer.load_mod_file('internal/config.lua', 'internal.config') +Cartomancer.load_mod_file('internal/atlas.lua', 'internal.atlas') +Cartomancer.load_mod_file('internal/ui.lua', 'internal.ui') +Cartomancer.load_mod_file('internal/keybinds.lua', 'internal.keybinds') + +Cartomancer.load_mod_file('core/view-deck.lua', 'core.view-deck') +Cartomancer.load_mod_file('core/flames.lua', 'core.flames') +Cartomancer.load_mod_file('core/optimizations.lua', 'core.optimizations') +Cartomancer.load_mod_file('core/jokers.lua', 'core.jokers') +Cartomancer.load_mod_file('core/hand.lua', 'core.hand') + +Cartomancer.load_config() + +Cartomancer.INTERNAL_jokers_menu = false + +-- TODO dedicated keybinds file? keybinds need to load after config +Cartomancer.register_keybind { + name = 'hide_joker', + func = function (controller) + Cartomancer.hide_hovered_joker(controller) + end +} + +Cartomancer.register_keybind { + name = 'toggle_tags', + func = function (controller) + Cartomancer.SETTINGS.hide_tags = not Cartomancer.SETTINGS.hide_tags + Cartomancer.update_tags_visibility() + end +} + +Cartomancer.register_keybind { + name = 'toggle_consumables', + func = function (controller) + Cartomancer.SETTINGS.hide_consumables = not Cartomancer.SETTINGS.hide_consumables + end +} + +Cartomancer.register_keybind { + name = 'toggle_deck', + func = function (controller) + Cartomancer.SETTINGS.hide_deck = not Cartomancer.SETTINGS.hide_deck + end +} + +Cartomancer.register_keybind { + name = 'toggle_jokers', + func = function (controller) + if not (G and G.jokers) then + return + end + G.jokers.cart_hide_all = not G.jokers.cart_hide_all + + if G.jokers.cart_hide_all then + Cartomancer.hide_all_jokers() + else + Cartomancer.show_all_jokers() + end + Cartomancer.align_G_jokers() + end +} + +Cartomancer.register_keybind { + name = 'toggle_jokers_buttons', + func = function (controller) + Cartomancer.SETTINGS.jokers_controls_buttons = not Cartomancer.SETTINGS.jokers_controls_buttons + end +} diff --git a/lovely/dump/tag.lua b/lovely/dump/tag.lua index efb65d6..8b9a561 100644 --- a/lovely/dump/tag.lua +++ b/lovely/dump/tag.lua @@ -1,4 +1,4 @@ -LOVELY_INTEGRITY = '1051baf1f570241c507e107aff5fffefe3df969645f0fe53ec0856cd5ac0a760' +LOVELY_INTEGRITY = '28c37f9c0f5cf94954059dedc38a88cb0f1dbceb28b6a40c9df225d84bb10fe5' --Class Tag = Object:extend() @@ -203,6 +203,14 @@ function Tag:apply_to_run(_context) return true end if self.name == 'Orbital Tag' then + if (not self.ability.orbital_hand) or (not G.GAME.hands[self.ability.orbital_hand]) then + local _poker_hands = {} + for k, v in pairs(G.GAME.hands) do + if v.visible then _poker_hands[#_poker_hands+1] = k end + end + + self.ability.orbital_hand = pseudorandom_element(_poker_hands, pseudoseed('orbital')) + end update_hand_text({sound = 'button', volume = 0.7, pitch = 0.8, delay = 0.3}, { handname= self.ability.orbital_hand, chips = G.GAME.hands[self.ability.orbital_hand].chips, @@ -723,7 +731,7 @@ function Tag:generate_UI(_size) return tag_sprite_tab, tag_sprite end -function Tag:get_uibox_table(tag_sprite, vars_only) +function Tag:get_uibox_table(tag_sprite) tag_sprite = tag_sprite or self.tag_sprite local name_to_check, loc_vars = self.name, {} if name_to_check == 'Uncommon Tag' then @@ -742,7 +750,6 @@ function Tag:get_uibox_table(tag_sprite, vars_only) } elseif name_to_check == "cry-Cat Tag" then loc_vars = {self.ability.level or 1} end - if vars_only then return loc_vars end tag_sprite.ability_UIBox_table = generate_card_ui(G.P_TAGS[self.key], nil, loc_vars, (self.hide_ability) and 'Undiscovered' or 'Tag', nil, (self.hide_ability), nil, nil, self) return tag_sprite end diff --git a/smods-main/.gitattributes b/smods-main/.gitattributes deleted file mode 100644 index 94f480d..0000000 --- a/smods-main/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* text=auto eol=lf \ No newline at end of file diff --git a/smods-main/.github/.keep b/smods-main/.github/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/smods-main/.github/workflows/version-bumper.yml b/smods-main/.github/workflows/version-bumper.yml deleted file mode 100644 index ae8baeb..0000000 --- a/smods-main/.github/workflows/version-bumper.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: Version Bumper and Tagger - -on: push - -jobs: - check-version-change: - if: github.repository_owner == 'Steamopollys' - runs-on: ubuntu-latest - outputs: - version_changed: ${{ steps.detect-version-change.outputs.version_changed }} - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 2 # Fetch the current and previous commit for comparison - - - name: Detect version change - id: detect-version-change - run: | - echo ::set-output name=version_changed::$(git diff HEAD^ HEAD -- manifest.json | grep -q '"version_number":' && echo "true" || echo "false") - - bump-and-tag-version: - needs: check-version-change - if: needs.check-version-change.outputs.version_changed == 'true' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # Necessary for tagging to include all history - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.9' - - - name: Bump version and create tag - run: | - import json - import re - from pathlib import Path - - # Load and parse manifest.json - manifest_path = Path('manifest.json') - manifest = json.loads(manifest_path.read_text()) - version_number = manifest['version_number'] - - # Update core/core.lua - core_lua_path = Path('core/core.lua') - core_lua_content = core_lua_path.read_text() - core_lua_content = re.sub(r'MODDED_VERSION = "\d+\.\d+\.\d+-STEAMODDED"', f'MODDED_VERSION = "{version_number}-STEAMODDED"', core_lua_content) - core_lua_path.write_text(core_lua_content) - - # Output version number for later steps - print(f"::set-output name=version_number::{version_number}") - id: bump-version - shell: python - - - name: Commit and push if changed - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: "Automatically bump version to ${{ needs.bump-and-tag-version.outputs.version_number }}" - file_pattern: core/core.lua injector.ps1 - - - name: Create and push tag - if: steps.bump-version.outputs.version_number - env: - VERSION: ${{ steps.bump-version.outputs.version_number }} - run: | - git tag $VERSION - git push origin $VERSION - diff --git a/smods-main/.gitignore b/smods-main/.gitignore deleted file mode 100644 index 390eb80..0000000 --- a/smods-main/.gitignore +++ /dev/null @@ -1,199 +0,0 @@ -# Created by https://www.toptal.com/developers/gitignore/api/python -# Edit at https://www.toptal.com/developers/gitignore?templates=python - -*~ - -### Python ### -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm.fming.dev/#use-with-ide -.pdm.toml - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ - -### Python Patch ### -# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration -poetry.toml - -# ruff -.ruff_cache/ - -# LSP config files -pyrightconfig.json - -## IntelliJ -/.idea/ -/shelf/ -/workspace.xml -/httpRequests/ -/dataSources/ -/dataSources.local.xml - -# End of https://www.toptal.com/developers/gitignore/api/python - -# Mac -.DS_Store - -/injector/steamodded_injector.dist/ -/injector/steamodded_injector.exe -/steamodded_injector.build/ -/steamodded_injector.dist/ -/steamodded_injector.onefile-build/ -/steamodded_injector.exe - -*.Identifier -core/EditionAPI.lua diff --git a/smods-main/LICENSE b/smods-main/LICENSE deleted file mode 100644 index f288702..0000000 --- a/smods-main/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/smods-main/README.md b/smods-main/README.md deleted file mode 100644 index 4d2aca8..0000000 --- a/smods-main/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# Steamodded - A Balatro ModLoader - -## Introduction - -Steamodded is a mod loader and injector for the game Balatro. Much like the [LÖVE framework](https://love2d.org/wiki/Main_Page) itself, it is built using [Lua](https://www.lua.org/). It is made with modularity and extensibility in mind, providing a large selection of APIs and other features to facilitate bringing your ideas to life. - -## Installation - -### How to Install Steamodded - -Click [here](https://github.com/Steamopollys/Steamodded/wiki). - -## How to Install a Mod - -- Navigate to your Mods directory (see the installation instructions). -- Put the mod into that directory. (The mod can be a single file if there is only one file provided, or it can be a whole folder.) -- Launch the game and enjoy! - -## Features - -Documentation for this project is currently incomplete. A collection of documentation pages and guides that are currently available can be found [here](https://github.com/Steamopollys/Steamodded/wiki). - -## Contributing - -This project is open for contribution; feel free to open a pull request. If you are adding new features, providing documentation is highly appreciated. - -## License - -This project is licensed under the GNU General Public License. This ensures that the software is free to use, modify, and distribute. For more details, click [here](https://github.com/Steamopollys/Steamodded/actions?tab=GPL-3.0-1-ov-file) diff --git a/smods-main/TODO b/smods-main/TODO deleted file mode 100644 index 455b484..0000000 --- a/smods-main/TODO +++ /dev/null @@ -1,29 +0,0 @@ -# Documentation -## To do - - -- Challenge -- DeckSkin - -## In progress -- Enhancement - -## Done - -- Achievement -- Atlas -- Center (Joker, Consumable, Voucher, Back, Booster) -- Blind -- ObjectType -- UndiscoveredSprite -- Edition -- Language -- Sound -- Stake -- PokerHand -- Suit -- Rank -- Seal -- Sticker -- Rarity -- Tag diff --git a/smods-main/assets/1x/default_achievements.png b/smods-main/assets/1x/default_achievements.png deleted file mode 100644 index 112362f..0000000 Binary files a/smods-main/assets/1x/default_achievements.png and /dev/null differ diff --git a/smods-main/assets/1x/mod_tags.png b/smods-main/assets/1x/mod_tags.png deleted file mode 100644 index c236b92..0000000 Binary files a/smods-main/assets/1x/mod_tags.png and /dev/null differ diff --git a/smods-main/assets/2x/default_achievements.png b/smods-main/assets/2x/default_achievements.png deleted file mode 100644 index 5bfbaff..0000000 Binary files a/smods-main/assets/2x/default_achievements.png and /dev/null differ diff --git a/smods-main/assets/2x/mod_tags.png b/smods-main/assets/2x/mod_tags.png deleted file mode 100644 index 2ada9aa..0000000 Binary files a/smods-main/assets/2x/mod_tags.png and /dev/null differ diff --git a/smods-main/assets/sounds/xchips.ogg b/smods-main/assets/sounds/xchips.ogg deleted file mode 100644 index ae47dfa..0000000 Binary files a/smods-main/assets/sounds/xchips.ogg and /dev/null differ diff --git a/smods-main/config.lua b/smods-main/config.lua deleted file mode 100644 index 032ff99..0000000 --- a/smods-main/config.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - ["no_mod_badges"] = false, - ["graphics_mipmap_level"] = 3, - ["graphics_mipmap_level_options"] = {0, 2, 4, 8}, - ["achievements"] = 1, - ["seeded_unlocks"] = false, -} diff --git a/smods-main/icon.png b/smods-main/icon.png deleted file mode 100644 index fcddcf9..0000000 Binary files a/smods-main/icon.png and /dev/null differ diff --git a/smods-main/libs/json/init.lua b/smods-main/libs/json/init.lua deleted file mode 100644 index 28215d7..0000000 --- a/smods-main/libs/json/init.lua +++ /dev/null @@ -1 +0,0 @@ -return require((...) .. '.json') \ No newline at end of file diff --git a/smods-main/libs/json/json.lua b/smods-main/libs/json/json.lua deleted file mode 100644 index 54d4448..0000000 --- a/smods-main/libs/json/json.lua +++ /dev/null @@ -1,388 +0,0 @@ --- --- json.lua --- --- Copyright (c) 2020 rxi --- --- Permission is hereby granted, free of charge, to any person obtaining a copy of --- this software and associated documentation files (the "Software"), to deal in --- the Software without restriction, including without limitation the rights to --- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies --- of the Software, and to permit persons to whom the Software is furnished to do --- so, subject to the following conditions: --- --- The above copyright notice and this permission notice shall be included in all --- copies or substantial portions of the Software. --- --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE --- SOFTWARE. --- - -local json = { _version = "0.1.2" } - -------------------------------------------------------------------------------- --- Encode -------------------------------------------------------------------------------- - -local encode - -local escape_char_map = { - [ "\\" ] = "\\", - [ "\"" ] = "\"", - [ "\b" ] = "b", - [ "\f" ] = "f", - [ "\n" ] = "n", - [ "\r" ] = "r", - [ "\t" ] = "t", -} - -local escape_char_map_inv = { [ "/" ] = "/" } -for k, v in pairs(escape_char_map) do - escape_char_map_inv[v] = k -end - - -local function escape_char(c) - return "\\" .. (escape_char_map[c] or string.format("u%04x", c:byte())) -end - - -local function encode_nil(val) - return "null" -end - - -local function encode_table(val, stack) - local res = {} - stack = stack or {} - - -- Circular reference? - if stack[val] then error("circular reference") end - - stack[val] = true - - if rawget(val, 1) ~= nil or next(val) == nil then - -- Treat as array -- check keys are valid and it is not sparse - local n = 0 - for k in pairs(val) do - if type(k) ~= "number" then - error("invalid table: mixed or invalid key types") - end - n = n + 1 - end - if n ~= #val then - error("invalid table: sparse array") - end - -- Encode - for i, v in ipairs(val) do - table.insert(res, encode(v, stack)) - end - stack[val] = nil - return "[" .. table.concat(res, ",") .. "]" - - else - -- Treat as an object - for k, v in pairs(val) do - if type(k) ~= "string" then - error("invalid table: mixed or invalid key types") - end - table.insert(res, encode(k, stack) .. ":" .. encode(v, stack)) - end - stack[val] = nil - return "{" .. table.concat(res, ",") .. "}" - end -end - - -local function encode_string(val) - return '"' .. val:gsub('[%z\1-\31\\"]', escape_char) .. '"' -end - - -local function encode_number(val) - -- Check for NaN, -inf and inf - if val ~= val or val <= -math.huge or val >= math.huge then - error("unexpected number value '" .. tostring(val) .. "'") - end - return string.format("%.14g", val) -end - - -local type_func_map = { - [ "nil" ] = encode_nil, - [ "table" ] = encode_table, - [ "string" ] = encode_string, - [ "number" ] = encode_number, - [ "boolean" ] = tostring, -} - - -encode = function(val, stack) - local t = type(val) - local f = type_func_map[t] - if f then - return f(val, stack) - end - error("unexpected type '" .. t .. "'") -end - - -function json.encode(val) - return ( encode(val) ) -end - - -------------------------------------------------------------------------------- --- Decode -------------------------------------------------------------------------------- - -local parse - -local function create_set(...) - local res = {} - for i = 1, select("#", ...) do - res[ select(i, ...) ] = true - end - return res -end - -local space_chars = create_set(" ", "\t", "\r", "\n") -local delim_chars = create_set(" ", "\t", "\r", "\n", "]", "}", ",") -local escape_chars = create_set("\\", "/", '"', "b", "f", "n", "r", "t", "u") -local literals = create_set("true", "false", "null") - -local literal_map = { - [ "true" ] = true, - [ "false" ] = false, - [ "null" ] = nil, -} - - -local function next_char(str, idx, set, negate) - for i = idx, #str do - if set[str:sub(i, i)] ~= negate then - return i - end - end - return #str + 1 -end - - -local function decode_error(str, idx, msg) - local line_count = 1 - local col_count = 1 - for i = 1, idx - 1 do - col_count = col_count + 1 - if str:sub(i, i) == "\n" then - line_count = line_count + 1 - col_count = 1 - end - end - error( string.format("%s at line %d col %d", msg, line_count, col_count) ) -end - - -local function codepoint_to_utf8(n) - -- http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=iws-appendixa - local f = math.floor - if n <= 0x7f then - return string.char(n) - elseif n <= 0x7ff then - return string.char(f(n / 64) + 192, n % 64 + 128) - elseif n <= 0xffff then - return string.char(f(n / 4096) + 224, f(n % 4096 / 64) + 128, n % 64 + 128) - elseif n <= 0x10ffff then - return string.char(f(n / 262144) + 240, f(n % 262144 / 4096) + 128, - f(n % 4096 / 64) + 128, n % 64 + 128) - end - error( string.format("invalid unicode codepoint '%x'", n) ) -end - - -local function parse_unicode_escape(s) - local n1 = tonumber( s:sub(1, 4), 16 ) - local n2 = tonumber( s:sub(7, 10), 16 ) - -- Surrogate pair? - if n2 then - return codepoint_to_utf8((n1 - 0xd800) * 0x400 + (n2 - 0xdc00) + 0x10000) - else - return codepoint_to_utf8(n1) - end -end - - -local function parse_string(str, i) - local res = "" - local j = i + 1 - local k = j - - while j <= #str do - local x = str:byte(j) - - if x < 32 then - decode_error(str, j, "control character in string") - - elseif x == 92 then -- `\`: Escape - res = res .. str:sub(k, j - 1) - j = j + 1 - local c = str:sub(j, j) - if c == "u" then - local hex = str:match("^[dD][89aAbB]%x%x\\u%x%x%x%x", j + 1) - or str:match("^%x%x%x%x", j + 1) - or decode_error(str, j - 1, "invalid unicode escape in string") - res = res .. parse_unicode_escape(hex) - j = j + #hex - else - if not escape_chars[c] then - decode_error(str, j - 1, "invalid escape char '" .. c .. "' in string") - end - res = res .. escape_char_map_inv[c] - end - k = j + 1 - - elseif x == 34 then -- `"`: End of string - res = res .. str:sub(k, j - 1) - return res, j + 1 - end - - j = j + 1 - end - - decode_error(str, i, "expected closing quote for string") -end - - -local function parse_number(str, i) - local x = next_char(str, i, delim_chars) - local s = str:sub(i, x - 1) - local n = tonumber(s) - if not n then - decode_error(str, i, "invalid number '" .. s .. "'") - end - return n, x -end - - -local function parse_literal(str, i) - local x = next_char(str, i, delim_chars) - local word = str:sub(i, x - 1) - if not literals[word] then - decode_error(str, i, "invalid literal '" .. word .. "'") - end - return literal_map[word], x -end - - -local function parse_array(str, i) - local res = {} - local n = 1 - i = i + 1 - while 1 do - local x - i = next_char(str, i, space_chars, true) - -- Empty / end of array? - if str:sub(i, i) == "]" then - i = i + 1 - break - end - -- Read token - x, i = parse(str, i) - res[n] = x - n = n + 1 - -- Next token - i = next_char(str, i, space_chars, true) - local chr = str:sub(i, i) - i = i + 1 - if chr == "]" then break end - if chr ~= "," then decode_error(str, i, "expected ']' or ','") end - end - return res, i -end - - -local function parse_object(str, i) - local res = {} - i = i + 1 - while 1 do - local key, val - i = next_char(str, i, space_chars, true) - -- Empty / end of object? - if str:sub(i, i) == "}" then - i = i + 1 - break - end - -- Read key - if str:sub(i, i) ~= '"' then - decode_error(str, i, "expected string for key") - end - key, i = parse(str, i) - -- Read ':' delimiter - i = next_char(str, i, space_chars, true) - if str:sub(i, i) ~= ":" then - decode_error(str, i, "expected ':' after key") - end - i = next_char(str, i + 1, space_chars, true) - -- Read value - val, i = parse(str, i) - -- Set - res[key] = val - -- Next token - i = next_char(str, i, space_chars, true) - local chr = str:sub(i, i) - i = i + 1 - if chr == "}" then break end - if chr ~= "," then decode_error(str, i, "expected '}' or ','") end - end - return res, i -end - - -local char_func_map = { - [ '"' ] = parse_string, - [ "0" ] = parse_number, - [ "1" ] = parse_number, - [ "2" ] = parse_number, - [ "3" ] = parse_number, - [ "4" ] = parse_number, - [ "5" ] = parse_number, - [ "6" ] = parse_number, - [ "7" ] = parse_number, - [ "8" ] = parse_number, - [ "9" ] = parse_number, - [ "-" ] = parse_number, - [ "t" ] = parse_literal, - [ "f" ] = parse_literal, - [ "n" ] = parse_literal, - [ "[" ] = parse_array, - [ "{" ] = parse_object, -} - - -parse = function(str, idx) - local chr = str:sub(idx, idx) - local f = char_func_map[chr] - if f then - return f(str, idx) - end - decode_error(str, idx, "unexpected character '" .. chr .. "'") -end - - -function json.decode(str) - if type(str) ~= "string" then - error("expected argument of type string, got " .. type(str)) - end - local res, idx = parse(str, next_char(str, 1, space_chars, true)) - idx = next_char(str, idx, space_chars, true) - if idx <= #str then - decode_error(str, idx, "trailing garbage") - end - return res -end - - -return json \ No newline at end of file diff --git a/smods-main/libs/nativefs/LICENSE b/smods-main/libs/nativefs/LICENSE deleted file mode 100644 index 828056f..0000000 --- a/smods-main/libs/nativefs/LICENSE +++ /dev/null @@ -1,7 +0,0 @@ -Copyright 2020 megagrump@pm.me - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/smods-main/libs/nativefs/README.md b/smods-main/libs/nativefs/README.md deleted file mode 100644 index 07e594b..0000000 --- a/smods-main/libs/nativefs/README.md +++ /dev/null @@ -1,94 +0,0 @@ -# This is a Thunderstore package mirror of EngineerSmith's `nativefs` repository with an added lovely patch. - -... - -This is a re-host as previously it was taken down by the original developer. Pull requests for fixes are welcome! - -# Native filesystem for LÖVE - -nativefs replicates a subset of the [love.filesystem](https://love2d.org/wiki/love.filesystem) API, but without LÖVE's path restrictions. - -## Available functions - -### nativefs - -Links in this list point to their `love.filesystem` counterparts. All functions are designed to behave the same way as `love.filesystem`, but without the path restrictions that LÖVE imposes; i.e., they allow full access to the filesystem. - -* [nativefs.newFile](https://love2d.org/wiki/love.filesystem.newFile) -* [nativefs.newFileData](https://love2d.org/wiki/love.filesystem.newFileData) -* [nativefs.mount](https://love2d.org/wiki/love.filesystem.mount) -* [nativefs.unmount](https://love2d.org/wiki/love.filesystem.unmount) -* [nativefs.read](https://love2d.org/wiki/love.filesystem.read) -* [nativefs.write](https://love2d.org/wiki/love.filesystem.write) -* [nativefs.append](https://love2d.org/wiki/love.filesystem.append) -* [nativefs.lines](https://love2d.org/wiki/love.filesystem.lines) -* [nativefs.load](https://love2d.org/wiki/love.filesystem.load) -* [nativefs.getWorkingDirectory](https://love2d.org/wiki/love.filesystem.getWorkingDirectory) -* [nativefs.getDirectoryItems](https://love2d.org/wiki/love.filesystem.getDirectoryItems) -* [nativefs.getInfo](https://love2d.org/wiki/love.filesystem.getInfo) -* [nativefs.createDirectory](https://love2d.org/wiki/love.filesystem.createDirectory) -* [nativefs.remove](https://love2d.org/wiki/love.filesystem.remove) -* nativefs.getDirectoryItemsInfo -* nativefs.getDriveList -* nativefs.setWorkingDirectory - -#### Additional `nativefs` functions - -Functions that are not available in `love.filesystem`: - -* `nativefs.getDirectoryItemsInfo(path)` -Returns a list of items in a directory that contains not only the names, but also the information returned by `getInfo` for each item. The return value is a list of files and directories, in which each entry is a table as returned by [getInfo](https://love2d.org/wiki/love.filesystem.getInfo), with an additional `name` field for each entry. Using this function is faster than calling `getInfo` separately for each item. - -* `nativefs.getDriveList()` -Returns a table with all populated drive letters on Windows (`{ 'C:/', 'D:/', ...}`). On systems that don't use drive letters, a table with the single entry `/` is returned. - -* `nativefs.setWorkingDirectory(directory)` -Changes the working directory. - -### File - -`nativefs.newFile` returns a `File` object that provides these functions: - -* [File:open](https://love2d.org/wiki/\(File\):open) -* [File:close](https://love2d.org/wiki/\(File\):close) -* [File:read](https://love2d.org/wiki/\(File\):read) -* [File:write](https://love2d.org/wiki/\(File\):write) -* [File:lines](https://love2d.org/wiki/\(File\):lines) -* [File:isOpen](https://love2d.org/wiki/\(File\):isOpen) -* [File:isEOF](https://love2d.org/wiki/\(File\):isEOF) -* [File:getFilename](https://love2d.org/wiki/\(File\):getFilename) -* [File:getMode](https://love2d.org/wiki/\(File\):getMode) -* [File:getBuffer](https://love2d.org/wiki/\(File\):getBuffer) -* [File:setBuffer](https://love2d.org/wiki/\(File\):setBuffer) -* [File:getSize](https://love2d.org/wiki/\(File\):getSize) -* [File:seek](https://love2d.org/wiki/\(File\):seek) -* [File:tell](https://love2d.org/wiki/\(File\):tell) -* [File:flush](https://love2d.org/wiki/\(File\):flush) -* [File:type](https://love2d.org/wiki/Object:type) -* [File:typeOf](https://love2d.org/wiki/Object:typeOf) -* [File:release](https://love2d.org/wiki/Object:release) - -Function names in this list are links to their LÖVE `File` counterparts. `File` is designed to work the same way as LÖVE's `File` objects. - -## Example - -```lua -local nativefs = require("nativefs") - --- Prints all information on files in C:\Windows -local files = nativefs.getDirectoryItemsInfo("C:/Windows") -for i = 1, #files do - if files[i].type == "file" then - local info = nativefs.getInfo("C:/Windows/" .. files[i].name) - print(i .. ": " .. files[i] .. " : Type:" .. info.type .. ", Size:" .. tostring(info.size) .. ", last modified:" .. tostring(info.modtime)) - end -end -``` -## License -Copyright 2020 megagrump@pm.me - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/smods-main/libs/nativefs/icon.png b/smods-main/libs/nativefs/icon.png deleted file mode 100644 index 20ae917..0000000 Binary files a/smods-main/libs/nativefs/icon.png and /dev/null differ diff --git a/smods-main/libs/nativefs/init.lua b/smods-main/libs/nativefs/init.lua deleted file mode 100644 index 46d2786..0000000 --- a/smods-main/libs/nativefs/init.lua +++ /dev/null @@ -1 +0,0 @@ -return require((...) .. '.nativefs') diff --git a/smods-main/libs/nativefs/manifest.json b/smods-main/libs/nativefs/manifest.json deleted file mode 100644 index 2908a51..0000000 --- a/smods-main/libs/nativefs/manifest.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "nativefs", - "version_number": "1.0.0", - "website_url": "https://github.com/EngineerSmith/nativefs", - "description": "nativefs replicates a subset of the love.filesystem API, but without LÖVE's path restrictions.", - "dependencies": ["Thunderstore-lovely-0.3.0"] -} diff --git a/smods-main/libs/nativefs/nativefs.lua b/smods-main/libs/nativefs/nativefs.lua deleted file mode 100644 index c6f36e0..0000000 --- a/smods-main/libs/nativefs/nativefs.lua +++ /dev/null @@ -1,495 +0,0 @@ ---[[ -Copyright 2020 megagrump@pm.me - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -]]-- - --- module("nativefs", package.seeall) - -local ffi, bit = require('ffi'), require('bit') -local C = ffi.C - -local fopen, getcwd, chdir, unlink, mkdir, rmdir -local BUFFERMODE, MODEMAP -local ByteArray = ffi.typeof('unsigned char[?]') -local function _ptr(p) return p ~= nil and p or nil end -- NULL pointer to nil - -local File = { - getBuffer = function(self) return self._bufferMode, self._bufferSize end, - getFilename = function(self) return self._name end, - getMode = function(self) return self._mode end, - isOpen = function(self) return self._mode ~= 'c' and self._handle ~= nil end, -} - -function File:open(mode) - if self._mode ~= 'c' then return false, "File " .. self._name .. " is already open" end - if not MODEMAP[mode] then return false, "Invalid open mode for " .. self._name .. ": " .. mode end - - local handle = _ptr(fopen(self._name, MODEMAP[mode])) - if not handle then return false, "Could not open " .. self._name .. " in mode " .. mode end - - self._handle, self._mode = ffi.gc(handle, C.fclose), mode - self:setBuffer(self._bufferMode, self._bufferSize) - - return true -end - -function File:close() - if self._mode == 'c' then return false, "File is not open" end - C.fclose(ffi.gc(self._handle, nil)) - self._handle, self._mode = nil, 'c' - return true -end - -function File:setBuffer(mode, size) - local bufferMode = BUFFERMODE[mode] - if not bufferMode then - return false, "Invalid buffer mode " .. mode .. " (expected 'none', 'full', or 'line')" - end - - if mode == 'none' then - size = math.max(0, size or 0) - else - size = math.max(2, size or 2) -- Windows requires buffer to be at least 2 bytes - end - - local success = self._mode == 'c' or C.setvbuf(self._handle, nil, bufferMode, size) == 0 - if not success then - self._bufferMode, self._bufferSize = 'none', 0 - return false, "Could not set buffer mode" - end - - self._bufferMode, self._bufferSize = mode, size - return true -end - -function File:getSize() - -- NOTE: The correct way to do this would be a stat() call, which requires a - -- lot more (system-specific) code. This is a shortcut that requires the file - -- to be readable. - local mustOpen = not self:isOpen() - if mustOpen and not self:open('r') then return 0 end - - local pos = mustOpen and 0 or self:tell() - C.fseek(self._handle, 0, 2) - local size = self:tell() - if mustOpen then - self:close() - else - self:seek(pos) - end - return size -end - -function File:read(containerOrBytes, bytes) - if self._mode ~= 'r' then return nil, 0 end - - local container = bytes ~= nil and containerOrBytes or 'string' - if container ~= 'string' and container ~= 'data' then - error("Invalid container type: " .. container) - end - - bytes = not bytes and containerOrBytes or 'all' - bytes = bytes == 'all' and self:getSize() - self:tell() or math.min(self:getSize() - self:tell(), bytes) - - if bytes <= 0 then - local data = container == 'string' and '' or love.data.newFileData('', self._name) - return data, 0 - end - - local data = love.data.newByteData(bytes) - local r = tonumber(C.fread(data:getFFIPointer(), 1, bytes, self._handle)) - - if container == 'data' then - -- FileData from ByteData requires LÖVE 11.4+ - local ok, fd = pcall(love.filesystem.newFileData, data, self._name) - if ok then return fd end - end - - local str = data:getString() - data:release() - data = container == 'data' and love.filesystem.newFileData(str, self._name) or str - return data, r -end - -local function lines(file, autoclose) - local BUFFERSIZE = 4096 - local buffer, bufferPos = ByteArray(BUFFERSIZE), 0 - local bytesRead = tonumber(C.fread(buffer, 1, BUFFERSIZE, file._handle)) - - local offset = file:tell() - return function() - file:seek(offset) - - local line = {} - while bytesRead > 0 do - for i = bufferPos, bytesRead - 1 do - if buffer[i] == 10 then -- end of line - bufferPos = i + 1 - return table.concat(line) - end - - if buffer[i] ~= 13 then -- ignore CR - table.insert(line, string.char(buffer[i])) - end - end - - bytesRead = tonumber(C.fread(buffer, 1, BUFFERSIZE, file._handle)) - offset, bufferPos = offset + bytesRead, 0 - end - - if not line[1] then - if autoclose then file:close() end - return nil - end - return table.concat(line) - end -end - -function File:lines() - if self._mode ~= 'r' then error("File is not opened for reading") end - return lines(self) -end - -function File:write(data, size) - if self._mode ~= 'w' and self._mode ~= 'a' then - return false, "File " .. self._name .. " not opened for writing" - end - - local toWrite, writeSize - if type(data) == 'string' then - writeSize = (size == nil or size == 'all') and #data or size - toWrite = data - else - writeSize = (size == nil or size == 'all') and data:getSize() or size - toWrite = data:getFFIPointer() - end - - if tonumber(C.fwrite(toWrite, 1, writeSize, self._handle)) ~= writeSize then - return false, "Could not write data" - end - return true -end - -function File:seek(pos) - return self._handle and C.fseek(self._handle, pos, 0) == 0 -end - -function File:tell() - if not self._handle then return nil, "Invalid position" end - return tonumber(C.ftell(self._handle)) -end - -function File:flush() - if self._mode ~= 'w' and self._mode ~= 'a' then - return nil, "File is not opened for writing" - end - return C.fflush(self._handle) == 0 -end - -function File:isEOF() - return not self:isOpen() or C.feof(self._handle) ~= 0 or self:tell() == self:getSize() -end - -function File:release() - if self._mode ~= 'c' then self:close() end - self._handle = nil -end - -function File:type() return 'File' end - -function File:typeOf(t) return t == 'File' end - -File.__index = File - ------------------------------------------------------------------------------ - -local nativefs = {} -local loveC = ffi.os == 'Windows' and ffi.load('love') or C - -function nativefs.newFile(name) - if type(name) ~= 'string' then - error("bad argument #1 to 'newFile' (string expected, got " .. type(name) .. ")") - end - return setmetatable({ - _name = name, - _mode = 'c', - _handle = nil, - _bufferSize = 0, - _bufferMode = 'none' - }, File) -end - -function nativefs.newFileData(filepath) - local f = nativefs.newFile(filepath) - local ok, err = f:open('r') - if not ok then return nil, err end - - local data, err = f:read('data', 'all') - f:close() - return data, err -end - -function nativefs.mount(archive, mountPoint, appendToPath) - return loveC.PHYSFS_mount(archive, mountPoint, appendToPath and 1 or 0) ~= 0 -end - -function nativefs.unmount(archive) - return loveC.PHYSFS_unmount(archive) ~= 0 -end - -function nativefs.read(containerOrName, nameOrSize, sizeOrNil) - local container, name, size - if sizeOrNil then - container, name, size = containerOrName, nameOrSize, sizeOrNil - elseif not nameOrSize then - container, name, size = 'string', containerOrName, 'all' - else - if type(nameOrSize) == 'number' or nameOrSize == 'all' then - container, name, size = 'string', containerOrName, nameOrSize - else - container, name, size = containerOrName, nameOrSize, 'all' - end - end - - local file = nativefs.newFile(name) - local ok, err = file:open('r') - if not ok then return nil, err end - - local data, size = file:read(container, size) - file:close() - return data, size -end - -local function writeFile(mode, name, data, size) - local file = nativefs.newFile(name) - local ok, err = file:open(mode) - if not ok then return nil, err end - - ok, err = file:write(data, size or 'all') - file:close() - return ok, err -end - -function nativefs.write(name, data, size) - return writeFile('w', name, data, size) -end - -function nativefs.append(name, data, size) - return writeFile('a', name, data, size) -end - -function nativefs.lines(name) - local f = nativefs.newFile(name) - local ok, err = f:open('r') - if not ok then return nil, err end - return lines(f, true) -end - -function nativefs.load(name) - local chunk, err = nativefs.read(name) - if not chunk then return nil, err end - return loadstring(chunk, name) -end - -function nativefs.getWorkingDirectory() - return getcwd() -end - -function nativefs.setWorkingDirectory(path) - if not chdir(path) then return false, "Could not set working directory" end - return true -end - -function nativefs.getDriveList() - if ffi.os ~= 'Windows' then return { '/' } end - local drives, bits = {}, C.GetLogicalDrives() - for i = 0, 25 do - if bit.band(bits, 2 ^ i) > 0 then - table.insert(drives, string.char(65 + i) .. ':/') - end - end - return drives -end - -function nativefs.createDirectory(path) - local current = path:sub(1, 1) == '/' and '/' or '' - for dir in path:gmatch('[^/\\]+') do - current = current .. dir .. '/' - local info = nativefs.getInfo(current, 'directory') - if not info and not mkdir(current) then return false, "Could not create directory " .. current end - end - return true -end - -function nativefs.remove(name) - local info = nativefs.getInfo(name) - if not info then return false, "Could not remove " .. name end - if info.type == 'directory' then - if not rmdir(name) then return false, "Could not remove directory " .. name end - return true - end - if not unlink(name) then return false, "Could not remove file " .. name end - return true -end - -local function withTempMount(dir, fn, ...) - local mountPoint = _ptr(loveC.PHYSFS_getMountPoint(dir)) - if mountPoint then return fn(ffi.string(mountPoint), ...) end - if not nativefs.mount(dir, '__nativefs__temp__') then return false, "Could not mount " .. dir end - local a, b = fn('__nativefs__temp__', ...) - nativefs.unmount(dir) - return a, b -end - -function nativefs.getDirectoryItems(dir) - local result, err = withTempMount(dir, love.filesystem.getDirectoryItems) - return result or {} -end - -local function getDirectoryItemsInfo(path, filtertype) - local items = {} - local files = love.filesystem.getDirectoryItems(path) - for i = 1, #files do - local filepath = string.format('%s/%s', path, files[i]) - local info = love.filesystem.getInfo(filepath, filtertype) - if info then - info.name = files[i] - table.insert(items, info) - end - end - return items -end - -function nativefs.getDirectoryItemsInfo(path, filtertype) - local result, err = withTempMount(path, getDirectoryItemsInfo, filtertype) - return result or {} -end - -local function getInfo(path, file, filtertype) - local filepath = string.format('%s/%s', path, file) - return love.filesystem.getInfo(filepath, filtertype) -end - -local function leaf(p) - p = p:gsub('\\', '/') - local last, a = p, 1 - while a do - a = p:find('/', a + 1) - if a then - last = p:sub(a + 1) - end - end - return last -end - -function nativefs.getInfo(path, filtertype) - local dir = path:match("(.*[\\/]).*$") or './' - local file = leaf(path) - local result, err = withTempMount(dir, getInfo, file, filtertype) - return result or nil -end - ------------------------------------------------------------------------------ - -MODEMAP = { r = 'rb', w = 'wb', a = 'ab' } -local MAX_PATH = 4096 - -ffi.cdef([[ - int PHYSFS_mount(const char* dir, const char* mountPoint, int appendToPath); - int PHYSFS_unmount(const char* dir); - const char* PHYSFS_getMountPoint(const char* dir); - - typedef struct FILE FILE; - - FILE* fopen(const char* path, const char* mode); - size_t fread(void* ptr, size_t size, size_t nmemb, FILE* stream); - size_t fwrite(const void* ptr, size_t size, size_t nmemb, FILE* stream); - int fclose(FILE* stream); - int fflush(FILE* stream); - size_t fseek(FILE* stream, size_t offset, int whence); - size_t ftell(FILE* stream); - int setvbuf(FILE* stream, char* buffer, int mode, size_t size); - int feof(FILE* stream); -]]) - -if ffi.os == 'Windows' then - ffi.cdef([[ - int MultiByteToWideChar(unsigned int cp, uint32_t flags, const char* mb, int cmb, const wchar_t* wc, int cwc); - int WideCharToMultiByte(unsigned int cp, uint32_t flags, const wchar_t* wc, int cwc, const char* mb, - int cmb, const char* def, int* used); - int GetLogicalDrives(void); - int CreateDirectoryW(const wchar_t* path, void*); - int _wchdir(const wchar_t* path); - wchar_t* _wgetcwd(wchar_t* buffer, int maxlen); - FILE* _wfopen(const wchar_t* path, const wchar_t* mode); - int _wunlink(const wchar_t* path); - int _wrmdir(const wchar_t* path); - ]]) - - BUFFERMODE = { full = 0, line = 64, none = 4 } - - local function towidestring(str) - local size = C.MultiByteToWideChar(65001, 0, str, #str, nil, 0) - local buf = ffi.new('wchar_t[?]', size + 1) - C.MultiByteToWideChar(65001, 0, str, #str, buf, size) - return buf - end - - local function toutf8string(wstr) - local size = C.WideCharToMultiByte(65001, 0, wstr, -1, nil, 0, nil, nil) - local buf = ffi.new('char[?]', size + 1) - C.WideCharToMultiByte(65001, 0, wstr, -1, buf, size, nil, nil) - return ffi.string(buf) - end - - local nameBuffer = ffi.new('wchar_t[?]', MAX_PATH + 1) - - fopen = function(path, mode) return C._wfopen(towidestring(path), towidestring(mode)) end - getcwd = function() return toutf8string(C._wgetcwd(nameBuffer, MAX_PATH)) end - chdir = function(path) return C._wchdir(towidestring(path)) == 0 end - unlink = function(path) return C._wunlink(towidestring(path)) == 0 end - mkdir = function(path) return C.CreateDirectoryW(towidestring(path), nil) ~= 0 end - rmdir = function(path) return C._wrmdir(towidestring(path)) == 0 end -else - BUFFERMODE = { full = 0, line = 1, none = 2 } - - ffi.cdef([[ - char* getcwd(char *buffer, int maxlen); - int chdir(const char* path); - int unlink(const char* path); - int mkdir(const char* path, int mode); - int rmdir(const char* path); - ]]) - - local nameBuffer = ByteArray(MAX_PATH) - - fopen = C.fopen - unlink = function(path) return ffi.C.unlink(path) == 0 end - chdir = function(path) return ffi.C.chdir(path) == 0 end - mkdir = function(path) return ffi.C.mkdir(path, 0x1ed) == 0 end - rmdir = function(path) return ffi.C.rmdir(path) == 0 end - - getcwd = function() - local cwd = _ptr(C.getcwd(nameBuffer, MAX_PATH)) - return cwd and ffi.string(cwd) or nil - end -end - -return nativefs diff --git a/smods-main/localization/en-us.lua b/smods-main/localization/en-us.lua deleted file mode 100644 index e4ff077..0000000 --- a/smods-main/localization/en-us.lua +++ /dev/null @@ -1,132 +0,0 @@ -return { - descriptions = { - Other = { - load_success = { - text = { - 'Mod loaded', - '{C:green}successfully!' - } - }, - load_failure_d = { - text = { - 'Missing {C:attention}dependencies!', - '#1#', - } - }, - load_failure_c = { - text = { - 'Unresolved {C:attention}conflicts!', - '#1#' - } - }, - load_failure_d_c = { - text = { - 'Missing {C:attention}dependencies!', - '#1#', - 'Unresolved {C:attention}conflicts!', - '#2#' - } - }, - load_failure_o = { - text = { - '{C:attention}Outdated!{} Steamodded', - 'versions {C:money}0.9.8{} and below', - 'are no longer supported.' - } - }, - load_failure_i = { - text = { - '{C:attention}Incompatible!{} Needs version', - '#1# of Steamodded,', - 'but #2# is installed.' - } - }, - load_failure_p = { - text = { - '{C:attention}Prefix Conflict!{}', - 'This mod\'s prefix is', - 'the same as another mod\'s.', - '({C:attention}#1#{})' - } - }, - load_failure_m = { - text = { - '{C:attention}Main File Not Found!{}', - 'This mod\'s main file', - 'could not be found.', - '({C:attention}#1#{})' - } - }, - load_disabled = { - text = { - 'This mod has been', - '{C:attention}disabled!{}' - } - } - }, - Edition = { - e_negative_playing_card = { - name = "Negative", - text = { - "{C:dark_edition}+#1#{} hand size" - }, - }, - } - }, - misc = { - achievement_names = { - hidden_achievement = "???", - }, - achievement_descriptions = { - hidden_achievement = "Play more to find out!", - }, - dictionary = { - b_mods = 'Mods', - b_mods_cap = 'MODS', - b_modded_version = 'Modded Version!', - b_steamodded = 'Steamodded', - b_credits = 'Credits', - b_open_mods_dir = 'Open Mods directory', - b_no_mods = 'No mods have been detected...', - b_mod_list = 'List of Activated Mods', - b_mod_loader = 'Mod Loader', - b_developed_by = 'developed by ', - b_rewrite_by = 'Rewrite by ', - b_github_project = 'Github Project', - b_github_bugs_1 = 'You can report bugs and', - b_github_bugs_2 = 'submit contributions there.', - b_disable_mod_badges = 'Disable Mod Badges', - b_author = 'Author', - b_authors = 'Authors', - b_unknown = 'Unknown', - b_lovely_mod = '(Lovely Mod) ', - b_by = ' By: ', - b_config = "Config", - b_additions = 'Additions', - b_stickers = 'Stickers', - b_achievements = "Achievements", - b_applies_stakes_1 = 'Applies ', - b_applies_stakes_2 = '', - b_graphics_mipmap_level = "Mipmap level", - b_browse = 'Browse', - b_search_prompt = 'Search for mods', - b_search_button = 'Search', - b_seeded_unlocks = 'Seeded unlocks', - b_seeded_unlocks_info = 'Enable unlocks and discoveries in seeded runs', - ml_achievement_settings = { - 'Disabled', - 'Enabled', - 'Bypass Restrictions' - }, - b_deckskins_lc = 'Low Contrast Colors', - b_deckskins_hc = 'High Contrast Colors', - b_deckskins_def = 'Default Colors', - }, - v_dictionary = { - c_types = '#1# Types', - cashout_hidden = '...and #1# more', - a_xchips = "X#1# Chips", - a_xchips_minus = "-X#1# Chips", - }, - } -} diff --git a/smods-main/localization/es_419.lua b/smods-main/localization/es_419.lua deleted file mode 100644 index b016289..0000000 --- a/smods-main/localization/es_419.lua +++ /dev/null @@ -1,117 +0,0 @@ -return { - descriptions = { - Other = { - load_success = { - text = { - '¡Mod cargado', - '{C:green}con éxito{}!' - } - }, - load_failure_d = { - text = { - '¡Faltan {C:attention}dependencias{}!', - '#1#', - } - }, - load_failure_c = { - text = { - '¡Hay {C:attention}conflictos{} sin resolver!', - '#1#' - } - }, - load_failure_d_c = { - text = { - '¡Faltan {C:attention}dependencias!', - '#1#', - '¡Hay {C:attention}conflictos{} sin resolver!', - '#2#' - } - }, - load_failure_o = { - text = { - '¡Steamodded {C:attention}obsoleto{}!', - 'Las versiones por debajo de {C:money}0.9.8{}', - 'ya no tienen soporte.' - } - }, - load_failure_i = { - text = { - '{C:attention}¡Incompatible!{} Necesita la versión', - '#1# de Steamodded,', - 'pero la #2# está instalada.' - } - }, - load_failure_p = { -- To be translated - text = { - '{C:attention}Prefix Conflict!{}', - 'This mod\'s prefix is', - 'the same as another mod\'s.', - '({C:attention}#1#{})' - } - }, - load_failure_m = { -- To be translated - text = { - '{C:attention}Main File Not Found!{}', - 'This mod\'s main file', - 'could not be found.', - '({C:attention}#1#{})' - } - }, - load_disabled = { - text = { - '¡Este mod ha sido', - '{C:attention}desactivado{}!' - } - } - }, - Edition = { - e_negative_playing_card = { - name = "Negativa", - text = { - "{C:dark_edition}+#1#{} de tamaño de mano" - }, - }, - } - }, - misc = { - achievement_names = { - hidden_achievement = "???", - }, - achievement_descriptions = { - hidden_achievement = "¡Juega más para descubirlo!", - }, - dictionary = { - b_mods = 'Mods', - b_mods_cap = 'MODS', - b_modded_version = 'Modded Version!', -- To be translated - b_steamodded = 'Steamodded', - b_credits = 'Créditos', - b_open_mods_dir = 'Abrir directorio de Mods', - b_no_mods = 'No se han detectado mods...', - b_mod_list = 'Lista de Mods activos', - b_mod_loader = 'Cargador de Mods', - b_developed_by = 'desarrollado por ', - b_rewrite_by = 'Reescrito por ', - b_github_project = 'Proyecto de Github', - b_github_bugs_1 = 'Puedes reportar errores', - b_github_bugs_2 = 'y contribuir allí.', - b_disable_mod_badges = 'Desactivar insignias de mods', - b_author = 'Autor/a', - b_authors = 'Autores', - b_unknown = 'Desconocido', - b_lovely_mod = '(Lovely Mod) ', -- TODO - b_by = ' Por: ', - b_config = "Configuración", - b_additions = 'Adiciones', - b_stickers = 'Stickers', -- TODO - b_achievements = "Logros", - b_applies_stakes_1 = 'Aplica ', - b_applies_stakes_2 = '', - b_graphics_mipmap_level = "Mipmap level", -- TODO - }, - v_dictionary = { - c_types = '#1# Tipos', - cashout_hidden = '...y #1# más', - }, - } -} diff --git a/smods-main/localization/es_ES.lua b/smods-main/localization/es_ES.lua deleted file mode 100644 index dbe46bd..0000000 --- a/smods-main/localization/es_ES.lua +++ /dev/null @@ -1,117 +0,0 @@ -return { - descriptions = { - Other = { - load_success = { - text = { - '¡Mod cargado', - '{C:green}con éxito{}!' - } - }, - load_failure_d = { - text = { - '¡Faltan {C:attention}dependencias{}!', - '#1#', - } - }, - load_failure_c = { - text = { - '¡Hay {C:attention}conflictos{} sin resolver!', - '#1#' - } - }, - load_failure_d_c = { - text = { - '¡Faltan {C:attention}dependencias!', - '#1#', - '¡Hay {C:attention}conflictos{} sin resolver!', - '#2#' - } - }, - load_failure_o = { - text = { - '¡Steamodded {C:attention}obsoleto{}!', - 'Las versiones por debajo de {C:money}0.9.8{}', - 'ya no tienen soporte.' - } - }, - load_failure_i = { - text = { - '{C:attention}¡Incompatible!{} Necesita la versión', - '#1# de Steamodded,', - 'pero la #2# está instalada.' - } - }, - load_failure_p = { -- To be translated - text = { - '{C:attention}Prefix Conflict!{}', - 'This mod\'s prefix is', - 'the same as another mod\'s.', - '({C:attention}#1#{})' - } - }, - load_failure_m = { -- To be translated - text = { - '{C:attention}Main File Not Found!{}', - 'This mod\'s main file', - 'could not be found.', - '({C:attention}#1#{})' - } - }, - load_disabled = { - text = { - '¡Este mod ha sido', - '{C:attention}desactivado{}!' - } - } - }, - Edition = { - e_negative_playing_card = { - name = "Negativa", - text = { - "{C:dark_edition}+#1#{} de tamaño de mano" - }, - }, - } - }, - misc = { - achievement_names = { - hidden_achievement = "???", - }, - achievement_descriptions = { - hidden_achievement = "¡Juega más para descubirlo!", - }, - dictionary = { - b_mods = 'Mods', - b_mods_cap = 'MODS', - b_modded_version = 'Modded Version!', -- To be translated - b_steamodded = 'Steamodded', - b_credits = 'Créditos', - b_open_mods_dir = 'Abrir directorio de Mods', - b_no_mods = 'No se han detectado mods...', - b_mod_list = 'Lista de Mods activos', - b_mod_loader = 'Cargador de Mods', - b_developed_by = 'desarrollado por ', - b_rewrite_by = 'Reescrito por ', - b_github_project = 'Proyecto de Github', - b_github_bugs_1 = 'Puedes reportar errores', - b_github_bugs_2 = 'y contribuir allí.', - b_disable_mod_badges = 'Desactivar insignias de mods', - b_author = 'Autor/a', - b_authors = 'Autores', - b_unknown = 'Desconocido', - b_lovely_mod = '(Lovely Mod) ', --TODO - b_by = ' Por: ', - b_config = "Configuración", - b_additions = 'Adiciones', - b_stickers = 'Stickers', -- TODO - b_achievements = "Logros", - b_applies_stakes_1 = 'Aplica ', - b_applies_stakes_2 = '', - b_graphics_mipmap_level = "Mipmap level", -- TODO - }, - v_dictionary = { - c_types = '#1# Tipos', - cashout_hidden = '...y #1# más', - }, - } -} diff --git a/smods-main/localization/pt_BR.lua b/smods-main/localization/pt_BR.lua deleted file mode 100644 index 9c41dd0..0000000 --- a/smods-main/localization/pt_BR.lua +++ /dev/null @@ -1,127 +0,0 @@ -return { - descriptions = { - Other = { - load_success = { - text = { - 'Mod carregado', - '{C:green}com sucesso!' - } - }, - load_failure_d = { - text = { - 'Faltam {C:attention}dependências!', - '#1#', - } - }, - load_failure_c = { - text = { - '{C:attention}Conflitos{} não resolvidos!', - '#1#' - } - }, - load_failure_d_c = { - text = { - 'Faltam {C:attention}dependências!', - '#1#', - '{C:attention}Conflitos{} não resolvidos!', - '#2#' - } - }, - load_failure_o = { - text = { - '{C:attention}Desatualizado!{} As versões', - '{C:money}0.9.8{} e abaxido do Steamodded', - 'não são mais suportadas.' - } - }, - load_failure_i = { - text = { - '{C:attention}Incompatível!{} Precisa da versão', - '#1# do Steamodded,', - 'mas a #2# está instalada.' - } - }, - load_failure_p = { - text = { - '{C:attention}Conflito de Prefixo!{}', - 'O prefixo deste mod é', - 'igual ao de outro mod.', - '({C:attention}#1#{})' - } - }, - load_failure_m = { - text = { - '{C:attention}Arquivo Principal Não Encontrado!{}', - 'O arquivo principal deste mod', - 'não pôde ser encontrado.', - '({C:attention}#1#{})' - } - }, - load_disabled = { - text = { - 'Este mod foi', - '{C:attention}desabilitado!{}' - } - } - }, - Edition = { - e_negative_playing_card = { - name = "Negativo", - text = { - "{C:dark_edition}+#1#{} tamanho de mão" - }, - }, - } - }, - misc = { - achievement_names = { - hidden_achievement = "???", - }, - achievement_descriptions = { - hidden_achievement = "Jogue mais para descobrir!", - }, - dictionary = { - b_mods = 'Mods', - b_mods_cap = 'MODS', - b_modded_version = 'Versão Modificada!', - b_steamodded = 'Steamodded', - b_credits = 'Créditos', - b_open_mods_dir = 'Abrir pasta Mods', - b_no_mods = 'Nenhum mod foi detectado...', - b_mod_list = 'Lista de Mods Ativos', - b_mod_loader = 'Mod Loader', - b_developed_by = 'desenvolvido por ', - b_rewrite_by = 'Reescrito por ', - b_github_project = 'Projeto no Github', - b_github_bugs_1 = 'Você pode reportar bugs e', - b_github_bugs_2 = 'submeter contribuições por lá.', - b_disable_mod_badges = 'Desabilitar Ícones de mods', - b_author = 'Autor', - b_authors = 'Autores', - b_unknown = 'Desconhecido', - b_lovely_mod = '(Mod do Lovely) ', - b_by = ' Por: ', - b_config = "Config.", - b_additions = 'Adições', - b_stickers = 'Adesivos', - b_achievements = "Conquistas", - b_applies_stakes_1 = 'Aplica ', - b_applies_stakes_2 = '', - b_graphics_mipmap_level = "Nível de Mipmap", - b_browse = 'Navegar', - b_search_prompt = 'Procurar por mods', - b_search_button = 'Procurar', - b_seeded_unlocks = 'Desbloquear com código', - b_seeded_unlocks_info = 'Permite descobertas e desbloqueios em tentativas com código', - ml_achievement_settings = { - 'Desabilitado', - 'Habilitado', - 'Ignorar Restrições' - } - }, - v_dictionary = { - c_types = '#1# Tipos', - cashout_hidden = '...e mais #1#', - }, - } -} diff --git a/smods-main/localization/zh_CN.lua b/smods-main/localization/zh_CN.lua deleted file mode 100644 index f9e259d..0000000 --- a/smods-main/localization/zh_CN.lua +++ /dev/null @@ -1,117 +0,0 @@ -return { - descriptions = { - Other = { - load_success = { - text = { - '模组加载{C:green}成功!' - } - }, - load_failure_d = { - text = { - '{C:attention}依赖项{}缺失!', - '#1#' - } - }, - load_failure_c = { - text = { - '存在{C:attention}冲突项{}!', - '#1#' - } - }, - load_failure_d_c = { - text = { - '{C:attention}依赖项{}缺失!', - '#1#', - '存在{C:attention}冲突项{}!', - '#2#' - } - }, - load_failure_o = { - text = { - 'Steamodded版本{C:attention}过旧{}!', - '已不再支持', - '{C:money}0.9.8{}及以下版本' - } - }, - load_failure_i = { - text = { - '{C:attention}不兼容!', - '所需Steamodded版本为#1#', - '但当前为#2#' - } - }, - load_failure_p = { - text = { - '{C:attention}前缀冲突!{}', - '此模组的前缀和', - '另外一个模组相同!', - '({C:attention}#1#{})' - } - }, - load_failure_m = { -- To be translated - text = { - '{C:attention}Main File Not Found!{}', - 'This mod\'s main file', - 'could not be found.', - '({C:attention}#1#{})' - } - }, - load_disabled = { - text = { - '该模组', - '已被{C:attention}禁用{}!' - } - } - }, - Edition = { - e_negative_playing_card = { - name = "负片", - text = { - "手牌上限{C:dark_edition}+#1#" - }, - }, - } - }, - misc = { - achievement_names = { - hidden_achievement = "???", - }, - achievement_descriptions = { - hidden_achievement = "未发现", - }, - dictionary = { - b_mods = '模组', - b_mods_cap = '模组', - b_modded_version = '模组环境!', - b_steamodded = 'Steamodded', - b_credits = '鸣谢', - b_open_mods_dir = '打开模组目录', - b_no_mods = '未检测到任何模组……', - b_mod_list = '已启用模组列表', - b_mod_loader = '模组加载器', - b_developed_by = '作者:', - b_rewrite_by = '重写者:', - b_github_project = 'Github项目', - b_github_bugs_1 = '你可以在此汇报漏洞', - b_github_bugs_2 = '和提交贡献', - b_disable_mod_badges = '禁用模组横标', - b_author = '作者', - b_authors = '作者', - b_unknown = '未知', - b_lovely_mod = '(依赖Lovely加载器的补丁模组)', - b_by = ' 作者:', - b_config = "配置", - b_additions = '新增项目', - b_stickers = '贴纸', - b_achievements = "成就", - b_applies_stakes_1 = '', - b_applies_stakes_2 = '的限制也都起效', - b_graphics_mipmap_level = "多级渐远纹理层级", - }, - v_dictionary = { - c_types = '共有#1#种', - cashout_hidden = '……还有#1#', - }, - }, - -} diff --git a/smods-main/lovely/achievements.toml b/smods-main/lovely/achievements.toml deleted file mode 100644 index f9338e9..0000000 --- a/smods-main/lovely/achievements.toml +++ /dev/null @@ -1,118 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -## Achievement API - -# fetch_achievements() -[[patches]] -[patches.regex] -target = "functions/common_events.lua" -pattern = '''(?[\t ]*)if G\.F_NO_ACHIEVEMENTS then return end[\n\s]*?--\|FROM LOCAL SETTINGS FILE''' -position = 'before' -# match_indent = true -line_prepend = '$indent' -payload = ''' -G.SETTINGS.ACHIEVEMENTS_EARNED = G.SETTINGS.ACHIEVEMENTS_EARNED or {} -for k, v in pairs(G.ACHIEVEMENTS) do - if not v.key then v.key = k end - for kk, vv in pairs(G.SETTINGS.ACHIEVEMENTS_EARNED) do - if G.ACHIEVEMENTS[kk] and G.ACHIEVEMENTS[kk].mod then - G.ACHIEVEMENTS[kk].earned = true - end - end -end -''' - -# check_for_unlock -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = '''if G.GAME.challenge then return end''' -position = "after" -payload = ''' -fetch_achievements() -- Refreshes achievements -for k, v in pairs(G.ACHIEVEMENTS) do - if (not v.earned) and (v.unlock_condition and type(v.unlock_condition) == 'function') and v:unlock_condition(args) then - unlock_achievement(k) - end -end''' -match_indent = true - -# unlock_achievement() -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = '''if G.PROFILES[G.SETTINGS.profile].all_unlocked then return end''' -position = "at" -payload = '''if G.PROFILES[G.SETTINGS.profile].all_unlocked and (G.ACHIEVEMENTS and G.ACHIEVEMENTS[achievement_name] and not G.ACHIEVEMENTS[achievement_name].bypass_all_unlocked and SMODS.config.achievements < 3) or (SMODS.config.achievements < 3 and (G.GAME.seeded or G.GAME.challenge)) then return true end''' -match_indent = true - -# unlock_achievement() - fix event queue leaking -# fixed smods achievements not unlocking due to above comment's memory leak fix -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = '''local achievement_set = false -if G.F_NO_ACHIEVEMENTS then return end''' -position = "at" -payload = '''local achievement_set = false -if not G.ACHIEVEMENTS then fetch_achievements() end -G.SETTINGS.ACHIEVEMENTS_EARNED[achievement_name] = true -G:save_progress() - -if G.ACHIEVEMENTS[achievement_name] and G.ACHIEVEMENTS[achievement_name].mod then - if not G.ACHIEVEMENTS[achievement_name].earned then - --|THIS IS THE FIRST TIME THIS ACHIEVEMENT HAS BEEN EARNED - achievement_set = true - G.FILE_HANDLER.force = true - end - G.ACHIEVEMENTS[achievement_name].earned = true -end - -if achievement_set then - notify_alert(achievement_name) - return true -end -if G.F_NO_ACHIEVEMENTS and not (G.ACHIEVEMENTS[achievement_name] or {}).mod then return true end''' -match_indent = true - -# create_UIBox_notify_alert -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = '''local t_s = Sprite(0,0,1.5*(_atlas.px/_atlas.py),1.5,_atlas, _c and _c.pos or {x=3, y=0})''' -position = "before" -payload = '''if SMODS.Achievements[_achievement] then _c = SMODS.Achievements[_achievement]; _atlas = G.ASSET_ATLAS[_c.atlas] end''' -match_indent = true - -# option to allow unlocks and discoveries in seeded runs -[[patches]] -[patches.regex] -target = 'functions/common_events.lua' -pattern = 'if G\.GAME\.seeded or G\.GAME\.challenge then return end' -position = 'at' -payload = 'if not SMODS.config.seeded_unlocks and (G.GAME.seeded or G.GAME.challenge) then return end' - -[[patches]] -[patches.pattern] -target = 'functions/state_events.lua' -match_indent = true -position = 'at' -pattern = 'if not G.GAME.seeded and not G.GAME.challenge then' -payload = 'if (not G.GAME.seeded and not G.GAME.challenge) or SMODS.config.seeded_unlocks then' - -[[patches]] -[patches.regex] -target = 'functions/common_events.lua' -pattern = 'if G\.GAME\.seeded then' -position = 'at' -payload = 'if false then' - -[[patches]] -[patches.regex] -target = 'functions/common_events.lua' -pattern = 'if G\.GAME\.challenge then' -position = 'at' -payload = 'if false then' diff --git a/smods-main/lovely/atlas.toml b/smods-main/lovely/atlas.toml deleted file mode 100644 index f08094d..0000000 --- a/smods-main/lovely/atlas.toml +++ /dev/null @@ -1,105 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -### Sprite API - -# Card:set_sprites() -[[patches]] -[patches.regex] -target = 'card.lua' -pattern = 'G.ASSET_ATLAS\["centers"\]' -position = 'at' -payload = "G.ASSET_ATLAS[(G.GAME.viewed_back or G.GAME.selected_back) and ((G.GAME.viewed_back or G.GAME.selected_back)[G.SETTINGS.colourblind_option and 'hc_atlas' or 'lc_atlas'] or (G.GAME.viewed_back or G.GAME.selected_back).atlas) or 'centers']" - -[[patches]] -[patches.regex] -target = 'card.lua' -pattern = 'G.ASSET_ATLAS\[_center.atlas or _center.set\]' -position = 'at' -payload = ''' -G.ASSET_ATLAS[(_center.undiscovered and (_center.undiscovered[G.SETTINGS.colourblind_option and 'hc_atlas' or 'lc_atlas'] or _center.undiscovered.atlas)) - or (SMODS.UndiscoveredSprites[_center.set] and (SMODS.UndiscoveredSprites[_center.set][G.SETTINGS.colourblind_option and 'hc_atlas' or 'lc_atlas'] or SMODS.UndiscoveredSprites[_center.set].atlas)) - or _center.set] or G.ASSET_ATLAS["Joker"]''' - -[[patches]] -[patches.regex] -target = 'card.lua' -pattern = "G.ASSET_ATLAS\\['Joker'\\]" -position = 'at' -payload = "G.ASSET_ATLAS[_center[G.SETTINGS.colourblind_option and 'hc_atlas' or 'lc_atlas'] or _center.atlas or _center.set]" - -[[patches]] -[patches.regex] -target = 'card.lua' -pattern = 'G.ASSET_ATLAS\[_center.set\]' -position = 'at' -payload = "G.ASSET_ATLAS[_center[G.SETTINGS.colourblind_option and 'hc_atlas' or 'lc_atlas'] or _center.atlas or _center.set]" - -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = "(_center.set == 'Joker' and G.j_undiscovered.pos) or" -position = 'before' -payload = '(_center.undiscovered and _center.undiscovered.pos) or (SMODS.UndiscoveredSprites[_center.set] and SMODS.UndiscoveredSprites[_center.set].pos) or' -match_indent = true - -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = '''(_center.set == 'Booster' and G.booster_undiscovered.pos))''' -position = 'at' -payload = '''(_center.set == 'Booster' and G.booster_undiscovered.pos) or G.j_undiscovered.pos)''' -match_indent = true - -# get_front_spriteinfo() - -[[patches]] -[patches.pattern] -target = 'functions/misc_functions.lua' -pattern = 'return G.ASSET_ATLAS[_front.atlas] or G.ASSET_ATLAS["cards_"..(G.SETTINGS.colourblind_option and 2 or 1)], _front.pos' -position = 'at' -match_indent = true -payload = 'return G.ASSET_ATLAS[G.SETTINGS.colourblind_option and _front.hc_atlas or _front.lc_atlas or {}] or G.ASSET_ATLAS[_front.atlas] or G.ASSET_ATLAS["cards_"..(G.SETTINGS.colourblind_option and 2 or 1)], _front.pos' - - -# Game:set_render_settings() -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -pattern = "G:set_render_settings()" -position = 'at' -match_indent = true -payload = "SMODS.injectObjects(SMODS.Atlas)" - - -# create_UIBox_notify_alert() -[[patches]] -[patches.pattern] -target = 'functions/UI_definitions.lua' -pattern = 'G.ASSET_ATLAS["icons"]' -position = 'after' -match_indent = false -payload = ''' - local _smods_atlas = _c and ((G.SETTINGS.colourblind_option and _c.hc_atlas or _c.lc_atlas) or _c.atlas) - if _smods_atlas then - _atlas = G.ASSET_ATLAS[_smods_atlas] or _atlas - end''' - -## Hide floating ? from undiscovered types -# Card:draw() -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = '''shared_sprite:draw_shader('dissolve', nil, nil, nil, self.children.center, scale_mod, rotate_mod)''' -position = 'at' -match_indent = true -payload = ''' -if (self.config.center.undiscovered and not self.config.center.undiscovered.no_overlay) or not( SMODS.UndiscoveredSprites[self.ability.set] and SMODS.UndiscoveredSprites[self.ability.set].no_overlay) then - shared_sprite:draw_shader('dissolve', nil, nil, nil, self.children.center, scale_mod, rotate_mod) -else - if SMODS.UndiscoveredSprites[self.ability.set] and SMODS.UndiscoveredSprites[self.ability.set].overlay_sprite then - SMODS.UndiscoveredSprites[self.ability.set].overlay_sprite:draw_shader('dissolve', nil, nil, nil, self.children.center, scale_mod, rotate_mod) - end -end''' diff --git a/smods-main/lovely/back.toml b/smods-main/lovely/back.toml deleted file mode 100644 index 6c69fa6..0000000 --- a/smods-main/lovely/back.toml +++ /dev/null @@ -1,173 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -### Back API - -# Back:init() -[[patches]] -[patches.pattern] -target = 'back.lua' -pattern = "if not selected_back then selected_back = G.P_CENTERS.b_red end" -position = 'after' -match_indent = true -payload = "self.atlas = selected_back.unlocked and selected_back.atlas or nil" - -# Back:change_to() -[[patches]] -[patches.pattern] -target = 'back.lua' -pattern = "if not new_back then new_back = G.P_CENTERS.b_red end" -position = 'after' -match_indent = true -payload = "self.atlas = new_back.unlocked and new_back.atlas or nil" - -# G.FUNCS.change_viewed_back -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -pattern = "G.PROFILES[G.SETTINGS.profile].MEMORY.deck = args.to_val" -position = 'after' -match_indent = true -payload = ''' -for key, val in pairs(G.sticker_card.area.cards) do - val.children.back = false - val:set_ability(val.config.center, true) -end''' - -# Back:apply_to_run() -[[patches]] -[patches.pattern] -target = 'back.lua' -pattern = "function Back:apply_to_run()" -position = 'after' -match_indent = true -payload = ''' - local obj = self.effect.center - if obj.apply and type(obj.apply) == 'function' then - obj:apply(self) - end''' - -# Back:trigger_effect(args) -[[patches]] -[patches.pattern] -target = 'back.lua' -pattern = "if not args then return end" -position = 'after' -match_indent = true -payload = ''' - local obj = self.effect.center - if type(obj.calculate) == 'function' then - local o = {obj:calculate(self, args)} - if next(o) ~= nil then return unpack(o) end - elseif type(obj.trigger_effect) == 'function' then - -- kept for compatibility - local o = {obj:trigger_effect(args)} - if next(o) ~= nil then - sendWarnMessage(('Found `trigger_effect` function on SMODS.Back object "%s". This field is deprecated; please use `calculate` instead.'):format(obj.key), 'Back') - return unpack(o) - end - end''' - -## Back:generate_UI - -# Localization with `unlock` field in loc_txt, same as for Jokers -[[patches]] -[patches.pattern] -target = 'back.lua' -pattern = 'if not back_config.unlock_condition then' -position = 'at' -payload = ''' -local localized_by_smods -local key_override -if back_config.locked_loc_vars and type(back_config.locked_loc_vars) == 'function' then - local res = back_config:locked_loc_vars() or {} - loc_args = res.vars or {} - key_override = res.key -end -if G.localization.descriptions.Back[key_override or back_config.key].unlock_parsed then - localize{type = 'unlocks', key = key_override or back_config.key, set = 'Back', nodes = loc_nodes, vars = loc_args} - localized_by_smods = true -end -if not back_config.unlock_condition then''' -match_indent = true -[[patches]] -[patches.pattern] -target = 'back.lua' -pattern = '''localize{type = 'descriptions', key = 'demo_locked', set = "Other", nodes = loc_nodes, vars = loc_args}''' -position = 'at' -payload = ''' -if not localized_by_smods then - localize{type = 'descriptions', key = 'demo_locked', set = "Other", nodes = loc_nodes, vars = loc_args} -end''' -match_indent = true - -[[patches]] -[patches.pattern] -target = 'back.lua' -pattern = 'loc_args = {other_name}' -position = 'at' -payload = 'loc_args = loc_args or {other_name}' -match_indent = true -[[patches]] -[patches.pattern] -target = 'back.lua' -pattern = 'loc_args = {tostring(back_config.unlock_condition.amount)}' -position = 'at' -payload = 'loc_args = loc_args or {tostring(back_config.unlock_condition.amount)}' -match_indent = true -[[patches]] -[patches.pattern] -target = 'back.lua' -pattern = 'loc_args = {other_name, colours = {get_stake_col(back_config.unlock_condition.stake)}}' -position = 'at' -payload = 'loc_args = loc_args or {other_name, colours = {get_stake_col(back_config.unlock_condition.stake)}}' -match_indent = true - -[[patches]] -[patches.pattern] -target = 'back.lua' -pattern = "if name_to_check == 'Blue Deck'*" -position = 'at' -match_indent = true -payload = ''' -local key_override -if back_config.loc_vars and type(back_config.loc_vars) == 'function' then - local res = back_config:loc_vars() or {} - loc_args = res.vars or {} - key_override = res.key -elseif name_to_check == 'Blue Deck' then loc_args = {effect_config.hands}''' - -[[patches]] -[patches.regex] -target = 'back.lua' -pattern = "key = back_config\\.key" -position = 'at' -payload = "key = key_override or back_config.key" - -# Back:apply_to_run() - add jokers support to config -[[patches]] -[patches.pattern] -target = 'back.lua' -match_indent = true -position = 'before' -pattern = ''' -if self.effect.config.voucher then -''' -payload = ''' -if self.effect.config.jokers then - delay(0.4) - G.E_MANAGER:add_event(Event({ - func = function() - for k, v in ipairs(self.effect.config.jokers) do - local card = create_card('Joker', G.jokers, nil, nil, nil, nil, v, 'deck') - card:add_to_deck() - G.jokers:emplace(card) - card:start_materialize() - end - return true - end - })) - end -''' diff --git a/smods-main/lovely/better_calc.toml b/smods-main/lovely/better_calc.toml deleted file mode 100644 index 020a233..0000000 --- a/smods-main/lovely/better_calc.toml +++ /dev/null @@ -1,1322 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 -# temp solution, nothing matches if -10 - -## G.FUNCS.evaluate_play() -# evaluate main scoring - -[[patches]] -[patches.regex] -target = 'functions/state_events.lua' -pattern = '''(?[\t ]*)(?if modded then update_hand_text\(\{sound = 'chips2', modded = modded\}, \{chips = hand_chips, mult = mult\}\) end)(.*\n)*?\s+(?--\++--)''' -position = 'at' -line_prepend = '$indent' -payload = '''$handtext -delay(0.3) -for _, v in ipairs(SMODS.get_card_areas('playing_cards')) do - SMODS.calculate_main_scoring({cardarea = v, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands}, v == G.play and scoring_hand or nil) - delay(0.3) -end -$delimiter''' -## eval_card() -# handle debuffed playing cards -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = ''' -function eval_card(card, context) - context = context or {} - local ret = {} -''' -position = 'at' -match_indent = true -payload = ''' -function eval_card(card, context) - if card.ability.set ~= 'Joker' and card.debuff then return {}, {} end - context = context or {} - local ret = {} -''' - -# built in config values -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = ''' -if context.cardarea == G.play then - local chips = card:get_chip_bonus() - if chips > 0 then - ret.chips = chips - end - - local mult = card:get_chip_mult() - if mult > 0 then - ret.mult = mult - end - - local x_mult = card:get_chip_x_mult(context) - if x_mult > 0 then - ret.x_mult = x_mult - end - - local p_dollars = card:get_p_dollars() - if p_dollars > 0 then - ret.p_dollars = p_dollars - end - - local jokers = card:calculate_joker(context) - if jokers then - ret.jokers = jokers - end - - local edition = card:get_edition(context) - if edition then - ret.edition = edition - end -end -''' -match_indent = true -position = "at" -payload = """ -if context.cardarea == G.play and context.main_scoring then - ret.playing_card = {} - local chips = card:get_chip_bonus() - if chips ~= 0 then - ret.playing_card.chips = chips - end - - local mult = card:get_chip_mult() - if mult ~= 0 then - ret.playing_card.mult = mult - end - - local x_mult = card:get_chip_x_mult(context) - if x_mult > 0 then - ret.playing_card.x_mult = x_mult - end - - local p_dollars = card:get_p_dollars() - if p_dollars > 0 then - ret.playing_card.p_dollars = p_dollars - end - - -- TARGET: main scoring on played cards - - local jokers = card:calculate_joker(context) - if jokers then - ret.jokers = jokers - end - - local edition = card:calculate_edition(context) - if edition then - ret.edition = edition - end -end -if context.end_of_round and context.cardarea == G.hand and context.playing_card_end_of_round then - local end_of_round = card:get_end_of_round_effect(context) - if end_of_round then - ret.end_of_round = end_of_round - end -end -""" -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = ''' -if context.cardarea == G.hand then - local h_mult = card:get_chip_h_mult() - if h_mult > 0 then - ret.h_mult = h_mult - end - - local h_x_mult = card:get_chip_h_x_mult() - if h_x_mult > 0 then - ret.x_mult = h_x_mult - end -''' -match_indent = true -position = "at" -payload = """ -if context.cardarea == G.hand and context.main_scoring then - ret.playing_card = {} - local h_mult = card:get_chip_h_mult() - if h_mult ~= 0 then - ret.playing_card.h_mult = h_mult - end - - local h_x_mult = card:get_chip_h_x_mult() - if h_x_mult > 0 then - ret.playing_card.x_mult = h_x_mult - end - - -- TARGET: main scoring on held cards -""" - -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = ''' -local seals = card:calculate_seal(context) -if seals then - ret.seals = seals -end -''' -match_indent = true -position = "at" -payload = """ -if card.ability.set == 'Enhanced' then - local enhancement = card:calculate_enhancement(context) - if enhancement then - ret.enhancement = enhancement - end -end -if card.edition then - local edition = card:calculate_edition(context) - if edition then - ret.edition = edition - end -end -if card.seal then - local seals = card:calculate_seal(context) - if seals then - ret.seals = seals - end -end -for k,v in pairs(SMODS.Stickers) do - local sticker = card:calculate_sticker(context, k) - if sticker then - ret[v] = sticker - end -end - --- TARGET: evaluate your own repetition effects -""" -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = "if context.cardarea == G.jokers or context.card == G.consumeables then" -match_indent = true -position = "before" -payload = """ -if card.ability.set == 'Enhanced' then - local enhancement = card:calculate_enhancement(context) - if enhancement then - ret.enhancement = enhancement - end -end -if card.edition then - local edition = card:calculate_edition(context) - if edition then - ret.edition = edition - end -end -if card.seal and not card.ability.extra_enhancement then - local seals = card:calculate_seal(context) - if seals then - ret.seals = seals - end -end -for k,v in pairs(SMODS.Stickers) do - local sticker = card:calculate_sticker(context, k) - if sticker then - ret[v] = sticker - end -end - --- TARGET: evaluate your own general effects -""" -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = ''' -if context.cardarea == G.jokers or context.card == G.consumeables then - local jokers = nil - if context.edition then - jokers = card:get_edition(context) - elseif context.other_joker then - jokers = context.other_joker:calculate_joker(context) - else - jokers = card:calculate_joker(context) - end - if jokers then - ret.jokers = jokers - end -end - -return ret''' -match_indent = true -position = "at" -payload = """ -local post_trig = {} -local areas = SMODS.get_card_areas('jokers') -local area_set = {} -for _,v in ipairs(areas) do area_set[v] = true end -if card.area and area_set[card.area] then - local jokers, triggered = card:calculate_joker(context) - if jokers or triggered then - ret.jokers = jokers - if not (context.retrigger_joker_check or context.retrigger_joker) then - local retriggers = SMODS.calculate_retriggers(card, context, ret) - if next(retriggers) then - ret.retriggers = retriggers - end - end - if not context.post_trigger and not context.retrigger_joker_check and SMODS.optional_features.post_trigger then - SMODS.calculate_context({blueprint_card = context.blueprint_card, post_trigger = true, other_card = card, other_context = context, other_ret = ret}, post_trig) - end - end -end - -return ret, post_trig -""" -# patch card_eval_status_text to allow G.deck usage -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = ''' -elseif card.area == G.hand then''' -match_indent = true -position = "at" -payload = """ -elseif card.area == G.hand or card.area == G.deck then -""" - -# card_eval_status_text alignment patches -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -match_indent = true -position = 'before' -pattern = '''elseif card.area == G.hand or card.area == G.deck then''' -payload = '''elseif card == G.deck then - y_off = -0.05*G.CARD_H - card_aligned = 'tm' -elseif card.area == G.discard or card.area == G.vouchers then - y_off = card.area == G.discard and -0.35*G.CARD_H or -0.65*G.CARD_H - card = G.deck.cards[1] or G.deck - card_aligned = 'tm' -''' - -# G.FUNCS.evaluate_play() - - -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = ''' ---calculate the card edition effects -if effects[ii].edition then - hand_chips = mod_chips(hand_chips + (effects[ii].edition.chip_mod or 0)) - mult = mult + (effects[ii].edition.mult_mod or 0) - mult = mod_mult(mult*(effects[ii].edition.x_mult_mod or 1)) - update_hand_text({delay = 0}, { - chips = effects[ii].edition.chip_mod and hand_chips or nil, - mult = (effects[ii].edition.mult_mod or effects[ii].edition.x_mult_mod) and mult or nil, - }) - card_eval_status_text(scoring_hand[i], 'extra', nil, percent, nil, { - message = (effects[ii].edition.chip_mod and localize{type='variable',key='a_chips',vars={effects[ii].edition.chip_mod}}) or - (effects[ii].edition.mult_mod and localize{type='variable',key='a_mult',vars={effects[ii].edition.mult_mod}}) or - (effects[ii].edition.x_mult_mod and localize{type='variable',key='a_xmult',vars={effects[ii].edition.x_mult_mod}}), - chip_mod = effects[ii].edition.chip_mod, - mult_mod = effects[ii].edition.mult_mod, - x_mult_mod = effects[ii].edition.x_mult_mod, - colour = G.C.DARK_EDITION, - edition = true}) -end -''' -match_indent = true -position = "at" -payload = '' - -## Remove base game calculations -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = ''' - scoring_hand[i].lucky_trigger = nil - - for ii = 1, #effects do - --If chips added, do chip add event and add the chips to the total - if effects[ii].chips then - if effects[ii].card then juice_card(effects[ii].card) end - hand_chips = mod_chips(hand_chips + effects[ii].chips) - update_hand_text({delay = 0}, {chips = hand_chips}) - card_eval_status_text(scoring_hand[i], 'chips', effects[ii].chips, percent) - end - - --If mult added, do mult add event and add the mult to the total - if effects[ii].mult then - if effects[ii].card then juice_card(effects[ii].card) end - mult = mod_mult(mult + effects[ii].mult) - update_hand_text({delay = 0}, {mult = mult}) - card_eval_status_text(scoring_hand[i], 'mult', effects[ii].mult, percent) - end - - --If play dollars added, add dollars to total - if effects[ii].p_dollars then - if effects[ii].card then juice_card(effects[ii].card) end - ease_dollars(effects[ii].p_dollars) - card_eval_status_text(scoring_hand[i], 'dollars', effects[ii].p_dollars, percent) - end - - --If dollars added, add dollars to total - if effects[ii].dollars then - if effects[ii].card then juice_card(effects[ii].card) end - ease_dollars(effects[ii].dollars) - card_eval_status_text(scoring_hand[i], 'dollars', effects[ii].dollars, percent) - end - - --Any extra effects - if effects[ii].extra then - if effects[ii].card then juice_card(effects[ii].card) end - local extras = {mult = false, hand_chips = false} - if effects[ii].extra.mult_mod then mult =mod_mult( mult + effects[ii].extra.mult_mod);extras.mult = true end - if effects[ii].extra.chip_mod then hand_chips = mod_chips(hand_chips + effects[ii].extra.chip_mod);extras.hand_chips = true end - if effects[ii].extra.swap then - local old_mult = mult - mult = mod_mult(hand_chips) - hand_chips = mod_chips(old_mult) - extras.hand_chips = true; extras.mult = true - end - if effects[ii].extra.func then effects[ii].extra.func() end - update_hand_text({delay = 0}, {chips = extras.hand_chips and hand_chips, mult = extras.mult and mult}) - card_eval_status_text(scoring_hand[i], 'extra', nil, percent, nil, effects[ii].extra) - end - - --If x_mult added, do mult add event and mult the mult to the total - if effects[ii].x_mult then - if effects[ii].card then juice_card(effects[ii].card) end - mult = mod_mult(mult*effects[ii].x_mult) - update_hand_text({delay = 0}, {mult = mult}) - card_eval_status_text(scoring_hand[i], 'x_mult', effects[ii].x_mult, percent) - end - - - end - end -end -''' -match_indent = true -position = "at" -payload = ''' - -- Base game calculation removed - SMODS.trigger_effects(effects, scoring_hand[i]) - local deck_effect = G.GAME.selected_back:trigger_effect({cardarea = G.play, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, other_card = scoring_hand[i], individual = true}) - if deck_effect then SMODS.calculate_effect(deck_effect, G.deck.cards[1] or G.deck) end - scoring_hand[i].lucky_trigger = nil - end - scoring_hand[i].extra_enhancements = nil -end -''' - -# Add deck/discard individual contexts -[[patches]] -[patches.pattern] -target = 'functions/state_events.lua' -position = 'before' -match_indent = true -pattern = ''' ---+++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- ---Joker Effects ---+++++++++++++++++++++++++++++++++++++++++++++++++++++++++--''' -payload = ''' - -''' - -# Joker Effects -# Edition effects -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = ''' ---calculate the joker edition effects -local edition_effects = eval_card(_card, {cardarea = G.jokers, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, edition = true}) -if edition_effects.jokers then - edition_effects.jokers.edition = true - if edition_effects.jokers.chip_mod then - hand_chips = mod_chips(hand_chips + edition_effects.jokers.chip_mod) - update_hand_text({delay = 0}, {chips = hand_chips}) - card_eval_status_text(_card, 'jokers', nil, percent, nil, { - message = localize{type='variable',key='a_chips',vars={edition_effects.jokers.chip_mod}}, - chip_mod = edition_effects.jokers.chip_mod, - colour = G.C.EDITION, - edition = true}) - end - if edition_effects.jokers.mult_mod then - mult = mod_mult(mult + edition_effects.jokers.mult_mod) - update_hand_text({delay = 0}, {mult = mult}) - card_eval_status_text(_card, 'jokers', nil, percent, nil, { - message = localize{type='variable',key='a_mult',vars={edition_effects.jokers.mult_mod}}, - mult_mod = edition_effects.jokers.mult_mod, - colour = G.C.DARK_EDITION, - edition = true}) - end - percent = percent+percent_delta -end''' -match_indent = true -position = "at" -payload = ''' -local effects = {} --- remove base game joker edition calc -local eval = eval_card(_card, {cardarea = G.jokers, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, edition = true, pre_joker = true}) -if eval.edition then effects[#effects+1] = eval end - -''' -# Edition mult effects -## extra end to fix syntax from adding joker-like areas -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = ''' - if edition_effects.jokers then - if edition_effects.jokers.x_mult_mod then - mult = mod_mult(mult*edition_effects.jokers.x_mult_mod) - update_hand_text({delay = 0}, {mult = mult}) - card_eval_status_text(_card, 'jokers', nil, percent, nil, { - message = localize{type='variable',key='a_xmult',vars={edition_effects.jokers.x_mult_mod}}, - x_mult_mod = edition_effects.jokers.x_mult_mod, - colour = G.C.EDITION, - edition = true}) - end - percent = percent+percent_delta - end -end''' -match_indent = false -position = "at" -payload = ''' - -- calculate edition multipliers - local eval = eval_card(_card, {cardarea = G.jokers, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, edition = true, post_joker = true}) - if eval.edition then effects[#effects+1] = eval end - - SMODS.trigger_effects(effects, _card) - local deck_effect = G.GAME.selected_back:trigger_effect({full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, other_joker = _card.ability.set == 'Joker' and _card or false, other_consumeable = _card.ability.set ~= 'Joker' and _card or false}) - if deck_effect then SMODS.calculate_effect(deck_effect, G.deck.cards[1] or G.deck) end - end end -''' -# Joker effects - -# allows adding other areas (syntax is fixed further down) -[[patches]] -[patches.pattern] -target = 'functions/state_events.lua' -match_indent = true -position = 'at' -pattern = '''for i=1, #G.jokers.cards + #G.consumeables.cards do - local _card = G.jokers.cards[i] or G.consumeables.cards[i - #G.jokers.cards]''' -payload = '''for _, area in ipairs(SMODS.get_card_areas('jokers')) do for _, _card in ipairs(area.cards) do''' - -## I am NOT converting this to regex (yet) -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = ''' - --calculate the joker effects - local effects = eval_card(_card, {cardarea = G.jokers, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, joker_main = true}) - - --Any Joker effects - if effects.jokers then - local extras = {mult = false, hand_chips = false} - if effects.jokers.mult_mod then mult = mod_mult(mult + effects.jokers.mult_mod);extras.mult = true end - if effects.jokers.chip_mod then hand_chips = mod_chips(hand_chips + effects.jokers.chip_mod);extras.hand_chips = true end - if effects.jokers.Xmult_mod then mult = mod_mult(mult*effects.jokers.Xmult_mod);extras.mult = true end - update_hand_text({delay = 0}, {chips = extras.hand_chips and hand_chips, mult = extras.mult and mult}) - card_eval_status_text(_card, 'jokers', nil, percent, nil, effects.jokers) - percent = percent+percent_delta - end''' -match_indent = true -position = "at" -payload = ''' --- Calculate context.joker_main -local joker_eval, post = eval_card(_card, {cardarea = G.jokers, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, joker_main = true}) -if next(joker_eval) then - if joker_eval.edition then joker_eval.edition = {} end - table.insert(effects, joker_eval) - for _, v in ipairs(post) do effects[#effects+1] = v end - if joker_eval.retriggers then - for rt = 1, #joker_eval.retriggers do - local rt_eval, rt_post = eval_card(_card, {cardarea = G.jokers, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, joker_main = true, retrigger_joker = true}) - table.insert(effects, {joker_eval.retriggers[rt]}) - table.insert(effects, rt_eval) - for _, v in ipairs(rt_post) do effects[#effects+1] = v end - end - end -end''' -# Joker on Joker effects -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = ''' ---Joker on Joker effects -for _, v in ipairs(G.jokers.cards) do - local effect = v:calculate_joker{full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, other_joker = _card} - if effect then - local extras = {mult = false, hand_chips = false} - if effect.mult_mod then mult = mod_mult(mult + effect.mult_mod);extras.mult = true end - if effect.chip_mod then hand_chips = mod_chips(hand_chips + effect.chip_mod);extras.hand_chips = true end - if effect.Xmult_mod then mult = mod_mult(mult*effect.Xmult_mod);extras.mult = true end - if extras.mult or extras.hand_chips then update_hand_text({delay = 0}, {chips = extras.hand_chips and hand_chips, mult = extras.mult and mult}) end - if extras.mult or extras.hand_chips then card_eval_status_text(v, 'jokers', nil, percent, nil, effect) end - percent = percent+percent_delta - end -end''' -match_indent = true -position = "at" -payload = ''' --- Calculate context.other_joker effects -for _, _area in ipairs(SMODS.get_card_areas('jokers')) do - for _, _joker in ipairs(_area.cards) do - local other_key = 'other_unknown' - if _card.ability.set == 'Joker' then other_key = 'other_joker' end - if _card.ability.consumeable then other_key = 'other_consumeable' end - if _card.ability.set == 'Voucher' then other_key = 'other_voucher' end - -- TARGET: add context.other_something identifier to your cards - local joker_eval,post = eval_card(_joker, {full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, [other_key] = _card, other_main = _card }) - if next(joker_eval) then - if joker_eval.edition then joker_eval.edition = {} end - joker_eval.jokers.juice_card = _joker - table.insert(effects, joker_eval) - for _, v in ipairs(post) do effects[#effects+1] = v end - if joker_eval.retriggers then - for rt = 1, #joker_eval.retriggers do - local rt_eval, rt_post = eval_card(_card, {full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, [other_key] = _card, retrigger_joker = true}) - table.insert(effects, {joker_eval.retriggers[rt]}) - table.insert(effects, rt_eval) - for _, v in ipairs(rt_post) do effects[#effects+1] = v end - end - end - end - end -end -''' - -## Fix other evaluations -# Discarding cards -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = ''' -for j = 1, #G.jokers.cards do - local eval = nil - eval = G.jokers.cards[j]:calculate_joker({discard = true, other_card = G.hand.highlighted[i], full_hand = G.hand.highlighted}) - if eval then - if eval.remove then removed = true end - card_eval_status_text(G.jokers.cards[j], 'jokers', nil, 1, nil, eval) - end -end''' -match_indent = true -position = "at" -payload = ''' -local effects = {} -SMODS.calculate_context({discard = true, other_card = G.hand.highlighted[i], full_hand = G.hand.highlighted}, effects) -SMODS.trigger_effects(effects) -for _, eval in pairs(effects) do - if type(eval) == 'table' then - for key, eval2 in pairs(eval) do - if key == 'remove' or (type(eval2) == 'table' and eval2.remove) then removed = true end - end - end -end''' - -# context.before -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = ''' -for i=1, #G.jokers.cards do - --calculate the joker effects - local effects = eval_card(G.jokers.cards[i], {cardarea = G.jokers, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, before = true}) - if effects.jokers then - card_eval_status_text(G.jokers.cards[i], 'jokers', nil, percent, nil, effects.jokers) - percent = percent + percent_delta - if effects.jokers.level_up then - level_up_hand(G.jokers.cards[i], text) - end - end -end''' -match_indent = true -position = "at" -payload = ''' --- context.before calculations -SMODS.calculate_context({full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, before = true}) - --- TARGET: effects before scoring starts''' - -# context.final_scoring_step -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = '''local nu_chip, nu_mult = G.GAME.selected_back:trigger_effect{context = 'final_scoring_step', chips = hand_chips, mult = mult}''' -match_indent = true -position = "before" -payload = ''' --- context.final_scoring_step calculations -SMODS.calculate_context({full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, final_scoring_step = true}) - --- TARGET: effects before deck final_scoring_step -''' - -# context.destroying_card -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = ''' -for j = 1, #G.jokers.cards do - destroyed = G.jokers.cards[j]:calculate_joker({destroying_card = scoring_hand[i], full_hand = G.play.cards}) - if destroyed then break end -end - -if scoring_hand[i].ability.name == 'Glass Card' and not scoring_hand[i].debuff and pseudorandom('glass') < G.GAME.probabilities.normal/scoring_hand[i].ability.extra then - destroyed = true -end''' -match_indent = true -position = "at" -payload = ''' --- context.destroying_card calculations -for j = 1, #G.jokers.cards do - local eval, post = eval_card(G.jokers.cards[j], {destroying_card = scoring_hand[i], full_hand = G.play.cards}) - SMODS.trigger_effects({eval, post}, scoring_hand[i]) - if eval.jokers then destroyed = true end - -end - -if SMODS.has_enhancement(scoring_hand[i], 'm_glass') and not scoring_hand[i].debuff and pseudorandom('glass') < G.GAME.probabilities.normal/(scoring_hand[i].ability.name == 'Glass Card' and scoring_hand[i].ability.extra or G.P_CENTERS.m_glass.config.extra) then - destroyed = true -end - -local eval, post = eval_card(scoring_hand[i], {destroying_card = scoring_hand[i], full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, cardarea = G.play}) -local self_destroy = false -for key, effect in pairs(eval) do - self_destroy = SMODS.calculate_effect(effect, scoring_hand[i]) -end -SMODS.trigger_effects({post}, scoring_hand[i]) -if self_destroy then destroyed = true end - --- TARGET: card destroyed when played -''' - -# context.remove_playing_cards -[[patches]] -[patches.regex] -target = "functions/state_events.lua" -pattern = '''(?[\t ]*)local cards_destroyed = \{\}\n(.*\n)*?\s+for j=1, #G\.jokers\.cards do\n\s+eval_card\(G\.jokers\.cards\[j\], \{cardarea = G\.jokers, remove_playing_cards = true, removed = cards_destroyed\}\)\n\s+end''' -line_prepend = '$indent' -position = "at" -payload = ''' -local cards_destroyed = {} -for _,v in ipairs(SMODS.get_card_areas('playing_cards', 'destroying_cards')) do - SMODS.calculate_destroying_cards({ full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, cardarea = v }, cards_destroyed, v == G.play and scoring_hand or nil) -end - --- context.remove_playing_cards calculations -if cards_destroyed[1] then - SMODS.calculate_context({scoring_hand = scoring_hand, remove_playing_cards = true, removed = cards_destroyed}) -end - --- TARGET: effects when cards are removed - -''' - -[[patches]] -[patches.regex] -target = 'card.lua' -line_prepend = '$indent' -position = 'at' -pattern = '(?[\t ]*)for i = 1, #G.jokers.cards do[\n\s]*G.jokers.cards\[i\]:calculate_joker\(\{remove_playing_cards = true, removed = destroyed_cards\}\)[\s\n]*end' -payload = '''SMODS.calculate_context({ remove_playing_cards = true, removed = destroyed_cards })''' - -# context.remove_playing_cards from discard -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = ''' -if destroyed_cards[1] then - for j=1, #G.jokers.cards do - eval_card(G.jokers.cards[j], {cardarea = G.jokers, remove_playing_cards = true, removed = destroyed_cards}) - end -end -''' -position = "at" -match_indent = true -payload = ''' --- context.remove_playing_cards from discard -if destroyed_cards[1] then - SMODS.calculate_context({remove_playing_cards = true, removed = destroyed_cards}) -end - --- TARGET: effects after cards destroyed in discard''' - - -# context.debuffed_hand -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = ''' -for i=1, #G.jokers.cards do - - --calculate the joker effects - local effects = eval_card(G.jokers.cards[i], {cardarea = G.jokers, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, debuffed_hand = true}) - - --Any Joker effects - if effects.jokers then - card_eval_status_text(G.jokers.cards[i], 'jokers', nil, percent, nil, effects.jokers) - percent = percent+percent_delta - end -end''' -match_indent = true -position = "at" -payload = ''' --- context.debuffed_hand calculations -SMODS.calculate_context({full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, debuffed_hand = true}) - --- TARGET: effects after hand debuffed by blind''' - -# context.after -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = ''' -for i=1, #G.jokers.cards do - --calculate the joker after hand played effects - local effects = eval_card(G.jokers.cards[i], {cardarea = G.jokers, full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, after = true}) - if effects.jokers then - card_eval_status_text(G.jokers.cards[i], 'jokers', nil, percent, nil, effects.jokers) - percent = percent + percent_delta - end -end''' -match_indent = true -position = "at" -payload = ''' --- context.after calculations -SMODS.calculate_context({full_hand = G.play.cards, scoring_hand = scoring_hand, scoring_name = text, poker_hands = poker_hands, after = true}) - --- TARGET: effects after hand evaluation''' - -# calc_dollar_bonus call through consumeables -[[patches]] -[patches.pattern] -target = 'functions/state_events.lua' -pattern = ''' -for i = 1, #G.jokers.cards do - local ret = G.jokers.cards[i]:calculate_dollar_bonus() - if ret then - add_round_eval_row({dollars = ret, bonus = true, name='joker'..i, pitch = pitch, card = G.jokers.cards[i]}) - pitch = pitch + 0.06 - dollars = dollars + ret - end -end -''' -position = 'at' -match_indent = true -payload = ''' -local i = 0 -for _, area in ipairs(SMODS.get_card_areas('jokers')) do - for _, _card in ipairs(area.cards) do - local ret = _card:calculate_dollar_bonus() - - -- TARGET: calc_dollar_bonus per card - if ret then - i = i+1 - add_round_eval_row({dollars = ret, bonus = true, name='joker'..i, pitch = pitch, card = _card}) - pitch = pitch + 0.06 - dollars = dollars + ret - end - end -end -''' - -# context.end_of_round -[[patches]] -[patches.pattern] -target = 'functions/state_events.lua' -pattern = ''' -for i = 1, #G.jokers.cards do - local eval = nil - eval = G.jokers.cards[i]:calculate_joker({end_of_round = true, game_over = game_over}) - if eval then - if eval.saved then - game_over = false - end - card_eval_status_text(G.jokers.cards[i], 'jokers', nil, nil, nil, eval) - end - G.jokers.cards[i]:calculate_rental() - G.jokers.cards[i]:calculate_perishable() -end -''' -position = 'at' -match_indent = true -payload = ''' --- context.end_of_round calculations -SMODS.saved = false -SMODS.calculate_context({end_of_round = true, game_over = game_over }) -if SMODS.saved then game_over = false end --- TARGET: main end_of_round evaluation -''' - -# context.end_of_round individual effects -[[patches]] -[patches.regex] -target = 'functions/state_events.lua' -position = 'at' -pattern = '''(?[\t ]*)for i=1, #G\.hand\.cards do\n\s+--Check for hand doubling\n(.*\n)*?\s+delay\(0\.3\)''' -line_prepend = '$indent' -payload = '''for _,v in ipairs(SMODS.get_card_areas('playing_cards', 'end_of_round')) do - SMODS.calculate_end_of_round_effects({ cardarea = v, end_of_round = true }) -end -''' - - -# context.setting_blind -[[patches]] -[patches.pattern] -target = 'functions/state_events.lua' -pattern = ''' -for i = 1, #G.jokers.cards do - G.jokers.cards[i]:calculate_joker({setting_blind = true, blind = G.GAME.round_resets.blind}) -end -''' -position = 'at' -match_indent = true -payload = ''' -SMODS.calculate_context({setting_blind = true, blind = G.GAME.round_resets.blind}) - --- TARGET: setting_blind effects -''' - -# context.pre_discard -[[patches]] -[patches.pattern] -target = 'functions/state_events.lua' -pattern = ''' -for j = 1, #G.jokers.cards do - G.jokers.cards[j]:calculate_joker({pre_discard = true, full_hand = G.hand.highlighted, hook = hook}) -end -''' -position = 'at' -match_indent = true -payload = ''' -SMODS.calculate_context({pre_discard = true, full_hand = G.hand.highlighted, hook = hook}) - --- TARGET: pre_discard -''' - -# context.selling_self in cards -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = ''' -self:calculate_joker{selling_self = true} -''' -position = 'at' -match_indent = true -payload = ''' -local eval, post = eval_card(self, {selling_self = true}) -SMODS.trigger_effects({eval, post}, self) -''' - -# context.open_booster -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = ''' - for i = 1, #G.jokers.cards do - G.jokers.cards[i]:calculate_joker({open_booster = true, card = self}) - end -''' -position = 'at' -match_indent = true -payload = ''' -SMODS.calculate_context({open_booster = true, card = self}) -''' - -# context.buying_card -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = ''' - for i = 1, #G.jokers.cards do - G.jokers.cards[i]:calculate_joker({buying_card = true, card = self}) - end -''' -position = 'at' -match_indent = true -payload = ''' -SMODS.calculate_context({buying_card = true, card = self}) -''' - -# context.first_hand_drawn -[[patches]] -[patches.pattern] -target = 'game.lua' -pattern = ''' - for i = 1, #G.jokers.cards do - G.jokers.cards[i]:calculate_joker({first_hand_drawn = true}) - end -end -''' -position = 'at' -match_indent = true -payload = ''' - SMODS.calculate_context({first_hand_drawn = true}) -end -SMODS.calculate_context({hand_drawn = true}) -''' - -# context.using_consumeable -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -pattern = ''' - for i = 1, #G.jokers.cards do - G.jokers.cards[i]:calculate_joker({using_consumeable = true, consumeable = card}) - end -''' -position = 'at' -match_indent = true -payload = ''' -SMODS.calculate_context({using_consumeable = true, consumeable = card, area = card.from_area}) -''' -# save area of used card -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -match_indent = true -position = 'before' -pattern = ''' -c1.area:remove_card(c1) -''' -payload = ''' -c1.from_area = c1.area -''' -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -match_indent = true -position = 'before' -pattern = ''' -if card.area and (not nc or card.area == G.pack_cards) then card.area:remove_card(card) end -''' -payload = ''' -if not card.from_area then card.from_area = card.area end -''' - -# context.selling_card -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -pattern = ''' - for i = 1, #G.jokers.cards do - if G.jokers.cards[i] ~= card then - G.jokers.cards[i]:calculate_joker({selling_card = true, card = card}) - end - end -''' -position = 'at' -match_indent = true -payload = ''' -SMODS.calculate_context({selling_card = true, card = card}) -''' - - -# context.buying_card -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -pattern = ''' -G.E_MANAGER:add_event(Event({func = function() c1:calculate_joker({buying_card = true, card = c1}) return true end})) -''' -position = 'at' -match_indent = true -payload = ''' -G.E_MANAGER:add_event(Event({func = function() - local eval, post = eval_card(c1, {buying_card = true, card = c1}) - SMODS.trigger_effects({eval, post}, c1) - return true - end})) -''' - -# context.buying_card -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -pattern = ''' - for i = 1, #G.jokers.cards do - G.jokers.cards[i]:calculate_joker({buying_card = true, card = c1}) - end -''' -position = 'at' -match_indent = true -payload = ''' -SMODS.calculate_context({buying_card = true, card = c1}) -''' - -# context.ending_shop -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -pattern = ''' - for i = 1, #G.jokers.cards do - G.jokers.cards[i]:calculate_joker({ending_shop = true}) - end -''' -position = 'at' -match_indent = true -payload = ''' -SMODS.calculate_context({ending_shop = true}) -''' - -# context.skipping_booster -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -pattern = ''' - for i = 1, #G.jokers.cards do - G.jokers.cards[i]:calculate_joker({skipping_booster = true}) - end -''' -position = 'at' -match_indent = true -payload = ''' -SMODS.calculate_context({skipping_booster = true}) -''' -# context.skip_blind -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -pattern = ''' - for i = 1, #G.jokers.cards do - G.jokers.cards[i]:calculate_joker({skip_blind = true}) - end -''' -position = 'at' -match_indent = true -payload = ''' -SMODS.calculate_context({skip_blind = true}) -''' - -# context.reroll_shop -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -pattern = ''' - for i = 1, #G.jokers.cards do - G.jokers.cards[i]:calculate_joker({reroll_shop = true}) - end -''' -position = 'at' -match_indent = true -payload = ''' -SMODS.calculate_context({reroll_shop = true}) -''' - - -# Fix purple seal calc -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = ''' -if context.discard then - if self.seal == 'Purple' and #G.consumeables.cards + G.GAME.consumeable_buffer < G.consumeables.config.card_limit then''' -position = 'at' -match_indent = true -payload = ''' -if context.discard and context.other_card == self then - if self.seal == 'Purple' and #G.consumeables.cards + G.GAME.consumeable_buffer < G.consumeables.config.card_limit then''' - -# Fix context.blueprint persisting -[[patches]] -[patches.pattern] -target = 'card.lua' -match_indent = true -position = 'after' -pattern = 'local other_joker_ret = other_joker:calculate_joker(context)' -payload = ''' -context.blueprint = nil -local eff_card = context.blueprint_card or self -context.blueprint_card = nil''' - -[[patches]] -[patches.pattern] -target = 'card.lua' -match_indent = true -position = 'at' -pattern = 'other_joker_ret.card = context.blueprint_card or self' -payload = '''other_joker_ret.card = eff_card''' - -# Auto deal with negative chips card_eval_status_text() -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -match_indent = true -position = 'at' -pattern = ''' -text = localize{type='variable',key='a_chips',vars={amt}} -''' -payload = ''' -text = localize{type='variable',key='a_chips'..(amt<0 and '_minus' or ''),vars={math.abs(amt)}} -''' - -# Auto deal with negative mult card_eval_status_text() -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -match_indent = true -position = 'at' -pattern = ''' -text = localize{type='variable',key='a_mult',vars={amt}} -''' -payload = ''' -text = localize{type='variable',key='a_mult'..(amt<0 and '_minus' or ''),vars={math.abs(amt)}} -''' - -# Auto deal with negative xmult card_eval_status_text() -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -match_indent = true -position = 'at' -pattern = ''' -text = localize{type='variable',key='a_xmult',vars={amt}} -''' -payload = ''' -text = localize{type='variable',key='a_xmult'..(amt<0 and '_minus' or ''),vars={math.abs(amt)}} -''' -# Make percent and percent_delta globals -[[patches]] -[patches.pattern] -target = 'functions/state_events.lua' -match_indent = true -position = 'at' -pattern = '''local percent = 0.3 -local percent_delta = 0.08 -''' -payload = '''percent = 0.3 -percent_delta = 0.08 -''' - -[[patches]] -[patches.pattern] -target = 'functions/state_events.lua' -match_indent = true -position = 'at' -pattern = '''local percent = (i-0.999)/(#G.hand.cards-0.998) + (j-1)*0.1''' -payload = '''percent = (i-0.999)/(#G.hand.cards-0.998) + (j-1)*0.1''' - -# Add support for pitch and volume returns in effects -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -match_indent = true -position = 'after' -pattern = ''' -volume = extra.edition and 0.3 or sound == 'multhit2' and 0.7 or 1 -''' -payload = ''' -sound = extra.sound or sound -percent = extra.pitch or percent -volume = extra.volume or volume -''' - -# Voucher cardarea -[[patches]] -[patches.pattern] -target = 'game.lua' -match_indent = true -position = 'before' -pattern = 'self.deck = CardArea(' -payload = '''self.vouchers = CardArea( - G.discard.T.x, G.discard.T.y, - G.discard.T.w, G.discard.T.h, - { type = "discard", card_limit = 1e308 } -) -''' - -[[patches]] -[patches.pattern] -target = 'card.lua' -match_indent = true -position = 'after' -pattern = 'function Card:apply_to_run(center)' -payload = '''local card_to_save = self and copy_card(self) or Card(0, 0, G.CARD_W, G.CARD_H, G.P_CARDS.empty, center) -card_to_save.VT.x, card_to_save.VT.y = G.vouchers.T.x, G.vouchers.T.y -G.vouchers:emplace(card_to_save) -''' - -[[patches]] -[patches.pattern] -target = 'card.lua' -position = 'at' -match_indent = false -pattern = '''if self.ability.set == "Planet" and not self.debuff then - if context.joker_main then - if G.GAME.used_vouchers.v_observatory and self.ability.consumeable.hand_type == context.scoring_name then - return { - message = localize{type = 'variable', key = 'a_xmult', vars = {G.P_CENTERS.v_observatory.config.extra}}, - Xmult_mod = G.P_CENTERS.v_observatory.config.extra - } - end - end -end''' -payload = '' - -[[patches]] -[patches.regex] -target = 'back.lua' -position = 'at' -line_prepend = '$indent' -pattern = '(?[\t ]*)(?Card.apply_to_run\(nil, G\.P_CENTERS\[.*?\]\))' -payload = '''G.E_MANAGER:add_event(Event({ - func = function() - $line - return true - end -}))''' - -#wtf -[[patches]] -[patches.pattern] -target = 'card.lua' -match_indent = true -position = 'at' -pattern = '''self.discard_pos = { - r = 3.6*(math.random()-0.5), - x = math.random(), - y = math.random() -}''' -payload = '''self.discard_pos = { - r = 0, - x = 0, - y = 0, -} -''' - -# xchip support -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -match_indent = true -position = 'before' -pattern = ''' -elseif (eval_type == 'x_mult') or (eval_type == 'h_x_mult') then -''' -payload = ''' -elseif eval_type == 'x_chips' then - sound = 'xchips' - volume = 0.7 - amt = amt - text = localize{type='variable',key='a_xchips'..(amt<0 and '_minus' or ''),vars={math.abs(amt)}} - colour = G.C.BLUE - config.type = 'fade' - config.scale = 0.7 -''' -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -match_indent = true -position = 'at' -pattern = ''' -if extra.chip_mod then -''' -payload = ''' -if extra.chip_mod or extra.Xchip_mod then -''' diff --git a/smods-main/lovely/blind.toml b/smods-main/lovely/blind.toml deleted file mode 100644 index 8ca1152..0000000 --- a/smods-main/lovely/blind.toml +++ /dev/null @@ -1,362 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -### Blind API - -## Set debuffed_by_blind, use it for Matador behavior -## Blind:debuff_card() -[[patches]] -[patches.pattern] -target = 'blind.lua' -pattern = 'card:set_debuff(true)' -position = 'after' -payload = "if card.debuff then card.debuffed_by_blind = true end" -match_indent = true -[[patches]] -[patches.regex] -target = 'blind.lua' -pattern = 'card:set_debuff\(true\); return end' -position = 'at' -payload = """ -card:set_debuff(true); if card.debuff then card.debuffed_by_blind = true end; return end""" - -## Card:set_debuff() -[[patches]] -[patches.regex] -target = 'card.lua' -pattern = ''' -self\.debuff = should_debuff -(?[\t ]*)end -''' -position = 'after' -payload = """if not self.debuff then self.debuffed_by_blind = false end - -""" -line_prepend = '$indent' - -## Blind functions - -# Blind:set_blind() -[[patches]] -[patches.pattern] -target = 'blind.lua' -pattern = "G.GAME.last_blind = G.GAME.last_blind or {}" -position = 'before' -match_indent = true -payload = ''' -local obj = self.config.blind -self.children.animatedSprite.atlas = G.ANIMATION_ATLAS[obj.atlas] or G.ANIMATION_ATLAS['blind_chips']''' - -[[patches]] -[patches.pattern] -target = 'blind.lua' -pattern = '--add new debuffs' -position = 'before' -match_indent = true -payload = ''' -if not reset then - local obj = self.config.blind - if obj.set_blind and type(obj.set_blind) == 'function' then - obj:set_blind() - end -end''' - -# Blind:disable() -[[patches]] -[patches.pattern] -target = 'blind.lua' -pattern = "if self.name == 'The Water' then" -position = 'before' -match_indent = true -payload = ''' -local obj = self.config.blind -if obj.disable and type(obj.disable) == 'function' then - obj:disable() -end''' - -# Blind:defeat() -[[patches]] -[patches.pattern] -target = 'blind.lua' -pattern = "if self.name == 'The Manacle' and not self.disabled then" -position = 'before' -match_indent = true -payload = ''' -local obj = self.config.blind -if obj.defeat and type(obj.defeat) == 'function' then - obj:defeat() -end''' - -# Blind:debuff_card() -[[patches]] -[patches.pattern] -target = 'blind.lua' -pattern = "if self.debuff and not self.disabled and card.area ~= G.jokers then" -position = 'before' -match_indent = true -payload = ''' -local obj = self.config.blind -if not self.disabled and obj.recalc_debuff and type(obj.recalc_debuff) == 'function' then - if obj:recalc_debuff(card, from_blind) then - card:set_debuff(true) - if card.debuff then card.debuffed_by_blind = true end - else - card:set_debuff(false) - end - return -elseif not self.disabled and obj.debuff_card and type(obj.debuff_card) == 'function' then - sendWarnMessage(("Blind object %s has debuff_card function, recalc_debuff is preferred"):format(obj.key), obj.set) - if obj:debuff_card(card, from_blind) then - card:set_debuff(true) - if card.debuff then card.debuffed_by_blind = true end - else - card:set_debuff(false) - end - return -end''' - -# Blind:stay_flipped() -[[patches]] -[patches.pattern] -target = 'blind.lua' -pattern = "if area == G.hand then" -position = 'before' -match_indent = true -payload = ''' -local obj = self.config.blind -if obj.stay_flipped and type(obj.stay_flipped) == 'function' then - return obj:stay_flipped(area, card) -end''' - -# Blind:drawn_to_hand() -[[patches]] -[patches.regex] -target = 'blind.lua' -pattern = "(?[\t ]*)if self.name == 'Cerulean Bell' then\n" -position = 'before' -line_prepend = '$indent' -payload = ''' -local obj = self.config.blind -if obj.drawn_to_hand and type(obj.drawn_to_hand) == 'function' then - obj:drawn_to_hand() -end''' - -# Blind:debuff_hand() -[[patches]] -[patches.pattern] -target = 'blind.lua' -pattern = "if self.debuff then" -position = 'before' -match_indent = true -payload = ''' -local obj = self.config.blind -if obj.debuff_hand and type(obj.debuff_hand) == 'function' then - return obj:debuff_hand(cards, hand, handname, check) -end''' - -# Blind:modify_hand() -[[patches]] -[patches.pattern] -target = 'blind.lua' -pattern = "if self.disabled then return mult, hand_chips, false end" -position = 'after' -match_indent = true -payload = ''' -local obj = self.config.blind -if obj.modify_hand and type(obj.modify_hand) == 'function' then - return obj:modify_hand(cards, poker_hands, text, mult, hand_chips) -end''' - -# Blind:press_play() -[[patches]] -[patches.pattern] -target = 'blind.lua' -pattern = 'if self.name == "The Hook" then' -position = 'before' -match_indent = true -payload = ''' -local obj = self.config.blind -if obj.press_play and type(obj.press_play) == 'function' then - return obj:press_play() -end''' - -# Blind:get_loc_debuff_text() -[[patches]] -[patches.pattern] -target = 'blind.lua' -pattern = 'function Blind:get_loc_debuff_text()' -position = 'after' -match_indent = true -payload = ''' - local obj = self.config.blind - if obj.get_loc_debuff_text and type(obj.get_loc_debuff_text) == 'function' then - return obj:get_loc_debuff_text() - end''' - -# Blind:set_text() -[[patches]] -[patches.pattern] -target = 'blind.lua' -pattern = "local loc_target = localize{type = 'raw_descriptions', key = self.config.blind.key, set = 'Blind', vars = loc_vars or self.config.blind.vars}" -position = 'at' -match_indent = true -payload = ''' -local target = {type = 'raw_descriptions', key = self.config.blind.key, set = 'Blind', vars = loc_vars or self.config.blind.vars} -local obj = self.config.blind -if obj.loc_vars and type(obj.loc_vars) == 'function' then - local res = obj:loc_vars() or {} - target.vars = res.vars or target.vars - target.key = res.key or target.key -end -local loc_target = localize(target)''' - -# Blind:load() -[[patches]] -[patches.pattern] -target = 'blind.lua' -pattern = 'if G.P_BLINDS[blindTable.config_blind] then' -position = 'after' -match_indent = true -payload = ''' -if self.config.blind.atlas then - self.children.animatedSprite.atlas = G.ANIMATION_ATLAS[self.config.blind.atlas] -end''' - - -# create_UIBox_blind_choice() -# create_UIBox_round_scores_row() -[[patches]] -[patches.regex] -target = 'functions/UI_definitions.lua' -pattern = "(?[\t ]*)blind_choice.animation = AnimatedSprite\\(0,0, 1.4, 1.4, (?G.ANIMATION_ATLAS\\['blind_chips'\\]), blind_choice.config.pos\\)" -position = 'at' -root_capture = 'atlas' -payload = "G.ANIMATION_ATLAS[blind_choice.config.atlas] or G.ANIMATION_ATLAS['blind_chips']" - -# create_UIBox_your_collection_blinds() -[[patches]] -[patches.regex] -target = 'functions/UI_definitions.lua' -pattern = "(?[\t ]*)local temp_blind = AnimatedSprite\\(0,0,1.3,1.3, G.ANIMATION_ATLAS\\['blind_chips'\\], discovered and v.pos or G.b_undiscovered.pos\\)" -position = 'at' -payload = ''' - -local s = 1.3 -if math.ceil(#blind_tab/6) > 6 then - s = s * 6/math.ceil(#blind_tab/6) -end -local temp_blind = AnimatedSprite(0,0,s,s, G.ANIMATION_ATLAS[discovered and v.atlas or 'blind_chips'], discovered and v.pos or G.b_undiscovered.pos)''' -line_prepend = '$indent' - -[[patches]] -[patches.pattern] -target = 'functions/UI_definitions.lua' -pattern = 'blind_matrix[math.ceil((k-1)/5+0.001)][1+((k-1)%5)] = {n=G.UIT.C, config={align = "cm", padding = 0.1}, nodes={' -match_indent = true -position = 'at' -payload = ''' -local blinds_per_row = math.ceil(#blind_tab / 6) -local row = math.ceil((k - 1) / blinds_per_row + 0.001) -table.insert(blind_matrix[row], { - n = G.UIT.C, - config = { align = "cm", padding = 0.1 }, - nodes = { - ((k - blinds_per_row) % (2 * blinds_per_row) == 1) and { n = G.UIT.B, config = { h = 0.2, w = 0.5 } } or nil, - { n = G.UIT.O, config = { object = temp_blind, focus_with_object = true } }, - ((k - blinds_per_row) % (2 * blinds_per_row) == 0) and { n = G.UIT.B, config = { h = 0.2, w = 0.5 } } or nil, - } -})''' - -[[patches]] -[patches.regex] -target = 'functions/UI_definitions.lua' -pattern = '[\t ]*\(k==6 or k ==16 or k == 26\) and \{n=G.UIT.B, config=\{h=0.2,w=0.5\}\} or nil,\n[\t ]*\{n=G.UIT.O, config=\{object = temp_blind, focus_with_object = true\}\},\n[\t ]*\(k==5 or k ==15 or k == 25\) and \{n=G.UIT.B, config=\{h=0.2,w=0.5\}\} or nil,\n[\t ]*\}\}' -position = 'at' -payload = '' - -[[patches]] -[patches.pattern] -target = 'functions/UI_definitions.lua' -pattern = 'table.sort(blind_tab, function (a, b) return a.order < b.order end)' -match_indent = true -position = 'at' -payload = ''' -table.sort(blind_tab, function(a, b) return a.order + (a.boss and a.boss.showdown and 1000 or 0) < b.order + (b.boss and b.boss.showdown and 1000 or 0) end)''' - -# add_round_eval_row() -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -pattern = "local blind_sprite = AnimatedSprite(0, 0, 1.2,1.2, G.ANIMATION_ATLAS['blind_chips'], copy_table(G.GAME.blind.pos))" -match_indent = true -position = 'at' -payload = ''' -local obj = G.GAME.blind.config.blind -local blind_sprite = AnimatedSprite(0, 0, 1.2, 1.2, G.ANIMATION_ATLAS[obj.atlas] or G.ANIMATION_ATLAS['blind_chips'], copy_table(G.GAME.blind.pos))''' - -# create_UIBox_blind_choice() -[[patches]] -[patches.pattern] -target = 'functions/UI_definitions.lua' -pattern = "local loc_target = localize{type = 'raw_descriptions', key = blind_choice.config.key, set = 'Blind', vars = {localize(G.GAME.current_round.most_played_poker_hand, 'poker_hands')}}" -match_indent = true -position = 'at' -payload = ''' -local target = {type = 'raw_descriptions', key = blind_choice.config.key, set = 'Blind', vars = {}} -if blind_choice.config.name == 'The Ox' then - target.vars = {localize(G.GAME.current_round.most_played_poker_hand, 'poker_hands')} -end -local obj = blind_choice.config -if obj.loc_vars and _G['type'](obj.loc_vars) == 'function' then - local res = obj:loc_vars() or {} - target.vars = res.vars or target.vars - target.key = res.key or target.key -end -local loc_target = localize(target)''' - -# create_UIBox_blind_popup() -[[patches]] -[patches.pattern] -target = 'functions/UI_definitions.lua' -pattern = '''local loc_target = localize{type = 'raw_descriptions', key = blind.key, set = 'Blind', vars = vars or blind.vars}''' -match_indent = true -position = 'at' -payload = ''' -local target = {type = 'raw_descriptions', key = blind.key, set = 'Blind', vars = vars or blind.vars} -if blind.collection_loc_vars and type(blind.collection_loc_vars) == 'function' then - local res = blind:collection_loc_vars() or {} - target.vars = res.vars or target.vars - target.key = res.key or target.key -end -local loc_target = localize(target)''' - -# get_new_boss() -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -pattern = 'elseif not v.boss.showdown*' -match_indent = true -position = 'before' -payload = ''' -elseif v.in_pool and type(v.in_pool) == 'function' then - local res, options = v:in_pool() - if - ( - ((G.GAME.round_resets.ante)%G.GAME.win_ante == 0 and G.GAME.round_resets.ante >= 2) == - (v.boss.showdown or false) - ) or - (options or {}).ignore_showdown_check - then - eligible_bosses[k] = res and true or nil - end''' - -# G.UIDEF.challenge_description_tab -[[patches]] -[patches.pattern] -target = 'functions/UI_definitions.lua' -pattern = "local temp_blind = AnimatedSprite(0,0,1,1, G.ANIMATION_ATLAS['blind_chips'], v.pos)" -position = 'at' -match_indent = true -payload = "local temp_blind = AnimatedSprite(0,0,1,1, G.ANIMATION_ATLAS[v.atlas or ''] or G.ANIMATION_ATLAS['blind_chips'], v.pos)" diff --git a/smods-main/lovely/blind_ui.toml b/smods-main/lovely/blind_ui.toml deleted file mode 100644 index 8c84f3f..0000000 --- a/smods-main/lovely/blind_ui.toml +++ /dev/null @@ -1,150 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -### Allow blinds to have more than 2 lines - -# create_UIBox_blind_choice() -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = "if blind_state == 'Select' then blind_state = 'Current' end" -position = 'after' -payload = ''' -local blind_desc_nodes = {} -for k, v in ipairs(text_table) do - blind_desc_nodes[#blind_desc_nodes+1] = {n=G.UIT.R, config={align = "cm", maxw = 2.8}, nodes={ - {n=G.UIT.T, config={text = v or '-', scale = 0.32, colour = disabled and G.C.UI.TEXT_INACTIVE or G.C.WHITE, shadow = not disabled}} - }} -end''' -match_indent = true - -[[patches]] -[patches.regex] -target = "functions/UI_definitions.lua" -pattern = ''' -(?[\t ]*)text_table\[1\] and \{n=G\.UIT\.R, config=\{align = "cm", minh = 0\.7, padding = 0\.05, minw = 2\.9}, nodes=\{ -[\t ]* text_table\[1\] and \{n=G\.UIT\.R, config=\{align = "cm", maxw = 2\.8\}, nodes=\{ -[\t ]* \{n=G\.UIT\.T, config=\{id = blind_choice\.config\.key, ref_table = \{val = ''\}, ref_value = 'val', scale = 0\.32, colour = disabled and G\.C\.UI\.TEXT_INACTIVE or G\.C\.WHITE, shadow = not disabled, func = 'HUD_blind_debuff_prefix'\}\}, -[\t ]* \{n=G\.UIT\.T, config=\{text = text_table\[1\] or '\-', scale = 0\.32, colour = disabled and G\.C\.UI\.TEXT_INACTIVE or G\.C\.WHITE, shadow = not disabled\}\} -[\t ]* \}\} or nil, -[\t ]* text_table\[2\] and \{n=G\.UIT\.R, config=\{align = "cm", maxw = 2\.8\}, nodes=\{ -[\t ]* \{n=G\.UIT\.T, config=\{text = text_table\[2\] or '\-', scale = 0\.32, colour = disabled and G\.C\.UI\.TEXT_INACTIVE or G\.C\.WHITE, shadow = not disabled\}\} -[\t ]* \}\} or nil, -[\t ]*\}\} or nil,''' -position = "at" -payload = ''' -text_table[1] and {n=G.UIT.R, config={align = "cm", minh = 0.7, padding = 0.05, minw = 2.9}, nodes = blind_desc_nodes} or nil,''' -line_prepend = '$indent' - -# create_UIBox_HUD_blind() -# Padding and contained nodes are set in G.FUNCS.HUD_blind_debuff (overrides.lua) -[[patches]] -[patches.regex] -target = "functions/UI_definitions.lua" -pattern = ''' -(?[\t ]*)\{n=G\.UIT\.R, config=\{align = "cm", padding = 0\.05\}, nodes=\{ -[\t ]* \{n=G\.UIT\.R, config=\{align = "cm", minh = 0\.3, maxw = 4\.2\}, nodes=\{ -[\t ]* \{n=G\.UIT\.T, config=\{ref_table = \{val = ''\}, ref_value = 'val', scale = scale\*0\.9, colour = G\.C\.UI\.TEXT_LIGHT, func = 'HUD_blind_debuff_prefix'\}\}, -[\t ]* \{n=G\.UIT\.T, config=\{ref_table = G\.GAME\.blind\.loc_debuff_lines, ref_value = 1, scale = scale\*0\.9, colour = G\.C\.UI\.TEXT_LIGHT, id = 'HUD_blind_debuff_1', func = 'HUD_blind_debuff'\}\} -[\t ]* \}\}, -[\t ]* \{n=G\.UIT\.R, config=\{align = "cm", minh = 0\.3, maxw = 4\.2\}, nodes=\{ -[\t ]* \{n=G\.UIT\.T, config=\{ref_table = G\.GAME\.blind\.loc_debuff_lines, ref_value = 2, scale = scale\*0\.9, colour = G\.C\.UI\.TEXT_LIGHT, id = 'HUD_blind_debuff_2', func = 'HUD_blind_debuff'\}\} -[\t ]* \}\}, -[\t ]*\}\},''' -position = "at" -payload = ''' -{n=G.UIT.R, config={align = "cm", id = 'HUD_blind_debuff', func = 'HUD_blind_debuff'}, nodes={}},''' -line_prepend = '$indent' - -# Blind:set_text -[[patches]] -[patches.regex] -target = "blind.lua" -pattern = """ -(?[\t ]*)self\\.loc_debuff_lines\\[1\\] = '' -[\t ]*self\\.loc_debuff_lines\\[2\\] = ''""" -position = 'at' -payload = 'EMPTY(self.loc_debuff_lines)' -line_prepend = '$indent' - -[[patches]] -[patches.pattern] -target = "blind.lua" -pattern = "for k, v in ipairs(loc_target) do" -position = 'before' -payload = 'EMPTY(self.loc_debuff_lines)' -match_indent = true - -[[patches]] -[patches.pattern] -target = "blind.lua" -pattern = "self.loc_debuff_text = self.loc_debuff_text..v..(k <= #loc_target and ' ' or '')" -position = 'after' -payload = "self.loc_debuff_lines[k] = v" -match_indent = true - -[[patches]] -[patches.regex] -target = "blind.lua" -pattern = """ -(?[\t ]*)self\\.loc_debuff_lines\\[1\\] = loc_target\\[1\\] or '' -[\t ]*self\\.loc_debuff_lines\\[2\\] = loc_target\\[2\\] or '' -""" -position = 'at' -payload = '' - -## Add a box with h=3.64 (magic number equal to the height of HUD_blind) -## centered inside 'row_blind' -# create_UIBox_HUD -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = """{n=G.UIT.R, config={align = "cm", id = 'row_blind', minw = 1, minh = 3.75}, nodes={}},""" -position = 'at' -payload = """{n=G.UIT.R, config={align = "cm", id = 'row_blind', minw = 1, minh = 3.75}, nodes={ - {n=G.UIT.B, config={w=0, h=3.64, id = 'row_blind_bottom'}, nodes={}} -}},""" -match_indent = true - -## Blind UI's bottom edge is aligned to it -[[patches]] -[patches.pattern] -target = "game.lua" -pattern = "config = {major = G.HUD:get_UIE_by_ID('row_blind'), align = 'cm', offset = {x=0,y=-10}, bond = 'Weak'}" -position = 'at' -payload = "config = {major = G.HUD:get_UIE_by_ID('row_blind_bottom'), align = 'bmi', offset = {x=0,y=-10}, bond = 'Weak'}" -match_indent = true - -## Patch G.GAME.blind:juice_up() across all files - -[[patches]] -[patches.regex] -target = "functions/common_events.lua" -pattern = ''' -(?[\t ]*)G\.HUD_blind:get_UIE_by_ID\('HUD_blind_debuff_1'\):juice_up\(0\.3, 0\) -[\t ]*G\.HUD_blind:get_UIE_by_ID\('HUD_blind_debuff_2'\):juice_up\(0\.3, 0\) -[\t ]*G\.GAME\.blind:juice_up\(\)''' -position = 'at' -payload = 'SMODS.juice_up_blind()' -line_prepend = '$indent' - -[[patches]] -[patches.regex] -target = "functions/state_events.lua" -pattern = ''' -(?[\t ]*)G\.HUD_blind:get_UIE_by_ID\('HUD_blind_debuff_1'\):juice_up\(0\.3, 0\) -[\t ]*G\.HUD_blind:get_UIE_by_ID\('HUD_blind_debuff_2'\):juice_up\(0\.3, 0\) -[\t ]*G\.GAME\.blind:juice_up\(\)''' -position = 'at' -payload = 'SMODS.juice_up_blind()' -line_prepend = '$indent' - -# remove statically added 1 from The Wheel's collection description -[[patches]] -[patches.regex] -target = 'functions/UI_definitions.lua' -pattern = '''\(k ==1 and blind\.name == 'The Wheel' and '1' or ''\)\.\.''' -position = 'at' -payload = '' diff --git a/smods-main/lovely/booster.toml b/smods-main/lovely/booster.toml deleted file mode 100644 index c2131c0..0000000 --- a/smods-main/lovely/booster.toml +++ /dev/null @@ -1,264 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -## Booster Pack API - -# Card:open -[[patches]] -[patches.regex] -target = "card.lua" -pattern = '''(?[\t ]*)if self\.ability\.name:find\('Arcana'\) then \n[\s\S]{12}G\.STATE''' -position = "before" -payload = ''' -booster_obj = self.config.center -if booster_obj and SMODS.Centers[booster_obj.key] then - G.STATE = G.STATES.SMODS_BOOSTER_OPENED - SMODS.OPENED_BOOSTER = self -end''' -line_prepend = '$indent' - -# Card:open -[[patches]] -[patches.regex] -target = "card.lua" -pattern = '''(?[\t ]*)if self\.ability\.name:find\('Arcana'\) then[\t\n ]*if G\.GAME\.used_vouchers\.v_omen_globe and pseudorandom\('omen_globe'\) > 0\.8 then''' # Possibly try to target something else -position = "at" -payload = '''if booster_obj.create_card and type(booster_obj.create_card) == "function" then - local _card_to_spawn = booster_obj:create_card(self, i) - if type((_card_to_spawn or {}).is) == 'function' and _card_to_spawn:is(Card) then - card = _card_to_spawn - else - card = SMODS.create_card(_card_to_spawn) - end -elseif self.ability.name:find('Arcana') then - if G.GAME.used_vouchers.v_omen_globe and pseudorandom('omen_globe') > 0.8 then''' -line_prepend = '$indent' - -# Game:set_globals -[[patches]] -[patches.regex] -target = "globals.lua" -pattern = '''(?[\t ]*)self\.STATES = \{''' -position = "after" -payload = ''' - - SMODS_BOOSTER_OPENED = 999,''' -line_prepend = '$indent' - -# Game:update -[[patches]] -[patches.regex] -target = "game.lua" -pattern = '''(?[\t ]*)if self\.STATE == self\.STATES\.TAROT_PACK then''' -position = "before" -payload = ''' -if G.STATE == G.STATES.SMODS_BOOSTER_OPENED then - SMODS.OPENED_BOOSTER.config.center:update_pack(dt) -end - -''' -line_prepend = '$indent' - -# G.FUNC.can_skip_booster -# TODO customize whether pack can be skipped -[[patches]] -[patches.regex] -target = "functions/button_callbacks.lua" -pattern = '''(?[\t ]*)\(G\.STATE == G\.STATES\.PLANET_PACK or G\.STATE == G\.STATES\.STANDARD_PACK''' -position = "at" -payload = '''(G.STATE == G.STATES.SMODS_BOOSTER_OPENED or G.STATE == G.STATES.PLANET_PACK or G.STATE == G.STATES.STANDARD_PACK''' - -# CardArea:draw() -[[patches]] -[patches.pattern] -target = "cardarea.lua" -pattern = "(self.config.type == 'deck' and self ~= G.deck) or" -position = "before" -payload = ''' -(self.config.type == 'hand' and state == G.STATES.SMODS_BOOSTER_OPENED) or''' -match_indent = true - -# G.FUNCS.use_card -[[patches]] -[patches.pattern] -target = "functions/button_callbacks.lua" -pattern = "prev_state == G.STATES.SPECTRAL_PACK or prev_state == G.STATES.STANDARD_PACK or" -position = "after" -payload = ''' -prev_state == G.STATES.SMODS_BOOSTER_OPENED or''' -match_indent = true - -# CardArea:align_cards() -[[patches]] -[patches.pattern] -target = "cardarea.lua" -pattern = "if self.config.type == 'hand' and (G.STATE == G.STATES.TAROT_PACK or G.STATE == G.STATES.SPECTRAL_PACK or G.STATE == G.STATES.PLANET_PACK) then" -position = "at" -payload = "if self.config.type == 'hand' and (G.STATE == G.STATES.TAROT_PACK or G.STATE == G.STATES.SPECTRAL_PACK or G.STATE == G.STATES.PLANET_PACK or G.STATE == G.STATES.SMODS_BOOSTER_OPENED) then" -match_indent = true - -# CardArea:align_cards() -[[patches]] -[patches.pattern] -target = "cardarea.lua" -pattern = "if self.config.type == 'hand' and not (G.STATE == G.STATES.TAROT_PACK or G.STATE == G.STATES.SPECTRAL_PACK or G.STATE == G.STATES.PLANET_PACK) then" -position = "at" -payload = "if self.config.type == 'hand' and not (G.STATE == G.STATES.TAROT_PACK or G.STATE == G.STATES.SPECTRAL_PACK or G.STATE == G.STATES.PLANET_PACK or G.STATE == G.STATES.SMODS_BOOSTER_OPENED) then" -match_indent = true - -# Card:can_use_consumable() -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = "if G.STATE == G.STATES.SELECTING_HAND or G.STATE == G.STATES.TAROT_PACK or G.STATE == G.STATES.SPECTRAL_PACK or G.STATE == G.STATES.PLANET_PACK then" -position = "at" -payload = "if G.STATE == G.STATES.SELECTING_HAND or G.STATE == G.STATES.TAROT_PACK or G.STATE == G.STATES.SPECTRAL_PACK or G.STATE == G.STATES.PLANET_PACK or G.STATE == G.STATES.SMODS_BOOSTER_OPENED then" -match_indent = true - -# G.FUNCS.use_card() -[[patches]] -[patches.pattern] -target = "functions/button_callbacks.lua" -pattern = "if G.STATE == G.STATES.TAROT_PACK or G.STATE == G.STATES.PLANET_PACK or G.STATE == G.STATES.SPECTRAL_PACK then" -position = "at" -payload = """ -if nc then - if area then area:remove_from_highlighted(card) end - play_sound('cardSlide2', nil, 0.3) - dont_dissolve = true -end -if (G.STATE == G.STATES.TAROT_PACK or G.STATE == G.STATES.PLANET_PACK or G.STATE == G.STATES.SPECTRAL_PACK or G.STATE == G.STATES.SMODS_BOOSTER_OPENED) then""" -match_indent = true - -# G.FUNC.use_card() -[[patches]] -[patches.pattern] -target = "functions/button_callbacks.lua" -pattern = 'if area == G.consumeables then' -position = 'before' -match_indent = true -payload = ''' -if nc and area == G.pack_cards then G.pack_cards:remove_card(card); G.consumeables:emplace(card) end''' - -# G.FUNC.use_card() -[[patches]] -[patches.pattern] -target = "functions/button_callbacks.lua" -pattern = "(G.STATE == G.STATES.BUFFOON_PACK and G.STATES.BUFFOON_PACK) or" -position = "before" -payload = "(G.STATE == G.STATES.SMODS_BOOSTER_OPENED and G.STATES.SMODS_BOOSTER_OPENED) or" -match_indent = true - -# G.FUNC.use_card() -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = "if not (G.STATE == G.STATES.TAROT_PACK or G.STATE == G.STATES.SPECTRAL_PACK) and" -position = "at" -payload = "if not (G.STATE == G.STATES.TAROT_PACK or G.STATE == G.STATES.SPECTRAL_PACK or G.STATE == G.STATES.SMODS_BOOSTER_OPENED) and" -match_indent = true - -# Card:use_consumeable() -[[patches]] -[patches.regex] -target = "card.lua" -pattern = '''(?[\t ]*)align = \(G\.STATE[\s\S]*and -0\.2 or 0},''' -position = "at" -payload = ''' -align = (G.STATE == G.STATES.TAROT_PACK or G.STATE == G.STATES.SPECTRAL_PACK or G.STATE == G.STATES.SMODS_BOOSTER_OPENED) and 'tm' or 'cm', -offset = {x = 0, y = (G.STATE == G.STATES.TAROT_PACK or G.STATE == G.STATES.SPECTRAL_PACK or G.STATE == G.STATES.SMODS_BOOSTER_OPENED) and -0.2 or 0},''' -line_prepend = '$indent' - -# G.FUNCS.use_card() -[[patches]] -[patches.pattern] -target = "functions/button_callbacks.lua" -pattern = "e.config.ref_table:redeem()" -position = "before" -payload = "if area == G.pack_cards then e.config.ref_table.cost = 0 end" -match_indent = true - -## Stopping ease_dollars anim from playing when voucher is free -# Card:redeem() -[[patches]] -[patches.regex] -target = "card.lua" -pattern = '''(?[\t ]*)ease_dollars\(-self\.cost\)\n[\s\S]{8}inc_career_stat\('c_shop_dollars_spent', self\.cost\)''' -position = "at" -payload = ''' -if self.cost ~= 0 then - ease_dollars(-self.cost) - inc_career_stat('c_shop_dollars_spent', self.cost) -end''' -line_prepend = '$indent' - -# Add support for saving consumables -# comment -[[patches]] -[patches.pattern] -target = 'functions/UI_definitions.lua' -match_indent = true -position = 'before' -pattern = ''' -if card.ability.consumeable then - if (card.area == G.pack_cards and G.pack_cards) then -''' -payload = ''' -if card.ability.consumeable and booster_obj and booster_obj.select_card then - if (card.area == G.pack_cards and G.pack_cards) then - return {n=G.UIT.ROOT, config = {padding = 0, colour = G.C.CLEAR}, nodes={ - {n=G.UIT.R, config={ref_table = card, r = 0.08, padding = 0.1, align = "bm", minw = 0.5*card.T.w - 0.15, maxw = 0.9*card.T.w - 0.15, minh = 0.3*card.T.h, hover = true, shadow = true, colour = G.C.UI.BACKGROUND_INACTIVE, one_press = true, button = 'use_card', func = 'can_select_from_booster'}, nodes={ - {n=G.UIT.T, config={text = localize('b_select'),colour = G.C.UI.TEXT_LIGHT, scale = 0.45, shadow = true}} - }}, - }} - end -end -''' - -# comment -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -match_indent = true -position = 'at' -pattern = ''' -if card.ability.consumeable then - if nc then -''' -payload = ''' -if booster_obj and booster_obj.select_card then - local area = type(booster_obj.select_card) == 'table' and (booster_obj.select_card[e.config.ref_table.ability.set] or nil) or booster_obj.select_card - G[area]:emplace(card) - play_sound('card1', 0.8, 0.6) - play_sound('generic1') - dont_dissolve = true - delay_fac = 0.2 -elseif card.ability.consumeable then - if nc then -''' -# comment -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -match_indent = true -position = 'before' -pattern = ''' -if area == G.consumeables then -''' -payload = ''' -booster_obj = nil -''' -# comment -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -match_indent = true -position = 'after' -pattern = ''' -G.FUNCS.skip_booster = function(e) -''' -payload = ''' -booster_obj = nil -''' diff --git a/smods-main/lovely/center.toml b/smods-main/lovely/center.toml deleted file mode 100644 index b92a26d..0000000 --- a/smods-main/lovely/center.toml +++ /dev/null @@ -1,552 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -### Center API - -# Card:set_ability() -[[patches]] -[patches.regex] -target = "card.lua" -pattern = "(?[\t ]*)if not G\\.OVERLAY_MENU then \n" -position = 'before' -payload = ''' -local obj = self.config.center -if obj.set_ability and type(obj.set_ability) == 'function' then - obj:set_ability(self, initial, delay_sprites) -end - -''' -line_prepend = '$indent' -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = "self.ability.bonus = (self.ability.bonus or 0) + (center.config.bonus or 0)" -position = "after" -payload = """ -for k, v in pairs(center.config) do - if k ~= 'bonus' then - if type(v) == 'table' then - self.ability[k] = copy_table(v) - else - self.ability[k] = v - end - end -end""" -match_indent = true - -# Card:calculate_joker() -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = '''function Card:calculate_joker(context) - if self.debuff then return nil end -''' -position = 'after' -payload = ''' - local obj = self.config.center - if self.ability.set ~= "Enhanced" and obj.calculate and type(obj.calculate) == 'function' then - local o, t = obj:calculate(self, context) - if o or t then return o, t end - end''' -match_indent = true - -# Card:update() -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = 'if G.STAGE == G.STAGES.RUN then' -position = 'before' -match_indent = true -payload = ''' -local obj = self.config.center -if obj.update and type(obj.update) == 'function' then - obj:update(self, dt) -end''' - -# Card:generate_UIBox_ability_table() -[[patches]] -[patches.regex] -target = 'card.lua' -pattern = "(?else)\n[\t ]*if self.ability.name == 'Loyalty Card' then\n[\t ]*self.ability.loyalty_remaining" -root_capture = 'else' -position = 'at' -payload = 'elseif context.joker_main then' - - -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = 'return generate_card_ui(self.config.center, nil, loc_vars, card_type, badges, hide_desc, main_start, main_end)' -position = 'at' -match_indent = true -payload = 'return generate_card_ui(self.config.center, nil, loc_vars, card_type, badges, hide_desc, main_start, main_end, self)' - -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -pattern = "full_UI_table.name = localize{type = 'name', set = _c.set, key = _c.key, nodes = full_UI_table.name}" -position = 'at' -match_indent = true -payload = ''' -if not _c.generate_ui or type(_c.generate_ui) ~= 'function' then - full_UI_table.name = localize{type = 'name', set = _c.set, key = _c.key, nodes = full_UI_table.name} -end''' - -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -pattern = "elseif specific_vars and specific_vars.debuffed then" -position = 'before' -match_indent = true -payload = ''' -elseif _c.generate_ui and type(_c.generate_ui) == 'function' then - _c:generate_ui(info_queue, card, desc_nodes, specific_vars, full_UI_table) - if specific_vars and specific_vars.pinned then info_queue[#info_queue+1] = {key = 'pinned_left', set = 'Other'} end - if specific_vars and specific_vars.sticker then info_queue[#info_queue+1] = {key = string.lower(specific_vars.sticker)..'_sticker', set = 'Other'} end''' - -[[patches]] -[patches.regex] -target = 'functions/common_events.lua' -pattern = "(?[\t ]+)if (?_c.name == 'Golden Ticket' then)" -line_prepend = '$indent' -position = 'at' -payload = ''' -local res = {} -if _c.locked_loc_vars and type(_c.locked_loc_vars) == 'function' then - local _card = _c.create_fake_card and _c:create_fake_card() - res = _c:locked_loc_vars(info_queue, _card) or {} - loc_vars = res.vars or {} - specific_vars = specific_vars or {} - specific_vars.not_hidden = res.not_hidden or specific_vars.not_hidden - if res.main_start then desc_nodes[#desc_nodes+1] = res.main_start end - main_end = res.main_end or main_end -elseif $rest''' - -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -position = 'at' -match_indent = true -pattern = "localize{type = 'unlocks', key = 'joker_locked_legendary', set = 'Other', nodes = desc_nodes, vars = loc_vars}" -payload = "localize{type = 'unlocks', key = res.key or 'joker_locked_legendary', set = res.set or 'Other', nodes = desc_nodes, vars = loc_vars, text_colour = res.text_colour, scale = res.scale}" - -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -position = 'at' -match_indent = true -pattern = "localize{type = 'unlocks', key = _c.key, set = _c.set, nodes = desc_nodes, vars = loc_vars}" -payload = "localize{type = 'unlocks', key = res.key or _c.key, set = res.set or _c.set, nodes = desc_nodes, vars = loc_vars, text_colour = res.text_colour, scale = res.scale}" - -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -position = 'at' -match_indent = true -pattern = 'elseif desc_nodes ~= full_UI_table.main then' -payload = 'elseif desc_nodes ~= full_UI_table.main and not desc_nodes.name then' - - - -# check_for_unlock() -[[patches]] -[patches.regex] -target = 'functions/common_events.lua' -pattern = "(?[\t ]*)if not card.unlocked and card.unlock_condition and args.type == 'career_stat' then" -line_prepend = '$indent' -position = 'before' -payload = ''' - -local custom_check -if not card.unlocked and card.check_for_unlock and type(card.check_for_unlock) == 'function' then - ret = card:check_for_unlock(args) - if ret then unlock_card(card) end - custom_check = true -end''' - -[[patches]] -[patches.regex] -target = 'functions/common_events.lua' -pattern = "(?[\t ]*)if(? )not card.unlocked and card.unlock_condition and args.type == 'career_stat' then" -position = 'at' -root_capture = 'a' -payload = ' not custom_check and ' - -[[patches]] -[patches.regex] -target = 'functions/common_events.lua' -pattern = "(?[\t ]*)if(? )not card.unlocked and card.unlock_condition and card.unlock_condition.type == args.type then" -position = 'at' -root_capture = 'a' -payload = ' not custom_check and ' - -#Card:use_consumable() -[[patches]] -[patches.regex] -target = 'card.lua' -pattern = "(?[\t ]*)if self.ability.consumeable.mod_conv or self.ability.consumeable.suit_conv then" -line_prepend = '$indent' -position = 'before' -payload = ''' -local obj = self.config.center -if obj.use and type(obj.use) == 'function' then - obj:use(self, area, copier) - return -end''' - -# Card:can_use_consumable() -[[patches]] -[patches.regex] -target = 'card.lua' -pattern = "(?[\t ]*)if self.ability.name == 'The Hermit' or self.ability.consumeable.hand_type" -line_prepend = '$indent' -position = 'before' -payload = ''' -local obj = self.config.center -if obj.can_use and type(obj.can_use) == 'function' then - return obj:can_use(self) -end''' - -# G.UIDEF.card_h_popup() -[[patches]] -[patches.regex] -target = 'functions/UI_definitions.lua' -pattern = "(?[\t ]*)(?if AUT.badges.card_type or AUT.badges.force_rarity then)\n[\t ]*(?.*)\n[\t ]*end" -line_prepend = '$indent' -position = 'at' -payload = ''' -local obj = card.config.center -$if - if obj and (obj.set_card_type_badge or obj.type and obj.type.set_card_type_badge) then - if obj.type and type(obj.type.set_card_type_badge) == 'function' then - obj.type:set_card_type_badge(obj, card, badges) - end - if type(obj.set_card_type_badge) == 'function' then - obj:set_card_type_badge(card, badges) - end - else - $rest - end -end -if obj and obj.set_badges and type(obj.set_badges) == 'function' then - obj:set_badges(card, badges) -end''' - -[[patches]] -[patches.regex] -target = 'functions/UI_definitions.lua' -pattern = "(?[\t ]*)if AUT.badges then\n([\t ]*.*\n){4}[\t ]*end" -line_prepend = '$indent' -position = 'after' -payload = ''' -if AUT.card_type ~= 'Locked' and AUT.card_type ~= 'Undiscovered' then - SMODS.create_mod_badges(card.config.center, badges) - if card.base then - SMODS.create_mod_badges(SMODS.Ranks[card.base.value], badges) - SMODS.create_mod_badges(SMODS.Suits[card.base.suit], badges) - end - if card.config and card.config.tag then - SMODS.create_mod_badges(SMODS.Tags[card.config.tag.key], badges) - end - badges.mod_set = nil -end''' - -# set_discover_tallies() -[[patches]] -[patches.regex] -target = 'functions/misc_functions.lua' -pattern = "(?[\t ]*)if v.set == 'Planet' then(\n[\t ]*.*){15}" -line_prepend = '$indent' -position = 'at' -payload = ''' -local tally = G.DISCOVER_TALLIES[v.set:lower()..'s'] -if tally then - tally.of = tally.of + 1 - if v.discovered then - tally.tally = tally.tally + 1 - end -end''' - -[[patches]] -[patches.regex] -target = 'functions/misc_functions.lua' -pattern = "[\t ]*tarots = \\{tally = 0, of = 0\\},\n(.*\n){2}" -line_prepend = '$indent' -position = 'at' -payload = '' - -[[patches]] -[patches.regex] -target = 'functions/misc_functions.lua' -pattern = "(?[\t ]*)for _, v in pairs\\(G.DISCOVER_TALLIES\\) do" -line_prepend = '$indent' -position = 'before' -payload = ''' -for _, v in ipairs(SMODS.ConsumableType.ctype_buffer) do - G.DISCOVER_TALLIES[v:lower()..'s'] = {tally = 0, of = 0} -end''' - -# create_UIBox_your_collection() -[[patches]] -[patches.regex] -target = 'functions/UI_definitions.lua' -pattern = "(?[\t ]*)local t = create_UIBox_generic_options\\(\\{ back_func = G.STAGE" -line_prepend = '$indent' -position = 'before' -payload = ''' -local consumable_nodes = {} -if #SMODS.ConsumableType.ctype_buffer <= 3 then - for _, key in ipairs(SMODS.ConsumableType.ctype_buffer) do - local id = 'your_collection_'..key:lower()..'s' - consumable_nodes[#consumable_nodes+1] = UIBox_button({button = id, label = {localize('b_'..key:lower()..'_cards')}, count = G.DISCOVER_TALLIES[key:lower()..'s'], minw = 4, id = id, colour = G.C.SECONDARY_SET[key]}) - end -else - consumable_nodes[#consumable_nodes+1] = UIBox_button({ button = 'your_collection_consumables', label = {localize('b_stat_consumables'), localize{ type = 'variable', key = 'c_types', vars = {#SMODS.ConsumableType.ctype_buffer} } }, count = G.DISCOVER_TALLIES['consumeables'], minw = 4, minh = 4, id = 'your_collection_consumables', colour = G.C.FILTER }) -end -''' - -[[patches]] -[patches.regex] -target = 'functions/UI_definitions.lua' -pattern = "(?[\t ]*)nodes=\\{\n[\t ]*UIBox_button\\(\\{button = 'your_collection_tarots'(.*\n){3}[\t ]*}" -line_prepend = '$indent' -position = 'at' -payload = 'nodes = consumable_nodes' - -# Card:apply_to_run() -[[patches]] -[patches.regex] -target = 'card.lua' -pattern = "(?[\t ]*)if center_table.name == 'Overstock'" -line_prepend = '$indent' -position = 'before' -payload = ''' -local obj = center or self.config.center -if obj.redeem and type(obj.redeem) == 'function' then - obj:redeem(card_to_save) - return -end''' - -# create_card_for_shop() -[[patches]] -[patches.pattern] -target = 'functions/UI_definitions.lua' -pattern = "local total_rate = G.GAME.joker_rate + G.GAME.tarot_rate + G.GAME.planet_rate + G.GAME.playing_card_rate + G.GAME.spectral_rate" -match_indent = true -position = 'at' -payload = ''' -local total_rate = G.GAME.joker_rate + G.GAME.playing_card_rate -for _,v in ipairs(SMODS.ConsumableType.ctype_buffer) do - total_rate = total_rate + G.GAME[v:lower()..'_rate'] -end''' - -[[patches]] -[patches.regex] -target = 'functions/UI_definitions.lua' -pattern = '(?[\t ]*)for _, v in ipairs\((?
  • \{\n(.*\n){5}[\t ]*\})\) do' -line_prepend = '$indent' -position = 'at' -payload = ''' --- need to preserve order to leave RNG unchanged -local rates = $li -for _, v in ipairs(SMODS.ConsumableType.ctype_buffer) do - if not (v == 'Tarot' or v == 'Planet' or v == 'Spectral') then - table.insert(rates, { type = v, val = G.GAME[v:lower()..'_rate'] }) - end -end -for _, v in ipairs(rates) do''' - -# create_card() -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -pattern = "if not forced_key and soulable and (not G.GAME.banned_keys['c_soul']) then" -match_indent = true -position = 'after' -payload = ''' - for _, v in ipairs(SMODS.Consumable.legendaries) do - if (_type == v.type.key or _type == v.soul_set) and not (G.GAME.used_jokers[v.key] and not next(find_joker("Showman")) and not v.can_repeat_soul) and (not v.in_pool or (type(v.in_pool) ~= "function") or v:in_pool()) then - if pseudorandom('soul_'..v.key.._type..G.GAME.round_resets.ante) > (1 - v.soul_rate) then - forced_key = v.key - end - end - end''' - -# Card:add_to_deck() -[[patches]] -[patches.regex] -target = 'card.lua' -pattern = '(?[\t ]*)if self.ability.h_size ~= 0 then\n[\t ]*G\.hand:change_size\(self.ability.h_size\)' -line_prepend = '$indent' -position = 'before' -payload = ''' -local obj = self.config.center -if obj and obj.add_to_deck and type(obj.add_to_deck) == 'function' then - obj:add_to_deck(self, from_debuff) -end''' - -# Card:remove_from_deck() -[[patches]] -[patches.regex] -target = 'card.lua' -pattern = '(?[\t ]*)if self.ability.h_size ~= 0 then\n[\t ]*G\.hand:change_size\(-self.ability.h_size\)' -line_prepend = '$indent' -position = 'before' -payload = ''' -local obj = self.config.center -if obj and obj.remove_from_deck and type(obj.remove_from_deck) == 'function' then - obj:remove_from_deck(self, from_debuff) -end''' - -# G.FUNCS.use_card() -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -pattern = "if card.area then card.area:remove_card(card) end" -match_indent = true -position = 'at' -payload = ''' -local nc -if card.ability.consumeable then - local obj = card.config.center - if obj.keep_on_use and type(obj.keep_on_use) == 'function' then - nc = obj:keep_on_use(card) - end -end -if card.area and (not nc or card.area == G.pack_cards) then card.area:remove_card(card) end''' - -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -pattern = "else draw_card(G.hand, G.play, 1, 'up', true, card, nil, mute) end" -match_indent = true -position = 'at' -payload = '''elseif not nc then draw_card(G.hand, G.play, 1, 'up', true, card, nil, mute) end''' - -# Card:set_sprites() -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = "if not self.children.back then" -match_indent = true -position = 'at' -payload = ''' -if _center.set_sprites and type(_center.set_sprites) == 'function' then - _center:set_sprites(self, _front) -end -if true then''' - -# Card:load() -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = 'if self.config.center.name == "Half Joker" then' -match_indent = true -position = 'at' -payload = ''' -local obj = self.config.center -if obj.load and type(obj.load) == 'function' then - obj:load(self, cardTable, other_card) -elseif self.config.center.name == "Half Joker" then''' - -# Card:calculate_dollar_bonus() -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = """function Card:calculate_dollar_bonus() - if self.debuff then return end""" -position = "after" -match_indent = true -payload = ''' - local obj = self.config.center - if obj.calc_dollar_bonus and type(obj.calc_dollar_bonus) == 'function' then - return obj:calc_dollar_bonus(self) - end -''' - -# Card:draw() -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = '--If the card has any edition/seal, add that here' -position = 'before' -match_indent = true -payload = ''' -local center = self.config.center -if center.draw and type(center.draw) == 'function' then - center:draw(self, layer) -end -if center.set == 'Default' or center.set == 'Enhanced' and not center.replace_base_card then - if not center.no_suit then - local suit = SMODS.Suits[self.base.suit] or {} - if suit.draw and type(suit.draw) == 'function' then - suit:draw(self, layer) - end - end - if not center.no_rank then - local rank = SMODS.Ranks[self.base.value] or {} - if rank.draw and type(rank.draw) == 'function' then - rank:draw(self, layer) - end - end -end -''' - -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = 'if self.seal then' -position = 'at' -match_indent = true -payload = ''' -local seal = G.P_SEALS[self.seal or {}] or {} -if type(seal.draw) == 'function' then - seal:draw(self, layer) -elseif self.seal then -''' - -# no_blueprint check -[[patches]] -[patches.pattern] -target = 'card.lua' -match_indent = true -position = 'at' -pattern = 'if other_joker and other_joker ~= self then' -payload = 'if other_joker and other_joker ~= self and not context.no_blueprint then' - -# extract joker loc_vars -[[patches]] -[patches.pattern] -target = 'card.lua' -match_indent = true -position = 'at' -pattern = 'function Card:generate_UIBox_ability_table()' -payload = 'function Card:generate_UIBox_ability_table(vars_only)' - -[[patches]] -[patches.pattern] -target = 'card.lua' -match_indent = true -position = 'before' -pattern = 'local badges = {}' -payload = 'if vars_only then return loc_vars, main_start, main_end end' - -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -match_indent = true -position = 'after' -pattern = "elseif _c.set == 'Joker' then" -payload = ''' - if not card then - local ability = copy_table(_c.config) - ability.set = 'Joker' - ability.name = _c.name - local ret = {Card.generate_UIBox_ability_table({ ability = ability, config = { center = _c }, bypass_lock = true}, true)} - specific_vars = ret[1] - if ret[2] then desc_nodes[#desc_nodes+1] = ret[2] end - main_end = ret[3] - end - ''' \ No newline at end of file diff --git a/smods-main/lovely/challenge.toml b/smods-main/lovely/challenge.toml deleted file mode 100644 index 0db9203..0000000 --- a/smods-main/lovely/challenge.toml +++ /dev/null @@ -1,21 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -5 - -# function G.UIDEF.challenge_list_page() -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = "local challenge_unlocked = G.PROFILES[G.SETTINGS.profile].challenges_unlocked and (G.PROFILES[G.SETTINGS.profile].challenges_unlocked >= k)" -position = 'after' -payload = """ -if v.unlocked and type(v.unlocked) == 'function' then - challenge_unlocked = v:unlocked() -elseif type(v.unlocked) == 'boolean' then - challenge_unlocked = v.unlocked -end -challenge_unlocked = challenge_unlocked or G.PROFILES[G.SETTINGS.profile].all_unlocked - -""" -match_indent = true diff --git a/smods-main/lovely/compact_cashout.toml b/smods-main/lovely/compact_cashout.toml deleted file mode 100644 index 98676f3..0000000 --- a/smods-main/lovely/compact_cashout.toml +++ /dev/null @@ -1,65 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -5 - - -# -# End of round money -# - -# Hide off screen rows - -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = "if config.name ~= 'bottom' then" -position = "after" -payload = ''' - total_cashout_rows = (total_cashout_rows or 0) + 1 - if total_cashout_rows > 7 then - return - end''' -match_indent = true - -# Reset rows amount - -[[patches]] -[patches.regex] -target = "functions/state_events.lua" -pattern = 'G\.FUNCS\.evaluate_round = function\(\)' -position = "after" -payload = ''' - - total_cashout_rows = 0''' - -# Add UI row with total rows hidden - -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = "add_round_eval_row({name = 'bottom', dollars = dollars})" -position = "before" -payload = ''' -if total_cashout_rows > 7 then - local total_hidden = total_cashout_rows - 7 - - G.E_MANAGER:add_event(Event({ - trigger = 'before',delay = 0.38, - func = function() - local hidden = {n=G.UIT.R, config={align = "cm"}, nodes={ - {n=G.UIT.O, config={object = DynaText({ - string = {localize{type = 'variable', key = 'cashout_hidden', vars = {total_hidden}}}, - colours = {G.C.WHITE}, shadow = true, float = false, - scale = 0.45, - font = G.LANGUAGES['en-us'].font, pop_in = 0 - })}} - }} - - G.round_eval:add_child(hidden, G.round_eval:get_UIE_by_ID('bonus_round_eval')) - return true - end - })) -end''' -match_indent = true - diff --git a/smods-main/lovely/compat_0_9_8.toml b/smods-main/lovely/compat_0_9_8.toml deleted file mode 100644 index a61c552..0000000 --- a/smods-main/lovely/compat_0_9_8.toml +++ /dev/null @@ -1,38 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -5 - -# fallback for card.ability.name -# Card:set_ability() -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = "self.ability.bonus = (self.ability.bonus or 0) + (center.config.bonus or 0)" -position = 'after' -payload = "if not self.ability.name then self.ability.name = center.key end" -match_indent = true - -# generate_card_ui() -# `card_type` is used to check whether card should be nil; non-recursive calls -# to generate_card_ui always have that arg set -[[patches]] -[patches.regex] -target = "functions/common_events.lua" -pattern = '(?[\t ]*)function generate_card_ui\([^)]*\)\n' -position = "after" -line_prepend = '$indent' -payload = """ - if card == nil and card_type then - card = SMODS.compat_0_9_8.generate_UIBox_ability_table_card - end - -""" -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = "for _, v in ipairs(info_queue) do" -position = 'before' -payload = "SMODS.compat_0_9_8.generate_UIBox_ability_table_card = nil" -match_indent = true - diff --git a/smods-main/lovely/core.toml b/smods-main/lovely/core.toml deleted file mode 100644 index 899b0cc..0000000 --- a/smods-main/lovely/core.toml +++ /dev/null @@ -1,24 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -5 - -[[patches]] -[patches.pattern] -target = "game.lua" -pattern = "self.SPEEDFACTOR = 1" -position = "after" -payload = "initSteamodded()" -match_indent = true - -[[patches]] -[patches.copy] -target = "main.lua" -position = "append" -sources = ["src/core.lua"] - -[[patches]] -[patches.module] -before = "main.lua" -source = "version.lua" -name = "SMODS.version" diff --git a/smods-main/lovely/crash_handler.toml b/smods-main/lovely/crash_handler.toml deleted file mode 100644 index cd590af..0000000 --- a/smods-main/lovely/crash_handler.toml +++ /dev/null @@ -1,20 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -[[patches]] -[patches.pattern] -target = "main.lua" -pattern = "function love.errhand(msg)" -position = "at" -payload = "if false then" -match_indent = true - -[[patches]] -[patches.copy] -target = "main.lua" -position = "prepend" -sources = [ - "src/crash_handler.lua", -] diff --git a/smods-main/lovely/deck_skins.toml b/smods-main/lovely/deck_skins.toml deleted file mode 100644 index c4e5c9f..0000000 --- a/smods-main/lovely/deck_skins.toml +++ /dev/null @@ -1,218 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -#========================================================# -# Choose any rank for custom deck and use provided atlas # -#========================================================# -[[patches]] -[patches.regex] -target = "functions/misc_functions.lua" -pattern = '''if _front and _front.suit and \(_front.value == 'Jack' or _front.value == 'Queen' or _front.value == 'King'\) then([\s\S]*?)end([\s\S]*?)end([\s\S]*?)end''' -position = "at" -payload = ''' -if _front and _front.suit and G.SETTINGS.CUSTOM_DECK and G.SETTINGS.CUSTOM_DECK.Collabs then - local collab = G.SETTINGS.CUSTOM_DECK.Collabs[_front.suit] - if collab then - local deckSkin = SMODS.DeckSkins[collab] - if deckSkin then - if deckSkin.outdated then - local hasRank = false - for i = 1, #deckSkin.ranks do - if deckSkin.ranks[i] == _front.value then hasRank = true break end - end - if hasRank then - local atlas = G.ASSET_ATLAS[G.SETTINGS.colour_palettes[_front.suit] == 'hc' and deckSkin.hc_atlas or deckSkin.lc_atlas] - if atlas then - if deckSkin.pos_style == 'collab' then - return atlas, G.COLLABS.pos[_front.value] - elseif deckSkin.pos_style == 'suit' then - return atlas, { x = _front.pos.x, y = 0} - elseif deckSkin.pos_style == 'deck' then - return atlas, _front.pos - elseif deckSkin.pos_style == 'ranks' or nil then - for i, rank in ipairs(deckSkin.ranks) do - if rank == _front.value then - return atlas, { x = i - 1, y = 0} - end - end - end - end - end - return G.ASSET_ATLAS[G.SETTINGS.colour_palettes[_front.suit] == 'hc' and _front.hc_atlas or _front.lc_atlas or {}] or G.ASSET_ATLAS[_front.atlas] or G.ASSET_ATLAS["cards_"..(G.SETTINGS.colour_palettes[_front.suit] == 'hc' and 2 or 1)], _front.pos - else - local palette = deckSkin.palette_map and deckSkin.palette_map[G.SETTINGS.colour_palettes[_front.suit] or ''] or (deckSkin.palettes or {})[1] - local hasRank = false - for i = 1, #palette.ranks do - if palette.ranks[i] == _front.value then hasRank = true break end - end - if hasRank then - local atlas = G.ASSET_ATLAS[palette.atlas] - if type(palette.pos_style) == "table" then - if palette.pos_style[_front.value] then - if palette.pos_style[_front.value].atlas then - atlas = G.ASSET_ATLAS[palette.pos_style[_front.value].atlas] - end - if palette.pos_style[_front.value].pos then - return atlas, palette.pos_style[_front.value].pos - end - elseif palette.pos_style.fallback_style then - if palette.pos_style.fallback_style == 'collab' then - return atlas, G.COLLABS.pos[_front.value] - elseif palette.pos_style.fallback_style == 'suit' then - return atlas, { x = _front.pos.x, y = 0} - elseif palette.pos_style.fallback_style == 'deck' then - return atlas, _front.pos - end - end - elseif palette.pos_style == 'collab' then - return atlas, G.COLLABS.pos[_front.value] - elseif palette.pos_style == 'suit' then - return atlas, { x = _front.pos.x, y = 0} - elseif palette.pos_style == 'deck' then - return atlas, _front.pos - elseif palette.pos_style == 'ranks' or nil then - for i, rank in ipairs(palette.ranks) do - if rank == _front.value then - return atlas, { x = i - 1, y = 0} - end - end - end - end - return G.ASSET_ATLAS[palette.hc_default and _front.hc_atlas or _front.lc_atlas or {}] or G.ASSET_ATLAS[_front.atlas] or G.ASSET_ATLAS["cards_"..(palette.hc_default and 2 or 1)], _front.pos - end - end - end -end -''' - -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = "{n=G.UIT.O, config={object = face_cards}}" -position = "at" -payload = "{n=G.UIT.O, config={object = G.cdds_cards}}" -match_indent = true -overwrite = false - -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = "table.insert(t, create_toggle({label = localize('b_high_contrast_cards'), ref_table = G.SETTINGS, ref_value = 'colourblind_option', callback = G.FUNCS.refresh_contrast_mode}))" -position = "at" -payload = ''' -local deckskin_key = G.COLLABS.options[_suit][current_option] - -local palette_loc_options = SMODS.DeckSkin.get_palette_loc_options(deckskin_key, _suit) - -local selected_palette = 1 -for i, v in ipairs(G.COLLABS.colour_palettes[deckskin_key]) do - if G.SETTINGS.colour_palettes[_suit] == v then - selected_palette = i - end -end - -table.insert(t, - {n=G.UIT.R, config={align = "cm", id = 'palette_selector'}, nodes={ - create_option_cycle({options = palette_loc_options, w = 5.5, cycle_shoulders = false, curr_suit = _suit, curr_skin = deckskin_key, opt_callback = 'change_colour_palette', current_option = selected_palette, colour = G.C.ORANGE, focus_args = {snap_to = true, nav = 'wide'}}), - }} - ) -''' -match_indent = true -overwrite = false - -#=======================# -# Extend custom deck ui # -#=======================# -[[patches]] -[patches.regex] -target = "functions/UI_definitions.lua" -pattern = '''local face_cards = CardArea\(([\s\S]*?)\)''' -position = "at" -payload = ''' -local rankCount = 0 -local lookup = {} -for i, s in ipairs(SMODS.Suit:obj_list(true)) do - local options = G.COLLABS.options[s.key] - for i = 1, #options do - local skin = SMODS.DeckSkins[options[i]] - if skin.palettes and not (skin.display_ranks or skin.ranks) then - for _, p in ipairs(skin.palettes) do - local p_ranks = p.display_ranks or p.ranks - for j = 1, #p_ranks do - if not lookup[p_ranks[j]] then - lookup[p_ranks[j]] = true - rankCount = rankCount + 1 - end - end - end - elseif not skin.palettes and (skin.display_ranks or skin.ranks) then - local ranks = skin.display_ranks or skin.ranks - for j = 1, #ranks do - if not lookup[skin.ranks[j]] then - lookup[skin.ranks[j]] = true - rankCount = rankCount + 1 - end - end - end - - end -end - -G.cdds_cards = CardArea( - 0,0, - math.min(math.max(rankCount*G.CARD_W*0.6, 4*G.CARD_W), 10*G.CARD_W), - 1.4*G.CARD_H, - {card_limit = rankCount, type = 'title', highlight_limit = 0}) - -G.cdds_cards.rankCount = rankCount - -''' - -[[patches]] -[patches.regex] -target = "functions/UI_definitions.lua" -pattern = '''for i = 1, 3 do([\s\S]*?)end''' -position = "at" -payload = ''' -G.FUNCS.update_collab_cards(current_option, _suit, true) -''' - -[[patches]] -[patches.regex] -target = "functions/UI_definitions.lua" -pattern = '''function create_UIBox_customize_deck()([\s\S]*?)end''' -position = "at" -payload = ''' -function create_UIBox_customize_deck() - local suitTabs = {} - - local index = 1 - for i, suit in ipairs(SMODS.Suit:obj_list(true)) do - if G.COLLABS.options[suit.key] then - suitTabs[index] = { - label = localize(suit.key, 'suits_plural'), - tab_definition_function = G.UIDEF.custom_deck_tab, - tab_definition_function_args = suit.key - } - index = index + 1 - end - end - - if suitTabs[1] then - suitTabs[1].chosen = true - end - - local t = create_UIBox_generic_options({ back_func = 'options', snap_back = nil, contents = { - {n=G.UIT.R, config={align = "cm", padding = 0}, nodes={ - create_tabs( - {tabs = suitTabs, snap_to_nav = true, no_shoulders = true} - )}}} - }) - - return t -end -''' - - diff --git a/smods-main/lovely/dollar_row.toml b/smods-main/lovely/dollar_row.toml deleted file mode 100644 index 4acb541..0000000 --- a/smods-main/lovely/dollar_row.toml +++ /dev/null @@ -1,77 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -### Dollar row patches (API removed) - - -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = "if num_dollars > 60 then" -position = "at" -payload = ''' -if num_dollars > 60 or num_dollars < -60 then''' -match_indent = true - -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = "local dollar_string = localize('$')..num_dollars" -position = "at" -payload = ''' -if num_dollars < 0 then --if negative - G.E_MANAGER:add_event(Event({ - trigger = 'before',delay = 0.38, - func = function() - G.round_eval:add_child( - {n=G.UIT.R, config={align = "cm", id = 'dollar_row_'..(dollar_row+1)..'_'..config.name}, nodes={ - {n=G.UIT.O, config={object = DynaText({string = {'-'..localize('$')..format_ui_value(-num_dollars)}, colours = {G.C.MONEY}, shadow = true, pop_in = 0, scale = 0.65, float = true})}} - }}, - G.round_eval:get_UIE_by_ID('dollar_'..config.name)) - play_sound('coin3', 0.9+0.2*math.random(), 0.7) - play_sound('coin6', 1.3, 0.8) - return true - end - })) -else --if positive -''' -match_indent = true - -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = "for i = 1, num_dollars or 1 do" -position = "at" -payload = ''' -local dollars_to_loop -if num_dollars < 0 then dollars_to_loop = (num_dollars*-1)+1 else dollars_to_loop = num_dollars end -for i = 1, dollars_to_loop do''' -match_indent = true - -[[patches]] -[patches.regex] -target = "functions/common_events.lua" -pattern = '''(?[\t ]*)else\n[\t ]*local dollars_to_loop''' -position = "before" -line_prepend = "$indent" -payload = ''' ---asdf -end''' - -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = "local r = {n=G.UIT.T, config={text = localize('$'), colour = G.C.MONEY, scale = ((num_dollars > 20 and 0.28) or (num_dollars > 9 and 0.43) or 0.58), shadow = true, hover = true, can_collide = false, juice = true}}" -position = "at" -payload = ''' -local r -if i == 1 and num_dollars < 0 then - r = {n=G.UIT.T, config={text = '-', colour = G.C.RED, scale = ((num_dollars < -20 and 0.28) or (num_dollars < -9 and 0.43) or 0.58), shadow = true, hover = true, can_collide = false, juice = true}} - play_sound('coin3', 0.9+0.2*math.random(), 0.7 - (num_dollars < -20 and 0.2 or 0)) -else - if num_dollars < 0 then r = {n=G.UIT.T, config={text = localize('$'), colour = G.C.RED, scale = ((num_dollars > 20 and 0.28) or (num_dollars > 9 and 0.43) or 0.58), shadow = true, hover = true, can_collide = false, juice = true}} - else r = {n=G.UIT.T, config={text = localize('$'), colour = G.C.MONEY, scale = ((num_dollars > 20 and 0.28) or (num_dollars > 9 and 0.43) or 0.58), shadow = true, hover = true, can_collide = false, juice = true}} end -end''' -match_indent = true diff --git a/smods-main/lovely/edition.toml b/smods-main/lovely/edition.toml deleted file mode 100644 index ccf477c..0000000 --- a/smods-main/lovely/edition.toml +++ /dev/null @@ -1,390 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -# Fix debug mode edition cycling -[[patches]] -[patches.regex] -target = "engine/controller.lua" -pattern = ''' -(?[\t ]*)local _edition = \{ -[\t ]*foil = not _card\.edition, -[\t ]*holo = _card\.edition and _card\.edition\.foil, -[\t ]*polychrome = _card\.edition and _card\.edition\.holo, -[\t ]*negative = _card\.edition and _card\.edition\.polychrome, -[\t ]*\}''' -position = "at" -payload = ''' -local found_index = 1 -if _card.edition then - for i, v in ipairs(G.P_CENTER_POOLS.Edition) do - if v.key == _card.edition.key then - found_index = i - break - end - end -end -found_index = found_index + 1 -if found_index > #G.P_CENTER_POOLS.Edition then found_index = found_index - #G.P_CENTER_POOLS.Edition end -local _edition = G.P_CENTER_POOLS.Edition[found_index].key''' -line_prepend = "$indent" - - -# Sort P_CENTER_POOLS["Editions"] -[[patches]] -[patches.pattern] -target = 'game.lua' -pattern = 'table.sort(self.P_CENTER_POOLS["Enhanced"], function (a, b) return a.order < b.order end)' -position = 'after' -payload = 'table.sort(self.P_CENTER_POOLS["Edition"], function (a, b) return a.order < b.order end)' -match_indent = true - - -# generate_card_ui() -# Adds tooltips for all editions -[[patches]] -[patches.regex] -target = 'functions/common_events.lua' -pattern = ''' -(?[\t ]*)if v == 'foil' then info_queue\[#info_queue\+1\] = G\.P_CENTERS\['e_foil'\] end -[\t ]*if v == 'holographic' then info_queue\[#info_queue\+1\] = G\.P_CENTERS\['e_holo'\] end -[\t ]*if v == 'polychrome' then info_queue\[#info_queue\+1\] = G\.P_CENTERS\['e_polychrome'\] end -[\t ]*if v == 'negative' then info_queue\[#info_queue\+1\] = G\.P_CENTERS\['e_negative'\] end -[\t ]*if v == 'negative_consumable' then info_queue\[#info_queue\+1\] = \{key = 'e_negative_consumable', set = 'Edition', config = \{extra = 1\}\} end''' -position = 'at' -payload = ''' -v = (v == 'holographic' and 'holo' or v) -if v:sub(1,9) == 'negative_' then - info_queue[#info_queue+1] = {key = 'e_'..v, set = 'Edition', config = {extra = G.P_CENTERS['e_negative'].config.card_limit}} -end -if G.P_CENTERS[v] and G.P_CENTERS[v].set == 'Edition' then - info_queue[#info_queue + 1] = G.P_CENTERS[v] -end -if G.P_CENTERS['e_'..v] and G.P_CENTERS['e_'..v].set == 'Edition' then - local t = {key = 'e_'..v, set = 'Edition', config = {}} - info_queue[#info_queue + 1] = t - if G.P_CENTERS['e_'..v].loc_vars and type(G.P_CENTERS['e_'..v].loc_vars) == 'function' then - local res = G.P_CENTERS['e_'..v]:loc_vars(info_queue, card) or {} - t.vars = res.vars - t.key = res.key or t.key - t.set = res.set or t.set - end -end''' -line_prepend = "$indent" -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -pattern = '''localize{type = 'descriptions', key = _c.key, set = _c.set, nodes = desc_nodes, vars = loc_vars}''' -position = 'at' -match_indent = true -payload = '''localize{type = 'descriptions', key = _c.key, set = _c.set, nodes = desc_nodes, vars = _c.vars or loc_vars}''' - - -# get_badge_colour() -[[patches]] -[patches.pattern] -target = 'functions/UI_definitions.lua' -pattern = 'return G.BADGE_COL[key] or {1, 0, 0, 1}' -position = 'before' -match_indent = true -payload = ''' -for _, v in ipairs(G.P_CENTER_POOLS.Edition) do - G.BADGE_COL[v.key:sub(3)] = v.badge_colour -end''' - -# Limit ARGS.send_to_shader[1] to wiggle between 0 and 2 instead of growing infinitely -# this makes shaders responsiveness on tilt reliable over time -# Card:draw() -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -G\.TIMERS\.REAL/\(28\)''' -position = "at" -payload = '''math.sin(G.TIMERS.REAL/28) + 1''' - -# Allow editions to not draw shadow -# Card:draw() -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -self\.ability\.effect ~= 'Glass Card' and not self\.greyed''' -position = "after" -payload = ''' and self:should_draw_shadow() ''' - -# If shader modifies shape of card, this will stop "back" layer of the card being rendered. -# Card:draw() -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = ''' -elseif not self.greyed then''' -position = "before" -payload = ''' -elseif not self:should_draw_base_shader() then - -- Don't render base dissolve shader. -''' -match_indent = true - -# If shader modifies shape of card, this will stop "back" layer of the card being rendered. -# spectral cards and booster packs only. -# Card:draw() -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = ''' -if self.ability.set == 'Booster' or self.ability.set == 'Spectral' then''' -position = "at" -payload = ''' -if (self.ability.set == 'Booster' or self.ability.set == 'Spectral') and self:should_draw_base_shader() then''' -match_indent = true - -# If shader modifies shape of card, this will stop "back" layer of the card being rendered. -# invisible joker and vouchers. -# Card:draw() -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = ''' -self.children.center:draw_shader('voucher', nil, self.ARGS.send_to_shader)''' -position = "at" -payload = ''' -if self:should_draw_base_shader() then - self.children.center:draw_shader('voucher', nil, self.ARGS.send_to_shader) -end''' -match_indent = true - -# Inject shaders applying to cards -# Card:draw() -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -(?[\t ]*)if self\.edition and self\.editi[A-z\.\:\n\t _(',)~=]*me', nil, self.ARGS.send_to_shader\) -[\t ]*end -[\t ]*end''' -position = "at" -payload = ''' -if self.edition then - for k, v in pairs(G.P_CENTER_POOLS.Edition) do - if self.edition[v.key:sub(3)] and v.shader then - if type(v.draw) == 'function' then - v:draw(self, layer) - else - self.children.center:draw_shader(v.shader, nil, self.ARGS.send_to_shader) - if self.children.front and self.ability.effect ~= 'Stone Card' and not self.config.center.replace_base_card then - self.children.front:draw_shader(v.shader, nil, self.ARGS.send_to_shader) - end - end - end - end -end''' -line_prepend = "$indent" - -# Inject shaders applying to floating sprites -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = "self.children.floating_sprite:draw_shader('dissolve', nil, nil, nil, self.children.center, scale_mod, rotate_mod)" -position = "after" -payload = ''' -if self.edition then - for k, v in pairs(G.P_CENTER_POOLS.Edition) do - if v.apply_to_float then - if self.edition[v.key:sub(3)] then - self.children.floating_sprite:draw_shader(v.shader, nil, nil, nil, self.children.center, scale_mod, rotate_mod) - end - end - end -end''' -match_indent = true - -# Remove prefix from shader key when calling send() -[[patches]] -[patches.pattern] -target = "engine/sprite.lua" -pattern = "if _send then G.SHADERS[_shader or 'dissolve']:send(_shader,_send) end" -position = "at" -payload = ''' -if _send then - G.SHADERS[_shader or 'dissolve']:send((SMODS.Shaders[_shader or 'dissolve'] and SMODS.Shaders[_shader or 'dissolve'].original_key) or _shader,_send) -end''' -match_indent = true - -# Inject change to edition cost in shop -[[patches]] -[patches.regex] -target = "card.lua" -pattern = '(?[\t ]*)self.ex([a-z._\s=+(0-9)]*)\n([\t ]*)([a-z._\s=+(0-9)]*)or 0\)' -position = "at" -payload = ''' -for k, v in pairs(G.P_CENTER_POOLS.Edition) do - if self.edition[v.key:sub(3)] then - if v.extra_cost then - self.extra_cost = self.extra_cost + v.extra_cost - end - end -end''' -line_prepend = "$indent" - -## Fix card_limit logic -# Card:add_to_deck() -[[patches]] -[patches.regex] -target = "card.lua" -pattern = '''(?[\t ]*)if self\.edition[A-z\.\:\n\t _(',)~=+\-0-9]*limit \+ 1''' -position = "at" -payload = ''' -if true then - if from_debuff then - self.ability.joker_added_to_deck_but_debuffed = nil - else - if self.edition and self.edition.card_limit then - if self.ability.consumeable then - G.consumeables.config.card_limit = G.consumeables.config.card_limit + self.edition.card_limit - else - G.jokers.config.card_limit = G.jokers.config.card_limit + self.edition.card_limit - end''' -line_prepend = "$indent" -# Card:remove_from_deck() -[[patches]] -[patches.regex] -target = "card.lua" -pattern = '''(?[\t ]*)if self\.edition[A-z\.\:\n\t _(',)~=+\-0-9]*limit \- 1''' -position = "at" -payload = ''' -if G.jokers then - if from_debuff then - self.ability.joker_added_to_deck_but_debuffed = true - else - if self.edition and self.edition.card_limit then - if self.ability.consumeable then - G.consumeables.config.card_limit = G.consumeables.config.card_limit - self.edition.card_limit - elseif self.ability.set == 'Joker' then - G.jokers.config.card_limit = G.jokers.config.card_limit - self.edition.card_limit - end''' -line_prepend = "$indent" -# Card:remove() -[[patches]] -[patches.regex] -target = "card.lua" -pattern = '''(?[\t ]*)if self\.ability\.queue_neg[A-z\.\:\n\t _(',)~=+\-0-9]*limit \- 1''' -position = "at" -payload = ''' -if self.ability.joker_added_to_deck_but_debuffed then - if self.edition and self.edition.card_limit then - if self.ability.consumeable then - G.consumeables.config.card_limit = G.consumeables.config.card_limit - self.edition.card_limit - elseif self.ability.set == 'Joker' then - G.jokers.config.card_limit = G.jokers.config.card_limit - self.edition.card_limit - end''' -line_prepend = "$indent" -# Card:save() -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = "added_to_deck = self.added_to_deck," -position = "after" -payload = "joker_added_to_deck_but_debuffed = self.joker_added_to_deck_but_debuffed," -match_indent = true - - - -## Negative playing card logic -# CardArea:emplace() -[[patches]] -[patches.pattern] -target = "cardarea.lua" -pattern = "function CardArea:emplace(*" -position = "after" -payload = ''' - if card.edition and card.edition.card_limit and (self == G.hand) then - self.config.real_card_limit = (self.config.real_card_limit or self.config.card_limit) + card.edition.card_limit - self.config.card_limit = math.max(0, self.config.real_card_limit) - end''' -match_indent = true -# CardArea:remove_card() -[[patches]] -[patches.pattern] -target = "cardarea.lua" -pattern = "card:remove_from_area()" -position = "before" -payload = ''' -if card.edition and card.edition.card_limit and (self == G.hand) then - self.config.real_card_limit = (self.config.real_card_limit or self.config.card_limit) - card.edition.card_limit - self.config.card_limit = math.max(0, self.config.real_card_limit) -end''' -match_indent = true - -# G.FUNCS.draw_from_deck_to_hand() -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = "local hand_space = e or*" -position = "at" -payload = """local hand_space = e -if not hand_space then - local limit = G.hand.config.card_limit - #G.hand.cards - local n = 0 - while n < #G.deck.cards do - local card = G.deck.cards[#G.deck.cards-n] - limit = limit - 1 + (card.edition and card.edition.card_limit or 0) - if limit < 0 then break end - n = n + 1 - end - hand_space = n -end""" -match_indent = true - -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = "badges[#badges + 1] = 'negative_consumable'" -position = "after" -payload = """ -elseif self.edition.type == 'negative' and (self.ability.set == 'Enhanced' or self.ability.set == 'Default') then - badges[#badges + 1] = 'negative_playing_card'""" -match_indent = true - -[[patches]] -[patches.pattern] -target = "engine/sprite.lua" -pattern = "love.graphics.setShader( G.SHADERS[_shader or 'dissolve'], G.SHADERS[_shader or 'dissolve'])" -position = "before" -payload = ''' -local p_shader = SMODS.Shader.obj_table[_shader or 'dissolve'] -if p_shader and type(p_shader.send_vars) == "function" then - local sh = G.SHADERS[_shader or 'dissolve'] - local parent_card = self.role.major and self.role.major:is(Card) and self.role.major - local send_vars = p_shader.send_vars(self, parent_card) - - if type(send_vars) == "table" then - for key, value in pairs(send_vars) do - sh:send(key, value) - end - end -end -''' -match_indent = true - -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = "if v == 'negative_consumable' then v = 'negative' end" -position = "at" -payload = '''if v == 'negative_consumable' or v == 'negative_playing_card' then v = 'negative' end''' -match_indent = true - -# -[[patches]] -[patches.regex] -target = 'functions/common_events.lua' -pattern = '''(?[\t ]*)(?local edition = poll_edition\('edi'\.\.\(key_append or ''\)\.\.G\.GAME\.round_resets\.ante\)(\n.*){2})''' -position = 'at' -line_prepend = '$indent' -payload = ''' -if not SMODS.bypass_create_card_edition then - $edi -end''' diff --git a/smods-main/lovely/enhancement.toml b/smods-main/lovely/enhancement.toml deleted file mode 100644 index ce5e769..0000000 --- a/smods-main/lovely/enhancement.toml +++ /dev/null @@ -1,269 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -## no_rank, no_suit, all_suits - -# Card:get_id() -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = "if self.ability.effect == 'Stone Card' and not self.vampired then" -match_indent = true -position = "at" -payload = '''if SMODS.has_no_rank(self) and not self.vampired then''' - -# Card:get_chip_bonus() -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -(?[\t ]*)if self\.ability\.effect == 'Stone Card' then -[\t ]* return self\.ability\.bonus \+ \(self\.ability\.perma_bonus or 0\) -[\t ]*end''' -position = "at" -payload = ''' -if self.ability.effect == 'Stone Card' or self.config.center.replace_base_card then - return self.ability.bonus + (self.ability.perma_bonus or 0) -end''' -line_prepend = '$indent' - -# Card:calculate_joker() -# Raised Fist -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = "if temp_ID >= G.hand.cards[i].base.id and G.hand.cards[i].ability.effect ~= 'Stone Card' then temp_Mult = G.hand.cards[i].base.nominal; temp_ID = G.hand.cards[i].base.id; raised_card = G.hand.cards[i] end" -match_indent = true -position = "at" -payload = """if temp_ID >= G.hand.cards[i].base.id and not SMODS.has_no_rank(G.hand.cards[i]) then - temp_Mult = G.hand.cards[i].base.nominal - temp_ID = G.hand.cards[i].base.id - raised_card = G.hand.cards[i] -end""" -# Flower Pot, Seeing Double -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = "if context.scoring_hand[i].ability.name ~= 'Wild Card' then" -match_indent = true -position = "at" -payload = '''if not SMODS.has_any_suit(context.scoring_hand[i]) then''' - -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = "if context.scoring_hand[i].ability.name == 'Wild Card' then" -match_indent = true -position = "at" -payload = '''if SMODS.has_any_suit(context.scoring_hand[i]) then''' - -# Card:get_suit() -[[patches]] -[patches.regex] -target = "card.lua" -pattern = '''(?[\t ]*)if self\.ability\.effect == 'Stone Card' then''' -line_prepend = '$indent' -position = "at" -payload = '''if SMODS.has_no_suit(self) then''' -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = 'if self.ability.name == "Wild Card" then' -match_indent = true -position = "at" -payload = '''if SMODS.has_any_suit(self) then''' -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = 'if self.ability.name == "Wild Card" and not self.debuff then' -match_indent = true -position = "at" -payload = '''if SMODS.has_any_suit(self) and not self.debuff then''' - -# check_for_unlock -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = "if v.ability.name ~= 'Stone Card' and v.base.suit == 'Hearts' then" -match_indent = true -position = "at" -payload = "if not SMODS.has_no_suit(v) and v.base.suit == 'Hearts' then" - -# reset_idol_card() -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = "valid_idol_cards[#valid_idol_cards+1] = v" -match_indent = true -position = "at" -payload = """if not SMODS.has_no_suit(v) and not SMODS.has_no_rank(v) then - valid_idol_cards[#valid_idol_cards+1] = v -end""" - -# reset_mail_rank() -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = "valid_mail_cards[#valid_mail_cards+1] = v" -match_indent = true -position = "at" -payload = """if not SMODS.has_no_rank(v) then - valid_mail_cards[#valid_mail_cards+1] = v -end""" - -# reset_castle_card() -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = "valid_castle_cards[#valid_castle_cards+1] = v" -match_indent = true -position = "at" -payload = """if not SMODS.has_no_suit(v) then - valid_castle_cards[#valid_castle_cards+1] = v -end""" - -# G.FUNCS.evaluate_play() -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = "if G.play.cards[i].ability.effect == 'Stone Card' then" -match_indent = true -position = "at" -payload = '''if SMODS.always_scores(G.play.cards[i]) then''' -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = "if scoring_hand[i].ability.effect ~= 'Stone Card' then" -match_indent = true -position = "at" -payload = '''if not SMODS.has_no_rank(scoring_hand[i]) then''' -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = "G.GAME.cards_played[scoring_hand[i].base.value].suits[scoring_hand[i].base.suit] = true" -match_indent = true -position = "at" -payload = """if not SMODS.has_no_suit(scoring_hand[i]) then - G.GAME.cards_played[scoring_hand[i].base.value].suits[scoring_hand[i].base.suit] = true -end""" - - -## replace_base_card -# Determines whether to draw the base card's front or not -# Card:draw() -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = "if self.children.front and self.ability.effect ~= 'Stone Card' then" -match_indent = true -position = "at" -payload = "if self.children.front and self.ability.effect ~= 'Stone Card' and not self.config.center.replace_base_card then" - -# Card:generate_UIBox_ability_table() -# replaces two consecutive lines -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = "if (_c.name == 'Stone Card') then full_UI_table.name = true end" -match_indent = true -position = "at" -payload = "if _c.name == 'Stone Card' or _c.replace_base_card then full_UI_table.name = true" -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = "if (specific_vars.playing_card and (_c.name ~= 'Stone Card')) then" -match_indent = true -position = "at" -payload = "elseif specific_vars.playing_card then" - - -## Allow cards to function as multiple enhancements (e.g. from jokers) -# Calculate extra enhancements when held in hand at end of round -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = "local effects = {G.hand.cards[i]:get_end_of_round_effect()}" -position = "at" -payload = ''' -local effects = {[1] = {playing_card = G.hand.cards[i]:get_end_of_round_effect()}} -local extra_enhancements = SMODS.get_enhancements(G.hand.cards[i], true) -local old_ability = copy_table(G.hand.cards[i].ability) -local old_center = G.hand.cards[i].config.center -local old_center_key = G.hand.cards[i].config.center_key -for k, _ in pairs(extra_enhancements) do - if G.P_CENTERS[k] then - G.hand.cards[i]:set_ability(G.P_CENTERS[k]) - G.hand.cards[i].ability.extra_enhancement = k - effects[#effects+1] = {[1] = {playing_card = G.hand.cards[i]:get_end_of_round_effect()}} - end -end -G.hand.cards[i].ability = old_ability -G.hand.cards[i].config.center = old_center -G.hand.cards[i].config.center_key = old_center_key -G.hand.cards[i]:set_sprites(old_center) -''' -match_indent = true - -# Prevent blue seal effect on extra enhancements at end of round -[[patches]] -[patches.pattern] -target = "card" -pattern = "if self.seal == 'Blue' and #G.consumeables.cards + G.GAME.consumeable_buffer < G.consumeables.config.card_limit then" -position = "before" -payload = ''' -if self.extra_enhancement then return ret end -''' -match_indent = true - -# Use the has enhancement function for enhancement gates -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = "if vv.config.center.key == v.enhancement_gate then" -position = "at" -payload = "if SMODS.has_enhancement(vv, v.enhancement_gate) then" -match_indent = true - -# Glass Card shattering -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = "if card.ability.name == 'Glass Card' then" -position = "at" -payload = "if SMODS.has_enhancement(card, 'm_glass') then" -match_indent = true - -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = "if G.hand.highlighted[i].ability.name == 'Glass Card' then" -position = "at" -payload = "if SMODS.has_enhancement(G.hand.highlighted[i], 'm_glass') then" -match_indent = true - -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = "if scoring_hand[i].ability.name == 'Glass Card' then" -position = "at" -payload = "if SMODS.shatters(scoring_hand[i]) then" -match_indent = true - -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = "if cards_destroyed[i].ability.name == 'Glass Card' then" -position = "at" -payload = "if SMODS.has_enhancement(cards_destroyed[i], 'm_glass') then" -match_indent = true - -# Prevent blue seals from applying on quantum enhancement calc -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = "if self.seal == 'Blue' and #G.consumeables.cards + G.GAME.consumeable_buffer < G.consumeables.config.card_limit then" -position = "at" -payload = "if self.seal == 'Blue' and #G.consumeables.cards + G.GAME.consumeable_buffer < G.consumeables.config.card_limit and not self.ability.extra_enhancement then" -match_indent = true \ No newline at end of file diff --git a/smods-main/lovely/fixes.toml b/smods-main/lovely/fixes.toml deleted file mode 100644 index 1d89b3e..0000000 --- a/smods-main/lovely/fixes.toml +++ /dev/null @@ -1,643 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -### Fixes for either base game code or general mod compatibility - -## Mods assume Game:start_run() is called with non-nil argument -# G.FUNCS.start_run() -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -pattern = "G.FUNCS.start_run = function(e, args)" -position = 'after' -match_indent = true -payload = "args = args or {}" - -## Allows running the game without Steam being active -# love.load() -[[patches]] -[patches.regex] -target = 'main.lua' -pattern = "(?[\t ]*)if not \\(st.init and st:init\\(\\)\\) then\n[\t ]*(?love.event.quit\\(\\))" -position = 'at' -root_capture = 'quit' -payload = 'st = nil' - - -## Prevents the game from crashing when hitting play with a corrupt/invalid save file -# G.FUNCS.can_continue(e) -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -pattern = "if G.SAVED_GAME ~= nil then G.SAVED_GAME = STR_UNPACK(G.SAVED_GAME) end" -position = 'after' -match_indent = true -payload = """ -if G.SAVED_GAME == nil then - e.config.colour = G.C.UI.BACKGROUND_INACTIVE - e.config.button = nil - return _can_continue -end -""" - -## Fix loading a blind with $0 reward -# Blind:load() -[[patches]] -[patches.regex] -target = 'blind.lua' -pattern = ''' -(?[\t ]*) G\.HUD_blind\.alignment\.offset\.y = 0 -[\t ]*end''' -position = 'at' -payload = ''' -end -if G.GAME.blind.name and G.GAME.blind.name ~= '' then - G.HUD_blind.alignment.offset.y = 0 -end''' -line_prepend = '$indent' - -## Remove incorrect check for Moveable alignment change -# Moveable:align_to_major() -[[patches]] -[patches.regex] -target = 'engine/moveable.lua' -pattern = ''' -(?[\t ]*)if +self\.alignment\.prev_offset\.x == self\.alignment\.offset\.x[\s\S]*?return end -''' -position = 'at' -payload = 'if not self.alignment.type_list then return end' -line_prepend = '$indent' - -## Prevent softlock if booster pack is empty -## Crashes the game when you skip too fast on this PR, along with being the culprit for allowing you to skip boosters early -# G.FUNCS.can_skip_booster() -# [[patches]] -# [patches.pattern] -# target = 'functions/button_callbacks.lua' -# pattern = 'if G.pack_cards and (G.pack_cards.cards[1]) and' -# position = 'at' -# payload = 'if G.pack_cards and' -# match_indent = true - -## Set `G.your_collection.config.collection` to true in all cases -# create_UIBox_your_collection_seals() -[[patches]] -[patches.regex] -target = 'functions/UI_definitions.lua' -pattern = '''\{card_limit = 4, type = 'title', highlight_limit = 0\}''' -position = 'at' -payload = '''{card_limit = 4, type = 'title', highlight_limit = 0, collection = true}''' - -## Save and load Card.unique_val -# Card:save() -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = "bypass_lock = self.bypass_lock," -position = "after" -payload = """ -unique_val = self.unique_val, -unique_val__saved_ID = self.ID, -ignore_base_shader = self.ignore_base_shader, -ignore_shadow = self.ignore_shadow,""" -match_indent = true - -# Card:load() -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = "self.bypass_lock = cardTable.bypass_lock" -position = "after" -payload = """ -self.unique_val = cardTable.unique_val or self.unique_val -if cardTable.unique_val__saved_ID and G.ID <= cardTable.unique_val__saved_ID then - G.ID = cardTable.unique_val__saved_ID + 1 -end - -self.ignore_base_shader = cardTable.ignore_base_shader or {} -self.ignore_shadow = cardTable.ignore_shadow or {}""" -match_indent = true - -## Vars in card descriptions should use `card.ability` instead of `_c.config` where possible -## Allow passing in custom vars -# generate_card_ui() -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -pattern = 'function generate_card_ui(_c, full_UI_table, specific_vars, card_type, badges, hide_desc, main_start, main_end)' -position = 'at' -match_indent = true -payload = '''function generate_card_ui(_c, full_UI_table, specific_vars, card_type, badges, hide_desc, main_start, main_end, card) - if _c.specific_vars then specific_vars = _c.specific_vars end''' - -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -pattern = "if _c.set == 'Other' then" -position = 'before' -match_indent = true -payload = "local cfg = (card and card.ability) or _c['config']" # string index to make sure the next patch doesn't eat it - -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -pattern = "if _c.name ~= 'Stone Card' and ((specific_vars and specific_vars.bonus_chips) or _c.config.bonus) then" -position = 'at' -match_indent = true -payload = "if _c.name ~= 'Stone Card' and ((specific_vars and specific_vars.bonus_chips) or (cfg.bonus ~= 0 and cfg.bonus)) then" - -[[patches]] -[patches.regex] -target = 'functions/common_events.lua' -pattern = '_c.config' -position = 'at' -payload = 'cfg' - -## When overriding with set_ability and card is added to deck, call add / remove effects -# Card:set_ability() -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = "self.config.center = center" -position = 'before' -match_indent = true -payload = ''' -if self.added_to_deck and old_center and not self.debuff then - self:remove_from_deck() - self.added_to_deck = true -end''' - -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = "if G.consumeables and self.area == G.consumeables then" -position = 'before' -match_indent = true -payload = ''' -if self.added_to_deck and old_center and not self.debuff then - self.added_to_deck = false - self:add_to_deck() -end''' - -## set_ability() transfers over old fields -# special cases: -# extra_value should be transferred -# name, effect, set, extra should always be overwritten -[[patches]] -[patches.regex] -target = 'card.lua' -pattern = ''' -(?[\t ]*)self\.ability = (\{[\s\S]*? -[\t ]*\}) -''' -position = 'at' -line_prepend = '$indent' -payload = ''' -local new_ability = $2 -self.ability = self.ability or {} -new_ability.extra_value = nil -self.ability.extra_value = self.ability.extra_value or 0 -for k, v in pairs(new_ability) do - self.ability[k] = v -end --- reset keys do not persist an ability change -local reset_keys = {'name', 'effect', 'set', 'extra', 'played_this_ante'} -for _, mod in ipairs(SMODS.mod_list) do - if mod.set_ability_reset_keys then - local keys = mod.set_ability_reset_keys() - for _, v in pairs(keys) do table.insert(reset_keys, v) end - end -end -for _, k in ipairs(reset_keys) do - self.ability[k] = new_ability[k] -end -''' - -## Fix crash if self.config.card == nil for non-vanilla set_ability() calls -# Card:set_ability() -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = "self.label = center.label or self.config.card.label or self.ability.set" -position = 'at' -match_indent = true -payload = "self.label = center.label or self.config.card and self.config.card.label or self.ability.set" - -### Fix Matador - -# These patches have been removed for altering vanilla behavior. Git blame this line to see what they were - -### Fix Crimson Heart - -## Blind:drawn_to_hand() -[[patches]] -[patches.pattern] -target = 'blind.lua' -pattern = "if self.name == 'Crimson Heart' and self.prepped and G.jokers.cards[1] then" -position = 'after' -match_indent = true -payload = """ - local prev_chosen_set = {} - local fallback_jokers = {}""" -# Fix bad logic if not enough choices for debuff -[[patches]] -[patches.regex] -target = 'blind.lua' -pattern = ''' -(?[\t ]*)for i = 1, #G\.jokers\.cards do -[\t ]*if not G\.jokers\.cards\[i\]\.debuff or #G\.jokers\.cards < 2 then jokers\[#jokers\+1\] = ?G\.jokers\.cards\[i\] end -[\t ]*G\.jokers\.cards\[i\]:set_debuff\(false\) -[\t ]*end''' -position = 'at' -line_prepend = '$indent' -payload = """ -for i = 1, #G.jokers.cards do - if G.jokers.cards[i].ability.crimson_heart_chosen then - prev_chosen_set[G.jokers.cards[i]] = true - G.jokers.cards[i].ability.crimson_heart_chosen = nil - if G.jokers.cards[i].debuff then SMODS.recalc_debuff(G.jokers.cards[i]) end - end -end -for i = 1, #G.jokers.cards do - if not G.jokers.cards[i].debuff then - if not prev_chosen_set[G.jokers.cards[i]] then - jokers[#jokers+1] = G.jokers.cards[i] - end - table.insert(fallback_jokers, G.jokers.cards[i]) - end -end -if #jokers == 0 then jokers = fallback_jokers end""" -# Add variable for Crimson Heart's choice -[[patches]] -[patches.pattern] -target = 'blind.lua' -pattern = "_card:set_debuff(true)" -position = "at" -match_indent = true -payload = """ -_card.ability.crimson_heart_chosen = true -SMODS.recalc_debuff(_card)""" - -## Blind:debuff_card() -[[patches]] -[patches.regex] -target = 'blind.lua' -pattern = ''' -if self\.name == 'Crimson Heart' and not self\.disabled and card\.area == G\.jokers then\s+ -((?[\t ]*)return)''' -root_capture = '$1' -position = "at" -line_prepend = '$indent' -payload = """ -if card.ability.crimson_heart_chosen then - card:set_debuff(true); - if card.debuff then card.debuffed_by_blind = true end - return -end""" - -## Blind:press_play() -# Shouldn't work with Matador -# yes it should - -## Blind:disable() -[[patches]] -[patches.pattern] -target = 'blind.lua' -pattern = "if self.name == 'The Water' then" -position = 'before' -payload = """ -if self.name == 'Crimson Heart' then - for _, v in ipairs(G.jokers.cards) do - v.ability.crimson_heart_chosen = nil - end -end""" -match_indent = true - -## Blind:defeat() -[[patches]] -[patches.pattern] -target = 'blind.lua' -pattern = "if self.name == 'The Manacle' and not self.disabled then" -position = 'before' -payload = """ -if self.name == 'Crimson Heart' then - for _, v in ipairs(G.jokers.cards) do - v.ability.crimson_heart_chosen = nil - end -end""" -match_indent = true - - -## Fix Manacle's unnecessary card draw after positive G.hand:change_size() -# Blind:disable() -[[patches]] -[patches.regex] -target = 'blind.lua' -pattern = 'G\.hand:change_size\(1\)(\s+G\.FUNCS\.draw_from_deck_to_hand\(1\))' -root_capture = '$1' -position = 'at' -payload = "" - -# -# Money scaling fix -# - -## create_UIBox_HUD -[[patches]] -[patches.regex] -target = "functions/UI_definitions.lua" -pattern = ''' -string = \{\{ref_table = G\.GAME\, ref_value = 'dollars'\, prefix = localize\('\$'\)\}\}\,''' -position = "after" -payload = ''' - - scale_function = function () - return scale_number(G.GAME.dollars, 2.2 * scale, 99999, 1000000) - end,''' - -## DynaText:update_text -[[patches]] -[patches.pattern] -target = "engine/text.lua" -pattern = 'self.config.H = 0' -position = "after" -payload = "self.scale = self.config.scale_function and self.config.scale_function() or self.scale" -match_indent = true - - -# -# Fix gold stake legendary infloop -# Do not try to roll for jokers that are not in_pool -# - -# generate_starting_seed() -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = '''if win_ante and (win_ante >= 8) then''' -match_indent = true -position = "at" -payload = '''if win_ante and (win_ante >= 8) or (v.in_pool and type(v.in_pool) == 'function' and not v:in_pool()) then''' - -# -# Fix G.GAME.blind:set_blind(nil, true, nil) -# being called when not in blind. -# - -# Card:add_to_deck -# Card:remove_from_deck -[[patches]] -[patches.regex] -target = "card.lua" -pattern = 'if G\.GAME\.blind then' -position = "at" -payload = "if G.GAME.blind and G.GAME.blind.in_blind then" - -# Blind:set_blind -[[patches]] -[patches.pattern] -target = "blind.lua" -match_indent = true -pattern = "if not reset then" -position = "after" -payload = ''' - if blind then - self.in_blind = true - end''' - -# end_round() -[[patches]] -[patches.pattern] -target = "functions/state_events.lua" -pattern = "local game_over = true" -position = "before" -payload = "G.GAME.blind.in_blind = false" -match_indent = true - - - -# Make sure new param is loaded -[[patches]] -[patches.pattern] -target = "blind.lua" -match_indent = true -pattern = "function Blind:load(blindTable)" -position = "after" -payload = ''' - self.in_blind = blindTable.in_blind''' - -# Make sure new param is saved -[[patches]] -[patches.pattern] -target = "blind.lua" -match_indent = true -pattern = "local blindTable = {" -position = "after" -payload = ''' - in_blind = self.in_blind,''' - -# Cartomancer and astronomer unlock when *actually all* Tarot/Planet cards are discovered -# check_for_unlock() -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -match_indent = true -pattern = "if card.unlock_condition.tarot_count <= args.tarot_count then" -position = "at" -payload = 'if #G.P_CENTER_POOLS.Tarot <= args.tarot_count then' - -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -match_indent = true -pattern = "if card.unlock_condition.planet_count <= args.planet_count then" -position = "at" -payload = 'if #G.P_CENTER_POOLS.Planet <= args.planet_count then' - -# wtf -[[patches]] -[patches.pattern] -target = "engine/animatedsprite.lua" -match_indent = true -pattern = "for _, v in pairs(G.ANIMATIONS) do" -position = "at" -payload = 'for k, v in pairs(G.ANIMATIONS) do' - -[[patches]] -[patches.pattern] -target = "engine/animatedsprite.lua" -match_indent = true -pattern = "for _, v in pairs(G.I.SPRITE) do" -position = "at" -payload = 'for k, v in pairs(G.I.SPRITE) do' - -## -## Card:draw() - improved mod compatibility -## -# Add option for sprites to not be drawn -[[patches]] -[patches.pattern] -target = "card.lua" -match_indent = true -pattern = ''' -if k ~= 'focused_ui' and k ~= "front" and k ~= "back" and k ~= "soul_parts" and k ~= "center" and k ~= 'floating_sprite' and k~= "shadow" and k~= "use_button" and k ~= 'buy_button' and k ~= 'buy_and_use_button' and k~= "debuff" and k ~= 'price' and k~= 'particles' and k ~= 'h_popup' then v:draw() end''' -position = "at" -payload = ''' -if not v.custom_draw and k ~= 'focused_ui' and k ~= "front" and k ~= "back" and k ~= "soul_parts" and k ~= "center" and k ~= 'floating_sprite' and k~= "shadow" and k~= "use_button" and k ~= 'buy_button' and k ~= 'buy_and_use_button' and k~= "debuff" and k ~= 'price' and k~= 'particles' and k ~= 'h_popup' then v:draw() end''' - -# This check is not necessary? -[[patches]] -[patches.pattern] -target = "card.lua" -match_indent = true -pattern = ''' -if self.edition or self.seal or self.ability.eternal or self.ability.rental or self.ability.perishable or self.sticker or ((self.sticker_run and self.sticker_run ~= 'NONE') and G.SETTINGS.run_stake_stickers) or (self.ability.set == 'Spectral') or self.debuff or self.greyed or (self.ability.name == 'The Soul') or (self.ability.set == 'Voucher') or (self.ability.set == 'Booster') or self.config.center.soul_pos or self.config.center.demo then''' -position = "at" -payload = ''' -if true then''' - -## Make vanilla enhancement jokers work with extra enhancements - -# Steel Joker -[[patches]] -[patches.pattern] -target = "card.lua" -match_indent = true -pattern = "if v.config.center == G.P_CENTERS.m_steel then self.ability.steel_tally = self.ability.steel_tally+1 end" -position = "at" -payload = "if SMODS.has_enhancement(v, 'm_steel') then self.ability.steel_tally = self.ability.steel_tally+1 end" - -# Stone Joker -[[patches]] -[patches.pattern] -target = "card.lua" -match_indent = true -pattern = "if v.config.center == G.P_CENTERS.m_stone then self.ability.stone_tally = self.ability.stone_tally+1 end" -position = "at" -payload = "if SMODS.has_enhancement(v, 'm_stone') then self.ability.stone_tally = self.ability.stone_tally+1 end" - -# Golden Ticket -[[patches]] -[patches.pattern] -target = "card.lua" -match_indent = true -pattern = "context.other_card.ability.name == 'Gold Card' then" -position = "at" -payload = "SMODS.has_enhancement(context.other_card, 'm_gold') then" - -# Golden Ticket Unlock -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -match_indent = true -pattern = "if args.cards[j].ability.name == 'Gold Card' then" -position = "at" -payload = "if SMODS.has_enhancement(args.cards[j], 'm_gold') then" - -# Glass Joker -[[patches]] -[patches.pattern] -target = "card.lua" -match_indent = true -pattern = "if val.ability.name == 'Glass Card' then shattered_glass = shattered_glass + 1 end" -position = "at" -payload = "if SMODS.has_enhancement(val, 'm_glass') then shattered_glass = shattered_glass + 1 end" - -# Driver's License -[[patches]] -[patches.pattern] -target = "card.lua" -match_indent = true -pattern = "if v.config.center ~= G.P_CENTERS.c_base then self.ability.driver_tally = self.ability.driver_tally+1 end" -position = "at" -payload = "if next(SMODS.get_enhancements(v)) then self.ability.driver_tally = self.ability.driver_tally+1 end" -# Basegame fix for the reroll vouchers redeem function when only the center but no card object exists - -# Card:apply_to_run -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = """G.GAME.round_resets.reroll_cost = G.GAME.round_resets.reroll_cost - self.ability.extra""" -position = 'at' -match_indent = true -payload = """G.GAME.round_resets.reroll_cost = G.GAME.round_resets.reroll_cost - center_table.extra""" - -# Card:apply_to_run -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = """G.GAME.current_round.reroll_cost = math.max(0, G.GAME.current_round.reroll_cost - self.ability.extra)""" -position = 'at' -match_indent = true -payload = """G.GAME.current_round.reroll_cost = math.max(0, G.GAME.current_round.reroll_cost - center_table.extra)""" - - -# Fix booster skip issues maybe? -[[patches]] -[patches.pattern] -target = "functions/button_callbacks.lua" -pattern = "if G.pack_cards and (G.pack_cards.cards[1]) and" -position = "at" -payload = ''' -if G.pack_cards and (not (G.GAME.STOP_USE and G.GAME.STOP_USE > 0)) and -''' -match_indent = true - -# Due to STOP_USE being used we can remove this dumb check -# could probably remove the rest of it since it serves no purpose otherwise, but whatever -[[patches]] -[patches.regex] -target = "functions/button_callbacks.lua" -pattern = '''and \(G\.hand\.cards\[1\] or \(G\.hand\.config\.card_limit <= 0\)\)''' -position = "at" -payload = ''' ''' - -# Fixes Steam API not loading on unix -[[patches]] -[patches.pattern] -target = 'main.lua' -match_indent = true -position = 'after' -pattern = '--To control when steam communication happens, make sure to send updates to steam as little as possible' -payload = '''local cwd = NFS.getWorkingDirectory() -NFS.setWorkingDirectory(love.filesystem.getSourceBaseDirectory()) -''' - -[[patches]] -[patches.pattern] -target = 'main.lua' -match_indent = true -position = 'before' -pattern = '--Set up the render window and the stage for the splash screen, then enter the gameloop with :update' -payload = '''NFS.setWorkingDirectory(cwd) -''' - -[[patches]] -[patches.pattern] -target = "main.lua" -pattern = '''if os == 'OS X' or os == 'Windows' then''' -position = "at" -payload = '''if os == 'OS X' or os == 'Windows' or os == 'Linux' then''' -overwrite = true -match_indent = true - -[[patches]] -[patches.pattern] -target = "main.lua" -pattern = '''if os == 'OS X' then''' -position = "at" -payload = '''if os == 'OS X' or os == 'Linux' then''' -overwrite = true -match_indent = true - -[[patches]] -[patches.pattern] -target = "main.lua" -pattern = "st = require 'luasteam'" -position = "at" -payload = """local success, _st = pcall(require, 'luasteam') -if success then st = _st else sendWarnMessage(_st); st = {} end""" -overwrite = true -match_indent = true diff --git a/smods-main/lovely/joker_retriggers.toml b/smods-main/lovely/joker_retriggers.toml deleted file mode 100644 index 7fa637c..0000000 --- a/smods-main/lovely/joker_retriggers.toml +++ /dev/null @@ -1,364 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = 0 - - -# Luchador -[[patches]] -[patches.regex] -target = "card.lua" -pattern = '''[ \t]*G\.GAME\.blind:disable\(\) -(?[ \t]*)end''' -position = "at" -line_prepend = '$indent' -payload = ''' G.GAME.blind:disable() - return nil, true -end''' - -# Diet Cola -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -[ \t]*return true -[ \t]*end\) -[ \t]*\}\)\) -(?[ \t]*)end -''' -position = "at" -line_prepend = '$indent' -payload = ''' return true - end) - })) - return nil, true -end -''' - -# Invisible Joker -[[patches]] -[patches.regex] -target = "card.lua" -pattern = '''[ \t]*if card\.ability\.invis_rounds then card\.ability\.invis_rounds = 0 end -[ \t]*card:add_to_deck\(\) -(?[ \t]*)G\.jokers:emplace\(card\)''' -position = "after" -line_prepend = '$indent' -payload = "return nil, true" - -# Campfire -[[patches]] -[patches.regex] -target = "card.lua" -pattern = '''localize\('k_upgrade_ex'\)\}\); return true -[ \t]*end\}\)\) -[ \t]*end -(?[ \t]*)return''' -position = "at" -line_prepend = '$indent' -payload = '''localize('k_upgrade_ex')}); return true - end})) -end -if self.ability.name == 'Campfire' and not context.blueprint then return nil, true end''' - -# Flash Card -[[patches]] -[patches.regex] -target = "card.lua" -pattern = '''[ \t]*G\.C\.MULT\}\) -[ \t]*return true -[ \t]*end\)\}\)\) -(?[ \t]*)end''' -position = "at" -line_prepend = '$indent' -payload = '''G.C.MULT}) - return true - end)})) -end -if self.ability.name == 'Flash Card' and not context.blueprint then return nil, true end''' - -# Perkeo -[[patches]] -[patches.regex] -target = "card.lua" -pattern = '''[ \t]*card_eval_status_text\(context\.blueprint_card or self, 'extra', nil, nil, nil, \{message = localize\('k_duplicated_ex'\)\}\) -(?[ \t]*)end''' -position = "at" -line_prepend = '$indent' -payload = ''' card_eval_status_text(context.blueprint_card or self, 'extra', nil, nil, nil, {message = localize('k_duplicated_ex')}) - return nil, true -end''' - -# Throwback -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -[ \t]*end -[ \t]*return -(?[ \t]*)elseif context\.skipping_booster''' -position = "before" -line_prepend = '$indent' -payload = "return nil, true" - -# Red Card -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -[ \t]*end -[ \t]*return -(?[ \t]*)elseif context\.playing_card_added''' -position = "before" -line_prepend = '$indent' -payload = "return nil, true" - -# Hologram -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -[ \t]*end -(?[ \t]*)elseif context\.first_hand_drawn''' -position = "before" -line_prepend = '$indent' -payload = "return nil, true" - -# Certificate -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -[ \t]*end -(?[ \t]*)if self\.ability\.name == 'DNA' and not context\.blueprint''' -position = "before" -line_prepend = '$indent' -payload = "return nil, true" - -# Chicot -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -[ \t]*end -(?[ \t]*)if self\.ability\.name == 'Madness' ''' -position = "before" -line_prepend = '$indent' -payload = "return nil, true" - -# Madness -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -[ \t]*end -(?[ \t]*)if self\.ability\.name == 'Burglar' ''' -position = "before" -line_prepend = '$indent' -payload = "return nil, true" - -# Burglar -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -[ \t]*end -(?[ \t]*)if self\.ability\.name == 'Riff-raff' ''' -position = "before" -line_prepend = '$indent' -payload = "return nil, true" - -# Riff-raff -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -[ \t]*end -(?[ \t]*)if self\.ability\.name == 'Cartomancer' ''' -position = "before" -line_prepend = '$indent' -payload = "return nil, true" - -# Cartomancer -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -[ \t]*end -(?[ \t]*)if self\.ability\.name == 'Ceremonial Dagger' and not context.blueprint''' -position = "before" -line_prepend = '$indent' -payload = "return nil, true" - -# Ceremonial Dagger -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -[ \t]*end -[ \t]*end -(?[ \t]*)if self\.ability\.name == 'Marble Joker' ''' -position = "before" -line_prepend = '$indent' -payload = "return nil, true" - -# Marble Joker -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -[ \t]*end -[ \t]*return -(?[ \t]*)elseif context.destroying_card''' -position = "before" -line_prepend = '$indent' -payload = "return nil, true" - -# Caino -[[patches]] -[patches.regex] -target = "card.lua" -pattern = '''[ \t]*func = function\(\) card_eval_status_text\(self, 'extra', nil, nil, nil, \{message = localize\{type = 'variable', key = 'a_xmult', vars = \{self\.ability\.caino_xmult\}\}\}\); return true -(?[ \t]*)end\}\)\)''' -position = "after" -line_prepend = '$indent' -payload = "return nil, true" - -# Glass Joker -[[patches]] -[patches.regex] -target = "card.lua" -pattern = '''glass_cards\}\}\}\) -[ \t]*return true -[ \t]*end -(?[ \t]*)\}\)\)''' -position = "after" -line_prepend = '$indent' -payload = "return nil, true" - -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -[ \t]*end -[ \t]*return -[ \t]*end -(?[ \t]*)if self\.ability\.name == 'Fortune Teller' and not context\.blueprint''' -position = "before" -line_prepend = '$indent' -payload = "return nil, true" - -# Fortune Teller -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -[ \t]*end -(?[ \t]*)if self\.ability\.name == 'Constellation' and not context\.blueprint''' -position = "before" -line_prepend = '$indent' -payload = "return nil, true" - -# Constellation -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -[ \t]*end -[ \t]*return -(?[ \t]*)elseif context.debuffed_hand''' -position = "before" -line_prepend = '$indent' -payload = "nil, true" - -# Burnt Joker -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -[ \t]*end -(?[ \t]*)elseif context.discard''' -position = "before" -line_prepend = '$indent' -payload = "return nil, true" - -# Faceless Joker -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -[ \t]*end -[ \t]*end -[ \t]*return -(?[ \t]*)elseif context.end_of_round''' -position = "before" -line_prepend = '$indent' -payload = "nil, true" - -# Yorick -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = "self.ability.yorick_discards = self.ability.yorick_discards - 1" -position = "after" -match_indent = true -payload = "return nil, true" - -# Hallucination -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = "card_eval_status_text(self, 'extra', nil, nil, nil, {message = localize('k_plus_tarot'), colour = G.C.PURPLE})" -position = "after" -match_indent = true -payload = "return nil, true" - -## Change card returns -# Ramen -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = ''' -message = localize('k_eaten_ex'), -colour = G.C.FILTER''' -position = "before" -match_indent = true -payload = "card = self," -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = '''message = localize{type='variable',key='a_xmult_minus',vars={self.ability.extra}},''' -position = "before" -match_indent = true -payload = "card = self," - -# Yorick -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = ''' -delay = 0.2, -message = localize{type='variable',key='a_xmult',vars={self.ability.x_mult}},''' -position = "before" -match_indent = true -payload = "card = self," - -# To Do List -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = '''message = localize('$')..self.ability.extra.dollars, - dollars = self.ability.extra.dollars,''' -position = "at" -match_indent = true -payload = '''message = localize('$')..self.ability.extra.dollars,''' - -# Matador -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = '''message = localize('$')..self.ability.extra, - dollars = self.ability.extra,''' -position = "at" -match_indent = true -payload = '''message = localize('$')..self.ability.extra,''' diff --git a/smods-main/lovely/joker_size.toml b/smods-main/lovely/joker_size.toml deleted file mode 100644 index 8aa82ab..0000000 --- a/smods-main/lovely/joker_size.toml +++ /dev/null @@ -1,73 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = 0 - -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = ''' -if _center.name == 'Square Joker' and (_center.discovered or self.bypass_discovery_center) then - self.children.center.scale.y = self.children.center.scale.x -end -''' -position = "after" -payload = ''' -if _center.pixel_size and _center.pixel_size.h and (_center.discovered or self.bypass_discovery_center) then - self.children.center.scale.y = self.children.center.scale.y*(_center.pixel_size.h/95) -end -if _center.pixel_size and _center.pixel_size.w and (_center.discovered or self.bypass_discovery_center) then - self.children.center.scale.x = self.children.center.scale.x*(_center.pixel_size.w/71) -end -''' -match_indent = true -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = ''' -if center.name == "Wee Joker" and (center.discovered or self.bypass_discovery_center) then - H = H*0.7 - W = W*0.7 - self.T.h = H - self.T.w = W -end -''' -position = "after" -payload = ''' -if center.display_size and center.display_size.h and (center.discovered or self.bypass_discovery_center) then - H = H*(center.display_size.h/95) - self.T.h = H -elseif center.pixel_size and center.pixel_size.h and (center.discovered or self.bypass_discovery_center) then - H = H*(center.pixel_size.h/95) - self.T.h = H -end -if center.display_size and center.display_size.w and (center.discovered or self.bypass_discovery_center) then - W = W*(center.display_size.w/71) - self.T.w = W -elseif center.pixel_size and center.pixel_size.w and (center.discovered or self.bypass_discovery_center) then - W = W*(center.pixel_size.w/71) - self.T.w = W -end -''' -match_indent = true -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = ''' -self.VT.h = self.T.H -self.VT.w = self.T.w -''' -position = "before" -payload = ''' -if self.config.center.display_size and self.config.center.display_size.h then - self.T.h = H*(self.config.center.display_size.h/95) -elseif self.config.center.pixel_size and self.config.center.pixel_size.h then - self.T.h = H*(self.config.center.pixel_size.h/95) -end -if self.config.center.display_size and self.config.center.display_size.w then - self.T.w = W*(self.config.center.display_size.w/71) -elseif self.config.center.pixel_size and self.config.center.pixel_size.w then - self.T.w = W*(self.config.center.pixel_size.w/71) -end -''' -match_indent = true diff --git a/smods-main/lovely/keybind.toml b/smods-main/lovely/keybind.toml deleted file mode 100644 index 80272b8..0000000 --- a/smods-main/lovely/keybind.toml +++ /dev/null @@ -1,82 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -5 - -# Check all registered keybinds -# inserted inside Controller:key_press_update - -[[patches]] -[patches.pattern] -target = 'engine/controller.lua' -pattern = "if not _RELEASE_MODE then" -position = "before" -payload = ''' -for _, keybind in pairs(SMODS.Keybinds) do - if keybind.action and keybind.key_pressed == key and keybind.event == 'pressed' then - local execute = true - for _, other_key in pairs(keybind.held_keys) do - if not self.held_keys[other_key] then - execute = false - break - end - end - if execute then - keybind:action() - end - end -end -''' -match_indent = true - -# Controller:key_release_update -[[patches]] -[patches.pattern] -target = 'engine/controller.lua' -pattern = "function Controller:key_release_update(key, dt)" -position = "after" -payload = ''' -for _, keybind in pairs(SMODS.Keybinds) do - if keybind.action and keybind.key_pressed == key and keybind.event == 'released' then - local execute = true - for _, other_key in pairs(keybind.held_keys) do - if not self.held_keys[other_key] then - execute = false - break - end - end - if execute then - keybind:action() - end - end -end -''' -match_indent = true - -[[patches]] -[patches.regex] -target = 'engine/controller.lua' -pattern = 'if key == "r"' -position = 'before' -line_prepend = '$indent' -payload = ''' -for _, keybind in pairs(SMODS.Keybinds) do - if keybind.key_pressed == key and keybind.event == 'held' and keybind.held_duration then - if self.held_key_times[key] > keybind.held_duration then - local execute = true - for _, other_key in pairs(keybind.held_keys) do - if not self.held_keys[other_key] then - execute = false - break - end - end - if execute then - keybind:action() - self.held_key_times[key] = nil - end - else - self.held_key_times[key] = self.held_key_times[key] + dt - end - end -end -''' diff --git a/smods-main/lovely/language.toml b/smods-main/lovely/language.toml deleted file mode 100644 index 5c89e5d..0000000 --- a/smods-main/lovely/language.toml +++ /dev/null @@ -1,59 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -### Language API - -# Game:set_language() -[[patches]] -[patches.pattern] -target = 'game.lua' -pattern = "if not (love.filesystem.read('localization/'..G.SETTINGS.language..'.lua')) or G.F_ENGLISH_ONLY then" -position = 'at' -payload = 'if false then' -match_indent = true - -[[patches]] -[patches.pattern] -target = 'game.lua' -pattern = "local localization = love.filesystem.getInfo('localization/'..G.SETTINGS.language..'.lua')" -position = 'at' -payload = "local localization = love.filesystem.getInfo('localization/'..G.SETTINGS.language..'.lua') or love.filesystem.getInfo('localization/en-us.lua')" -match_indent = true - -[[patches]] -[patches.pattern] -target = 'game.lua' -pattern = "self.localization = assert(loadstring(love.filesystem.read('localization/'..G.SETTINGS.language..'.lua')))()" -position = 'at' -payload = "self.localization = assert(loadstring(love.filesystem.read('localization/'..G.SETTINGS.language..'.lua') or love.filesystem.read('localization/en-us.lua')))()" -match_indent = true - -[[patches]] -[patches.pattern] -target = 'game.lua' -pattern = "self.LANG = self.LANGUAGES[self.SETTINGS.language] or self.LANGUAGES['en-us']" -position = 'at' -payload = "self.LANG = self.LANGUAGES[self.SETTINGS.real_language or self.SETTINGS.language] or self.LANGUAGES['en-us']" -match_indent = true - -# G.FUNCS.change_lang - -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -pattern = "G.SETTINGS.language = lang.key" -position = 'at' -payload = """G.SETTINGS.language = lang.loc_key or lang.key -G.SETTINGS.real_language = lang.key""" -match_indent = true - -# G.FUNCS.warn_lang (wtf) -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -pattern = 'if (_infotip_object.config.set ~= e.config.ref_table.label) and (not G.F_NO_ACHIEVEMENTS) then' -position = 'at' -payload = 'if (_infotip_object.config.set ~= e.config.ref_table.label) then' -match_indent = true diff --git a/smods-main/lovely/libs.toml b/smods-main/lovely/libs.toml deleted file mode 100644 index b7e8e9a..0000000 --- a/smods-main/lovely/libs.toml +++ /dev/null @@ -1,16 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -5 - -[[patches]] -[patches.module] -source = "libs/json/json.lua" -before = "main.lua" -name = "json" - -[[patches]] -[patches.module] -source = "libs/nativefs/nativefs.lua" -before = "main.lua" -name = "nativefs" diff --git a/smods-main/lovely/loader.toml b/smods-main/lovely/loader.toml deleted file mode 100644 index dfe4bd9..0000000 --- a/smods-main/lovely/loader.toml +++ /dev/null @@ -1,27 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -5 - -### Supporting code for loader.lua - -## Save discovered, unlocked states -# Game:init_item_prototypes() -[[patches]] -[patches.pattern] -target = 'game.lua' -pattern = "meta.alerted = meta.alerted or {}" -position = 'after' -payload = ''' -for _, t in ipairs{ - G.P_CENTERS, - G.P_BLINDS, - G.P_TAGS, - G.P_SEALS, -} do - for k, v in pairs(t) do - SMODS._save_d_u(v) - v._discovered_unlocked_overwritten = true - end -end''' -match_indent = true diff --git a/smods-main/lovely/menu.toml b/smods-main/lovely/menu.toml deleted file mode 100644 index 0e3e9fb..0000000 --- a/smods-main/lovely/menu.toml +++ /dev/null @@ -1,60 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -5 - -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = '''local main_menu = nil''' -position = "after" -payload = '''local mods = nil''' -match_indent = true - -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = '''main_menu = UIBox_button{ label = {localize('b_main_menu')}, button = "go_to_menu", minw = 5}''' -position = "after" -payload = '''mods = UIBox_button{ id = "mods_button", label = {localize('b_mods')}, button = "mods_button", minw = 5}''' -match_indent = true - -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = '''G.ARGS.set_alerts_alertables[11].should_alert = alert_booster''' -position = "after" -payload = '''table.insert(G.ARGS.set_alerts_alertables, {id = 'mods_button', alert_uibox_name = 'mods_button_alert', should_alert = SMODS.mod_button_alert})''' -match_indent = true - -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = '''main_menu,''' -position = "after" -payload = '''mods,''' -match_indent = true - - -[[patches]] -[patches.pattern] -target = 'game.lua' -pattern = '''self.ASSET_ATLAS[self.asset_atli[i].name].image = love.graphics.newImage(self.asset_atli[i].path, {mipmaps = true, dpiscale = self.SETTINGS.GRAPHICS.texture_scaling})''' -position = 'after' -payload = ''' -local mipmap_level = SMODS.config.graphics_mipmap_level_options[SMODS.config.graphics_mipmap_level] -if mipmap_level and mipmap_level > 0 then - self.ASSET_ATLAS[self.asset_atli[i].name].image:setMipmapFilter('linear', mipmap_level) -end''' -match_indent = true - - -[[patches]] -[patches.pattern] -target = 'functions/UI_definitions.lua' -pattern = '''create_option_cycle({w = 4,scale = 0.8, label = localize("b_set_CRT_bloom"),options = localize('ml_bloom_opt'), opt_callback = 'change_crt_bloom', current_option = G.SETTINGS.GRAPHICS.bloom}),''' -position = 'after' -payload = ''' -create_option_cycle({label = localize('b_graphics_mipmap_level'),scale = 0.8, options = SMODS.config.graphics_mipmap_level_options, opt_callback = 'SMODS_change_mipmap', current_option = SMODS.config.graphics_mipmap_level}),''' -match_indent = true - diff --git a/smods-main/lovely/mod.toml b/smods-main/lovely/mod.toml deleted file mode 100644 index 225effb..0000000 --- a/smods-main/lovely/mod.toml +++ /dev/null @@ -1,70 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -5 - -### Per-mod functions - -# end_round() -[[patches]] -[patches.regex] -target = 'functions/state_events.lua' -pattern = '''(?[\t ]*)reset_castle_card\(\)''' -line_prepend = '$indent' -position = 'after' -payload = ''' -for _, mod in ipairs(SMODS.mod_list) do - if mod.reset_game_globals and type(mod.reset_game_globals) == 'function' then - mod.reset_game_globals(false) - end -end''' - -# Game:start_run() -[[patches]] -[patches.regex] -target = 'game.lua' -pattern = '''(?[\t ]*)reset_castle_card\(\)''' -line_prepend = '$indent' -position = 'after' -payload = ''' -for _, mod in ipairs(SMODS.mod_list) do - if mod.reset_game_globals and type(mod.reset_game_globals) == 'function' then - mod.reset_game_globals(true) - end -end''' - -# Card:set_debuff() -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = "function Card:set_debuff(should_debuff)" -position = 'after' -match_indent = true -payload = ''' - for _, mod in ipairs(SMODS.mod_list) do - if mod.set_debuff and type(mod.set_debuff) == 'function' then - local res = mod.set_debuff(self) - if res == 'prevent_debuff' then - if self.debuff then - self.debuff = false - if self.area == G.jokers then self:add_to_deck(true) end - self.debuffed_by_blind = false - end - return - end - should_debuff = should_debuff or res - end - end - for k, v in pairs(self.ability.debuff_sources or {}) do - if v == 'prevent_debuff' then - if self.debuff then - self.debuff = false - if self.area == G.jokers then self:add_to_deck(true) end - end - self.debuffed_by_blind = false - return - end - should_debuff = should_debuff or v - end - -''' diff --git a/smods-main/lovely/number_formatting.toml b/smods-main/lovely/number_formatting.toml deleted file mode 100644 index 0107ffa..0000000 --- a/smods-main/lovely/number_formatting.toml +++ /dev/null @@ -1,171 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -# -# Use number_format for... -# - -# DynaText - -[[patches]] -[patches.regex] -target = "engine/text.lua" -pattern = 'tostring\((?v\.ref_table and v\.ref_table\[v\.ref_value\] or v\.string)\)' -position = "at" -payload = "format_ui_value($param)" - -# Cash Out - -[[patches]] -[patches.regex] -target = "functions/common_events.lua" -pattern = ''' -localize\('\$'\)\.\.config\.dollars''' -position = "at" -payload = "localize('$')..format_ui_value(config.dollars)" - -# End of round money - -[[patches]] -[patches.regex] -target = "functions/common_events.lua" -pattern = ''' -localize\('\$'\)\.\.num_dollars\}''' -position = "at" -payload = "localize('$')..format_ui_value(num_dollars)}" - -# Tooltip numbers - -[[patches]] -[patches.regex] -target = "functions/misc_functions.lua" -pattern = '(?args\.vars\[tonumber\(subpart\[1\]\)\])' -position = "at" -payload = 'format_ui_value($param)' - -# Poker Hand chips - -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = "{n=G.UIT.T, config={text = G.GAME.hands[handname].chips, scale = 0.45, colour = G.C.UI.TEXT_LIGHT}}," -position = "at" -payload = "{n=G.UIT.T, config={text = number_format(G.GAME.hands[handname].chips, 1000000), scale = 0.45, colour = G.C.UI.TEXT_LIGHT}}," -match_indent = true - -# Poker Hand mult - -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = "{n=G.UIT.T, config={text = G.GAME.hands[handname].mult, scale = 0.45, colour = G.C.UI.TEXT_LIGHT}}" -position = "at" -payload = "{n=G.UIT.T, config={text = number_format(G.GAME.hands[handname].mult, 1000000), scale = 0.45, colour = G.C.UI.TEXT_LIGHT}}" -match_indent = true - -# Continue Run - Money - -[[patches]] -[patches.regex] -target = "functions/UI_definitions.lua" -pattern = 'tostring\(saved_game\.GAME\.dollars\)' -position = "at" -payload = "format_ui_value(saved_game.GAME.dollars)" - -# Continue Run - Best Hand - bigger size - -[[patches]] -[patches.regex] -target = "functions/UI_definitions.lua" -pattern = 'scale_number\(saved_game\.GAME\.round_scores\.hand\.amt\, 0\.8\*scale\)' -position = "at" -payload = "scale_number(saved_game.GAME.round_scores.hand.amt, 0.8*scale, 100000000000)" - - -# -# Custom sci notation switch point -# - -## number_format -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = 'function number_format(num)' -position = "at" -payload = ''' -function number_format(num, e_switch_point) - if type(num) ~= 'number' then return num end - - local sign = (num >= 0 and "") or "-" - num = math.abs(num)''' -match_indent = true - -[[patches]] -[patches.regex] -target = "functions/misc_functions.lua" -pattern = 'num >= G\.E_SWITCH_POINT' -position = "at" -payload = "num >= (e_switch_point or G.E_SWITCH_POINT)" - -# 1. Fix floating point error (1.000e92 instead of 10.000e91) -# 2. Lower precision with higher numbers -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = ''' -return string.format("%.3f",x/(10^fac))..'e'..fac''' -position = "at" -payload = ''' -if num == math.huge then - return sign.."naneinf" -end - -local mantissa = round_number(x/(10^fac), 3) -if mantissa >= 10 then - mantissa = mantissa / 10 - fac = fac + 1 -end -return sign..(string.format(fac >= 100 and "%.1fe%i" or fac >= 10 and "%.2fe%i" or "%.3fe%i", mantissa, fac))''' -match_indent = true - -# Remove trailing zeroes -# E.g. X1.5 being displayed as X1.50 -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = ''' -return string.format(num ~= math.floor(num) and (num >= 100 and "%.0f" or num >= 10 and "%.1f" or "%.2f") or "%.0f", num):reverse():gsub("(%d%d%d)", "%1,"):gsub(",$", ""):reverse()''' -position = "at" -payload = ''' -local formatted -if num ~= math.floor(num) and num < 100 then - formatted = string.format(num >= 10 and "%.1f" or "%.2f", num) - if formatted:sub(-1) == "0" then - formatted = formatted:gsub("%.?0+$", "") - end - -- Return already to avoid comas being added - if num < 0.01 then return tostring(num) end -else - formatted = string.format("%.0f", num) -end -return sign..(formatted:reverse():gsub("(%d%d%d)", "%1,"):gsub(",$", ""):reverse())''' -match_indent = true - -## scale_number -[[patches]] -[patches.pattern] -target = "functions/button_callbacks.lua" -pattern = 'function scale_number(number, scale, max)' -position = "at" -payload = 'function scale_number(number, scale, max, e_switch_point)' -match_indent = true - -[[patches]] -[patches.regex] -target = "functions/button_callbacks.lua" -pattern = 'number >= G\.E_SWITCH_POINT' -position = "at" -payload = "math.abs(number) >= (e_switch_point or G.E_SWITCH_POINT)" - diff --git a/smods-main/lovely/playing_card.toml b/smods-main/lovely/playing_card.toml deleted file mode 100644 index 1f6a244..0000000 --- a/smods-main/lovely/playing_card.toml +++ /dev/null @@ -1,299 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -### Playing Card API - -# Game:init_game_object() -[[patches]] -[patches.pattern] -target = 'game.lua' -pattern = 'function Game:init_game_object()' -position = 'after' -match_indent = true -payload = ''' - local cards_played = {} - for _,v in ipairs(SMODS.Rank.obj_buffer) do - cards_played[v] = { suits = {}, total = 0 } - end''' - -[[patches]] -[patches.regex] -target = "game.lua" -pattern = '(?[\t ]*)cards_played = \{\n(.*\n){13}[\t ]*\},' -position = 'at' -line_prepend = '$indent' -payload = ''' - cards_played = cards_played, - disabled_suits = {}, - disabled_ranks = {},''' - -# Game:start_run() -[[patches]] -[patches.pattern] -target = "game.lua" -pattern = 'local _ = nil' -position = 'before' -match_indent = true -payload = ''' -if type(SMODS.Ranks[v.value].in_pool) == 'function' and not SMODS.Ranks[v.value]:in_pool({initial_deck = true, suit = v.suit}) -or type(SMODS.Suits[v.suit].in_pool) == 'function' and not SMODS.Suits[v.suit]:in_pool({initial_deck = true, rank = v.value}) then - goto continue -end''' - -[[patches]] -[patches.pattern] -target = "game.lua" -pattern = "if self.GAME.starting_params.erratic_suits_and_ranks then _, k = pseudorandom_element(G.P_CARDS, pseudoseed('erratic')) end" -position = 'at' -match_indent = true -payload = '''if self.GAME.starting_params.erratic_suits_and_ranks then - v, k = pseudorandom_element(G.P_CARDS, pseudoseed('erratic'), {starting_deck = true}) -end''' - -[[patches]] -[patches.pattern] -target = "game.lua" -pattern = 'local _r, _s = string.sub(k, 3, 3), string.sub(k, 1, 1)' -position = 'at' -match_indent = true -payload = 'local _r, _s = SMODS.Ranks[v.value].card_key, SMODS.Suits[v.suit].card_key' - -[[patches]] -[patches.pattern] -target = "game.lua" -pattern = "if self.GAME.starting_params.no_faces and (_r == 'K' or _r == 'Q' or _r == 'J') then keep = false end" -position = 'at' -match_indent = true -payload = ''' -if self.GAME.starting_params.no_faces and SMODS.Ranks[v.value].face then keep = false end''' - -[[patches]] -[patches.pattern] -target = "game.lua" -pattern = "if keep then card_protos[#card_protos+1] = {s=_s,r=_r,e=_e,d=_d,g=_g} end" -position = "after" -payload = "::continue::" -match_indent = true - -# loc_colour() -[[patches]] -[patches.pattern] -target = 'functions/misc_functions.lua' -pattern = 'return G.ARGS.LOC_COLOURS[_c] or _default or G.C.UI.TEXT_DARK' -position = 'before' -match_indent = true -payload = ''' - for _, v in ipairs(SMODS.Rarity.obj_buffer) do - G.ARGS.LOC_COLOURS[v:lower()] = G.C.RARITY[v] - end - for _, v in ipairs(SMODS.ConsumableType.ctype_buffer) do - G.ARGS.LOC_COLOURS[v:lower()] = G.C.SECONDARY_SET[v] - end - for _, v in ipairs(SMODS.Suit.obj_buffer) do - G.ARGS.LOC_COLOURS[v:lower()] = G.C.SUITS[v] - end''' - -# get_flush() -[[patches]] -[patches.regex] -target = "functions/misc_functions.lua" -pattern = '(?[\t ]*)local suits = \{\n[\t ]*"Spades",\n[\t ]*"Hearts",\n[\t ]*"Clubs",\n[\t ]*"Diamonds"\n[\t ]*\}\n[\t ]*if #hand > 5 or (?#hand < \(5 - \(four_fingers and 1 or 0\)\) then return ret else)' -position = 'at' -line_prepend = '$indent' -payload = ''' -local suits = SMODS.Suit.obj_buffer -if $restcond''' - -# get_X_same() -[[patches]] -[patches.pattern] -target = 'functions/misc_functions.lua' -pattern = 'local vals = {{},{},{},{},{},{},{},{},{},{},{},{},{},{}}' -position = 'at' -match_indent = true -payload = ''' -local vals = {} -for i = 1, SMODS.Rank.max_id.value do - vals[i] = {} -end''' - -[[patches]] -[patches.pattern] -target = 'functions/misc_functions.lua' -pattern = 'function get_X_same(num, hand)' -position = 'at' -match_indent = true -payload = '''function get_X_same(num, hand, or_more)''' - -[[patches]] -[patches.pattern] -target = 'functions/misc_functions.lua' -pattern = 'if #curr == num then' -position = 'at' -match_indent = true -payload = '''if or_more and (#curr >= num) or (#curr == num) then''' - -# Card:get_nominal() -[[patches]] -[patches.regex] -target = "card.lua" -pattern = 'function Card:get_nominal\(mod\)\n([\t ]+.*\n)*end' -position = 'at' -payload = ''' -function Card:get_nominal(mod) - local mult = 1 - local rank_mult = 1 - if mod == 'suit' then mult = 10000 end - if self.ability.effect == 'Stone Card' or (self.config.center.no_suit and self.config.center.no_rank) then - mult = -10000 - elseif self.config.center.no_suit then - mult = 0 - elseif self.config.center.no_rank then - rank_mult = 0 - end - return 10*self.base.nominal*rank_mult + self.base.suit_nominal*mult + (self.base.suit_nominal_original or 0)*0.0001*mult + 10*self.base.face_nominal*rank_mult + 0.000001*self.unique_val -end''' - -# Card:set_base() -[[patches]] -[patches.regex] -target = 'card.lua' -pattern = "(?[\t ]*)if self.base.value == '2' then self.base.nominal = 2; self.base.id = 2(\n[\t ]+elseif .*)*" -position = 'at' -line_prepend = '$indent' -payload = ''' -local rank = SMODS.Ranks[self.base.value] or {} -self.base.nominal = rank.nominal or 0 -self.base.face_nominal = rank.face_nominal or 0 -self.base.id = rank.id''' - -[[patches]] -[patches.regex] -target = 'card.lua' -pattern = "(?[\t ]*)if self.base.suit == 'Diamonds' then self.base.suit_nominal = 0.01; self.base.suit_nominal_original = suit_base_nominal_original or 0.001 (\n[\t ]+elseif .*)*" -position = 'at' -line_prepend = '$indent' -payload = ''' -local suit = SMODS.Suits[self.base.suit] or {} -self.base.suit_nominal = suit.suit_nominal or 0 -self.base.suit_nominal_original = suit_base_nominal_original or suit.suit_nominal or 0''' - -# Card:change_suit() -[[patches]] -[patches.regex] -target = 'card.lua' -pattern = "(?[\t ]*)local new_code = [\\s\\S]*?local new_val = [\\s\\S]*?local new_card = G.P_CARDS\\[new_code..new_val\\]" -position = 'at' -line_prepend = '$indent' -payload = ''' -local new_code = SMODS.Suits[new_suit].card_key -local new_val = SMODS.Ranks[self.base.value].card_key -local new_card = G.P_CARDS[new_code..'_'..new_val]''' - -# Card:is_face() -[[patches]] -[patches.regex] -target = 'card.lua' -pattern = "(?[\t ]*)if id == 11 or id == 12 or id == 13 or next\\(find_joker\\(\"Pareidolia\"\\)\\) then" -position = 'at' -line_prepend = '$indent' -payload = ''' -local rank = SMODS.Ranks[self.base.value] -if not id then return end -if (id > 0 and rank and rank.face) or next(find_joker("Pareidolia")) then''' - - -# tally_sprite() -[[patches]] -[patches.regex] -target = 'functions/UI_definitions.lua' -pattern = '(?[\t ]*local t_s = Sprite\(0,0,0.5,0.5,)G.ASSET_ATLAS\[.*?\](?.*?\))' -position = 'at' -payload = '$start G.ASSET_ATLAS[suit and SMODS.Suits[suit][G.SETTINGS.colourblind_option and "hc_ui_atlas" or "lc_ui_atlas"]] or G.ASSET_ATLAS[("ui_"..(G.SETTINGS.colourblind_option and "2" or "1"))]$rest' - -[[patches]] -[patches.pattern] -target = 'functions/UI_definitions.lua' -pattern = 'function tally_sprite(pos, value, tooltip)' -position = 'at' -match_indent = true -payload = 'function tally_sprite(pos, value, tooltip, suit)' - -# G.UIDEF.challenge_description_tab() -[[patches]] -[patches.regex] -target = 'functions/UI_definitions.lua' -pattern = "(?[\t ]*)local SUITS = \\{(\n.*){5}\n[\t ]*local suit_map = \\{'S', 'H', 'C', 'D'\\}" -position = 'at' -line_prepend = '$indent' -payload = ''' -local SUITS = {} -local suit_map = {} -for i = #SMODS.Suit.obj_buffer, 1, -1 do - local suit = SMODS.Suits[SMODS.Suit.obj_buffer[i]] - SUITS[suit.card_key] = {} - suit_map[#suit_map+1] = suit.card_key -end''' - -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = 'local _r, _s = string.sub(k, 3, 3), string.sub(k, 1, 1)' -position = 'at' -match_indent = true -payload = 'local _r, _s = SMODS.Ranks[v.value].card_key, SMODS.Suits[v.suit].card_key' - -# TODO there may need to be a way to let in_pool know what challenge is being displayed -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = 'local keep, _e, _d, _g = true, nil, nil, nil' -position = 'after' -match_indent = true -payload = ''' -if type(SMODS.Ranks[v.value].in_pool) == 'function' and not SMODS.Ranks[v.value]:in_pool({initial_deck = true, suit = v.suit}) then - keep = false -end -if type(SMODS.Suits[v.suit].in_pool) == 'function' and not SMODS.Suits[v.suit]:in_pool({initial_deck = true, rank = v.value}) then - keep = false -end''' - -[[patches]] -[patches.regex] -target = 'functions/UI_definitions.lua' -pattern = '(?[\t ]*)for j = 1, 4 do\n[\t ]*(?if SUITS\[suit_map\[j\]\]\[1\] then\n[\t ]*table.sort.*(\n.*)*?)\n[\t ]*0\.42\*G.CARD_H,' -position = 'at' -line_prepend = '$indent' -payload = ''' -local num_suits = 0 -for j = 1, #suit_map do - if SUITS[suit_map[j]][1] then num_suits = num_suits + 1 end -end -for j = 1, #suit_map do - $mid - (0.42 - (num_suits <= 4 and 0 or num_suits >= 8 and 0.28 or 0.07 * (num_suits - 4))) * G.CARD_H,''' - -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -pattern = '--Fill all remaining info if this is the main desc' -position = 'before' -match_indent = true -payload = '''if card_type == 'Default' or card_type == 'Enhanced' and not _c.replace_base_card and card and card.base then - if not _c.no_suit then - local suit = SMODS.Suits[card.base.suit] or {} - if suit.loc_vars and type(suit.loc_vars) == 'function' then - suit:loc_vars(info_queue, card) - end - end - if not _c.no_rank then - local rank = SMODS.Ranks[card.base.value] or {} - if rank.loc_vars and type(rank.loc_vars) == 'function' then - rank:loc_vars(info_queue, card) - end - end -end - -''' diff --git a/smods-main/lovely/poker_hand.toml b/smods-main/lovely/poker_hand.toml deleted file mode 100644 index d6f0f05..0000000 --- a/smods-main/lovely/poker_hand.toml +++ /dev/null @@ -1,60 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -5 - -### Poker Hand API - -# evaluate_poker_hand() -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = "local parts = {" -position = 'before' -payload = ''' -for _,v in ipairs(SMODS.PokerHand.obj_buffer) do - results[v] = {} -end''' -match_indent = true - -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = "if next(parts._5) and next(parts._flush) then" -position = 'before' -payload = ''' -for _,_hand in pairs(SMODS.PokerHands) do - if _hand.atomic_part and type(_hand.atomic_part) == 'function' then - parts[_hand.key] = _hand.atomic_part(hand) - end -end''' -match_indent = true - -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = "return results" -position = 'before' -payload = ''' -for _,_hand in pairs(SMODS.PokerHands) do - if _hand.composite and type(_hand.composite) == 'function' then - local other_hands - results[_hand.key], other_hands = _hand.composite(parts) - results[_hand.key] = results[_hand.key] or {} - if other_hands and type(other_hands) == 'table' then - for k, v in pairs(other_hands) do - results[k] = v - end - end - else - results[_hand.key] = parts[_hand.key] - end -end -results.top = nil -for _, v in ipairs(G.handlist) do - if not results.top and results[v] then - results.top = results[v] - break - end -end''' -match_indent = true diff --git a/smods-main/lovely/pool.toml b/smods-main/lovely/pool.toml deleted file mode 100644 index e08d9f7..0000000 --- a/smods-main/lovely/pool.toml +++ /dev/null @@ -1,185 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -### Functions that affect random selection from pools - -# pseudorandom_element() -# TODO special cases for now -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = "function pseudorandom_element(_t, seed)" -position = "at" -payload = """function pseudorandom_element(_t, seed, args) - -- TODO special cases for now - -- Preserves reverse nominal order for Suits, nominal+face_nominal order for Ranks - -- for vanilla RNG - if _t == SMODS.Suits then - _t = SMODS.Suit:obj_list(true) - end - if _t == SMODS.Ranks then - _t = SMODS.Rank:obj_list() - end -""" -match_indent = true - -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = "keys[#keys+1] = {k = k,v = v}" -position = "at" -payload = """ -local keep = true -local in_pool_func = - args and args.in_pool - or type(v) == 'table' and type(v.in_pool) == 'function' and v.in_pool - or _t == G.P_CARDS and function(c) - --Handles special case for Erratic Deck - local initial_deck = args and args.starting_deck or false - - return not ( - type(SMODS.Ranks[c.value].in_pool) == 'function' and not SMODS.Ranks[c.value]:in_pool({initial_deck = initial_deck, suit = c.suit}) - or type(SMODS.Suits[c.suit].in_pool) == 'function' and not SMODS.Suits[c.suit]:in_pool({initial_deck = initial_deck, rank = c.value}) - ) - end -if in_pool_func then - keep = in_pool_func(v, args) -end -if keep then - keys[#keys+1] = {k = k,v = v} -end""" -match_indent = true - -# fixes pseudorandom_element on an empty list -# nil, nil is returned in that case -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = "local key = keys[math.random(#keys)].k" -position = "before" -payload = "if #keys == 0 then return nil, nil end" -match_indent = true - -## get_current_pool() - -# Centers - -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -pattern = "else _starting_pool, _pool_key = G.P_CENTER_POOLS[_type], _type..(_append or '')" -match_indent = true -position = 'before' -payload = ''' -elseif SMODS.ObjectTypes[_type] and SMODS.ObjectTypes[_type].rarities then - local rarities = SMODS.ObjectTypes[_type].rarities - local rarity - if _legendary and rarities.legendary then - rarity = rarities.legendary.key - else - rarity = _rarity or SMODS.poll_rarity(_type, 'rarity_'.._type..G.GAME.round_resets.ante..(_append or '')) - end - _starting_pool, _pool_key = SMODS.ObjectTypes[_type].rarity_pools[rarity], _type..rarity..(_append or '')''' - -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -pattern = "if _type == 'Tarot' or _type == 'Tarot_Planet' then _pool[#_pool + 1] = \"c_strength\"" -match_indent = true -position = 'at' -payload = ''' -if SMODS.ObjectTypes[_type] and SMODS.ObjectTypes[_type].default and G.P_CENTERS[SMODS.ObjectTypes[_type].default] then - _pool[#_pool+1] = SMODS.ObjectTypes[_type].default -elseif _type == 'Tarot' or _type == 'Tarot_Planet' then _pool[#_pool + 1] = "c_strength"''' - -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -pattern = "if v.name == 'Black Hole' or v.name == 'The Soul' then" -match_indent = true -position = 'at' -payload = "if v.name == 'Black Hole' or v.name == 'The Soul' or v.hidden then" - -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -pattern = "if _type == 'Enhanced' then" -match_indent = true -position = 'before' -payload = ''' -local in_pool, pool_opts -if v.in_pool and type(v.in_pool) == 'function' then - in_pool, pool_opts = v:in_pool({ source = _append }) -end -pool_opts = pool_opts or {} -''' - -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -pattern = 'elseif not (G.GAME.used_jokers[v.key] and not next(find_joker("Showman"))) and' -match_indent = true -position = 'at' -payload = '''elseif not (G.GAME.used_jokers[v.key] and not pool_opts.allow_duplicates and not next(find_joker("Showman"))) and''' - -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -pattern = "if add and not G.GAME.banned_keys[v.key] then" -match_indent = true -position = 'before' -payload = ''' -if v.in_pool and type(v.in_pool) == 'function' then - add = in_pool and (add or pool_opts.override_base_checks) -end -''' - -## G.GAME.used_jokers now checks keys, not names -# Card:set_ability() -# Remove the old center from `used_jokers` if set_ability overrides -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = "local old_center = self.config.center" -position = 'after' -payload = ''' -if old_center and not next(SMODS.find_card(old_center.key, true)) then - G.GAME.used_jokers[old_center.key] = nil -end''' -match_indent = true -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -(?[\t ]*)for k, v in pairs\(G\.P_CENTERS\) do -[\t ]*if v\.name == self\.ability\.name then -[\t ]*G\.GAME\.used_jokers\[k\] = true -[\t ]*end -[\t ]*end''' -position = "at" -payload = ''' -if self.config.center.key then - G.GAME.used_jokers[self.config.center.key] = true -end -''' -line_prepend = "$indent" -# Card:remove() -[[patches]] -[patches.regex] -target = "card.lua" -pattern = ''' -(?[\t ]*)for k, v in pairs\(G\.P_CENTERS\) do -[\t ]*if v\.name == self\.ability\.name then -[\t ]*if not next\(find_joker\(self\.ability\.name, true\)\) then -[\t ]*G\.GAME\.used_jokers\[k\] = nil -[\t ]*end -[\t ]*end -[\t ]*end''' -position = "at" -payload = ''' -if not next(SMODS.find_card(self.config.center.key, true)) then - G.GAME.used_jokers[self.config.center.key] = nil -end''' -line_prepend = "$indent" diff --git a/smods-main/lovely/rarity.toml b/smods-main/lovely/rarity.toml deleted file mode 100644 index efaef67..0000000 --- a/smods-main/lovely/rarity.toml +++ /dev/null @@ -1,61 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -### Rarity API - -# get_badge_colour -[[patches]] -[patches.pattern] -target = 'functions/UI_definitions.lua' -pattern = 'return G.BADGE_COL[key] or {1, 0, 0, 1}' -position = 'before' -match_indent = true -payload = ''' -for k, v in pairs(SMODS.Rarity.obj_buffer) do - G.BADGE_COL[k] = G.C.RARITY[v] -end''' - -# G.UIDEF.card_h_popup -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = "if AUT.card_type == 'Joker' or (AUT.badges and AUT.badges.force_rarity) then card_type = ({localize('k_common'), localize('k_uncommon'), localize('k_rare'), localize('k_legendary')})[card.config.center.rarity] end" -position = "at" -payload = "if AUT.card_type == 'Joker' or (AUT.badges and AUT.badges.force_rarity) then card_type = SMODS.Rarity:get_rarity_badge(card.config.center.rarity) end" -match_indent = true - -# Game:update -[[patches]] -[patches.pattern] -target = "game.lua" -pattern = "self.C.EDITION[2] = 0.7+0.2*(1+math.sin(self.TIMERS.REAL*1.5 + 6))" -position = "after" -payload = ''' -for k, v in pairs(SMODS.Rarities) do - if v.gradient and type(v.gradient) == "function" then v:gradient(dt) end -end''' -match_indent = true - -# get_current_pool -[[patches]] -[patches.regex] -target = "functions/common_events.lua" -pattern = '''(?[\t ]*)local rarity = _rarity or pseudorandom\('rarity'\.\.G\.GAME\.round_resets\.ante\.\.\(_append or ''\)\) \n[\s\S]{12}rarity = \(_legendary and 4\) or \(rarity > 0\.95 and 3\) or \(rarity > 0\.7 and 2\) or 1''' -position = "at" -payload = ''' -_rarity = (_legendary and 4) or (type(_rarity) == "number" and ((_rarity > 0.95 and 3) or (_rarity > 0.7 and 2) or 1)) or _rarity -_rarity = ({Common = 1, Uncommon = 2, Rare = 3, Legendary = 4})[_rarity] or _rarity -local rarity = _rarity or SMODS.poll_rarity("Joker", 'rarity'..G.GAME.round_resets.ante..(_append or '')) -''' - -## Ensure that other cards set to string rarity work the same as set for int rarity -# Card:calculate_joker -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = "if self.ability.name == 'Baseball Card' and context.other_joker.config.center.rarity == 2 and self ~= context.other_joker then" -position = "at" -payload = '''if self.ability.name == 'Baseball Card' and (context.other_joker.config.center.rarity == 2 or context.other_joker.config.center.rarity == "Uncommon") and self ~= context.other_joker then''' -match_indent = true diff --git a/smods-main/lovely/seal.toml b/smods-main/lovely/seal.toml deleted file mode 100644 index 2b65828..0000000 --- a/smods-main/lovely/seal.toml +++ /dev/null @@ -1,222 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -### Seal API -# Card:open() -[[patches]] -[patches.regex] -target = 'card.lua' -pattern = ''' -(?[\t ]*)local seal_rate = 10 -[\n\t ]*local seal_poll = pseudorandom\(pseudoseed\('stdseal'..G.GAME.round_resets.ante\)\) -[\n\t ]*if seal_poll > 1 - 0.02\*seal_rate then -[\n\t ]*local seal_type = pseudorandom\(pseudoseed\('stdsealtype'..G.GAME.round_resets.ante\)\) -[\n\t ]*if seal_type > 0.75 then card:set_seal\('Red'\) -[\n\t ]*elseif seal_type > 0.5 then card:set_seal\('Blue'\) -[\n\t ]*elseif seal_type > 0.25 then card:set_seal\('Gold'\) -[\n\t ]*else card:set_seal\('Purple'\) -[\n\t ]*end -[\n\t ]*end''' -position = 'at' -line_prepend = '$indent' -payload = ''' -card:set_seal(SMODS.poll_seal({mod = 10}))''' - -# Card:calculate_joker() -[[patches]] -[patches.regex] -target = 'card.lua' -pattern = ''' -(?[\t ]*)local seal_type = pseudorandom\(pseudoseed\('certsl'\)\) -[\n\t ]*if seal_type > 0.75 then _card:set_seal\('Red', true\) -[\n\t ]*elseif seal_type > 0.5 then _card:set_seal\('Blue', true\) -[\n\t ]*elseif seal_type > 0.25 then _card:set_seal\('Gold', true\) -[\n\t ]*else _card:set_seal\('Purple', true\) -[\n\t ]*end''' -position = 'at' -line_prepend = '$indent' -payload = '''_card:set_seal(SMODS.poll_seal({guaranteed = true, type_key = 'certsl'}))''' - -# get_badge_colour() -[[patches]] -[patches.pattern] -target = 'functions/UI_definitions.lua' -pattern = 'return G.BADGE_COL[key] or {1, 0, 0, 1}' -position = 'before' -match_indent = true -payload = ''' -for k, v in pairs(SMODS.Seals) do - G.BADGE_COL[k:lower()..'_seal'] = v.badge_colour -end''' - -# Card:calculate_seal() -[[patches]] -[patches.regex] -target = "card.lua" -pattern = 'function Card:calculate_seal\(context\)\n(?[\t ]*)if self.debuff then return nil end' -position = 'after' -line_prepend = '$indent' -payload = ''' -local obj = G.P_SEALS[self.seal] or {} -if obj.calculate and type(obj.calculate) == 'function' then - local o = obj:calculate(self, context) - if o then - if not o.card then o.card = self end - return o - end -end''' - -# Card:update() -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = 'if G.STAGE == G.STAGES.RUN then' -position = 'before' -match_indent = true -payload = ''' -local obj = G.P_SEALS[self.seal] or {} -if obj.update and type(obj.update) == 'function' then - obj:update(self, dt) -end''' - -# Card:get_p_dollars() -[[patches]] -[patches.regex] -target = "card.lua" -pattern = '''(?[\t ]*)if (?self\.seal == 'Gold' then\n)''' -position = 'at' -line_prepend = '$indent' -payload = ''' -local obj = G.P_SEALS[self.seal] or {} -if obj.get_p_dollars and type(obj.get_p_dollars) == 'function' then - ret = ret + obj:get_p_dollars(self) -elseif $cond''' - -# generate_card_ui() -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -pattern = "if v == 'gold_seal'*" -match_indent = true -position = 'before' -payload = ''' -local seal = G.P_SEALS[v] or G.P_SEALS[SMODS.Seal.badge_to_key[v] or ''] -if seal then - info_queue[#info_queue+1] = seal -else''' -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -pattern = "if v == 'purple_seal'*" -match_indent = true -position = 'after' -payload = 'end' - -[[patches]] -[patches.regex] -target = 'functions/common_events.lua' -position = 'at' -pattern = '''\{key = (?'.*?_seal'), set = 'Other'\}''' -payload = '''G.P_SEALS[$badge] or G.P_SEALS[SMODS.Seal.badge_to_key[$badge] or '']''' - -# Card:update_alert() -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = "function Card:update_alert()" -match_indent = true -position = 'after' -payload = ''' - if self.ability.set == 'Default' and self.config.center and self.config.center.key == 'c_base' and self.seal then - if G.P_SEALS[self.seal].alerted and self.children.alert then - self.children.alert:remove() - self.children.alert = nil - elseif not G.P_SEALS[self.seal].alerted and not self.children.alert and G.P_SEALS[self.seal].discovered then - self.children.alert = UIBox{ - definition = create_UIBox_card_alert(), - config = {align="tli", - offset = {x = 0.1, y = 0.1}, - parent = self} - } - end - end''' - -# Card:hover() -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = "G:save_progress()" -match_indent = false -position = "after" -payload = ''' - elseif self.children.alert and self.seal and not G.P_SEALS[self.seal].alerted then - G.P_SEALS[self.seal].alerted = true - G:save_progress()''' - -# Game:init_item_prototypes() -[[patches]] -[patches.regex] -target = 'game.lua' -pattern = '''(?[\t ]*)Gold =[ {A-z=1-4,"}\n]*},[\n\t ]*}''' -position = 'at' -line_prepend = '$indent' -payload = ''' -Red = {order = 1, discovered = false, set = "Seal"}, -Blue = {order = 2, discovered = false, set = "Seal"}, -Gold = {order = 3, discovered = false, set = "Seal"}, -Purple = {order = 4, discovered = false, set = "Seal"}, -} -''' - -# Card:set_seal() -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = '''G.CONTROLLER.locks.seal = true''' -position = 'after' -match_indent = true -payload = '''local sound = G.P_SEALS[_seal].sound or {sound = 'gold_seal', per = 1.2, vol = 0.4}''' -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = '''play_sound('gold_seal', 1.2, 0.4)''' -position = 'at' -match_indent = true -payload = '''play_sound(sound.sound, sound.per, sound.vol)''' -## Populate Seal Ability Table -[[patches]] -[patches.pattern] -target = 'card.lua' -pattern = '''self.seal = _seal''' -position = 'after' -match_indent = true -payload = ''' -self.ability.seal = {} -for k, v in pairs(G.P_SEALS[_seal].config or {}) do - if type(v) == 'table' then - self.ability.seal[k] = copy_table(v) - else - self.ability.seal[k] = v - end -end -''' - -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -pattern = '''new_card:set_seal(other.seal, true)''' -position = 'after' -match_indent = true -payload = ''' -if other.seal then - for k, v in pairs(other.ability.seal or {}) do - if type(v) == 'table' then - new_card.ability.seal[k] = copy_table(v) - else - new_card.ability.seal[k] = v - end - end -end -''' \ No newline at end of file diff --git a/smods-main/lovely/sound.toml b/smods-main/lovely/sound.toml deleted file mode 100644 index 481300e..0000000 --- a/smods-main/lovely/sound.toml +++ /dev/null @@ -1,167 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -#modulate_sound() -[[patches]] -[patches.pattern] -target = 'functions/misc_functions.lua' -pattern = 'G.SOUND_MANAGER.channel:push(G.ARGS.push)' -match_indent = true -position = 'after' -payload = ''' -SMODS.previous_track = SMODS.previous_track or '' -local in_sync = (SMODS.Sounds[desired_track] or {}).sync -local out_sync = (SMODS.Sounds[SMODS.previous_track] or {}).sync -local should_sync = true -if (type(in_sync) == 'table' and not in_sync[SMODS.previous_track]) or in_sync == false then should_sync = false end -if (type(out_sync) == 'table' and not out_sync[desired_track]) or out_sync == false then should_sync = false end -if - SMODS.previous_track and SMODS.previous_track ~= desired_track and - not should_sync -then - G.ARGS.push.type = 'restart_music' - G.SOUND_MANAGER.channel:push(G.ARGS.push) -end -SMODS.previous_track = desired_track''' - -[[patches]] -[patches.pattern] -target = 'functions/misc_functions.lua' -pattern = 'G.ARGS.push.ambient_control = G.SETTINGS.ambient_control' -match_indent = true -position = 'after' -payload = ''' -if SMODS.remove_replace_sound and SMODS.remove_replace_sound ~= desired_track then - SMODS.Sound.replace_sounds[SMODS.remove_replace_sound] = nil - SMODS.remove_replace_sound = nil -end -local replace_sound = SMODS.Sound.replace_sounds[desired_track] -if replace_sound then - local replaced_track = desired_track - desired_track = replace_sound.key - G.ARGS.push.desired_track = desired_track - if SMODS.previous_track ~= desired_track then - if replace_sound.times > 0 then replace_sound.times = replace_sound.times - 1 end - if replace_sound.times == 0 then SMODS.remove_replace_sound = replaced_track end - end -end -local stop_sound = SMODS.Sound.stop_sounds[desired_track] -if SMODS.Sound.stop_sounds[desired_track] then - if SMODS.previous_track ~= '' and stop_sound > 0 then stop_sound = stop_sound - 1 end - SMODS.Sound.stop_sounds[desired_track] = stop_sound ~= 0 and stop_sound or nil - SMODS.previous_track = '' - return -end -''' - -[[patches]] -[patches.pattern] -target = 'functions/misc_functions.lua' -pattern = "(G.STATE == G.STATES.SPLASH and '') or" -match_indent = true -position = 'after' -payload = 'SMODS.Sound:get_current_music() or' - -# PLAY_SOUND -[[patches]] -[patches.pattern] -target = 'engine/sound_manager.lua' -pattern = '''local s = {sound = love.audio.newSource("resources/sounds/"..args.sound_code..'.ogg', should_stream and "stream" or 'static')}''' -match_indent = true -position = 'at' -payload = ''' -local c = SMODS_Sounds[args.sound_code] -local s = c and -{sound = love.audio.newSource(love.sound.newDecoder(c.data), c.should_stream and 'stream' or 'static'), per = c.per, vol = c.vol } or -{sound = love.audio.newSource("resources/sounds/"..args.sound_code..'.ogg', should_stream and "stream" or 'static')}''' - -# pass in custom sounds -[[patches]] -[patches.pattern] -target = 'engine/sound_manager.lua' -pattern = "DISABLE_SFX = false" -match_indent = true -position = 'after' -payload = ''' -SMODS_Sounds = {} -''' -[[patches]] -[patches.pattern] -target = 'engine/sound_manager.lua' -pattern = "elseif request.type == 'stop' then" -match_indent = true -position = 'before' -payload = ''' -elseif request.type == 'sound_source' then - SMODS_Sounds[request.sound_code] = { - sound_code = request.sound_code, - data = request.data, - sound = sound, - per = request.per, - vol = request.vol, - } - SOURCES[request.sound_code] = {} -''' - -[[patches]] -[patches.pattern] -target = 'engine/sound_manager.lua' -pattern = "s.original_pitch = args.per or 1" -match_indent = true -position = 'at' -payload = 's.original_pitch = ((args.type ~= "sound") and s.per) or args.per or 1' - -[[patches]] -[patches.pattern] -target = 'engine/sound_manager.lua' -pattern = "s.original_volume = args.vol or 1" -match_indent = true -position = 'at' -payload = 's.original_volume = ((args.type ~= "sound") and s.vol) or args.vol or 1' - -# don't crash RESTART_MUSIC - -[[patches]] -[patches.pattern] -target = 'engine/sound_manager.lua' -pattern = "RESTART_MUSIC()" -match_indent = true -position = 'at' -payload = 'RESTART_MUSIC(request)' - -# fix looping for music of different length - -[[patches]] -[patches.regex] -target = 'engine/sound_manager.lua' -pattern = """(?[\t ]*)function MODULATE\\(args\\)(\n.*){9}""" -line_prepend = '$indent' -position = 'at' -payload = """function MODULATE(args) - if args.desired_track ~= '' then - local sound = ((SOURCES[current_track or {}] or {})[1] or {}).sound - if not sound or not sound:isPlaying() then - RESTART_MUSIC(args) - end - end -""" -[[patches]] -[patches.pattern] -target = 'engine/sound_manager.lua' -pattern = "for _, s in pairs(v) do" -match_indent = true -position = 'at' -payload = """current_track = args.desired_track -for _, s in pairs(v) do""" - -# [[patches]] -# [patches.pattern] -# target = 'engine/sound_manager.lua' -# pattern = 'if s.sound and not s.sound:isPlaying() then' -# match_indent = true -# position = 'at' -# payload = '''if s.sound and s.sound:isPlaying() then -# s.sound:stop() -# elseif s.sound and not s.sound:isPlaying() then''' diff --git a/smods-main/lovely/stake.toml b/smods-main/lovely/stake.toml deleted file mode 100644 index 839175f..0000000 --- a/smods-main/lovely/stake.toml +++ /dev/null @@ -1,190 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -# Fix areas where highest stake is hardcoded as Gold Stake -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = "if G.PROFILES[G.SETTINGS.profile].all_unlocked then max_stake = 8 end" -position = "at" -payload = "if G.PROFILES[G.SETTINGS.profile].all_unlocked then max_stake = #G.P_CENTER_POOLS['Stake'] end" -match_indent = true - -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = "for i = 1, math.min(max_stake+1, 8) do" -position = "at" -payload = "for i = 1, math.min(max_stake+1, #G.P_CENTER_POOLS['Stake']) do" -match_indent = true - -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = "if G.GAME.stake >= 8 then" -position = "at" -payload = "if G.GAME.stake >= #G.P_CENTER_POOLS['Stake'] then" -match_indent = true - -# Stake modifier API -[[patches]] -[patches.pattern] -target = "game.lua" -pattern = "if self.GAME.stake >= 2 then" -position = "before" -payload = "if false then" -match_indent = true - -[[patches]] -[patches.pattern] -target = "game.lua" -pattern = "if self.GAME.stake >= 8 then self.GAME.modifiers.enable_rentals_in_shop = true end" -position = "after" -payload = "end SMODS.setup_stake(self.GAME.stake)" -match_indent = true - -# Stake shininess API -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = "if _stake == 8 then" -position = "at" -payload = "if G.P_CENTER_POOLS['Stake'][_stake].shiny then" -match_indent = true - -# Override stake listing to make room for our recursive version -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = "for i = G.GAME.stake-1, 2, -1 do" -position = "before" -payload = "if false then" -match_indent = true - -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = 'other_col = {n=G.UIT.R, config={align = "cm", padding = 0.05, r = 0.1, colour = G.C.L_BLACK}, nodes=stake_desc_rows}' -position = "before" -payload = "end SMODS.applied_stakes_UI(G.GAME.stake, stake_desc_rows)" -match_indent = true - -# Set win stake to that specified in unlocked stake -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = 'for i = 1, G.GAME.stake do' -position = "at" -payload = '''for i = 1, -(G.P_CENTER_POOLS["Stake"][G.GAME.stake].unlocked_stake) and -(G.P_STAKES[G.P_CENTER_POOLS["Stake"][G.GAME.stake].unlocked_stake].stake_level-1) or (G.GAME.stake-1) -do''' -match_indent = true - -# Stake Sprites -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = 'local stake_sprite = Sprite(0,0,_scale*1,_scale*1,G.ASSET_ATLAS["chips"], G.P_CENTER_POOLS.Stake[_stake].pos)' -position = "at" -payload = 'local stake_sprite = Sprite(0,0,_scale*1,_scale*1,G.ASSET_ATLAS[G.P_CENTER_POOLS.Stake[_stake].atlas], G.P_CENTER_POOLS.Stake[_stake].pos)' -match_indent = true - -# Achievements and unlocks -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = 'if highest_win >= 2 then' -position = "at" -payload = 'if highest_win >= G.P_STAKES["stake_red"].stake_level then' -match_indent = true - -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = 'if highest_win >= 4 then' -position = "at" -payload = 'if highest_win >= G.P_STAKES["stake_black"].stake_level then' -match_indent = true - -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = 'if highest_win >= 8 then' -position = "at" -payload = 'if highest_win >= G.P_STAKES["stake_gold"].stake_level then' -match_indent = true - -# get_blind_amount -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = 'function get_blind_amount(ante)' -position = "after" -payload = '''if G.GAME.modifiers.scaling and G.GAME.modifiers.scaling > 3 then return SMODS.get_blind_amount(ante) end''' -match_indent = true - -# set_joker_usage -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = 'G.PROFILES[G.SETTINGS.profile].joker_usage[v.config.center_key] = {count = 1, order = v.config.center.order, wins = {}, losses = {}}' -position = "at" -payload = 'G.PROFILES[G.SETTINGS.profile].joker_usage[v.config.center_key] = {count = 1, order = v.config.center.order, wins = {}, losses = {}, wins_by_key = {}, losses_by_key = {}}' -match_indent = true - -# set_joker_win -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = 'G.PROFILES[G.SETTINGS.profile].joker_usage[v.config.center_key] = G.PROFILES[G.SETTINGS.profile].joker_usage[v.config.center_key] or {count = 1, order = v.config.center.order, wins = {}, losses = {}}' -position = "at" -payload = 'G.PROFILES[G.SETTINGS.profile].joker_usage[v.config.center_key] = G.PROFILES[G.SETTINGS.profile].joker_usage[v.config.center_key] or {count = 1, order = v.config.center.order, wins = {}, losses = {}, wins_by_key = {}, losses_by_key = {}}' -match_indent = true - -#set_joker_win -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = 'G.PROFILES[G.SETTINGS.profile].joker_usage[v.config.center_key].wins[G.GAME.stake] = (G.PROFILES[G.SETTINGS.profile].joker_usage[v.config.center_key].wins[G.GAME.stake] or 0) + 1' -position = "after" -payload = 'G.PROFILES[G.SETTINGS.profile].joker_usage[v.config.center_key].wins_by_key[SMODS.stake_from_index(G.GAME.stake)] = (G.PROFILES[G.SETTINGS.profile].joker_usage[v.config.center_key].wins_by_key[SMODS.stake_from_index(G.GAME.stake)] or 0) + 1' -match_indent = true - -#set_joker_loss -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = 'G.PROFILES[G.SETTINGS.profile].joker_usage[v.config.center_key].losses[G.GAME.stake] = (G.PROFILES[G.SETTINGS.profile].joker_usage[v.config.center_key].losses[G.GAME.stake] or 0) + 1' -position = "after" -payload = 'G.PROFILES[G.SETTINGS.profile].joker_usage[v.config.center_key].losses_by_key[SMODS.stake_from_index(G.GAME.stake)] = (G.PROFILES[G.SETTINGS.profile].joker_usage[v.config.center_key].losses_by_key[SMODS.stake_from_index(G.GAME.stake)] or 0) + 1' -match_indent = true - -# set_deck_usage -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = 'G.PROFILES[G.SETTINGS.profile].deck_usage[deck_key] = {count = 1, order = G.GAME.selected_back.effect.center.order, wins = {}, losses = {}}' -position = "at" -payload = 'G.PROFILES[G.SETTINGS.profile].deck_usage[deck_key] = {count = 1, order = G.GAME.selected_back.effect.center.order, wins = {}, losses = {}, wins_by_key = {}, losses_by_key = {}}' -match_indent = true - -# set_deck_loss -[[patches]] -[patches.pattern] -target = "functions/misc_functions.lua" -pattern = 'if not G.PROFILES[G.SETTINGS.profile].deck_usage[deck_key] then G.PROFILES[G.SETTINGS.profile].deck_usage[deck_key] = {count = 1, order = G.GAME.selected_back.effect.center.order, wins = {}, losses = {}} end' -position = "at" -payload = 'if not G.PROFILES[G.SETTINGS.profile].deck_usage[deck_key] then G.PROFILES[G.SETTINGS.profile].deck_usage[deck_key] = {count = 1, order = G.GAME.selected_back.effect.center.order, wins = {}, losses = {}, wins_by_key = {}, losses_by_key = {}} end' -match_indent = true - -# G.UIDEF.viewed_stake_option -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = 'G.viewed_stake = math.min(max_stake+1, G.viewed_stake)' -position = "after" -payload = '''if G.viewed_stake > #G.P_CENTER_POOLS.Stake then G.viewed_stake = #G.P_CENTER_POOLS.Stake end''' -match_indent = true diff --git a/smods-main/lovely/sticker.toml b/smods-main/lovely/sticker.toml deleted file mode 100644 index 92e329c..0000000 --- a/smods-main/lovely/sticker.toml +++ /dev/null @@ -1,132 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -### Sticker API - -# generate_UIBox_ability_table() -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = "if self.sticker or ((self.sticker_run and self.sticker_run~='NONE') and G.SETTINGS.run_stake_stickers) then loc_vars = loc_vars or {}; loc_vars.sticker=(self.sticker or self.sticker_run) end" -position = "before" -match_indent = true -payload = ''' -for k, v in ipairs(SMODS.Sticker.obj_buffer) do - if self.ability[v] and not SMODS.Stickers[v].hide_badge then - badges[#badges+1] = v - end -end''' - -# generate_card_ui() -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = "if v == 'eternal' then*" -match_indent = true -position = "before" -payload = ''' -local sticker = SMODS.Stickers[v] -if sticker then - local t = { key = v, set = 'Other' } - local res = {} - if sticker.loc_vars and type(sticker.loc_vars) == 'function' then - res = sticker:loc_vars(info_queue, card) or {} - t.vars = res.vars or {} - t.key = res.key or t.key - t.set = res.set or t.set - end - info_queue[#info_queue+1] = t -else''' - -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = "if v == 'rental' then*" -match_indent = true -position = "after" -payload = '''end''' - -# create_card() -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = "if card.ability.consumeable and not skip_materialize then card:start_materialize() end" -position = "after" -match_indent = true -payload = ''' -for k, v in ipairs(SMODS.Sticker.obj_buffer) do - local sticker = SMODS.Stickers[v] - if sticker.should_apply and type(sticker.should_apply) == 'function' and sticker:should_apply(card, center, area) then - sticker:apply(card, true) - end -end''' - -## Remove base game sticker rolls if one is added -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = "if G.GAME.modifiers.enable_eternals_in_shop and eternal_perishable_poll > 0.7 then" -position = "at" -match_indent = true -payload = '''if G.GAME.modifiers.enable_eternals_in_shop and eternal_perishable_poll > 0.7 and not SMODS.Stickers["eternal"].should_apply then''' - -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = "elseif G.GAME.modifiers.enable_perishables_in_shop and ((eternal_perishable_poll > 0.4) and (eternal_perishable_poll <= 0.7)) then" -position = "at" -match_indent = true -payload = '''elseif G.GAME.modifiers.enable_perishables_in_shop and ((eternal_perishable_poll > 0.4) and (eternal_perishable_poll <= 0.7)) and not SMODS.Stickers["perishable"].should_apply then''' - -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = "if G.GAME.modifiers.enable_rentals_in_shop and pseudorandom((area == G.pack_cards and 'packssjr' or 'ssjr')..G.GAME.round_resets.ante) > 0.7 then" -position = "at" -match_indent = true -payload = '''if G.GAME.modifiers.enable_rentals_in_shop and pseudorandom((area == G.pack_cards and 'packssjr' or 'ssjr')..G.GAME.round_resets.ante) > 0.7 and not SMODS.Stickers["rental"].should_apply then''' - -# Card:draw() -[[patches]] -[patches.pattern] -target = "card.lua" -pattern = '''if self.ability.name == 'The Soul' and (self.config.center.discovered or self.bypass_discovery_center) then''' -match_indent = true -position = "before" -payload = ''' -for k, v in pairs(SMODS.Stickers) do - if self.ability[v.key] then - if v and v.draw and type(v.draw) == 'function' then - v:draw(self, layer) - else - G.shared_stickers[v.key].role.draw_major = self - G.shared_stickers[v.key]:draw_shader('dissolve', nil, nil, nil, self.children.center) - G.shared_stickers[v.key]:draw_shader('voucher', nil, self.ARGS.send_to_shader, nil, self.children.center) - end - end -end -''' - -# get_badge_colour() -[[patches]] -[patches.pattern] -target = 'functions/UI_definitions.lua' -pattern = 'return G.BADGE_COL[key] or {1, 0, 0, 1}' -position = 'before' -match_indent = true -payload = ''' -for k, v in pairs(SMODS.Stickers) do - G.BADGE_COL[k] = v.badge_colour -end''' - -## Remove Pinned effect when in Sticker collections -# CardArea:aling_cards -[[patches]] -[patches.pattern] -target = 'cardarea.lua' -pattern = '''table.sort(self.cards, function (a, b) return a.T.x + a.T.w/2 - 100*(a.pinned and a.sort_id or 0) < b.T.x + b.T.w/2 - 100*(b.pinned and b.sort_id or 0) end)''' -position = 'at' -match_indent = true -payload = '''table.sort(self.cards, function (a, b) return a.T.x + a.T.w/2 - 100*((a.pinned and not a.ignore_pinned) and a.sort_id or 0) < b.T.x + b.T.w/2 - 100*((b.pinned and not b.ignore_pinned) and b.sort_id or 0) end)''' diff --git a/smods-main/lovely/tag.toml b/smods-main/lovely/tag.toml deleted file mode 100644 index 7a885e3..0000000 --- a/smods-main/lovely/tag.toml +++ /dev/null @@ -1,139 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -### Tag API -# Tag:apply_to_run() -[[patches]] -[patches.pattern] -target = "tag.lua" -pattern = "function Tag:apply_to_run(_context)" -position = 'after' -match_indent = true -payload = ''' - if self.triggered then return end - local obj = SMODS.Tags[self.key] - local res - if obj and obj.apply and type(obj.apply) == 'function' then - res = obj:apply(self, _context) - end - if res then return res end -''' - -# Tag:set_ability() -[[patches]] -[patches.pattern] -target = "tag.lua" -pattern = "function Tag:set_ability()" -position = 'after' -match_indent = true -payload = ''' - local obj = SMODS.Tags[self.key] - local res - if obj and obj.set_ability and type(obj.set_ability) == 'function' then - obj:set_ability(self) - end -''' - -# create_UIBox_your_collection_tags() -[[patches]] -[patches.regex] -target = "functions/UI_definitions.lua" -pattern = "(?[\t ]*)local tag_matrix = \\{(\n.*){6}" -position = 'at' -line_prepend = '$indent' -payload = ''' -local tag_matrix = {} -local counter = 0 -local tag_tab = {} -local tag_pool = {} -if G.ACTIVE_MOD_UI then - for k, v in pairs(G.P_TAGS) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id then tag_pool[k] = v end - end -else - tag_pool = G.P_TAGS -end -for k, v in pairs(tag_pool) do - counter = counter + 1 - tag_tab[#tag_tab+1] = v -end -for i = 1, math.ceil(counter / 6) do - table.insert(tag_matrix, {}) -end''' - -[[patches]] -[patches.regex] -target = "functions/UI_definitions.lua" -pattern = '''(?[\t ]*)v\.children\.alert\.states\.collide\.can = false\n[\s\S]{8}end\n[\s\S]{8}return true\n[\s\S]{4}end\)\n[\s\S]{2}\}\)\)\n{3}''' -position = 'after' -line_prepend = '$indent' -payload = ''' -local table_nodes = {} -for i = 1, math.ceil(counter / 6) do - table.insert(table_nodes, {n=G.UIT.R, config={align = "cm"}, nodes=tag_matrix[i]}) -end''' - -[[patches]] -[patches.regex] -target = "functions/UI_definitions.lua" -pattern = '''(?[\t ]*)\{\n[\s\S]{10}\{n=G\.UIT\.R, config=\{align = "cm"\}, nodes=tag_matrix\[1\]},[\s\S]*tag_matrix\[4\]\},\n[\s\S]{8}\}''' -position = 'at' -line_prepend = '$indent' -payload = '''table_nodes''' - -# Tag:generate_UI() -[[patches]] -[patches.regex] -target = "tag.lua" -pattern = 'G.ASSET_ATLAS\["tags"\]' -position = 'at' -payload = 'G.ASSET_ATLAS[(not self.hide_ability) and G.P_TAGS[self.key].atlas or "tags"]' - -# Tag:get_uibox_table() -[[patches]] -[patches.pattern] -target = "tag.lua" -pattern = '''function Tag:get_uibox_table(tag_sprite)''' -position = 'at' -match_indent = true -payload = '''function Tag:get_uibox_table(tag_sprite, vars_only)''' -[[patches]] -[patches.pattern] -target = "tag.lua" -pattern = '''tag_sprite.ability_UIBox_table = generate_card_ui(G.P_TAGS[self.key], nil, loc_vars, (self.hide_ability) and 'Undiscovered' or 'Tag', nil, (self.hide_ability))''' -position = 'at' -match_indent = true -payload = '''if vars_only then return loc_vars end -tag_sprite.ability_UIBox_table = generate_card_ui(G.P_TAGS[self.key], nil, loc_vars, (self.hide_ability) and 'Undiscovered' or 'Tag', nil, (self.hide_ability), nil, nil, self)''' - -# generate_card_ui() - -[[patches]] -[patches.pattern] -target = "functions/common_events.lua" -pattern = "elseif _c.set == 'Tag' then" -position = "after" -match_indent = true -payload = '''specific_vars = specific_vars or Tag.get_uibox_table({ name = _c.name, config = _c.config, ability = { orbital_hand = '['..localize('k_poker_hand')..']' }}, nil, true) -''' - -# Prevent Boss Tag from crashing when triggered at a bad time -# by quietly rerolling it if blind select UI is not there -[[patches]] -[patches.pattern] -target = "functions/button_callbacks.lua" -pattern = "G.FUNCS.reroll_boss = function(e)" -position = "after" -match_indent = true -payload = '''if not G.blind_select_opts then - G.GAME.round_resets.boss_rerolled = true - if not G.from_boss_tag then ease_dollars(-10) end - G.from_boss_tag = nil - G.GAME.round_resets.blind_choices.Boss = get_new_boss() - for i = 1, #G.GAME.tags do - if G.GAME.tags[i]:apply_to_run({type = 'new_blind_choice'}) then break end - end - return true -end''' \ No newline at end of file diff --git a/smods-main/lovely/threads.toml b/smods-main/lovely/threads.toml deleted file mode 100644 index 85c2580..0000000 --- a/smods-main/lovely/threads.toml +++ /dev/null @@ -1,30 +0,0 @@ -# Necessary to kill threads which lets us restart the game. - -[manifest] -version = "1.0.0" -dump_lua = true -priority = -5 - -[[patches]] -[patches.pattern] -target = "engine/save_manager.lua" -pattern = "if request then" -position = "after" -payload = "if request.type == 'kill' then return end" -match_indent = true - -[[patches]] -[patches.pattern] -target = "engine/http_manager.lua" -pattern = "if request then" -position = "after" -payload = "if request.type == 'kill' then return end" -match_indent = true - -[[patches]] -[patches.pattern] -target = "engine/sound_manager.lua" -pattern = "if request then" -position = "after" -payload = "if request.type == 'kill' then return end" -match_indent = true diff --git a/smods-main/lovely/ui.toml b/smods-main/lovely/ui.toml deleted file mode 100644 index 5a2eff1..0000000 --- a/smods-main/lovely/ui.toml +++ /dev/null @@ -1,213 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -### Addition Tab - -## Decks tab -# create_UIBox_your_collection_decks() -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = '''G.GAME.viewed_back = Back(G.P_CENTERS.b_red)''' -position = "at" -payload = ''' -local deck_pool = SMODS.collection_pool(G.P_CENTER_POOLS.Back) -G.GAME.viewed_back = Back(G.ACTIVE_MOD_UI and deck_pool[1] or G.P_CENTERS.b_red)''' -match_indent = true - -# create_UIBox_your_collection_decks() -[[patches]] -[patches.regex] -target = 'functions/UI_definitions.lua' -pattern = '''(?[\t ]*)for k, v in ipairs\(G\.P_CENTER_POOLS\.Back\) do\n[\s\S]{4}ordered_names\[#ordered_names\+1\] = v\.name\n[\s\S]{2}end''' -position = 'at' -payload = ''' -for k, v in ipairs(deck_pool) do - ordered_names[#ordered_names+1] = v.key -end''' -line_prepend = '$indent' - -# create_UIBox_your_collection_decks() -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = '''local t = create_UIBox_generic_options({ back_func = 'your_collection', contents = {''' -position = "at" -payload = '''local t = create_UIBox_generic_options({ back_func = G.ACTIVE_MOD_UI and "openModUI_"..G.ACTIVE_MOD_UI.id or 'your_collection', contents = {''' -match_indent = true - -# G.FUNCS.your_collection_deck_page -[[patches]] -[patches.pattern] -target = "functions/button_callbacks.lua" -pattern = '''G.GAME.viewed_back:change_to(G.P_CENTER_POOLS.Back[args.to_key])''' -position = "at" -payload = ''' -local deck_pool = SMODS.collection_pool(G.P_CENTER_POOLS.Back) -G.GAME.viewed_back:change_to(deck_pool[args.to_key])''' -match_indent = true - -# create_UIBox_your_collection() -[[patches]] -[patches.regex] -target = 'functions/UI_definitions.lua' -pattern = '''(?[\t ]*)UIBox_button\(\{button = 'your_collection_blinds', label = \{localize\('b_blinds'\)\}, count = G\.DISCOVER_TALLIES\.blinds, minw = 5, minh = 2.0, id = 'your_collection_blinds', focus_args = \{snap_to = true\}\}\),''' -position = 'after' -payload = '''UIBox_button({button = 'your_collection_other_gameobjects', label = {localize('k_other')}, minw = 5, id = 'your_collection_other_gameobjects', focus_args = {snap_to = true}}),''' - -# Fix UIElement.config.chosen being overriden if choice=true is set -# UIElement:click() -[[patches]] -[patches.pattern] -target = "engine/ui.lua" -match_indent = true -position = "after" -pattern = "if self.config.choice then" -payload = " local chosen_temp = self.config.chosen" - -[[patches]] -[patches.pattern] -target = "engine/ui.lua" -match_indent = true -position = "at" -pattern = "self.config.chosen = true" -payload = "self.config.chosen = chosen_temp or true" - -# Escape from mod menu saves config -# Needs to be before all checks -[[patches]] -[patches.pattern] -target = 'engine/controller.lua' -pattern = "function Controller:key_press_update(key, dt)" -position = "after" -payload = ''' - if key == "escape" and G.ACTIVE_MOD_UI then - G.FUNCS.exit_mods() - end -''' -match_indent = true - -[[patches]] -[patches.regex] -target = 'functions/UI_definitions.lua' -position = 'before' -line_prepend = '$indent' -pattern = ''' -(?[\t ]*)return \{n=G\.UIT\.ROOT, config = \{align = 'cm', colour = G\.C\.CLEAR\}, nodes=\{ -[\t ]*\{n=G\.UIT\.C,''' -payload = ''' -local cols -if #info_boxes <= 3 then - cols = 1 -elseif #info_boxes <= 10 then - cols = 2 -elseif #info_boxes <= 24 then - cols = 3 -else - cols = 4 -end -local nodes_per_col = math.ceil(#info_boxes/cols) -local info_cols = {} -for i = 0, cols-1 do - local col = {} - for j = 1, nodes_per_col do - local info_box = info_boxes[i*nodes_per_col+j] - if info_box then - table.insert(col, info_box) - else break end - end - table.insert(info_cols, {n=G.UIT.C, config = {align="cm"}, nodes = col}) -end -info_boxes = {{n=G.UIT.R, config = {align="cm", padding = 0.05, card_pos = card.T.x }, nodes = info_cols}} -''' - -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -match_indent = true -position = 'at' -pattern = "config = {offset = {x=-0.03,y=0}, align = 'cl', parent = e}" -payload = """config = (not e.config.ref_table or not e.config.ref_table[1].config.card_pos or e.config.ref_table[1].config.card_pos > G.ROOM.T.w*0.4) and - {offset = {x=-0.03,y=0}, align = 'cl', parent = e} or - {offset = {x=0.03,y=0}, align = 'cr', parent = e}""" - -[[patches]] -[patches.pattern] -target = 'tag.lua' -match_indent = true -position = 'at' -pattern = "_self.config.h_popup_config ={align = 'cl', offset = {x=-0.1,y=0},parent = _self}" -payload = """_self.config.h_popup_config = (_self.T.x > G.ROOM.T.w*0.4) and - {align = 'cl', offset = {x=-0.1,y=0},parent = _self} or - {align = 'cr', offset = {x=0.1,y=0},parent = _self}""" - -# desc_from_rows -[[patches]] -[patches.regex] -target = 'functions/UI_definitions.lua' -position = 'at' -pattern = 'colour = empty and G\.C\.CLEAR or G\.C\.UI\.BACKGROUND_WHITE' -payload = 'colour = desc_nodes.background_colour or empty and G.C.CLEAR or G.C.UI.BACKGROUND_WHITE' - -# info_tip_from_rows -[[patches]] -[patches.regex] -target = 'functions/UI_definitions.lua' -position = 'at' -pattern = 'padding = 0\.05, colour = G\.C\.WHITE\}' -payload = 'padding = 0.05, colour = desc_nodes.background_colour or G.C.WHITE}' - -# localize -[[patches]] -[patches.regex] -target = 'functions/misc_functions.lua' -position = 'after' -pattern = '\(part\.control\.C and loc_colour\(part\.control\.C\)\)' -payload = ' or args.text_colour' - -[[patches]] -[patches.regex] -target = 'functions/misc_functions.lua' -position = 'at' -pattern = 'loc_colour\(part\.control\.C or nil, args\.default_col\)' -payload = 'not part.control.C and args.text_colour or loc_colour(part.control.C or nil, args.default_col)' - -[[patches]] -[patches.regex] -target = 'functions/misc_functions.lua' -position = 'after' -pattern = 'part\.control\.s and tonumber\(part\.control\.s\)' -payload = ' or args.scale ' - -# set_discover_tallies() -# exclude no_collection objects -[[patches]] -[patches.pattern] -target = 'functions/misc_functions.lua' -match_indent = true -position = 'at' -pattern = "if not v.omit then" -payload = "if not v.omit and not v.no_collection then" - -[[patches]] -[patches.regex] -target = 'functions/misc_functions.lua' -line_prepend = '$indent' -position = 'at' -pattern = '(?[\t ]*)(?for _, v in pairs\(G\.P_[BT].*)(?(\n.*){7})' -payload = '''$start - if not v.no_collection then - $rest -end -''' - -#set_alerts() -[[patches]] -[patches.pattern] -target = 'functions/common_events.lua' -match_indent = true -position = 'at' -pattern = "if v.discovered and not v.alerted then" -payload = "if v.discovered and not v.alerted and not v.no_collection then" diff --git a/smods-main/lovely/ui_elements.toml b/smods-main/lovely/ui_elements.toml deleted file mode 100644 index 96050d0..0000000 --- a/smods-main/lovely/ui_elements.toml +++ /dev/null @@ -1,121 +0,0 @@ -[manifest] -version = "1.0.0" -dump_lua = true -priority = -10 - -## colour argument fix -# create_tabs() -[[patches]] -[patches.pattern] -target = 'functions/UI_definitions.lua' -pattern = '''tab_buttons[#tab_buttons+1] = UIBox_button({id = 'tab_but_'..(v.label or ''), ref_table = v, button = 'change_tab', label = {v.label}, minh = 0.8*args.scale, minw = 2.5*args.scale, col = true, choice = true, scale = args.text_scale, chosen = v.chosen, func = v.func, focus_args = {type = 'none'}})''' -position = 'at' -payload = '''tab_buttons[#tab_buttons+1] = UIBox_button({id = 'tab_but_'..(v.label or ''), ref_table = v, button = 'change_tab', label = {v.label}, minh = 0.8*args.scale, minw = 2.5*args.scale, col = true, choice = true, scale = args.text_scale, chosen = v.chosen, func = v.func, colour = args.colour, focus_args = {type = 'none'}})''' -match_indent = true - -# UIElement:draw_self() -[[patches]] -[patches.pattern] -target = 'engine/ui.lua' -pattern = '''love.graphics.polygon("fill", get_chosen_triangle_from_rect(self.layered_parallax.x, self.layered_parallax.y, self.VT.w*G.TILESIZE, self.VT.h*G.TILESIZE, self.config.chosen == 'vert'))''' -position = 'before' -payload = '''love.graphics.setColor(self.config.colour)''' -match_indent = true - - -## multiple text input fix -# create_text_input() -[[patches]] -[patches.pattern] -target = 'functions/UI_definitions.lua' -pattern = '''args.current_prompt_text = ''''' -position = 'after' -payload = '''args.id = args.id or "text_input"''' -match_indent = true -[[patches]] -[patches.pattern] -target = 'functions/UI_definitions.lua' -pattern = '''ui_letters[#ui_letters+1] = {n=G.UIT.T, config={ref_table = args, ref_value = 'current_prompt_text', scale = args.text_scale, colour = lighten(copy_table(args.colour), 0.4), id = 'prompt'}}''' -position = 'at' -payload = '''ui_letters[#ui_letters+1] = {n=G.UIT.T, config={ref_table = args, ref_value = 'current_prompt_text', scale = args.text_scale, colour = lighten(copy_table(args.colour), 0.4), id = args.id..'_prompt'}}''' -match_indent = true -[[patches]] -[patches.pattern] -target = 'functions/UI_definitions.lua' -pattern = '''ui_letters[i] = {n=G.UIT.T, config={ref_table = text.letters, ref_value = i, scale = args.text_scale, colour = G.C.UI.TEXT_LIGHT, id = 'letter_'..i}}''' -position = 'at' -payload = '''ui_letters[i] = {n=G.UIT.T, config={ref_table = text.letters, ref_value = i, scale = args.text_scale, colour = G.C.UI.TEXT_LIGHT, id = args.id..'_letter_'..i}}''' -match_indent = true -[[patches]] -[patches.pattern] -target = 'functions/UI_definitions.lua' -pattern = '''ui_letters[#ui_letters+1] = {n=G.UIT.B, config={r = 0.03,w=0.1, h=0.4, colour = position_text_colour, id = 'position', func = 'flash'}}''' -position = 'at' -payload = '''ui_letters[#ui_letters+1] = {n=G.UIT.B, config={r = 0.03,w=0.1, h=0.4, colour = position_text_colour, id = args.id..'_position', func = 'flash'}}''' -match_indent = true -[[patches]] -[patches.pattern] -target = 'functions/UI_definitions.lua' -pattern = '''{n=G.UIT.C, config={align = "cm", draw_layer = 1, colour = G.C.CLEAR}, nodes = {''' -position = 'at' -payload = '''{n=G.UIT.C, config={align = "cm", colour = G.C.CLEAR}, nodes = {''' -match_indent = true -[[patches]] -[patches.pattern] -target = 'functions/UI_definitions.lua' -pattern = '''{n=G.UIT.C, config={id = 'text_input', align = "cm", padding = 0.05, r = 0.1, draw_layer = 2, hover = true, colour = args.colour,minw = args.w, min_h = args.h, button = 'select_text_input', shadow = true}, nodes={''' -position = 'at' -payload = '''{n=G.UIT.C, config={id = args.id, align = "cm", padding = 0.05, r = 0.1, hover = true, colour = args.colour,minw = args.w, min_h = args.h, button = 'select_text_input', shadow = true}, nodes={''' -match_indent = true - -# G.FUNCS.select_text_input -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -pattern = '''G.CONTROLLER.text_input_hook = e.children[1].children[1]''' -position = 'after' -payload = '''G.CONTROLLER.text_input_id = e.config.id''' -match_indent = true - -# G.FUNCS.paste_seed -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -pattern = '''G.CONTROLLER.text_input_hook = e.UIBox:get_UIE_by_ID('text_input').children[1].children[1]''' -position = 'after' -payload = """G.CONTROLLER.text_input_id = 'text_input'""" -match_indent = true - -# G.FUNCS.flash -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -pattern = '''if G.CONTROLLER.text_input_hook then''' -position = 'at' -payload = '''if G.CONTROLLER.text_input_hook and G.CONTROLLER.text_input_id == e.config.id:sub(1,string.len(G.CONTROLLER.text_input_id)) then''' -match_indent = true - -# TRANSPOSE_TEXT_INPUT() -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -pattern = '''if hook.children[i].config.id == 'position' then''' -position = 'at' -payload = '''if hook.children[i].config.id == G.CONTROLLER.text_input_id..'_position' then''' -match_indent = true -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -pattern = '''local real_letter = hook.children[position_child+dir].config.id:sub(1, 7) == 'letter_' and hook.children[position_child+dir].config.text ~= ''''' -position = 'at' -payload = '''local real_letter = hook.children[position_child+dir].config.id:sub(1, 8+string.len(G.CONTROLLER.text_input_id)) == G.CONTROLLER.text_input_id..'_letter_' and hook.children[position_child+dir].config.text ~= ''''' -match_indent = true - -# GET_TEXT_FROM_INPUT() -[[patches]] -[patches.pattern] -target = 'functions/button_callbacks.lua' -pattern = '''if hook.children[i].config and hook.children[i].config.id:sub(1, 7) == 'letter_' and hook.children[i].config.text ~= '' then''' -position = 'at' -payload = '''if hook.children[i].config and hook.children[i].config.id:sub(1, 8+string.len(G.CONTROLLER.text_input_id)) == G.CONTROLLER.text_input_id..'_letter_' and hook.children[i].config.text ~= '' then''' -match_indent = true diff --git a/smods-main/manifest.json b/smods-main/manifest.json deleted file mode 100644 index 0b06fff..0000000 --- a/smods-main/manifest.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "Steamodded", - "version_number": "0.9.8", - "website_url": "https://github.com/Steamopollys/Steamodded", - "description": "A Balatro ModLoader", - "dependencies": [ - "Thunderstore-lovely-0.3.1", - "metherul-nativefs-1.0.0" - ] -} diff --git a/smods-main/src/compat_0_9_8.lua b/smods-main/src/compat_0_9_8.lua deleted file mode 100644 index 7875d1c..0000000 --- a/smods-main/src/compat_0_9_8.lua +++ /dev/null @@ -1,536 +0,0 @@ -SMODS.compat_0_9_8 = {} -SMODS.compat_0_9_8.load_done = false - -function SMODS.compat_0_9_8.load() - if SMODS.compat_0_9_8.load_done then - return - end - - function SMODS.compat_0_9_8.delay_register(cls, self) - if self.delay_register then - self.delay_register = nil - return - end - cls.super.register(self) - end - - function SMODS.compat_0_9_8.joker_loc_vars(self, info_queue, card) - local vars, main_end - if self.loc_def and type(self.loc_def) == 'function' then - vars, main_end = self.loc_def(card, info_queue) - end - if self.tooltip and type(self.tooltip) == 'function' then - self.tooltip(self, info_queue) - end - if vars then - return { - vars = vars, - main_end = main_end - } - else - return {} - end - end - -- Applies to Tarot, Planet, Spectral and Voucher - function SMODS.compat_0_9_8.tarot_loc_vars(self, info_queue, card) - local vars, main_end - if self.loc_def and type(self.loc_def) == 'function' then - vars, main_end = self.loc_def(self, info_queue) - end - if self.tooltip and type(self.tooltip) == 'function' then - self.tooltip(self, info_queue) - end - if vars then - return { - vars = vars, - main_end = main_end - } - else - return {} - end - end - - SMODS.compat_0_9_8.init_queue = {} - SMODS.INIT = setmetatable({}, { - __newindex = function(t, k, v) - SMODS.compat_0_9_8.init_queue[k] = v - rawset(t, k, v) - end - }) - function SMODS.findModByID(id) - return SMODS.Mods[id] - end - function SMODS.end_calculate_context(c) - return c.joker_main - end - function SMODS.LOAD_LOC() - init_localization() - end - - SMODS.SOUND_SOURCES = SMODS.Sounds - function register_sound(name, path, filename) - SMODS.Sound { - key = name, - path = filename, - } - end - function modded_play_sound(sound_code, stop_previous_instance, volume, pitch) - return SMODS.Sound.play(nil, pitch, volume, stop_previous_instance, sound_code) - end - - SMODS.Card = { - SUITS = SMODS.Suits, - RANKS = SMODS.Ranks, - SUIT_LIST = SMODS.Suit.obj_buffer, - RANK_LIST = SMODS.Rank.obj_buffer, - } - - SMODS.compat_0_9_8.Deck_new = SMODS.Back:extend { - register = function(self) - SMODS.compat_0_9_8.delay_register(SMODS.compat_0_9_8.Deck_new, self) - end, - __index = function(t, k) - if k == 'slug' then return t.key - elseif k == 'spritePos' then return t.pos - end - return getmetatable(t)[k] - end, - __newindex = function(t, k, v) - if k == 'slug' then t.key = v; return - elseif k == 'spritePos' then t.pos = v; return - end - rawset(t, k, v) - end, - } - SMODS.Deck = {} - function SMODS.Deck.new(self, name, slug, config, spritePos, loc_txt, unlocked, discovered) - return SMODS.compat_0_9_8.Deck_new { - name = name, - key = slug, - config = config, - pos = spritePos, - loc_txt = loc_txt, - unlocked = unlocked, - discovered = discovered, - atlas = config and config.atlas, - delay_register = true - } - end - SMODS.Decks = SMODS.Centers - - SMODS.Sprites = {} - SMODS.compat_0_9_8.Sprite_new = SMODS.Atlas:extend { - register = function(self) - if self.delay_register then - self.delay_register = nil - return - end - if self.registered then - sendWarnMessage(('Detected duplicate register call on object %s'):format(self.key), self.set) - return - end - SMODS.compat_0_9_8.Sprite_new.super.register(self) - table.insert(SMODS.Sprites, self) - end, - __index = function(t, k) - if k == 'name' then return t.key - end - return getmetatable(t)[k] - end, - __newindex = function(t, k, v) - if k == 'name' then t.key = v; return - end - rawset(t, k, v) - end, - } - SMODS.Sprite = {} - function SMODS.Sprite.new(self, name, top_lpath, path, px, py, type, frames) - local atlas_table - if type == 'animation_atli' then - atlas_table = 'ANIMATION_ATLAS' - else - atlas_table = 'ASSET_ATLAS' - end - return SMODS.compat_0_9_8.Sprite_new { - key = name, - path = path, - atlas_table = atlas_table, - px = px, - py = py, - frames = frames, - delay_register = true - } - end - - SMODS.compat_0_9_8.Joker_new = SMODS.Joker:extend { - loc_vars = SMODS.compat_0_9_8.joker_loc_vars, - register = function(self) - SMODS.compat_0_9_8.delay_register(SMODS.compat_0_9_8.Joker_new, self) - end, - __index = function(t, k) - if k == 'slug' then return t.key - elseif k == 'atlas' and SMODS.Atlases[t.key] then return t.key - elseif k == 'spritePos' then return t.pos - end - return getmetatable(t)[k] - end, - __newindex = function(t, k, v) - if k == 'slug' then t.key = v; return - elseif k == 'spritePos' then t.pos = v; return - end - if k == 'calculate' or k == 'set_ability' or k == 'set_badges' or k == 'update' then - local v_ref = v - v = function(self, ...) - return v_ref(...) - end - end - rawset(t, k, v) - end, - } - function SMODS.Joker.new(self, name, slug, config, spritePos, loc_txt, rarity, cost, unlocked, discovered, - blueprint_compat, eternal_compat, effect, atlas, soul_pos) - local x = SMODS.compat_0_9_8.Joker_new { - name = name, - key = slug, - config = config, - pos = spritePos, - loc_txt = loc_txt, - rarity = rarity, - cost = cost, - unlocked = unlocked, - discovered = discovered, - blueprint_compat = blueprint_compat, - eternal_compat = eternal_compat, - effect = effect, - atlas = atlas, - soul_pos = soul_pos, - delay_register = true - } - return x - end - SMODS.Jokers = SMODS.Centers - - function SMODS.compat_0_9_8.extend_consumable_class(SMODS_cls) - local cls - cls = SMODS_cls:extend { - loc_vars = SMODS.compat_0_9_8.tarot_loc_vars, - register = function(self) - SMODS.compat_0_9_8.delay_register(cls, self) - end, - __index = function(t, k) - if k == 'slug' then - return t.key - elseif k == 'atlas' and SMODS.Atlases[t.key] then - return t.key - end - return getmetatable(t)[k] - end, - __newindex = function(t, k, v) - if k == 'slug' then - t.key = v; return - elseif k == 'spritePos' then - t.pos = v; return - end - if k == 'set_badges' or k == 'use' or k == 'can_use' or k == 'update' then - local v_ref = v - v = function(self, ...) - return v_ref(...) - end - end - rawset(t, k, v) - end - } - return cls - end - - SMODS.compat_0_9_8.Tarot_new = SMODS.compat_0_9_8.extend_consumable_class(SMODS.Tarot) - function SMODS.Tarot.new(self, name, slug, config, pos, loc_txt, cost, cost_mult, effect, consumeable, discovered, - atlas) - return SMODS.compat_0_9_8.Tarot_new { - name = name, - key = slug, - config = config, - pos = pos, - loc_txt = loc_txt, - cost = cost, - cost_mult = cost_mult, - effect = effect, - consumeable = consumeable, - discovered = discovered, - atlas = atlas, - delay_register = true - } - end - SMODS.Tarots = SMODS.Centers - - SMODS.compat_0_9_8.Planet_new = SMODS.compat_0_9_8.extend_consumable_class(SMODS.Planet) - function SMODS.Planet.new(self, name, slug, config, pos, loc_txt, cost, cost_mult, effect, freq, consumeable, - discovered, atlas) - return SMODS.compat_0_9_8.Planet_new { - name = name, - key = slug, - config = config, - pos = pos, - loc_txt = loc_txt, - cost = cost, - cost_mult = cost_mult, - effect = effect, - freq = freq, - consumeable = consumeable, - discovered = discovered, - atlas = atlas, - delay_register = true - } - end - SMODS.Planets = SMODS.Centers - - SMODS.compat_0_9_8.Spectral_new = SMODS.compat_0_9_8.extend_consumable_class(SMODS.Spectral) - function SMODS.Spectral.new(self, name, slug, config, pos, loc_txt, cost, consumeable, discovered, atlas) - return SMODS.compat_0_9_8.Spectral_new { - name = name, - key = slug, - config = config, - pos = pos, - loc_txt = loc_txt, - cost = cost, - consumeable = consumeable, - discovered = discovered, - atlas = atlas, - delay_register = true - } - end - SMODS.Spectrals = SMODS.Centers - - SMODS.compat_0_9_8.Seal_new = SMODS.Seal:extend { - class_prefix = false, - register = function(self) - if self.delay_register then - self.delay_register = nil - return - end - if self.registered then - sendWarnMessage(('Detected duplicate register call on object %s'):format(self.key), self.set) - return - end - if self:check_dependencies() and not self.obj_table[self.label] then - self.obj_table[self.label] = self - self.obj_buffer[#self.obj_buffer + 1] = self.label - self.registered = true - end - end, - __index = function(t, k) - if k == 'name' then return t.key - end - return getmetatable(t)[k] - end, - __newindex = function(t, k, v) - if k == 'name' then t.key = v; return - end - rawset(t, k, v) - end, - } - function SMODS.Seal.new(self, name, label, full_name, pos, loc_txt, atlas, discovered, color) - return SMODS.compat_0_9_8.Seal_new { - key = name, - label = label, - full_name = full_name, - pos = pos, - loc_txt = { - description = loc_txt, - label = full_name - }, - atlas = atlas, - discovered = discovered, - colour = color, - delay_register = true - } - end - - SMODS.compat_0_9_8.Voucher_new = SMODS.Voucher:extend { - loc_vars = SMODS.compat_0_9_8.tarot_loc_vars, - register = function(self) - SMODS.compat_0_9_8.delay_register(SMODS.compat_0_9_8.Voucher_new, self) - end, - __index = function(t, k) - if k == 'slug' then return t.key - elseif k == 'atlas' and SMODS.Atlases[t.key] then return t.key - end - return getmetatable(t)[k] - end, - __newindex = function(t, k, v) - if k == 'slug' then t.key = v; return - end - if k == 'update' then - local v_ref = v - v = function(self, ...) - return v_ref(...) - end - elseif k == 'redeem' then - local v_ref = v - v = function(center, card) - local center_table = { - name = center and center.name or card and card.ability.name, - extra = center and center.config.extra or card and card.ability.extra - } - return v_ref(center_table) - end - end - rawset(t, k, v) - end - } - function SMODS.Voucher.new(self, name, slug, config, pos, loc_txt, cost, unlocked, discovered, available, requires, - atlas) - return SMODS.compat_0_9_8.Voucher_new { - name = name, - key = slug, - config = config, - pos = pos, - loc_txt = loc_txt, - cost = cost, - unlocked = unlocked, - discovered = discovered, - available = available, - requires = requires, - atlas = atlas, - delay_register = true - } - end - SMODS.Vouchers = SMODS.Centers - - SMODS.compat_0_9_8.Blind_new = SMODS.Blind:extend { - register = function(self) - SMODS.compat_0_9_8.delay_register(SMODS.compat_0_9_8.Blind_new, self) - end, - __index = function(t, k) - if k == 'slug' then return t.key - end - return getmetatable(t)[k] - end, - __newindex = function(t, k, v) - if k == 'slug' then t.key = v; return - end - if k == 'set_blind' - or k == 'disable' - or k == 'defeat' - or k == 'debuff_card' - or k == 'stay_flipped' - or k == 'drawn_to_hand' - or k == 'debuff_hand' - or k == 'modify_hand' - or k == 'press_play' - or k == 'get_loc_debuff_text' then - local v_ref = v - v = function(self, ...) - return v_ref(G.GAME.blind, ...) - end - end - rawset(t, k, v) - end - } - function SMODS.Blind.new(self, name, slug, loc_txt, dollars, mult, vars, debuff, pos, boss, boss_colour, defeated, - atlas) - return SMODS.compat_0_9_8.Blind_new { - name = name, - key = slug, - loc_txt = loc_txt, - dollars = dollars, - mult = mult, - loc_vars = { - vars = vars, - }, - debuff = debuff, - pos = pos, - boss = boss, - boss_colour = boss_colour, - defeated = defeated, - atlas = atlas, - delay_register = true - } - end - - SMODS.compat_0_9_8.loc_proxies = setmetatable({}, {__mode = 'k'}) - -- Indexing a table `t` that has this metatable instead indexes `t.capture_table`. - -- Handles nested indices by instead indexing `t.capture_table` with the - -- concatenation of all indices, separated by dots. - SMODS.compat_0_9_8.loc_proxy_mt = { - __index = function(t, k) - if rawget(t, 'stop_capture') then - return t.orig_t[k] - end - local new_idx_str = t.idx_str .. "." .. k - -- first check capture_table - if t.capture_table[new_idx_str] ~= nil then - return t.capture_table[new_idx_str] - end - -- then fall back to orig_t - local orig_v = t.orig_t[k] - if type(orig_v) ~= 'table' then - -- reached a non-table value, stop proxying - return orig_v - end - local ret = setmetatable({ - -- concatenation of all indexes, starting from G.localization - -- separated by dots and preceded by a dot - idx_str = new_idx_str, - -- table we would be indexing - orig_t = orig_v, - capture_table = t.capture_table, - }, SMODS.compat_0_9_8.loc_proxy_mt) - SMODS.compat_0_9_8.loc_proxies[ret] = true - return ret - end, - __newindex = function(t, k, v) - if rawget(t, 'stop_capture') then - t.orig_t[k] = v; return - end - local new_idx_str = t.idx_str .. "." .. k - t.capture_table[new_idx_str] = v - end - } - -- Drop-in replacement for G.localization. Captures changes in `capture_table` - function SMODS.compat_0_9_8.loc_proxy(capture_table) - local ret = setmetatable({ - idx_str = '', - orig_t = G.localization, - capture_table = capture_table, - }, SMODS.compat_0_9_8.loc_proxy_mt) - SMODS.compat_0_9_8.loc_proxies[ret] = true - return ret - end - function SMODS.compat_0_9_8.stop_loc_proxies() - collectgarbage() - for proxy, _ in pairs(SMODS.compat_0_9_8.loc_proxies) do - rawset(proxy, 'stop_capture', true) - SMODS.compat_0_9_8.loc_proxies[proxy] = nil - end - end - - SMODS.compat_0_9_8.load_done = true -end - -function SMODS.compat_0_9_8.with_compat(func) - SMODS.compat_0_9_8.load() - local localization_ref = G.localization - init_localization_ref = init_localization - local captured_loc = {} - G.localization = SMODS.compat_0_9_8.loc_proxy(captured_loc) - function init_localization() - G.localization = localization_ref - init_localization_ref() - G.localization = SMODS.compat_0_9_8.loc_proxy(captured_loc) - end - func() - G.localization = localization_ref - init_localization = init_localization_ref - SMODS.compat_0_9_8.stop_loc_proxies() - function SMODS.current_mod.process_loc_text() - for idx_str, v in pairs(captured_loc) do - local t = G - local k = 'localization' - for cur_k in idx_str:gmatch("[^%.]+") do - t, k = t[k], cur_k - end - t[k] = v - end - end -end diff --git a/smods-main/src/core.lua b/smods-main/src/core.lua deleted file mode 100644 index e44e824..0000000 --- a/smods-main/src/core.lua +++ /dev/null @@ -1,77 +0,0 @@ ---- STEAMODDED CORE ---- MODULE CORE - -SMODS = {} -MODDED_VERSION = require'SMODS.version' -SMODS.id = 'Steamodded' -SMODS.version = MODDED_VERSION:gsub('%-STEAMODDED', '') -SMODS.can_load = true -SMODS.meta_mod = true -SMODS.config_file = 'config.lua' - --- Include lovely and nativefs modules -local nativefs = require "nativefs" -local lovely = require "lovely" -local json = require "json" - -local lovely_mod_dir = lovely.mod_dir:gsub("/$", "") -NFS = nativefs --- make lovely_mod_dir an absolute path. --- respects symlink/.. combos -NFS.setWorkingDirectory(lovely_mod_dir) -lovely_mod_dir = NFS.getWorkingDirectory() --- make sure NFS behaves the same as love.filesystem -NFS.setWorkingDirectory(love.filesystem.getSaveDirectory()) - -JSON = json - -local function set_mods_dir() - local love_dirs = { - love.filesystem.getSaveDirectory(), - love.filesystem.getSourceBaseDirectory() - } - for _, love_dir in ipairs(love_dirs) do - if lovely_mod_dir:sub(1, #love_dir) == love_dir then - -- relative path from love_dir - SMODS.MODS_DIR = lovely_mod_dir:sub(#love_dir+2) - NFS.setWorkingDirectory(love_dir) - return - end - end - SMODS.MODS_DIR = lovely_mod_dir -end -set_mods_dir() - -local function find_self(directory, target_filename, target_line, depth) - depth = depth or 1 - if depth > 3 then return end - for _, filename in ipairs(NFS.getDirectoryItems(directory)) do - local file_path = directory .. "/" .. filename - local file_type = NFS.getInfo(file_path).type - if file_type == 'directory' or file_type == 'symlink' then - local f = find_self(file_path, target_filename, target_line, depth+1) - if f then return f end - elseif filename == target_filename then - local first_line = NFS.read(file_path):match('^(.-)\n') - if first_line == target_line then - -- use parent directory - return directory:match('^(.+/)') - end - end - end -end - -SMODS.path = find_self(SMODS.MODS_DIR, 'core.lua', '--- STEAMODDED CORE') - -for _, path in ipairs { - "src/ui.lua", - "src/index.lua", - "src/utils.lua", - "src/overrides.lua", - "src/game_object.lua", - "src/logging.lua", - "src/compat_0_9_8.lua", - "src/loader.lua", -} do - assert(load(NFS.read(SMODS.path..path), ('=[SMODS _ "%s"]'):format(path)))() -end diff --git a/smods-main/src/crash_handler.lua b/smods-main/src/crash_handler.lua deleted file mode 100644 index e762ad1..0000000 --- a/smods-main/src/crash_handler.lua +++ /dev/null @@ -1,855 +0,0 @@ ---- STEAMODDED CORE ---- MODULE STACKTRACE --- NOTE: This is a modifed version of https://github.com/ignacio/StackTracePlus/blob/master/src/StackTracePlus.lua --- Licensed under the MIT License. See https://github.com/ignacio/StackTracePlus/blob/master/LICENSE --- The MIT License --- Copyright (c) 2010 Ignacio Burgueño --- Permission is hereby granted, free of charge, to any person obtaining a copy --- of this software and associated documentation files (the "Software"), to deal --- in the Software without restriction, including without limitation the rights --- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --- copies of the Software, and to permit persons to whom the Software is --- furnished to do so, subject to the following conditions: --- The above copyright notice and this permission notice shall be included in --- all copies or substantial portions of the Software. --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN --- THE SOFTWARE. --- tables -function loadStackTracePlus() - local _G = _G - local string, io, debug, coroutine = string, io, debug, coroutine - - -- functions - local tostring, print, require = tostring, print, require - local next, assert = next, assert - local pcall, type, pairs, ipairs = pcall, type, pairs, ipairs - local error = error - - assert(debug, "debug table must be available at this point") - - local io_open = io.open - local string_gmatch = string.gmatch - local string_sub = string.sub - local table_concat = table.concat - - local _M = { - max_tb_output_len = 70 -- controls the maximum length of the 'stringified' table before cutting with ' (more...)' - } - - -- this tables should be weak so the elements in them won't become uncollectable - local m_known_tables = { - [_G] = "_G (global table)" - } - local function add_known_module(name, desc) - local ok, mod = pcall(require, name) - if ok then - m_known_tables[mod] = desc - end - end - - add_known_module("string", "string module") - add_known_module("io", "io module") - add_known_module("os", "os module") - add_known_module("table", "table module") - add_known_module("math", "math module") - add_known_module("package", "package module") - add_known_module("debug", "debug module") - add_known_module("coroutine", "coroutine module") - - -- lua5.2 - add_known_module("bit32", "bit32 module") - -- luajit - add_known_module("bit", "bit module") - add_known_module("jit", "jit module") - -- lua5.3 - if _VERSION >= "Lua 5.3" then - add_known_module("utf8", "utf8 module") - end - - local m_user_known_tables = {} - - local m_known_functions = {} - for _, name in ipairs { -- Lua 5.2, 5.1 - "assert", "collectgarbage", "dofile", "error", "getmetatable", "ipairs", "load", "loadfile", "next", "pairs", - "pcall", "print", "rawequal", "rawget", "rawlen", "rawset", "require", "select", "setmetatable", "tonumber", - "tostring", "type", "xpcall", -- Lua 5.1 - "gcinfo", "getfenv", "loadstring", "module", "newproxy", "setfenv", "unpack" -- TODO: add table.* etc functions - } do - if _G[name] then - m_known_functions[_G[name]] = name - end - end - - local m_user_known_functions = {} - - local function safe_tostring(value) - local ok, err = pcall(tostring, value) - if ok then - return err - else - return (": '%s'"):format(err) - end - end - - -- Private: - -- Parses a line, looking for possible function definitions (in a very naïve way) - -- Returns '(anonymous)' if no function name was found in the line - local function ParseLine(line) - assert(type(line) == "string") - -- print(line) - local match = line:match("^%s*function%s+(%w+)") - if match then - -- print("+++++++++++++function", match) - return match - end - match = line:match("^%s*local%s+function%s+(%w+)") - if match then - -- print("++++++++++++local", match) - return match - end - match = line:match("^%s*local%s+(%w+)%s+=%s+function") - if match then - -- print("++++++++++++local func", match) - return match - end - match = line:match("%s*function%s*%(") -- this is an anonymous function - if match then - -- print("+++++++++++++function2", match) - return "(anonymous)" - end - return "(anonymous)" - end - - -- Private: - -- Tries to guess a function's name when the debug info structure does not have it. - -- It parses either the file or the string where the function is defined. - -- Returns '?' if the line where the function is defined is not found - local function GuessFunctionName(info) - -- print("guessing function name") - if type(info.source) == "string" and info.source:sub(1, 1) == "@" then - local file, err = io_open(info.source:sub(2), "r") - if not file then - print("file not found: " .. tostring(err)) -- whoops! - return "?" - end - local line - for _ = 1, info.linedefined do - line = file:read("*l") - end - if not line then - print("line not found") -- whoops! - return "?" - end - return ParseLine(line) - elseif type(info.source) == "string" and info.source:sub(1, 6) == "=[love" then - return "(LÖVE Function)" - else - local line - local lineNumber = 0 - for l in string_gmatch(info.source, "([^\n]+)\n-") do - lineNumber = lineNumber + 1 - if lineNumber == info.linedefined then - line = l - break - end - end - if not line then - print("line not found") -- whoops! - return "?" - end - return ParseLine(line) - end - end - - --- - -- Dumper instances are used to analyze stacks and collect its information. - -- - local Dumper = {} - - Dumper.new = function(thread) - local t = { - lines = {} - } - for k, v in pairs(Dumper) do - t[k] = v - end - - t.dumping_same_thread = (thread == coroutine.running()) - - -- if a thread was supplied, bind it to debug.info and debug.get - -- we also need to skip this additional level we are introducing in the callstack (only if we are running - -- in the same thread we're inspecting) - if type(thread) == "thread" then - t.getinfo = function(level, what) - if t.dumping_same_thread and type(level) == "number" then - level = level + 1 - end - return debug.getinfo(thread, level, what) - end - t.getlocal = function(level, loc) - if t.dumping_same_thread then - level = level + 1 - end - return debug.getlocal(thread, level, loc) - end - else - t.getinfo = debug.getinfo - t.getlocal = debug.getlocal - end - - return t - end - - -- helpers for collecting strings to be used when assembling the final trace - function Dumper:add(text) - self.lines[#self.lines + 1] = text - end - function Dumper:add_f(fmt, ...) - self:add(fmt:format(...)) - end - function Dumper:concat_lines() - return table_concat(self.lines) - end - - --- - -- Private: - -- Iterates over the local variables of a given function. - -- - -- @param level The stack level where the function is. - -- - function Dumper:DumpLocals(level) - local prefix = "\t " - local i = 1 - - if self.dumping_same_thread then - level = level + 1 - end - - local name, value = self.getlocal(level, i) - if not name then - return - end - self:add("\tLocal variables:\r\n") - while name do - if type(value) == "number" then - self:add_f("%s%s = number: %g\r\n", prefix, name, value) - elseif type(value) == "boolean" then - self:add_f("%s%s = boolean: %s\r\n", prefix, name, tostring(value)) - elseif type(value) == "string" then - self:add_f("%s%s = string: %q\r\n", prefix, name, value) - elseif type(value) == "userdata" then - self:add_f("%s%s = %s\r\n", prefix, name, safe_tostring(value)) - elseif type(value) == "nil" then - self:add_f("%s%s = nil\r\n", prefix, name) - elseif type(value) == "table" then - if m_known_tables[value] then - self:add_f("%s%s = %s\r\n", prefix, name, m_known_tables[value]) - elseif m_user_known_tables[value] then - self:add_f("%s%s = %s\r\n", prefix, name, m_user_known_tables[value]) - else - local txt = "{" - for k, v in pairs(value) do - txt = txt .. safe_tostring(k) .. ":" .. safe_tostring(v) - if #txt > _M.max_tb_output_len then - txt = txt .. " (more...)" - break - end - if next(value, k) then - txt = txt .. ", " - end - end - self:add_f("%s%s = %s %s\r\n", prefix, name, safe_tostring(value), txt .. "}") - end - elseif type(value) == "function" then - local info = self.getinfo(value, "nS") - local fun_name = info.name or m_known_functions[value] or m_user_known_functions[value] - if info.what == "C" then - self:add_f("%s%s = C %s\r\n", prefix, name, - (fun_name and ("function: " .. fun_name) or tostring(value))) - else - local source = info.short_src - if source:sub(2, 7) == "string" then - source = source:sub(9) -- uno más, por el espacio que viene (string "Baragent.Main", por ejemplo) - end - -- for k,v in pairs(info) do print(k,v) end - fun_name = fun_name or GuessFunctionName(info) - self:add_f("%s%s = Lua function '%s' (defined at line %d of chunk %s)\r\n", prefix, name, fun_name, - info.linedefined, source) - end - elseif type(value) == "thread" then - self:add_f("%sthread %q = %s\r\n", prefix, name, tostring(value)) - end - i = i + 1 - name, value = self.getlocal(level, i) - end - end - - --- - -- Public: - -- Collects a detailed stack trace, dumping locals, resolving function names when they're not available, etc. - -- This function is suitable to be used as an error handler with pcall or xpcall - -- - -- @param thread An optional thread whose stack is to be inspected (defaul is the current thread) - -- @param message An optional error string or object. - -- @param level An optional number telling at which level to start the traceback (default is 1) - -- - -- Returns a string with the stack trace and a string with the original error. - -- - function _M.stacktrace(thread, message, level) - if type(thread) ~= "thread" then - -- shift parameters left - thread, message, level = nil, thread, message - end - - thread = thread or coroutine.running() - - level = level or 1 - - local dumper = Dumper.new(thread) - - local original_error - - if type(message) == "table" then - dumper:add("an error object {\r\n") - local first = true - for k, v in pairs(message) do - if first then - dumper:add(" ") - first = false - else - dumper:add(",\r\n ") - end - dumper:add(safe_tostring(k)) - dumper:add(": ") - dumper:add(safe_tostring(v)) - end - dumper:add("\r\n}") - original_error = dumper:concat_lines() - elseif type(message) == "string" then - dumper:add(message) - original_error = message - end - - dumper:add("\r\n") - dumper:add [[ -Stack Traceback -=============== -]] - -- print(error_message) - - local level_to_show = level - if dumper.dumping_same_thread then - level = level + 1 - end - - local info = dumper.getinfo(level, "nSlf") - while info do - if info.what == "main" then - if string_sub(info.source, 1, 1) == "@" then - dumper:add_f("(%d) main chunk of file '%s' at line %d\r\n", level_to_show, - string_sub(info.source, 2), info.currentline) - elseif info.source and info.source:sub(1, 1) == "=" then - local str = info.source:sub(3, -2) - local props = {} - -- Split by space - for v in string.gmatch(str, "[^%s]+") do - table.insert(props, v) - end - local source = table.remove(props, 1) - if source == "love" then - dumper:add_f("(%d) main chunk of LÖVE file '%s' at line %d\r\n", level_to_show, - table.concat(props, " "):sub(2, -2), info.currentline) - elseif source == "SMODS" then - local modID = table.remove(props, 1) - local fileName = table.concat(props, " ") - if modID == '_' then - dumper:add_f("(%d) main chunk of Steamodded file '%s' at line %d\r\n", level_to_show, - fileName:sub(2, -2), info.currentline) - else - dumper:add_f("(%d) main chunk of file '%s' at line %d (from mod with id %s)\r\n", - level_to_show, fileName:sub(2, -2), info.currentline, modID) - end - elseif source == "lovely" then - local module = table.remove(props, 1) - local fileName = table.concat(props, " ") - dumper:add_f("(%d) main chunk of file '%s' at line %d (from lovely module %s)\r\n", - level_to_show, fileName:sub(2, -2), info.currentline, module) - else - dumper:add_f("(%d) main chunk of %s at line %d\r\n", level_to_show, info.source, - info.currentline) - end - else - dumper:add_f("(%d) main chunk of %s at line %d\r\n", level_to_show, info.source, info.currentline) - end - elseif info.what == "C" then - -- print(info.namewhat, info.name) - -- for k,v in pairs(info) do print(k,v, type(v)) end - local function_name = m_user_known_functions[info.func] or m_known_functions[info.func] or info.name or - tostring(info.func) - dumper:add_f("(%d) %s C function '%s'\r\n", level_to_show, info.namewhat, function_name) - -- dumper:add_f("%s%s = C %s\r\n", prefix, name, (m_known_functions[value] and ("function: " .. m_known_functions[value]) or tostring(value))) - elseif info.what == "tail" then - -- print("tail") - -- for k,v in pairs(info) do print(k,v, type(v)) end--print(info.namewhat, info.name) - dumper:add_f("(%d) tail call\r\n", level_to_show) - dumper:DumpLocals(level) - elseif info.what == "Lua" then - local source = info.short_src - local function_name = m_user_known_functions[info.func] or m_known_functions[info.func] or info.name - if source:sub(2, 7) == "string" then - source = source:sub(9) - end - local was_guessed = false - if not function_name or function_name == "?" then - -- for k,v in pairs(info) do print(k,v, type(v)) end - function_name = GuessFunctionName(info) - was_guessed = true - end - -- test if we have a file name - local function_type = (info.namewhat == "") and "function" or info.namewhat - if info.source and info.source:sub(1, 1) == "@" then - dumper:add_f("(%d) Lua %s '%s' at file '%s:%d'%s\r\n", level_to_show, function_type, function_name, - info.source:sub(2), info.currentline, was_guessed and " (best guess)" or "") - elseif info.source and info.source:sub(1, 1) == '#' then - dumper:add_f("(%d) Lua %s '%s' at template '%s:%d'%s\r\n", level_to_show, function_type, - function_name, info.source:sub(2), info.currentline, was_guessed and " (best guess)" or "") - elseif info.source and info.source:sub(1, 1) == "=" then - local str = info.source:sub(3, -2) - local props = {} - -- Split by space - for v in string.gmatch(str, "[^%s]+") do - table.insert(props, v) - end - local source = table.remove(props, 1) - if source == "love" then - dumper:add_f("(%d) LÖVE %s at file '%s:%d'%s\r\n", level_to_show, function_type, - table.concat(props, " "):sub(2, -2), info.currentline, was_guessed and " (best guess)" or "") - elseif source == "SMODS" then - local modID = table.remove(props, 1) - local fileName = table.concat(props, " ") - if modID == '_' then - dumper:add_f("(%d) Lua %s '%s' at Steamodded file '%s:%d' %s\r\n", level_to_show, - function_type, function_name, fileName:sub(2, -2), info.currentline, - was_guessed and " (best guess)" or "") - else - dumper:add_f("(%d) Lua %s '%s' at file '%s:%d' (from mod with id %s)%s\r\n", level_to_show, - function_type, function_name, fileName:sub(2, -2), info.currentline, modID, - was_guessed and " (best guess)" or "") - end - elseif source == "lovely" then - local module = table.remove(props, 1) - local fileName = table.concat(props, " ") - dumper:add_f("(%d) Lua %s '%s' at file '%s:%d' (from lovely module %s)%s\r\n", level_to_show, - function_type, function_name, fileName:sub(2, -2), info.currentline, module, - was_guessed and " (best guess)" or "") - else - dumper:add_f("(%d) Lua %s '%s' at line %d of chunk '%s'\r\n", level_to_show, function_type, - function_name, info.currentline, source) - end - else - dumper:add_f("(%d) Lua %s '%s' at line %d of chunk '%s'\r\n", level_to_show, function_type, - function_name, info.currentline, source) - end - dumper:DumpLocals(level) - else - dumper:add_f("(%d) unknown frame %s\r\n", level_to_show, info.what) - end - - level = level + 1 - level_to_show = level_to_show + 1 - info = dumper.getinfo(level, "nSlf") - end - - return dumper:concat_lines(), original_error - end - - -- - -- Adds a table to the list of known tables - function _M.add_known_table(tab, description) - if m_known_tables[tab] then - error("Cannot override an already known table") - end - m_user_known_tables[tab] = description - end - - -- - -- Adds a function to the list of known functions - function _M.add_known_function(fun, description) - if m_known_functions[fun] then - error("Cannot override an already known function") - end - m_user_known_functions[fun] = description - end - - return _M -end - --- Note: The below code is not from the original StackTracePlus.lua -local stackTraceAlreadyInjected = false - -function getDebugInfoForCrash() - local version = VERSION - if not version or type(version) ~= "string" then - local versionFile = love.filesystem.read("version.jkr") - if versionFile then - version = versionFile:match("[^\n]*") .. " (best guess)" - else - version = "???" - end - end - local modded_version = MODDED_VERSION - if not modded_version or type(modded_version) ~= "string" then - local moddedSuccess, reqVersion = pcall(require, "SMODS.version") - if moddedSuccess and type(reqVersion) == "string" then - modded_version = reqVersion - else - modded_version = "???" - end - end - - local info = "Additional Context:\nBalatro Version: " .. version .. "\nModded Version: " .. - (modded_version) - local major, minor, revision, codename = love.getVersion() - info = info .. string.format("\nLÖVE Version: %d.%d.%d", major, minor, revision) - local lovely_success, lovely = pcall(require, "lovely") - if lovely_success then - info = info .. "\nLovely Version: " .. lovely.version - end - info = info .. "\nPlatform: " .. (love.system.getOS() or "???") - if SMODS and SMODS.Mods then - local mod_strings = "" - local lovely_strings = "" - local i = 1 - local lovely_i = 1 - for _, v in pairs(SMODS.Mods) do - if (v.can_load and (not v.meta_mod or v.lovely_only)) or (v.lovely and not v.can_load and not v.disabled) then - if v.lovely_only or (v.lovely and not v.can_load) then - lovely_strings = lovely_strings .. "\n " .. lovely_i .. ": " .. v.name - lovely_i = lovely_i + 1 - if not v.can_load then - lovely_strings = lovely_strings .. "\n Has Steamodded mod that failed to load." - if #v.load_issues.dependencies > 0 then - lovely_strings = lovely_strings .. "\n Missing Dependencies:" - for k, v in ipairs(v.load_issues.dependencies) do - lovely_strings = lovely_strings .. "\n " .. k .. ". " .. v - end - end - if #v.load_issues.conflicts > 0 then - lovely_strings = lovely_strings .. "\n Conflicts:" - for k, v in ipairs(v.load_issues.conflicts) do - lovely_strings = lovely_strings .. "\n " .. k .. ". " .. v - end - end - if v.load_issues.outdated then - lovely_strings = lovely_strings .. "\n Outdated Mod." - end - if v.load_issues.main_file_not_found then - lovely_strings = lovely_strings .. "\n Main file not found. (" .. v.main_file ..")" - end - end - else - mod_strings = mod_strings .. "\n " .. i .. ": " .. v.name .. " by " .. - table.concat(v.author, ", ") .. " [ID: " .. v.id .. - (v.priority ~= 0 and (", Priority: " .. v.priority) or "") .. - (v.version and v.version ~= '0.0.0' and (", Version: " .. v.version) or "") .. - (v.lovely and (", Uses Lovely") or "") .. "]" - i = i + 1 - local debugInfo = v.debug_info - if debugInfo then - if type(debugInfo) == "string" then - if #debugInfo ~= 0 then - mod_strings = mod_strings .. "\n " .. debugInfo - end - elseif type(debugInfo) == "table" then - for kk, vv in pairs(debugInfo) do - if type(vv) ~= 'nil' then - vv = tostring(vv) - end - if #vv ~= 0 then - mod_strings = mod_strings .. "\n " .. kk .. ": " .. vv - end - end - end - end - end - end - end - info = info .. "\nSteamodded Mods:" .. mod_strings .. "\nLovely Mods:" .. lovely_strings - end - return info -end - -function injectStackTrace() - if (stackTraceAlreadyInjected) then - return - end - stackTraceAlreadyInjected = true - local STP = loadStackTracePlus() - local utf8 = require("utf8") - - -- Modifed from https://love2d.org/wiki/love.errorhandler - function love.errorhandler(msg) - msg = tostring(msg) - - if not sendErrorMessage then - function sendErrorMessage(msg) - print(msg) - end - end - if not sendInfoMessage then - function sendInfoMessage(msg) - print(msg) - end - end - - sendErrorMessage("Oops! The game crashed\n" .. STP.stacktrace(msg), 'StackTrace') - - if not love.window or not love.graphics or not love.event then - return - end - - if not love.graphics.isCreated() or not love.window.isOpen() then - local success, status = pcall(love.window.setMode, 800, 600) - if not success or not status then - return - end - end - - -- Reset state. - if love.mouse then - love.mouse.setVisible(true) - love.mouse.setGrabbed(false) - love.mouse.setRelativeMode(false) - if love.mouse.isCursorSupported() then - love.mouse.setCursor() - end - end - if love.joystick then - -- Stop all joystick vibrations. - for i, v in ipairs(love.joystick.getJoysticks()) do - v:setVibration() - end - end - if love.audio then - love.audio.stop() - end - - love.graphics.reset() - local font = love.graphics.setNewFont("resources/fonts/m6x11plus.ttf", 20) - - local background = {0, 0, 1} - if G and G.C and G.C.BLACK then - background = G.C.BLACK - end - love.graphics.clear(background) - love.graphics.origin() - - local trace = STP.stacktrace("", 3) - - local sanitizedmsg = {} - for char in msg:gmatch(utf8.charpattern) do - table.insert(sanitizedmsg, char) - end - sanitizedmsg = table.concat(sanitizedmsg) - - local err = {} - - table.insert(err, "Oops! The game crashed:") - if sanitizedmsg:find("Syntax error: game.lua:4: '=' expected near 'Game'") then - table.insert(err, - 'Duplicate installation of Steamodded detected! Please clean your installation: Steam Library > Balatro > Properties > Installed Files > Verify integrity of game files.') - else - table.insert(err, sanitizedmsg) - end - if #sanitizedmsg ~= #msg then - table.insert(err, "Invalid UTF-8 string in error message.") - end - - local success, msg = pcall(getDebugInfoForCrash) - if success and msg then - table.insert(err, '\n' .. msg) - sendInfoMessage(msg, 'StackTrace') - else - table.insert(err, "\n" .. "Failed to get additional context :/") - sendErrorMessage("Failed to get additional context :/\n" .. msg, 'StackTrace') - end - - for l in trace:gmatch("(.-)\n") do - table.insert(err, l) - end - - local p = table.concat(err, "\n") - - p = p:gsub("\t", "") - p = p:gsub("%[string \"(.-)\"%]", "%1") - - local scrollOffset = 0 - local endHeight = 0 - love.keyboard.setKeyRepeat(true) - - local function scrollDown(amt) - if amt == nil then - amt = 18 - end - scrollOffset = scrollOffset + amt - if scrollOffset > endHeight then - scrollOffset = endHeight - end - end - - local function scrollUp(amt) - if amt == nil then - amt = 18 - end - scrollOffset = scrollOffset - amt - if scrollOffset < 0 then - scrollOffset = 0 - end - end - - local pos = 70 - local arrowSize = 20 - - local function calcEndHeight() - local font = love.graphics.getFont() - local rw, lines = font:getWrap(p, love.graphics.getWidth() - pos * 2) - local lineHeight = font:getHeight() - local atBottom = scrollOffset == endHeight and scrollOffset ~= 0 - endHeight = #lines * lineHeight - love.graphics.getHeight() + pos * 2 - if (endHeight < 0) then - endHeight = 0 - end - if scrollOffset > endHeight or atBottom then - scrollOffset = endHeight - end - end - - local function draw() - if not love.graphics.isActive() then - return - end - love.graphics.clear(background) - calcEndHeight() - love.graphics.printf(p, pos, pos - scrollOffset, love.graphics.getWidth() - pos * 2) - if scrollOffset ~= endHeight then - love.graphics.polygon("fill", love.graphics.getWidth() - (pos / 2), - love.graphics.getHeight() - arrowSize, love.graphics.getWidth() - (pos / 2) + arrowSize, - love.graphics.getHeight() - (arrowSize * 2), love.graphics.getWidth() - (pos / 2) - arrowSize, - love.graphics.getHeight() - (arrowSize * 2)) - end - if scrollOffset ~= 0 then - love.graphics.polygon("fill", love.graphics.getWidth() - (pos / 2), arrowSize, - love.graphics.getWidth() - (pos / 2) + arrowSize, arrowSize * 2, - love.graphics.getWidth() - (pos / 2) - arrowSize, arrowSize * 2) - end - love.graphics.present() - end - - local fullErrorText = p - local function copyToClipboard() - if not love.system then - return - end - love.system.setClipboardText(fullErrorText) - p = p .. "\nCopied to clipboard!" - end - - p = p .. "\n\nPress ESC to exit\nPress R to restart the game" - if love.system then - p = p .. "\nPress Ctrl+C or tap to copy this error" - end - - if G then - -- Kill threads (makes restarting possible) - if G.SOUND_MANAGER and G.SOUND_MANAGER.channel then - G.SOUND_MANAGER.channel:push({ - type = 'kill' - }) - end - if G.SAVE_MANAGER and G.SAVE_MANAGER.channel then - G.SAVE_MANAGER.channel:push({ - type = 'kill' - }) - end - if G.HTTP_MANAGER and G.HTTP_MANAGER.channel then - G.HTTP_MANAGER.channel:push({ - type = 'kill' - }) - end - end - - return function() - love.event.pump() - - for e, a, b, c in love.event.poll() do - if e == "quit" then - return 1 - elseif e == "keypressed" and a == "escape" then - return 1 - elseif e == "keypressed" and a == "c" and love.keyboard.isDown("lctrl", "rctrl") then - copyToClipboard() - elseif e == "keypressed" and a == "r" then - SMODS.restart_game() - elseif e == "keypressed" and a == "down" then - scrollDown() - elseif e == "keypressed" and a == "up" then - scrollUp() - elseif e == "keypressed" and a == "pagedown" then - scrollDown(love.graphics.getHeight()) - elseif e == "keypressed" and a == "pageup" then - scrollUp(love.graphics.getHeight()) - elseif e == "keypressed" and a == "home" then - scrollOffset = 0 - elseif e == "keypressed" and a == "end" then - scrollOffset = endHeight - elseif e == "wheelmoved" then - scrollUp(b * 20) - elseif e == "gamepadpressed" and b == "dpdown" then - scrollDown() - elseif e == "gamepadpressed" and b == "dpup" then - scrollUp() - elseif e == "gamepadpressed" and b == "a" then - return "restart" - elseif e == "gamepadpressed" and b == "x" then - copyToClipboard() - elseif e == "gamepadpressed" and (b == "b" or b == "back" or b == "start") then - return 1 - elseif e == "touchpressed" then - local name = love.window.getTitle() - if #name == 0 or name == "Untitled" then - name = "Game" - end - local buttons = {"OK", "Cancel", "Restart"} - if love.system then - buttons[4] = "Copy to clipboard" - end - local pressed = love.window.showMessageBox("Quit " .. name .. "?", "", buttons) - if pressed == 1 then - return 1 - elseif pressed == 3 then - return "restart" - elseif pressed == 4 then - copyToClipboard() - end - end - end - - draw() - - if love.timer then - love.timer.sleep(0.1) - end - end - - end -end - -injectStackTrace() - --- ---------------------------------------------- --- --------MOD CORE API STACKTRACE END----------- diff --git a/smods-main/src/game_object.lua b/smods-main/src/game_object.lua deleted file mode 100644 index e71d754..0000000 --- a/smods-main/src/game_object.lua +++ /dev/null @@ -1,3289 +0,0 @@ ---- STEAMODDED CORE ---- MODULE API - -function loadAPIs() - ------------------------------------------------------------------------------------------------- - --- API CODE GameObject - ------------------------------------------------------------------------------------------------- - - --- GameObject base class. You should always use the appropriate subclass to register your object. - SMODS.GameObject = Object:extend() - SMODS.GameObject.subclasses = {} - function SMODS.GameObject:extend(o) - local cls = Object.extend(self) - for k, v in pairs(o or {}) do - cls[k] = v - end - self.subclasses[#self.subclasses + 1] = cls - cls.subclasses = {} - return cls - end - - function SMODS.GameObject:__call(o) - o = o or {} - assert(o.mod == nil) - o.mod = SMODS.current_mod - setmetatable(o, self) - for _, v in ipairs(o.required_params or {}) do - assert(not (o[v] == nil), ('Missing required parameter for %s declaration: %s'):format(o.set, v)) - end - if o:check_duplicate_register() then return end - -- also updates o.prefix_config - SMODS.add_prefixes(self, o) - if o:check_duplicate_key() then return end - o:register() - return o - end - - function SMODS.modify_key(obj, prefix, condition, key) - key = key or 'key' - -- condition == nil counts as true - if condition ~= false and obj[key] and prefix then - if string.sub(obj[key], 1, #prefix + 1) == prefix..'_' then - -- this happens within steamodded itself and I don't want to spam the logs with warnings, leaving this disabled for now - -- sendWarnMessage(("Attempted to prefix field %s=%s on object %s, already prefixed"):format(key, obj[key], obj.key), obj.set) - return - end - obj[key] = prefix .. '_' .. obj[key] - end - end - - function SMODS.add_prefixes(cls, obj, from_take_ownership) - if obj.prefix_config == false then return end - obj.prefix_config = obj.prefix_config or {} - if obj.raw_key then - sendWarnMessage(([[The field `raw_key` on %s is deprecated. -Set `prefix_config.key = false` on your object instead.]]):format(obj.key), obj.set) - obj.prefix_config.key = false - end - -- keep class defaults for unmodified keys in prefix_config - obj.prefix_config = SMODS.merge_defaults(obj.prefix_config, cls.prefix_config) - local mod = SMODS.current_mod - obj.prefix_config = SMODS.merge_defaults(obj.prefix_config, mod and mod.prefix_config) - obj.original_key = obj.key - local key_cfg = obj.prefix_config.key - if key_cfg ~= false then - if type(key_cfg) ~= 'table' then key_cfg = {} end - if not from_take_ownership then - SMODS.modify_key(obj, mod and mod.prefix, key_cfg.mod) - end - SMODS.modify_key(obj, cls.class_prefix, key_cfg.class) - end - local atlas_cfg = obj.prefix_config.atlas - if atlas_cfg ~= false then - if type(atlas_cfg) ~= 'table' then atlas_cfg = {} end - for _, v in ipairs({ 'atlas', 'hc_atlas', 'lc_atlas', 'hc_ui_atlas', 'lc_ui_atlas', 'sticker_atlas' }) do - if rawget(obj, v) then SMODS.modify_key(obj, mod and mod.prefix, atlas_cfg, v) end - end - end - local shader_cfg = obj.prefix_config.shader - SMODS.modify_key(obj, mod and mod.prefix, shader_cfg, 'shader') - local card_key_cfg = obj.prefix_config.card_key - SMODS.modify_key(obj, mod and mod.prefix, card_key_cfg, 'card_key') - local above_stake_cfg = obj.prefix_config.above_stake - if above_stake_cfg ~= false then - if type(above_stake_cfg) ~= 'table' then above_stake_cfg = {} end - SMODS.modify_key(obj, mod and mod.prefix, above_stake_cfg.mod, 'above_stake') - SMODS.modify_key(obj, cls.class_prefix, above_stake_cfg.class, 'above_stake') - end - local applied_stakes_cfg = obj.prefix_config.applied_stakes - if applied_stakes_cfg ~= false and obj.applied_stakes then - if type(applied_stakes_cfg) ~= 'table' then applied_stakes_cfg = {} end - for k,v in pairs(obj.applied_stakes) do - SMODS.modify_key(obj.applied_stakes, mod and mod.prefix, (applied_stakes_cfg[k] or {}).mod or applied_stakes_cfg.mod, k) - SMODS.modify_key(obj.applied_stakes, cls.class_prefix, (applied_stakes_cfg[k] or {}).class or applied_stakes_cfg.class, k) - end - end - local unlocked_stake_cfg = obj.prefix_config.unlocked_stake - if unlocked_stake_cfg ~= false then - if type(unlocked_stake_cfg) ~= 'table' then unlocked_stake_cfg = {} end - SMODS.modify_key(obj, mod and mod.prefix, unlocked_stake_cfg.mod, 'unlocked_stake') - SMODS.modify_key(obj, cls.class_prefix, unlocked_stake_cfg.class, 'unlocked_stake') - end - end - - function SMODS.GameObject:check_duplicate_register() - if self.registered then - sendWarnMessage(('Detected duplicate register call on object %s'):format(self.key), self.set) - return true - end - return false - end - - -- Checked on __call but not take_ownership. For take_ownership, the key must exist - function SMODS.GameObject:check_duplicate_key() - if self.obj_table[self.key] or (self.get_obj and self:get_obj(self.key)) then - sendWarnMessage(('Object %s has the same key as an existing object, not registering.'):format(self.key), self.set) - sendWarnMessage('If you want to modify an existing object, use take_ownership()', self.set) - return true - end - return false - end - - function SMODS.GameObject:register() - if self:check_dependencies() then - self.obj_table[self.key] = self - self.obj_buffer[#self.obj_buffer + 1] = self.key - self.registered = true - end - end - - function SMODS.GameObject:check_dependencies() - local keep = true - if self.dependencies then - -- ensure dependencies are a table - if type(self.dependencies) == 'string' then self.dependencies = { self.dependencies } end - for _, v in ipairs(self.dependencies) do - self.mod.optional_dependencies[v] = true - if not next(SMODS.find_mod(v)) then keep = false end - end - end - return keep - end - - function SMODS.GameObject:process_loc_text() - SMODS.process_loc_text(G.localization.descriptions[self.set], self.key, self.loc_txt) - end - - --- Starting from this class, recursively searches for - --- functions with the given key on all subordinate classes - --- and run all found functions with the given arguments - function SMODS.GameObject:send_to_subclasses(func, ...) - if rawget(self, func) and type(self[func]) == 'function' then self[func](self, ...) end - for _, cls in ipairs(self.subclasses) do - cls:send_to_subclasses(func, ...) - end - end - - - -- Inject all direct instances `o` of the class by calling `o:inject()`. - -- Also inject anything necessary for the class itself. - function SMODS.GameObject:inject_class() - local inject_time = 0 - local start_time = love.timer.getTime() - self:send_to_subclasses('pre_inject_class') - local end_time = love.timer.getTime() - inject_time = end_time - start_time - start_time = end_time - local o = nil - for i, key in ipairs(self.obj_buffer) do - o = self.obj_table[key] - o.atlas = o.atlas or o.set - - if o._discovered_unlocked_overwritten then - assert(o._saved_d_u) - o.discovered, o.unlocked = o._d, o._u - o._discovered_unlocked_overwritten = false - else - SMODS._save_d_u(o) - end - - -- Add centers to pools - o:inject(i) - - -- Setup Localize text - o:process_loc_text() - if self.log_interval and i%(self.log_interval) == 0 then - end_time = love.timer.getTime() - inject_time = inject_time + end_time - start_time - start_time = end_time - local alert = ('[%s] Injecting %s: %.3f ms'):format(string.rep('0', 4-#tostring(i))..i, self.set, inject_time*1000) - sendTraceMessage(alert, 'TIMER') - boot_print_stage(alert) - end - end - self:send_to_subclasses('post_inject_class') - end_time = love.timer.getTime() - inject_time = inject_time + end_time - start_time - local n = #self.obj_buffer - local alert = ('[%s] Injected %s in %.3f ms'):format(string.rep('0',4-#tostring(n))..n, self.set, inject_time*1000) - sendInfoMessage(alert, 'TIMER') - boot_print_stage(alert) - end - - --- Takes control of vanilla objects. Child class must implement get_obj for this to function. - function SMODS.GameObject:take_ownership(key, obj, silent) - if self.check_duplicate_register(obj) then return end - obj.key = key - obj.mod = nil - SMODS.add_prefixes(self, obj, true) - key = obj.key - local orig_o = self.obj_table[key] or (self.get_obj and self:get_obj(key)) - if not orig_o then - sendWarnMessage( - ('Cannot take ownership of %s: Does not exist.'):format(key), self.set - ) - return - end - local is_loc_modified = obj.loc_txt or obj.loc_vars or obj.generate_ui - if is_loc_modified then orig_o.is_loc_modified = true end - if not orig_o.is_loc_modified then - -- Setting generate_ui to this sentinel value - -- makes vanilla localization code run instead of SMODS's code - orig_o.generate_ui = 0 - else - -- reset the value if otherwise, in case when the object was taken over before and this value was already set to 0 - if orig_o.generate_ui == 0 then - orig_o.generate_ui = nil - end - end - -- TODO - -- it's unclear how much we should modify `obj` on a failed take_ownership call. - -- do we make sure the metatable is set early, or wait until the end? - setmetatable(orig_o, self) - if orig_o.mod then - orig_o.dependencies = orig_o.dependencies or {} - if not silent then table.insert(orig_o.dependencies, SMODS.current_mod.id) end - else - if not silent then orig_o.mod = SMODS.current_mod end - orig_o.rarity_original = orig_o.rarity - end - if orig_o._saved_d_u then - orig_o.discovered, orig_o.unlocked = orig_o._d, orig_o._u - orig_o._saved_d_u = false - orig_o._discovered_unlocked_overwritten = false - end - for k, v in pairs(obj) do orig_o[k] = v end - SMODS._save_d_u(orig_o) - orig_o.taken_ownership = true - orig_o:register() - return orig_o - end - - -- Inject all SMODS Objects that are part of this class or a subclass. - function SMODS.injectObjects(class) - if class.obj_table and class.obj_buffer then - class:inject_class() - else - for _, subclass in ipairs(class.subclasses) do SMODS.injectObjects(subclass) end - end - end - - -- Internal function - -- Creates a list of objects from a list of keys. - -- Currently used for a special case when selecting a random suit/rank. - function SMODS.GameObject:obj_list(reversed) - local lb, ub, step = 1, #self.obj_buffer, 1 - if reversed then lb, ub, step = ub, lb, -1 end - local res = {} - for i = lb, ub, step do - res[#res+1] = self.obj_table[self.obj_buffer[i]] - end - return res - end - - ------------------------------------------------------------------------------------------------- - ----- API CODE GameObject.Language - ------------------------------------------------------------------------------------------------- - - SMODS.Languages = {} - SMODS.Language = SMODS.GameObject:extend { - obj_table = SMODS.Languages, - set = 'Language', - obj_buffer = {}, - required_params = { - 'key', - 'label', - }, - prefix_config = { key = false }, - process_loc_text = function() end, - inject = function(self) - self.font = self.font or 1 - if type(self.font) == 'table' and not self.font.FONT and self.font.file and self.font.render_scale then - local data = assert(NFS.newFileData(self.mod.path .. 'assets/fonts/' .. self.font.file), ('Failed to collect file data for font of language %s'):format(self.key)) - self.font.FONT = love.graphics.newFont(data, self.font.render_scale) - elseif type(self.font) ~= 'table' then - self.font = G.FONTS[type(self.font) == 'number' and self.font or 1] or G.FONTS[1] - end - G.LANGUAGES[self.key] = self - if self.key == (G.SETTINGS.real_language or G.SETTINGS.language) then G.LANG = self end - end, - } - - ------------------------------------------------------------------------------------------------- - ----- INTERNAL API CODE GameObject._Loc_Pre - ------------------------------------------------------------------------------------------------- - - SMODS._Loc_Pre = SMODS.GameObject:extend { - obj_table = {}, - obj_buffer = {}, - silent = true, - set = '[INTERNAL]', - register = function() error('INTERNAL CLASS, DO NOT CALL') end, - pre_inject_class = function() - SMODS.handle_loc_file(SMODS.path) - if SMODS.dump_loc then SMODS.dump_loc.pre_inject = copy_table(G.localization) end - for _, mod in ipairs(SMODS.mod_list) do - if mod.process_loc_text and type(mod.process_loc_text) == 'function' then - mod.process_loc_text() - end - end - end - } - - ------------------------------------------------------------------------------------------------- - ----- API CODE GameObject.Atlas - ------------------------------------------------------------------------------------------------- - - SMODS.Atlases = {} - SMODS.Atlas = SMODS.GameObject:extend { - obj_table = SMODS.Atlases, - obj_buffer = {}, - disable_mipmap = false, - required_params = { - 'key', - 'path', - 'px', - 'py' - }, - atlas_table = 'ASSET_ATLAS', - set = 'Atlas', - register = function(self) - if self.registered then - sendWarnMessage(('Detected duplicate register call on object %s'):format(self.key), self.set) - return - end - if self.language then - self.key_noloc = self.key - self.key = ('%s_%s'):format(self.key, self.language) - end - -- needed for changing high contrast settings, apparently - self.name = self.key - SMODS.Atlas.super.register(self) - end, - inject = function(self) - local file_path = type(self.path) == 'table' and - ((G.SETTINGS.real_language and self.path[G.SETTINGS.real_language]) or self.path[G.SETTINGS.language] or self.path['default'] or self.path['en-us']) or self.path - if file_path == 'DEFAULT' then return end - -- language specific sprites override fully defined sprites only if that language is set - if self.language and G.SETTINGS.language ~= self.language and G.SETTINGS.real_language ~= self.language then return end - if not self.language and (self.obj_table[('%s_%s'):format(self.key, G.SETTINGS.language)] or self.obj_table[('%s_%s'):format(self.key, G.SETTINGS.real_language)]) then return end - self.full_path = (self.mod and self.mod.path or SMODS.path) .. - 'assets/' .. G.SETTINGS.GRAPHICS.texture_scaling .. 'x/' .. file_path - local file_data = assert(NFS.newFileData(self.full_path), - ('Failed to collect file data for Atlas %s'):format(self.key)) - self.image_data = assert(love.image.newImageData(file_data), - ('Failed to initialize image data for Atlas %s'):format(self.key)) - self.image = love.graphics.newImage(self.image_data, - { mipmaps = true, dpiscale = G.SETTINGS.GRAPHICS.texture_scaling }) - G[self.atlas_table][self.key_noloc or self.key] = self - - local mipmap_level = SMODS.config.graphics_mipmap_level_options[SMODS.config.graphics_mipmap_level] - if not self.disable_mipmap and mipmap_level and mipmap_level > 0 then - self.image:setMipmapFilter('linear', mipmap_level) - end - end, - process_loc_text = function() end, - pre_inject_class = function(self) - G:set_render_settings() -- restore originals first in case a texture pack was disabled - end - } - - SMODS.Atlas { - key = 'mod_tags', - path = 'mod_tags.png', - px = 34, - py = 34, - } - SMODS.Atlas { - key = 'achievements', - path = 'default_achievements.png', - px = 66, - py = 66, - } - - ------------------------------------------------------------------------------------------------- - ----- API CODE GameObject.Sound - ------------------------------------------------------------------------------------------------- - - SMODS.Sounds = {} - SMODS.Sound = SMODS.GameObject:extend { - obj_buffer = {}, - set = 'Sound', - obj_table = SMODS.Sounds, - stop_sounds = {}, - replace_sounds = {}, - required_params = { - 'key', - 'path' - }, - process_loc_text = function() end, - register = function(self) - if self.registered then - sendWarnMessage(('Detected duplicate register call on object %s'):format(self.key), self.set) - return - end - self.sound_code = self.key - if self.replace then - local replace, times, args - if type(self.replace) == 'table' then - replace, times, args = self.replace.key, self.replace.times or -1, self.replace.args - else - replace, times = self.replace, -1 - end - self.replace_sounds[replace] = { key = self.key, times = times, args = args } - end - -- TODO detect music state based on if select_music_track exists - assert(not self.select_music_track or self.key:find('music')) - SMODS.Sound.super.register(self) - end, - inject = function(self) - local file_path = type(self.path) == 'table' and - ((G.SETTINGS.real_language and self.path[G.SETTINGS.real_language]) or self.path[G.SETTINGS.language] or self.path['default'] or self.path['en-us']) or self.path - if file_path == 'DEFAULT' then return end - local prev_path = self.full_path - self.full_path = (self.mod and self.mod.path or SMODS.path) .. - 'assets/sounds/' .. file_path - if prev_path == self.full_path then return end - self.data = NFS.read('data', self.full_path) - --self.decoder = love.sound.newDecoder(self.data) - self.should_stream = string.find(self.key, 'music') or string.find(self.key, 'stream') or string.find(self.key, 'ambient') - --self.sound = love.audio.newSource(self.decoder, self.should_stream and 'stream' or 'static') - if prev_path then G.SOUND_MANAGER.channel:push({ type = 'stop' }) end - G.SOUND_MANAGER.channel:push({ type = 'sound_source', sound_code = self.sound_code, data = self.data, should_stream = self.should_stream, per = self.pitch, vol = self.volume }) - end, - register_global = function(self) - local mod = SMODS.current_mod - if not mod then return end - for _, filename in ipairs(NFS.getDirectoryItems(mod.path .. 'assets/sounds/')) do - local extension = string.sub(filename, -4) - if extension == '.ogg' or extension == '.mp3' or extension == '.wav' then -- please use .ogg or .wav files - local sound_code = string.sub(filename, 1, -5) - self { - key = sound_code, - path = filename, - } - end - end - end, - -- retaining this function for mod compat - play = function(self, pitch, volume, stop_previous_instance, key) - return play_sound(key or self.sound_code, pitch, volume) - end, - create_stop_sound = function(self, key, times) - times = times or -1 - self.stop_sounds[key] = times - end, - create_replace_sound = function(self, replace_sound) - self.replace = replace_sound - local replace, times, args - if type(self.replace) == 'table' then - replace, times, args = self.replace.key, self.replace.times or -1, self.replace.args - else - replace, times = self.replace, -1 - end - self.replace_sounds[replace] = { key = self.key, times = times, args = args } - end, - get_current_music = function(self) - local track - local maxp = -math.huge - for _, v in ipairs(self.obj_buffer) do - local s = self.obj_table[v] - if type(s.select_music_track) == 'function' then - local res = s:select_music_track() - if res then - if type(res) ~= 'number' then res = 0 end - if res > maxp then track, maxp = v, res end - end - end - end - return track - end - } - - local play_sound_ref = play_sound - function play_sound(sound_code, per, vol) - local replace_sound = SMODS.Sound.replace_sounds[sound_code] - if replace_sound then - local sound = SMODS.Sounds[replace_sound.key] - local rt - if replace_sound.args then - local args = replace_sound.args - if type(args) == 'function' then args = args(sound, { pitch = per, volume = vol }) end - play_sound(sound.sound_code, args.pitch, args.volume) - if not args.continue_base_sound then rt = true end - else - play_sound(sound.sound_code, per, vol) - rt = true - end - if replace_sound.times > 0 then replace_sound.times = replace_sound.times - 1 end - if replace_sound.times == 0 then SMODS.Sound.replace_sounds[sound_code] = nil end - if rt then return end - end - local stop_sound = SMODS.Sound.stop_sounds[sound_code] - if stop_sound then - if stop_sound > 0 then - SMODS.Sound.stop_sounds[sound_code] = stop_sound - 1 - end - return - end - - return play_sound_ref(sound_code, per, vol) - end - - SMODS.Sound{ key = 'xchips', path = 'xchips.ogg'} - - ------------------------------------------------------------------------------------------------- - ----- API CODE GameObject.Stake - ------------------------------------------------------------------------------------------------- - - SMODS.Stakes = {} - SMODS.Stake = SMODS.GameObject:extend { - obj_table = SMODS.Stakes, - obj_buffer = {}, - class_prefix = 'stake', - unlocked = false, - set = 'Stake', - atlas = 'chips', - pos = { x = 0, y = 0 }, - injected = false, - required_params = { - 'key', - 'pos', - 'applied_stakes' - }, - pre_inject_class = function(self) - G.P_CENTER_POOLS[self.set] = {} - G.P_STAKES = {} - end, - inject = function(self) - if not self.injected then - -- Inject stake in the correct spot - self.count = #G.P_CENTER_POOLS[self.set] + 1 - self.order = self.count - if self.above_stake and G.P_STAKES[self.above_stake] then - self.order = G.P_STAKES[self.above_stake].order + 1 - end - for _, v in pairs(G.P_STAKES) do - if v.order >= self.order then - v.order = v.order + 1 - end - end - G.P_STAKES[self.key] = self - table.insert(G.P_CENTER_POOLS.Stake, self) - -- Sticker sprites (stake_ prefix is removed for vanilla compatiblity) - if self.sticker_pos ~= nil then - G.shared_stickers[self.key:sub(7)] = Sprite(0, 0, G.CARD_W, G.CARD_H, - G.ASSET_ATLAS[self.sticker_atlas] or G.ASSET_ATLAS["stickers"], self.sticker_pos) - G.sticker_map[self.key] = self.key:sub(7) - else - G.sticker_map[self.key] = nil - end - else - G.P_STAKES[self.key] = self - SMODS.insert_pool(G.P_CENTER_POOLS.Stake, self) - end - self.injected = true - -- should only need to do this once per injection routine - end, - post_inject_class = function(self) - table.sort(G.P_CENTER_POOLS[self.set], function(a, b) return a.order < b.order end) - for _,stake in pairs(G.P_CENTER_POOLS.Stake) do - local applied = SMODS.build_stake_chain(stake) - stake.stake_level = 0 - for i,_ in ipairs(G.P_CENTER_POOLS.Stake) do - if applied[i] then stake.stake_level = stake.stake_level+1 end - end - end - G.C.STAKES = {} - for i = 1, #G.P_CENTER_POOLS[self.set] do - G.C.STAKES[i] = G.P_CENTER_POOLS[self.set][i].colour or G.C.WHITE - end - end, - process_loc_text = function(self) - -- empty loc_txt indicates there are existing values that shouldn't be changed or it isn't necessary - if not self.loc_txt or not next(self.loc_txt) then return end - local target = (G.SETTINGS.real_language and self.loc_txt[G.SETTINGS.real_language]) or self.loc_txt[G.SETTINGS.language] or self.loc_txt['default'] or self.loc_txt['en-us'] or - self.loc_txt - local applied_text = "{s:0.8}" .. localize('b_applies_stakes_1') - local any_applied - for _, v in pairs(self.applied_stakes) do - any_applied = true - applied_text = applied_text .. - localize { set = self.set, key = v, type = 'name_text' } .. ', ' - end - applied_text = applied_text:sub(1, -3) - if not any_applied then - applied_text = "{s:0.8}" - else - applied_text = applied_text .. localize('b_applies_stakes_2') - end - local desc_target = copy_table(target) - table.insert(desc_target.text, applied_text) - G.localization.descriptions[self.set][self.key] = desc_target - SMODS.process_loc_text(G.localization.descriptions["Other"], self.key:sub(7) .. "_sticker", self.loc_txt, - 'sticker') - end, - get_obj = function(self, key) return G.P_STAKES[key] end - } - - function SMODS.build_stake_chain(stake, applied) - if not applied then applied = {} end - if not stake or applied[stake.order] then return end - applied[stake.order] = stake.order - if not stake.applied_stakes then - return applied - end - for _, s in pairs(stake.applied_stakes) do - SMODS.build_stake_chain(G.P_STAKES[s], applied) - end - return applied - end - - function SMODS.setup_stake(i) - local applied_stakes = SMODS.build_stake_chain(G.P_CENTER_POOLS.Stake[i]) - for stake, _ in pairs(applied_stakes) do - if G.P_CENTER_POOLS['Stake'][stake].modifiers then - G.P_CENTER_POOLS['Stake'][stake].modifiers() - end - end - end - - --Register vanilla stakes - G.P_STAKES = {} - SMODS.Stake { - name = "White Stake", - key = "white", - unlocked_stake = "red", - unlocked = true, - applied_stakes = {}, - pos = { x = 0, y = 0 }, - sticker_pos = { x = 1, y = 0 }, - colour = G.C.WHITE, - loc_txt = {} - } - SMODS.Stake { - name = "Red Stake", - key = "red", - unlocked_stake = "green", - applied_stakes = { "white" }, - pos = { x = 1, y = 0 }, - sticker_pos = { x = 2, y = 0 }, - modifiers = function() - G.GAME.modifiers.no_blind_reward = G.GAME.modifiers.no_blind_reward or {} - G.GAME.modifiers.no_blind_reward.Small = true - end, - colour = G.C.RED, - loc_txt = {} - } - SMODS.Stake { - name = "Green Stake", - key = "green", - unlocked_stake = "black", - applied_stakes = { "red" }, - pos = { x = 2, y = 0 }, - sticker_pos = { x = 3, y = 0 }, - modifiers = function() - G.GAME.modifiers.scaling = (G.GAME.modifiers.scaling or 1) + 1 - end, - colour = G.C.GREEN, - loc_txt = {} - } - SMODS.Stake { - name = "Black Stake", - key = "black", - unlocked_stake = "blue", - applied_stakes = { "green" }, - pos = { x = 4, y = 0 }, - sticker_pos = { x = 0, y = 1 }, - modifiers = function() - G.GAME.modifiers.enable_eternals_in_shop = true - end, - colour = G.C.BLACK, - loc_txt = {} - } - SMODS.Stake { - name = "Blue Stake", - key = "blue", - unlocked_stake = "purple", - applied_stakes = { "black" }, - pos = { x = 3, y = 0 }, - sticker_pos = { x = 4, y = 0 }, - modifiers = function() - G.GAME.starting_params.discards = G.GAME.starting_params.discards - 1 - end, - colour = G.C.BLUE, - loc_txt = {} - } - SMODS.Stake { - name = "Purple Stake", - key = "purple", - unlocked_stake = "orange", - applied_stakes = { "blue" }, - pos = { x = 0, y = 1 }, - sticker_pos = { x = 1, y = 1 }, - modifiers = function() - G.GAME.modifiers.scaling = (G.GAME.modifiers.scaling or 1) + 1 - end, - colour = G.C.PURPLE, - loc_txt = {} - } - SMODS.Stake { - name = "Orange Stake", - key = "orange", - unlocked_stake = "gold", - applied_stakes = { "purple" }, - pos = { x = 1, y = 1 }, - sticker_pos = { x = 2, y = 1 }, - modifiers = function() - G.GAME.modifiers.enable_perishables_in_shop = true - end, - colour = G.C.ORANGE, - loc_txt = {} - } - SMODS.Stake { - name = "Gold Stake", - key = "gold", - applied_stakes = { "orange" }, - pos = { x = 2, y = 1 }, - sticker_pos = { x = 3, y = 1 }, - modifiers = function() - G.GAME.modifiers.enable_rentals_in_shop = true - end, - colour = G.C.GOLD, - shiny = true, - loc_txt = {} - } - - ------------------------------------------------------------------------------------------------- - ------- API CODE GameObject.Rarity - ------------------------------------------------------------------------------------------------- - - SMODS.Rarities = {} - SMODS.Rarity = SMODS.GameObject:extend { - obj_table = SMODS.Rarities, - obj_buffer = {}, - set = 'Rarity', - required_params = { - 'key', - }, - badge_colour = HEX 'FFFFFF', - default_weight = 0, - inject = function(self) - G.P_JOKER_RARITY_POOLS[self.key] = {} - G.C.RARITY[self.key] = self.badge_colour - end, - process_loc_text = function(self) - SMODS.process_loc_text(G.localization.misc.labels, "k_"..self.key:lower(), self.loc_txt, 'name') - SMODS.process_loc_text(G.localization.misc.dictionary, "k_"..self.key:lower(), self.loc_txt, 'name') - end, - get_rarity_badge = function(self, rarity) - local vanilla_rarity_keys = {localize('k_common'), localize('k_uncommon'), localize('k_rare'), localize('k_legendary')} - if (vanilla_rarity_keys)[rarity] then - return vanilla_rarity_keys[rarity] --compat layer in case function gets the int of the rarity - else - return localize("k_"..rarity:lower()) - end - end, - } - - function SMODS.inject_rarity(object_type, rarity) - if not object_type.rarities then - object_type.rarities = {} - object_type.rarity_pools = {} - end - object_type.rarities[#object_type.rarities+1] = { - key = rarity.key, - weight = type(rarity.pools[object_type.key]) == "table" and rarity.pools[object_type.key].weight or rarity.default_weight - } - for _, vv in ipairs(object_type.rarities) do - local default_rarity_check = {["Common"] = 1, ["Uncommon"] = 2, ["Rare"] = 3, ["Legendary"] = 4} - if default_rarity_check[vv.key] then - object_type.rarity_pools[default_rarity_check[vv.key]] = {} - else - object_type.rarity_pools[vv.key] = {} - end - end - end - - local game_init_game_object_ref = Game.init_game_object - function Game:init_game_object() - local t = game_init_game_object_ref(self) - for _, v in pairs(SMODS.Rarities) do - local key = v.key:lower() .. '_mod' - t[key] = t[key] or 1 - end - return t - end - - SMODS.Rarity{ - key = "Common", - loc_txt = {}, - default_weight = 0.7, - badge_colour = HEX('009dff'), - get_weight = function(self, weight, object_type) - return weight - end, - } - - SMODS.Rarity{ - key = "Uncommon", - loc_txt = {}, - default_weight = 0.25, - badge_colour = HEX("4BC292"), - get_weight = function(self, weight, object_type) - return weight - end, - } - - SMODS.Rarity{ - key = "Rare", - loc_txt = {}, - default_weight = 0.05, - badge_colour = HEX('fe5f55'), - get_weight = function(self, weight, object_type) - return weight - end, - } - - SMODS.Rarity{ - key = "Legendary", - loc_txt = {}, - default_weight = 0, - badge_colour = HEX("b26cbb"), - get_weight = function(self, weight, object_type) - return weight - end, - } - - ------------------------------------------------------------------------------------------------- - ------- API CODE GameObject.ObjectType - ------------------------------------------------------------------------------------------------- - - SMODS.ObjectTypes = {} - SMODS.ObjectType = SMODS.GameObject:extend { - obj_table = SMODS.ObjectTypes, - obj_buffer = {}, - set = 'ObjectType', - required_params = { - 'key', - }, - prefix_config = { key = false }, - inject = function(self) - G.P_CENTER_POOLS[self.key] = G.P_CENTER_POOLS[self.key] or {} - local injected_rarities = {} - if self.rarities then - self.rarity_pools = {} - for _, v in ipairs(self.rarities) do - if not v.weight then v.weight = SMODS.Rarities[v.key].default_weight end - local default_rarity_check = {["Common"] = 1, ["Uncommon"] = 2, ["Rare"] = 3, ["Legendary"] = 4} - if default_rarity_check[v.key] then - self.rarity_pools[default_rarity_check[v.key]] = {} - else - self.rarity_pools[v.key] = {} - end - injected_rarities[v.key] = true - end - end - for _, v in pairs(SMODS.Rarities) do - if v.pools and v.pools[self.key] and not injected_rarities[v.key] then SMODS.inject_rarity(self, v) end - end - end, - inject_card = function(self, center) - if center.set ~= self.key then SMODS.insert_pool(G.P_CENTER_POOLS[self.key], center) end - local default_rarity_check = {["Common"] = 1, ["Uncommon"] = 2, ["Rare"] = 3, ["Legendary"] = 4} - if self.rarities and center.rarity and self.rarity_pools[default_rarity_check[center.rarity] or center.rarity] then - SMODS.insert_pool(self.rarity_pools[default_rarity_check[center.rarity] or center.rarity], center) - end - end, - delete_card = function(self, center) - if center.set ~= self.key then SMODS.remove_pool(G.P_CENTER_POOLS[self.key], center.key) end - local default_rarity_check = {["Common"] = 1, ["Uncommon"] = 2, ["Rare"] = 3, ["Legendary"] = 4} - if self.rarities and center.rarity and self.rarity_pools[default_rarity_check[center.rarity] or center.rarity] then - SMODS.remove_pool(self.rarity_pools[default_rarity_check[center.rarity] or center.rarity], center.key) - end - end, - } - - SMODS.ObjectType{ - key = "Joker", - rarities = { - { key = "Common" }, - { key = "Uncommon" }, - { key = "Rare" }, - }, - } - - ------------------------------------------------------------------------------------------------- - ------- API CODE GameObject.ConsumableType - ------------------------------------------------------------------------------------------------- - - SMODS.ConsumableTypes = {} - SMODS.ConsumableType = SMODS.ObjectType:extend { - ctype_buffer = {}, - set = 'ConsumableType', - required_params = { - 'key', - 'primary_colour', - 'secondary_colour', - }, - prefix_config = { key = false }, - collection_rows = { 6, 6 }, - create_UIBox_your_collection = function(self) - local type_buf = {} - for _, v in ipairs(SMODS.ConsumableType.ctype_buffer) do - if not v.no_collection and (not G.ACTIVE_MOD_UI or modsCollectionTally(G.P_CENTER_POOLS[v]).of > 0) then type_buf[#type_buf + 1] = v end - end - return SMODS.card_collection_UIBox(G.P_CENTER_POOLS[self.key], self.collection_rows, { back_func = #type_buf>3 and 'your_collection_consumables' or nil }) - end, - register = function(self) - SMODS.ConsumableType.super.register(self) - if self:check_dependencies() then - SMODS.ConsumableType.ctype_buffer[#SMODS.ConsumableType.ctype_buffer+1] = self.key - end - end, - inject = function(self) - SMODS.ObjectType.inject(self) - SMODS.ConsumableTypes[self.key] = self - G.localization.descriptions[self.key] = G.localization.descriptions[self.key] or {} - G.C.SET[self.key] = self.primary_colour - G.C.SECONDARY_SET[self.key] = self.secondary_colour - G.FUNCS['your_collection_' .. string.lower(self.key) .. 's'] = function(e) - G.SETTINGS.paused = true - G.FUNCS.overlay_menu { - definition = self:create_UIBox_your_collection(), - } - end - end, - process_loc_text = function(self) - SMODS.process_loc_text(G.localization.misc.dictionary, 'k_' .. string.lower(self.key), self.loc_txt, 'name') - SMODS.process_loc_text(G.localization.misc.dictionary, 'b_' .. string.lower(self.key) .. '_cards', - self.loc_txt, 'collection') - SMODS.process_loc_text(G.localization.descriptions.Other, 'undiscovered_' .. string.lower(self.key), - self.loc_txt, 'undiscovered') - end, - } - - SMODS.ConsumableType { - key = 'Tarot', - collection_rows = { 5, 6 }, - primary_colour = G.C.SET.Tarot, - secondary_colour = G.C.SECONDARY_SET.Tarot, - inject_card = function(self, center) - SMODS.ObjectType.inject_card(self, center) - SMODS.insert_pool(G.P_CENTER_POOLS['Tarot_Planet'], center) - end, - delete_card = function(self, center) - SMODS.ObjectType.delete_card(self, center) - SMODS.remove_pool(G.P_CENTER_POOLS['Tarot_Planet'], center.key) - end, - loc_txt = {}, - } - SMODS.ConsumableType { - key = 'Planet', - collection_rows = { 6, 6 }, - primary_colour = G.C.SET.Planet, - secondary_colour = G.C.SECONDARY_SET.Planet, - inject_card = function(self, center) - SMODS.ObjectType.inject_card(self, center) - SMODS.insert_pool(G.P_CENTER_POOLS['Tarot_Planet'], center) - end, - delete_card = function(self, center) - SMODS.ObjectType.delete_card(self, center) - SMODS.remove_pool(G.P_CENTER_POOLS['Tarot_Planet'], center.key) - end, - loc_txt = {}, - } - SMODS.ConsumableType { - key = 'Spectral', - collection_rows = { 4, 5 }, - primary_colour = G.C.SET.Spectral, - secondary_colour = G.C.SECONDARY_SET.Spectral, - loc_txt = {}, - } - - local game_init_game_object_ref = Game.init_game_object - function Game:init_game_object() - local t = game_init_game_object_ref(self) - for _, v in pairs(SMODS.ConsumableTypes) do - local key = v.key:lower() .. '_rate' - t[key] = v.shop_rate or t[key] or 0 - end - return t - end - - ------------------------------------------------------------------------------------------------- - ----- API CODE GameObject.Center - ------------------------------------------------------------------------------------------------- - - SMODS.Centers = {} - --- Shared class for center objects. Holds no default values; only register an object directly using this if it doesn't fit any subclass, creating one isn't justified and you know what you're doing. - SMODS.Center = SMODS.GameObject:extend { - obj_table = SMODS.Centers, - obj_buffer = {}, - set = 'Center', -- For logging purposes | Subclasses should change this - get_obj = function(self, key) return G.P_CENTERS[key] end, - register = function(self) - -- 0.9.8 defense - self.name = self.name or self.key - SMODS.Center.super.register(self) - end, - inject = function(self) - G.P_CENTERS[self.key] = self - if not self.omit then SMODS.insert_pool(G.P_CENTER_POOLS[self.set], self) end - for k, v in pairs(SMODS.ObjectTypes) do - -- Should "cards" be formatted as `{[
    ] = true}` or {
    }? - -- Changing "cards" and "pools" wouldn't be hard to do, just depends on preferred format - if ((self.pools and self.pools[k]) or (v.cards and v.cards[self.key])) then - SMODS.ObjectTypes[k]:inject_card(self) - end - end - end, - delete = function(self) - G.P_CENTERS[self.key] = nil - SMODS.remove_pool(G.P_CENTER_POOLS[self.set], self.key) - for k, v in pairs(SMODS.ObjectTypes) do - if ((self.pools and self.pools[k]) or (v.cards and v.cards[self.key])) then - SMODS.ObjectTypes[k]:remove_card(self) - end - end - local j - for i, v in ipairs(self.obj_buffer) do - if v == self.key then j = i end - end - if j then table.remove(self.obj_buffer, j) end - self = nil - return true - end, - create_fake_card = function(self) - return { ability = copy_table(self.config), fake_card = true } - end, - generate_ui = function(self, info_queue, card, desc_nodes, specific_vars, full_UI_table) - if not card then - card = self:create_fake_card() - end - local target = { - type = 'descriptions', - key = self.key, - set = self.set, - nodes = desc_nodes, - vars = - specific_vars or {} - } - local res = {} - if self.loc_vars and type(self.loc_vars) == 'function' then - res = self:loc_vars(info_queue, card) or {} - target.vars = res.vars or target.vars - target.key = res.key or target.key - target.set = res.set or target.set - target.scale = res.scale - target.text_colour = res.text_colour - end - if desc_nodes == full_UI_table.main and not full_UI_table.name then - full_UI_table.name = self.set == 'Enhanced' and 'temp_value' or localize { type = 'name', set = target.set, key = res.name_key or target.key, nodes = full_UI_table.name, vars = res.name_vars or target.vars or {} } - elseif desc_nodes ~= full_UI_table.main and not desc_nodes.name and self.set ~= 'Enhanced' then - desc_nodes.name = localize{type = 'name_text', key = res.name_key or target.key, set = target.set } - end - if specific_vars and specific_vars.debuffed and not res.replace_debuff then - target = { type = 'other', key = 'debuffed_' .. - (specific_vars.playing_card and 'playing_card' or 'default'), nodes = desc_nodes } - end - if res.main_start then - desc_nodes[#desc_nodes + 1] = res.main_start - end - localize(target) - if res.main_end then - desc_nodes[#desc_nodes + 1] = res.main_end - end - desc_nodes.background_colour = res.background_colour - end - } - - ------------------------------------------------------------------------------------------------- - ------- API CODE GameObject.Center.Joker - ------------------------------------------------------------------------------------------------- - - SMODS.Joker = SMODS.Center:extend { - rarity = 1, - unlocked = true, - discovered = false, - blueprint_compat = false, - perishable_compat = true, - eternal_compat = true, - pos = { x = 0, y = 0 }, - cost = 3, - config = {}, - set = 'Joker', - atlas = 'Joker', - class_prefix = 'j', - required_params = { - 'key', - }, - inject = function(self) - -- call the parent function to ensure all pools are set - SMODS.Center.inject(self) - if self.taken_ownership and self.rarity_original == self.rarity then - SMODS.remove_pool(G.P_JOKER_RARITY_POOLS[self.rarity_original], self.key) - SMODS.insert_pool(G.P_JOKER_RARITY_POOLS[self.rarity], self, false) - else - SMODS.insert_pool(G.P_JOKER_RARITY_POOLS[self.rarity], self) - local vanilla_rarities = {["Common"] = 1, ["Uncommon"] = 2, ["Rare"] = 3, ["Legendary"] = 4} - if vanilla_rarities[self.rarity] then - SMODS.insert_pool(G.P_JOKER_RARITY_POOLS[vanilla_rarities[self.rarity]], self) - end - end - end - } - - ------------------------------------------------------------------------------------------------- - ------- API CODE GameObject.Center.Consumable - ------------------------------------------------------------------------------------------------- - - SMODS.Consumable = SMODS.Center:extend { - unlocked = true, - discovered = false, - consumeable = true, - pos = { x = 0, y = 0 }, - atlas = 'Tarot', - legendaries = {}, - cost = 3, - config = {}, - class_prefix = 'c', - required_params = { - 'set', - 'key', - }, - inject = function(self) - SMODS.Center.inject(self) - SMODS.insert_pool(G.P_CENTER_POOLS['Consumeables'], self) - self.type = SMODS.ConsumableTypes[self.set] - if self.hidden then - self.soul_set = self.soul_set or 'Spectral' - self.soul_rate = self.soul_rate or 0.003 - table.insert(self.legendaries, self) - end - if self.type and self.type.inject_card and type(self.type.inject_card) == 'function' then - self.type:inject_card(self) - end - end, - delete = function(self) - if self.type and self.type.delete_card and type(self.type.delete_card) == 'function' then - self.type:delete_card(self) - end - SMODS.remove_pool(G.P_CENTER_POOLS['Consumeables'], self.key) - SMODS.Consumable.super.delete(self) - end, - create_fake_card = function(self) - local ret = SMODS.Center.create_fake_card(self) - ret.ability.consumeable = copy_table(self.config) - return ret - end, - loc_vars = function(self, info_queue) - return {} - end - } - - SMODS.Tarot = SMODS.Consumable:extend { - set = 'Tarot', - } - SMODS.Planet = SMODS.Consumable:extend { - set = 'Planet', - atlas = 'Planet', - } - SMODS.Spectral = SMODS.Consumable:extend { - set = 'Spectral', - atlas = 'Spectral', - cost = 4, - } - - - ------------------------------------------------------------------------------------------------- - ------- API CODE GameObject.Center.Voucher - ------------------------------------------------------------------------------------------------- - - SMODS.Voucher = SMODS.Center:extend { - set = 'Voucher', - cost = 10, - atlas = 'Voucher', - discovered = false, - unlocked = true, - available = true, - pos = { x = 0, y = 0 }, - config = {}, - class_prefix = 'v', - required_params = { - 'key', - } - } - - SMODS.Voucher:take_ownership('observatory', { - calculate = function(self, card, context) - if - context.other_consumeable and - context.other_consumeable.ability.set == 'Planet' and - context.other_consumeable.ability.consumeable.hand_type == context.scoring_name - then - return { - x_mult = card.ability.extra - } - end - end, - }) - - ------------------------------------------------------------------------------------------------- - ------- API CODE GameObject.Center.Back - ------------------------------------------------------------------------------------------------- - - SMODS.Back = SMODS.Center:extend { - set = 'Back', - discovered = false, - unlocked = true, - atlas = 'centers', - pos = { x = 0, y = 0 }, - config = {}, - omit = false, - unlock_condition = {}, - stake = 1, - class_prefix = 'b', - required_params = { - 'key', - }, - register = function(self) - -- game expects a name, so ensure it's set - self.name = self.name or self.key - SMODS.Back.super.register(self) - end - } - - -- set the correct stake level for unlocks when injected (spares me from completely overwriting the unlock checks) - local function stake_mod(stake) - return { - inject = function(self) - self.unlock_condition.stake = SMODS.Stakes[stake].order - SMODS.Back.inject(self) - end - } - end - SMODS.Back:take_ownership('zodiac', stake_mod('stake_red')) - SMODS.Back:take_ownership('painted', stake_mod('stake_green')) - SMODS.Back:take_ownership('anaglyph', stake_mod('stake_black')) - SMODS.Back:take_ownership('plasma', stake_mod('stake_blue')) - SMODS.Back:take_ownership('erratic', stake_mod('stake_orange')) - - ------------------------------------------------------------------------------------------------- - ----- API CODE GameObject.Center.Booster - ------------------------------------------------------------------------------------------------- - - SMODS.OPENED_BOOSTER = nil - SMODS.Booster = SMODS.Center:extend { - required_params = { - 'key', - }, - class_prefix = 'p', - set = "Booster", - atlas = "Booster", - pos = {x = 0, y = 0}, - loc_txt = {}, - discovered = false, - weight = 1, - cost = 4, - config = {extra = 3, choose = 1}, - process_loc_text = function(self) - SMODS.process_loc_text(G.localization.descriptions.Other, self.key, self.loc_txt) - SMODS.process_loc_text(G.localization.misc.dictionary, 'k_booster_group_'..self.key, self.loc_txt, 'group_name') - end, - loc_vars = function(self, info_queue, card) - return { vars = {card.ability.choose, card.ability.extra} } - end, - generate_ui = function(self, info_queue, card, desc_nodes, specific_vars, full_UI_table) - if not card then - card = self:create_fake_card() - end - local target = { - type = 'other', - key = self.key, - nodes = desc_nodes, - vars = {} - } - local res = {} - if self.loc_vars and type(self.loc_vars) == 'function' then - res = self:loc_vars(info_queue, card) or {} - target.vars = res.vars or target.vars - target.key = res.key or target.key - target.scale = res.scale - target.text_colour = res.text_colour - end - if desc_nodes == full_UI_table.main and not full_UI_table.name then - full_UI_table.name = localize{type = 'name', set = 'Other', key = res.name_key or target.key, nodes = full_UI_table.name, vars = res.name_vars or target.vars or {}} - elseif desc_nodes ~= full_UI_table.main and not desc_nodes.name then - desc_nodes.name = localize{type = 'name_text', key = res.name_key or target.key, set = 'Other' } - end - localize(target) - desc_nodes.background_colour = res.background_colour - end, - --[[ - create_card = function(self, card) - -- Example - -- return {set = "Joker", area = G.pack_cards, skip_materialize = true, soulable = true, key_append = "buf"} - end, - --]] - update_pack = function(self, dt) - if G.buttons then G.buttons:remove(); G.buttons = nil end - if G.shop then G.shop.alignment.offset.y = G.ROOM.T.y+11 end - - if not G.STATE_COMPLETE then - G.STATE_COMPLETE = true - G.CONTROLLER.interrupt.focus = true - G.E_MANAGER:add_event(Event({ - trigger = 'immediate', - func = function() - if self.particles and type(self.particles) == "function" then self:particles() end - G.booster_pack = UIBox{ - definition = self:create_UIBox(), - config = {align="tmi", offset = {x=0,y=G.ROOM.T.y + 9}, major = G.hand, bond = 'Weak'} - } - G.booster_pack.alignment.offset.y = -2.2 - G.ROOM.jiggle = G.ROOM.jiggle + 3 - self:ease_background_colour() - G.E_MANAGER:add_event(Event({ - trigger = 'immediate', - func = function() - if self.draw_hand == true then G.FUNCS.draw_from_deck_to_hand() end - - G.E_MANAGER:add_event(Event({ - trigger = 'after', - delay = 0.5, - func = function() - G.CONTROLLER:recall_cardarea_focus('pack_cards') - return true - end})) - return true - end - })) - return true - end - })) - end - end, - ease_background_colour = function(self) - ease_colour(G.C.DYN_UI.MAIN, G.C.FILTER) - ease_background_colour{new_colour = G.C.FILTER, special_colour = G.C.BLACK, contrast = 2} - end, - create_UIBox = function(self) - local _size = SMODS.OPENED_BOOSTER.ability.extra - G.pack_cards = CardArea( - G.ROOM.T.x + 9 + G.hand.T.x, G.hand.T.y, - math.max(1,math.min(_size,5))*G.CARD_W*1.1, - 1.05*G.CARD_H, - {card_limit = _size, type = 'consumeable', highlight_limit = 1}) - - local t = {n=G.UIT.ROOT, config = {align = 'tm', r = 0.15, colour = G.C.CLEAR, padding = 0.15}, nodes={ - {n=G.UIT.R, config={align = "cl", colour = G.C.CLEAR,r=0.15, padding = 0.1, minh = 2, shadow = true}, nodes={ - {n=G.UIT.R, config={align = "cm"}, nodes={ - {n=G.UIT.C, config={align = "cm", padding = 0.1}, nodes={ - {n=G.UIT.C, config={align = "cm", r=0.2, colour = G.C.CLEAR, shadow = true}, nodes={ - {n=G.UIT.O, config={object = G.pack_cards}},}}}}}}, - {n=G.UIT.R, config={align = "cm"}, nodes={}}, - {n=G.UIT.R, config={align = "tm"}, nodes={ - {n=G.UIT.C,config={align = "tm", padding = 0.05, minw = 2.4}, nodes={}}, - {n=G.UIT.C,config={align = "tm", padding = 0.05}, nodes={ - UIBox_dyn_container({ - {n=G.UIT.C, config={align = "cm", padding = 0.05, minw = 4}, nodes={ - {n=G.UIT.R,config={align = "bm", padding = 0.05}, nodes={ - {n=G.UIT.O, config={object = DynaText({string = localize(self.group_key or ('k_booster_group_'..self.key)), colours = {G.C.WHITE},shadow = true, rotate = true, bump = true, spacing =2, scale = 0.7, maxw = 4, pop_in = 0.5})}}}}, - {n=G.UIT.R,config={align = "bm", padding = 0.05}, nodes={ - {n=G.UIT.O, config={object = DynaText({string = {localize('k_choose')..' '}, colours = {G.C.WHITE},shadow = true, rotate = true, bump = true, spacing =2, scale = 0.5, pop_in = 0.7})}}, - {n=G.UIT.O, config={object = DynaText({string = {{ref_table = G.GAME, ref_value = 'pack_choices'}}, colours = {G.C.WHITE},shadow = true, rotate = true, bump = true, spacing =2, scale = 0.5, pop_in = 0.7})}}}},}} - }),}}, - {n=G.UIT.C,config={align = "tm", padding = 0.05, minw = 2.4}, nodes={ - {n=G.UIT.R,config={minh =0.2}, nodes={}}, - {n=G.UIT.R,config={align = "tm",padding = 0.2, minh = 1.2, minw = 1.8, r=0.15,colour = G.C.GREY, one_press = true, button = 'skip_booster', hover = true,shadow = true, func = 'can_skip_booster'}, nodes = { - {n=G.UIT.T, config={text = localize('b_skip'), scale = 0.5, colour = G.C.WHITE, shadow = true, focus_args = {button = 'y', orientation = 'bm'}, func = 'set_button_pip'}}}}}}}}}}}} - return t - end, - take_ownership_by_kind = function(self, kind, obj, silent) - for k, v in ipairs(G.P_CENTER_POOLS.Booster) do - if v.set == self.set and v.kind and v.kind == kind then - self:take_ownership(v.key, obj, silent) - end - end - end - } - - local pack_loc_vars = function(self, info_queue, card) - local cfg = (card and card.ability) or self.config - return { - vars = { cfg.choose, cfg.extra }, - key = self.key:sub(1, -3), - } - end - SMODS.Booster:take_ownership_by_kind('Arcana', { - group_key = "k_arcana_pack", - draw_hand = true, - update_pack = SMODS.Booster.update_pack, - ease_background_colour = function(self) ease_background_colour_blind(G.STATES.TAROT_PACK) end, - create_UIBox = function(self) return create_UIBox_arcana_pack() end, - particles = function(self) - G.booster_pack_sparkles = Particles(1, 1, 0,0, { - timer = 0.015, - scale = 0.2, - initialize = true, - lifespan = 1, - speed = 1.1, - padding = -1, - attach = G.ROOM_ATTACH, - colours = {G.C.WHITE, lighten(G.C.PURPLE, 0.4), lighten(G.C.PURPLE, 0.2), lighten(G.C.GOLD, 0.2)}, - fill = true - }) - G.booster_pack_sparkles.fade_alpha = 1 - G.booster_pack_sparkles:fade(1, 0) - end, - create_card = function(self, card, i) - local _card - if G.GAME.used_vouchers.v_omen_globe and pseudorandom('omen_globe') > 0.8 then - _card = {set = "Spectral", area = G.pack_cards, skip_materialize = true, soulable = true, key_append = "ar2"} - else - _card = {set = "Tarot", area = G.pack_cards, skip_materialize = true, soulable = true, key_append = "ar1"} - end - return _card - end, - loc_vars = pack_loc_vars, - }) - - SMODS.Booster:take_ownership_by_kind('Celestial', { - group_key = "k_celestial_pack", - update_pack = SMODS.Booster.update_pack, - ease_background_colour = function(self) ease_background_colour_blind(G.STATES.PLANET_PACK) end, - create_UIBox = function(self) return create_UIBox_celestial_pack() end, - particles = function(self) - G.booster_pack_stars = Particles(1, 1, 0,0, { - timer = 0.07, - scale = 0.1, - initialize = true, - lifespan = 15, - speed = 0.1, - padding = -4, - attach = G.ROOM_ATTACH, - colours = {G.C.WHITE, HEX('a7d6e0'), HEX('fddca0')}, - fill = true - }) - G.booster_pack_meteors = Particles(1, 1, 0,0, { - timer = 2, - scale = 0.05, - lifespan = 1.5, - speed = 4, - attach = G.ROOM_ATTACH, - colours = {G.C.WHITE}, - fill = true - }) - end, - create_card = function(self, card, i) - local _card - if G.GAME.used_vouchers.v_telescope and i == 1 then - local _planet, _hand, _tally = nil, nil, 0 - for k, v in ipairs(G.handlist) do - if G.GAME.hands[v].visible and G.GAME.hands[v].played > _tally then - _hand = v - _tally = G.GAME.hands[v].played - end - end - if _hand then - for k, v in pairs(G.P_CENTER_POOLS.Planet) do - if v.config.hand_type == _hand then - _planet = v.key - end - end - end - _card = {set = "Planet", area = G.pack_cards, skip_materialize = true, soulable = true, key = _planet, key_append = "pl1"} - else - _card = {set = "Planet", area = G.pack_cards, skip_materialize = true, soulable = true, key_append = "pl1"} - end - return _card - end, - loc_vars = pack_loc_vars, - }) - - SMODS.Booster:take_ownership_by_kind('Spectral', { - group_key = "k_spectral_pack", - draw_hand = true, - update_pack = SMODS.Booster.update_pack, - ease_background_colour = function(self) ease_background_colour_blind(G.STATES.SPECTRAL_PACK) end, - create_UIBox = function(self) return create_UIBox_spectral_pack() end, - particles = function(self) - G.booster_pack_sparkles = Particles(1, 1, 0,0, { - timer = 0.015, - scale = 0.1, - initialize = true, - lifespan = 3, - speed = 0.2, - padding = -1, - attach = G.ROOM_ATTACH, - colours = {G.C.WHITE, lighten(G.C.GOLD, 0.2)}, - fill = true - }) - G.booster_pack_sparkles.fade_alpha = 1 - G.booster_pack_sparkles:fade(1, 0) - end, - create_card = function(self, card, i) - return {set = "Spectral", area = G.pack_cards, skip_materialize = true, soulable = true, key_append = "spe"} - end, - loc_vars = pack_loc_vars, - }) - - SMODS.Booster:take_ownership_by_kind('Standard', { - group_key = "k_standard_pack", - update_pack = SMODS.Booster.update_pack, - ease_background_colour = function(self) ease_background_colour_blind(G.STATES.STANDARD_PACK) end, - create_UIBox = function(self) return create_UIBox_standard_pack() end, - particles = function(self) - G.booster_pack_sparkles = Particles(1, 1, 0,0, { - timer = 0.015, - scale = 0.3, - initialize = true, - lifespan = 3, - speed = 0.2, - padding = -1, - attach = G.ROOM_ATTACH, - colours = {G.C.BLACK, G.C.RED}, - fill = true - }) - G.booster_pack_sparkles.fade_alpha = 1 - G.booster_pack_sparkles:fade(1, 0) - end, - create_card = function(self, card, i) - local _edition = poll_edition('standard_edition'..G.GAME.round_resets.ante, 2, true) - local _seal = SMODS.poll_seal({mod = 10}) - return {set = (pseudorandom(pseudoseed('stdset'..G.GAME.round_resets.ante)) > 0.6) and "Enhanced" or "Base", edition = _edition, seal = _seal, area = G.pack_cards, skip_materialize = true, soulable = true, key_append = "sta"} - end, - loc_vars = pack_loc_vars, - }) - - SMODS.Booster:take_ownership_by_kind('Buffoon', { - group_key = "k_buffoon_pack", - update_pack = SMODS.Booster.update_pack, - ease_background_colour = function(self) ease_background_colour_blind(G.STATES.BUFFOON_PACK) end, - create_UIBox = function(self) return create_UIBox_buffoon_pack() end, - create_card = function(self, card) - return {set = "Joker", area = G.pack_cards, skip_materialize = true, soulable = true, key_append = "buf"} - end, - loc_vars = pack_loc_vars, - }) - - ------------------------------------------------------------------------------------------------- - ----- API CODE GameObject.UndiscoveredSprite - ------------------------------------------------------------------------------------------------- - - SMODS.UndiscoveredSprites = {} - SMODS.UndiscoveredSprite = SMODS.GameObject:extend { - obj_buffer = {}, - obj_table = SMODS.UndiscoveredSprites, - set = 'Undiscovered Sprite', - -- this is more consistent and allows for extension - process_loc_text = function() end, - inject = function(self) - if self.overlay_pos then - self.overlay_sprite = Sprite(0, 0, G.CARD_W, G.CARD_H, G.ASSET_ATLAS[self.atlas], self.overlay_pos) - self.no_overlay = true - end - end, - prefix_config = { key = false }, - required_params = { - 'key', - 'atlas', - 'pos', - } - } - SMODS.UndiscoveredSprite { key = 'Joker', atlas = 'Joker', pos = G.j_undiscovered.pos } - SMODS.UndiscoveredSprite { key = 'Edition', atlas = 'Joker', pos = G.j_undiscovered.pos } - SMODS.UndiscoveredSprite { key = 'Tarot', atlas = 'Tarot', pos = G.t_undiscovered.pos } - SMODS.UndiscoveredSprite { key = 'Planet', atlas = 'Tarot', pos = G.p_undiscovered.pos } - SMODS.UndiscoveredSprite { key = 'Spectral', atlas = 'Tarot', pos = G.s_undiscovered.pos } - SMODS.UndiscoveredSprite { key = 'Voucher', atlas = 'Voucher', pos = G.v_undiscovered.pos } - SMODS.UndiscoveredSprite { key = 'Booster', atlas = 'Booster', pos = G.booster_undiscovered.pos } - - ------------------------------------------------------------------------------------------------- - ----- API CODE GameObject.Blind - ------------------------------------------------------------------------------------------------- - - SMODS.Blinds = {} - SMODS.Blind = SMODS.GameObject:extend { - obj_table = SMODS.Blinds, - obj_buffer = {}, - class_prefix = 'bl', - debuff = {}, - vars = {}, - dollars = 5, - mult = 2, - atlas = 'blind_chips', - discovered = false, - pos = { x = 0, y = 0 }, - required_params = { - 'key', - }, - set = 'Blind', - get_obj = function(self, key) return G.P_BLINDS[key] end, - register = function(self) - self.name = self.name or self.key - SMODS.Blind.super.register(self) - end, - inject = function(self, i) - -- no pools to query length of, so we assign order manually - if not self.taken_ownership then - self.order = 30 + i - end - G.P_BLINDS[self.key] = self - end - } - SMODS.Blind:take_ownership('eye', { - set_blind = function(self, reset, silent) - if not reset then - G.GAME.blind.hands = {} - for _, v in ipairs(G.handlist) do - G.GAME.blind.hands[v] = false - end - end - end - }) - SMODS.Blind:take_ownership('wheel', { - loc_vars = function(self) - return { vars = { G.GAME.probabilities.normal } } - end, - collection_loc_vars = function(self) - return { vars = { '1' }} - end, - process_loc_text = function(self) - local text = G.localization.descriptions.Blind[self.key].text[1] - if string.sub(text, 1, 3) ~= '#1#' then - G.localization.descriptions.Blind[self.key].text[1] = "#1#"..text - end - SMODS.Blind.process_loc_text(self) - end, - get_loc_debuff_text = function() return G.GAME.blind.loc_debuff_text end, - }) - - ------------------------------------------------------------------------------------------------- - ----- API CODE GameObject.Seal - ------------------------------------------------------------------------------------------------- - - SMODS.Seals = {} - SMODS.Seal = SMODS.GameObject:extend { - obj_table = SMODS.Seals, - obj_buffer = {}, - rng_buffer = { 'Purple', 'Gold', 'Blue', 'Red' }, - badge_to_key = {}, - set = 'Seal', - atlas = 'centers', - pos = { x = 0, y = 0 }, - discovered = false, - badge_colour = HEX('FFFFFF'), - required_params = { - 'key', - 'pos', - }, - inject = function(self) - G.P_SEALS[self.key] = self - G.shared_seals[self.key] = Sprite(0, 0, G.CARD_W, G.CARD_H, - G.ASSET_ATLAS[self.atlas] or G.ASSET_ATLAS['centers'], self.pos) - self.badge_to_key[self.key:lower() .. '_seal'] = self.key - SMODS.insert_pool(G.P_CENTER_POOLS[self.set], self) - self.rng_buffer[#self.rng_buffer + 1] = self.key - end, - process_loc_text = function(self) - SMODS.process_loc_text(G.localization.descriptions.Other, self.key:lower() .. '_seal', self.loc_txt) - SMODS.process_loc_text(G.localization.misc.labels, self.key:lower() .. '_seal', self.loc_txt, 'label') - end, - get_obj = function(self, key) return G.P_SEALS[key] end, - generate_ui = function(self, info_queue, card, desc_nodes, specific_vars, full_UI_table) - local target = { - type = 'other', - set = 'Other', - key = self.key:lower()..'_seal', - nodes = desc_nodes, - vars = specific_vars or {}, - } - local res = {} - if self.loc_vars and type(self.loc_vars) == 'function' then - res = self:loc_vars(info_queue, card) or {} - target.vars = res.vars or target.vars - target.key = res.key or target.key - if res.set then - target.type = 'descriptions' - target.set = res.set - end - target.scale = res.scale - target.text_colour = res.text_colour - end - if desc_nodes == full_UI_table.main and not full_UI_table.name then - full_UI_table.name = localize { type = 'name', set = target.set, key = res.name_key or target.key, nodes = full_UI_table.name, vars = res.name_vars or target.vars or {} } - elseif desc_nodes ~= full_UI_table.main and not desc_nodes.name then - desc_nodes.name = localize{type = 'name_text', key = res.name_key or target.key, set = target.set } - end - if res.main_start then - desc_nodes[#desc_nodes + 1] = res.main_start - end - localize(target) - if res.main_end then - desc_nodes[#desc_nodes + 1] = res.main_end - end - desc_nodes.background_colour = res.background_colour - end, - } - for _,v in ipairs { 'Purple', 'Gold', 'Blue', 'Red' } do - SMODS.Seal:take_ownership(v, { badge_colour = G.C[v:upper()], pos = G.shared_seals[v].sprite_pos, generate_ui = SMODS.Seal.generate_ui }) - end - - ------------------------------------------------------------------------------------------------- - ----- API CODE GameObject.Suit - ------------------------------------------------------------------------------------------------- - - SMODS.inject_p_card = function(suit, rank) - G.P_CARDS[suit.card_key .. '_' .. rank.card_key] = { - name = rank.key .. ' of ' .. suit.key, - value = rank.key, - suit = suit.key, - pos = { x = rank.pos.x, y = rank.suit_map[suit.key] or suit.pos.y }, - lc_atlas = rank.suit_map[suit.key] and rank.lc_atlas or suit.lc_atlas, - hc_atlas = rank.suit_map[suit.key] and rank.hc_atlas or suit.hc_atlas, - } - end - SMODS.remove_p_card = function(suit, rank) - G.P_CARDS[suit.card_key .. '_' .. rank.card_key] = nil - end - - SMODS.Suits = {} - SMODS.Suit = SMODS.GameObject:extend { - obj_table = SMODS.Suits, - obj_buffer = {}, - used_card_keys = {}, - set = 'Suit', - required_params = { - 'key', - 'card_key', - 'pos', - 'ui_pos', - }, - hc_atlas = 'cards_2', - lc_atlas = 'cards_1', - hc_ui_atlas = 'ui_2', - lc_ui_atlas = 'ui_1', - hc_colour = HEX '000000', - lc_colour = HEX '000000', - max_nominal = { - value = 0, - }, - register = function(self) - -- 0.9.8 compat - self.name = self.name or self.key - if self.used_card_keys[self.card_key] then - sendWarnMessage(('Tried to use duplicate card key %s, aborting registration'):format(self.card_key), self.set) - return - end - self.used_card_keys[self.card_key] = true - self.max_nominal.value = self.max_nominal.value + 0.01 - self.suit_nominal = self.max_nominal.value - local def = 'default_'..self.key - if G.COLLABS.options[self.key] == nil then - G.COLLABS.options[self.key] = {def} - end - SMODS.Suit.super.register(self) - self:create_default_deck_skin() - end, - inject = function(self) - for _, rank in pairs(SMODS.Ranks) do - SMODS.inject_p_card(self, rank) - end - end, - create_default_deck_skin = function(self) - if self.key ~= "Hearts" and self.key ~= "Diamonds" and self.key ~= "Clubs" and self.key ~= "Spades" then - local contrast = self.lc_atlas ~= self.hc_atlas or not rawget(self, 'hc_atlas') - SMODS.DeckSkin{ - key = 'default_'..self.key, - prefix_config = { key = false }, - suit = self.key, - palettes = { - { - key = contrast and 'lc' or 'def', - ranks = {'Ace', 'King', 'Queen', 'Jack', '10', '9', '8', '7', '6', '5', '4', '3', '2'}, - display_ranks = {'King', 'Queen', 'Jack'}, - atlas = self.lc_atlas, - pos_style = 'deck' - }, - contrast and { - key = 'hc', - ranks = {'Ace', 'King', 'Queen', 'Jack', '10', '9', '8', '7', '6', '5', '4', '3', '2'}, - display_ranks = {'King', 'Queen', 'Jack'}, - atlas = self.hc_atlas, - pos_style = 'deck' - } or nil, - } - } - end - end, - delete = function(self) - local i - for j, v in ipairs(self.obj_buffer) do - if v == self.key then i = j end - end - for _, rank in pairs(SMODS.Ranks) do - SMODS.remove_p_card(self, rank) - end - self.used_card_keys[self.card_key] = nil - table.remove(self.obj_buffer, i) - end, - process_loc_text = function(self) - -- empty loc_txt indicates there are existing values that shouldn't be changed - SMODS.process_loc_text(G.localization.misc.suits_plural, self.key, self.loc_txt, 'plural') - SMODS.process_loc_text(G.localization.misc.suits_singular, self.key, self.loc_txt, 'singular') - if not self.keep_base_colours then - if type(self.lc_colour) == 'string' then self.lc_colour = HEX(self.lc_colour) end - if type(self.hc_colour) == 'string' then self.hc_colour = HEX(self.hc_colour) end - G.C.SO_1[self.key] = self.lc_colour - G.C.SO_2[self.key] = self.hc_colour - G.C.SUITS[self.key] = G.C["SO_" .. (G.SETTINGS.colourblind_option and 2 or 1)][self.key] - end - end, - } - SMODS.Suit { - key = 'Diamonds', - card_key = 'D', - pos = { y = 2 }, - ui_pos = { x = 1, y = 1 }, - keep_base_colours = true, - } - SMODS.Suit { - key = 'Clubs', - card_key = 'C', - pos = { y = 1 }, - ui_pos = { x = 2, y = 1 }, - keep_base_colours = true, - } - SMODS.Suit { - key = 'Hearts', - card_key = 'H', - pos = { y = 0 }, - ui_pos = { x = 0, y = 1 }, - keep_base_colours = true, - } - SMODS.Suit { - key = 'Spades', - card_key = 'S', - pos = { y = 3 }, - ui_pos = { x = 3, y = 1 }, - keep_base_colours = true, - } - ------------------------------------------------------------------------------------------------- - ----- API CODE GameObject.Rank - ------------------------------------------------------------------------------------------------- - - SMODS.Ranks = {} - SMODS.Rank = SMODS.GameObject:extend { - obj_table = SMODS.Ranks, - obj_buffer = {}, - used_card_keys = {}, - set = 'Rank', - required_params = { - 'key', - 'pos', - 'nominal', - }, - hc_atlas = 'cards_2', - lc_atlas = 'cards_1', - strength_effect = { - fixed = 1, - random = false, - ignore = false - }, - next = {}, - straight_edge = false, - -- TODO we need a better system for what this is doing. - -- We should allow setting a playing card's atlas and position to any values, - -- and we should also ensure that it's easy to create an atlas with a standard - -- arrangement: x and y set according to rank and suit. - - -- Currently suit_map does the following: - -- suit_map forces a playing card's atlas to be rank.hc_atlas/lc_atlas, - -- and not the atlas defined on the suit of the playing card; - -- additionally pos.y is set according to the corresponding value in the - -- suit_map - suit_map = { - Hearts = 0, - Clubs = 1, - Diamonds = 2, - Spades = 3, - }, - max_id = { - value = 1, - }, - register = function(self) - if self.used_card_keys[self.card_key] then - sendWarnMessage(('Tried to use duplicate card key %s, aborting registration'):format(self.card_key), self.set) - return - end - self.used_card_keys[self.card_key] = true - self.max_id.value = self.max_id.value + 1 - self.id = self.max_id.value - self.shorthand = self.shorthand or self.key - self.sort_nominal = self.nominal + (self.face_nominal or 0) - if self:check_dependencies() and not self.obj_table[self.key] then - self.obj_table[self.key] = self - local j - -- keep buffer sorted in ascending nominal order - for i = 1, #self.obj_buffer - 1 do - if self.obj_table[self.obj_buffer[i]].sort_nominal > self.sort_nominal then - j = i - break - end - end - if j then - table.insert(self.obj_buffer, j, self.key) - else - table.insert(self.obj_buffer, self.key) - end - end - end, - process_loc_text = function(self) - SMODS.process_loc_text(G.localization.misc.ranks, self.key, self.loc_txt, 'name') - end, - inject = function(self) - for _, suit in pairs(SMODS.Suits) do - SMODS.inject_p_card(suit, self) - end - end, - delete = function(self) - local i - for j, v in ipairs(self.obj_buffer) do - if v == self.key then i = j end - end - for _, suit in pairs(SMODS.Suits) do - SMODS.remove_p_card(suit, self) - end - self.used_card_keys[self.card_key] = nil - table.remove(self.obj_buffer, i) - end - } - for _, v in ipairs({ 2, 3, 4, 5, 6, 7, 8, 9 }) do - SMODS.Rank { - key = v .. '', - card_key = v .. '', - pos = { x = v - 2 }, - nominal = v, - next = { (v + 1) .. '' }, - } - end - SMODS.Rank { - key = '10', - card_key = 'T', - pos = { x = 8 }, - nominal = 10, - next = { 'Jack' }, - } - SMODS.Rank { - key = 'Jack', - card_key = 'J', - pos = { x = 9 }, - nominal = 10, - face_nominal = 0.1, - face = true, - shorthand = 'J', - next = { 'Queen' }, - } - SMODS.Rank { - key = 'Queen', - card_key = 'Q', - pos = { x = 10 }, - nominal = 10, - face_nominal = 0.2, - face = true, - shorthand = 'Q', - next = { 'King' }, - } - SMODS.Rank { - key = 'King', - card_key = 'K', - pos = { x = 11 }, - nominal = 10, - face_nominal = 0.3, - face = true, - shorthand = 'K', - next = { 'Ace' }, - } - SMODS.Rank { - key = 'Ace', - card_key = 'A', - pos = { x = 12 }, - nominal = 11, - face_nominal = 0.4, - shorthand = 'A', - straight_edge = true, - next = { '2' }, - } - -- make consumable effects compatible with added suits - -- TODO put this in utils.lua - local function juice_flip(used_tarot) - G.E_MANAGER:add_event(Event({ - trigger = 'after', - delay = 0.4, - func = function() - play_sound('tarot1') - used_tarot:juice_up(0.3, 0.5) - return true - end - })) - for i = 1, #G.hand.cards do - local percent = 1.15 - (i - 0.999) / (#G.hand.cards - 0.998) * 0.3 - G.E_MANAGER:add_event(Event({ - trigger = 'after', - delay = 0.15, - func = function() - G.hand.cards[i]:flip(); play_sound('card1', percent); G.hand.cards[i]:juice_up(0.3, 0.3); return true - end - })) - end - end - SMODS.Consumable:take_ownership('strength', { - use = function(self, card, area, copier) - local used_tarot = copier or card - G.E_MANAGER:add_event(Event({ - trigger = 'after', - delay = 0.4, - func = function() - play_sound('tarot1') - used_tarot:juice_up(0.3, 0.5) - return true - end - })) - for i = 1, #G.hand.highlighted do - local percent = 1.15 - (i - 0.999) / (#G.hand.highlighted - 0.998) * 0.3 - G.E_MANAGER:add_event(Event({ - trigger = 'after', - delay = 0.15, - func = function() - G.hand.highlighted[i]:flip(); play_sound('card1', percent); G.hand.highlighted[i]:juice_up(0.3, - 0.3); return true - end - })) - end - delay(0.2) - for i = 1, #G.hand.highlighted do - G.E_MANAGER:add_event(Event({ - trigger = 'after', - delay = 0.1, - func = function() - local _card = G.hand.highlighted[i] - local rank_data = SMODS.Ranks[_card.base.value] - local behavior = rank_data.strength_effect or { fixed = 1, ignore = false, random = false } - local new_rank - if behavior.ignore or not next(rank_data.next) then - return true - elseif behavior.random then - -- TODO doesn't respect in_pool - new_rank = pseudorandom_element(rank_data.next, pseudoseed('strength')) - else - local ii = (behavior.fixed and rank_data.next[behavior.fixed]) and behavior.fixed or 1 - new_rank = rank_data.next[ii] - end - assert(SMODS.change_base(_card, nil, new_rank)) - return true - end - })) - end - for i = 1, #G.hand.highlighted do - local percent = 0.85 + (i - 0.999) / (#G.hand.highlighted - 0.998) * 0.3 - G.E_MANAGER:add_event(Event({ - trigger = 'after', - delay = 0.15, - func = function() - G.hand.highlighted[i]:flip(); play_sound('tarot2', percent, 0.6); G.hand.highlighted[i] - :juice_up( - 0.3, 0.3); return true - end - })) - end - G.E_MANAGER:add_event(Event({ - trigger = 'after', - delay = 0.2, - func = function() - G.hand:unhighlight_all(); return true - end - })) - delay(0.5) - end, - }) - SMODS.Consumable:take_ownership('sigil', { - use = function(self, card, area, copier) - local used_tarot = copier or card - juice_flip(used_tarot) - local _suit = pseudorandom_element(SMODS.Suits, pseudoseed('sigil')) - for i = 1, #G.hand.cards do - G.E_MANAGER:add_event(Event({ - func = function() - local _card = G.hand.cards[i] - assert(SMODS.change_base(_card, _suit.key)) - return true - end - })) - end - for i = 1, #G.hand.cards do - local percent = 0.85 + (i - 0.999) / (#G.hand.cards - 0.998) * 0.3 - G.E_MANAGER:add_event(Event({ - trigger = 'after', - delay = 0.15, - func = function() - G.hand.cards[i]:flip(); play_sound('tarot2', percent, 0.6); G.hand.cards[i]:juice_up(0.3, 0.3); return true - end - })) - end - delay(0.5) - end, - }) - SMODS.Consumable:take_ownership('ouija', { - use = function(self, card, area, copier) - local used_tarot = copier or card - juice_flip(used_tarot) - local _rank = pseudorandom_element(SMODS.Ranks, pseudoseed('ouija')) - for i = 1, #G.hand.cards do - G.E_MANAGER:add_event(Event({ - func = function() - local _card = G.hand.cards[i] - assert(SMODS.change_base(_card, nil, _rank.key)) - return true - end - })) - end - G.hand:change_size(-1) - for i = 1, #G.hand.cards do - local percent = 0.85 + (i - 0.999) / (#G.hand.cards - 0.998) * 0.3 - G.E_MANAGER:add_event(Event({ - trigger = 'after', - delay = 0.15, - func = function() - G.hand.cards[i]:flip(); play_sound('tarot2', percent, 0.6); G.hand.cards[i]:juice_up(0.3, 0.3); return true - end - })) - end - delay(0.5) - end, - }) - local function random_destroy(used_tarot) - local destroyed_cards = {} - destroyed_cards[#destroyed_cards + 1] = pseudorandom_element(G.hand.cards, pseudoseed('random_destroy')) - G.E_MANAGER:add_event(Event({ - trigger = 'after', - delay = 0.4, - func = function() - play_sound('tarot1') - used_tarot:juice_up(0.3, 0.5) - return true - end - })) - G.E_MANAGER:add_event(Event({ - trigger = 'after', - delay = 0.1, - func = function() - for i = #destroyed_cards, 1, -1 do - local card = destroyed_cards[i] - if card.ability.name == 'Glass Card' then - card:shatter() - else - card:start_dissolve(nil, i ~= #destroyed_cards) - end - end - return true - end - })) - return destroyed_cards - end - SMODS.Consumable:take_ownership('grim', { - use = function(self, card, area, copier) - local used_tarot = copier or card - local destroyed_cards = random_destroy(used_tarot) - G.E_MANAGER:add_event(Event({ - trigger = 'after', - delay = 0.7, - func = function() - local cards = {} - for i = 1, card.ability.extra do - cards[i] = true - -- TODO preserve suit vanilla RNG - local _suit, _rank = - pseudorandom_element(SMODS.Suits, pseudoseed('grim_create')).card_key, 'A' - local cen_pool = {} - for k, v in pairs(G.P_CENTER_POOLS["Enhanced"]) do - if v.key ~= 'm_stone' and not v.overrides_base_rank then - cen_pool[#cen_pool + 1] = v - end - end - create_playing_card({ - front = G.P_CARDS[_suit .. '_' .. _rank], - center = pseudorandom_element(cen_pool, pseudoseed('spe_card')) - }, G.hand, nil, i ~= 1, { G.C.SECONDARY_SET.Spectral }) - end - playing_card_joker_effects(cards) - return true - end - })) - delay(0.3) - SMODS.calculate_context({ remove_playing_cards = true, removed = destroyed_cards }) - end, - }) - SMODS.Consumable:take_ownership('familiar', { - use = function(self, card, area, copier) - local used_tarot = copier or card - local destroyed_cards = random_destroy(used_tarot) - G.E_MANAGER:add_event(Event({ - trigger = 'after', - delay = 0.7, - func = function() - local cards = {} - for i = 1, card.ability.extra do - cards[i] = true - -- TODO preserve suit vanilla RNG - local faces = {} - for _, v in ipairs(SMODS.Rank.obj_buffer) do - local r = SMODS.Ranks[v] - if r.face then table.insert(faces, r) end - end - local _suit, _rank = - pseudorandom_element(SMODS.Suits, pseudoseed('familiar_create')).card_key, - pseudorandom_element(faces, pseudoseed('familiar_create')).card_key - local cen_pool = {} - for k, v in pairs(G.P_CENTER_POOLS["Enhanced"]) do - if v.key ~= 'm_stone' and not v.overrides_base_rank then - cen_pool[#cen_pool + 1] = v - end - end - create_playing_card({ - front = G.P_CARDS[_suit .. '_' .. _rank], - center = pseudorandom_element(cen_pool, pseudoseed('spe_card')) - }, G.hand, nil, i ~= 1, { G.C.SECONDARY_SET.Spectral }) - end - playing_card_joker_effects(cards) - return true - end - })) - delay(0.3) - SMODS.calculate_context({ remove_playing_cards = true, removed = destroyed_cards }) - end, - }) - SMODS.Consumable:take_ownership('incantation', { - use = function(self, card, area, copier) - local used_tarot = copier or card - local destroyed_cards = random_destroy(used_tarot) - G.E_MANAGER:add_event(Event({ - trigger = 'after', - delay = 0.7, - func = function() - local cards = {} - for i = 1, card.ability.extra do - cards[i] = true - -- TODO preserve suit vanilla RNG - local numbers = {} - for _, v in ipairs(SMODS.Rank.obj_buffer) do - local r = SMODS.Ranks[v] - if v ~= 'Ace' and not r.face then table.insert(numbers, r) end - end - local _suit, _rank = - pseudorandom_element(SMODS.Suits, pseudoseed('incantation_create')).card_key, - pseudorandom_element(numbers, pseudoseed('incantation_create')).card_key - local cen_pool = {} - for k, v in pairs(G.P_CENTER_POOLS["Enhanced"]) do - if v.key ~= 'm_stone' and not v.overrides_base_rank then - cen_pool[#cen_pool + 1] = v - end - end - create_playing_card({ - front = G.P_CARDS[_suit .. '_' .. _rank], - center = pseudorandom_element(cen_pool, pseudoseed('spe_card')) - }, G.hand, nil, i ~= 1, { G.C.SECONDARY_SET.Spectral }) - end - playing_card_joker_effects(cards) - return true - end - })) - delay(0.3) - SMODS.calculate_context({ remove_playing_cards = true, removed = destroyed_cards }) - - end, - }) - ------------------------------------------------------------------------------------------------- - ----- API CODE GameObject.DeckSkin - ------------------------------------------------------------------------------------------------- - - SMODS.DeckSkins = {} - SMODS.DeckSkin = SMODS.GameObject:extend { - obj_table = SMODS.DeckSkins, - obj_buffer = {}, - required_params = { - 'key', - 'suit', - }, - pos_style = 'deck', - set = 'DeckSkin', - count_by_suit = {}, - process_loc_text = function(self) - G.localization.misc.collabs[self.suit] = G.localization.misc.collabs[self.suit] or {["1"] = 'Default'} - G.localization.misc.collab_palettes = G.localization.misc.collab_palettes or {} - G.localization.misc.collab_palettes[self.key] = G.localization.misc.collab_palettes[self.key] or {} - if not self.outdated then - for i, p in ipairs(self.palettes) do - if p.loc_txt then - SMODS.process_loc_text(G.localization.misc.collab_palettes[self.key], i..'', p.loc_txt) - elseif G.localization.misc.collab_palettes[self.key][i..''] then - else - G.localization.misc.collab_palettes[self.key][i..''] = ({ lc = true, hc = true, def = true })[p.key] and localize('b_deckskins_'..p.key) or p.key - end - end - else - if self.lc_atlas == self.hc_atlas then - G.localization.misc.collab_palettes[self.key]['1'] = localize('b_deckskins_def') - else - G.localization.misc.collab_palettes[self.key]['1'] = localize('b_deckskins_lc') - G.localization.misc.collab_palettes[self.key]['2'] = localize('b_deckskins_hc') - end - end - - if not self.loc_txt then - G.localization.misc.collabs[self.suit][self.suit_index .. ''] = G.localization.misc.collabs[self.suit][self.suit_index .. ''] or self.key - return - end - - SMODS.process_loc_text(G.localization.misc.collabs[self.suit], self.suit_index..'', self.loc_txt) - end, - register = function(self) - if self.registered then - sendWarnMessage(('Detected duplicate register call on DeckSkin %s'):format(self.key), self.set) - return - end - if self:check_dependencies() then - assert(not self.palettes ~= not (self.ranks and self.lc_atlas), - ('Error loading DeckSkin %s! Please define your palettes or use the old formatting'):format(self.key)) - -- for compat with old format - self.pos_style = self.posStyle or self.pos_style - if self.palettes and not (self.ranks and self.lc_atlas) then - local temp_palettes = self.palettes - self.palettes = {} - -- ensure all palettes are valid - for _,v in ipairs(temp_palettes) do assert(self:add_palette(v)) end - - elseif not self.palettes and (self.ranks and self.lc_atlas) then - sendWarnMessage(('Old DeckSkin formatting detected on DeckSkin %s!'):format(self.key), self.set) - self.outdated = true - - self.hc_atlas = self.hc_atlas or self.lc_atlas - local valid_pos_styles = { ranks = true, collab = true, suit = true, deck = true} - assert(valid_pos_styles[self.pos_style], - ('%s is not a valid pos_style on DeckSkin %s. Supported pos_style values are \'ranks\', \'collab\', \'suit\' and \'deck\'') - :format(self.pos_style, self.key), self.set) - end - - self.count_by_suit[self.suit] = (self.count_by_suit[self.suit] or 0) + 1 - self.suit_index = self.count_by_suit[self.suit] - self.obj_buffer[#self.obj_buffer + 1] = self.key - self.obj_table[self.key] = self - self.registered = true - end - end, - pre_inject_class = function(self) - G.COLLABS.options = {} - end, - inject = function(self) - local def = 'default_'..self.suit - G.COLLABS.options[self.suit] = G.COLLABS.options[self.suit] or {def} - G.COLLABS.colour_palettes = G.COLLABS.colour_palettes or {} - G.COLLABS.colour_palettes[self.key] = {} - if self.palettes then - for _,v in ipairs(self.palettes) do - table.insert(G.COLLABS.colour_palettes[self.key], v.key) - end - else - if self.lc_atlas == self.hc_atlas then - table.insert(G.COLLABS.colour_palettes[self.key], 'lc') - else - table.insert(G.COLLABS.colour_palettes[self.key], 'lc') - table.insert(G.COLLABS.colour_palettes[self.key], 'hc') - end - end - G.COLLABS.options[self.suit] = G.COLLABS.options[self.suit] or {} - local options = G.COLLABS.options[self.suit] - if self.key ~= def then - options[#options + 1] = self.key - end - end, - add_palette = function(self, palette) - if not (self and self.key) then return false, 'Invalid DeckSkin object' end - local required_values = { 'key', 'ranks', 'atlas' } - -- for compat with old format - palette.pos_style = palette.pos_style or palette.posStyle or 'deck' - for _,v in ipairs(required_values) do - if not palette[v] then - return false, ('Missing required value "%s" in Palette "%s" on DeckSkin "%s"'):format(v, palette.key or '(unknown)', self.key) - end - end - table.insert(self.palettes, palette) - self.palette_map = self.palette_map or {} - self.palette_map[palette.key] = palette - return true - end, - get_palette_loc_options = function(key, suit) - if type(key) == "number" then - key = G.COLLABS.options[suit][key] - end - - local conv_palette_loc_options = {} - for k, v in pairs(G.localization.misc.collab_palettes[key]) do - conv_palette_loc_options[tonumber(k)] = v - end - - return conv_palette_loc_options - end, - post_inject_class = function(self) - for _, k in ipairs(SMODS.Suit.obj_buffer) do - local val = G.SETTINGS.CUSTOM_DECK.Collabs[k] or '' - if not self.obj_table[val] then - G.SETTINGS.CUSTOM_DECK.Collabs[k] = 'default_'..k - end - local skin = self.obj_table[G.SETTINGS.CUSTOM_DECK.Collabs[k]] - local pal = G.SETTINGS.colour_palettes[k] - if not skin.outdated and skin.palette_map and not skin.palette_map[pal] then - G.SETTINGS.colour_palettes[k] = skin.palettes[1].key - end - end - - end - } - - for suitName, options in pairs(G.COLLABS.options) do - SMODS.DeckSkin{ - key = options[1]..'_'..suitName, - suit = suitName, - palettes = { - { - key = 'lc', - ranks = {'2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', "King", "Ace",}, - display_ranks = {'King', 'Queen', 'Jack'}, - atlas = 'cards_1', - pos_style = 'deck' - }, - { - key = 'hc', - ranks = {'2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', "King", "Ace",}, - display_ranks = {'King', 'Queen', 'Jack'}, - atlas = 'cards_2', - pos_style = 'deck', - hc_default = true, - }, - } - } - end - for suitName, options in pairs(G.COLLABS.options) do - for i = 2, #options do - SMODS.DeckSkin{ - key = options[i], - suit = suitName, - palettes = { - { - key = 'lc', - ranks = {'King', 'Queen', 'Jack'}, - atlas = options[i] .. '_1', - pos_style = 'collab' - }, - { - key = 'hc', - ranks = {'King', 'Queen', 'Jack'}, - atlas = options[i] .. '_2', - pos_style = 'collab', - hc_default = true, - }, - }, - } - end - end - - if not G.SETTINGS.colour_palettes then - local val = G.SETTINGS.colourblind_option and 'hc' or 'lc' - G.SETTINGS.colour_palettes = { - Spades = val, - Hearts = val, - Clubs = val, - Diamonds = val, - } - G:save_settings() - end - - ------------------------------------------------------------------------------------------------- - ----- API CODE GameObject.PokerHand - ------------------------------------------------------------------------------------------------- - - SMODS.PokerHandParts = {} - SMODS.PokerHandPart = SMODS.GameObject:extend { - obj_table = SMODS.PokerHandParts, - obj_buffer = {}, - required_params = { - 'key', - 'func', - }, - inject_class = function() end, - } - local handlist = G.handlist - G.handlist = {} - SMODS.PokerHands = {} - SMODS.PokerHand = SMODS.GameObject:extend { - obj_table = SMODS.PokerHands, - obj_buffer = G.handlist, - required_params = { - 'key', - 'mult', - 'chips', - 'l_mult', - 'l_chips', - 'example', - 'evaluate' - }, - visible = true, - played = 0, - played_this_round = 0, - level = 1, - set = 'PokerHand', - process_loc_text = function(self) - SMODS.process_loc_text(G.localization.misc.poker_hands, self.key, self.loc_txt, 'name') - SMODS.process_loc_text(G.localization.misc.poker_hand_descriptions, self.key, self.loc_txt, 'description') - end, - register = function(self) - if self:check_dependencies() and not self.obj_table[self.key] then - self.s_mult = self.mult - self.s_chips = self.chips - self.visible = self.visible - self.level = self.level - self.played = self.played - self.played_this_round = self.played_this_round - self.obj_table[self.key] = self - self.obj_buffer[#self.obj_buffer + 1] = self.key - end - end, - inject = function(self) end, - post_inject_class = function(self) - table.sort( - self.obj_buffer, - function(a, b) - local x, y = self.obj_table[a], self.obj_table[b] - local x_above = self.obj_table[x.above_hand or {}] - local y_above = self.obj_table[y.above_hand or {}] - local function eval(h) return h.mult*h.chips + (h.order_offset or 0) end - return (x_above and (1e-6*eval(x) + eval(x_above)) or eval(x)) > (y_above and (1e-6*eval(y) + eval(y_above)) or eval(y)) - end - ) - for i, v in ipairs(self.obj_buffer) do self.obj_table[v].order = i end - end - } - - SMODS.PokerHandPart { - key = '_highest', - func = function(hand) return get_highest(hand) end - } - SMODS.PokerHandPart { - key = '_straight', - func = function(hand) return get_straight(hand) end - } - SMODS.PokerHandPart { - key = '_flush', - func = function(hand) return get_flush(hand) end, - } - -- all sets of 2 or more cards of same rank - SMODS.PokerHandPart { - key = '_all_pairs', - func = function(hand) - local _2 = get_X_same(2, hand, true) - if not next(_2) then return {} end - return {SMODS.merge_lists(_2)} - end - } - for i = 2, 5 do - SMODS.PokerHandPart { - key = '_'..i, - func = function(hand) return get_X_same(i, hand, true) end - } - end - - local hands = G:init_game_object().hands - local eval_functions = { - ['Flush Five'] = function(parts) - if not next(parts._5) or not next(parts._flush) then return {} end - return { SMODS.merge_lists(parts._5, parts._flush) } - end, - ['Flush House'] = function(parts) - if #parts._3 < 1 or #parts._2 < 2 or not next(parts._flush) then return {} end - return { SMODS.merge_lists(parts._all_pairs, parts._flush) } - end, - ['Five of a Kind'] = function(parts) return parts._5 end, - ['Straight Flush'] = function(parts) - if not next(parts._straight) or not next(parts._flush) then return end - return { SMODS.merge_lists(parts._straight, parts._flush) } - end, - ['Four of a Kind'] = function(parts) return parts._4 end, - ['Full House'] = function(parts) - if #parts._3 < 1 or #parts._2 < 2 then return {} end - return parts._all_pairs - end, - ['Flush'] = function(parts) return parts._flush end, - ['Straight'] = function(parts) return parts._straight end, - ['Three of a Kind'] = function(parts) return parts._3 end, - ['Two Pair'] = function(parts) - if #parts._2 < 2 then return {} end - return parts._all_pairs - end, - ['Pair'] = function(parts) return parts._2 end, - ['High Card'] = function(parts) return parts._highest end, - } - for _, v in ipairs(handlist) do - local hand = copy_table(hands[v]) - hand.key = v - hand.evaluate = eval_functions[v] - SMODS.PokerHand(hand) - end - ------------------------------------------------------------------------------------------------- - ----- API CODE GameObject.Challenge - ------------------------------------------------------------------------------------------------- - - SMODS.Challenges = {} - SMODS.Challenge = SMODS.GameObject:extend { - obj_table = SMODS.Challenges, - obj_buffer = {}, - get_obj = function(self, key) - for _, v in ipairs(G.CHALLENGES) do - if v.id == key then return v end - end - end, - set = "Challenge", - required_params = { - 'key', - }, - deck = { type = "Challenge Deck" }, - rules = { custom = {}, modifiers = {} }, - jokers = {}, - consumeables = {}, - vouchers = {}, - restrictions = { banned_cards = {}, banned_tags = {}, banned_other = {} }, - unlocked = function(self) return true end, - class_prefix = 'c', - process_loc_text = function(self) - SMODS.process_loc_text(G.localization.misc.challenge_names, self.key, self.loc_txt, 'name') - end, - register = function(self) - if self.registered then - sendWarnMessage(('Detected duplicate register call on object %s'):format(self.key), self.set) - return - end - self.id = self.key - -- only needs to be called once - SMODS.insert_pool(G.CHALLENGES, self) - SMODS.Challenge.super.register(self) - end, - inject = function(self) end, - } - for k, v in ipairs { - 'omelette_1', - 'city_1', - 'rich_1', - 'knife_1', - 'xray_1', - 'mad_world_1', - 'luxury_1', - 'non_perishable_1', - 'medusa_1', - 'double_nothing_1', - 'typecast_1', - 'inflation_1', - 'bram_poker_1', - 'fragile_1', - 'monolith_1', - 'blast_off_1', - 'five_card_1', - 'golden_needle_1', - 'cruelty_1', - 'jokerless_1', - } do - SMODS.Challenge:take_ownership(v, { - unlocked = function(self) - return G.PROFILES[G.SETTINGS.profile].challenges_unlocked and - (G.PROFILES[G.SETTINGS.profile].challenges_unlocked >= k) - end, - }) - end - - ------------------------------------------------------------------------------------------------- - ----- API CODE GameObject.Tag - ------------------------------------------------------------------------------------------------- - - SMODS.Tags = {} - SMODS.Tag = SMODS.GameObject:extend { - obj_table = SMODS.Tags, - obj_buffer = {}, - required_params = { - 'key', - }, - discovered = false, - min_ante = nil, - atlas = 'tags', - class_prefix = 'tag', - set = 'Tag', - pos = { x = 0, y = 0 }, - config = {}, - get_obj = function(self, key) return G.P_TAGS[key] end, - process_loc_text = function(self) - SMODS.process_loc_text(G.localization.descriptions.Tag, self.key, self.loc_txt) - end, - inject = function(self) - G.P_TAGS[self.key] = self - SMODS.insert_pool(G.P_CENTER_POOLS[self.set], self) - end, - generate_ui = function(self, info_queue, card, desc_nodes, specific_vars, full_UI_table) - if not card then - card = { config = copy_table(self.config), fake_tag = true} - end - local target = { - type = 'descriptions', - key = self.key, - set = self.set, - nodes = desc_nodes, - vars = specific_vars - } - local res = {} - if self.loc_vars and type(self.loc_vars) == 'function' then - -- card is actually a `Tag` here - res = self:loc_vars(info_queue, card) or {} - target.vars = res.vars or target.vars - target.key = res.key or target.key - target.set = res.set or target.set - target.scale = res.scale - target.text_colour = res.text_colour - end - if desc_nodes == full_UI_table.main and not full_UI_table.name then - full_UI_table.name = localize { type = 'name', set = target.set, key = res.name_key or target.key, nodes = full_UI_table.name, vars = res.name_vars or res.vars or {} } - elseif desc_nodes ~= full_UI_table.main and not desc_nodes.name then - desc_nodes.name = localize{type = 'name_text', key = res.name_key or target.key, set = target.set } - end - if res.main_start then - desc_nodes[#desc_nodes + 1] = res.main_start - end - localize(target) - if res.main_end then - desc_nodes[#desc_nodes + 1] = res.main_end - end - desc_nodes.background_colour = res.background_colour - end - } - - ------------------------------------------------------------------------------------------------- - ----- API CODE GameObject.Sticker - ------------------------------------------------------------------------------------------------- - - SMODS.Stickers = {} - SMODS.Sticker = SMODS.GameObject:extend { - obj_table = SMODS.Stickers, - obj_buffer = {}, - set = 'Sticker', - required_params = { - 'key', - }, - rate = 0.3, - atlas = 'stickers', - pos = { x = 0, y = 0 }, - badge_colour = HEX 'FFFFFF', - default_compat = true, - compat_exceptions = {}, - sets = { Joker = true }, - needs_enable_flag = true, - process_loc_text = function(self) - SMODS.process_loc_text(G.localization.descriptions.Other, self.key, self.loc_txt) - SMODS.process_loc_text(G.localization.misc.labels, self.key, self.loc_txt, 'label') - end, - register = function(self) - if self.registered then - sendWarnMessage(('Detected duplicate register call on object %s'):format(self.key), self.set) - return - end - SMODS.Sticker.super.register(self) - self.order = #self.obj_buffer - end, - inject = function(self) - self.sticker_sprite = Sprite(0, 0, G.CARD_W, G.CARD_H, G.ASSET_ATLAS[self.atlas], self.pos) - G.shared_stickers[self.key] = self.sticker_sprite - end, - -- relocating sticker checks to here, so if the sticker has different checks than default - -- they can be handled without hooking/injecting into create_card - -- or handling it in apply - -- TODO: rename - should_apply = function(self, card, center, area, bypass_roll) - if - ( not self.sets or self.sets[center.set or {}]) and - ( - center[self.key..'_compat'] or -- explicit marker - (self.default_compat and not self.compat_exceptions[center.key]) or -- default yes with no exception - (not self.default_compat and self.compat_exceptions[center.key]) -- default no with exception - ) and - (not self.needs_enable_flag or G.GAME.modifiers['enable_'..self.key]) - then - self.last_roll = pseudorandom((area == G.pack_cards and 'packssj' or 'shopssj')..self.key..G.GAME.round_resets.ante) - return (bypass_roll ~= nil) and bypass_roll or self.last_roll > (1-self.rate) - end - end, - apply = function(self, card, val) - card.ability[self.key] = val - end - } - - -- Create base game stickers - -- eternal and perishable follow shared checks for sticker application, therefore omitted - SMODS.Sticker{ - key = "eternal", - badge_colour = HEX 'c75985', - prefix_config = {key = false}, - pos = { x = 0, y = 0 }, - hide_badge = true, - order = 1, - should_apply = false, - inject = function(self) - SMODS.Sticker.inject(self) - G.shared_sticker_eternal = self.sticker_sprite - end, - } - - SMODS.Sticker{ - key = "perishable", - badge_colour = HEX '4f5da1', - prefix_config = {key = false}, - pos = { x = 0, y = 2 }, - hide_badge = true, - order = 2, - should_apply = false, - apply = function(self, card, val) - card.ability[self.key] = val - if card.ability[self.key] then card.ability.perish_tally = G.GAME.perishable_rounds end - end, - loc_vars = function(self, info_queue, card) - return {vars = {card.ability.perishable_rounds or 5, card.ability.perish_tally or G.GAME.perishable_rounds}} - end, - inject = function(self) - SMODS.Sticker.inject(self) - G.shared_sticker_perishable = self.sticker_sprite - end, - calculate = function(self, card, context) - if context.end_of_round and not context.repetition and not context.individual then - card:calculate_perishable() - end - end - } - - SMODS.Sticker{ - key = "rental", - badge_colour = HEX 'b18f43', - prefix_config = {key = false}, - pos = { x = 1, y = 2 }, - hide_badge = true, - order = 3, - should_apply = false, - apply = function(self, card, val) - card.ability[self.key] = val - if card.ability[self.key] then card:set_cost() end - end, - loc_vars = function(self, info_queue, card) - return {vars = {G.GAME.rental_rate or 1}} - end, - inject = function(self) - SMODS.Sticker.inject(self) - G.shared_sticker_rental = self.sticker_sprite - end, - calculate = function(self, card, context) - if context.end_of_round and not context.repetition and not context.individual then - card:calculate_rental() - end - end - } - - SMODS.Sticker{ - key = "pinned", - badge_colour = HEX 'fda200', - prefix_config = {key = false}, - pos = { x = 10, y = 10 }, -- Base game has no art, and I haven't made any yet to represent Pinned with - rate = 0, - should_apply = false, - order = 4, - apply = function(self, card, val) - card[self.key] = val - end - } - - ------------------------------------------------------------------------------------------------- - ----- API CODE GameObject.Enhancement - ------------------------------------------------------------------------------------------------- - - SMODS.Enhancement = SMODS.Center:extend { - set = 'Enhanced', - class_prefix = 'm', - atlas = 'centers', - pos = { x = 0, y = 0 }, - required_params = { - 'key', - -- table with keys `name` and `text` - }, - -- other fields: - -- replace_base_card - -- if true, don't draw base card sprite and don't give base card's chips - -- no_suit - -- if true, enhanced card has no suit - -- no_rank - -- if true, enhanced card has no rank - -- overrides_base_rank - -- Set to true if your enhancement overrides the base card's rank. - -- This prevents rank generators like Familiar creating cards - -- whose rank is overridden. - -- any_suit - -- if true, enhanced card is any suit - -- always_scores - -- if true, card always scores - -- loc_subtract_extra_chips - -- During tooltip generation, number of chips to subtract from displayed extra chips. - -- Use if enhancement already displays its own chips. - -- Future work: use ranks() and suits() for better control - register = function(self) - self.config = self.config or {} - assert(not (self.no_suit and self.any_suit)) - if self.no_rank then self.overrides_base_rank = true end - SMODS.Enhancement.super.register(self) - end, - -- Produces the description of the whole playing card - -- (including chips from the rank of the card and permanent bonus chips). - -- You will probably want to override this if your enhancement interacts with - -- those parts of the base card. - generate_ui = function(self, info_queue, card, desc_nodes, specific_vars, full_UI_table) - if specific_vars and specific_vars.nominal_chips and not self.replace_base_card then - localize { type = 'other', key = 'card_chips', nodes = desc_nodes, vars = { specific_vars.nominal_chips } } - end - SMODS.Enhancement.super.generate_ui(self, info_queue, card, desc_nodes, specific_vars, full_UI_table) - if specific_vars and specific_vars.bonus_chips then - local remaining_bonus_chips = specific_vars.bonus_chips - (self.config.bonus or 0) - if remaining_bonus_chips > 0 then - localize { type = 'other', key = 'card_extra_chips', nodes = desc_nodes, vars = { specific_vars.bonus_chips - (self.config.bonus or 0) } } - end - end - end, - -- other methods: - -- calculate(self, context, effect) - } - -- Note: `name`, `effect`, and `label` all serve the same purpose as - -- the name of the enhancement. In theory, `effect` serves to allow reusing - -- similar effects (ex. the Sinful jokers). But Balatro just uses them all - -- indiscriminately for enhancements. - -- `name` and `effect` are technically different for Bonus and Mult - -- cards but this never matters in practice; also `label` is a red herring, - -- I can't even find a single use of `label`. - - -- It would be nice if the relevant functions for modding each class of object - -- would be documented. - -- For example, Card:set_ability sets the card's enhancement, which is not immediately - -- obvious. - - -- local stone_card = SMODS.Enhancement:take_ownership('m_stone', { - -- replace_base_card = true, - -- no_suit = true, - -- no_rank = true, - -- always_scores = true, - -- loc_txt = { - -- name = "Stone Card", - -- text = { - -- "{C:chips}+#1#{} Chips", - -- "no rank or suit" - -- } - -- }, - -- loc_vars = function(self) - -- return { - -- vars = { self.config.bonus } - -- } - -- end - -- }) - - ------------------------------------------------------------------------------------------------- - ----- API CODE GameObject.Shader - ------------------------------------------------------------------------------------------------- - - SMODS.Shaders = {} - SMODS.Shader = SMODS.GameObject:extend { - obj_table = SMODS.Shaders, - obj_buffer = {}, - required_params = { - 'key', - 'path', - }, - set = 'Shader', - send_vars = nil, -- function (sprite) - get custom externs to send to shader. - inject = function(self) - self.full_path = (self.mod and self.mod.path or SMODS.path) .. - 'assets/shaders/' .. self.path - local file = NFS.read(self.full_path) - love.filesystem.write(self.key .. "-temp.fs", file) - G.SHADERS[self.key] = love.graphics.newShader(self.key .. "-temp.fs") - love.filesystem.remove(self.key .. "-temp.fs") - -- G.SHADERS[self.key] = love.graphics.newShader(self.full_path) - end, - process_loc_text = function() end - } - - ------------------------------------------------------------------------------------------------- - ----- API CODE GameObject.Edition - ------------------------------------------------------------------------------------------------- - - SMODS.Edition = SMODS.Center:extend { - set = 'Edition', - -- atlas only matters for displaying editions in the collection - atlas = 'Joker', - pos = { x = 0, y = 0 }, - class_prefix = 'e', - discovered = false, - unlocked = true, - apply_to_float = false, - in_shop = false, - weight = 0, - badge_colour = G.C.DARK_EDITION, - -- default sound is foil sound - sound = { sound = "foil1", per = 1.2, vol = 0.4 }, - required_params = { - 'key', - 'shader' -- can be set to `false` for shaderless edition - }, - -- optional fields: - extra_cost = nil, - - -- TODO badge colours. need to check how Steamodded already does badge colors - -- other methods: - calculate = nil, -- function (self) - on_apply = nil, -- function (card) - modify card when edition is applied - on_remove = nil, -- function (card) - modify card when edition is removed - on_load = nil, -- function (card) - modify card when it is loaded from the save file - register = function(self) - self.config = self.config or {} - SMODS.Edition.super.register(self) - end, - process_loc_text = function(self) - SMODS.process_loc_text(G.localization.misc.labels, self.key:sub(3), self.loc_txt, 'label') - SMODS.Edition.super.process_loc_text(self) - end, - -- apply_modifier = true when G.GAME.edition_rate is to be applied - get_weight = function(self, apply_modifier) - return self.weight - end - } - - -- TODO also, this should probably be a utility method in core - -- card_area = pass the card area - -- edition = boolean value - function SMODS.Edition:get_edition_cards(card_area, edition) - local cards = {} - for _, v in ipairs(card_area.cards) do - if (not v.edition and edition) or (v.edition and not edition) then - table.insert(cards, v) - end - end - return cards - end - - SMODS.Edition:take_ownership('foil', { - shader = 'foil', - config = setmetatable({ chips = 50 }, { - __index = function(t, k) - if k == 'extra' then return t.chips end - return rawget(t, k) - end, - __newindex = function(t, k, v) - if k == 'extra' then - t.chips = v; return - end - rawset(t, k, v) - end, - }), - sound = { sound = "foil1", per = 1.2, vol = 0.4 }, - weight = 20, - extra_cost = 2, - get_weight = function(self) - return G.GAME.edition_rate * self.weight - end, - loc_vars = function(self) - return { vars = { self.config.chips } } - end, - calculate = function(self, card, context) - if context.pre_joker or (context.main_scoring and context.cardarea == G.play) then - return { - chips = card.edition.chips - } - end - end - }) - SMODS.Edition:take_ownership('holo', { - shader = 'holo', - config = setmetatable({ mult = 10 }, { - __index = function(t, k) - if k == 'extra' then return t.mult end - return rawget(t, k) - end, - __newindex = function(t, k, v) - if k == 'extra' then - t.mult = v; return - end - rawset(t, k, v) - end, - }), - sound = { sound = "holo1", per = 1.2 * 1.58, vol = 0.4 }, - weight = 14, - extra_cost = 3, - get_weight = function(self) - return G.GAME.edition_rate * self.weight - end, - loc_vars = function(self) - return { vars = { self.config.mult } } - end, - calculate = function(self, card, context) - if context.pre_joker or (context.main_scoring and context.cardarea == G.play) then - return { - mult = card.edition.mult - } - end - end - }) - SMODS.Edition:take_ownership('polychrome', { - shader = 'polychrome', - config = setmetatable({ x_mult = 1.5 }, { - __index = function(t, k) - if k == 'extra' then return t.x_mult end - return rawget(t, k) - end, - __newindex = function(t, k, v) - if k == 'extra' then - t.x_mult = v; return - end - rawset(t, k, v) - end, - }), - sound = { sound = "polychrome1", per = 1.2, vol = 0.7 }, - weight = 3, - extra_cost = 5, - get_weight = function(self) - return (G.GAME.edition_rate - 1) * G.P_CENTERS["e_negative"].weight + G.GAME.edition_rate * self.weight - end, - loc_vars = function(self) - return { vars = { self.config.x_mult } } - end, - calculate = function(self, card, context) - if context.post_joker or (context.main_scoring and context.cardarea == G.play) then - return { - x_mult = card.edition.x_mult - } - end - end - }) - SMODS.Edition:take_ownership('negative', { - shader = 'negative', - config = setmetatable({ card_limit = 1 }, { - __index = function(t, k) - if k == 'extra' then return t.card_limit end - return rawget(t, k) - end, - __newindex = function(t, k, v) - if k == 'extra' then - t.card_limit = v; return - end - rawset(t, k, v) - end, - }), - sound = { sound = "negative", per = 1.5, vol = 0.4 }, - weight = 3, - extra_cost = 5, - get_weight = function(self) - return self.weight - end, - loc_vars = function(self) - return { vars = { self.config.card_limit } } - end, - }) - - ------------------------------------------------------------------------------------------------- - ------- API CODE GameObject.Keybind - ------------------------------------------------------------------------------------------------- - SMODS.Keybinds = {} - SMODS.Keybind = SMODS.GameObject:extend { - obj_table = SMODS.Keybinds, - obj_buffer = {}, - - -- key_pressed = 'x', - held_keys = {}, -- other key(s) that need to be held - -- action = function(controller) - -- print("Keybind pressed") - -- end, - - event = 'pressed', - held_duration = 1, - - required_params = { - 'key_pressed', - 'action', - }, - set = 'Keybind', - class_prefix = 'keybind', - register = function(self) - self.key = self.key or (#self.obj_buffer..'') - SMODS.Keybind.super.register(self) - end, - inject = function(_) end - } - - SMODS.Keybind { - key_pressed = 'm', - event = 'held', - held_duration = 1.1, - action = function(self) - SMODS.save_all_config() - SMODS.restart_game() - end - } - - ------------------------------------------------------------------------------------------------- - ------- API CODE GameObject.Achievements - ------------------------------------------------------------------------------------------------- - - SMODS.Achievements = {} - SMODS.Achievement = SMODS.GameObject:extend{ - obj_table = SMODS.Achievements, - obj_buffer = {}, - required_params = { - 'key', - 'unlock_condition', - }, - set = 'Achievement', - class_prefix = "ach", - atlas = "achievements", - pos = {x=1, y=0}, - hidden_pos = {x=0, y=0}, - bypass_all_unlocked = false, - hidden_name = true, - steamid = "STEAMODDED", - pre_inject_class = fetch_achievements, - inject = function(self) - G.ACHIEVEMENTS[self.key] = self - if self.reset_on_startup then - if G.SETTINGS.ACHIEVEMENTS_EARNED[self.key] then G.SETTINGS.ACHIEVEMENTS_EARNED[self.key] = nil end - if G.ACHIEVEMENTS[self.key].earned then G.ACHIEVEMENTS[self.key].earned = nil end - end - end, - process_loc_text = function(self) - SMODS.process_loc_text(G.localization.misc.achievement_names, self.key, self.loc_txt, "name") - SMODS.process_loc_text(G.localization.misc.achievement_descriptions, self.key, self.loc_txt, "description") - end, - } - - ------------------------------------------------------------------------------------------------- - ----- INTERNAL API CODE GameObject._Loc_Post - ------------------------------------------------------------------------------------------------- - - SMODS._Loc_Post = SMODS.GameObject:extend { - obj_table = {}, - obj_buffer = {}, - set = '[INTERNAL]', - silent = true, - register = function() error('INTERNAL CLASS, DO NOT CALL') end, - pre_inject_class = function() - for _, mod in ipairs(SMODS.mod_list) do - if mod.can_load then - SMODS.handle_loc_file(mod.path) - end - end - end - } -end diff --git a/smods-main/src/index.lua b/smods-main/src/index.lua deleted file mode 100644 index 699ac1c..0000000 --- a/smods-main/src/index.lua +++ /dev/null @@ -1,32 +0,0 @@ -SMODS.fetch_index = function() - SMODS.index = {} - local https = require"https" - local status, contents = https.request("https://github.com/Aurelius7309/Steamodded.index/archive/refs/heads/main.zip") - if status ~= 200 then return false end - love.filesystem.write('index.zip', contents) - if not love.filesystem.mount('index.zip', 'index') then return false end - local path = 'index/Steamodded.index-main/mods/' - for _, filename in ipairs(love.filesystem.getDirectoryItems(path)) do - local key, ext = filename:sub(1, -6), filename:sub(-5) - if ext:lower() == '.json' then - local success, data = pcall(function() return JSON.decode(love.filesystem.read(path..filename)) end) - if success and data.id == key then SMODS.index[key] = data end - end - end - love.filesystem.unmount('index.zip') - return true -end - -SMODS.update_mod_files = function(id) - local mod = SMODS.Mods[id] - if not mod then return false end - local use_git = os.execute('git -v') == 0 - if false and use_git and os.execute(('cd %s & git pull'):format(mod.path)) == 0 then - return true - end - local https = require"https" - local url = mod.github or (SMODS.index[id] or {}).github - local status, contents = https.request(url) -- TODO account for branches - local hash = contents:match('"currentOid":"([^"]*)"') - sendWarnMessage(hash, "Index") -end diff --git a/smods-main/src/loader.lua b/smods-main/src/loader.lua deleted file mode 100644 index fb429d1..0000000 --- a/smods-main/src/loader.lua +++ /dev/null @@ -1,728 +0,0 @@ ---- STEAMODDED CORE ---- MODULE MODLOADER - -function loadMods(modsDirectory) - SMODS.Mods = {} - SMODS.Mods[SMODS.id] = SMODS - SMODS.Mods['Lovely'] = { - id = 'Lovely', - can_load = true, - version = require'lovely'.version, - meta_mod = true, - } - SMODS.Mods['Balatro'] = { - id = 'Balatro', - can_load = true, - version = G.VERSION, - meta_mod = true, - } - SMODS.mod_priorities = {} - SMODS.mod_list = {} - SMODS.provided_mods = {} - -- for legacy header support - local header_components = { - name = { pattern = '%-%-%- MOD_NAME: ([^\n]+)\n', required = true }, - id = { pattern = '%-%-%- MOD_ID: ([^ \n]+)\n', required = true }, - author = { pattern = '%-%-%- MOD_AUTHOR: %[(.-)%]\n', required = true, parse_array = true }, - description = { pattern = '%-%-%- MOD_DESCRIPTION: (.-)\n', required = true }, - priority = { pattern = '%-%-%- PRIORITY: (%-?%d+)\n', handle = function(x) return x and x + 0 or 0 end }, - badge_colour = { pattern = '%-%-%- BADGE_COLO[U]?R: (%x-)\n', handle = function(x) return HEX(x or '666666FF') end }, - badge_text_colour = { pattern = '%-%-%- BADGE_TEXT_COLO[U]?R: (%x-)\n', handle = function(x) return HEX(x or 'FFFFFF') end }, - display_name = { pattern = '%-%-%- DISPLAY_NAME: (.-)\n' }, - dependencies = { - pattern = { - '%-%-%- DEPENDENCIES: %[(.-)%]\n', - '%-%-%- DEPENDS: %[(.-)%]\n', - '%-%-%- DEPS: %[(.-)%]\n', - }, - parse_array = true, - handle = function(x) - local t = {} - for _, v in ipairs(x) do - table.insert(t, { - id = v:match '(.-)[<>]' or v, - min_version = v:match '>=([^<>]+)', - max_version = v:match '<=([^<>]+)', - }) - end - return t - end, - }, - conflicts = { - pattern = '%-%-%- CONFLICTS: %[(.-)%]\n', - parse_array = true, - handle = function(x) - local t = {} - for _, v in ipairs(x) do - table.insert(t, { - id = v:match '(.-)[<>]', - min_version = v:match '>=([^<>]+)', - max_version = v:match '<=([^<>]+)', - }) - if t.min_version and not V(t[#t].min_version):is_valid() then t[#t].min_version = nil end - if t.max_version and not V(t[#t].max_version):is_valid() then t[#t].max_version = nil end - end - - return t - end - }, - prefix = { pattern = '%-%-%- PREFIX: (.-)\n' }, - version = { pattern = '%-%-%- VERSION: (.-)\n', handle = function(x) return x and V(x):is_valid() and x or '0.0.0' end }, - outdated = { pattern = { 'SMODS%.INIT', 'SMODS%.Deck[:.]new' } }, - dump_loc = { pattern = { '%-%-%- DUMP_LOCALIZATION\n'}} - } - - - local json_spec = { - id = { type = 'string', required = true }, - author = { type = 'table', required = true, check = function(mod, t) - for k, v in pairs(t) do - if type(k) ~= 'number' or type(v) ~= 'string' then t[k] = nil end - end - return t - end }, - name = { type = 'string', required = true }, - display_name = { type = 'string', check = function(mod, s) mod.display_name = s or mod.name end }, - description = { type = 'string', required = true }, - priority = { type = 'number', default = 0 }, - badge_colour = { type = 'string', check = function(mod, s) local success, hex = pcall(HEX, s); mod.badge_colour = success and hex or HEX('666665FF') end }, - badge_text_colour = { type = 'string', check = function(mod, s) local success, hex = pcall(HEX, s); mod.badge_text_colour = success and hex or HEX('FFFFFFFF') end}, - prefix = { type = 'string', required = true }, - version = { type = 'string', check = function(mod, x) return x and V(x):is_valid() and x or '0.0.0' end }, - dump_loc = { type = 'boolean' }, - dependencies = { type = 'table', check = function(mod, t) - local ops = { - ['<<'] = function(a,b) return a>'] = function(a,b) return a>b end, - ['<='] = function(a,b) return a<=b end, - ['>='] = function(a,b) return a>=b end, - ['=='] = function(a,b) return a==b end - } - for i,v in ipairs(t or {}) do - local parts = {} - parts.str = v - for part in v:gmatch('([^|]+)') do - local x = {} - x.id = part:match '^([^(%s]+)' - local j = 1 - for version_string in string.gmatch(part, '%((.-)%)') do - local operator, version = string.match(version_string, '^(..)(.*)$') - local op = ops[operator] - local ver = V(version) - -- if operator == '<<' and not ver.rev then - -- ver.beta = -1 - -- ver.rev = '~' - -- end - if op and ver:is_valid(true) then - x[j] = { op = op, ver = ver } - j = j+1 - end - end - parts[#parts+1] = x - end - t[i] = parts - end - end}, - conflicts = { type = 'table', check = function(mod, t) - local ops = { - ['<<'] = function(a,b) return a>'] = function(a,b) return a>b end, - ['<='] = function(a,b) return a<=b end, - ['>='] = function(a,b) return a>=b end, - ['=='] = function(a,b) return a==b end - } - for i,v in ipairs(t or {}) do - v = v:gsub('%s', '') - local x = {} - x.str = v - v = v:gsub('%s', '') - x.id = v:match '^([^(%s]+)' - local j = 1 - for version_string in string.gmatch(v, '%((.-)%)') do - local operator, version = string.match(version_string, '^(..)(.*)$') - local op = ops[operator] - local ver = V(version) - -- if operator == '<<' and not ver.rev then - -- ver.beta = -1 - -- ver.rev = '~' - -- end - if op and ver:is_valid(true) then - x[j] = { op = op, ver = ver, str = '('..version_string..')' } - j = j+1 - end - end - t[i] = x - end - end}, - main_file = { type = 'string', required = true }, - config_file = {type = 'string', default = 'config.lua' }, - __ = { check = function(mod) - if SMODS.Mods[mod.id] then error('dupe') end - end}, - provides = { type = 'table', check = function(mod, t) - t = t or {} - for _,v in pairs(t) do - v = v:gsub('%s', '') - local id = v:match '^([^(%s]+)' - local ver = v:match '%((.-)%)' - ver = (ver and V(ver):is_valid()) and ver or mod.version - if id and ver then - SMODS.provided_mods[id] = SMODS.provided_mods[id] or {} - table.insert(SMODS.provided_mods[id], { version = ver, mod = mod }) - end - end - end} - - } - - - local used_prefixes = {} - local lovely_directories = {} - - -- Function to process each directory (including subdirectories) with depth tracking - local function processDirectory(directory, depth) - if depth > 3 or directory..'/' == SMODS.path then - return - end - - local isDirLovely = false - - for _, filename in ipairs(NFS.getDirectoryItems(directory)) do - local file_path = directory .. "/" .. filename - - -- Check if the current file is a directory - local file_type = NFS.getInfo(file_path).type - if file_type == 'directory' or file_type == 'symlink' then - -- Lovely patches - if depth == 2 and filename == "lovely" and not isDirLovely then - isDirLovely = true - table.insert(lovely_directories, directory .. "/") - end - -- If it's a directory and depth is within limit, recursively process it - if depth < 2 or (filename:lower() ~= 'localization' and filename:lower() ~= 'assets') then - processDirectory(file_path, depth + 1) - end - elseif depth == 2 and filename == "lovely.toml" and not isDirLovely then - isDirLovely = true - table.insert(lovely_directories, directory .. "/") - elseif filename:lower():match('%.json') and depth > 1 then - local json_str = NFS.read(file_path) - local parsed, mod = pcall(JSON.decode, json_str) - local valid = true - local err - if not parsed then - valid = false - err = mod - else - mod.json = true - mod.path = directory .. '/' - mod.optional_dependencies = {} - local success, e = pcall(function() - -- remove invalid fields and check required ones first - for k, v in pairs(json_spec) do - if v.type and type(mod[k]) ~= v.type then mod[k] = nil end - if v.required and mod[k] == nil then error(k) end - end - -- perform additional checks and fill in defaults - for k, v in pairs(json_spec) do - if v.default then mod[k] = mod[k] or v.default end - if v.check then v.check(mod, mod[k]) end - end - end) - if not success then - valid = false - err = e - end - end - if not valid then - sendErrorMessage(('Found invalid metadata JSON file at %s, ignoring: %s'):format(file_path, err), 'Loader') - else - sendInfoMessage('Valid JSON file found') - if NFS.getInfo(directory..'/.lovelyignore') then - mod.disabled = true - end - if mod.prefix and used_prefixes[mod.prefix] then - mod.can_load = false - mod.load_issues = { - prefix_conflict = used_prefixes[mod.prefix], - dependencies = {}, - conflicts = {}, - } - sendWarnMessage(('Duplicate Mod prefix %s used by %s, %s'):format(mod.prefix, mod.id, used_prefixes[mod.prefix]), 'Loader') - end - if not NFS.getInfo(mod.path..mod.main_file) then - mod.can_load = false - mod.load_issues = { - main_file_not_found = true, - dependencies = {}, - conflicts = {}, - } - sendWarnMessage(('Unable to load Mod %s: cannot find main file'):format(mod.id), 'Loader') - end - if mod.dump_loc then - SMODS.dump_loc = { - path = mod.path, - } - end - SMODS.Mods[mod.id] = mod - SMODS.mod_priorities[mod.priority] = SMODS.mod_priorities[mod.priority] or {} - table.insert(SMODS.mod_priorities[mod.priority], mod) - end - elseif filename:lower():match("%.lua$") then -- Check for legacy headers - if depth == 1 then - sendWarnMessage(('Found lone Lua file %s in Mods directory :: Please place the files for each mod in its own subdirectory.'):format(filename), 'Loader') - end - local file_content = NFS.read(file_path) - - -- Convert CRLF in LF - file_content = file_content:gsub("\r\n", "\n") - - -- Check the header lines using string.match - local headerLine = file_content:match("^(.-)\n") - if headerLine == "--- STEAMODDED HEADER" then - sendTraceMessage('Processing Mod file (Legacy header): ' .. filename, "Loader") - local mod = {} - local sane = true - for k, v in pairs(header_components) do - local component = nil - if type(v.pattern) == "table" then - for _, pattern in ipairs(v.pattern) do - component = file_content:match(pattern) or component - if component then break end - end - else - component = file_content:match(v.pattern) - end - if v.required and not component then - sane = false - sendWarnMessage(string.format('Mod file %s is missing required header component: %s', - filename, k), 'Loader') - break - end - if v.parse_array then - local list = {} - component = component or '' - for val in string.gmatch(component, "([^,]+)") do - table.insert(list, val:match("^%s*(.-)%s*$")) -- Trim spaces - end - component = list - end - if v.handle and type(v.handle) == 'function' then - component = v.handle(component) - end - mod[k] = component - end - if NFS.getInfo(directory..'/.lovelyignore') then - mod.disabled = true - end - if SMODS.Mods[mod.id] then - sane = false - sendWarnMessage("Duplicate Mod ID: " .. mod.id, 'Loader') - end - - if mod.outdated then - mod.prefix_config = { key = { mod = false }, atlas = false } - else - mod.prefix = mod.prefix or (mod.id or ''):lower():sub(1, 4) - end - if mod.prefix and used_prefixes[mod.prefix] then - mod.can_load = false - mod.load_issues = { - prefix_conflict = used_prefixes[mod.prefix], - dependencies = {}, - conflicts = {}, - } - sendWarnMessage(('Duplicate Mod prefix %s used by %s, %s'):format(mod.prefix, mod.id, used_prefixes[mod.prefix]), 'Loader') - end - - if sane then - sendTraceMessage('Saving Mod Info: ' .. mod.id, 'Loader') - mod.path = directory .. '/' - mod.main_file = filename - mod.display_name = mod.display_name or mod.name - if mod.prefix then - used_prefixes[mod.prefix] = mod.id - end - mod.optional_dependencies = {} - if mod.dump_loc then - SMODS.dump_loc = { - path = mod.path, - } - end - SMODS.Mods[mod.id] = mod - SMODS.mod_priorities[mod.priority] = SMODS.mod_priorities[mod.priority] or {} - table.insert(SMODS.mod_priorities[mod.priority], mod) - end - end - end - end - end - - - boot_print_stage('Processing Mod Files') - -- Start processing with the initial directory at depth 1 - processDirectory(modsDirectory, 1) - for _, path in ipairs(lovely_directories) do - local hasSMOD = false - for _, mod in pairs(SMODS.Mods) do - if mod.path == path then - mod.lovely = true - hasSMOD = true - end - end - if not hasSMOD then - local name = string.match(path, "[/\\]([^/\\]+)[/\\]?$") - local disabled = not not NFS.getInfo(path .. '/.lovelyignore') - local mod = { - name = name, - id = "lovely-compat-" .. name, - author = {"???"}, - description = "A lovely mod.", - prefix_config = { key = { mod = false }, atlas = false }, - priority = 0, - badge_colour = HEX("666666FF"), - badge_text_colour = HEX('FFFFFF'), - path = path, - main_file = "", - display_name = name, - dependencies = {}, - optional_dependencies = {}, - conflicts = {}, - version = "0.0.0", - can_load = not disabled, - lovely = true, - lovely_only = true, - meta_mod = true, - disabled = disabled, - load_issues = { - dependencies = {}, - conflicts = {}, - disabled = disabled - } - - } - SMODS.mod_priorities[mod.priority] = SMODS.mod_priorities[mod.priority] or {} - table.insert(SMODS.mod_priorities[mod.priority], mod) - SMODS.Mods[mod.id] = mod - end - end - - -- sort by priority - local keyset = {} - for k, _ in pairs(SMODS.mod_priorities) do - keyset[#keyset + 1] = k - end - table.sort(keyset) - - local function check_dependencies(mod, seen) - if not (mod.can_load == nil) then return mod.can_load end - seen = seen or {} - local can_load = true - if seen[mod.id] then return true end - seen[mod.id] = true - local load_issues = { - dependencies = {}, - conflicts = {}, - } - if not mod.json then - for _, v in ipairs(mod.conflicts or {}) do - -- block load even if the conflict is also blocked - if - SMODS.Mods[v.id] and - (not v.max_version or V(SMODS.Mods[v.id].version) <= V(v.max_version)) and - (not v.min_version or V(SMODS.Mods[v.id].version) >= V(v.min_version)) - then - can_load = false - table.insert(load_issues.conflicts, v.id..(v.max_version and '<='..v.max_version or '')..(v.min_version and '>='..v.min_version or '')) - end - end - for _, v in ipairs(mod.dependencies or {}) do - -- recursively check dependencies of dependencies to make sure they are actually fulfilled - if - not SMODS.Mods[v.id] or - not check_dependencies(SMODS.Mods[v.id], seen) or - (v.max_version and V(SMODS.Mods[v.id].version) > V(v.max_version)) or - (v.min_version and V(SMODS.Mods[v.id].version) < V(v.min_version)) - then - can_load = false - table.insert(load_issues.dependencies, - v.id .. (v.min_version and '>=' .. v.min_version or '') .. (v.max_version and '<=' .. v.max_version or '')) - if v.id == 'Steamodded' then - load_issues.version_mismatch = ''..(v.min_version and '>='..v.min_version or '')..(v.max_version and '<='..v.max_version or '') - end - end - end - else - for _, x in ipairs(mod.dependencies or {}) do - local fulfilled - for _, y in ipairs(x) do - if fulfilled then break end - local id = y.id - if SMODS.Mods[id] and check_dependencies(SMODS.Mods[id], seen) then - fulfilled = true - local dep_ver = V(SMODS.Mods[id].version) - for _, v in ipairs(y) do - if not v.op(dep_ver, v.ver) then - fulfilled = false - end - end - if fulfilled then y.fulfilled = true end - else - for _, provided in ipairs(SMODS.provided_mods[id] or {}) do - if provided.mod ~= mod and check_dependencies(provided.mod, seen) then - fulfilled = true - local dep_ver = V(provided.version) - for _, v in ipairs(y) do - if not v.op(dep_ver, v.ver) then - fulfilled = false - end - end - if fulfilled then y.fulfilled = true; y.provided = provided end - end - end - end - end - if not fulfilled then - can_load = false - table.insert(load_issues.dependencies, x.str) - end - end - for _, y in ipairs(mod.conflicts or {}) do - local id = y.id - local conflict = false - if SMODS.Mods[id] and check_dependencies(SMODS.Mods[id], seen) then - conflict = true - local dep_ver = V(SMODS.Mods[id].version) - for _, v in ipairs(y) do - if not v.op(dep_ver, v.ver) then - conflict = false - break - end - end - else - for _, provided in ipairs(SMODS.provided_mods[id] or {}) do - if provided.mod ~= mod and check_dependencies(provided.mod, seen) then - conflict = true - local dep_ver = V(provided.version) - for _, v in ipairs(y) do - if not v.op(dep_ver, v.ver) then - conflict = false - break - end - end - end - end - end - if conflict then - can_load = false - table.insert(load_issues.conflicts, y.str) - end - end - end - if mod.disabled then - can_load = false - load_issues.disabled = true - end - if not can_load then - mod.load_issues = load_issues - return false - end - for _, x in ipairs(mod.dependencies or {}) do - for _, y in ipairs(x) do - if y.fulfilled then - if y.provided then - y.provided.mod.can_load = true - else - SMODS.Mods[y.id].can_load = true - end - end - end - end - return true - end - - -- check dependencies first (for object dependencies) - for _, mod in pairs(SMODS.Mods) do mod.can_load = check_dependencies(mod) end - - boot_print_stage('Loading Mods') - -- load the mod files - for _, priority in ipairs(keyset) do - table.sort(SMODS.mod_priorities[priority], - function(mod_a, mod_b) - return mod_a.id < mod_b.id - end) - for _, mod in ipairs(SMODS.mod_priorities[priority]) do - SMODS.mod_list[#SMODS.mod_list + 1] = mod -- keep mod list in prioritized load order - if mod.can_load and not mod.lovely_only then - SMODS.current_mod = mod - if mod.outdated then - SMODS.compat_0_9_8.with_compat(function() - mod.config = {} - assert(load(NFS.read(mod.path..mod.main_file), ('=[SMODS %s "%s"]'):format(mod.id, mod.main_file)))() - for k, v in pairs(SMODS.compat_0_9_8.init_queue) do - v() - SMODS.compat_0_9_8.init_queue[k] = nil - end - end) - else - SMODS.load_mod_config(mod) - assert(load(NFS.read(mod.path..mod.main_file), ('=[SMODS %s "%s"]'):format(mod.id, mod.main_file)))() - end - SMODS.current_mod = nil - elseif not mod.lovely_only then - sendTraceMessage(string.format("Mod %s was unable to load: %s%s%s%s", mod.id, - mod.load_issues.outdated and - 'Outdated: Steamodded versions 0.9.8 and below are no longer supported!\n' or '', - mod.load_issues.main_file_not_found and "The main file could not be found.\n" or '', - next(mod.load_issues.dependencies) and - ('Missing Dependencies: ' .. inspect(mod.load_issues.dependencies) .. '\n') or '', - next(mod.load_issues.conflicts) and - ('Unresolved Conflicts: ' .. inspect(mod.load_issues.conflicts) .. '\n') or '' - ), 'Loader') - end - end - end - SMODS.get_optional_features() - -- compat after loading mods - if SMODS.compat_0_9_8.load_done then - -- Invasive change to Card:generate_UIBox_ability_table() - local Card_generate_UIBox_ability_table_ref = Card.generate_UIBox_ability_table - function Card:generate_UIBox_ability_table(...) - SMODS.compat_0_9_8.generate_UIBox_ability_table_card = self - local ret = Card_generate_UIBox_ability_table_ref(self, ...) - SMODS.compat_0_9_8.generate_UIBox_ability_table_card = nil - return ret - end - end -end - -function SMODS.injectItems() - -- Set .key for vanilla undiscovered, locked objects - for k, v in pairs(G) do - if type(k) == 'string' and (k:sub(-12, -1) == 'undiscovered' or k:sub(-6, -1) == 'locked') then - v.key = k - end - end - SMODS.injectObjects(SMODS.GameObject) - if SMODS.dump_loc then - boot_print_stage('Dumping Localization') - SMODS.create_loc_dump() - end - boot_print_stage('Initializing Localization') - init_localization() - SMODS.SAVE_UNLOCKS() - table.sort(G.P_CENTER_POOLS["Back"], function (a, b) return (a.order - (a.unlocked and 100 or 0)) < (b.order - (b.unlocked and 100 or 0)) end) - for _, t in ipairs{ - G.P_CENTERS, - G.P_BLINDS, - G.P_TAGS, - G.P_SEALS, - } do - for k, v in pairs(t) do - assert(v._discovered_unlocked_overwritten) - end - end -end - -local function initializeModUIFunctions() - for id, modInfo in pairs(SMODS.mod_list) do - G.FUNCS["openModUI_" .. modInfo.id] = function(e) - G.ACTIVE_MOD_UI = modInfo - G.FUNCS.overlay_menu({ - definition = create_UIBox_mods(e) - }) - end - end -end - -local function checkForLoadFailure() - SMODS.mod_button_alert = false - for k,v in pairs(SMODS.Mods) do - if v and not v.can_load and not v.disabled then - SMODS.mod_button_alert = true - return - end - end -end - -function initSteamodded() - initGlobals() - boot_print_stage("Loading APIs") - loadAPIs() - loadMods(SMODS.MODS_DIR) - checkForLoadFailure() - initializeModUIFunctions() - boot_print_stage("Injecting Items") - SMODS.injectItems() - SMODS.booted = true -end - --- re-inject on reload -local init_item_prototypes_ref = Game.init_item_prototypes -function Game:init_item_prototypes() - init_item_prototypes_ref(self) - convert_save_data() - if SMODS.booted then - SMODS.injectItems() - end -end - -SMODS.booted = false -function boot_print_stage(stage) - if not SMODS.booted then - boot_timer(nil, "STEAMODDED - " .. stage, 0.95) - end -end - -function boot_timer(_label, _next, progress) - progress = progress or 0 - G.LOADING = G.LOADING or { - font = love.graphics.setNewFont("resources/fonts/m6x11plus.ttf", 20), - love.graphics.dis - } - local realw, realh = love.window.getMode() - love.graphics.setCanvas() - love.graphics.push() - love.graphics.setShader() - love.graphics.clear(0, 0, 0, 1) - love.graphics.setColor(0.6, 0.8, 0.9, 1) - if progress > 0 then love.graphics.rectangle('fill', realw / 2 - 150, realh / 2 - 15, progress * 300, 30, 5) end - love.graphics.setColor(1, 1, 1, 1) - love.graphics.setLineWidth(3) - love.graphics.rectangle('line', realw / 2 - 150, realh / 2 - 15, 300, 30, 5) - love.graphics.print("LOADING: " .. _next, realw / 2 - 150, realh / 2 + 40) - love.graphics.pop() - love.graphics.present() - - G.ARGS.bt = G.ARGS.bt or love.timer.getTime() - G.ARGS.bt = love.timer.getTime() -end - -function SMODS.load_file(path, id) - if not path or path == "" then - error("No path was provided to load.") - end - local mod - if not id then - if not SMODS.current_mod then - error("No ID was provided! Usage without an ID is only available when file is first loaded.") - end - mod = SMODS.current_mod - else - mod = SMODS.Mods[id] - end - if not mod then - error("Mod not found. Ensure you are passing the correct ID.") - end - local file_path = mod.path .. path - local file_content, err = NFS.read(file_path) - if not file_content then return nil, "Error reading file '" .. path .. "' for mod with ID '" .. mod.id .. "': " .. err end - local chunk, err = load(file_content, "=[SMODS " .. mod.id .. ' "' .. path .. '"]') - if not chunk then return nil, "Error processing file '" .. path .. "' for mod with ID '" .. mod.id .. "': " .. err end - return chunk -end - ----------------------------------------------- -------------MOD LOADER END-------------------- diff --git a/smods-main/src/logging.lua b/smods-main/src/logging.lua deleted file mode 100644 index 001ed9c..0000000 --- a/smods-main/src/logging.lua +++ /dev/null @@ -1,58 +0,0 @@ ---- STEAMODDED CORE ---- MODULE LOGGING - -function initializeSocketConnection() - local socket = require("socket") - client = socket.connect("localhost", 53153) - if not client then - print("Failed to connect to the debug server") - end -end - --- message, logger in this order to preserve backward compatibility -function sendTraceMessage(message, logger) - sendMessageToConsole("TRACE", logger, message) -end - -function sendDebugMessage(message, logger) - sendMessageToConsole("DEBUG", logger, message) -end - -function sendInfoMessage(message, logger) - -- space in info string to align the logs in console - sendMessageToConsole("INFO ", logger, message) -end - -function sendWarnMessage(message, logger) - -- space in warn string to align the logs in console - sendMessageToConsole("WARN ", logger, message) -end - -function sendErrorMessage(message, logger) - sendMessageToConsole("ERROR", logger, message) -end - -function sendFatalMessage(message, logger) - sendMessageToConsole("FATAL", logger, message) -end - -function sendMessageToConsole(level, logger, message) - level = level or "DEBUG" - logger = logger or "DefaultLogger" - message = message or "Default log message" - date = os.date('%Y-%m-%d %H:%M:%S') - print(date .. " :: " .. level .. " :: " .. logger .. " :: " .. message) - if client then - -- naive way to separate the logs if the console receive multiple logs at the same time - client:send(date .. " :: " .. level .. " :: " .. logger .. " :: " .. message .. "ENDOFLOG") - end -end - -initializeSocketConnection() - --- Use the function to send messages -sendDebugMessage("Steamodded Debug Socket started !", "DebugConsole") - - ------------------------------------------------ ----------------MOD LOGGING END----------------- diff --git a/smods-main/src/overrides.lua b/smods-main/src/overrides.lua deleted file mode 100644 index 139a35d..0000000 --- a/smods-main/src/overrides.lua +++ /dev/null @@ -1,1753 +0,0 @@ ---- STEAMODDED CORE ---- OVERRIDES - ---#region blind UI --- Recreate all lines of the blind description. --- This callback is called each frame. ----@param e {} ---**e** Is the UIE that called this function -G.FUNCS.HUD_blind_debuff = function(e) - local scale = 0.4 - local num_lines = #G.GAME.blind.loc_debuff_lines - while G.GAME.blind.loc_debuff_lines[num_lines] == '' do - num_lines = num_lines - 1 - end - local padding = 0.05 - if num_lines > 5 then - local excess_height = (0.3 + padding)*(num_lines - 5) - padding = padding - excess_height / (num_lines + 1) - end - e.config.padding = padding - if num_lines > #e.children then - for i = #e.children+1, num_lines do - local node_def = {n = G.UIT.R, config = {align = "cm", minh = 0.3, maxw = 4.2}, nodes = { - {n = G.UIT.T, config = {ref_table = G.GAME.blind.loc_debuff_lines, ref_value = i, scale = scale * 0.9, colour = G.C.UI.TEXT_LIGHT}}}} - e.UIBox:set_parent_child(node_def, e) - end - elseif num_lines < #e.children then - for i = num_lines+1, #e.children do - e.children[i]:remove() - e.children[i] = nil - end - end - e.UIBox:recalculate() - assert(G.HUD_blind == e.UIBox) -end - -function create_UIBox_your_collection_blinds(exit) - local min_ante = 1 - local max_ante = 16 - local spacing = 1 - 15*0.06 - if G.GAME and G.GAME.round_resets and G.GAME.round_resets.ante then - local current_ante = G.GAME.round_resets.ante - - if current_ante > 8 then - min_ante = current_ante - 8 + 1 - max_ante = current_ante + 8 - end - end - local ante_amounts = {} - for i = min_ante, max_ante do - if i > 1 then - ante_amounts[#ante_amounts + 1] = { n = G.UIT.R, config = { minh = spacing }, nodes = {} } - end - local blind_chip = Sprite(0, 0, 0.2, 0.2, G.ASSET_ATLAS["ui_" .. (G.SETTINGS.colourblind_option and 2 or 1)], - { x = 0, y = 0 }) - blind_chip.states.drag.can = false - ante_amounts[#ante_amounts + 1] = { - n = G.UIT.R, - config = { align = "cm", padding = 0.03 }, - nodes = { - { - n = G.UIT.C, - config = { align = "cm", minw = 0.7 }, - nodes = { - { n = G.UIT.T, config = { text = i, scale = 0.4, colour = G.C.FILTER, shadow = true } }, - } - }, - { - n = G.UIT.C, - config = { align = "cr", minw = 2.8 }, - nodes = { - { n = G.UIT.O, config = { object = blind_chip } }, - { n = G.UIT.C, config = { align = "cm", minw = 0.03, minh = 0.01 }, nodes = {} }, - { n = G.UIT.T, config = { text = number_format(get_blind_amount(i)), scale = 0.4, colour = i <= G.PROFILES[G.SETTINGS.profile].high_scores.furthest_ante.amt and G.C.RED or G.C.JOKER_GREY, shadow = true } }, - } - } - } - } - end - - local rows = 6 - local cols = 5 - local page = 1 - local deck_tables = {} - - G.your_collection = {} - for j = 1, rows do - G.your_collection[j] = CardArea( - G.ROOM.T.x + 0.2 * G.ROOM.T.w / 2, G.ROOM.T.h, - cols * 1.55, - 0.95 * 1.33, - { card_limit = cols, type = 'title_2', highlight_limit = 0, collection = true }) - table.insert(deck_tables, - { - n = G.UIT.R, - config = { align = "cm", padding = 0, no_fill = true }, - nodes = { - j%2 == 0 and { n = G.UIT.B, config = { h = 0.2, w = 0.5 } } or nil, - { n = G.UIT.O, config = { object = G.your_collection[j] } }, - j%2 == 1 and { n = G.UIT.B, config = { h = 0.2, w = 0.5 } } or nil, - } - } - ) - end - - local blind_tab = SMODS.collection_pool(G.P_BLINDS) - local blinds_amt = #blind_tab - - local this_page = {} - for i, v in ipairs(blind_tab) do - if i > rows*cols*(page-1) and i <= rows*cols*page then - table.insert(this_page, v) - elseif i > rows*cols*page then - break - end - end - blind_tab = this_page - - local blinds_to_be_alerted = {} - local row, col = 1, 1 - for k, v in ipairs(blind_tab) do - local temp_blind = AnimatedSprite(G.your_collection[row].T.x + G.your_collection[row].T.w/2, G.your_collection[row].T.y, 1.3, 1.3, G.ANIMATION_ATLAS[v.discovered and v.atlas or 'blind_chips'], - v.discovered and v.pos or G.b_undiscovered.pos) - temp_blind.states.click.can = false - temp_blind.states.drag.can = false - temp_blind.states.hover.can = true - local card = Card(G.your_collection[row].T.x + G.your_collection[row].T.w/2, G.your_collection[row].T.y, 1.3, 1.3, G.P_CARDS.empty, G.P_CENTERS.c_base) - temp_blind.states.click.can = false - card.states.drag.can = false - card.states.hover.can = true - card.children.center = temp_blind - temp_blind:set_role({major = card, role_type = 'Glued', draw_major = card}) - card.set_sprites = function(...) - local args = {...} - if not args[1].animation then return end -- fix for debug unlock - local c = card.children.center - Card.set_sprites(...) - card.children.center = c - end - temp_blind:define_draw_steps({ - { shader = 'dissolve', shadow_height = 0.05 }, - { shader = 'dissolve' } - }) - temp_blind.float = true - card.states.collide.can = true - card.config.blind = v - card.config.force_focus = true - if v.discovered and not v.alerted then - blinds_to_be_alerted[#blinds_to_be_alerted + 1] = card - end - card.hover = function() - if not G.CONTROLLER.dragging.target or G.CONTROLLER.using_touch then - if not card.hovering and card.states.visible then - card.hovering = true - card.hover_tilt = 3 - card:juice_up(0.05, 0.02) - play_sound('chips1', math.random() * 0.1 + 0.55, 0.12) - card.config.h_popup = create_UIBox_blind_popup(v, card.config.blind.discovered) - card.config.h_popup_config = card:align_h_popup() - Node.hover(card) - if card.children.alert then - card.children.alert:remove() - card.children.alert = nil - card.config.blind.alerted = true - G:save_progress() - end - end - end - card.stop_hover = function() - card.hovering = false; Node.stop_hover(card); card.hover_tilt = 0 - end - end - G.your_collection[row]:emplace(card) - col = col + 1 - if col > cols then col = 1; row = row + 1 end - end - - G.E_MANAGER:add_event(Event({ - trigger = 'immediate', - func = (function() - for _, v in ipairs(blinds_to_be_alerted) do - v.children.alert = UIBox { - definition = create_UIBox_card_alert(), - config = { align = "tri", offset = { x = 0.1, y = 0.1 }, parent = v } - } - v.children.alert.states.collide.can = false - end - return true - end) - })) - - local page_options = {} - for i = 1, math.ceil(blinds_amt/(rows*cols)) do - table.insert(page_options, localize('k_page')..' '..tostring(i)..'/'..tostring(math.ceil(blinds_amt/(rows*cols)))) - end - - local extras = nil - local t = create_UIBox_generic_options({ - back_func = G.ACTIVE_MOD_UI and "openModUI_"..G.ACTIVE_MOD_UI.id or exit or 'your_collection', - contents = { - { - n = G.UIT.C, - config = { align = "cm", r = 0.1, colour = G.C.BLACK, padding = 0.1, emboss = 0.05 }, - nodes = { - { - n = G.UIT.C, - config = { align = "cm", r = 0.1, colour = G.C.L_BLACK, padding = 0.1, force_focus = true, focus_args = { nav = 'tall' } }, - nodes = { - { - n = G.UIT.R, - config = { align = "cm", padding = 0.05 }, - nodes = { - { - n = G.UIT.C, - config = { align = "cm", minw = 0.7 }, - nodes = { - { n = G.UIT.T, config = { text = localize('k_ante_cap'), scale = 0.4, colour = lighten(G.C.FILTER, 0.2), shadow = true } }, - } - }, - { - n = G.UIT.C, - config = { align = "cr", minw = 2.8 }, - nodes = { - { n = G.UIT.T, config = { text = localize('k_base_cap'), scale = 0.4, colour = lighten(G.C.RED, 0.2), shadow = true } }, - } - } - } - }, - { n = G.UIT.R, config = { align = "cm" }, nodes = ante_amounts } - } - }, - { - n = G.UIT.C, - config = { align = 'cm' }, - nodes = { - { - n = G.UIT.R, - config = { align = 'cm', padding = 0.15 }, - nodes = {} - }, - { - n= G.UIT.R, - config = {align = 'cm' }, - nodes = { - { - n = G.UIT.C, - config = { - align = 'cm', - }, - nodes = deck_tables, - } - } - }, - { - n = G.UIT.R, - config = { align = 'cm', padding = 0.1 }, - nodes = {} - }, - create_option_cycle({ - options = page_options, - w = 4.5, - cycle_shoulders = true, - opt_callback = 'your_collection_blinds_page', - focus_args = {snap_to = true, nav = 'wide'}, - current_option = page, - colour = G.C.RED, - no_pips = true - }) - }, - }, - } - } - } - }) - return t -end - -function G.FUNCS.your_collection_blinds_page(args) - if not args or not args.cycle_config then return end - for j = 1, #G.your_collection do - for i = #G.your_collection[j].cards, 1, -1 do - local c = G.your_collection[j]:remove_card(G.your_collection[j].cards[i]) - c:remove() - c = nil - end - end - - local cols = 5 - local rows = 6 - local page = args.cycle_config.current_option - local blind_tab = SMODS.collection_pool(G.P_BLINDS) - - local this_page = {} - for i, v in ipairs(blind_tab) do - if i > rows*cols*(page-1) and i <= rows*cols*page then - table.insert(this_page, v) - elseif i > rows*cols*page then - break - end - end - blind_tab = this_page - - local blinds_to_be_alerted = {} - local row, col = 1, 1 - for k, v in ipairs(blind_tab) do - local temp_blind = AnimatedSprite(G.your_collection[row].T.x + G.your_collection[row].T.w/2, G.your_collection[row].T.y, 1.3, 1.3, G.ANIMATION_ATLAS[v.discovered and v.atlas or 'blind_chips'], - v.discovered and v.pos or G.b_undiscovered.pos) - temp_blind.states.click.can = false - temp_blind.states.drag.can = false - temp_blind.states.hover.can = true - local card = Card(G.your_collection[row].T.x + G.your_collection[row].T.w/2, G.your_collection[row].T.y, 1.3, 1.3, G.P_CARDS.empty, G.P_CENTERS.c_base) - temp_blind.states.click.can = false - card.states.drag.can = false - card.states.hover.can = true - card.children.center = temp_blind - temp_blind:set_role({major = card, role_type = 'Glued', draw_major = card}) - card.set_sprites = function(...) - local args = {...} - if not args[1].animation then return end -- fix for debug unlock - local c = card.children.center - Card.set_sprites(...) - card.children.center = c - end - temp_blind:define_draw_steps({ - { shader = 'dissolve', shadow_height = 0.05 }, - { shader = 'dissolve' } - }) - temp_blind.float = true - card.states.collide.can = true - card.config.blind = v - card.config.force_focus = true - if v.discovered and not v.alerted then - blinds_to_be_alerted[#blinds_to_be_alerted + 1] = card - end - card.hover = function() - if not G.CONTROLLER.dragging.target or G.CONTROLLER.using_touch then - if not card.hovering and card.states.visible then - card.hovering = true - card.hover_tilt = 3 - card:juice_up(0.05, 0.02) - play_sound('chips1', math.random() * 0.1 + 0.55, 0.12) - card.config.h_popup = create_UIBox_blind_popup(v, card.config.blind.discovered) - card.config.h_popup_config = card:align_h_popup() - Node.hover(card) - if card.children.alert then - card.children.alert:remove() - card.children.alert = nil - card.config.blind.alerted = true - G:save_progress() - end - end - end - card.stop_hover = function() - card.hovering = false; Node.stop_hover(card); card.hover_tilt = 0 - end - end - G.your_collection[row]:emplace(card) - col = col + 1 - if col > cols then col = 1; row = row + 1 end - end - G.E_MANAGER:add_event(Event({ - trigger = 'immediate', - func = (function() - for _, v in ipairs(blinds_to_be_alerted) do - v.children.alert = UIBox{ - definition = create_UIBox_card_alert(), - config = { align="tri", offset = {x = 0.1, y = 0.1}, parent = v} - } - v.children.alert.states.collide.can = false - end - return true - end) - })) -end ---#endregion ---#region tag collections -function create_UIBox_your_collection_tags() - G.E_MANAGER:add_event(Event({ - func = function() - G.FUNCS.your_collection_tags_page({ cycle_config = {}}) - return true - end - })) - return { - n = G.UIT.O, - config = { object = UIBox{ - definition = create_UIBox_your_collection_tags_content(), - config = { offset = {x=0, y=0}, align = 'cm' } - }, id = 'your_collection_tags_contents', align = 'cm' }, - } -end - -function create_UIBox_your_collection_tags_content(page) - page = page or 1 - local tag_matrix = {} - local rows = 4 - local cols = 6 - local tag_tab = SMODS.collection_pool(G.P_TAGS) - for i = 1, math.ceil(rows) do - table.insert(tag_matrix, {}) - end - - local tags_to_be_alerted = {} - local row, col = 1, 1 - for k, v in ipairs(tag_tab) do - if k <= cols*rows*(page-1) then elseif k > cols*rows*page then break else - local discovered = v.discovered - local temp_tag = Tag(v.key, true) - if not v.discovered then temp_tag.hide_ability = true end - local temp_tag_ui, temp_tag_sprite = temp_tag:generate_UI() - tag_matrix[row][col] = { - n = G.UIT.C, - config = { align = "cm", padding = 0.1 }, - nodes = { - temp_tag_ui, - } - } - col = col + 1 - if col > cols then col = 1; row = row + 1 end - if discovered and not v.alerted then - tags_to_be_alerted[#tags_to_be_alerted + 1] = temp_tag_sprite - end - end - end - - G.E_MANAGER:add_event(Event({ - trigger = 'immediate', - func = (function() - for _, v in ipairs(tags_to_be_alerted) do - v.children.alert = UIBox { - definition = create_UIBox_card_alert(), - config = { align = "tri", offset = { x = 0.1, y = 0.1 }, parent = v } - } - v.children.alert.states.collide.can = false - end - return true - end) - })) - - - local table_nodes = {} - for i = 1, rows do - table.insert(table_nodes, { n = G.UIT.R, config = { align = "cm", minh = 1 }, nodes = tag_matrix[i] }) - end - local page_options = {} - for i = 1, math.ceil(#tag_tab/(rows*cols)) do - table.insert(page_options, localize('k_page')..' '..tostring(i)..'/'..tostring(math.ceil(#tag_tab/(rows*cols)))) - end - local t = create_UIBox_generic_options({ - back_func = G.ACTIVE_MOD_UI and "openModUI_" .. G.ACTIVE_MOD_UI.id or 'your_collection', - contents = { - { - n = G.UIT.R, - config = { align = "cm", r = 0.1, colour = G.C.BLACK, padding = 0.1, emboss = 0.05 }, - nodes = { - { - n = G.UIT.C, - config = { align = "cm" }, - nodes = { - { n = G.UIT.R, config = { align = "cm" }, nodes = table_nodes }, - } - }, - } - }, - { - n = G.UIT.R, - config = { align = 'cm' }, - nodes = { - create_option_cycle({ - options = page_options, - w = 4.5, - cycle_shoulders = true, - opt_callback = 'your_collection_tags_page', - focus_args = { snap_to = true, nav = 'wide' }, - current_option = page, - colour = G.C.RED, - no_pips = true - }) - } - } - } - }) - return t -end - -G.FUNCS.your_collection_tags_page = function(args) - local page = args.cycle_config.current_option or 1 - local t = create_UIBox_your_collection_tags_content(page) - local e = G.OVERLAY_MENU:get_UIE_by_ID('your_collection_tags_contents') - if e.config.object then e.config.object:remove() end - e.config.object = UIBox{ - definition = t, - config = {offset = {x=0,y=0}, align = 'cm', parent = e} - } -end ---#endregion ---#region stakes UI -function SMODS.applied_stakes_UI(i, stake_desc_rows, num_added) - if num_added == nil then num_added = { val = 0 } end - if G.P_CENTER_POOLS['Stake'][i].applied_stakes then - for _, v in pairs(G.P_CENTER_POOLS['Stake'][i].applied_stakes) do - if v ~= "white" then - --todo: manage this with pages - if num_added.val < 8 then - local i = G.P_STAKES[v].stake_level - local _stake_desc = {} - local _stake_center = G.P_CENTER_POOLS.Stake[i] - localize { type = 'descriptions', key = _stake_center.key, set = _stake_center.set, nodes = _stake_desc } - local _full_desc = {} - for k, v in ipairs(_stake_desc) do - _full_desc[#_full_desc + 1] = {n = G.UIT.R, config = {align = "cm"}, nodes = v} - end - _full_desc[#_full_desc] = nil - stake_desc_rows[#stake_desc_rows + 1] = {n = G.UIT.R, config = {align = "cm" }, nodes = { - {n = G.UIT.C, config = {align = 'cm'}, nodes = { - {n = G.UIT.C, config = {align = "cm", colour = get_stake_col(i), r = 0.1, minh = 0.35, minw = 0.35, emboss = 0.05 }, nodes = {}}, - {n = G.UIT.B, config = {w = 0.1, h = 0.1}}}}, - {n = G.UIT.C, config = {align = "cm", padding = 0.03, colour = G.C.WHITE, r = 0.1, minh = 0.7, minw = 4.8 }, nodes = - _full_desc},}} - end - num_added.val = num_added.val + 1 - num_added.val = SMODS.applied_stakes_UI(G.P_STAKES[v].stake_level, stake_desc_rows, - num_added) - end - end - end -end - --- We're overwriting so much that it's better to just remake this -function G.UIDEF.deck_stake_column(_deck_key) - local deck_usage = G.PROFILES[G.SETTINGS.profile].deck_usage[_deck_key] - local stake_col = {} - local valid_option = nil - local num_stakes = #G.P_CENTER_POOLS['Stake'] - for i = #G.P_CENTER_POOLS['Stake'], 1, -1 do - local _wins = deck_usage and deck_usage.wins[i] or 0 - if (deck_usage and deck_usage.wins[i - 1]) or i == 1 or G.PROFILES[G.SETTINGS.profile].all_unlocked then valid_option = true end - stake_col[#stake_col + 1] = {n = G.UIT.R, config = {id = i, align = "cm", colour = _wins > 0 and G.C.GREY or G.C.CLEAR, outline = 0, outline_colour = G.C.WHITE, r = 0.1, minh = 2 / num_stakes, minw = valid_option and 0.45 or 0.25, func = 'RUN_SETUP_check_back_stake_highlight'}, nodes = { - {n = G.UIT.R, config = {align = "cm", minh = valid_option and 1.36 / num_stakes or 1.04 / num_stakes, minw = valid_option and 0.37 or 0.13, colour = _wins > 0 and get_stake_col(i) or G.C.UI.TRANSPARENT_LIGHT, r = 0.1}, nodes = {}}}} - if i > 1 then stake_col[#stake_col + 1] = {n = G.UIT.R, config = {align = "cm", minh = 0.8 / num_stakes, minw = 0.04 }, nodes = {} } end - end - return {n = G.UIT.ROOT, config = {align = 'cm', colour = G.C.CLEAR}, nodes = stake_col} -end - ---#endregion ---#region straights and view deck UI -function get_straight(hand) - local ret = {} - local four_fingers = next(SMODS.find_card('j_four_fingers')) - local can_skip = next(SMODS.find_card('j_shortcut')) - if #hand < (5 - (four_fingers and 1 or 0)) then return ret end - local t = {} - local RANKS = {} - for i = 1, #hand do - if hand[i]:get_id() > 0 then - local rank = hand[i].base.value - RANKS[rank] = RANKS[rank] or {} - RANKS[rank][#RANKS[rank] + 1] = hand[i] - end - end - local straight_length = 0 - local straight = false - local skipped_rank = false - local vals = {} - for k, v in pairs(SMODS.Ranks) do - if v.straight_edge then - table.insert(vals, k) - end - end - local init_vals = {} - for _, v in ipairs(vals) do - init_vals[v] = true - end - if not next(vals) then table.insert(vals, 'Ace') end - local initial = true - local br = false - local end_iter = false - local i = 0 - while 1 do - end_iter = false - if straight_length >= (5 - (four_fingers and 1 or 0)) then - straight = true - end - i = i + 1 - if br or (i > #SMODS.Rank.obj_buffer + 1) then break end - if not next(vals) then break end - for _, val in ipairs(vals) do - if init_vals[val] and not initial then br = true end - if RANKS[val] then - straight_length = straight_length + 1 - skipped_rank = false - for _, vv in ipairs(RANKS[val]) do - t[#t + 1] = vv - end - vals = SMODS.Ranks[val].next - initial = false - end_iter = true - break - end - end - if not end_iter then - local new_vals = {} - for _, val in ipairs(vals) do - for _, r in ipairs(SMODS.Ranks[val].next) do - table.insert(new_vals, r) - end - end - vals = new_vals - if can_skip and not skipped_rank then - skipped_rank = true - else - straight_length = 0 - skipped_rank = false - if not straight then t = {} end - if straight then break end - end - end - end - if not straight then return ret end - table.insert(ret, t) - return ret -end - -function G.UIDEF.deck_preview(args) - local _minh, _minw = 0.35, 0.5 - local suit_labels = {} - local suit_counts = {} - local mod_suit_counts = {} - for _, v in ipairs(SMODS.Suit.obj_buffer) do - suit_counts[v] = 0 - mod_suit_counts[v] = 0 - end - local mod_suit_diff = false - local wheel_flipped, wheel_flipped_text = 0, nil - local flip_col = G.C.WHITE - local rank_counts = {} - local deck_tables = {} - remove_nils(G.playing_cards) - table.sort(G.playing_cards, function(a, b) return a:get_nominal('suit') > b:get_nominal('suit') end) - local SUITS = {} - for _, suit in ipairs(SMODS.Suit.obj_buffer) do - SUITS[suit] = {} - for _, rank in ipairs(SMODS.Rank.obj_buffer) do - SUITS[suit][rank] = {} - end - end - local stones = nil - local suit_map = {} - for i = #SMODS.Suit.obj_buffer, 1, -1 do - suit_map[#suit_map + 1] = SMODS.Suit.obj_buffer[i] - end - local rank_name_mapping = {} - for i = #SMODS.Rank.obj_buffer, 1, -1 do - rank_name_mapping[#rank_name_mapping + 1] = SMODS.Rank.obj_buffer[i] - end - for k, v in ipairs(G.playing_cards) do - if v.ability.effect == 'Stone Card' then - stones = stones or 0 - end - if (v.area and v.area == G.deck) or v.ability.wheel_flipped then - if v.ability.wheel_flipped and not (v.area and v.area == G.deck) then wheel_flipped = wheel_flipped + 1 end - if v.ability.effect == 'Stone Card' then - stones = stones + 1 - else - for kk, vv in pairs(suit_counts) do - if v.base.suit == kk then suit_counts[kk] = suit_counts[kk] + 1 end - if v:is_suit(kk) then mod_suit_counts[kk] = mod_suit_counts[kk] + 1 end - end - if SUITS[v.base.suit][v.base.value] then - table.insert(SUITS[v.base.suit][v.base.value], v) - end - rank_counts[v.base.value] = (rank_counts[v.base.value] or 0) + 1 - end - end - end - - wheel_flipped_text = (wheel_flipped > 0) and - {n = G.UIT.T, config = {text = '?', colour = G.C.FILTER, scale = 0.25, shadow = true}} - or nil - flip_col = wheel_flipped_text and mix_colours(G.C.FILTER, G.C.WHITE, 0.7) or G.C.WHITE - - suit_labels[#suit_labels + 1] = {n = G.UIT.R, config = {align = "cm", r = 0.1, padding = 0.04, minw = _minw, minh = 2 * _minh + 0.25}, nodes = { - stones and {n = G.UIT.T, config = {text = localize('ph_deck_preview_stones') .. ': ', colour = G.C.WHITE, scale = 0.25, shadow = true}} - or nil, - stones and {n = G.UIT.T, config = {text = '' .. stones, colour = (stones > 0 and G.C.WHITE or G.C.UI.TRANSPARENT_LIGHT), scale = 0.4, shadow = true}} - or nil,}} - local hidden_ranks = {} - for _, rank in ipairs(rank_name_mapping) do - local count = 0 - for _, suit in ipairs(suit_map) do - count = count + #SUITS[suit][rank] - end - if count == 0 and SMODS.Ranks[rank].in_pool and not SMODS.Ranks[rank]:in_pool({suit=''}) then - hidden_ranks[rank] = true - end - end - local hidden_suits = {} - for _, suit in ipairs(suit_map) do - if suit_counts[suit] == 0 and SMODS.Suits[suit].in_pool and not SMODS.Suits[suit]:in_pool({rank=''}) then - hidden_suits[suit] = true - end - end - local _row = {} - local _bg_col = G.C.JOKER_GREY - for k, v in ipairs(rank_name_mapping) do - local _tscale = 0.3 - local _colour = G.C.BLACK - local rank_col = SMODS.Ranks[v].face and G.C.WHITE or _bg_col - rank_col = mix_colours(rank_col, _bg_col, 0.8) - - local _col = {n = G.UIT.C, config = {align = "cm" }, nodes = { - {n = G.UIT.C, config = {align = "cm", r = 0.1, minw = _minw, minh = _minh, colour = rank_col, emboss = 0.04, padding = 0.03 }, nodes = { - {n = G.UIT.R, config = {align = "cm" }, nodes = { - {n = G.UIT.T, config = {text = '' .. SMODS.Ranks[v].shorthand, colour = _colour, scale = 1.6 * _tscale } },}}, - {n = G.UIT.R, config = {align = "cm", minw = _minw + 0.04, minh = _minh, colour = G.C.L_BLACK, r = 0.1 }, nodes = { - {n = G.UIT.T, config = {text = '' .. (rank_counts[v] or 0), colour = flip_col, scale = _tscale, shadow = true } }}}}}}} - if not hidden_ranks[v] then table.insert(_row, _col) end - end - table.insert(deck_tables, {n = G.UIT.R, config = {align = "cm", padding = 0.04 }, nodes = _row }) - - for _, suit in ipairs(suit_map) do - if not hidden_suits[suit] then - _row = {} - _bg_col = mix_colours(G.C.SUITS[suit], G.C.L_BLACK, 0.7) - for _, rank in ipairs(rank_name_mapping) do - local _tscale = #SUITS[suit][rank] > 0 and 0.3 or 0.25 - local _colour = #SUITS[suit][rank] > 0 and flip_col or G.C.UI.TRANSPARENT_LIGHT - - local _col = {n = G.UIT.C, config = {align = "cm", padding = 0.05, minw = _minw + 0.098, minh = _minh }, nodes = { - {n = G.UIT.T, config = {text = '' .. #SUITS[suit][rank], colour = _colour, scale = _tscale, shadow = true, lang = G.LANGUAGES['en-us'] } },}} - if not hidden_ranks[rank] then table.insert(_row, _col) end - end - table.insert(deck_tables, - {n = G.UIT.R, config = {align = "cm", r = 0.1, padding = 0.04, minh = 0.4, colour = _bg_col }, nodes = - _row}) - end - end - - for k, v in ipairs(suit_map) do - if not hidden_suits[v] then - local deckskin = SMODS.DeckSkins[G.SETTINGS.CUSTOM_DECK.Collabs[v]] - local palette = deckskin.palette_map and deckskin.palette_map[G.SETTINGS.colour_palettes[v] or ''] or (deckskin.palettes or {})[1] - local t_s - if palette and palette.suit_icon and palette.suit_icon.atlas then - local _x = (v == 'Spades' and 3) or (v == 'Hearts' and 0) or (v == 'Clubs' and 2) or (v == 'Diamonds' and 1) - t_s = Sprite(0,0,0.3,0.3,G.ASSET_ATLAS[palette.suit_icon.atlas or 'ui_1'], (type(palette.suit_icon.pos) == "number" and {x=_x, y=palette.suit_icon.pos}) or palette.suit_icon.pos or {x=_x, y=0}) - elseif G.SETTINGS.colour_palettes[v] == 'lc' or G.SETTINGS.colour_palettes[v] == 'hc' then - t_s = Sprite(0, 0, 0.3, 0.3, - G.ASSET_ATLAS[SMODS.Suits[v][G.SETTINGS.colour_palettes[v] == 'hc' and "hc_ui_atlas" or G.SETTINGS.colour_palettes[v] == 'lc' and "lc_ui_atlas"]] or - G.ASSET_ATLAS[("ui_" .. (G.SETTINGS.colourblind_option and "2" or "1"))], SMODS.Suits[v].ui_pos) - else - t_s = Sprite(0, 0, 0.3, 0.3, G.ASSET_ATLAS[("ui_" .. (G.SETTINGS.colourblind_option and "2" or "1"))], SMODS.Suits[v].ui_pos) - end - - t_s.states.drag.can = false - t_s.states.hover.can = false - t_s.states.collide.can = false - - if mod_suit_counts[v] ~= suit_counts[v] then mod_suit_diff = true end - - suit_labels[#suit_labels + 1] = - {n = G.UIT.R, config = {align = "cm", r = 0.1, padding = 0.03, colour = G.C.JOKER_GREY }, nodes = { - {n = G.UIT.C, config = {align = "cm", minw = _minw, minh = _minh }, nodes = { - {n = G.UIT.O, config = {can_collide = false, object = t_s } }}}, - {n = G.UIT.C, config = {align = "cm", minw = _minw * 2.4, minh = _minh, colour = G.C.L_BLACK, r = 0.1 }, nodes = { - {n = G.UIT.T, config = {text = '' .. suit_counts[v], colour = flip_col, scale = 0.3, shadow = true, lang = G.LANGUAGES['en-us'] } }, - mod_suit_counts[v] ~= suit_counts[v] and {n = G.UIT.T, config = {text = ' (' .. mod_suit_counts[v] .. ')', colour = mix_colours(G.C.BLUE, G.C.WHITE, 0.7), scale = 0.28, shadow = true, lang = G.LANGUAGES['en-us'] } } - or nil,}}}} - end - end - - - local t = {n = G.UIT.ROOT, config = {align = "cm", colour = G.C.JOKER_GREY, r = 0.1, emboss = 0.05, padding = 0.07}, nodes = { - {n = G.UIT.R, config = {align = "cm", r = 0.1, emboss = 0.05, colour = G.C.BLACK, padding = 0.1}, nodes = { - {n = G.UIT.R, config = {align = "cm"}, nodes = { - {n = G.UIT.C, config = {align = "cm", padding = 0.04}, nodes = suit_labels }, - {n = G.UIT.C, config = {align = "cm", padding = 0.02}, nodes = deck_tables }}}, - mod_suit_diff and {n = G.UIT.R, config = {align = "cm" }, nodes = { - {n = G.UIT.C, config = {padding = 0.3, r = 0.1, colour = mix_colours(G.C.BLUE, G.C.WHITE, 0.7) }, nodes = {} }, - {n = G.UIT.T, config = {text = ' ' .. localize('ph_deck_preview_effective'), colour = G.C.WHITE, scale = 0.3 } },}} - or nil, - wheel_flipped_text and {n = G.UIT.R, config = {align = "cm" }, nodes = { - {n = G.UIT.C, config = {padding = 0.3, r = 0.1, colour = flip_col }, nodes = {} }, - {n = G.UIT.T, config = { - text = ' ' .. (wheel_flipped > 1 and - localize { type = 'variable', key = 'deck_preview_wheel_plural', vars = { wheel_flipped } } or - localize { type = 'variable', key = 'deck_preview_wheel_singular', vars = { wheel_flipped } }), - colour = G.C.WHITE, - scale = 0.3}},}} - or nil,}}}} - return t -end - -function tally_sprite(pos, value, tooltip, suit) - local text_colour = G.C.BLACK - if type(value) == "table" and value[1].string==value[2].string then - text_colour = value[1].colour or G.C.WHITE - value = value[1].string - end - local deckskin = suit and SMODS.DeckSkins[G.SETTINGS.CUSTOM_DECK.Collabs[suit]] - local palette = deckskin and (deckskin.palette_map and deckskin.palette_map[G.SETTINGS.colour_palettes[suit] or ''] or (deckskin.palettes or {})[1]) - local t_s - if palette and palette.suit_icon and palette.suit_icon.atlas then - local _x = (suit == 'Spades' and 3) or (suit == 'Hearts' and 0) or (suit == 'Clubs' and 2) or (suit == 'Diamonds' and 1) - t_s = Sprite(0,0,0.3,0.3,G.ASSET_ATLAS[palette.suit_icon.atlas or 'ui_1'], (type(palette.suit_icon.pos) == "number" and {x=_x, y=palette.suit_icon.pos}) or palette.suit_icon.pos or {x=_x, y=0}) - elseif suit and (G.SETTINGS.colour_palettes[suit] == 'lc' or G.SETTINGS.colour_palettes[suit] == 'hc') then - t_s = Sprite(0, 0, 0.3, 0.3, - G.ASSET_ATLAS[SMODS.Suits[suit][G.SETTINGS.colour_palettes[suit] == 'hc' and "hc_ui_atlas" or G.SETTINGS.colour_palettes[suit] == 'lc' and "lc_ui_atlas"]] or - G.ASSET_ATLAS[("ui_" .. (G.SETTINGS.colourblind_option and "2" or "1"))], SMODS.Suits[suit].ui_pos) - else - t_s = Sprite(0,0,0.5,0.5, suit and G.ASSET_ATLAS[SMODS.Suits[suit][G.SETTINGS.colourblind_option and "hc_ui_atlas" or "lc_ui_atlas"]] or G.ASSET_ATLAS[("ui_"..(G.SETTINGS.colourblind_option and "2" or "1"))], {x=pos.x or 0, y=pos.y or 0}) - end - t_s.states.drag.can = false - t_s.states.hover.can = false - t_s.states.collide.can = false - return - {n=G.UIT.C, config={align = "cm", padding = 0.07,force_focus = true, focus_args = {type = 'tally_sprite'}, tooltip = {text = tooltip}}, nodes={ - {n=G.UIT.R, config={align = "cm", r = 0.1, padding = 0.04, emboss = 0.05, colour = G.C.JOKER_GREY}, nodes={ - {n=G.UIT.O, config={w=0.5,h=0.5 ,can_collide = false, object = t_s, tooltip = {text = tooltip}}} - }}, - {n=G.UIT.R, config={align = "cm"}, nodes={ - type(value) == "table" and {n=G.UIT.O, config={object = DynaText({string = value, colours = {G.C.RED}, scale = 0.4, silent = true, shadow = true, pop_in_rate = 10, pop_delay = 4})}} or - {n=G.UIT.T, config={text = value or 'NIL',colour = text_colour, scale = 0.4, shadow = true}}, - }}, - }} -end - -function G.UIDEF.view_deck(unplayed_only) - local deck_tables = {} - remove_nils(G.playing_cards) - G.VIEWING_DECK = true - table.sort(G.playing_cards, function(a, b) return a:get_nominal('suit') > b:get_nominal('suit') end) - local SUITS = {} - local suit_map = {} - for i = #SMODS.Suit.obj_buffer, 1, -1 do - SUITS[SMODS.Suit.obj_buffer[i]] = {} - suit_map[#suit_map + 1] = SMODS.Suit.obj_buffer[i] - end - for k, v in ipairs(G.playing_cards) do - if v.base.suit then table.insert(SUITS[v.base.suit], v) end - end - local num_suits = 0 - for j = 1, #suit_map do - if SUITS[suit_map[j]][1] then num_suits = num_suits + 1 end - end - for j = 1, #suit_map do - if SUITS[suit_map[j]][1] then - local view_deck = CardArea( - G.ROOM.T.x + 0.2 * G.ROOM.T.w / 2, G.ROOM.T.h, - 6.5 * G.CARD_W, - ((num_suits > 8) and 0.2 or (num_suits > 4) and (1 - 0.1 * num_suits) or 0.6) * G.CARD_H, - { - card_limit = #SUITS[suit_map[j]], - type = 'title', - view_deck = true, - highlight_limit = 0, - card_w = G - .CARD_W * 0.7, - draw_layers = { 'card' } - }) - table.insert(deck_tables, - {n = G.UIT.R, config = {align = "cm", padding = 0}, nodes = { - {n = G.UIT.O, config = {object = view_deck}}}} - ) - - for i = 1, #SUITS[suit_map[j]] do - if SUITS[suit_map[j]][i] then - local greyed, _scale = nil, 0.7 - if unplayed_only and not ((SUITS[suit_map[j]][i].area and SUITS[suit_map[j]][i].area == G.deck) or SUITS[suit_map[j]][i].ability.wheel_flipped) then - greyed = true - end - local copy = copy_card(SUITS[suit_map[j]][i], nil, _scale) - copy.greyed = greyed - copy.T.x = view_deck.T.x + view_deck.T.w / 2 - copy.T.y = view_deck.T.y - - copy:hard_set_T() - view_deck:emplace(copy) - end - end - end - end - - local flip_col = G.C.WHITE - - local suit_tallies = {} - local mod_suit_tallies = {} - for _, v in ipairs(suit_map) do - suit_tallies[v] = 0 - mod_suit_tallies[v] = 0 - end - local rank_tallies = {} - local mod_rank_tallies = {} - local rank_name_mapping = SMODS.Rank.obj_buffer - for _, v in ipairs(rank_name_mapping) do - rank_tallies[v] = 0 - mod_rank_tallies[v] = 0 - end - local face_tally = 0 - local mod_face_tally = 0 - local num_tally = 0 - local mod_num_tally = 0 - local ace_tally = 0 - local mod_ace_tally = 0 - local wheel_flipped = 0 - - for k, v in ipairs(G.playing_cards) do - if v.ability.name ~= 'Stone Card' and (not unplayed_only or ((v.area and v.area == G.deck) or v.ability.wheel_flipped)) then - if v.ability.wheel_flipped and not (v.area and v.area == G.deck) and unplayed_only then wheel_flipped = wheel_flipped + 1 end - --For the suits - if v.base.suit then suit_tallies[v.base.suit] = (suit_tallies[v.base.suit] or 0) + 1 end - for kk, vv in pairs(mod_suit_tallies) do - mod_suit_tallies[kk] = (vv or 0) + (v:is_suit(kk) and 1 or 0) - end - - --for face cards/numbered cards/aces - local card_id = v:get_id() - if v.base.value then face_tally = face_tally + ((SMODS.Ranks[v.base.value].face) and 1 or 0) end - mod_face_tally = mod_face_tally + (v:is_face() and 1 or 0) - if v.base.value and not SMODS.Ranks[v.base.value].face and card_id ~= 14 then - num_tally = num_tally + 1 - if not v.debuff then mod_num_tally = mod_num_tally + 1 end - end - if card_id == 14 then - ace_tally = ace_tally + 1 - if not v.debuff then mod_ace_tally = mod_ace_tally + 1 end - end - - --ranks - if v.base.value then rank_tallies[v.base.value] = rank_tallies[v.base.value] + 1 end - if v.base.value and not v.debuff then mod_rank_tallies[v.base.value] = mod_rank_tallies[v.base.value] + 1 end - end - end - local modded = face_tally ~= mod_face_tally - for kk, vv in pairs(mod_suit_tallies) do - modded = modded or (vv ~= suit_tallies[kk]) - if modded then break end - end - - if wheel_flipped > 0 then flip_col = mix_colours(G.C.FILTER, G.C.WHITE, 0.7) end - - local rank_cols = {} - for i = #rank_name_mapping, 1, -1 do - if rank_tallies[rank_name_mapping[i]] ~= 0 or not SMODS.Ranks[rank_name_mapping[i]].in_pool or SMODS.Ranks[rank_name_mapping[i]]:in_pool({suit=''}) then - local mod_delta = mod_rank_tallies[rank_name_mapping[i]] ~= rank_tallies[rank_name_mapping[i]] - rank_cols[#rank_cols + 1] = {n = G.UIT.R, config = {align = "cm", padding = 0.07}, nodes = { - {n = G.UIT.C, config = {align = "cm", r = 0.1, padding = 0.04, emboss = 0.04, minw = 0.5, colour = G.C.L_BLACK}, nodes = { - {n = G.UIT.T, config = {text = SMODS.Ranks[rank_name_mapping[i]].shorthand, colour = G.C.JOKER_GREY, scale = 0.35, shadow = true}},}}, - {n = G.UIT.C, config = {align = "cr", minw = 0.4}, nodes = { - mod_delta and {n = G.UIT.O, config = { - object = DynaText({ - string = { { string = '' .. rank_tallies[rank_name_mapping[i]], colour = flip_col }, { string = '' .. mod_rank_tallies[rank_name_mapping[i]], colour = G.C.BLUE } }, - colours = { G.C.RED }, scale = 0.4, y_offset = -2, silent = true, shadow = true, pop_in_rate = 10, pop_delay = 4 - })}} - or {n = G.UIT.T, config = {text = rank_tallies[rank_name_mapping[i]], colour = flip_col, scale = 0.45, shadow = true } },}}}} - end - end - - local tally_ui = { - -- base cards - {n = G.UIT.R, config = {align = "cm", minh = 0.05, padding = 0.07}, nodes = { - {n = G.UIT.O, config = { - object = DynaText({ - string = { - { string = localize('k_base_cards'), colour = G.C.RED }, - modded and { string = localize('k_effective'), colour = G.C.BLUE } or nil - }, - colours = { G.C.RED }, silent = true, scale = 0.4, pop_in_rate = 10, pop_delay = 4 - }) - }}}}, - -- aces, faces and numbered cards - {n = G.UIT.R, config = {align = "cm", minh = 0.05, padding = 0.1}, nodes = { - tally_sprite( - { x = 1, y = 0 }, - { { string = '' .. ace_tally, colour = flip_col }, { string = '' .. mod_ace_tally, colour = G.C.BLUE } }, - { localize('k_aces') } - ), --Aces - tally_sprite( - { x = 2, y = 0 }, - { { string = '' .. face_tally, colour = flip_col }, { string = '' .. mod_face_tally, colour = G.C.BLUE } }, - { localize('k_face_cards') } - ), --Face - tally_sprite( - { x = 3, y = 0 }, - { { string = '' .. num_tally, colour = flip_col }, { string = '' .. mod_num_tally, colour = G.C.BLUE } }, - { localize('k_numbered_cards') } - ), --Numbers - }}, - } - -- add suit tallies - local hidden_suits = {} - for _, suit in ipairs(suit_map) do - if suit_tallies[suit] == 0 and SMODS.Suits[suit].in_pool and not SMODS.Suits[suit]:in_pool({rank=''}) then - hidden_suits[suit] = true - end - end - local i = 1 - local num_suits_shown = 0 - for i = 1, #suit_map do - if not hidden_suits[suit_map[i]] then - num_suits_shown = num_suits_shown+1 - end - end - local suits_per_row = num_suits_shown > 6 and 4 or num_suits_shown > 4 and 3 or 2 - local n_nodes = {} - while i <= #suit_map do - while #n_nodes < suits_per_row and i <= #suit_map do - if not hidden_suits[suit_map[i]] then - table.insert(n_nodes, tally_sprite( - SMODS.Suits[suit_map[i]].ui_pos, - { - { string = '' .. suit_tallies[suit_map[i]], colour = flip_col }, - { string = '' .. mod_suit_tallies[suit_map[i]], colour = G.C.BLUE } - }, - { localize(suit_map[i], 'suits_plural') }, - suit_map[i] - )) - end - i = i + 1 - end - if #n_nodes > 0 then - local n = {n = G.UIT.R, config = {align = "cm", minh = 0.05, padding = 0.1}, nodes = n_nodes} - table.insert(tally_ui, n) - n_nodes = {} - end - end - local t = {n = G.UIT.ROOT, config = {align = "cm", colour = G.C.CLEAR}, nodes = { - {n = G.UIT.R, config = {align = "cm", padding = 0.05}, nodes = {}}, - {n = G.UIT.R, config = {align = "cm"}, nodes = { - {n = G.UIT.C, config = {align = "cm", minw = 1.5, minh = 2, r = 0.1, colour = G.C.BLACK, emboss = 0.05}, nodes = { - {n = G.UIT.C, config = {align = "cm", padding = 0.1}, nodes = { - {n = G.UIT.R, config = {align = "cm", r = 0.1, colour = G.C.L_BLACK, emboss = 0.05, padding = 0.15}, nodes = { - {n = G.UIT.R, config = {align = "cm"}, nodes = { - {n = G.UIT.O, config = { - object = DynaText({ string = G.GAME.selected_back.loc_name, colours = {G.C.WHITE}, bump = true, rotate = true, shadow = true, scale = 0.6 - string.len(G.GAME.selected_back.loc_name) * 0.01 }) - }},}}, - {n = G.UIT.R, config = {align = "cm", r = 0.1, padding = 0.1, minw = 2.5, minh = 1.3, colour = G.C.WHITE, emboss = 0.05}, nodes = { - {n = G.UIT.O, config = { - object = UIBox { - definition = G.GAME.selected_back:generate_UI(nil, 0.7, 0.5, G.GAME.challenge), config = {offset = { x = 0, y = 0 } } - } - }}}}}}, - {n = G.UIT.R, config = {align = "cm", r = 0.1, outline_colour = G.C.L_BLACK, line_emboss = 0.05, outline = 1.5}, nodes = - tally_ui}}}, - {n = G.UIT.C, config = {align = "cm"}, nodes = rank_cols}, - {n = G.UIT.B, config = {w = 0.1, h = 0.1}},}}, - {n = G.UIT.B, config = {w = 0.2, h = 0.1}}, - {n = G.UIT.C, config = {align = "cm", padding = 0.1, r = 0.1, colour = G.C.BLACK, emboss = 0.05}, nodes = - deck_tables}}}, - {n = G.UIT.R, config = {align = "cm", minh = 0.8, padding = 0.05}, nodes = { - modded and {n = G.UIT.R, config = {align = "cm"}, nodes = { - {n = G.UIT.C, config = {padding = 0.3, r = 0.1, colour = mix_colours(G.C.BLUE, G.C.WHITE, 0.7)}, nodes = {}}, - {n = G.UIT.T, config = {text = ' ' .. localize('ph_deck_preview_effective'), colour = G.C.WHITE, scale = 0.3}},}} - or nil, - wheel_flipped > 0 and {n = G.UIT.R, config = {align = "cm"}, nodes = { - {n = G.UIT.C, config = {padding = 0.3, r = 0.1, colour = flip_col}, nodes = {}}, - {n = G.UIT.T, config = { - text = ' ' .. (wheel_flipped > 1 and - localize { type = 'variable', key = 'deck_preview_wheel_plural', vars = { wheel_flipped } } or - localize { type = 'variable', key = 'deck_preview_wheel_singular', vars = { wheel_flipped } }), - colour = G.C.WHITE, scale = 0.3 - }},}} - or nil,}}}} - return t -end - ---#endregion ---#region poker hands -local init_game_object_ref = Game.init_game_object -function Game:init_game_object() - local t = init_game_object_ref(self) - for _, key in ipairs(SMODS.PokerHand.obj_buffer) do - t.hands[key] = {} - for k, v in pairs(SMODS.PokerHands[key]) do - -- G.GAME needs to be able to be serialized - -- TODO this is too specific; ex. nested tables with simple keys - -- are fine. - -- In fact, the check should just warn you if you have a key that - -- can't be serialized. - if type(v) == 'number' or type(v) == 'boolean' or k == 'example' then - t.hands[key][k] = v - end - end - end - return t -end - --- why bother patching when i basically change everything -function G.FUNCS.get_poker_hand_info(_cards) - local poker_hands = evaluate_poker_hand(_cards) - local scoring_hand = {} - local text, disp_text, loc_disp_text = 'NULL', 'NULL', 'NULL' - for _, v in ipairs(G.handlist) do - if next(poker_hands[v]) then - text = v - scoring_hand = poker_hands[v][1] - break - end - end - disp_text = text - local _hand = SMODS.PokerHands[text] - if text == 'Straight Flush' then - local royal = true - for j = 1, #scoring_hand do - local rank = SMODS.Ranks[scoring_hand[j].base.value] - royal = royal and (rank.key == 'Ace' or rank.key == '10' or rank.face) - end - if royal then - disp_text = 'Royal Flush' - end - elseif _hand and _hand.modify_display_text and type(_hand.modify_display_text) == 'function' then - disp_text = _hand:modify_display_text(_cards, scoring_hand) or disp_text - end - loc_disp_text = localize(disp_text, 'poker_hands') - return text, loc_disp_text, poker_hands, scoring_hand, disp_text -end - -function create_UIBox_current_hands(simple) - G.current_hands = {} - local index = 0 - for _, v in ipairs(G.handlist) do - local ui_element = create_UIBox_current_hand_row(v, simple) - G.current_hands[index + 1] = ui_element - if ui_element then - index = index + 1 - end - if index >= 10 then - break - end - end - - local visible_hands = {} - for _, v in ipairs(G.handlist) do - if G.GAME.hands[v].visible then - table.insert(visible_hands, v) - end - end - - local hand_options = {} - for i = 1, math.ceil(#visible_hands / 10) do - table.insert(hand_options, - localize('k_page') .. ' ' .. tostring(i) .. '/' .. tostring(math.ceil(#visible_hands / 10))) - end - - local object = {n = G.UIT.ROOT, config = {align = "cm", colour = G.C.CLEAR}, nodes = { - {n = G.UIT.R, config = {align = "cm", padding = 0.04}, nodes = - G.current_hands}, - {n = G.UIT.R, config = {align = "cm", padding = 0}, nodes = { - create_option_cycle({ - options = hand_options, - w = 4.5, - cycle_shoulders = true, - opt_callback = 'your_hands_page', - focus_args = { snap_to = true, nav = 'wide' }, - current_option = 1, - colour = G.C.RED, - no_pips = true - })}}}} - - local t = {n = G.UIT.ROOT, config = {align = "cm", minw = 3, padding = 0.1, r = 0.1, colour = G.C.CLEAR}, nodes = { - {n = G.UIT.O, config = { - id = 'hand_list', - object = UIBox { - definition = object, config = {offset = { x = 0, y = 0 }, align = 'cm'} - } - }}}} - return t -end - -G.FUNCS.your_hands_page = function(args) - if not args or not args.cycle_config then return end - G.current_hands = {} - - - local index = 0 - for _, v in ipairs(G.handlist) do - local ui_element = create_UIBox_current_hand_row(v, simple) - if index >= (0 + 10 * (args.cycle_config.current_option - 1)) and index < 10 * args.cycle_config.current_option then - G.current_hands[index - (10 * (args.cycle_config.current_option - 1)) + 1] = ui_element - end - - if ui_element then - index = index + 1 - end - - if index >= 10 * args.cycle_config.current_option then - break - end - end - - local visible_hands = {} - for _, v in ipairs(G.handlist) do - if G.GAME.hands[v].visible then - table.insert(visible_hands, v) - end - end - - local hand_options = {} - for i = 1, math.ceil(#visible_hands / 10) do - table.insert(hand_options, - localize('k_page') .. ' ' .. tostring(i) .. '/' .. tostring(math.ceil(#visible_hands / 10))) - end - - local object = {n = G.UIT.ROOT, config = {align = "cm", colour = G.C.CLEAR }, nodes = { - {n = G.UIT.R, config = {align = "cm", padding = 0.04 }, nodes = G.current_hands - }, - {n = G.UIT.R, config = {align = "cm", padding = 0 }, nodes = { - create_option_cycle({ - options = hand_options, - w = 4.5, - cycle_shoulders = true, - opt_callback = - 'your_hands_page', - focus_args = { snap_to = true, nav = 'wide' }, - current_option = args.cycle_config.current_option, - colour = G - .C.RED, - no_pips = true - }) - } - } - } - } - - local hand_list = G.OVERLAY_MENU:get_UIE_by_ID('hand_list') - if hand_list then - if hand_list.config.object then - hand_list.config.object:remove() - end - hand_list.config.object = UIBox { - definition = object, config = {offset = { x = 0, y = 0 }, align = 'cm', parent = hand_list } - } - end -end - -function evaluate_poker_hand(hand) - local results = {} - local parts = {} - for _, v in ipairs(SMODS.PokerHandPart.obj_buffer) do - parts[v] = SMODS.PokerHandParts[v].func(hand) or {} - end - for k, _hand in pairs(SMODS.PokerHands) do - results[k] = _hand.evaluate(parts, hand) or {} - end - for _, v in ipairs(G.handlist) do - if not results.top and results[v] then - results.top = results[v] - break - end - end - return results -end ---#endregion - --- Init custom card parameters. -local card_init = Card.init -function Card:init(X, Y, W, H, card, center, params) - card_init(self, X, Y, W, H, card, center, params) - - -- This table contains object keys for layers (e.g. edition) - -- that dont want base layer to be drawn. - -- When layer is removed, layer's value should be set to nil. - self.ignore_base_shader = self.ignore_base_shader or {} - -- This table contains object keys for layers (e.g. edition) - -- that dont want shadow to be drawn. - -- When layer is removed, layer's value should be set to nil. - self.ignore_shadow = self.ignore_shadow or {} -end - -function Card:should_draw_base_shader() - return not next(self.ignore_base_shader or {}) -end - -function Card:should_draw_shadow() - return not next(self.ignore_shadow or {}) -end - -local smods_card_load = Card.load --- -function Card:load(cardTable, other_card) - local ret = smods_card_load(self, cardTable, other_card) - local on_edition_loaded = self.edition and self.edition.key and G.P_CENTERS[self.edition.key].on_load - if type(on_edition_loaded) == "function" then - on_edition_loaded(self) - end - - return ret -end - --- self = pass the card --- edition = --- nil (removes edition) --- OR key as string --- OR { name_of_edition = true } (key without e_). This is from the base game, prefer using a string. --- OR another card's self.edition table --- immediate = boolean value --- silent = boolean value -function Card:set_edition(edition, immediate, silent) - -- Check to see if negative is being removed and reduce card_limit accordingly - if (self.added_to_deck or self.joker_added_to_deck_but_debuffed or (self.area == G.hand and not self.debuff)) and self.edition and self.edition.card_limit then - if self.ability.consumeable and self.area == G.consumeables then - G.consumeables.config.card_limit = G.consumeables.config.card_limit - self.edition.card_limit - elseif self.ability.set == 'Joker' and self.area == G.jokers then - G.jokers.config.card_limit = G.jokers.config.card_limit - self.edition.card_limit - elseif self.area == G.hand then - G.hand.config.card_limit = G.hand.config.card_limit - self.edition.card_limit - end - end - - local old_edition = self.edition and self.edition.key - if old_edition then - self.ignore_base_shader[old_edition] = nil - self.ignore_shadow[old_edition] = nil - - local on_old_edition_removed = G.P_CENTERS[old_edition] and G.P_CENTERS[old_edition].on_remove - if type(on_old_edition_removed) == "function" then - on_old_edition_removed(self) - end - end - - local edition_type = nil - if type(edition) == 'string' then - assert(string.sub(edition, 1, 2) == 'e_') - edition_type = string.sub(edition, 3) - elseif type(edition) == 'table' then - if edition.type then - edition_type = edition.type - else - for k, v in pairs(edition) do - if v then - assert(not edition_type) - edition_type = k - end - end - end - end - - if not edition_type or edition_type == 'base' then - if self.edition == nil then -- early exit - return - end - self.edition = nil -- remove edition from card - self:set_cost() - if not silent then - G.E_MANAGER:add_event(Event({ - trigger = 'after', - delay = not immediate and 0.2 or 0, - blockable = not immediate, - func = function() - self:juice_up(1, 0.5) - play_sound('whoosh2', 1.2, 0.6) - return true - end - })) - end - return - end - - self.edition = {} - self.edition[edition_type] = true - self.edition.type = edition_type - self.edition.key = 'e_' .. edition_type - - local p_edition = G.P_CENTERS['e_' .. edition_type] - - if p_edition.override_base_shader or p_edition.disable_base_shader then - self.ignore_base_shader[self.edition.key] = true - end - if p_edition.no_shadow or p_edition.disable_shadow then - self.ignore_shadow[self.edition.key] = true - end - - local on_edition_applied = p_edition.on_apply - if type(on_edition_applied) == "function" then - on_edition_applied(self) - end - - for k, v in pairs(p_edition.config) do - if type(v) == 'table' then - self.edition[k] = copy_table(v) - else - self.edition[k] = v - end - if k == 'card_limit' and (self.added_to_deck or self.joker_added_to_deck_but_debuffed or (self.area == G.hand and not self.debuff)) and G.jokers and G.consumeables then - if self.ability.consumeable then - G.consumeables.config.card_limit = G.consumeables.config.card_limit + v - elseif self.ability.set == 'Joker' then - G.jokers.config.card_limit = G.jokers.config.card_limit + v - elseif self.area == G.hand then - local is_in_pack = (G.STATE == G.STATES.TAROT_PACK or G.STATE == G.STATES.SPECTRAL_PACK or (G.STATE == G.STATES.SMODS_BOOSTER_OPENED and SMODS.OPENED_BOOSTER.config.center.draw_hand)) - G.E_MANAGER:add_event(Event({ - trigger = 'immediate', - func = function() - if G.hand.config.real_card_limit then - G.hand.config.real_card_limit = G.hand.config.real_card_limit + v - end - G.hand.config.card_limit = G.hand.config.card_limit + v - if not is_in_pack then - G.FUNCS.draw_from_deck_to_hand(v) - end - return true - end - })) - end - end - end - - if self.area and self.area == G.jokers then - if self.edition then - if not G.P_CENTERS['e_' .. (self.edition.type)].discovered then - discover_card(G.P_CENTERS['e_' .. (self.edition.type)]) - end - else - if not G.P_CENTERS['e_base'].discovered then - discover_card(G.P_CENTERS['e_base']) - end - end - end - - if self.edition and not silent then - local ed = G.P_CENTERS['e_' .. (self.edition.type)] - G.CONTROLLER.locks.edition = true - G.E_MANAGER:add_event(Event({ - trigger = 'after', - delay = not immediate and 0.2 or 0, - blockable = not immediate, - func = function() - if self.edition then - self:juice_up(1, 0.5) - play_sound(ed.sound.sound, ed.sound.per, ed.sound.vol) - end - return true - end - })) - G.E_MANAGER:add_event(Event({ - trigger = 'after', - delay = 0.1, - func = function() - G.CONTROLLER.locks.edition = false - return true - end - })) - end - - if G.jokers and self.area == G.jokers then - check_for_unlock({ type = 'modify_jokers' }) - end - - self:set_cost() -end - --- _key = key value for random seed --- _mod = scale of chance against base card (does not change guaranteed weights) --- _no_neg = boolean value to disable negative edition --- _guaranteed = boolean value to determine whether an edition is guaranteed --- _options = list of keys of editions to include in the poll --- OR list of tables { name = key, weight = number } -function poll_edition(_key, _mod, _no_neg, _guaranteed, _options) - local _modifier = 1 - local edition_poll = pseudorandom(pseudoseed(_key or 'edition_generic')) -- Generate the poll value - local available_editions = {} -- Table containing a list of editions and their weights - - if not _options then - _options = { 'e_negative', 'e_polychrome', 'e_holo', 'e_foil' } - if _key == "wheel_of_fortune" or _key == "aura" then -- set base game edition polling - else - for _, v in ipairs(G.P_CENTER_POOLS.Edition) do - if v.in_shop then - table.insert(_options, v.key) - end - end - end - end - for _, v in ipairs(_options) do - local edition_option = {} - if type(v) == 'string' then - assert(string.sub(v, 1, 2) == 'e_') - edition_option = { name = v, weight = G.P_CENTERS[v].weight } - elseif type(v) == 'table' then - assert(string.sub(v.name, 1, 2) == 'e_') - edition_option = { name = v.name, weight = v.weight } - end - table.insert(available_editions, edition_option) - end - - -- Calculate total weight of editions - local total_weight = 0 - for _, v in ipairs(available_editions) do - total_weight = total_weight + (v.weight) -- total all the weights of the polled editions - end - -- sendDebugMessage("Edition weights: "..total_weight, "EditionAPI") - -- If not guaranteed, calculate the base card rate to maintain base 4% chance of editions - if not _guaranteed then - _modifier = _mod or 1 - total_weight = total_weight + (total_weight / 4 * 96) -- Find total weight with base_card_rate as 96% - for _, v in ipairs(available_editions) do - v.weight = G.P_CENTERS[v.name]:get_weight() -- Apply game modifiers where appropriate (defined in edition declaration) - end - end - -- sendDebugMessage("Total weight: "..total_weight, "EditionAPI") - -- sendDebugMessage("Editions: "..#available_editions, "EditionAPI") - -- sendDebugMessage("Poll: "..edition_poll, "EditionAPI") - - -- Calculate whether edition is selected - local weight_i = 0 - for _, v in ipairs(available_editions) do - weight_i = weight_i + v.weight * _modifier - -- sendDebugMessage(v.name.." weight is "..v.weight*_modifier) - -- sendDebugMessage("Checking for "..v.name.." at "..(1 - (weight_i)/total_weight), "EditionAPI") - if edition_poll > 1 - (weight_i) / total_weight then - if not (v.name == 'e_negative' and _no_neg) then -- skip return if negative is selected and _no_neg is true - -- sendDebugMessage("Matched edition: "..v.name, "EditionAPI") - return v.name - end - end - end - - return nil -end - --- local cge = Card.get_edition --- function Card:get_edition() --- if self.ability.extra_enhancement then return end --- local ret = cge(self) --- if self.edition and self.edition.key then --- local ed = SMODS.Centers[self.edition.key] --- if ed.calculate and type(ed.calculate) == 'function' then --- ed:calculate(self, {edition_main = true, edition_val = ret}) --- end --- end --- return ret --- end - -function get_joker_win_sticker(_center, index) - local joker_usage = G.PROFILES[G.SETTINGS.profile].joker_usage[_center.key] or {} - if joker_usage.wins then - local applied = {} - local _count = 0 - local _stake = nil - for k, v in pairs(joker_usage.wins_by_key) do - SMODS.build_stake_chain(G.P_STAKES[k], applied) - end - for i, v in ipairs(G.P_CENTER_POOLS.Stake) do - if applied[v.order] then - _count = _count+1 - if (v.stake_level or 0) > (_stake and G.P_STAKES[_stake].stake_level or 0) then - _stake = v.key - end - end - end - if index then return _count end - if _count > 0 then return G.sticker_map[_stake] end - end - if index then return 0 end -end - -function get_deck_win_stake(_deck_key) - if not _deck_key then - local _stake, _stake_low = nil, nil - local deck_count = 0 - for _, deck in pairs(G.PROFILES[G.SETTINGS.profile].deck_usage) do - local deck_won_with = false - for key, _ in pairs(deck.wins_by_key or {}) do - deck_won_with = true - if (G.P_STAKES[key] and G.P_STAKES[key].stake_level or 0) > (_stake and G.P_STAKES[_stake].stake_level or 0) then - _stake = key - end - end - if deck_won_with then deck_count = deck_count + 1 end - if not _stake_low then _stake_low = _stake end - if (_stake and G.P_STAKES[_stake] and G.P_STAKES[_stake].stake_level or 0) < (_stake_low and G.P_STAKES[_stake_low].stake_level or 0) then - _stake_low = _stake - end - end - return _stake and G.P_STAKES[_stake].order or 0, (deck_count >= #G.P_CENTER_POOLS.Back and G.P_STAKES[_stake_low].order or 0) - end - if G.PROFILES[G.SETTINGS.profile].deck_usage[_deck_key] and G.PROFILES[G.SETTINGS.profile].deck_usage[_deck_key].wins_by_key then - local _stake = nil - for key, _ in pairs(G.PROFILES[G.SETTINGS.profile].deck_usage[_deck_key].wins_by_key) do - if (G.P_STAKES[key] and G.P_STAKES[key].stake_level or 0) > (_stake and G.P_STAKES[_stake].stake_level or 0) then - _stake = key - end - end - if _stake then return G.P_STAKES[_stake].order end - end - return 0 -end - -function get_deck_win_sticker(_center) - if G.PROFILES[G.SETTINGS.profile].deck_usage[_center.key] and - G.PROFILES[G.SETTINGS.profile].deck_usage[_center.key].wins_by_key then - local _stake = nil - for key, _ in pairs(G.PROFILES[G.SETTINGS.profile].deck_usage[_center.key].wins_by_key) do - if (G.P_STAKES[key] and G.P_STAKES[key].stake_level or 0) > (_stake and G.P_STAKES[_stake].stake_level or 0) then - _stake = key - end - end - if _stake then return G.sticker_map[_stake] end - end -end - -function set_deck_win() - if G.GAME.selected_back and G.GAME.selected_back.effect and G.GAME.selected_back.effect.center and G.GAME.selected_back.effect.center.key then - local deck_key = G.GAME.selected_back.effect.center.key - local deck_usage = G.PROFILES[G.SETTINGS.profile].deck_usage[deck_key] - if not deck_usage then deck_usage = { count = 1, order = - G.GAME.selected_back.effect.center.order, wins = {}, losses = {}, wins_by_key = {}, losses_by_key = {} } end - if deck_usage then - deck_usage.wins[G.GAME.stake] = (deck_usage.wins[G.GAME.stake] or 0) + 1 - deck_usage.wins_by_key[SMODS.stake_from_index(G.GAME.stake)] = (deck_usage.wins_by_key[SMODS.stake_from_index(G.GAME.stake)] or 0) + 1 - local applied = SMODS.build_stake_chain(G.P_STAKES[SMODS.stake_from_index(G.GAME.stake)]) or {} - for i, v in ipairs(G.P_CENTER_POOLS.Stake) do - if applied[i] then - deck_usage.wins[i] = math.max(deck_usage.wins[i] or 0, 1) - deck_usage.wins_by_key[SMODS.stake_from_index(i)] = math.max(deck_usage.wins_by_key[SMODS.stake_from_index(i)] or 0, 1) - end - end - end - set_challenge_unlock() - G:save_settings() - G.PROFILES[G.SETTINGS.profile].deck_usage[deck_key] = deck_usage - end -end - -function Card:align_h_popup() - local focused_ui = self.children.focused_ui and true or false - local popup_direction = (self.children.buy_button or (self.area and self.area.config.view_deck) or (self.area and self.area.config.type == 'shop')) and 'cl' or - (self.T.y < G.CARD_H*0.8) and 'bm' or - 'tm' - local sign = 1 - if popup_direction == 'cl' and self.T.x <= G.ROOM.T.w*0.4 then - popup_direction = 'cr' - sign = -1 - end - return { - major = self.children.focused_ui or self, - parent = self, - xy_bond = 'Strong', - r_bond = 'Weak', - wh_bond = 'Weak', - offset = { - x = popup_direction ~= 'cl' and popup_direction ~= 'cr' and 0 or - focused_ui and sign*-0.05 or - (self.ability.consumeable and 0.0) or - (self.ability.set == 'Voucher' and 0.0) or - sign*-0.05, - y = focused_ui and ( - popup_direction == 'tm' and (self.area and self.area == G.hand and -0.08 or-0.15) or - popup_direction == 'bm' and 0.12 or - 0 - ) or - popup_direction == 'tm' and -0.13 or - popup_direction == 'bm' and 0.1 or - 0 - }, - type = popup_direction, - --lr_clamp = true - } -end - -function get_pack(_key, _type) - if not G.GAME.first_shop_buffoon and not G.GAME.banned_keys['p_buffoon_normal_1'] then - G.GAME.first_shop_buffoon = true - return G.P_CENTERS['p_buffoon_normal_'..(math.random(1, 2))] - end - local cume, it, center = 0, 0, nil - local temp_in_pool = {} - for k, v in ipairs(G.P_CENTER_POOLS['Booster']) do - local add - v.current_weight = v.get_weight and v:get_weight() or v.weight or 1 - if (not _type or _type == v.kind) then add = true end - if v.in_pool and type(v.in_pool) == 'function' then - local res, pool_opts = v:in_pool() - pool_opts = pool_opts or {} - add = res and (add or pool_opts.override_base_checks) - end - if add and not G.GAME.banned_keys[v.key] then cume = cume + (v.current_weight or 1); temp_in_pool[v.key] = true end - end - local poll = pseudorandom(pseudoseed((_key or 'pack_generic')..G.GAME.round_resets.ante))*cume - for k, v in ipairs(G.P_CENTER_POOLS['Booster']) do - if temp_in_pool[v.key] then - it = it + (v.current_weight or 1) - if it >= poll and it - (v.current_weight or 1) <= poll then center = v; break end - end - end - if not center then center = G.P_CENTERS['p_buffoon_normal_1'] end return center -end - ---#region quantum enhancements API --- prevent base chips from applying with extra enhancements -local gcb = Card.get_chip_bonus -function Card:get_chip_bonus() - if not self.ability.extra_enhancement then - return gcb(self) - end - if self.debuff then return 0 end - return self.ability.bonus + (self.ability.perma_bonus or 0) -end - --- prevent quantum enhacements from applying seal effects -local ccs = Card.calculate_seal -function Card:calculate_seal(context) - if self.ability.extra_enhancement then return end - return ccs(self, context) -end ---#endregion - -function playing_card_joker_effects(cards) - SMODS.calculate_context({playing_card_added = true, cards = cards}) -end - -G.FUNCS.change_collab = function(args) - G.SETTINGS.CUSTOM_DECK.Collabs[args.cycle_config.curr_suit] = G.COLLABS.options[args.cycle_config.curr_suit][args.to_key] or 'default' - local deckskin_key = G.COLLABS.options[args.cycle_config.curr_suit][args.to_key] - local palette_loc_options = SMODS.DeckSkin.get_palette_loc_options(args.to_key, args.cycle_config.curr_suit) - local swap_node = G.OVERLAY_MENU:get_UIE_by_ID('palette_selector') - local selected_palette = 1 - for i, v in ipairs(G.COLLABS.colour_palettes[deckskin_key]) do - if G.SETTINGS.colour_palettes[args.cycle_config.curr_suit] == v then - selected_palette = i - end - end - G.FUNCS.update_suit_colours(args.cycle_config.curr_suit, deckskin_key, selected_palette) - G.FUNCS.update_collab_cards(args.to_key, args.cycle_config.curr_suit) - if swap_node then - for i=1, #swap_node.children do - swap_node.children[i]:remove() - swap_node.children[i] = nil - end - local new_palette_selector = {n=G.UIT.R, config={align = "cm", id = 'palette_selector'}, nodes={ - create_option_cycle({options = palette_loc_options, w = 5.5, cycle_shoulders = false, curr_suit = args.cycle_config.curr_suit, curr_skin = deckskin_key, opt_callback = 'change_colour_palette', current_option = selected_palette, colour = G.C.ORANGE, focus_args = {snap_to = true, nav = 'wide'}}), - }} - swap_node.UIBox:add_child(new_palette_selector, swap_node) - end - for k, v in pairs(G.I.CARD) do - if v.config and v.config.card and v.children.front and v.ability.effect ~= 'Stone Card' then - v:set_sprites(nil, v.config.card) - end - end - G:save_settings() -end - -G.FUNCS.change_colour_palette = function(args) - G.SETTINGS.colour_palettes[args.cycle_config.curr_suit] = G.COLLABS.colour_palettes[args.cycle_config.curr_skin][args.to_key] - G.FUNCS.update_suit_colours(args.cycle_config.curr_suit, args.cycle_config.curr_skin) - G.FUNCS.update_collab_cards(args.cycle_config.curr_skin, args.cycle_config.curr_suit) - for k, v in pairs(G.I.CARD) do - if v.config and v.config.card and v.children.front and v.ability.effect ~= 'Stone Card' then - v:set_sprites(nil, v.config.card) - end - end - G:save_settings() -end \ No newline at end of file diff --git a/smods-main/src/ui.lua b/smods-main/src/ui.lua deleted file mode 100644 index 0490272..0000000 --- a/smods-main/src/ui.lua +++ /dev/null @@ -1,1821 +0,0 @@ -SMODS.GUI = {} -SMODS.GUI.DynamicUIManager = {} - -function STR_UNPACK(str) - local chunk, err = loadstring(str) - if chunk then - setfenv(chunk, {}) -- Use an empty environment to prevent access to potentially harmful functions - local success, result = pcall(chunk) - if success then - return result - else - print("Error unpacking string: " .. result) - return nil - end - else - print("Error loading string: " .. err) - return nil - end -end - - -local gameMainMenuRef = Game.main_menu -function Game:main_menu(change_context) - for k, v in pairs(G.C.SUITS) do - G.FUNCS.update_suit_colours(k, G.SETTINGS.CUSTOM_DECK.Collabs[k]) - end - gameMainMenuRef(self, change_context) - UIBox({ - definition = { - n = G.UIT.ROOT, - config = { - align = "cm", - colour = G.C.UI.TRANSPARENT_DARK - }, - nodes = { - { - n = G.UIT.T, - config = { - scale = 0.3, - text = MODDED_VERSION, - colour = G.C.UI.TEXT_LIGHT - } - } - } - }, - config = { - align = "tri", - bond = "Weak", - offset = { - x = 0, - y = 0.3 - }, - major = G.ROOM_ATTACH - } - }) -end - -local gameUpdateRef = Game.update -function Game:update(dt) - if G.STATE ~= G.STATES.SPLASH and G.MAIN_MENU_UI then - local node = G.MAIN_MENU_UI:get_UIE_by_ID("main_menu_play") - - if node and not node.children.alert then - node.children.alert = UIBox({ - definition = create_UIBox_card_alert({ - text = localize('b_modded_version'), - no_bg = true, - scale = 0.4, - text_rot = -0.2 - }), - config = { - align = "tli", - offset = { - x = -0.1, - y = 0 - }, - major = node, - parent = node - } - }) - node.children.alert.states.collide.can = false - end - end - gameUpdateRef(self, dt) -end - -local function wrapText(text, maxChars) - local wrappedText = "" - local currentLineLength = 0 - - for word in text:gmatch("%S+") do - if currentLineLength + #word <= maxChars then - wrappedText = wrappedText .. word .. ' ' - currentLineLength = currentLineLength + #word + 1 - else - wrappedText = wrappedText .. '\n' .. word .. ' ' - currentLineLength = #word + 1 - end - end - - return wrappedText -end - --- Helper function to concatenate author names -local function concatAuthors(authors) - if type(authors) == "table" then - return table.concat(authors, ", ") - end - return authors or localize('b_unknown') -end - - -SMODS.LAST_SELECTED_MOD_TAB = "mod_desc" -function create_UIBox_mods(args) - local mod = G.ACTIVE_MOD_UI - if not SMODS.LAST_SELECTED_MOD_TAB then SMODS.LAST_SELECTED_MOD_TAB = "mod_desc" end - - local mod_tabs = {} - table.insert(mod_tabs, buildModDescTab(mod)) - local additions_tab = buildAdditionsTab(mod) - if additions_tab then table.insert(mod_tabs, additions_tab) end - local credits_func = mod.credits_tab - if credits_func and type(credits_func) == 'function' then - table.insert(mod_tabs, { - label = localize("b_credits"), - chosen = SMODS.LAST_SELECTED_MOD_TAB == "credits" or false, - tab_definition_function = function(...) - SMODS.LAST_SELECTED_MOD_TAB = "credits" - return credits_func(...) - end - }) - end - local config_func = mod.config_tab - if config_func and type(config_func) == 'function' then - table.insert(mod_tabs, { - label = localize("b_config"), - chosen = SMODS.LAST_SELECTED_MOD_TAB == "config" or false, - tab_definition_function = function(...) - SMODS.LAST_SELECTED_MOD_TAB = "config" - return config_func(...) - end - }) - end - - local mod_has_achievement - for _, v in pairs(SMODS.Achievements) do - if v.mod.id == mod.id then mod_has_achievement = true end - end - if mod_has_achievement then table.insert(mod_tabs, - { - label = localize("b_achievements"), - chosen = SMODS.LAST_SELECTED_MOD_TAB == "achievements" or false, - tab_definition_function = function() - SMODS.LAST_SELECTED_MOD_TAB = "achievements" - return buildAchievementsTab(mod) - end - }) - end - - local custom_ui_func = mod.extra_tabs - if custom_ui_func and type(custom_ui_func) == 'function' then - local custom_tabs = custom_ui_func() - if next(custom_tabs) and #custom_tabs == 0 then custom_tabs = { custom_tabs } end - for i, v in ipairs(custom_tabs) do - local id = mod.id..'_'..i - v.chosen = (SMODS.LAST_SELECTED_MOD_TAB == id) or false - v.label = v.label or '' - local def = v.tab_definition_function - assert(def, ('Custom defined mod tab with label "%s" from mod with id %s is missing definition function'):format(v.label, mod.id)) - v.tab_definition_function = function(...) - SMODS.LAST_SELECTED_MOD_TAB = id - return def(...) - end - table.insert(mod_tabs, v) - end - end - - return (create_UIBox_generic_options({ - back_func = "mods_button", - contents = { - { - n = G.UIT.R, - config = { - padding = 0, - align = "tm" - }, - nodes = { - create_tabs({ - snap_to_nav = true, - colour = G.C.BOOSTER, - tabs = mod_tabs - }) - } - } - } - })) -end - -function buildModDescTab(mod) - G.E_MANAGER:add_event(Event({ - blockable = false, - func = function() - G.REFRESH_ALERTS = nil - return true - end - })) - local label = mod.name - if (G.localization.descriptions.Mod or {})[mod.id] then - label = localize { type = 'name_text', set = 'Mod', key = mod.id } - end - return { - label = label, - chosen = SMODS.LAST_SELECTED_MOD_TAB == "mod_desc" or false, - tab_definition_function = function() - local modNodes = {} - local scale = 0.75 -- Scale factor for text - local maxCharsPerLine = 50 - - local wrappedDescription = wrapText(mod.description or '', maxCharsPerLine) - - local authors = localize('b_author' .. (#mod.author > 1 and 's' or '')) .. ': ' .. concatAuthors(mod.author) - - -- Authors names in blue - table.insert(modNodes, { - n = G.UIT.R, - config = { - padding = 0, - align = "cm", - r = 0.1, - emboss = 0.1, - outline = 1, - padding = 0.07 - }, - nodes = { - { - n = G.UIT.T, - config = { - text = authors, - shadow = true, - scale = scale * 0.65, - colour = G.C.BLUE, - } - } - } - }) - - -- Mod description - if (G.localization.descriptions.Mod or {})[mod.id] then - modNodes[#modNodes + 1] = {} - local loc_vars = mod.description_loc_vars and mod:description_loc_vars() or {} - localize { type = 'descriptions', key = loc_vars.key or mod.id, set = 'Mod', nodes = modNodes[#modNodes], vars = loc_vars.vars, scale = loc_vars.scale, text_colour = loc_vars.text_colour, shadow = loc_vars.shadow } - modNodes[#modNodes] = desc_from_rows(modNodes[#modNodes]) - modNodes[#modNodes].config.colour = loc_vars.background_colour or modNodes[#modNodes].config.colour - else - table.insert(modNodes, { - n = G.UIT.R, - config = { - padding = 0.2, - align = "cm" - }, - nodes = { - { - n = G.UIT.T, - config = { - text = wrappedDescription, - shadow = true, - scale = scale * 0.5, - colour = G.C.UI.TEXT_LIGHT - } - } - } - }) - end - - local custom_ui_func = mod.custom_ui - if custom_ui_func and type(custom_ui_func) == 'function' then - custom_ui_func(modNodes) - end - - return { - n = G.UIT.ROOT, - config = { - emboss = 0.05, - minh = 6, - r = 0.1, - minw = 6, - align = "tm", - padding = 0.2, - colour = G.C.BLACK - }, - nodes = modNodes - } - end - } -end - -function buildAdditionsTab(mod) - local consumable_nodes = {} - for _, key in ipairs(SMODS.ConsumableType.ctype_buffer) do - local id = 'your_collection_'..key:lower()..'s' - local tally = modsCollectionTally(G.P_CENTER_POOLS[key]) - if tally.of > 0 then - consumable_nodes[#consumable_nodes+1] = UIBox_button({button = id, label = {localize('b_'..key:lower()..'_cards')}, count = tally, minw = 4, id = id, colour = G.C.SECONDARY_SET[key]}) - end - end - if #consumable_nodes > 3 then - consumable_nodes = { UIBox_button({ button = 'your_collection_consumables', label = {localize('b_stat_consumables'), localize{ type = 'variable', key = 'c_types', vars = {#consumable_nodes} } }, count = modsCollectionTally(G.P_CENTER_POOLS.Consumeables), minw = 4, minh = 4, id = 'your_collection_consumables', colour = G.C.FILTER }) } - end - - local leftside_nodes = {} - for _, v in ipairs { { k = 'Joker', minh = 1.7, scale = 0.6 }, { k = 'Back', b = 'decks' }, { k = 'Voucher' } } do - v.b = v.b or v.k:lower()..'s' - v.l = v.l or v.b - local tally = modsCollectionTally(G.P_CENTER_POOLS[v.k]) - if tally.of > 0 then - leftside_nodes[#leftside_nodes+1] = UIBox_button({button = 'your_collection_'..v.b, label = {localize('b_'..v.l)}, count = modsCollectionTally(G.P_CENTER_POOLS[v.k]), minw = 5, minh = v.minh, scale = v.scale, id = 'your_collection_'..v.b}) - end - end - if #consumable_nodes > 0 then - leftside_nodes[#leftside_nodes + 1] = { - n = G.UIT.R, - config = { align = "cm", padding = 0.1, r = 0.2, colour = G.C.BLACK }, - nodes = { - { - n = G.UIT.C, - config = { align = "cm", maxh = 2.9 }, - nodes = { - { n = G.UIT.T, config = { text = localize('k_cap_consumables'), scale = 0.45, colour = G.C.L_BLACK, vert = true, maxh = 2.2 } }, - } - }, - { n = G.UIT.C, config = { align = "cm", padding = 0.15 }, nodes = consumable_nodes } - } - } - end - - local rightside_nodes = {} - for _, v in ipairs { { k = 'Enhanced', b = 'enhancements', l = 'enhanced_cards'}, { k = 'Seal' }, { k = 'Edition' }, { k = 'Booster', l = 'booster_packs' }, { b = 'tags', p = G.P_TAGS }, { b = 'blinds', p = G.P_BLINDS, minh = 2.0 }, } do - v.b = v.b or v.k:lower()..'s' - v.l = v.l or v.b - v.p = v.p or G.P_CENTER_POOLS[v.k] - local tally = modsCollectionTally(v.p) - if tally.of > 0 then - rightside_nodes[#rightside_nodes+1] = UIBox_button({button = 'your_collection_'..v.b, label = {localize('b_'..v.l)}, count = modsCollectionTally(v.p), minw = 5, minh = v.minh, id = 'your_collection_'..v.b}) - end - end - local has_other_gameobjects = create_UIBox_Other_GameObjects() - if has_other_gameobjects then - rightside_nodes[#rightside_nodes+1] = UIBox_button({button = 'your_collection_other_gameobjects', label = {localize('k_other')}, minw = 5, id = 'your_collection_other_gameobjects', focus_args = {snap_to = true}}) - end - - local t = {n=G.UIT.R, config={align = "cm",padding = 0.2, minw = 7}, nodes={ - {n=G.UIT.C, config={align = "cm", padding = 0.15}, nodes = leftside_nodes }, - {n=G.UIT.C, config={align = "cm", padding = 0.15}, nodes = rightside_nodes } - }} - - local modNodes = {} - table.insert(modNodes, t) - return (#leftside_nodes > 0 or #rightside_nodes > 0 ) and { - label = localize("b_additions"), - chosen = SMODS.LAST_SELECTED_MOD_TAB == "additions" or false, - tab_definition_function = function() - SMODS.LAST_SELECTED_MOD_TAB = "additions" - return { - n = G.UIT.ROOT, - config = { - emboss = 0.05, - minh = 6, - r = 0.1, - minw = 6, - align = "tm", - padding = 0.2, - colour = G.C.BLACK - }, - nodes = modNodes - } - end - } or nil -end - --- Disable alerts when in Additions tab -local set_alerts_ref = set_alerts -function set_alerts() - if G.ACTIVE_MOD_UI then - else - set_alerts_ref() - end -end - -G.FUNCS.your_collection_other_gameobjects = function(e) - G.SETTINGS.paused = true - G.FUNCS.overlay_menu{ - definition = create_UIBox_Other_GameObjects(), - } -end - -function create_UIBox_Other_GameObjects() - local custom_gameobject_tabs = {{}} - local curr_height = 0 - local curr_col = 1 - local other_collections_tabs = {} - local smods_uibox_buttons = { - { - count = G.ACTIVE_MOD_UI and modsCollectionTally(SMODS.Stickers), --Returns nil outside of G.ACTIVE_MOD_UI but we don't use it anyways - button = UIBox_button({button = 'your_collection_stickers', label = {localize('b_stickers')}, count = G.ACTIVE_MOD_UI and modsCollectionTally(SMODS.Stickers), minw = 5, id = 'your_collection_stickers'}) - } - } - - if G.ACTIVE_MOD_UI then - for _, tab in pairs(smods_uibox_buttons) do - if tab.count.of > 0 then other_collections_tabs[#other_collections_tabs+1] = tab.button end - end - if G.ACTIVE_MOD_UI and G.ACTIVE_MOD_UI.custom_collection_tabs then - object_tabs = G.ACTIVE_MOD_UI.custom_collection_tabs() - for _, tab in ipairs(object_tabs) do - other_collections_tabs[#other_collections_tabs+1] = tab - end - end - else - for _, tab in pairs(smods_uibox_buttons) do - other_collections_tabs[#other_collections_tabs+1] = tab.button - end - for _, mod in pairs(SMODS.Mods) do - if mod.custom_collection_tabs and type(mod.custom_collection_tabs) == "function" then - object_tabs = mod.custom_collection_tabs() - for _, tab in ipairs(object_tabs) do - other_collections_tabs[#other_collections_tabs+1] = tab - end - end - end - end - - local custom_gameobject_rows = {} - if #other_collections_tabs > 0 then - for _, gameobject_tabs in ipairs(other_collections_tabs) do - table.insert(custom_gameobject_tabs[curr_col], gameobject_tabs) - curr_height = curr_height + gameobject_tabs.nodes[1].config.minh - if curr_height > 6 then --TODO: Verify that this is the ideal number - curr_height = 0 - curr_col = curr_col + 1 - custom_gameobject_tabs[curr_col] = {} - end - end - for _, v in ipairs(custom_gameobject_tabs) do - table.insert(custom_gameobject_rows, {n=G.UIT.C, config={align = "cm", padding = 0.15}, nodes = v}) - end - - local t = {n=G.UIT.C, config={align = "cm", r = 0.1, colour = G.C.BLACK, padding = 0.1, emboss = 0.05, minw = 7}, nodes={ - {n=G.UIT.R, config={align = "cm", padding = 0.15}, nodes = custom_gameobject_rows} - }} - - return create_UIBox_generic_options({ back_func = G.ACTIVE_MOD_UI and "openModUI_"..G.ACTIVE_MOD_UI.id or 'your_collection', contents = {t}}) - else - return nil - end -end - -G.FUNCS.your_collection_consumables = function(e) - G.SETTINGS.paused = true - G.FUNCS.overlay_menu{ - definition = create_UIBox_your_collection_consumables(), - } -end - -function create_UIBox_your_collection_consumables() - local t = create_UIBox_generic_options({ back_func = G.ACTIVE_MOD_UI and "openModUI_"..G.ACTIVE_MOD_UI.id or 'your_collection', contents = { - { n = G.UIT.C, config = { align = 'cm', minw = 11.5, minh = 6 }, nodes = { - { n = G.UIT.O, config = { id = 'consumable_collection', object = Moveable() },} - }}, - }}) - G.E_MANAGER:add_event(Event({func = function() - G.FUNCS.your_collection_consumables_page({ cycle_config = { current_option = 1 }}) - return true - end})) - return t -end - -G.FUNCS.your_collection_consumables_page = function(args) - if not args or not args.cycle_config then return end - if G.OVERLAY_MENU then - local uie = G.OVERLAY_MENU:get_UIE_by_ID('consumable_collection') - if uie then - if uie.config.object then - uie.config.object:remove() - end - uie.config.object = UIBox{ - definition = G.UIDEF.consumable_collection_page(args.cycle_config.current_option), - config = { align = 'cm', parent = uie} - } - end - end -end - -G.UIDEF.consumable_collection_page = function(page) - local nodes_per_page = 10 - local page_offset = nodes_per_page * ((page or 1) - 1) - local type_buf = {} - if G.ACTIVE_MOD_UI then - for _, v in ipairs(SMODS.ConsumableType.ctype_buffer) do - if modsCollectionTally(G.P_CENTER_POOLS[v]).of > 0 then type_buf[#type_buf + 1] = v end - end - else - type_buf = SMODS.ConsumableType.ctype_buffer - end - local center_options = {} - for i = 1, math.ceil(#type_buf / nodes_per_page) do - table.insert(center_options, - localize('k_page') .. - ' ' .. tostring(i) .. '/' .. tostring(math.ceil(#type_buf / nodes_per_page))) - end - local option_nodes = { create_option_cycle({ - options = center_options, - w = 4.5, - cycle_shoulders = true, - opt_callback = 'your_collection_consumables_page', - focus_args = { snap_to = true, nav = 'wide' }, - current_option = page or 1, - colour = G.C.RED, - no_pips = true - }) } - local function create_consumable_nodes(_start, _end) - local t = {} - for i = _start, _end do - local key = type_buf[i] - if not key then - if i == _start then break end - t[#t+1] = { n = G.UIT.R, config = { align ='cm', minh = 0.81 }, nodes = {}} - else - local id = 'your_collection_'..key:lower()..'s' - t[#t+1] = UIBox_button({button = id, label = {localize('b_'..key:lower()..'_cards')}, count = G.ACTIVE_MOD_UI and modsCollectionTally(G.P_CENTER_POOLS[key]) or G.DISCOVER_TALLIES[key:lower()..'s'], minw = 4, id = id, colour = G.C.SECONDARY_SET[key]}) - end - end - return t - end - - local t = { n = G.UIT.C, config = { align = 'cm' }, nodes = { - {n=G.UIT.R, config = {align="cm"}, nodes = { - {n=G.UIT.C, config={align = "tm", padding = 0.15}, nodes= create_consumable_nodes(page_offset + 1, page_offset + math.ceil(nodes_per_page/2))}, - {n=G.UIT.C, config={align = "tm", padding = 0.15}, nodes= create_consumable_nodes(page_offset+1+math.ceil(nodes_per_page/2), page_offset + nodes_per_page)}, - }}, - {n=G.UIT.R, config = {align="cm"}, nodes = option_nodes}, - }} - return t -end - -function buildAchievementsTab(mod, current_page) - current_page = current_page or 1 - fetch_achievements() - local achievement_matrix = {{},{}} - local achievements_per_row = 3 - local achievements_pool = {} - for k, v in pairs(G.ACHIEVEMENTS) do - if v.mod and v.mod.id == mod.id then achievements_pool[#achievements_pool+1] = v end - end - - local achievement_tab = {} - for k, v in pairs(achievements_pool) do - achievement_tab[#achievement_tab+1] = v - end - - table.sort(achievement_tab, function(a, b) return (a.order or 1) < (b.order or 1) end) - - local row = 1 - local max_lines = 2 - for i = 1, achievements_per_row*2 do - local v = achievement_tab[i+((achievements_per_row*2)*(current_page-1))] - if not v then break end - local temp_achievement = Sprite(0,0,1.1,1.1,G.ASSET_ATLAS[v.atlas or "achievements"], v.earned and v.pos or {x=0, y=0}) - temp_achievement:define_draw_steps({ - {shader = 'dissolve', shadow_height = 0.05}, - {shader = 'dissolve'} - }) - if i == 1 then - G.E_MANAGER:add_event(Event({ - trigger = 'immediate', - func = (function() - G.CONTROLLER:snap_to{node = temp_achievement} - return true - end) - })) - end - temp_achievement.float = true - temp_achievement.states.hover.can = true - temp_achievement.states.drag.can = false - temp_achievement.states.collide.can = true - --temp_achievement.config = {blind = v, force_focus = true} - temp_achievement.hover = function() - if not G.CONTROLLER.dragging.target or G.CONTROLLER.using_touch then - if not temp_achievement.hovering and temp_achievement.states.visible then - temp_achievement.hovering = true - temp_achievement.hover_tilt = 3 - temp_achievement:juice_up(0.05, 0.02) - play_sound('chips1', math.random()*0.1 + 0.55, 0.12) - Node.hover(temp_achievement) - if temp_achievement.children.alert then - temp_achievement.children.alert:remove() - temp_achievement.children.alert = nil - v.alerted = true - G:save_progress() - end - end - end - temp_achievement.stop_hover = function() temp_achievement.hovering = false; Node.stop_hover(temp_achievement); temp_achievement.hover_tilt = 0 end - end - - -- Description - local achievement_text = {} - local maxCharsPerLine = 30 - local function wrapText(text, maxChars) - local wrappedText = {""} - local curr_line = 1 - local currentLineLength = 0 - - for word in text:gmatch("%S+") do - if currentLineLength + #word <= maxChars then - wrappedText[curr_line] = wrappedText[curr_line] .. word .. ' ' - currentLineLength = currentLineLength + #word + 1 - else - wrappedText[curr_line] = string.sub(wrappedText[curr_line], 0, -2) - curr_line = curr_line + 1 - wrappedText[curr_line] = "" - wrappedText[curr_line] = wrappedText[curr_line] .. word .. ' ' - currentLineLength = #word + 1 - end - end - - wrappedText[curr_line] = string.sub(wrappedText[curr_line], 0, -2) - return wrappedText - end - - local loc_target = (v.hidden_text and not v.earned) and {localize("hidden_achievement", 'achievement_descriptions')} or wrapText(localize(v.key, 'achievement_descriptions'), maxCharsPerLine) - local loc_name = (v.hidden_name and not v.earned) and localize("hidden_achievement", 'achievement_names') or localize(v.key, 'achievement_names') - - local ability_text = {} - if loc_target then - for k, v in ipairs(loc_target) do - ability_text[#ability_text + 1] = {n=G.UIT.R, config={align = "cm"}, nodes={{n=G.UIT.T, config={text = v, scale = 0.35, shadow = true, colour = G.C.WHITE}}}} - end - end - max_lines = math.max(max_lines, #ability_text) - achievement_text[#achievement_text + 1] = - {n=G.UIT.R, config={align = "cm", emboss = 0.05, r = 0.1, minw = 4, maxw = 4, padding = 0.05, colour = G.C.WHITE, minh = 0.4*max_lines+0.1}, nodes={ - ability_text[1] and {n=G.UIT.R, config={align = "cm", padding = 0.08, colour = G.C.GREY, r = 0.1, emboss = 0.05, minw = 3.9, maxw = 3.9, minh = 0.4*max_lines}, nodes=ability_text} or nil - }} - - table.insert(achievement_matrix[row], { - n = G.UIT.C, - config = { align = "cm", padding = 0.1 }, - nodes = { - {n=G.UIT.R, config = {align = "cm"}, nodes = { - {n=G.UIT.R, config = {align = "cm", padding = 0.1}, nodes = {{ n = G.UIT.O, config = { object = temp_achievement, focus_with_object = true }}}}, - { - n=G.UIT.R, config = {align = "cm", minw = 4, maxw = 4, padding = 0.05}, nodes = { - {n=G.UIT.R, config={align = "cm", emboss = 0.05, r = 0.1, padding = 0.1, minh = 0.6, colour = G.C.GREY}, nodes={ - {n=G.UIT.O, config={align = "cm", maxw = 3.8, object = DynaText({string = loc_name, maxw = 3.8, colours = {G.C.UI.TEXT_LIGHT}, shadow = true, spacing = 1, bump = true, scale = 0.4})}}, - }}, - {n=G.UIT.R, config={align = "cm"}, nodes=achievement_text}, - }, - }, - }}, - }, - }) - if #achievement_matrix[row] == achievements_per_row then - row = row + 1 - achievement_matrix[row] = {} - max_lines = 2 - end - end - - local achievements_options = {} - for i = 1, math.ceil(#achievements_pool/(2*achievements_per_row)) do - table.insert(achievements_options, localize('k_page')..' '..tostring(i)..'/'..tostring(math.ceil(#achievements_pool/(2*achievements_per_row)))) - end - - local t = { - {n=G.UIT.C, config={}, nodes={ - {n=G.UIT.C, config={align = "cm"}, nodes={ - {n=G.UIT.R, config={align = "cm"}, nodes={ - {n=G.UIT.R, config={align = "cm", padding = 0.1 }, nodes=achievement_matrix[1]}, - {n=G.UIT.R, config={align = "cm", padding = 0.1 }, nodes=achievement_matrix[2]}, - create_option_cycle({options = achievements_options, w = 4.5, cycle_shoulders = true, opt_callback = 'achievments_tab_page', focus_args = {snap_to = true, nav = 'wide'},current_option = current_page, colour = G.C.RED, no_pips = true}) - }} - }} - }}} - return { - n = G.UIT.ROOT, - config = { - emboss = 0.05, - minh = 6, - r = 0.1, - minw = 6, - align = "tm", - padding = 0.2, - colour = G.C.BLACK - }, - nodes = t - } -end - -G.FUNCS.achievments_tab_page = function(args) - if not args or not args.cycle_config then return end - achievement_matrix = {{},{}} - - local tab_contents = G.OVERLAY_MENU:get_UIE_by_ID('tab_contents') - tab_contents.config.object:remove() - tab_contents.config.object = UIBox{ - definition = buildAchievementsTab(G.ACTIVE_MOD_UI, args.cycle_config.current_option), - config = {offset = {x=0,y=0}, parent = tab_contents, type = 'cm'} - } - tab_contents.UIBox:recalculate() -end - --- TODO: Optimize this. -function modsCollectionTally(pool, set) - local set = set or nil - local obj_tally = {tally = 0, of = 0} - - for _, v in pairs(pool) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id and not v.no_collection then - if set then - if v.set and v.set == set then - obj_tally.of = obj_tally.of+1 - if v.discovered then - obj_tally.tally = obj_tally.tally+1 - end - end - else - obj_tally.of = obj_tally.of+1 - if v.discovered then - obj_tally.tally = obj_tally.tally+1 - end - end - end - end - - return obj_tally -end - --- TODO: Make better solution -local UIBox_button_ref = UIBox_button -function UIBox_button(args) - local button = UIBox_button_ref(args) - button.nodes[1].config.count = args.count - return button -end - -function buildModtag(mod) - local tag_pos, tag_message, tag_atlas = { x = 0, y = 0 }, "load_success", mod.prefix and mod.prefix .. '_modicon' or 'modicon' - local specific_vars = {} - - if not mod.can_load then - tag_message = "load_failure" - tag_atlas = "mod_tags" - specific_vars = {} - if next(mod.load_issues.dependencies) then - tag_message = tag_message..'_d' - table.insert(specific_vars, concatAuthors(mod.load_issues.dependencies)) - end - if next(mod.load_issues.conflicts) then - tag_message = tag_message .. '_c' - table.insert(specific_vars, concatAuthors(mod.load_issues.conflicts)) - end - if mod.load_issues.outdated then tag_message = 'load_failure_o' end - if mod.load_issues.version_mismatch then - tag_message = 'load_failure_i' - specific_vars = {mod.load_issues.version_mismatch, MODDED_VERSION:gsub('-STEAMODDED', '')} - end - if mod.load_issues.main_file_not_found then - tag_message = 'load_failure_m' - specific_vars = {mod.main_file} - end - if mod.load_issues.prefix_conflict then - tag_message = 'load_failure_p' - local name = mod.load_issues.prefix_conflict - for _, m in ipairs(SMODS.mod_list) do - if m.id == mod.load_issues.prefix_conflict then - name = m.name or name - end - end - specific_vars = {name} - end - if mod.disabled then - tag_pos = {x = 1, y = 0} - tag_message = 'load_disabled' - end - end - - - local tag_sprite_tab = nil - - local tag_sprite = Sprite(0, 0, 0.8*1, 0.8*1, G.ASSET_ATLAS[tag_atlas] or G.ASSET_ATLAS['tags'], tag_pos) - tag_sprite.T.scale = 1 - tag_sprite_tab = {n= G.UIT.C, config={align = "cm", padding = 0}, nodes={ - {n=G.UIT.O, config={w=0.8*1, h=0.8*1, colour = G.C.BLUE, object = tag_sprite, focus_with_object = true}}, - }} - tag_sprite:define_draw_steps({ - {shader = 'dissolve', shadow_height = 0.05}, - {shader = 'dissolve'}, - }) - tag_sprite.float = true - tag_sprite.states.hover.can = true - tag_sprite.states.drag.can = false - tag_sprite.states.collide.can = true - - tag_sprite.hover = function(_self) - if not G.CONTROLLER.dragging.target or G.CONTROLLER.using_touch then - if not _self.hovering and _self.states.visible then - _self.hovering = true - if _self == tag_sprite then - _self.hover_tilt = 3 - _self:juice_up(0.05, 0.02) - play_sound('paper1', math.random()*0.1 + 0.55, 0.42) - play_sound('tarot2', math.random()*0.1 + 0.55, 0.09) - end - tag_sprite.ability_UIBox_table = generate_card_ui({set = "Other", discovered = false, key = tag_message}, nil, specific_vars, 'Other', nil, false) - _self.config.h_popup = G.UIDEF.card_h_popup(_self) - _self.config.h_popup_config ={align = 'cl', offset = {x=-0.1,y=0},parent = _self} - Node.hover(_self) - if _self.children.alert then - _self.children.alert:remove() - _self.children.alert = nil - G:save_progress() - end - end - end - end - tag_sprite.stop_hover = function(_self) _self.hovering = false; Node.stop_hover(_self); _self.hover_tilt = 0 end - - tag_sprite:juice_up() - - return tag_sprite_tab -end - --- Helper function to create a clickable mod box -local function createClickableModBox(modInfo, scale) - local function invert(c) - return {1-c[1], 1-c[2], 1-c[3], c[4]} - end - local col, text_col - if modInfo.should_enable == nil then - modInfo.should_enable = not modInfo.disabled - end - if SMODS.full_restart == nil then - SMODS.full_restart = 0 - end - if modInfo.can_load then - col = G.C.BOOSTER - elseif modInfo.disabled then - col = G.C.UI.BACKGROUND_INACTIVE - else - col = mix_colours(G.C.RED, G.C.UI.BACKGROUND_INACTIVE, 0.7) - text_col = G.C.TEXT_DARK - end - local label = { " " .. modInfo.name .. " " } - if modInfo.lovely_only then - label[2] = localize('b_lovely_mod') - else - label[2] = localize('b_by') .. concatAuthors(modInfo.author) .. " " - end - local but = UIBox_button { - label = label, - shadow = true, - scale = scale, - colour = col, - text_colour = text_col, - button = "openModUI_" .. modInfo.id, - minh = 0.8, - minw = 7 - } - if modInfo.lovely_only then - local config = but.nodes[1].nodes[2].nodes[1].config - config.colour = mix_colours(invert(col), G.C.UI.TEXT_INACTIVE, 0.8) - config.scale = scale * .8 - end - if modInfo.version and modInfo.version ~= '0.0.0' then - table.insert(but.nodes[1].nodes[1].nodes, { - n = G.UIT.T, - config = { - text = ('(%s) '):format(modInfo.version), - scale = scale*0.8, - colour = mix_colours(invert(col), G.C.UI.TEXT_INACTIVE, 0.8), - shadow = true, - }, - }) - end - if modInfo.config_tab then - table.insert(but.nodes[1].nodes[1].nodes, { - n = G.UIT.O, - config = { - object = Sprite(0,0,0.4,0.4, G.ASSET_ATLAS['mod_tags'], {x=2,y=0}) - } - }) - end - return { - n = G.UIT.R, - config = { padding = 0, align = "cm" }, - nodes = { - { - n = G.UIT.C, - config = { align = "cm" }, - nodes = { - buildModtag(modInfo) - } - }, - { - n = G.UIT.C, - config = { align = "cm", padding = 0.1 }, - nodes = {}, - }, - { n = G.UIT.C, config = { padding = 0, align = "cm" }, nodes = { but } }, - create_toggle({ - label = '', - ref_table = modInfo, - ref_value = 'should_enable', - col = true, - w = 0, - h = 0.5, - callback = ( - function(_set_toggle) - if not modInfo.should_enable then - NFS.write(modInfo.path .. '.lovelyignore', '') - else - NFS.remove(modInfo.path .. '.lovelyignore') - end - local toChange = 1 - if modInfo.should_enable == not modInfo.disabled then - toChange = -1 - end - SMODS.full_restart = SMODS.full_restart + toChange - end - ) - }), - }} - -end - -function G.FUNCS.openModsDirectory(options) - love.system.openURL(SMODS.MODS_DIR) -end - -function G.FUNCS.mods_buttons_page(options) - if not options or not options.cycle_config then - return - end -end - -function SMODS.load_mod_config(mod) - local s1, config = pcall(function() - return load(NFS.read(('config/%s.jkr'):format(mod.id)), ('=[SMODS %s "config"]'):format(mod.id))() - end) - local s2, default_config = pcall(function() - return load(NFS.read(mod.path..(mod.config_file or 'config.lua')), ('=[SMODS %s "default_config"]'):format(mod.id))() - end) - if not s1 or type(config) ~= 'table' then config = {} end - if not s2 or type(default_config) ~= 'table' then default_config = {} end - mod.config = default_config - - local function insert_saved_config(savedCfg, defaultCfg) - for savedKey, savedVal in pairs(savedCfg) do - local savedValType = type(savedVal) - local defaultValType = type(defaultCfg[savedKey]) - if not defaultCfg[savedKey] then - defaultCfg[savedKey] = savedVal - elseif savedValType ~= defaultValType then - elseif savedValType == "table" and defaultValType == "table" then - insert_saved_config(savedVal, defaultCfg[savedKey]) - elseif savedVal ~= defaultCfg[savedKey] then - defaultCfg[savedKey] = savedVal - end - - end - end - - insert_saved_config(config, mod.config) - - return mod.config -end -SMODS:load_mod_config() -function SMODS.save_mod_config(mod) - local success = pcall(function() - NFS.createDirectory('config') - assert(mod.config and next(mod.config)) - local serialized = 'return '..serialize(mod.config) - NFS.write(('config/%s.jkr'):format(mod.id), serialized) - end) - return success -end -function SMODS.save_all_config() - SMODS:save_mod_config() - for _, v in ipairs(SMODS.mod_list) do - if v.can_load then - local save_func = type(v.save_mod_config) == 'function' and v.save_mod_config or SMODS.save_mod_config - save_func(v) - end - end -end - -function G.FUNCS.exit_mods(e) - G.ACTIVE_MOD_UI = nil - SMODS.save_all_config() - if SMODS.full_restart and SMODS.full_restart ~= 0 then - -- launch a new instance of the game and quit the current one - SMODS.restart_game() - end - SMODS.IN_MODS_TAB = nil - if e then - -- This is only needed when back button is pressed - G.FUNCS.exit_overlay_menu(e) - end -end - -function create_UIBox_mods_button() - local scale = 0.75 - SMODS.browse_search = SMODS.browse_search or '' - return (create_UIBox_generic_options({ - back_func = 'exit_mods', - contents = { - { - n = G.UIT.R, - config = { - padding = 0, - align = "cm" - }, - nodes = { - create_tabs({ - snap_to_nav = true, - colour = G.C.BOOSTER, - tabs = { - { - label = localize('b_mods'), - chosen = true, - tab_definition_function = function() - return SMODS.GUI.DynamicUIManager.initTab({ - updateFunctions = { - modsList = G.FUNCS.update_mod_list, - }, - staticPageDefinition = SMODS.GUI.staticModListContent() - }) - end - }, - -- { - -- label = localize('b_browse'), - -- tab_definition_function = function() - -- return { - -- n = G.UIT.ROOT, - -- config = { - -- align = "cm", - -- padding = 0.05, - -- colour = G.C.CLEAR, - -- }, - -- nodes = { - -- { - -- n = G.UIT.C, - -- config = { align = 'cm' }, - -- nodes = { - -- { - -- n = G.UIT.R, - -- config = { align = 'cl' }, - -- nodes = { - -- create_text_input{ - -- prompt_text = localize('b_search_prompt'), - -- max_length = 50, - -- text_scale = 0.6, - -- w = 6, - -- h = 1, - -- ref_table = SMODS, - -- ref_value = "browse_search", - -- extended_corpus = true, - -- }, - -- UIBox_button{ - -- button = 'browse_search', - -- label = {localize('b_search_button')}, - -- minw = 3, - -- colour = G.C.RED - -- } - -- } - -- }, - -- { - -- n = G.UIT.R, - -- config = { align = 'cm', emboss = 0.05, colour = G.C.BLACK, minh=5, minw=10.5}, - -- nodes = { - -- { - -- n = G.UIT.O, - -- config = { align = 'cm', object = Moveable(), id = 'browse_mods'} - -- } - -- } - -- } - -- } - -- } - -- } - -- } - -- end, - -- }, - { - - label = localize('b_credits'), - tab_definition_function = function() - return { - n = G.UIT.ROOT, - config = { - emboss = 0.05, - minh = 6, - r = 0.1, - minw = 6, - align = "cm", - padding = 0.2, - colour = G.C.BLACK - }, - nodes = { - { - n = G.UIT.R, - config = { - padding = 0, - align = "cm" - }, - nodes = { - { - n = G.UIT.T, - config = { - text = localize('b_mod_loader'), - shadow = true, - scale = scale * 0.8, - colour = G.C.UI.TEXT_LIGHT - } - } - } - }, - { - n = G.UIT.R, - config = { - padding = 0, - align = "cm" - }, - nodes = { - { - n = G.UIT.T, - config = { - text = localize('b_developed_by'), - shadow = true, - scale = scale * 0.8, - colour = G.C.UI.TEXT_LIGHT - } - }, - { - n = G.UIT.T, - config = { - text = "Steamo", - shadow = true, - scale = scale * 0.8, - colour = G.C.BLUE - } - } - } - }, - { - n = G.UIT.R, - config = { - padding = 0, - align = "cm" - }, - nodes = { - { - n = G.UIT.T, - config = { - text = localize('b_rewrite_by'), - shadow = true, - scale = scale * 0.8, - colour = G.C.UI.TEXT_LIGHT - } - }, - { - n = G.UIT.T, - config = { - text = "Aure", - shadow = true, - scale = scale * 0.8, - colour = G.C.BLUE - } - } - } - }, - { - n = G.UIT.R, - config = { - padding = 0.2, - align = "cm", - }, - nodes = { - UIBox_button({ - minw = 3.85, - button = "steamodded_github", - label = {localize('b_github_project')} - }) - } - }, - { - n = G.UIT.R, - config = { - padding = 0.2, - align = "cm" - }, - nodes = { - { - n = G.UIT.T, - config = { - text = localize('b_github_bugs_1')..'\n'..localize('b_github_bugs_2'), - shadow = true, - scale = scale * 0.5, - colour = G.C.UI.TEXT_LIGHT - } - }, - - } - }, - } - } - end - }, - { - label = localize('b_config'), - tab_definition_function = function() - return { - n = G.UIT.ROOT, - config = { - align = "cm", - padding = 0.05, - colour = G.C.CLEAR, - }, - nodes = { - create_toggle { - label = localize('b_disable_mod_badges'), - ref_table = SMODS.config, - ref_value = 'no_mod_badges', - }, - create_toggle { - label = localize('b_seeded_unlocks'), - info = {localize('b_seeded_unlocks_info')}, - ref_table = SMODS.config, - ref_value = 'seeded_unlocks', - }, - create_option_cycle { - w = 4.5, - scale = 0.8, - label = localize('b_achievements'), - options = localize('ml_achievement_settings'), - opt_callback = 'update_achievement_settings', - current_option = SMODS.config.achievements, - cycle_shoulders = true, - } - } - } - end - } - } - }) - } - } - } - })) -end - -G.FUNCS.update_achievement_settings = function(e) - local opt = (e.cycle_config or {}).current_option or 1 - SMODS.config.achievements = opt - G.F_NO_ACHIEVEMENTS = opt == 1 -end - -G.FUNCS.browse_search = function(e) - SMODS.fetch_index() - -end - -G.FUNCS.browse_mods_page = function(args) - local page = args.cycle_config and args.cycle_config.current_option or 1 -end - -function G.FUNCS.steamodded_github(e) - love.system.openURL("https://github.com/Steamopollys/Steamodded") -end - -function G.FUNCS.mods_button(e) - G.SETTINGS.paused = true - SMODS.LAST_SELECTED_MOD_TAB = nil - SMODS.IN_MODS_TAB = true - - G.FUNCS.overlay_menu({ - definition = create_UIBox_mods_button() - }) -end - -local create_UIBox_main_menu_buttonsRef = create_UIBox_main_menu_buttons -function create_UIBox_main_menu_buttons() - local modsButton = UIBox_button({ - id = "mods_button", - minh = 1.55, - minw = 1.85, - col = true, - button = "mods_button", - colour = G.C.BOOSTER, - label = {localize('b_mods_cap')}, - scale = 0.45 * 1.2 - }) - local menu = create_UIBox_main_menu_buttonsRef() - table.insert(menu.nodes[1].nodes[1].nodes, modsButton) - menu.nodes[1].nodes[1].config = {align = "cm", padding = 0.15, r = 0.1, emboss = 0.1, colour = G.C.L_BLACK, mid = true} - if SMODS.mod_button_alert then - G.E_MANAGER:add_event(Event({ - func = function() - if G.MAIN_MENU_UI then -- Wait until the ui is rendered before spawning the alert - UIBox{definition = create_UIBox_card_alert(), config = {align="tri", offset = {x = 0.05, y = -0.05}, major = G.MAIN_MENU_UI:get_UIE_by_ID('mods_button'), can_collide = false}} - return true - end - end, - blocking = false, - blockable = false - })) - end - return menu -end - -local create_UIBox_profile_buttonRef = create_UIBox_profile_button -function create_UIBox_profile_button() - local profile_menu = create_UIBox_profile_buttonRef() - profile_menu.nodes[1].config = {align = "cm", padding = 0.11, r = 0.1, emboss = 0.1, colour = G.C.L_BLACK} - return(profile_menu) -end - --- Disable achievments and crash report upload -function initGlobals() - G.F_NO_ACHIEVEMENTS = SMODS.config.achievements == 1 - G.F_CRASH_REPORTS = false -end - -function G.FUNCS.update_mod_list(args) - if not args or not args.cycle_config then return end - SMODS.GUI.DynamicUIManager.updateDynamicAreas({ - ["modsList"] = SMODS.GUI.dynamicModListContent(args.cycle_config.current_option) - }) -end - --- Same as Balatro base game code, but accepts a value to match against (rather than the index in the option list) --- e.g. create_option_cycle({ current_option = 1 }) vs. SMODS.GUID.createOptionSelector({ current_option = "Page 1/2" }) -function SMODS.GUI.createOptionSelector(args) - args = args or {} - args.colour = args.colour or G.C.RED - args.options = args.options or { - 'Option 1', - 'Option 2' - } - - local current_option_index = 1 - for i, option in ipairs(args.options) do - if option == args.current_option then - current_option_index = i - break - end - end - args.current_option_val = args.options[current_option_index] - args.current_option = current_option_index - args.opt_callback = args.opt_callback or nil - args.scale = args.scale or 1 - args.ref_table = args.ref_table or nil - args.ref_value = args.ref_value or nil - args.w = (args.w or 2.5)*args.scale - args.h = (args.h or 0.8)*args.scale - args.text_scale = (args.text_scale or 0.5)*args.scale - args.l = '<' - args.r = '>' - args.focus_args = args.focus_args or {} - args.focus_args.type = 'cycle' - - local info = nil - if args.info then - info = {} - for k, v in ipairs(args.info) do - table.insert(info, {n=G.UIT.R, config={align = "cm", minh = 0.05}, nodes={ - {n=G.UIT.T, config={text = v, scale = 0.3*args.scale, colour = G.C.UI.TEXT_LIGHT}} - }}) - end - info = {n=G.UIT.R, config={align = "cm", minh = 0.05}, nodes=info} - end - - local disabled = #args.options < 2 - local pips = {} - for i = 1, #args.options do - pips[#pips+1] = {n=G.UIT.B, config={w = 0.1*args.scale, h = 0.1*args.scale, r = 0.05, id = 'pip_'..i, colour = args.current_option == i and G.C.WHITE or G.C.BLACK}} - end - - local choice_pips = not args.no_pips and {n=G.UIT.R, config={align = "cm", padding = (0.05 - (#args.options > 15 and 0.03 or 0))*args.scale}, nodes=pips} or nil - - local t = - {n=G.UIT.C, config={align = "cm", padding = 0.1, r = 0.1, colour = G.C.CLEAR, id = args.id and (not args.label and args.id or nil) or nil, focus_args = args.focus_args}, nodes={ - {n=G.UIT.C, config={align = "cm",r = 0.1, minw = 0.6*args.scale, hover = not disabled, colour = not disabled and args.colour or G.C.BLACK,shadow = not disabled, button = not disabled and 'option_cycle' or nil, ref_table = args, ref_value = 'l', focus_args = {type = 'none'}}, nodes={ - {n=G.UIT.T, config={ref_table = args, ref_value = 'l', scale = args.text_scale, colour = not disabled and G.C.UI.TEXT_LIGHT or G.C.UI.TEXT_INACTIVE}} - }}, - args.mid and - {n=G.UIT.C, config={id = 'cycle_main'}, nodes={ - {n=G.UIT.R, config={align = "cm", minh = 0.05}, nodes={ - args.mid - }}, - not disabled and choice_pips or nil - }} - or {n=G.UIT.C, config={id = 'cycle_main', align = "cm", minw = args.w, minh = args.h, r = 0.1, padding = 0.05, colour = args.colour,emboss = 0.1, hover = true, can_collide = true, on_demand_tooltip = args.on_demand_tooltip}, nodes={ - {n=G.UIT.R, config={align = "cm"}, nodes={ - {n=G.UIT.R, config={align = "cm"}, nodes={ - {n=G.UIT.O, config={object = DynaText({string = {{ref_table = args, ref_value = "current_option_val"}}, colours = {G.C.UI.TEXT_LIGHT},pop_in = 0, pop_in_rate = 8, reset_pop_in = true,shadow = true, float = true, silent = true, bump = true, scale = args.text_scale, non_recalc = true})}}, - }}, - {n=G.UIT.R, config={align = "cm", minh = 0.05}, nodes={ - }}, - not disabled and choice_pips or nil - }} - }}, - {n=G.UIT.C, config={align = "cm",r = 0.1, minw = 0.6*args.scale, hover = not disabled, colour = not disabled and args.colour or G.C.BLACK,shadow = not disabled, button = not disabled and 'option_cycle' or nil, ref_table = args, ref_value = 'r', focus_args = {type = 'none'}}, nodes={ - {n=G.UIT.T, config={ref_table = args, ref_value = 'r', scale = args.text_scale, colour = not disabled and G.C.UI.TEXT_LIGHT or G.C.UI.TEXT_INACTIVE}} - }}, - }} - - if args.cycle_shoulders then - t = - {n=G.UIT.R, config={align = "cm", colour = G.C.CLEAR}, nodes = { - {n=G.UIT.C, config={minw = 0.7,align = "cm", colour = G.C.CLEAR,func = 'set_button_pip', focus_args = {button = 'leftshoulder', type = 'none', orientation = 'cm', scale = 0.7, offset = {x = -0.1, y = 0}}}, nodes = {}}, - {n=G.UIT.C, config={id = 'cycle_shoulders', padding = 0.1}, nodes={t}}, - {n=G.UIT.C, config={minw = 0.7,align = "cm", colour = G.C.CLEAR,func = 'set_button_pip', focus_args = {button = 'rightshoulder', type = 'none', orientation = 'cm', scale = 0.7, offset = {x = 0.1, y = 0}}}, nodes = {}}, - }} - else - t = - {n=G.UIT.R, config={align = "cm", colour = G.C.CLEAR, padding = 0.0}, nodes = { - t - }} - end - if args.label or args.info then - t = {n=G.UIT.R, config={align = "cm", padding = 0.05, id = args.id or nil}, nodes={ - args.label and {n=G.UIT.R, config={align = "cm"}, nodes={ - {n=G.UIT.T, config={text = args.label, scale = 0.5*args.scale, colour = G.C.UI.TEXT_LIGHT}} - }} or nil, - t, - info, - }} - end - return t -end - -local function generateBaseNode(staticPageDefinition) - return { - n = G.UIT.ROOT, - config = { - emboss = 0.05, - minh = 6, - r = 0.1, - minw = 8, - align = "cm", - padding = 0.2, - colour = G.C.BLACK - }, - nodes = { - staticPageDefinition - } - } -end - --- Initialize a tab with sections that can be updated dynamically (e.g. modifying text labels, showing additional UI elements after toggling buttons, etc.) -function SMODS.GUI.DynamicUIManager.initTab(args) - local updateFunctions = args.updateFunctions - local staticPageDefinition = args.staticPageDefinition - - for _, updateFunction in pairs(updateFunctions) do - G.E_MANAGER:add_event(Event({func = function() - updateFunction{cycle_config = {}} - return true - end})) - end - return generateBaseNode(staticPageDefinition) -end - --- Call this to trigger an update for a list of dynamic content areas -function SMODS.GUI.DynamicUIManager.updateDynamicAreas(uiDefinitions) - for id, uiDefinition in pairs(uiDefinitions) do - local dynamicArea = G.OVERLAY_MENU:get_UIE_by_ID(id) - if dynamicArea and dynamicArea.config.object then - dynamicArea.config.object:remove() - dynamicArea.config.object = UIBox{ - definition = uiDefinition, - config = {offset = {x=0, y=0}, align = 'cm', parent = dynamicArea} - } - end - end -end - -local function recalculateModsList(page) - page = page or SMODS.LAST_VIEWED_MODS_PAGE or 1 - SMODS.LAST_VIEWED_MODS_PAGE = page - local modsPerPage = 4 - local startIndex = (page - 1) * modsPerPage + 1 - local endIndex = startIndex + modsPerPage - 1 - local totalPages = math.ceil(#SMODS.mod_list / modsPerPage) - local currentPage = localize('k_page') .. ' ' .. page .. "/" .. totalPages - local pageOptions = {} - for i = 1, totalPages do - table.insert(pageOptions, (localize('k_page') .. ' ' .. tostring(i) .. "/" .. totalPages)) - end - local showingList = #SMODS.mod_list > 0 - - return currentPage, pageOptions, showingList, startIndex, endIndex, modsPerPage -end - --- Define the content in the pane that does not need to update --- Should include OBJECT nodes that indicate where the dynamic content sections will be populated --- EX: in this pane the 'modsList' node will contain the dynamic content which is defined in the function below -function SMODS.GUI.staticModListContent() - local scale = 0.75 - local currentPage, pageOptions, showingList = recalculateModsList() - return { - n = G.UIT.ROOT, - config = { - minh = 6, - r = 0.1, - minw = 10, - align = "tm", - padding = 0.2, - colour = G.C.BLACK - }, - nodes = { - -- row container - { - n = G.UIT.R, - config = { align = "cm", padding = 0.05 }, - nodes = { - -- column container - { - n = G.UIT.C, - config = { align = "cm", minw = 3, padding = 0.2, r = 0.1, colour = G.C.CLEAR }, - nodes = { - -- title row - { - n = G.UIT.R, - config = { - padding = 0.05, - align = "cm" - }, - nodes = { - UIBox_button({ - label = { localize('b_mod_list') }, - shadow = true, - scale = scale*0.85, - colour = G.C.BOOSTER, - button = "openModsDirectory", - minh = scale, - minw = 9 - }), - } - }, - - -- add some empty rows for spacing - { - n = G.UIT.R, - config = { align = "cm", padding = 0.05 }, - nodes = {} - }, - { - n = G.UIT.R, - config = { align = "cm", padding = 0.05 }, - nodes = {} - }, - { - n = G.UIT.R, - config = { align = "cm", padding = 0.05 }, - nodes = {} - }, - { - n = G.UIT.R, - config = { align = "cm", padding = 0.05 }, - nodes = {} - }, - - -- dynamic content rendered in this row container - -- list of 4 mods on the current page - { - n = G.UIT.R, - config = { - padding = 0.05, - align = "cm", - minh = 2, - minw = 4 - }, - nodes = { - {n=G.UIT.O, config={id = 'modsList', object = Moveable()}}, - } - }, - - -- another empty row for spacing - { - n = G.UIT.R, - config = { align = "cm", padding = 0.3 }, - nodes = {} - }, - - -- page selector - -- does not appear when list of mods is empty - showingList and SMODS.GUI.createOptionSelector({label = "", scale = 0.8, options = pageOptions, opt_callback = 'update_mod_list', no_pips = true, current_option = ( - currentPage - )}) or nil - } - }, - } - }, - } - } -end - -function SMODS.GUI.dynamicModListContent(page) - local scale = 0.75 - local _, __, showingList, startIndex, endIndex, modsPerPage = recalculateModsList(page) - - local modNodes = {} - - -- If no mods are loaded, show a default message - if showingList == false then - table.insert(modNodes, { - n = G.UIT.R, - config = { - padding = 0, - align = "cm" - }, - nodes = { - { - n = G.UIT.T, - config = { - text = localize('b_no_mods'), - shadow = true, - scale = scale * 0.5, - colour = G.C.UI.TEXT_DARK - } - } - } - }) - else - local modCount = 0 - local id = 0 - - for _, condition in ipairs({ - function(m) return not m.can_load and not m.disabled end, - function(m) return m.can_load and m.config_tab end, - function(m) return m.can_load and not m.config_tab end, - function(m) return m.disabled end, - }) do - for _, modInfo in ipairs(SMODS.mod_list) do - if modCount >= modsPerPage then break end - if condition(modInfo) then - id = id + 1 - if id >= startIndex and id <= endIndex then - table.insert(modNodes, createClickableModBox(modInfo, scale * 0.5)) - modCount = modCount + 1 - end - end - end - end - end - - return { - n = G.UIT.C, - config = { - r = 0.1, - align = "cm", - padding = 0.2, - }, - nodes = modNodes - } -end - -G.FUNCS.SMODS_change_mipmap = function(args) - SMODS.config.graphics_mipmap_level = args.to_key - G:set_render_settings() - SMODS:save_mod_config() -end - -SMODS.card_collection_UIBox = function(_pool, rows, args) - args = args or {} - args.w_mod = args.w_mod or 1 - args.h_mod = args.h_mod or 1 - args.card_scale = args.card_scale or 1 - local deck_tables = {} - local pool = SMODS.collection_pool(_pool) - - G.your_collection = {} - local cards_per_page = 0 - local row_totals = {} - for j = 1, #rows do - if cards_per_page >= #pool and args.collapse_single_page then - rows[j] = nil - else - row_totals[j] = cards_per_page - cards_per_page = cards_per_page + rows[j] - G.your_collection[j] = CardArea( - G.ROOM.T.x + 0.2*G.ROOM.T.w/2,G.ROOM.T.h, - (args.w_mod*rows[j]+0.25)*G.CARD_W, - args.h_mod*G.CARD_H, - {card_limit = rows[j], type = args.area_type or 'title', highlight_limit = 0, collection = true} - ) - table.insert(deck_tables, - {n=G.UIT.R, config={align = "cm", padding = 0.07, no_fill = true}, nodes={ - {n=G.UIT.O, config={object = G.your_collection[j]}} - }}) - end - end - - local options = {} - for i = 1, math.ceil(#pool/cards_per_page) do - table.insert(options, localize('k_page')..' '..tostring(i)..'/'..tostring(math.ceil(#pool/cards_per_page))) - end - - G.FUNCS.SMODS_card_collection_page = function(e) - if not e or not e.cycle_config then return end - for j = 1, #G.your_collection do - for i = #G.your_collection[j].cards, 1, -1 do - local c = G.your_collection[j]:remove_card(G.your_collection[j].cards[i]) - c:remove() - c = nil - end - end - for j = 1, #rows do - for i = 1, rows[j] do - local center = pool[i+row_totals[j] + (cards_per_page*(e.cycle_config.current_option - 1))] - if not center then break end - local card = Card(G.your_collection[j].T.x + G.your_collection[j].T.w/2, G.your_collection[j].T.y, G.CARD_W*args.card_scale, G.CARD_H*args.card_scale, G.P_CARDS.empty, (args.center and G.P_CENTERS[args.center]) or center) - if args.modify_card then args.modify_card(card, center, i, j) end - if not args.no_materialize then card:start_materialize(nil, i>1 or j>1) end - G.your_collection[j]:emplace(card) - end - end - INIT_COLLECTION_CARD_ALERTS() - end - - G.FUNCS.SMODS_card_collection_page{ cycle_config = { current_option = 1 }} - - local t = create_UIBox_generic_options({ back_func = (args and args.back_func) or G.ACTIVE_MOD_UI and "openModUI_"..G.ACTIVE_MOD_UI.id or 'your_collection', snap_back = args.snap_back, infotip = args.infotip, contents = { - {n=G.UIT.R, config={align = "cm", r = 0.1, colour = G.C.BLACK, emboss = 0.05}, nodes=deck_tables}, - (not args.hide_single_page or cards_per_page < #pool) and {n=G.UIT.R, config={align = "cm"}, nodes={ - create_option_cycle({options = options, w = 4.5, cycle_shoulders = true, opt_callback = 'SMODS_card_collection_page', current_option = 1, colour = G.C.RED, no_pips = true, focus_args = {snap_to = true, nav = 'wide'}}) - }} or nil, - }}) - return t -end - -create_UIBox_your_collection_jokers = function() - return SMODS.card_collection_UIBox(G.P_CENTER_POOLS.Joker, {5,5,5}, { - no_materialize = true, - modify_card = function(card, center) card.sticker = get_joker_win_sticker(center) end, - h_mod = 0.95, - }) -end -create_UIBox_your_collection_boosters = function() - return SMODS.card_collection_UIBox(G.P_CENTER_POOLS.Booster, {4,4}, { - h_mod = 1.3, - w_mod = 1.25, - card_scale = 1.27, - }) -end -create_UIBox_your_collection_vouchers = function() - return SMODS.card_collection_UIBox(G.P_CENTER_POOLS.Voucher, {4,4}, { - area_type = 'voucher', - modify_card = function(card, center, i, j) - card.ability.order = i+(j-1)*4 - end, - }) -end -create_UIBox_your_collection_enhancements = function() - return SMODS.card_collection_UIBox(G.P_CENTER_POOLS.Enhanced, {4,4}, { - no_materialize = true, - snap_back = true, - h_mod = 1.03, - infotip = localize('ml_edition_seal_enhancement_explanation'), - hide_single_page = true, - }) -end -create_UIBox_your_collection_editions = function() - return SMODS.card_collection_UIBox(G.P_CENTER_POOLS.Edition, {5,5}, { - snap_back = true, - h_mod = 1.03, - infotip = localize('ml_edition_seal_enhancement_explanation'), - hide_single_page = true, - collapse_single_page = true, - modify_card = function(card, center) - if center.discovered then card:set_edition(center.key, true, true) end - end, - }) -end - -create_UIBox_your_collection_seals = function() - return SMODS.card_collection_UIBox(G.P_CENTER_POOLS.Seal, {5,5}, { - snap_back = true, - infotip = localize('ml_edition_seal_enhancement_explanation'), - hide_single_page = true, - collapse_single_page = true, - center = 'c_base', - h_mod = 1.03, - modify_card = function(card, center) - card:set_seal(center.key, true) - end, - }) -end - -G.FUNCS.your_collection_stickers = function(e) - G.SETTINGS.paused = true - G.FUNCS.overlay_menu{ - definition = create_UIBox_your_collection_stickers(), - } -end - -create_UIBox_your_collection_stickers = function() - return SMODS.card_collection_UIBox(SMODS.Stickers, {5,5}, { - snap_back = true, - hide_single_page = true, - collapse_single_page = true, - center = 'c_base', - h_mod = 1.03, - back_func = 'your_collection_other_gameobjects', - modify_card = function(card, center) - card.ignore_pinned = true - center:apply(card, true) - end, - }) -end diff --git a/smods-main/src/utils.lua b/smods-main/src/utils.lua deleted file mode 100644 index 6f9c09d..0000000 --- a/smods-main/src/utils.lua +++ /dev/null @@ -1,1796 +0,0 @@ ---- STEAMODDED CORE ---- UTILITY FUNCTIONS -function inspect(table) - if type(table) ~= 'table' then - return "Not a table" - end - - local str = "" - for k, v in pairs(table) do - local valueStr = type(v) == "table" and "table" or tostring(v) - str = str .. tostring(k) .. ": " .. valueStr .. "\n" - end - - return str -end - -function inspectDepth(table, indent, depth) - if depth and depth > 5 then -- Limit the depth to avoid deep nesting - return "Depth limit reached" - end - - if type(table) ~= 'table' then -- Ensure the object is a table - return "Not a table" - end - - local str = "" - if not indent then indent = 0 end - - for k, v in pairs(table) do - local formatting = string.rep(" ", indent) .. tostring(k) .. ": " - if type(v) == "table" then - str = str .. formatting .. "\n" - str = str .. inspectDepth(v, indent + 1, (depth or 0) + 1) - elseif type(v) == 'function' then - str = str .. formatting .. "function\n" - elseif type(v) == 'boolean' then - str = str .. formatting .. tostring(v) .. "\n" - else - str = str .. formatting .. tostring(v) .. "\n" - end - end - - return str -end - -function inspectFunction(func) - if type(func) ~= 'function' then - return "Not a function" - end - - local info = debug.getinfo(func) - local result = "Function Details:\n" - - if info.what == "Lua" then - result = result .. "Defined in Lua\n" - else - result = result .. "Defined in C or precompiled\n" - end - - result = result .. "Name: " .. (info.name or "anonymous") .. "\n" - result = result .. "Source: " .. info.source .. "\n" - result = result .. "Line Defined: " .. info.linedefined .. "\n" - result = result .. "Last Line Defined: " .. info.lastlinedefined .. "\n" - result = result .. "Number of Upvalues: " .. info.nups .. "\n" - - return result -end - -function SMODS._save_d_u(o) - assert(not o._discovered_unlocked_overwritten) - o._d, o._u = o.discovered, o.unlocked - o._saved_d_u = true -end - -function SMODS.SAVE_UNLOCKS() - boot_print_stage("Saving Unlocks") - G:save_progress() - ------------------------------------- - local TESTHELPER_unlocks = false and not _RELEASE_MODE - ------------------------------------- - if not love.filesystem.getInfo(G.SETTINGS.profile .. '') then - love.filesystem.createDirectory(G.SETTINGS.profile .. - '') - end - if not love.filesystem.getInfo(G.SETTINGS.profile .. '/' .. 'meta.jkr') then - love.filesystem.append( - G.SETTINGS.profile .. '/' .. 'meta.jkr', 'return {}') - end - - convert_save_to_meta() - - local meta = STR_UNPACK(get_compressed(G.SETTINGS.profile .. '/' .. 'meta.jkr') or 'return {}') - meta.unlocked = meta.unlocked or {} - meta.discovered = meta.discovered or {} - meta.alerted = meta.alerted or {} - - G.P_LOCKED = {} - for k, v in pairs(G.P_CENTERS) do - if not v.wip and not v.demo then - if TESTHELPER_unlocks then - v.unlocked = true; v.discovered = true; v.alerted = true - end --REMOVE THIS - if not v.unlocked and meta.unlocked[k] then - v.unlocked = true - end - if not v.unlocked then - G.P_LOCKED[#G.P_LOCKED + 1] = v - end - if not v.discovered and meta.discovered[k] then - v.discovered = true - end - if v.discovered and meta.alerted[k] or v.set == 'Back' or v.start_alerted then - v.alerted = true - elseif v.discovered then - v.alerted = false - end - end - end - - table.sort(G.P_LOCKED, function (a, b) return a.order and b.order and a.order < b.order end) - - for k, v in pairs(G.P_BLINDS) do - v.key = k - if not v.wip and not v.demo then - if TESTHELPER_unlocks then v.discovered = true; v.alerted = true end --REMOVE THIS - if not v.discovered and meta.discovered[k] then - v.discovered = true - end - if v.discovered and meta.alerted[k] then - v.alerted = true - elseif v.discovered then - v.alerted = false - end - end - end - for k, v in pairs(G.P_TAGS) do - v.key = k - if not v.wip and not v.demo then - if TESTHELPER_unlocks then v.discovered = true; v.alerted = true end --REMOVE THIS - if not v.discovered and meta.discovered[k] then - v.discovered = true - end - if v.discovered and meta.alerted[k] then - v.alerted = true - elseif v.discovered then - v.alerted = false - end - end - end - for k, v in pairs(G.P_SEALS) do - v.key = k - if not v.wip and not v.demo then - if TESTHELPER_unlocks then - v.discovered = true; v.alerted = true - end --REMOVE THIS - if not v.discovered and meta.discovered[k] then - v.discovered = true - end - if v.discovered and meta.alerted[k] then - v.alerted = true - elseif v.discovered then - v.alerted = false - end - end - end - for _, t in ipairs{ - G.P_CENTERS, - G.P_BLINDS, - G.P_TAGS, - G.P_SEALS, - } do - for k, v in pairs(t) do - v._discovered_unlocked_overwritten = true - end - end -end - -function SMODS.process_loc_text(ref_table, ref_value, loc_txt, key) - local target = (type(loc_txt) == 'table') and - ((G.SETTINGS.real_language and loc_txt[G.SETTINGS.real_language]) or loc_txt[G.SETTINGS.language] or loc_txt['default'] or loc_txt['en-us']) or loc_txt - if key and (type(target) == 'table') then target = target[key] end - if not (type(target) == 'string' or target and next(target)) then return end - ref_table[ref_value] = target -end - -local function parse_loc_file(file_name, force) - local loc_table = nil - if file_name:lower():match("%.json$") then - loc_table = assert(JSON.decode(NFS.read(file_name))) - else - loc_table = assert(loadstring(NFS.read(file_name)))() - end - local function recurse(target, ref_table) - if type(target) ~= 'table' then return end --this shouldn't happen unless there's a bad return value - for k, v in pairs(target) do - -- If the value doesn't exist *or* - -- force mode is on and the value is not a table, - -- change/add the thing - -- brings back compatibility with language patching mods - if (not ref_table[k] and type(k) ~= 'number') or (force and ((type(v) ~= 'table') or type(v[1]) == 'string')) then - ref_table[k] = v - else - recurse(v, ref_table[k]) - end - end - end - recurse(loc_table, G.localization) -end - -local function handle_loc_file(dir, language, force) - for k, v in ipairs({ dir .. language .. '.lua', dir .. language .. '.json' }) do - if NFS.getInfo(v) then - parse_loc_file(v, force) - break - end - end -end - -function SMODS.handle_loc_file(path) - local dir = path .. 'localization/' - handle_loc_file(dir, 'en-us', true) - handle_loc_file(dir, 'default', true) - handle_loc_file(dir, G.SETTINGS.language, true) - if G.SETTINGS.real_language then handle_loc_file(dir, G.SETTINGS.real_language, true) end -end - -function SMODS.insert_pool(pool, center, replace) - if replace == nil then replace = center.taken_ownership end - if replace then - for k, v in ipairs(pool) do - if v.key == center.key then - pool[k] = center - end - end - else - local prev_order = (pool[#pool] and pool[#pool].order) or 0 - if prev_order ~= nil then - center.order = prev_order + 1 - end - table.insert(pool, center) - end -end - -function SMODS.remove_pool(pool, key) - local j - for i, v in ipairs(pool) do - if v.key == key then j = i end - end - if j then return table.remove(pool, j) end -end - -function SMODS.juice_up_blind() - local ui_elem = G.HUD_blind:get_UIE_by_ID('HUD_blind_debuff') - for _, v in ipairs(ui_elem.children) do - v.children[1]:juice_up(0.3, 0) - end - G.GAME.blind:juice_up() -end - --- @deprecated -function SMODS.eval_this(_card, effects) - sendWarnMessage('SMODS.eval_this is deprecated. All calculation stages now support returning effects directly. Effects evaluated using this function are out of order and may not use the correct sound pitch.', 'Util') - if effects then - local extras = { mult = false, hand_chips = false } - if effects.mult_mod then - mult = mod_mult(mult + effects.mult_mod); extras.mult = true - end - if effects.chip_mod then - hand_chips = mod_chips(hand_chips + effects.chip_mod); extras.hand_chips = true - end - if effects.Xmult_mod then - mult = mod_mult(mult * effects.Xmult_mod); extras.mult = true - end - update_hand_text({ delay = 0 }, { chips = extras.hand_chips and hand_chips, mult = extras.mult and mult }) - if effects.message then - card_eval_status_text(_card, 'jokers', nil, percent, nil, effects) - end - percent = (percent or 0) + (percent_delta or 0.08) - end -end - --- Change a card's suit, rank, or both. --- Accepts keys for both objects instead of needing to build a card key yourself. -function SMODS.change_base(card, suit, rank) - if not card then return false end - local _suit = SMODS.Suits[suit or card.base.suit] - local _rank = SMODS.Ranks[rank or card.base.value] - if not _suit or not _rank then - sendWarnMessage(('Tried to call SMODS.change_base with invalid arguments: suit="%s", rank="%s"'):format(suit, rank), 'Util') - return false - end - card:set_base(G.P_CARDS[('%s_%s'):format(_suit.card_key, _rank.card_key)]) - return card -end - --- Return an array of all (non-debuffed) jokers or consumables with key `key`. --- Debuffed jokers count if `count_debuffed` is true. --- This function replaces find_joker(); please use SMODS.find_card() instead --- to avoid name conflicts with other mods. -function SMODS.find_card(key, count_debuffed) - local results = {} - if not G.jokers or not G.jokers.cards then return {} end - for _, area in ipairs(SMODS.get_card_areas('jokers')) do - for _, v in pairs(area.cards) do - if v and type(v) == 'table' and v.config.center.key == key and (count_debuffed or not v.debuff) then - table.insert(results, v) - end - end - end - return results -end - -function SMODS.create_card(t) - if not t.area and t.key and G.P_CENTERS[t.key] then - t.area = G.P_CENTERS[t.key].consumeable and G.consumeables or G.P_CENTERS[t.key].set == 'Joker' and G.jokers - end - if not t.area and not t.key and t.set and SMODS.ConsumableTypes[t.set] then - t.area = G.consumeables - end - SMODS.bypass_create_card_edition = t.no_edition - local _card = create_card(t.set, t.area, t.legendary, t.rarity, t.skip_materialize, t.soulable, t.key, t.key_append) - SMODS.bypass_create_card_edition = nil - - -- Should this be restricted to only cards able to handle these - -- or should that be left to the person calling SMODS.create_card to use it correctly? - if t.edition then _card:set_edition(t.edition) end - if t.enhancement then _card:set_ability(G.P_CENTERS[t.enhancement]) end - if t.seal then _card:set_seal(t.seal) end - if t.stickers then - for i, v in ipairs(t.stickers) do - local s = SMODS.Stickers[v] - if not s or type(s.should_apply) ~= 'function' or s:should_apply(_card, t.area, true) then - SMODS.Stickers[v]:apply(_card, true) - end - end - end - - return _card -end - -function SMODS.add_card(t) - local card = SMODS.create_card(t) - card:add_to_deck() - local area = t.area or G.jokers - area:emplace(card) - return card -end - -function SMODS.debuff_card(card, debuff, source) - debuff = debuff or nil - source = source and tostring(source) or nil - if debuff == 'reset' then card.ability.debuff_sources = {}; return end - card.ability.debuff_sources = card.ability.debuff_sources or {} - card.ability.debuff_sources[source] = debuff - card:set_debuff() -end - --- Recalculate whether a card should be debuffed -function SMODS.recalc_debuff(card) - G.GAME.blind:debuff_card(card) -end - -function SMODS.restart_game() - if ((G or {}).SOUND_MANAGER or {}).channel then - G.SOUND_MANAGER.channel:push({ - type = "kill", - }) - end - if ((G or {}).SAVE_MANAGER or {}).channel then - G.SAVE_MANAGER.channel:push({ - type = "kill", - }) - end - if ((G or {}).HTTP_MANAGER or {}).channel then - G.HTTP_MANAGER.channel:push({ - type = "kill", - }) - end - if love.system.getOS() ~= 'OS X' then - love.thread.newThread("os.execute(...)\n"):start('"' .. arg[-2] .. '" ' .. table.concat(arg, " ")) - else - os.execute('sh "/Users/$USER/Library/Application Support/Steam/steamapps/common/Balatro/run_lovely.sh" &') - end - - love.event.quit() -end - -function SMODS.create_mod_badges(obj, badges) - if not SMODS.config.no_mod_badges and obj and obj.mod and obj.mod.display_name and not obj.no_mod_badges then - local mods = {} - badges.mod_set = badges.mod_set or {} - if not badges.mod_set[obj.mod.id] and not obj.no_main_mod_badge then table.insert(mods, obj.mod) end - badges.mod_set[obj.mod.id] = true - if obj.dependencies then - for _, v in ipairs(obj.dependencies) do - local m = assert(SMODS.find_mod(v)[1]) - if not badges.mod_set[m.id] then - table.insert(mods, m) - badges.mod_set[m.id] = true - end - end - end - for i, mod in ipairs(mods) do - local mod_name = string.sub(mod.display_name, 1, 20) - local size = 0.9 - local font = G.LANG.font - local max_text_width = 2 - 2*0.05 - 4*0.03*size - 2*0.03 - local calced_text_width = 0 - -- Math reproduced from DynaText:update_text - for _, c in utf8.chars(mod_name) do - local tx = font.FONT:getWidth(c)*(0.33*size)*G.TILESCALE*font.FONTSCALE + 2.7*1*G.TILESCALE*font.FONTSCALE - calced_text_width = calced_text_width + tx/(G.TILESIZE*G.TILESCALE) - end - local scale_fac = - calced_text_width > max_text_width and max_text_width/calced_text_width - or 1 - badges[#badges + 1] = {n=G.UIT.R, config={align = "cm"}, nodes={ - {n=G.UIT.R, config={align = "cm", colour = mod.badge_colour or G.C.GREEN, r = 0.1, minw = 2, minh = 0.36, emboss = 0.05, padding = 0.03*size}, nodes={ - {n=G.UIT.B, config={h=0.1,w=0.03}}, - {n=G.UIT.O, config={object = DynaText({string = mod_name or 'ERROR', colours = {mod.badge_text_colour or G.C.WHITE},float = true, shadow = true, offset_y = -0.05, silent = true, spacing = 1*scale_fac, scale = 0.33*size*scale_fac})}}, - {n=G.UIT.B, config={h=0.1,w=0.03}}, - }} - }} - end - end -end - -function SMODS.create_loc_dump() - local _old, _new = SMODS.dump_loc.pre_inject, G.localization - local _dump = {} - local function recurse(old, new, dump) - for k, _ in pairs(new) do - if type(new[k]) == 'table' then - dump[k] = {} - if not old[k] then - dump[k] = new[k] - else - recurse(old[k], new[k], dump[k]) - end - elseif old[k] ~= new[k] then - dump[k] = new[k] - end - end - end - recurse(_old, _new, _dump) - local function cleanup(dump) - for k, v in pairs(dump) do - if type(v) == 'table' then - cleanup(v) - if not next(v) then dump[k] = nil end - end - end - end - cleanup(_dump) - local str = 'return ' .. serialize(_dump) - NFS.createDirectory(SMODS.dump_loc.path..'localization/') - NFS.write(SMODS.dump_loc.path..'localization/dump.lua', str) -end - --- Serializes an input table in valid Lua syntax --- Keys must be of type number or string --- Values must be of type number, boolean, string or table -function serialize(t, indent) - indent = indent or '' - local str = '{\n' - for k, v in ipairs(t) do - str = str .. indent .. '\t' - if type(v) == 'number' then - str = str .. v - elseif type(v) == 'boolean' then - str = str .. (v and 'true' or 'false') - elseif type(v) == 'string' then - str = str .. serialize_string(v) - elseif type(v) == 'table' then - str = str .. serialize(v, indent .. '\t') - else - -- not serializable - str = str .. 'nil' - end - str = str .. ',\n' - end - for k, v in pairs(t) do - if type(k) == 'string' then - str = str .. indent .. '\t' .. '[' .. serialize_string(k) .. '] = ' - - if type(v) == 'number' then - str = str .. v - elseif type(v) == 'boolean' then - str = str .. (v and 'true' or 'false') - elseif type(v) == 'string' then - str = str .. serialize_string(v) - elseif type(v) == 'table' then - str = str .. serialize(v, indent .. '\t') - else - -- not serializable - str = str .. 'nil' - end - str = str .. ',\n' - end - end - str = str .. indent .. '}' - return str -end - -function serialize_string(s) - return string.format("%q", s) -end - --- Starting with `t`, insert any key-value pairs from `defaults` that don't already --- exist in `t` into `t`. Modifies `t`. --- Returns `t`, the result of the merge. --- --- `nil` inputs count as {}; `false` inputs count as a table where --- every possible key maps to `false`. Therefore, --- * `t == nil` is weak and falls back to `defaults` --- * `t == false` explicitly ignores `defaults` --- (This function might not return a table, due to the above) -function SMODS.merge_defaults(t, defaults) - if t == false then return false end - if defaults == false then return false end - - -- Add in the keys from `defaults`, returning a table - if defaults == nil then return t end - if t == nil then t = {} end - for k, v in pairs(defaults) do - if t[k] == nil then - t[k] = v - end - end - return t -end -V_MT = { - __eq = function(a, b) - local minorWildcard = a.minor == -2 or b.minor == -2 - local patchWildcard = a.patch == -2 or b.patch == -2 - local betaWildcard = a.rev == '~' or b.rev == '~' - return a.major == b.major and - (a.minor == b.minor or minorWildcard) and - (a.patch == b.patch or minorWildcard or patchWildcard) and - (a.rev == b.rev or minorWildcard or patchWildcard or betaWildcard) and - (betaWildcard or a.beta == b.beta) - end, - __le = function(a, b) - local b = { - major = b.major + (b.minor == -2 and 1 or 0), - minor = b.minor == -2 and 0 or (b.minor + (b.patch == -2 and 1 or 0)), - patch = b.patch == -2 and 0 or b.patch, - beta = b.beta, - rev = b.rev, - } - if a.major ~= b.major then return a.major < b.major end - if a.minor ~= b.minor then return a.minor < b.minor end - if a.patch ~= b.patch then return a.patch < b.patch end - if a.beta ~= b.beta then return a.beta < b.beta end - return a.rev <= b.rev - end, - __lt = function(a, b) - return a <= b and not (a == b) - end, - __call = function(_, str) - str = str or '0.0.0' - local _, _, major, minorFull, minor, patchFull, patch, rev = string.find(str, '^(%d+)(%.?([%d%*]*))(%.?([%d%*]*))(.*)$') - local minorWildcard = string.match(minor, '%*') - local patchWildcard = string.match(patch, '%*') - if (minorFull ~= "" and minor == "") or (patchFull ~= "" and patch == "") then - sendWarnMessage('Trailing dot found in version "' .. str .. '".') - major, minor, patch = -1, 0, 0 - end - local t = { - major = tonumber(major), - minor = minorWildcard and -2 or tonumber(minor) or 0, - patch = patchWildcard and -2 or tonumber(patch) or 0, - rev = rev or '', - beta = rev and rev:sub(1,1) == '~' and -1 or 0 - } - return setmetatable(t, V_MT) - end -} -V = setmetatable({}, V_MT) -V_MT.__index = V -function V.is_valid(v, allow_wildcard) - if getmetatable(v) ~= V_MT then return false end - return(pcall(function() return V() <= v and (allow_wildcard or (v.minor ~= -2 and v.patch ~= -2 and v.rev ~= '~')) end)) -end - --- Flatten the given arrays of arrays into one, then --- add elements of each table to a new table in order, --- skipping any duplicates. -function SMODS.merge_lists(...) - local t = {} - for _, v in ipairs({...}) do - for _, vv in ipairs(v) do - table.insert(t, vv) - end - end - local ret = {} - local seen = {} - for _, li in ipairs(t) do - assert(type(li) == 'table') - for _, v in ipairs(li) do - if not seen[v] then - ret[#ret+1] = v - seen[v] = true - end - end - end - return ret -end - ---#region Number formatting - -function round_number(num, precision) - precision = 10^(precision or 0) - - return math.floor(num * precision + 0.4999999999999994) / precision -end - --- Formatting util for UI elements (look number_formatting.toml) -function format_ui_value(value) - if type(value) ~= "number" then - return tostring(value) - end - - return number_format(value, 1000000) -end - ---#endregion - - -function SMODS.poll_seal(args) - args = args or {} - local key = args.key or 'stdseal' - local mod = args.mod or 1 - local guaranteed = args.guaranteed or false - local options = args.options or get_current_pool("Seal") - local type_key = args.type_key or key.."type"..G.GAME.round_resets.ante - key = key..G.GAME.round_resets.ante - - local available_seals = {} - local total_weight = 0 - for _, v in ipairs(options) do - if v ~= "UNAVAILABLE" then - local seal_option = {} - if type(v) == 'string' then - assert(G.P_SEALS[v]) - seal_option = { key = v, weight = G.P_SEALS[v].weight or 5 } -- default weight set to 5 to replicate base game weighting - elseif type(v) == 'table' then - assert(G.P_SEALS[v.key]) - seal_option = { key = v.key, weight = v.weight } - end - if seal_option.weight > 0 then - table.insert(available_seals, seal_option) - total_weight = total_weight + seal_option.weight - end - end - end - total_weight = total_weight + (total_weight / 2 * 98) -- set base rate to 2% - - local type_weight = 0 -- modified weight total - for _,v in ipairs(available_seals) do - v.weight = G.P_SEALS[v.key].get_weight and G.P_SEALS[v.key]:get_weight() or v.weight - type_weight = type_weight + v.weight - end - - local seal_poll = pseudorandom(pseudoseed(key or 'stdseal'..G.GAME.round_resets.ante)) - if seal_poll > 1 - (type_weight*mod / total_weight) or guaranteed then -- is a seal generated - local seal_type_poll = pseudorandom(pseudoseed(type_key)) -- which seal is generated - local weight_i = 0 - for k, v in ipairs(available_seals) do - weight_i = weight_i + v.weight - if seal_type_poll > 1 - (weight_i / type_weight) then - return v.key - end - end - end -end - -function SMODS.get_blind_amount(ante) - local scale = G.GAME.modifiers.scaling - local amounts = { - 300, - 700 + 100*scale, - 1400 + 600*scale, - 2100 + 2900*scale, - 15000 + 5000*scale*math.log(scale), - 12000 + 8000*(scale+1)*(0.4*scale), - 10000 + 25000*(scale+1)*((scale/4)^2), - 50000 * (scale+1)^2 * (scale/7)^2 - } - - if ante < 1 then return 100 end - if ante <= 8 then return amounts[ante] - amounts[ante]%(10^math.floor(math.log10(amounts[ante])-1)) end - local a, b, c, d = amounts[8], amounts[8]/amounts[7], ante-8, 1 + 0.2*(ante-8) - local amount = math.floor(a*(b + (b*0.75*c)^d)^c) - amount = amount - amount%(10^math.floor(math.log10(amount)-1)) - return amount -end - -function SMODS.stake_from_index(index) - local stake = G.P_CENTER_POOLS.Stake[index] or nil - if not stake then return "error" end - return stake.key -end - -function convert_save_data() - for k, v in pairs(G.PROFILES[G.SETTINGS.profile].deck_usage) do - local first_pass = not v.wins_by_key and not v.losses_by_key - v.wins_by_key = v.wins_by_key or {} - for index, number in pairs(v.wins or {}) do - if index > 8 and not first_pass then break end - v.wins_by_key[SMODS.stake_from_index(index)] = number - end - v.losses_by_key = v.losses_by_key or {} - for index, number in pairs(v.losses or {}) do - if index > 8 and not first_pass then break end - v.losses_by_key[SMODS.stake_from_index(index)] = number - end - end - for k, v in pairs(G.PROFILES[G.SETTINGS.profile].joker_usage) do - local first_pass = not v.wins_by_key and not v.losses_by_key - v.wins_by_key = v.wins_by_key or {} - for index, number in pairs(v.wins or {}) do - if index > 8 and not first_pass then break end - v.wins_by_key[SMODS.stake_from_index(index)] = number - end - v.losses_by_key = v.losses_by_key or {} - for index, number in pairs(v.losses or {}) do - if index > 8 and not first_pass then break end - v.losses_by_key[SMODS.stake_from_index(index)] = number - end - end - G:save_settings() -end - - -function SMODS.poll_rarity(_pool_key, _rand_key) - local rarity_poll = pseudorandom(pseudoseed(_rand_key or ('rarity'..G.GAME.round_resets.ante))) -- Generate the poll value - local available_rarities = copy_table(SMODS.ObjectTypes[_pool_key].rarities) -- Table containing a list of rarities and their rates - local vanilla_rarities = {["Common"] = 1, ["Uncommon"] = 2, ["Rare"] = 3, ["Legendary"] = 4} - - -- Calculate total rates of rarities - local total_weight = 0 - for _, v in ipairs(available_rarities) do - v.mod = G.GAME[tostring(v.key):lower().."_mod"] or 1 - -- Should this fully override the v.weight calcs? - if SMODS.Rarities[v.key] and SMODS.Rarities[v.key].get_weight and type(SMODS.Rarities[v.key].get_weight) == "function" then - v.weight = SMODS.Rarities[v.key]:get_weight(v.weight, SMODS.ObjectTypes[_pool_key]) - end - v.weight = v.weight*v.mod - total_weight = total_weight + v.weight - end - -- recalculate rarities to account for v.mod - for _, v in ipairs(available_rarities) do - v.weight = v.weight / total_weight - end - - -- Calculate selected rarity - local weight_i = 0 - for _, v in ipairs(available_rarities) do - weight_i = weight_i + v.weight - if rarity_poll < weight_i then - if vanilla_rarities[v.key] then - return vanilla_rarities[v.key] - else - return v.key - end - end - end - return nil -end - -function SMODS.poll_enhancement(args) - args = args or {} - local key = args.key or 'std_enhance' - local mod = args.mod or 1 - local guaranteed = args.guaranteed or false - local options = args.options or get_current_pool("Enhanced") - if args.no_replace then - for i, k in pairs(options) do - if G.P_CENTERS[k] and G.P_CENTERS[k].replace_base_card then - options[i] = 'UNAVAILABLE' - end - end - end - local type_key = args.type_key or key.."type"..G.GAME.round_resets.ante - key = key..G.GAME.round_resets.ante - - local available_enhancements = {} - local total_weight = 0 - for _, v in ipairs(options) do - if v ~= "UNAVAILABLE" then - local enhance_option = {} - if type(v) == 'string' then - assert(G.P_CENTERS[v]) - enhance_option = { key = v, weight = G.P_CENTERS[v].weight or 5 } -- default weight set to 5 to replicate base game weighting - elseif type(v) == 'table' then - assert(G.P_CENTERS[v.key]) - enhance_option = { key = v.key, weight = v.weight } - end - if enhance_option.weight > 0 then - table.insert(available_enhancements, enhance_option) - total_weight = total_weight + enhance_option.weight - end - end - end - total_weight = total_weight + (total_weight / 40 * 60) -- set base rate to 40% - - local type_weight = 0 -- modified weight total - for _,v in ipairs(available_enhancements) do - v.weight = G.P_CENTERS[v.key].get_weight and G.P_CENTERS[v.key]:get_weight() or v.weight - type_weight = type_weight + v.weight - end - - local enhance_poll = pseudorandom(pseudoseed(key)) - if enhance_poll > 1 - (type_weight*mod / total_weight) or guaranteed then -- is an enhancement selected - local seal_type_poll = pseudorandom(pseudoseed(type_key)) -- which enhancement is selected - local weight_i = 0 - for k, v in ipairs(available_enhancements) do - weight_i = weight_i + v.weight - if seal_type_poll > 1 - (weight_i / type_weight) then - return v.key - end - end - end -end - -function time(func, ...) - local start_time = love.timer.getTime() - func(...) - local end_time = love.timer.getTime() - return 1000*(end_time-start_time) -end - -function Card:add_sticker(sticker, bypass_check) - local sticker = SMODS.Stickers[sticker] - if bypass_check or (sticker and sticker.should_apply and type(sticker.should_apply) == 'function' and sticker:should_apply(self, self.config.center, self.area, true)) then - sticker:apply(self, true) - end -end - -function Card:remove_sticker(sticker) - if self.ability[sticker] then - SMODS.Stickers[sticker]:apply(self, false) - end -end - - -function Card:calculate_sticker(context, key) - local sticker = SMODS.Stickers[key] - if self.ability[key] and type(sticker.calculate) == 'function' then - local o = sticker:calculate(self, context) - if o then - if not o.card then o.card = self end - return o - end - end -end - -function Card:calculate_enhancement(context) - if self.debuff or self.ability.set ~= 'Enhanced' then return nil end - local center = self.config.center - if center.calculate and type(center.calculate) == 'function' then - local o = center:calculate(self, context) - if o then - if not o.card then o.card = self end - return o - end - end -end - -function SMODS.get_enhancements(card, extra_only) - if not SMODS.optional_features.quantum_enhancements or not G.hand then - return not extra_only and card.ability.set == 'Enhanced' and { [card.config.center.key] = true } or {} - end - if card.extra_enhancements and next(card.extra_enhancements) then - if extra_only then - local extras = copy_table(card.extra_enhancements) - extras[card.config.center.key] = nil - return extras - end - return card.extra_enhancements - end - local enhancements = {} - if card.config.center.key ~= "c_base" and not extra_only then - enhancements[card.config.center.key] = true - end - local calc_return = {} - SMODS.calculate_context({other_card = card, check_enhancement = true, no_blueprint = true}, calc_return) - for _, eval in pairs(calc_return) do - for key, eval2 in pairs(eval) do - if type(eval2) == 'table' then - for key2, _ in pairs(eval2) do - if G.P_CENTERS[key2] then enhancements[key2] = true end - end - else - if G.P_CENTERS[key] then enhancements[key] = true end - end - end - end - - if extra_only and enhancements[card.config.center.key] then - enhancements[card.config.center.key] = nil - end - if next(enhancements) then card.extra_enhancements = enhancements end - return enhancements -end - -function SMODS.has_enhancement(card, key) - if card.config.center.key == key then return true end - card.extra_enhancements = nil - local enhancements = SMODS.get_enhancements(card) - if enhancements[key] then return true end - return false -end - -function SMODS.shatters(card) - card.extra_enhancements = nil - local enhancements = SMODS.get_enhancements(card) - for key, _ in pairs(enhancements) do - if G.P_CENTERS[key].shatters or key == 'm_glass' then return true end - end -end - -function SMODS.calculate_quantum_enhancements(card, effects, context) - if not SMODS.optional_features.quantum_enhancements then return end - context.extra_enhancement = true - local extra_enhancements = SMODS.get_enhancements(card, true) - local old_ability = copy_table(card.ability) - local old_center = card.config.center - local old_center_key = card.config.center_key - for k, _ in pairs(extra_enhancements) do - if G.P_CENTERS[k] then - card:set_ability(G.P_CENTERS[k]) - card.ability.extra_enhancement = k - local eval = eval_card(card, context) - table.insert(effects, 1, eval) - end - end - card.ability = old_ability - card.config.center = old_center - card.config.center_key = old_center_key - card:set_sprites(old_center) - context.extra_enhancement = nil -end - -function SMODS.has_no_suit(card) - local is_stone = false - local is_wild = false - card.extra_enhancements = nil - for k, _ in pairs(SMODS.get_enhancements(card)) do - if k == 'm_stone' or G.P_CENTERS[k].no_suit then is_stone = true end - if k == 'm_wild' or G.P_CENTERS[k].any_suit then is_wild = true end - end - return is_stone and not is_wild -end -function SMODS.has_any_suit(card) - card.extra_enhancements = nil - for k, _ in pairs(SMODS.get_enhancements(card)) do - if k == 'm_wild' or G.P_CENTERS[k].any_suit then return true end - end -end -function SMODS.has_no_rank(card) - card.extra_enhancements = nil - for k, _ in pairs(SMODS.get_enhancements(card)) do - if k == 'm_stone' or G.P_CENTERS[k].no_rank then return true end - end -end -function SMODS.always_scores(card) - card.extra_enhancements = nil - for k, _ in pairs(SMODS.get_enhancements(card)) do - if k == 'm_stone' or G.P_CENTERS[k].always_scores then return true end - end - if (G.P_CENTERS[(card.edition or {}).key] or {}).always_scores then return true end - if (G.P_SEALS[card.seal or {}] or {}).always_scores then return true end - for k, v in pairs(SMODS.Stickers) do - if v.always_scores and card.ability[k] then return true end - end -end - -SMODS.collection_pool = function(_base_pool) - local pool = {} - if type(_base_pool) ~= 'table' then return pool end - local is_array = _base_pool[1] - local ipairs = is_array and ipairs or pairs - for _, v in ipairs(_base_pool) do - if (not G.ACTIVE_MOD_UI or v.mod == G.ACTIVE_MOD_UI) and not v.no_collection then - pool[#pool+1] = v - end - end - if not is_array then table.sort(pool, function(a,b) return a.order < b.order end) end - return pool -end - -SMODS.find_mod = function(id) - local ret = {} - local mod = SMODS.Mods[id] or {} - if mod.can_load then ret[#ret+1] = mod end - for _,v in ipairs(SMODS.provided_mods[id] or {}) do - if v.mod.can_load then ret[#ret+1] = v.mod end - end - return ret -end - -local function bufferCardLimitForSmallDS(cards, scaleFactor) - local cardCount = #cards - if type(scaleFactor) ~= "number" or scaleFactor <= 0 then - sendWarnMessage("scaleFactor must be a positive number") - return cardCount - end - -- Ensure card_limit is always at least the number of cards - G.cdds_cards.config.card_limit = math.max(G.cdds_cards.config.card_limit, cardCount) - -- Calculate the buffer size dynamically based on the scale factor - local buffer = 0 - if cardCount < G.cdds_cards.rankCount then - -- Buffer decreases as cardCount approaches G.cdds_cards.rankCount, modulated by scaleFactor - buffer = math.ceil(((G.cdds_cards.rankCount - cardCount) / scaleFactor)) - end - G.cdds_cards.config.card_limit = math.max(cardCount, cardCount + buffer) - - return G.cdds_cards.config.card_limit -end - -G.FUNCS.update_collab_cards = function(key, suit, silent) - if type(key) == "number" then - key = G.COLLABS.options[suit][key] - end - if not G.cdds_cards then return end - local cards = {} - local cards_order = {} - local deckskin = SMODS.DeckSkins[key] - local palette = deckskin.palette_map and deckskin.palette_map[G.SETTINGS.colour_palettes[suit] or ''] or (deckskin.palettes or {})[1] - local suit_data = SMODS.Suits[suit] - local d_ranks = (palette and (palette.display_ranks or palette.ranks)) or deckskin.display_ranks or deckskin.ranks - if deckskin.outdated then - local reversed = {} - for i = #d_ranks, 1, -1 do - table.insert(reversed, d_ranks[i]) - end - d_ranks = reversed - end - - local diff_order - if #G.cdds_cards.cards ~= #d_ranks then - diff_order = true - else - for i,v in ipairs(G.cdds_cards.cards) do - if v.config.card_key ~= suit_data.card_key..'_'..SMODS.Ranks[d_ranks[i]].card_key then - diff_order = true - break - end - end - end - - if diff_order then - for i = #G.cdds_cards.cards, 1, -1 do - G.cdds_cards:remove_card(G.cdds_cards.cards[i]):remove() - end - for i, r in ipairs(d_ranks) do - local rank = SMODS.Ranks[r] - local card_code = suit_data.card_key .. '_' .. rank.card_key - cards_order[#cards_order+1] = card_code - local card = Card(G.cdds_cards.T.x+G.cdds_cards.T.w/2, G.cdds_cards.T.y+G.cdds_cards.T.h/2, G.CARD_W*1.2, G.CARD_H*1.2, G.P_CARDS[card_code], G.P_CENTERS.c_base) - -- Instead of no ui it would be nice to pass info queue to this so that artist credits can be done? - card.no_ui = true - - G.cdds_cards:emplace(card) - end - end - G.cdds_cards.config.card_limit = bufferCardLimitForSmallDS(cards, 2.5) -end - -G.FUNCS.update_suit_colours = function(suit, skin, palette_num) - skin = skin and SMODS.DeckSkins[skin] or nil - local new_colour_proto = G.C.SO_1[suit] - if G.SETTINGS.colour_palettes[suit] == 'lc' or G.SETTINGS.colour_palettes[suit] == 'hc' then - new_colour_proto = G.C["SO_"..((G.SETTINGS.colour_palettes[suit] == 'hc' and 2) or (G.SETTINGS.colour_palettes[suit] == 'lc' and 1))][suit] - end - if skin and not skin.outdated then - local palette = (palette_num and skin.palettes[palette_num]) or skin.palette_map and skin.palette_map[G.SETTINGS.colour_palettes[suit] or ''] - new_colour_proto = palette and palette.colour or new_colour_proto - end - G.C.SUITS[suit] = new_colour_proto -end - --- This function handles the calculation of each effect returned to evaluate play. --- Can easily be hooked to add more calculation effects ala Talisman -SMODS.calculate_individual_effect = function(effect, scored_card, key, amount, from_edition) - if effect.card and effect.card ~= scored_card then juice_card(effect.card) end - if (key == 'chips' or key == 'h_chips' or key == 'chip_mod') and amount then - hand_chips = mod_chips(hand_chips + amount) - update_hand_text({delay = 0}, {chips = hand_chips, mult = mult}) - if not effect.remove_default_message then - if from_edition then - card_eval_status_text(scored_card, 'jokers', nil, percent, nil, {message = localize{type = 'variable', key = amount > 0 and 'a_chips' or 'a_chips_minus', vars = {amount}}, chip_mod = amount, colour = G.C.EDITION, edition = true}) - else - if key ~= 'chip_mod' then - if effect.chip_message then - card_eval_status_text(scored_card or effect.card or effect.focus, 'extra', nil, percent, nil, effect.chip_message) - else - card_eval_status_text(scored_card or effect.card or effect.focus, 'chips', amount, percent) - end - end - end - end - return true - end - - if (key == 'mult' or key == 'h_mult' or key == 'mult_mod') and amount then - mult = mod_mult(mult + amount) - update_hand_text({delay = 0}, {chips = hand_chips, mult = mult}) - if not effect.remove_default_message then - if from_edition then - card_eval_status_text(scored_card, 'jokers', nil, percent, nil, {message = localize{type = 'variable', key = amount > 0 and 'a_mult' or 'a_mult_minus', vars = {amount}}, mult_mod = amount, colour = G.C.DARK_EDITION, edition = true}) - else - if key ~= 'mult_mod' then - if effect.mult_message then - card_eval_status_text(scored_card or effect.card or effect.focus, 'extra', nil, percent, nil, effect.mult_message) - else - card_eval_status_text(scored_card or effect.card or effect.focus, 'mult', amount, percent) - end - end - end - end - return true - end - - if (key == 'p_dollars' or key == 'dollars' or key == 'h_dollars') and amount then - ease_dollars(amount) - if not effect.remove_default_message then - if effect.dollar_message then - card_eval_status_text(scored_card or effect.card or effect.focus, 'extra', nil, percent, nil, effect.dollar_message) - else - card_eval_status_text(scored_card or effect.card or effect.focus, 'dollars', amount, percent) - end - end - return true - end - - if (key == 'x_chips' or key == 'xchips' or key == 'Xchip_mod') and amount ~= 1 then - hand_chips = mod_chips(hand_chips * amount) - update_hand_text({delay = 0}, {chips = hand_chips, mult = mult}) - if not effect.remove_default_message then - if from_edition then - card_eval_status_text(scored_card, 'jokers', nil, percent, nil, {message = localize{type='variable',key= amount > 0 and 'a_xchips' or 'a_xchips_minus',vars={amount}}, Xchips_mod = amount, colour = G.C.EDITION, edition = true}) - else - if key ~= 'Xchip_mod' then - if effect.xchip_message then - card_eval_status_text(scored_card or effect.card or effect.focus, 'extra', nil, percent, nil, effect.xchip_message) - else - card_eval_status_text(scored_card or effect.card or effect.focus, 'x_chips', amount, percent) - end - end - end - end - return true - end - - if (key == 'x_mult' or key == 'xmult' or key == 'Xmult' or key == 'x_mult_mod' or key == 'Xmult_mod') and amount ~= 1 then - mult = mod_mult(mult * amount) - update_hand_text({delay = 0}, {chips = hand_chips, mult = mult}) - if not effect.remove_default_message then - if from_edition then - card_eval_status_text(scored_card, 'jokers', nil, percent, nil, {message = localize{type='variable',key= amount > 0 and 'a_xmult' or 'a_xmult_minus',vars={amount}}, Xmult_mod = amount, colour = G.C.EDITION, edition = true}) - else - if key ~= 'Xmult_mod' then - if effect.xmult_message then - card_eval_status_text(scored_card or effect.card or effect.focus, 'extra', nil, percent, nil, effect.xmult_message) - else - card_eval_status_text(scored_card or effect.card or effect.focus, 'x_mult', amount, percent) - end - end - end - end - return true - end - - if key == 'message' then - card_eval_status_text(effect.message_card or effect.juice_card or scored_card or effect.card or effect.focus, 'extra', nil, percent, nil, effect) - return true - end - - if key == 'func' then - effect.func() - return true - end - - if key == 'swap' then - local old_mult = mult - mult = mod_mult(hand_chips) - hand_chips = mod_chips(old_mult) - update_hand_text({delay = 0}, {chips = hand_chips, mult = mult}) - return true - end - - if key == 'level_up' then - level_up_hand(scored_card, G.GAME.last_hand_played, effect.instant, type(amount) == 'number' and amount or 1) - return true - end - - if key == 'extra' then - return SMODS.calculate_effect(amount, scored_card) - end - - if key == 'saved' then - SMODS.saved = amount - return true - end -end - --- Used to calculate a table of effects generated in evaluate_play -SMODS.trigger_effects = function(effects, card) - for i, effect_table in ipairs(effects) do - for key, effect in pairs(effect_table) do - if key ~= 'smods' then - if type(effect) == 'table' then - local calc = SMODS.calculate_effect(effect, card, key == 'edition') - if calc then effects.calculated = true end - end - end - end - end -end - -SMODS.calculate_effect = function(effect, scored_card, from_edition, pre_jokers) - local calculated = false - for _, key in ipairs(SMODS.calculation_keys) do - if effect[key] then - if effect.juice_card then G.E_MANAGER:add_event(Event({trigger = 'immediate', func = function () effect.juice_card:juice_up(0.1); scored_card:juice_up(0.1); return true end})) end - calculated = SMODS.calculate_individual_effect(effect, scored_card, key, effect[key], from_edition, pre_jokers) - percent = (percent or 0) + (percent_delta or 0.08) - end - end - if effect.effect then calculated = true end - if effect.remove then calculated = true end - return calculated -end - -SMODS.calculation_keys = { - 'chips', 'h_chips', 'chip_mod', - 'mult', 'h_mult', 'mult_mod', - 'x_chips', 'xchips', 'Xchip_mod', - 'x_mult', 'Xmult', 'xmult', 'x_mult_mod', 'Xmult_mod', - 'p_dollars', 'dollars', 'h_dollars', - 'swap', - 'message', - 'level_up', 'func', 'extra', - 'saved' -} - -SMODS.calculate_repetitions = function(card, context, reps) - -- From the card - context.repetition_only = true - local eval = eval_card(card, context) - for key, value in pairs(eval) do - if value.repetitions then - for h=1, value.repetitions do - value.card = value.card or card - value.message = value.message or (not value.remove_default_message and localize('k_again_ex')) - reps[#reps+1] = {key = value} - end - end - end - context.repetition_only = false - --From jokers - for _, area in ipairs(SMODS.get_card_areas('jokers')) do - for _, _card in ipairs(area.cards) do - --calculate the joker effects - local eval, post = eval_card(_card, context) - if next(post) then SMODS.trigger_effects({post}, card) end - local rt = eval and eval.retriggers and #eval.retriggers or 0 - for key, value in pairs(eval) do - if value.repetitions and key ~= 'retriggers' then - - for h=1, value.repetitions do - value.card = value.card or _card - value.message = value.message or (not value.remove_default_message and localize('k_again_ex')) - reps[#reps+1] = {key = value} - for i=1, rt do - local rt_eval, rt_post = eval_card(_card, context) - rt_eval.card = rt_eval.card or _card - reps[#reps+1] = {key = value} - if next(rt_post) then SMODS.trigger_effects({rt_post}, card) end - end - end - end - end - end - end - local effect = G.GAME.selected_back:trigger_effect(context) - if effect and effect.repetitions then - for h=1, effect.repetitions do - effect.card = effect.card or G.deck.cards[1] or G.deck - reps[#reps+1] = {key = effect} - end - end - return reps -end - -SMODS.calculate_retriggers = function(card, context, _ret) - local retriggers = {} - if not SMODS.optional_features.retrigger_joker then return retriggers end - for _, area in ipairs(SMODS.get_card_areas('jokers')) do - for _, _card in ipairs(area.cards) do - local eval, post = eval_card(_card, {retrigger_joker_check = true, other_card = card, other_context = context, other_ret = _ret}) - if next(post) then SMODS.trigger_effects({post}, _card) end - for key, value in pairs(eval) do - if value.repetitions then - for h=1, value.repetitions do - value.retrigger_card = _card - value.message = value.message or (not value.remove_default_message and localize('k_again_ex')) - retriggers[#retriggers + 1] = value - end - end - end - end - end - return retriggers -end - -function Card:calculate_edition(context) - if self.debuff then return end - if self.edition then - local edition = G.P_CENTERS[self.edition.key] - if edition.calculate and type(edition.calculate) == 'function' then - local o = edition:calculate(self, context) - if o then - if not o.card then o.card = self end - return o - end - end - end -end - --- Used to calculate contexts across G.jokers, scoring_hand (if present), G.play and G.GAME.selected_back --- Hook this function to add different areas to MOST calculations -function SMODS.calculate_context(context, return_table) - context.cardarea = G.jokers - context.main_eval = true - for _, area in ipairs(SMODS.get_card_areas('jokers')) do - for _, _card in ipairs(area.cards) do - --calculate the joker effects - local eval, post = eval_card(_card, context) - local effects = {eval} - for _,v in ipairs(post) do effects[#effects+1] = v end - - if context.other_joker then - for k, v in pairs(effects[1]) do - v.other_card = _card - end - end - if effects[1].retriggers then - context.retrigger_joker = true - for rt = 1, #effects[1].retriggers do - context.retrigger_joker = effects[1].retriggers[rt].retrigger_card - local rt_eval, rt_post = eval_card(_card, context) - table.insert(effects, {effects[1].retriggers[rt]}) - table.insert(effects, rt_eval) - for _,v in ipairs(rt_post) do effects[#effects+1] = v end - end - context.retrigger_joker = false - end - if return_table then - for _,v in ipairs(effects) do - if v.jokers and not v.jokers.card then v.jokers.card = _card end - return_table[#return_table+1] = v - end - else - SMODS.trigger_effects(effects, _card) - end - end - end - context.main_eval = nil - if context.scoring_hand then - context.cardarea = G.play - for i=1, #context.scoring_hand do - --calculate the played card effects - if return_table then - return_table[#return_table+1] = eval_card(context.scoring_hand[i], context) - SMODS.calculate_quantum_enhancements(context.scoring_hand[i], return_table, context) - else - local effects = {eval_card(context.scoring_hand[i], context)} - SMODS.calculate_quantum_enhancements(context.scoring_hand[i], effects, context) - SMODS.trigger_effects(effects, context.scoring_hand[i]) - end - end - end - context.cardarea = G.hand - for i=1, #G.hand.cards do - --calculate the held card effects - if return_table then - return_table[#return_table+1] = eval_card(G.hand.cards[i], context) - else - local effects = {eval_card(G.hand.cards[i], context)} - SMODS.calculate_quantum_enhancements(G.hand.cards[i], effects, context) - SMODS.trigger_effects(effects, G.hand.cards[i]) - end - end - if SMODS.optional_features.cardareas.deck then - context.cardarea = G.deck - for i=1, #G.deck.cards do - --calculate the held card effects - if return_table then - return_table[#return_table+1] = eval_card(G.deck.cards[i], context) - else - local effects = {eval_card(G.deck.cards[i], context)} - SMODS.calculate_quantum_enhancements(G.deck.cards[i], effects, context) - SMODS.trigger_effects(effects, G.deck.cards[i]) - end - end - end - if SMODS.optional_features.cardareas.discard then - context.cardarea = G.discard - for i=1, #G.discard.cards do - --calculate the held card effects - if return_table then - return_table[#return_table+1] = eval_card(G.discard.cards[i], context) - else - local effects = {eval_card(G.discard.cards[i], context)} - SMODS.calculate_quantum_enhancements(G.discard.cards[i], effects, context) - SMODS.trigger_effects(effects, G.discard.cards[i]) - end - end - end - local effect = G.GAME.selected_back:trigger_effect(context) - if effect then SMODS.calculate_effect(effect, G.deck.cards[1] or G.deck) end -end - -function SMODS.score_card(card, context) - local reps = { 1 } - local j = 1 - while j <= #reps do - if reps[j] ~= 1 then - local _, eff = next(reps[j]) - SMODS.calculate_effect(eff, eff.card) - percent = percent + percent_delta - end - - context.main_scoring = true - local effects = { eval_card(card, context) } - SMODS.calculate_quantum_enhancements(card, effects, context) - context.main_scoring = nil - context.individual = true - context.other_card = card - - if next(effects) then - for _, area in ipairs(SMODS.get_card_areas('jokers')) do - for _, _card in ipairs(area.cards) do - --calculate the joker individual card effects - local eval, post = eval_card(_card, context) - if next(eval) then - if eval.jokers then eval.jokers.juice_card = eval.jokers.juice_card or eval.jokers.card or _card end - table.insert(effects, eval) - for _, v in ipairs(post) do effects[#effects+1] = v end - if eval.retriggers then - context.retrigger_joker = true - for rt = 1, #eval.retriggers do - local rt_eval, rt_post = eval_card(_card, context) - table.insert(effects, { eval.retriggers[rt] }) - table.insert(effects, rt_eval) - for _, v in ipairs(rt_post) do effects[#effects+1] = v end - end - context.retrigger_joker = nil - end - end - end - end - end - - SMODS.trigger_effects(effects, card) - local deck_effect = G.GAME.selected_back:trigger_effect(context) - if deck_effect then SMODS.calculate_effect(deck_effect, G.deck.cards[1] or G.deck) end - - context.individual = nil - if reps[j] == 1 and effects.calculated then - context.repetition = true - context.card_effects = effects - SMODS.calculate_repetitions(card, context, reps) - context.repetition = nil - context.card_effects = nil - end - j = j + (effects.calculated and 1 or #reps) - context.other_card = nil - card.lucky_trigger = nil - end - card.extra_enhancements = nil -end - -function SMODS.calculate_main_scoring(context, scoring_hand) - for _, card in ipairs(scoring_hand or context.cardarea.cards) do - --add cards played to list - if scoring_hand and not SMODS.has_no_rank(card) then - G.GAME.cards_played[card.base.value].total = G.GAME.cards_played[card.base.value].total + 1 - if not SMODS.has_no_suit(card) then - G.GAME.cards_played[card.base.value].suits[card.base.suit] = true - end - end - --if card is debuffed - if scoring_hand and card.debuff then - G.GAME.blind.triggered = true - G.E_MANAGER:add_event(Event({ - trigger = 'immediate', - func = (function() SMODS.juice_up_blind();return true end) - })) - card_eval_status_text(card, 'debuff') - else - SMODS.score_card(card, context) - end - end -end - -function SMODS.calculate_end_of_round_effects(context) - for i, card in ipairs(context.cardarea.cards) do - local reps = {1} - local j = 1 - while j <= #reps do - percent = (i-0.999)/(#context.cardarea.cards-0.998) + (j-1)*0.1 - if reps[j] ~= 1 then - local _, eff = next(reps[j]) - SMODS.calculate_effect(eff, eff.card) - percent = percent + 0.08 - end - - context.playing_card_end_of_round = true - --calculate the hand effects - local effects = {eval_card(card, context)} - local extra_enhancements = SMODS.get_enhancements(card, true) - local old_ability = copy_table(card.ability) - local old_center = card.config.center - local old_center_key = card.config.center_key - for k, _ in pairs(extra_enhancements) do - if G.P_CENTERS[k] then - card:set_ability(G.P_CENTERS[k]) - card.ability.extra_enhancement = k - effects[#effects+1] = eval_card(card, context) - end - end - card.ability = old_ability - card.config.center = old_center - card.config.center_key = old_center_key - card:set_sprites(old_center) - - context.playing_card_end_of_round = nil - context.individual = true - context.other_card = card - -- context.end_of_round individual calculations - for _, area in ipairs(SMODS.get_card_areas('jokers')) do - for _, _card in ipairs(area.cards) do - - local eval, post = eval_card(_card, context) - eval.juice_card = eval.card - if next(eval) then - table.insert(effects, eval) - end - for _, v in ipairs(post) do effects[#effects+1] = v end - end - end - - local deck_effect = G.GAME.selected_back:trigger_effect(context) - if deck_effect then SMODS.calculate_effect(deck_effect, G.deck.cards[1] or G.deck) end - SMODS.trigger_effects(effects, card) - - context.individual = nil - context.repetition = true - context.card_effects = effects - if reps[j] == 1 then - SMODS.calculate_repetitions(card, context, reps) - end - - context.repetition = nil - context.card_effects = nil - j = j + (effects.calculated and 1 or #reps) - - -- TARGET: effects after end of round evaluation - end - end -end - -function SMODS.calculate_destroying_cards(context, cards_destroyed, scoring_hand) - for i,card in ipairs(scoring_hand or context.cardarea.cards) do - local destroyed = nil - --un-highlight all cards - if scoring_hand then highlight_card(card,(i-0.999)/(#scoring_hand-0.998),'down') end - - -- context.destroying_card calculations - context.destroy_card = card - context.destroying_card = scoring_hand and card - for _, area in ipairs(SMODS.get_card_areas('jokers')) do - local should_break - for _, _card in ipairs(area.cards) do - local eval, post = eval_card(_card, context) - local self_destroy = false - for key, effect in pairs(eval) do - if type(effect) == 'table' then - self_destroy = SMODS.calculate_effect(effect, card) - else - self_destroy = effect - end - end - SMODS.trigger_effects({post}, card) - if self_destroy then - destroyed = true - should_break = true - break - end - end - if should_break then break end - end - - if scoring_hand and SMODS.has_enhancement(card, 'm_glass') and not card.debuff and pseudorandom('glass') < G.GAME.probabilities.normal/(card.ability.name == 'Glass Card' and card.ability.extra or G.P_CENTERS.m_glass.config.extra) then - destroyed = true - end - - local eval, post = eval_card(card, context) - local self_destroy = false - for key, effect in pairs(eval) do - self_destroy = SMODS.calculate_effect(effect, card) - end - SMODS.trigger_effects({post}, card) - if self_destroy then destroyed = true end - - -- TARGET: card destroyed - - if destroyed then - if SMODS.shatters(card) then - card.shattered = true - else - card.destroyed = true - end - cards_destroyed[#cards_destroyed+1] = card - end - end -end - -function SMODS.get_card_areas(_type, _context) - if _type == 'playing_cards' then - local t = {} - if _context ~= 'end_of_round' then t[#t+1] = G.play end - t[#t+1] = G.hand - if SMODS.optional_features.cardareas.deck then t[#t+1] = G.deck end - if SMODS.optional_features.cardareas.discard then t[#t+1] = G.discard end - -- TARGET: add your own CardAreas for playing card evaluation - return t - end - if _type == 'jokers' then - local t = {G.jokers, G.consumeables, G.vouchers} - -- TARGET: add your own CardAreas for joker evaluation - return t - end - return {} -end - -local flat_copy_table = function(tbl) - local new = {} - for i, v in pairs(tbl) do - new[i] = v - end - return new -end - ----Seatch for val anywhere deep in tbl. Return a table of finds, or the first found if immediate is provided. -SMODS.deepfind = function(tbl, val, immediate) - local seen = {[tbl] = true} - local collector = {} - local stack = { {tbl = tbl, path = {}, objpath = {}} } - - --while there are any elements to traverse - while #stack > 0 do - --pull the top off of the stack and start traversing it (by default this will be the last element of the last traversed table found in pairs) - local current = table.remove(stack) - --the current table we wish to traverse - local currentTbl = current.tbl - --the current path - local currentPath = current.path - --the current object path - local currentObjPath = current.objpath - - --for every table that we have - for i, v in pairs(currentTbl) do - --if the value matches - if v == val then - --copy our values and store it in the collector - local newPath = flat_copy_table(currentPath) - local newObjPath = flat_copy_table(currentObjPath) - table.insert(newPath, i) - table.insert(newObjPath, v) - table.insert(collector, {table = currentTbl, index = i, tree = newPath, objtree = newObjPath}) - if immediate then - return collector - end - --otherwise, if its a traversable table we havent seen yet - elseif type(v) == "table" and not seen[v] then - --make sure we dont see it again - seen[v] = true - --and then place it on the top of the stack - local newPath = flat_copy_table(currentPath) - local newObjPath = flat_copy_table(currentObjPath) - table.insert(newPath, i) - table.insert(newObjPath, v) - table.insert(stack, {tbl = v, path = newPath, objpath = newObjPath}) - end - end - end - - return collector -end - ---Seatch for val as an index anywhere deep in tbl. Return a table of finds, or the first found if immediate is provided. -SMODS.deepfindbyindex = function(tbl, val, immediate) - local seen = {[tbl] = true} - local collector = {} - local stack = { {tbl = tbl, path = {}, objpath = {}} } - - --while there are any elements to traverse - while #stack > 0 do - --pull the top off of the stack and start traversing it (by default this will be the last element of the last traversed table found in pairs) - local current = table.remove(stack) - --the current table we wish to traverse - local currentTbl = current.tbl - --the current path - local currentPath = current.path - --the current object path - local currentObjPath = current.objpath - - --for every table that we have - for i, v in pairs(currentTbl) do - --if the value matches - if i == val then - --copy our values and store it in the collector - local newPath = flat_copy_table(currentPath) - local newObjPath = flat_copy_table(currentObjPath) - table.insert(newPath, i) - table.insert(newObjPath, v) - table.insert(collector, {table = currentTbl, index = i, tree = newPath, objtree = newObjPath}) - if immediate then - return collector - end - --otherwise, if its a traversable table we havent seen yet - elseif type(v) == "table" and not seen[v] then - --make sure we dont see it again - seen[v] = true - --and then place it on the top of the stack - local newPath = flat_copy_table(currentPath) - local newObjPath = flat_copy_table(currentObjPath) - table.insert(newPath, i) - table.insert(newObjPath, v) - table.insert(stack, {tbl = v, path = newPath, objpath = newObjPath}) - end - end - end - - return collector -end - --- this is for debugging -SMODS.debug_calculation = function() - G.contexts = {} - local cj = Card.calculate_joker - function Card:calculate_joker(context) - for k,v in pairs(context) do G.contexts[k] = (G.contexts[k] or 0) + 1 end - return cj(self, context) - end -end - -local function insert(t, res) - for k,v in pairs(res) do - if type(v) == 'table' and type(t[k]) == 'table' then - insert(t[k], v) - else - t[k] = v - end - end -end -SMODS.optional_features = { - cardareas = {}, -} -SMODS.get_optional_features = function() - for _,mod in ipairs(SMODS.mod_list) do - if mod.can_load and mod.optional_features then - local opt_features = type(mod.optional_features) == 'function' and mod.optional_features() or mod.optional_features - if type(opt_features) == 'table' then - insert(SMODS.optional_features, opt_features) - end - end - end -end - -G.FUNCS.can_select_from_booster = function(e) - local area = booster_obj and booster_obj.select_card and (type(booster_obj.select_card) == 'table' and (booster_obj.select_card[e.config.ref_table.ability.set] or nil) or booster_obj.select_card) or nil - if area and #G[area].cards < G[area].config.card_limit then - e.config.colour = G.C.GREEN - e.config.button = 'use_card' - else - e.config.colour = G.C.UI.BACKGROUND_INACTIVE - e.config.button = nil - end - end \ No newline at end of file diff --git a/smods-main/tk_debug_window.py b/smods-main/tk_debug_window.py deleted file mode 100644 index e5305f5..0000000 --- a/smods-main/tk_debug_window.py +++ /dev/null @@ -1,649 +0,0 @@ -import re -import socket -import string -import threading -import tkinter as tk -from datetime import datetime -from tkinter import filedialog - -log_levels = { - "TRACE": 0, - "DEBUG": 1, - "INFO ": 2, - "WARN ": 3, - "ERROR": 4, - "FATAL": 5 -} - - -# might or might not be a copy paste from https://stackoverflow.com/a/16375233 -class TextLineNumbers(tk.Canvas): - def __init__(self, *args, **kwargs): - tk.Canvas.__init__(self, *args, **kwargs, highlightthickness=0) - self.textwidget = None - - def attach(self, text_widget): - self.textwidget = text_widget - - def redraw(self, *args): - '''redraw line numbers''' - self.delete("all") - - i = self.textwidget.index("@0,0") - while True: - dline = self.textwidget.dlineinfo(i) - if dline is None: - break - y = dline[1] - linenum = str(i).split(".")[0] - self.create_text(2, y, anchor="nw", text=linenum, fill="#606366") - i = self.textwidget.index("%s+1line" % i) - - -class CustomText(tk.Text): - def __init__(self, *args, **kwargs): - tk.Text.__init__(self, *args, **kwargs) - - # create a proxy for the underlying widget - self._orig = self._w + "_orig" - self.tk.call("rename", self._w, self._orig) - self.tk.createcommand(self._w, self._proxy) - - def _proxy(self, *args): - # let the actual widget perform the requested action - cmd = (self._orig,) + args - result = self.tk.call(cmd) - - # generate an event if something was added or deleted, - # or the cursor position changed - if (args[0] in ("insert", "replace", "delete") or - args[0:3] == ("mark", "set", "insert") or - args[0:2] == ("xview", "moveto") or - args[0:2] == ("xview", "scroll") or - args[0:2] == ("yview", "moveto") or - args[0:2] == ("yview", "scroll") - ): - self.event_generate("<>", when="tail") - - # return what the actual widget returned - return result - - -class Log: - def __init__(self, log: str): - self.parse_error = False - log_parts = log.split(" :: ") - if len(log_parts) == 4: - self.timestamp_str = log_parts[0] - self.log_level = log_parts[1] - self.logger = log_parts[2] - self.log_str = log_parts[3] - elif len(log_parts) == 3: - self.timestamp_str = datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f') - self.logger = log_parts[0] - self.log_str = log_parts[1] - self.log_str = log_parts[2] - else: - self.parse_error = True - self.timestamp_str = datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f') - self.log_level = "DEBUG" - self.logger = "DefaultLogger" - self.log_str = log - - def __str__(self): - if not self.parse_error: - return f"{self.timestamp_str} :: {self.log_level} :: {self.logger} :: {self.log_str}\n" - return f"{self.timestamp_str} :: {self.log_str}\n" - - -class PlaceholderEntry(tk.Entry): - def __init__(self, *args, placeholder="", **kwargs): - super().__init__(*args, **kwargs) - self.placeholder = placeholder - self.user_has_interacted = False - self.insert(0, self.placeholder) - self.word_pattern = re.compile(r'[\s\W]|$') - self.config(fg='grey') - self.bind('', self.on_focus_out) - self.bind('', self.on_focus_in) - self.bind('', self.handle_ctrl_backspace) - self.bind('', self.handle_ctrl_delete) - self.bind('', self.on_key_press) # Bind key press event - - def on_focus_in(self, event): - if not self.user_has_interacted and self.get() == self.placeholder: - self.delete(0, 'end') - self.config(fg='black') - - def on_focus_out(self, event): - if not self.get(): - self.insert(0, self.placeholder) - self.config(fg='grey') - self.user_has_interacted = False # Reset flag if entry is empty - else: - self.user_has_interacted = True - - def on_key_press(self, event): - self.user_has_interacted = True # User has interacted when any key is pressed - - def reset_interaction_flag(self): - self.user_has_interacted = False - - def handle_ctrl_backspace(self, event: tk.Event): - # Get the current content of the entry and the cursor position - content = self.get() - cursor_pos = self.index(tk.INSERT) - - # If the last character before the cursor is a space or punctuation, delete it - if cursor_pos > 0 and (content[cursor_pos - 1] == ' ' or content[cursor_pos - 1] in string.punctuation): - self.delete(cursor_pos - 1, tk.INSERT) - return "break" # Prevent default behavior - - # Find the start of the word to the left of the cursor - pre_cursor = content[:cursor_pos] - match = self.word_pattern.search(pre_cursor[::-1]) # [\s\W]|$ matches spaces, punctuation, or end of string - word_start = cursor_pos - match.start() if match else 0 - - # Delete the word - self.delete(word_start, cursor_pos) - return "break" # Prevent default behavior - - def handle_ctrl_delete(self, event: tk.Event): - # Get the current content of the entry and the cursor position - content = self.get() - cursor_pos = self.index(tk.INSERT) - - # If the first character after the cursor is a space or punctuation, delete it - if len(content) > cursor_pos and (content[cursor_pos] == ' ' or content[cursor_pos] in string.punctuation): - self.delete(cursor_pos, cursor_pos + 1) - return "break" # Prevent default behavior - - # Find the end of the word to the right of the cursor - post_cursor = content[cursor_pos:] - match = self.word_pattern.search(post_cursor) # [\s\W]|$ matches spaces, punctuation, or end of string - word_end = match.start() if match else len(post_cursor) - - # Delete the word - self.delete(cursor_pos, cursor_pos + word_end) - return "break" # Prevent default behavior - - -class OptionsFrame(tk.Frame): - def __init__(self, parent): - super().__init__(parent) - self.global_search_frame = GlobalSearchFrame(self, parent) - self.specific_search_frame = SpecificSearchFrame(self, parent) - self.create_widgets() - - def inject_console(self, console): - self.global_search_frame.inject_console(console) - self.specific_search_frame.inject_console(console) - - def create_widgets(self): - self.global_search_frame.pack(side=tk.TOP, fill='x', expand=True) - self.specific_search_frame.pack(side=tk.BOTTOM, fill='x', expand=True) - - -class GlobalSearchFrame(tk.Frame): - def __init__(self, parent, root): - super().__init__(parent) - - self.after_id = None - self.root = root - self.console = None - - # Global search entry - self.search_entry_placeholder = "Search" - self.search_entry_var = tk.StringVar() - self.search_entry = PlaceholderEntry( - self, - placeholder=self.search_entry_placeholder, - textvariable=self.search_entry_var - ) - self.search_entry_var.trace("w", self.on_entry_changed) - self.search_entry.bind('', lambda event: self.console.text_widget.focus()) - self.search_entry.config(fg='grey') - - self.search_modes = [] - self.search_mode_var = tk.StringVar(value='normal') - self.search_mode_var.trace("w", self.apply_search_mode) - for mode, text in [('normal', 'normal'), ('match_case', 'match case'), ('regex', 'regex')]: - self.search_modes.append(tk.Radiobutton(self, text=text, variable=self.search_mode_var, value=mode)) - - self.create_widgets() - - def apply_search_mode(self, *args): - self.console.set_filter(global_search_mode=self.search_mode_var.get()) - - def inject_console(self, console): - self.console = console - - def create_widgets(self): - self.search_entry.pack(side=tk.LEFT, fill='x', expand=True, padx=(5, 0)) - for mode in self.search_modes: - mode.pack(side=tk.LEFT, padx=(5, 0)) - self.search_entry.bind('', lambda event: self.console.next_occurrence()) - self.search_entry.bind('', lambda event: self.console.previous_occurrence()) - - def on_entry_changed(self, *args): - if self.after_id: - self.root.after_cancel(self.after_id) - self.after_id = self.root.after(300, self.apply_search_entry_var) - - def apply_search_entry_var(self): - self.console.set_filter(global_search_str=self.search_entry_var.get()) - self.after_id = None - - -class Console(tk.Frame): - def __init__(self, parent, option_frame: OptionsFrame): - super().__init__(parent) - self.global_search_mode = "normal" - self.all_logs = [] - self.shown_logs = [] - self.option_frame = option_frame - self.text_widget = CustomText(self) - self.linenumbers = TextLineNumbers(self, width=30) - self.linenumbers.attach(self.text_widget) - self.text_widget.bind("<>", self._on_change) - self.text_widget.bind("", self._on_change) - self.scrollbar = tk.Scrollbar(self, command=self.text_widget.yview) - self.global_search_str = "" - self.logger_name = "" - self.log_level = "TRACE" - self.and_above = True - self.create_widgets() - - def _on_change(self, event): - self.linenumbers.redraw() - - def create_widgets(self): - self.scrollbar.pack(side=tk.RIGHT, fill='y') - self.linenumbers.pack(side=tk.LEFT, fill="y") - self.text_widget.pack(side=tk.LEFT, expand=True, fill='both') - self.text_widget.config(yscrollcommand=self.scrollbar.set) - self.text_widget.config(state=tk.DISABLED) - - def set_filter( - self, - global_search_str: str = None, - global_search_mode: str = None, - logger_name: str = None, - log_level: str = None, - and_above: bool = None - ): - if global_search_str is not None and self.option_frame.global_search_frame.search_entry.user_has_interacted: - self.global_search_str = global_search_str - - if logger_name is not None and self.option_frame.specific_search_frame.logger_entry.user_has_interacted: - self.logger_name = logger_name - - if global_search_mode is not None: - self.global_search_mode = global_search_mode - - if log_level is not None: - self.log_level = log_level - - if and_above is not None: - self.and_above = and_above - - self.apply_filters() - - def append_log(self, log: str): - log_obj = Log(log) - self.all_logs.append(log_obj) - if self.filter_log(log_obj): - self.shown_logs.append(log_obj) - # Check if the user is at the end before appending - at_end = self.text_widget.yview()[1] == 1.0 - self.text_widget.config(state=tk.NORMAL) - self.text_widget.insert(tk.END, str(log_obj)) - self.text_widget.config(state=tk.DISABLED) - if at_end: - self.text_widget.see(tk.END) - if self.global_search_str: - self.search_text() - - def clear_logs(self): - self.text_widget.config(state=tk.NORMAL) - self.text_widget.delete('1.0', tk.END) - self.text_widget.config(state=tk.DISABLED) - self.shown_logs.clear() - self.all_logs.clear() - self.apply_filters() - - def apply_filters(self): - # Re-filter all logs and update the text widget only if necessary - filtered_logs = [log for log in self.all_logs if self.filter_log(log)] - self.shown_logs = filtered_logs - self.update_text_widget() - - def filter_log(self, log): - # print(self.global_search_str, self.global_search_mode, self.logger_name, self.log_level, self.and_above) - if self.and_above: - flag = log_levels[log.log_level] >= log_levels[self.log_level] - else: - flag = log.log_level == self.log_level - - if self.logger_name: - flag = flag and self.logger_name in log.logger - - return flag - - def update_text_widget(self): - # Preserve the current view position unless at the end - at_end = self.text_widget.yview()[1] == 1.0 - self.text_widget.config(state=tk.NORMAL) - self.text_widget.delete('1.0', tk.END) - self.text_widget.config(state=tk.DISABLED) - for log in self.shown_logs: - self.text_widget.config(state=tk.NORMAL) - self.text_widget.insert(tk.END, str(log)) - self.text_widget.config(state=tk.DISABLED) - if at_end: - self.text_widget.see(tk.END) - - if self.global_search_str: - self.search_text() - - def search_text(self): - self.text_widget.tag_remove('found', '1.0', tk.END) - search_query = self.global_search_str.strip() - if not search_query: - return - - if self.global_search_mode == 'match_case': - pattern = re.escape(search_query) - elif self.global_search_mode == 'regex': - # Directly use the user input for regex, but be cautious of Tkinter's limited regex support - pattern = search_query - else: # normal mode, make it case-insensitive - pattern = '(?i)' + re.escape(search_query) # Add (?i) for case-insensitive search in Tkinter - - start = '1.0' - while True: - match_start = self.text_widget.search(pattern, start, tk.END, regexp=True) - if not match_start: - break - match_end = f"{match_start}+{len(search_query)}c" - self.text_widget.tag_add('found', match_start, match_end) - start = match_end - - self.text_widget.tag_config('found', background='yellow') - at_end = self.text_widget.yview()[1] == 1.0 - if at_end: - first_occurrence = self.text_widget.tag_ranges('found') - if first_occurrence: - self.text_widget.see(first_occurrence[0]) - self.next_occurrence() - - def prepare_occurrence_navigation(self): - current_tags = self.text_widget.tag_ranges('found') - if not current_tags: - return None, None - - # Ensure the 'current_found' tag exists with a blue background. - self.text_widget.tag_config('current_found', background='#ADD8E6') - - # Get the current position of the cursor in the text widget. - cursor_index = self.text_widget.index(tk.INSERT) - - # Remove the 'current_found' tag from the entire text widget. - self.text_widget.tag_remove('current_found', '1.0', tk.END) - - # Convert the current cursor index to a comparable value. - cursor_line, cursor_char = map(int, cursor_index.split('.')) - - return current_tags, (cursor_line, cursor_char) - - def next_occurrence(self): - current_tags, cursor_position = self.prepare_occurrence_navigation() - if not current_tags or not cursor_position: - return - - cursor_line, cursor_char = cursor_position - - for i in range(0, len(current_tags), 2): - tag_start = current_tags[i] - tag_end = current_tags[i + 1] - - # Convert tag start index to comparable values. - tag_start_line, tag_start_char = map(int, str(tag_start).split('.')) - - # Check if the tag start is greater than the cursor position. - if tag_start_line > cursor_line or (tag_start_line == cursor_line and tag_start_char > cursor_char): - self.text_widget.mark_set(tk.INSERT, tag_start) - self.text_widget.see(tag_start) - - # Apply the 'current_found' tag to the current occurrence. - self.text_widget.tag_add('current_found', tag_start, tag_end) - break - else: - # Wrap to the first tag if no next tag is found. - self.text_widget.mark_set(tk.INSERT, str(current_tags[0])) - self.text_widget.see(str(current_tags[0])) - self.text_widget.tag_add('current_found', current_tags[0], current_tags[1]) - - def previous_occurrence(self): - current_tags, cursor_position = self.prepare_occurrence_navigation() - if not current_tags or not cursor_position: - return - - cursor_line, cursor_char = cursor_position - - for i in range(len(current_tags) - 2, -1, -2): - tag_start = current_tags[i] - tag_end = current_tags[i + 1] - - # Convert tag start index to comparable values. - tag_start_line, tag_start_char = map(int, str(tag_start).split('.')) - - # Check if the tag start is less than the cursor position. - if tag_start_line < cursor_line or (tag_start_line == cursor_line and tag_start_char < cursor_char): - self.text_widget.mark_set(tk.INSERT, tag_start) - self.text_widget.see(tag_start) - - # Apply the 'current_found' tag to the current occurrence. - self.text_widget.tag_add('current_found', tag_start, tag_end) - break - else: - # Wrap to the last tag if no previous tag is found. - self.text_widget.mark_set(tk.INSERT, str(current_tags[-2])) - self.text_widget.see(str(current_tags[-2])) - self.text_widget.tag_add('current_found', current_tags[-2], current_tags[-1]) - - -class SpecificSearchFrame(tk.Frame): - def __init__(self, parent, root): - super().__init__(parent) - self.root = root - self.after_id = None - self.console = None - - # Logger name entry - self.logger_entry_placeholder = "Logger Name" - self.logger_entry_var = tk.StringVar() - self.logger_entry = PlaceholderEntry( - self, - placeholder=self.logger_entry_placeholder, - textvariable=self.logger_entry_var - ) - self.logger_entry_var.trace("w", self.on_entry_changed) - self.logger_entry.bind('', lambda event: self.console.text_widget.focus()) - self.logger_entry.config(fg='grey') - - # Log level dropdown - self.log_level_dropdown_var = tk.StringVar() - self.log_level_dropdown_var.set("TRACE") - self.log_level_dropdown = tk.OptionMenu( - self, - self.log_level_dropdown_var, - *log_levels.keys() - ) - self.log_level_dropdown_var.trace( - "w", - lambda *args: self.console.set_filter(log_level=self.log_level_dropdown_var.get()) - ) - - # And above checkbox - self.and_above_var = tk.BooleanVar() - self.and_above_var.set(True) - self.and_above_checkbox = tk.Checkbutton( - self, - text="And above", - variable=self.and_above_var, - onvalue=True, - offvalue=False, - command=lambda: self.console.set_filter(and_above=self.and_above_var.get()) - ) - - self.clear_log_button: tk.Button | None = None - - self.create_widgets() - - def inject_console(self, console): - self.console = console - self.clear_log_button = tk.Button( - self, - text="Clear Logs", - command=self.console.clear_logs - ) - self.clear_log_button.pack(side=tk.RIGHT, padx=(5, 0), fill='x', expand=True) - - def create_widgets(self): - self.logger_entry.pack(side=tk.LEFT, fill='x', expand=True, padx=(5, 0)) - self.log_level_dropdown.pack(side=tk.LEFT, padx=(5, 0), fill='x', expand=True) - self.and_above_checkbox.pack(side=tk.LEFT, padx=(5, 0), fill='x', expand=True) - - def on_entry_changed(self, *args): - if self.after_id: - self.root.after_cancel(self.after_id) - self.after_id = self.root.after(250, self.apply_logger_entry_var) - - def apply_logger_entry_var(self): - if self.logger_entry.user_has_interacted: - self.console.set_filter(logger_name=self.logger_entry_var.get()) - self.after_id = None - - -class ExportMenuBar(tk.Menu): - def __init__(self, parent, console: Console, *args, **kwargs): - super().__init__(parent, *args, **kwargs) - self.parent = parent - self.initialize_menu() - self.console = console - - def initialize_menu(self): - # Create a File menu - file_menu = tk.Menu(self, tearoff=0) - file_menu.add_command(label="All logs", command=self.export_all_logs) - file_menu.add_separator() - file_menu.add_command(label="Filtered logs", command=self.export_filtered_logs) - - # Adding the "File" menu to the menubar - self.add_cascade(label="Export", menu=file_menu) - - def export_all_logs(self): - file_path = filedialog.asksaveasfilename( - defaultextension=".log", - filetypes=[("Log files", "*.log"), ("All files", "*.*")], - initialfile=f"Balatro-AllLogs-{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.log" - ) - if file_path: - with open(file_path, "w") as f: - for log in self.console.all_logs: - f.write(str(log)) - - def export_filtered_logs(self): - file_path = filedialog.asksaveasfilename( - defaultextension=".log", - filetypes=[("Log files", "*.log"), ("All files", "*.*")], - initialfile=f"Balatro-FilteredLogs-{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.log" - ) - if file_path: - with open(file_path, "w") as f: - for log in self.console.shown_logs: - f.write(str(log)) - - -class MainWindow(tk.Tk): - def __init__(self): - super().__init__() - self.title("Steamodded Debug Console") - self.options_frame = OptionsFrame(self) - self.console = Console(self, self.options_frame) - self.options_frame.inject_console(self.console) - self.menu_bar = ExportMenuBar(self, self.console) - self.create_widgets() - - self.bind('', self.focus_search) - self.bind('', self.focus_search) - - self.bind('', lambda event: self.menu_bar.export_filtered_logs()) - self.bind('', lambda event: self.menu_bar.export_filtered_logs()) - - self.bind('', lambda event: self.menu_bar.export_all_logs()) - self.bind('', lambda event: self.menu_bar.export_all_logs()) - - self.bind('', lambda event: self.console.clear_logs()) - self.bind('', lambda event: self.console.clear_logs()) - - self.bind('', self.focus_logger) - self.bind('', self.focus_logger) - - def create_widgets(self): - self.console.pack(side=tk.TOP, expand=True, fill='both') - self.options_frame.pack(side=tk.BOTTOM, fill='x', expand=False) - self.config(menu=self.menu_bar) - - def get_console(self): - return self.console - - def focus_search(self, event): - self.options_frame.global_search_frame.search_entry.focus() - - def focus_logger(self, event): - self.options_frame.specific_search_frame.logger_entry.focus() - - -def client_handler(client_socket, console: Console): - buffer = [] - while True: - data = client_socket.recv(1024) - if not data: - break - - decoded_data = data.decode() - buffer.append(decoded_data) # Append new data to the buffer list - - # Join the buffer and split by "ENDOFLOG" - # This handles cases where "ENDOFLOG" is spread across multiple recv calls - combined_data = ''.join(buffer) - logs = combined_data.split("ENDOFLOG") - - # The last element might be an incomplete log; keep it in the buffer - buffer = [logs.pop()] if logs[-1] else [] - - # Append each complete log to the console - for log in logs: - if log: - console.append_log(log) - - # Handle any remaining data in the buffer after the connection is closed - if ''.join(buffer): - console.append_log(''.join(buffer)) - - -def listen_for_clients(console: Console): - server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - server_socket.bind(('localhost', 53153)) - server_socket.listen() - while True: - client, addr = server_socket.accept() - threading.Thread(target=client_handler, args=(client, console)).start() - - -if __name__ == "__main__": - root = MainWindow() - threading.Thread(target=listen_for_clients, daemon=True, args=(root.get_console(),)).start() - root.mainloop() diff --git a/smods-main/version.lua b/smods-main/version.lua deleted file mode 100644 index 807adbc..0000000 --- a/smods-main/version.lua +++ /dev/null @@ -1 +0,0 @@ -return "1.0.0~ALPHA-1410b-STEAMODDED"