Integrate with the mods actually installed beside us
New integrations.lua, loaded pcall-wrapped at the end of main.lua; every integration gates on its target's global so a missing mod is silence. Both targets load before us by priority. JokerDisplay: each known joker's display definition gains a live '(2 combos)' counter in JD's own parenthetical reminder style -- the same partner count the hover tooltip names -- by appending a dynamic element to reminder_text (created when absent) and wrapping calc_function to fill card.joker_display_values. The wrapper pcalls the original calc and blanks the text when the new jd_combos config toggle is off, so it flips mid-run in both directions. Too Many Jokers: registers the SEARCH_FIELD_FUNCS hook its api.md documents, indexing every joker under its tag labels on both sides, so the collection search finds jokers by 'money', 'Hearts', 'held-card retriggers'. Unknown centers stay nil. The smoke scenario now asserts the JokerDisplay patch against the real mod: 13/13 in-game. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -111,6 +111,19 @@ UIBox = function(args) return {def = args and args.definition, remove = function
|
||||
create_option_cycle = function() return {n = 'R', config = {}, nodes = {}} end
|
||||
localize = function() error('no localization outside the game') end
|
||||
|
||||
-- Cross-mod integration stubs, present BEFORE main.lua loads (both real mods
|
||||
-- load before this one: JokerDisplay at priority -1e9, TMJ at -1000). One
|
||||
-- JokerDisplay definition of each shape: with a reminder_text row and without.
|
||||
JokerDisplay = {Definitions = {
|
||||
j_baron = {text = {{text = 'x'}},
|
||||
calc_function = function(card)
|
||||
card.joker_display_values = card.joker_display_values or {}
|
||||
card.joker_display_values.orig_ran = true
|
||||
end},
|
||||
j_mime = {text = {{text = 'x'}}, reminder_text = {{text = '(hand)'}}},
|
||||
}}
|
||||
TMJ = {SEARCH_FIELD_FUNCS = {}}
|
||||
|
||||
local data = dofile('synergies.lua')
|
||||
dofile('main.lua')
|
||||
|
||||
@@ -673,6 +686,46 @@ JCA.register_pair('j_mod_test', 'j_baron', 'test blurb')
|
||||
eq(JCA.score('j_mod_test', 'j_baron') - before, 4, 'JCA.register_pair adds the +4 pair bonus')
|
||||
JCA.db.j_mod_test = nil -- keep the UI section on vanilla data only
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
section('Integrations: JokerDisplay counter and TMJ search')
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- JokerDisplay: every known joker with a definition gains the counter, in
|
||||
-- both definition shapes.
|
||||
eq(JCA.integrations.jokerdisplay, 2, 'both stub JokerDisplay definitions were patched')
|
||||
ok(JokerDisplay.Definitions.j_baron.reminder_text,
|
||||
'a definition without reminder_text gains one for the counter')
|
||||
eq(#JokerDisplay.Definitions.j_mime.reminder_text, 3,
|
||||
'an existing reminder_text grows by separator + counter')
|
||||
|
||||
-- The wrapped calc_function fills the live count and keeps the original.
|
||||
field('j_baron', 'j_mime')
|
||||
local jd_card = G.jokers.cards[1]
|
||||
jd_card.joker_display_values = {}
|
||||
JokerDisplay.Definitions.j_baron.calc_function(jd_card)
|
||||
eq(jd_card.joker_display_values.jca_combos, '(1 combo)',
|
||||
'the counter shows the live board partner count')
|
||||
ok(jd_card.joker_display_values.orig_ran,
|
||||
'and the original calc_function still runs first')
|
||||
|
||||
JCA.config.jd_combos = false
|
||||
JokerDisplay.Definitions.j_baron.calc_function(jd_card)
|
||||
eq(jd_card.joker_display_values.jca_combos, '',
|
||||
'the config toggle blanks the counter mid-run')
|
||||
JCA.config.jd_combos = true
|
||||
|
||||
-- Too Many Jokers: the search hook indexes jokers by tag labels and stays
|
||||
-- silent on centers the database does not know.
|
||||
eq(JCA.integrations.toomanyjokers, 1, 'the TMJ search hook registered')
|
||||
local tmj_fields = TMJ.SEARCH_FIELD_FUNCS[1]({key = 'j_baron'})
|
||||
local tmj_hit = false
|
||||
for _, f in ipairs(tmj_fields) do
|
||||
if f == 'held-card retriggers' then tmj_hit = true end
|
||||
end
|
||||
ok(tmj_hit, 'TMJ search finds Baron under its tag labels')
|
||||
eq(TMJ.SEARCH_FIELD_FUNCS[1]({key = 'j_totally_modded'}), nil,
|
||||
'an unknown center returns nil, not an error')
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
section('UI: catalog pages build and animate')
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user