feat: server-driven banned/approved mod policy#28
Draft
ChronoFinale wants to merge 1 commit into
Draft
Conversation
877e001 to
1b2fe5a
Compare
Keeps a banned/approved mod policy in memory and sends it to a client when it
joins or creates a lobby, so the client can colour opponents' mods red (banned)
/ green (approved) / white (unknown) without a mod release.
- modPolicy.ts: in-memory policy with get/set; loads an optional mod_policy.json
fallback at boot, else a minimal hardcoded default. fetchRemotePolicy() pulls
the normalized { mods: [...] } array from <BALATROMP_BASE_URL>/api/mod-policy.
- main.ts: a background poll refreshes the cached policy without a restart; the
admin `setModPolicy` command updates it live and broadcasts to lobby clients.
- actionHandlers.ts: sendModPolicy on lobby create/join/rejoin.
- actions.ts: ActionSetModPolicy type.
- .env.example documents BALATROMP_BASE_URL / refresh interval / optional token.
The website (Balatro-Multiplayer/www) is the source of truth — staff edit the
lists there and the server polls them.
1b2fe5a to
de7db64
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
Server-driven banned/approved mod policy. The server keeps the policy in memory and sends it to a client when it joins/creates a lobby, so the client can colour opponents' mods red (banned) / green (approved) / white (unknown) — and staff can update the lists without a mod release.
This is the game-server piece. The admin UI + source of truth is a companion PR to
www(addsGET /api/mod-policy); the client rendering is a companion PR toBalatroMultiplayer.How it works
modPolicy.ts— in-memory{ banned, approved }withget/set. At boot it loads an optionalmod_policy.jsonfallback, else a minimal hardcoded default.fetchRemotePolicy()pulls the normalized{ mods: [...] }array from<BALATROMP_BASE_URL>/api/mod-policy.main.ts— a background poll refreshes the cached policy on an interval (no restart). The adminsetModPolicycommand updates it live and broadcasts to clients in lobbies.actionHandlers.ts—sendModPolicyon lobby create / join / rejoin.actions.ts— thesetModPolicyserver→client action type.The website is the source of truth: staff edit the lists there; the server polls and caches.
Config (
.env.example)BALATROMP_BASE_URL— defaults to production; override tohttp://localhost:3000for local dev.MOD_POLICY_REFRESH_MS— poll interval (default 5 min, min 5 s).MOD_POLICY_TOKEN— optional bearer token if the endpoint is ever gated.mod_policy.jsonis gitignored — it's only a local offline fallback.Verification
tscclean.setModPolicydelivered to the client on lobby join.