Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compatibility/Distro.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
if SMODS.Mods["Distro"] and SMODS.Mods["Distro"].can_load then
Distro = Distro or nil
DiscordIPC = DiscordIPC or nil
if not DiscordIPC or not Distro then return end
G.E_MANAGER:add_event(Event({
trigger = "immediate",
no_delete = true,
Expand Down
1 change: 1 addition & 0 deletions compatibility/Handy.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Handy = Handy or nil
if Handy then
-- In this version all checks included in mod, but since I care about older versions, keep all patches
if not (Handy.meta and Handy.meta["1.5.1a_multiplayer_check"]) then
Expand Down
4 changes: 3 additions & 1 deletion compatibility/HotPotato.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ if SMODS.Mods["HotPotato"] and SMODS.Mods["HotPotato"].can_load then
MP.DECK.ban_card("j_joker")
MP.DECK.ban_card("j_hpot_lotus")
MP.DECK.ban_card("j_hpot_c_sharp")

MP.DECK.ban_card("j_hpot_goblin_tinkerer") -- too easy to infinite

Wheel = Wheel or nil
if not Wheel then return end

-- essentially we're just hooking a bunch of functions to separate and normalise rng
-- i was gonna hook more but it ended up only being 2 so whatever

Expand Down
1 change: 1 addition & 0 deletions compatibility/JokerDisplay.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
if SMODS.Mods["JokerDisplay"] and SMODS.Mods["JokerDisplay"].can_load then
JokerDisplay = JokerDisplay or nil
if JokerDisplay then
local jd_def = JokerDisplay.Definitions
jd_def["j_mp_conjoined_joker"] = {
Expand Down
10 changes: 5 additions & 5 deletions compatibility/Preview/CorePreview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

function FN.PRE.simulate()
-- Guard against simulating in redundant places:
if FN.PRE.five_second_coroutine and coroutine.status(FN.PRE.five_second_coroutine) == "suspended" then
if FN.PRE.five_second_coroutine and (coroutine.status(FN.PRE.five_second_coroutine) == "suspended") then
coroutine.resume(FN.PRE.five_second_coroutine)
end
if
Expand Down Expand Up @@ -52,7 +52,7 @@ function CardArea:parse_highlighted()
orig_hl(self)
if not MP.INTEGRATIONS.Preview then return end

if not FN.PRE.lock_updates and FN.PRE.show_preview then FN.PRE.show_preview = false end
if (not FN.PRE.lock_updates) and FN.PRE.show_preview then FN.PRE.show_preview = false end
FN.PRE.add_update_event("immediate")
end

Expand Down Expand Up @@ -89,7 +89,7 @@ function FN.PRE.update_on_card_order_change(cardarea)
if G.STATE == G.STATES.HAND_PLAYED then return end

local prev_order = nil
if cardarea.config.type == "joker" and cardarea.cards[1].ability.set == "Joker" then
if (cardarea.config.type == "joker") and (cardarea.cards[1].ability.set == "Joker") then
if cardarea.cards[1].edition and cardarea.cards[1].edition.mp_phantom then return end
-- Note that the consumables cardarea also has type 'joker' so must verify by checking first card.
prev_order = FN.PRE.joker_order
Expand All @@ -102,9 +102,9 @@ function FN.PRE.update_on_card_order_change(cardarea)
-- Go through stored card IDs and check against current card IDs, in-order.
-- If any mismatch occurs, toggle flag and update name for next time.
local should_update = false
if #cardarea.cards ~= #prev_order then prev_order = {} end
if (not prev_order) or (#cardarea.cards ~= #prev_order) then prev_order = {} end
for i, c in ipairs(cardarea.cards) do
if c.sort_id ~= prev_order[i] then
if c and (c.sort_id ~= prev_order[i]) then
prev_order[i] = c.sort_id
should_update = true
end
Expand Down
1 change: 1 addition & 0 deletions compatibility/Preview/EngineSimulate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ if not FN.SIM.run then

function FN.SIM.simulate_blind_debuffs()
local blind_obj = G.GAME.blind
if not blind_obj then return false end
if blind_obj.disabled then return false end

-- The following are part of Blind:press_play()
Expand Down
4 changes: 2 additions & 2 deletions compatibility/Preview/InterfacePreview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function FN.get_preview_settings_page()
FN.PRE.data = FN.PRE.simulate()
else
-- Preview was just disabled, so remove preview node:
G.HUD:get_UIE_by_ID("fn_pre_score").parent:remove()
G.HUD:get_UIE_by_ID("fn_pre_score").parent:remove() ---@diagnostic disable-line: undefined-field
end
G.HUD:recalculate()
end
Expand All @@ -135,7 +135,7 @@ function FN.get_preview_settings_page()
FN.PRE.data = FN.PRE.simulate()
else
-- Preview was just disabled, so remove preview node:
G.HUD:get_UIE_by_ID("fn_pre_dollars").parent:remove()
G.HUD:get_UIE_by_ID("fn_pre_dollars").parent:remove() ---@diagnostic disable-line: undefined-field
end
G.HUD:recalculate()
end
Expand Down
4 changes: 4 additions & 0 deletions compatibility/Preview/Jokers/Multiplayer.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
FN.SIM = FN.SIM or nil
FNSJ = FNSJ or nil
if not FN.SIM or not FNSJ then return end

FNSJ.simulate_mp_defensive_joker = function(joker_obj, context)
if context.cardarea == G.jokers and context.global then FN.SIM.add_chips(joker_obj.ability.t_chips) end
end
Expand Down
2 changes: 1 addition & 1 deletion compatibility/Preview/UtilsPreview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function FN.PRE.format_number(num)
-- Start using e-notation earlier to reduce number length, if showing min and max for preview:
if true and num >= 1e7 then
local x = string.format("%.4g", num)
local fac = math.floor(math.log(tonumber(x), 10))
local fac = math.floor(math.log(tonumber(x) or 1, 10))
return string.format("%.2f", x / (10 ^ fac)) .. "e" .. fac
end
return number_format(num) -- Default Balatro function.
Expand Down
6 changes: 3 additions & 3 deletions compatibility/TheOrder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ function reset_idol_card()
if #valid_idol_cards == 0 then return end

local value_order = {}
for i, rank in ipairs(SMODS.Rank.obj_buffer) do
for i, rank in ipairs(SMODS.Rank.obj_buffer) do ---@diagnostic disable-line: param-type-mismatch
value_order[rank] = i
end

local suit_order = {}
for i, suit in ipairs(SMODS.Suit.obj_buffer) do
for i, suit in ipairs(SMODS.Suit.obj_buffer) do ---@diagnostic disable-line: param-type-mismatch
suit_order[suit] = i
end

Expand Down Expand Up @@ -111,7 +111,7 @@ function reset_mail_rank()
local count_map = {}
local total_weight = 0
local value_order = {}
for i, rank in ipairs(SMODS.Rank.obj_buffer) do
for i, rank in ipairs(SMODS.Rank.obj_buffer) do ---@diagnostic disable-line: param-type-mismatch
value_order[rank] = i
end

Expand Down
1 change: 1 addition & 0 deletions compatibility/TooManyJokers.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
TMJ = TMJ or nil
if TMJ then
TMJ.ALLOW_HIGHLIGHT = false --this is implemented in a hook, can't move it over here
G.FUNCS.tmj_spawn = function()
Expand Down
4 changes: 3 additions & 1 deletion compatibility/UpgradeMod.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ if SMODS.Mods["upgrademod"] and SMODS.Mods["upgrademod"].can_load then
level = G.GAME.hands[hand_type].level,
})

level_up_hand(nil, hand_type, false, -((asteroid_factor or 1) * (planet_level or 1)))
asteroid_factor = asteroid_factor or 1
planet_level = planet_level or 1
level_up_hand(nil, hand_type, false, -(asteroid_factor * planet_level))

update_hand_text(
{ sound = "button", volume = 0.7, pitch = 1.1, delay = 0 },
Expand Down
4 changes: 2 additions & 2 deletions core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ function MP.load_mp_dir(directory, recursive)
local items = NFS.getDirectoryItemsInfo(dir_path)
-- sort by prefix like { _file, _dir, file, dir }
table.sort(items, function(a, b)
if has_prefix(a.name) ~= has_prefix(b.name) then return has_prefix(a.name) end
if has_prefix(a.name) ~= has_prefix(b.name) then return has_prefix(a.name) end ---@diagnostic disable-line: undefined-field
return (a.type == "directory") ~= (b.type == "directory") and a.type ~= "directory" or false
end)

-- load sorted files/dirs
for _, item in ipairs(items) do
local path = directory .. "/" .. item.name
local path = directory .. "/" .. item.name ---@diagnostic disable-line: undefined-field
sendDebugMessage("Loading item: " .. path, "MULTIPLAYER")
if item.type ~= "directory" then
MP.load_mp_file(path)
Expand Down
3 changes: 2 additions & 1 deletion lib/joker_stats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ end

function MP.STATS.record_match(won)
local config = SMODS.Mods["Multiplayer"].config
if not config then return end
config.joker_stats = config.joker_stats or {}
config.match_history = config.match_history or {}

Expand All @@ -40,5 +41,5 @@ end

function MP.STATS.get_joker_wins(joker_key)
local config = SMODS.Mods["Multiplayer"].config
return config.joker_stats and config.joker_stats[joker_key] or 0
return config and config.joker_stats[joker_key] or 0
end
13 changes: 9 additions & 4 deletions objects/challenges/polymorph_spam.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SMODS.Challenge({
},
},
restrictions = {
banned_cards = function()
banned_cards = function() ---@diagnostic disable-line: assign-type-mismatch
local ret = {}
local add = {
j_campfire = true,
Expand Down Expand Up @@ -39,6 +39,7 @@ end

local function get_pos(card)
local area = get_area(card)
if not area then return nil end
for i, v in ipairs(area.cards) do
if card == v then return i end
end
Expand All @@ -59,6 +60,7 @@ local function get_transmutations_loc(card)
local done = false
local num = 0
local area = get_area(card)
if not area then return nil end
local limit = area.config.card_limit
local pos = get_pos(card) or nil
local ret = {}
Expand Down Expand Up @@ -104,7 +106,8 @@ local function mass_polymorph(area)
break
end
if v == card.config.center then
swap = get_pos(card)
local pos = get_pos(card)
if pos then swap = pos end
else
swap = math.max(swap - 1, 0)
end
Expand Down Expand Up @@ -159,8 +162,10 @@ function localize(args, misc_cat)
table.remove(loc_target, 2)
end
local list = get_transmutations_loc(transmute_card)
for i = 1, #list do
loc_target[#loc_target + 1] = { list[i] }
if list then
for i = 1, #list do
loc_target[#loc_target + 1] = { list[i] }
end
end
end
return localize_ref(args, misc_cat)
Expand Down
2 changes: 1 addition & 1 deletion objects/consumables/asteroid.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SMODS.Atlas({
key = "asteroid",
path = {
path = { ---@diagnostic disable-line: assign-type-mismatch
["default"] = "c_asteroid.png",
["ru"] = "c_asteroid_ru.png",
},
Expand Down
4 changes: 2 additions & 2 deletions objects/decks/02_orange.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SMODS.Back({
apply = function(self)
stop_use()
local lock = self.key
G.CONTROLLER.locks[lock] = true
G.CONTROLLER.locks[lock] = true ---@diagnostic disable-line: need-check-nil
-- "yeah just triple layer the event surely that works...WHAT THE SHIT"
G.E_MANAGER:add_event(Event({
func = function()
Expand All @@ -30,7 +30,7 @@ SMODS.Back({
delay(0.2)
G.FUNCS.use_card({ config = { ref_table = card } })
card:start_materialize()
G.CONTROLLER.locks[lock] = nil
G.CONTROLLER.locks[lock] = nil ---@diagnostic disable-line: need-check-nil
return true
end,
}))
Expand Down
6 changes: 5 additions & 1 deletion objects/decks/ZZ_cocktail.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ SMODS.Back({
back:change_to(G.P_CENTERS[G.GAME.modifiers.mp_cocktail[i]])
local ret1, ret2 = back:trigger_effect(context)
back:change_to(G.P_CENTERS["b_mp_cocktail"])
if ret1 or ret2 then return ret1, ret2 end
if ret1 or ret2 then return ret1, ret2 end ---@diagnostic disable-line: return-type-mismatch
end
end,
mp_credits = { art = { "aura!", "shai1n" }, code = { "Toneblock" } },
Expand Down Expand Up @@ -426,6 +426,7 @@ end

local highlight_ref = Card.highlight
function Card:highlight(is_highlighted)
self.mp_cocktail_select = self.mp_cocktail_select or nil
if self.mp_cocktail_select then
local shift = G.CONTROLLER.held_keys["lshift"] or G.CONTROLLER.held_keys["rshift"]
if shift and self.mp_cocktail_forced then
Expand Down Expand Up @@ -484,6 +485,7 @@ G.E_MANAGER:add_event(Event({
func = function()
local decks = MP.get_cocktail_decks()
local cfg = SMODS.Mods["Multiplayer"].config
if not cfg then return true end
if (not cfg.cocktail) or #decks + 1 ~= #cfg.cocktail then
local string = ""
for i = 1, #decks do
Expand All @@ -500,6 +502,7 @@ G.E_MANAGER:add_event(Event({
function MP.cocktail_cfg_edit(bool, deck) -- strings are easier to send, and it's just ones and zeroes
local decks = MP.get_cocktail_decks()
local cfg = SMODS.Mods["Multiplayer"].config
if not cfg then return end
local num = (bool == 2) and "2" or (bool and "1" or "0")
if not deck then
local string = ""
Expand Down Expand Up @@ -528,6 +531,7 @@ end
function MP.cocktail_cfg_readpos(pos, construct)
local decks = MP.get_cocktail_decks() -- copypasted code. unsure how to make this less messy without making it more messy
local cfg = SMODS.Mods["Multiplayer"].config
if not cfg then return end
if pos == "show" then pos = #cfg.cocktail end
if construct then return MP.cocktail_cfg_get():sub(pos, pos) end
return cfg.cocktail:sub(pos, pos)
Expand Down
1 change: 1 addition & 0 deletions objects/decks/_decks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ SMODS.DrawStep({
key = "back_multiplayer",
order = 11,
func = function(self)
Galdur = Galdur or nil
if not Galdur and G.GAME.viewed_back and G.GAME.viewed_back.effect and G.GAME.viewed_back.effect.center.mod then
if G.GAME.viewed_back.effect.center.mod.id == "Multiplayer" and G.STAGE == G.STAGES.MAIN_MENU then
G.shared_stickers["mp_sticker_balanced"].role.draw_major = self
Expand Down
2 changes: 1 addition & 1 deletion objects/jokers/sandbox/castle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ SMODS.Joker({
local suit = card.ability.extra.suit or G.GAME.current_round.castle_card.suit or "Spades"
return {
vars = {
string.upper(localize(suit, "suits_plural")),
string.upper(localize(suit, "suits_plural") or ""),
colours = { G.C.SUITS[suit] },
card.ability.extra.chips,
card.ability.extra.chip_mod,
Expand Down
4 changes: 2 additions & 2 deletions objects/jokers/sandbox/idol.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ local function get_most_common_card()

-- Sort by count descending first, then by suit/value for consistency
local value_order = {}
for i, rank in ipairs(SMODS.Rank.obj_buffer) do
for i, rank in ipairs(SMODS.Rank.obj_buffer) do ---@diagnostic disable-line: param-type-mismatch
value_order[rank] = i
end

local suit_order = {}
for i, suit in ipairs(SMODS.Suit.obj_buffer) do
for i, suit in ipairs(SMODS.Suit.obj_buffer) do ---@diagnostic disable-line: param-type-mismatch
suit_order[suit] = i
end

Expand Down
2 changes: 1 addition & 1 deletion objects/jokers/sandbox/vampire.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SMODS.Joker({
local stone_cards = {}
for _, scored_card in ipairs(context.scoring_hand) do
if
next(SMODS.get_enhancements(scored_card))
next(SMODS.get_enhancements(scored_card)) ---@diagnostic disable-line: param-type-mismatch
and not scored_card.debuff
and not scored_card.vampired
and not SMODS.has_enhancement(scored_card, "m_stone") -- todo like this - does it even work?
Expand Down
6 changes: 3 additions & 3 deletions overrides/mod_badges.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ function SMODS.create_mod_badges(obj, badges)
local calced_text_width = 0
-- Math reproduced from DynaText:update_text
for _, c in utf8.chars(text) 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)
local scale = G.TILESCALE * font.FONTSCALE ---@diagnostic disable-line: undefined-field
local tx = scale * (font.FONT:getWidth(c) * 0.33 * size + 2.7) ---@diagnostic disable-line: undefined-field
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
return scale_fac
Expand Down
2 changes: 1 addition & 1 deletion rulesets/_rulesets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function MP.ReworkCenter(key, ruleset, loc_key, args)

-- Auto-inject generate_ui when adding loc_vars to vanilla centers
if needs_generate_ui then
center[prefix .. "generate_ui"] = SMODS.Center.generate_ui
center[prefix .. "generate_ui"] = SMODS.Center.generate_ui ---@diagnostic disable-line: assign-type-mismatch
if not center.mp_vanilla_generate_ui then center.mp_vanilla_generate_ui = center.generate_ui or "NULL" end
end

Expand Down
2 changes: 1 addition & 1 deletion rulesets/smallworld.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function MP.apply_fake_back_vouchers(back)
for i, v in ipairs(fake_back.effect.config.vouchers) do
local voucher = v
if G.GAME.banned_keys[v] or G.GAME.used_vouchers[v] then voucher = get_next_voucher_key() end
G.GAME.used_vouchers[voucher] = true
G.GAME.used_vouchers[voucher] = true ---@diagnostic disable-line: need-check-nil
fake_back.effect.config.vouchers[i] = voucher
end
G.GAME.current_round.voucher = SMODS.get_next_vouchers() -- the extreme jank doesn't matter as long as it's synced ig
Expand Down
Loading