Skip to content

Auto-gate reworked jokers from layer membership#412

Merged
stephenkirk merged 4 commits into
devfrom
stephenkirk/layer-auto-gate
Apr 29, 2026
Merged

Auto-gate reworked jokers from layer membership#412
stephenkirk merged 4 commits into
devfrom
stephenkirk/layer-auto-gate

Conversation

@stephenkirk

@stephenkirk stephenkirk commented Apr 28, 2026

Copy link
Copy Markdown
Member

Summary

Layers already declare which jokers they own via reworked_jokers. So the boilerplate every standard-layer joker was carrying:

mp_include = function(self) return MP.is_layer_active("standard") and MP.LOBBY.code end

...is now redundant. SMODS.Joker:register is overridden so it consults a reverse index (MP._JOKER_LAYERS) and auto-attaches a default mp_include when the joker doesn't define one. Bespoke gates win; the override stays out of their way.

What changed

  • New reverse index built in MP.Layer(): full joker key → owning layers.
  • SMODS.Joker:register overridden to inject a default mp_include for jokers whose key is in the index. By the time register runs, SMODS has already prefixed the key, so lookups are direct (no manual "j_<prefix>_<key>" reconstruction).
  • 8 standard-layer jokers stripped of their mp_include boilerplate.

Migration landscape (63 total mp_include calls)

# Count Where Pattern Status
A 5 objects/jokers/standard/* is_layer_active("standard") and LOBBY.code ✅ This PR
B 9 objects/jokers/*.lua (top level) LOBBY.code and config.multiplayer_jokers (8); conjoined adds not is_layer_active("sandbox") Next — much easier if we extract MP jokers to a layer
C ~25 objects/jokers/sandbox/* MP.SANDBOX.is_joker_allowed(self.key) Wait - currently centralized via joker_mappings
D ~25 objects/jokers/sandbox/extra-credit/* same as C Wait
E 2 error.lua, magnet_sandbox.lua bespoke Leave

Test plan

  • Lobby with standard-layer ruleset (Blitz, Traditional, etc.): reworked jokers appear
  • Lobby with non-standard ruleset (Sandbox, Vanilla): reworked jokers absent
  • No active ruleset: reworked jokers absent
  • Bespoke mp_include jokers (sandbox, top-level MP, error, magnet_sandbox) unaffected

Wrap SMODS.Joker so that any joker whose full key appears in some
layer's reworked_jokers gets a default mp_include attached when none
is provided. Joker files no longer need to repeat the
is_layer_active(...) check the layer already declared. Bespoke gating
still wins (sandbox rotation, extra-credit checks, etc.).

Demonstrated on the five standard reworks. j_mp_bloodstone added to
standard.reworked_jokers since it was the only standard rework not
listed there (silent rework, no UI side effects).
Override SMODS.Joker:register directly instead of wrapping the whole
table in a metatable proxy. self.key is already prefixed at register
time, so the manual prefix reconstruction goes away too. Same behavior,
fewer moving parts. Per smods maintainer's suggestion.
Bloodstone already pulls its PvP proc rolls from a shared sequence
(by round + play order), but the sticker tooltip never explained why.
Add the localized text so players see that both bloodstones fire on
the same hands.
@stephenkirk stephenkirk force-pushed the stephenkirk/layer-auto-gate branch from f836cdf to 8bccaf9 Compare April 29, 2026 17:52
@stephenkirk stephenkirk merged commit 462cce7 into dev Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant