From dcf9d55fcfc1bd989544ff705356f80149c4373e Mon Sep 17 00:00:00 2001 From: Emik Date: Tue, 23 Jun 2026 20:47:12 +0200 Subject: [PATCH] Improve debugging experience, nerf Violet Vessel --- manifest.json | 2 +- src/joker.lua | 6 ++-- src/lib/funky.lua | 37 ++++++++++++++++------- src/lib/intellisense.lua | 3 ++ src/lib/shared.lua | 64 +++++++++++++++++++++++++++++++++++++++- src/main.lua | 6 ++-- 6 files changed, 100 insertions(+), 18 deletions(-) diff --git a/manifest.json b/manifest.json index 64919ee..3b5feb6 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "id": "Roland", "name": "Roland", "prefix": "Roland", - "version": "2.9.25", + "version": "2.9.26", "badge_colour": "8BE9FD", "display_name": "Roland", "main_file": "src/main.lua", diff --git a/src/joker.lua b/src/joker.lua index 62b5e3a..3ce532a 100644 --- a/src/joker.lua +++ b/src/joker.lua @@ -648,7 +648,7 @@ joker { local _ = card.area == G.jokers and self:cerulean(false) end, cerulean = function(_, value) - f(G.jokers.cards):each(function(v) + local _ = G.jokers and f(G.jokers.cards):each(function(v) f {"click", "drag", "focus", "hover"}:map(f.index_into(v.states)):each(function(s) s.can = value or v.config.center.key == "j_Roland_cerulean" end) @@ -675,7 +675,7 @@ joker { {card = card, xmult = card.ability.extra.xmult} or nil end, crimson = function() - f(G.jokers.cards, ipairs_reversed):where(is_frozen, false):each(function(v) + local _ = G.jokers and f(G.jokers.cards, ipairs_reversed):where(is_frozen, false):each(function(v) local right = G.jokers.cards[v.rank + 1] local debuffed_by_crimson = right and @@ -757,7 +757,7 @@ joker { key = "violet", pronouns = "she_they", idea = "hamester", - config = {extra = {before = 0.1, xmult = 9}}, + config = {extra = {before = 0.1, xmult = 6}}, pixel_size = {w = 68, h = 68}, attributes = {"xmult"}, cost = 6, diff --git a/src/lib/funky.lua b/src/lib/funky.lua index 4455634..0999532 100644 --- a/src/lib/funky.lua +++ b/src/lib/funky.lua @@ -128,13 +128,6 @@ local function autopairs(tbl, fpairs) return (fpairs or (tbl[#tbl] and ipairs or pairs))(tbl) end ----@param any any ----@return boolean ----@nodiscard -local function is_f(any) - return type(any) == "table" and any.from == f.from and any.new == f.new -end - --- Always returns nil. ---@return nil ---@nodiscard @@ -202,6 +195,15 @@ function f.const(v) end end +---@param i integer +---@return fun(...: any): any +---@nodiscard +function f.arg(i) + return function(...) + return ({...})[i] + end +end + ---@generic K, V ---@param v K ---@return fun(x: { [K]: V }): V @@ -240,21 +242,32 @@ function f.indices(v) end end +---@param any any +---@return boolean +---@nodiscard +function f.isf(any) + return type(any) == "table" and any.from == f.from and any.new == f.new +end + f[true and "chain"] = function(...) - for _, v in ipairs(...) do + local ret + + for _, v in ipairs {...} do if type(v) == "table" then for _, vv in ipairs(v) do + local copy = ret vv = autofunc(vv) ret = ret and function(...) - return vv(ret(...)) + return vv(copy(...)) end or vv end else + local copy = ret v = autofunc(v) ret = ret and function(...) - return v(ret(...)) + return v(copy(...)) end or v end end @@ -271,6 +284,7 @@ function f.new(fnext) return { all = f.all, any = f.any, + arg = f.arg, chain = f.chain, concat = f.concat, const = f.const, @@ -285,6 +299,7 @@ function f.new(fnext) index = f.index, index_into = f.index_into, indices = f.indices, + isf = f.isf, keys = f.keys, map = f.map, new = f.new, @@ -371,7 +386,7 @@ function f:concat(...) local sum, last = 0, 0 for i = 1, #fs do - fs[i] = is_f(fs[i]) and fs[i] or f.from(fs[i]) + fs[i] = f.isf(fs[i]) and fs[i] or f.from(fs[i]) end return f.new(function() diff --git a/src/lib/intellisense.lua b/src/lib/intellisense.lua index c617837..1feacaf 100644 --- a/src/lib/intellisense.lua +++ b/src/lib/intellisense.lua @@ -25,6 +25,9 @@ CardSleeves = CardSleeves --- @type table|fun(obj: SMODS.Back): SMODS.Back CardSleeves.Sleeve = CardSleeves.Sleeve +--- @type {aliases: { [string]: [string] }} +Cryptid = Cryptid + --- @type fun(area: CardArea, ...: ...): Card create_card_for_shop = create_card_for_shop diff --git a/src/lib/shared.lua b/src/lib/shared.lua index 463d28b..29609a7 100644 --- a/src/lib/shared.lua +++ b/src/lib/shared.lua @@ -1,5 +1,40 @@ local f = assert(SMODS.load_file "src/lib/funky.lua")() or require "lib.funky" +local function add_card(v) + return SMODS.add_card {no_edition = true, key = v} +end + +local function simplify(x) + return type(x) == "string" and x:lower():gsub("%s", ""):gsub("_", ""):gsub("^the", "") or x +end + +local function flatten(v) + return type(v) ~= "table" and {v} or (f.isf(v) and v:table() or v) +end + +---@param it string +local function find(it) + if (G.P_CENTERS[it] or {}).config then + return it + end + + if Cryptid and Cryptid.aliases and Cryptid.aliases[it] then + return Cryptid.aliases[it] + end + + local match = simplify(it) + + return f(G.localization.descriptions) + :flatmap(flatten) + :where(type, "table") + :where(f.chain(f.arg(2), f.index_into(G.P_CENTERS), "config")) + :where(function(v, k) + return match == simplify(k) or match == simplify(v.name) + end) + :keys() + :any() +end + local function protect(fun) return function() local res, ret = pcall(fun) @@ -56,4 +91,31 @@ local function u() G.STATE ~= G.STATES.PLAY_TAROT) end -return {f, q, u} +--- Creates one or more cards. +---@param ... any +---@return Card|Card[] +local function c(...) + local cards = f {...} + :flatmap(flatten) + :where(type, "string") + :map(string.lower) + :map(find) + :where(f.id) + :map(add_card) + :values() + :table() + + return #cards > 1 and cards or cards[1] +end + +return {f, q, u, setmetatable({}, { + __call = function(_, ...) + return c(...) + end, + __index = function(_, k) + return c(k) + end, + __newindex = function() + sendErrorMessage("`c` should not be assigned to.", "Roland") + end, +})} diff --git a/src/main.lua b/src/main.lua index 33ccfea..09678d5 100644 --- a/src/main.lua +++ b/src/main.lua @@ -52,9 +52,11 @@ q { -- G.ARGS.LOC_COLOURS["Bakery_credit_bg_Roland_" .. k] = v.bg end) - if SMODS.Mods.DebugPlus and SMODS.Mods.Roland.config.import_funky then - _G.f, _G.q, _G.u = unpack(qol) + if not SMODS.Mods.DebugPlus or not SMODS.Mods.Roland.config.import_funky then + return end + + _G.f, _G.q, _G.u, _G.c = unpack(qol) end, }