feat(chat): custom chat bubbles

Players choose how their chat bubble looks, and everyone sees it.

- style: a gradient of 2 to 5 colour stops (linear at any 45° step,
  radial, or solid), its strength, text and border colours, outline
  thickness 0-4, opacity 25-100%, and an animation (still, pulse, shimmer,
  flow, rainbow) at 40-300% speed. lib/chatstyles.js keeps the one
  canonical form: forgiving for saved accounts, strict for requests.
- in the game: Settings > Chat Bubble > Customize opens an editor with
  presets (Ocean, Sunset, Forest, Midnight, Candy, Rainbow), a palette,
  Swap, Random, Reset and Save, and a live preview. "Custom bubbles: Off"
  draws everyone's bubbles normally on this computer only.
- on the web: the account page has a Chat bubble section with the same
  choices.
- wire: xcs with no fields asks for the saved style, with twelve (or an
  older client's 7, 10 or 11) saves it; the reply is the canonical twelve.
  A typed line ("uc") carries its sender's style after the stock extra
  field, only when it is not the default, so message and type stay where
  the game reads them and unpatched clients are unaffected.

ajclient.swf is built with this and the six client commits before it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
SnipzilandClaude Opus 5.5 committed 2026-10-21 22:42:11 -04:00
1 parent c1a85f9b5d
commit 83c2fc3b0b
14 files changed
+1697 -12

No files matched your search

+13
View File
@@ -24,6 +24,7 @@ const support = require("./support.js");
const totp = require("./totp.js");
const recoveryMail = require("./recoverymail.js");
const world = require("./world.js");
const chatStyles = require("./chatstyles.js");
// the account page at /account: what a player can do about their own
// account from a browser. they sign in with the game's username and
@@ -168,6 +169,7 @@ const profile = (account, from) => {
logins: account.numLogins || 0,
playtime: account.playtime,
playtimePublic: account.playtimePublic,
chatStyle: chatStyles.normalize(account.chatStyle),
animals: account.avatars.length,
animalType: avatar ? avatar.type : null,
items: account.items.length,
@@ -428,6 +430,17 @@ const act = (account, body, req, from, res) => {
account.playtimePublic = body.on === true;
accounts.save(account);
return {ok: account.playtimePublic ? "Others can see your playtime on your card." : "Your playtime is private."};
// A player can choose every colour, opacity, animation and animation
// speed. Validation is deliberately here as well as in the page: saved
// state is not trusted just because it came from our own browser UI.
case "chatStyle": {
if (!chatStyles.valid(body.style)) {
return {error: "Choose valid chat colours and animation settings."};
}
account.chatStyle = chatStyles.normalize(body.style);
accounts.save(account);
return {ok: "Chat style saved. Your next message will use it."};
}
// their Discord account, for their card in the game: it is linked by
// signing in to Discord (GET /account/discord/link), and only taken off
// here, with the booster badge it brought.