From eda992fcffe306896b6946ad40e45d4e0727b970 Mon Sep 17 00:00:00 2001 From: S Date: Wed, 14 Oct 2026 19:03:13 +0300 Subject: [PATCH] Brought up to date with the private repository (a06d3c5) --- .gitignore | 29 + config.js | 307 ++ deploy/burrow-update.service | 7 + deploy/burrow-update.timer | 9 + deploy/update.sh | 36 + lib/accounts.js | 694 +++ lib/achievements.js | 167 + lib/admin.js | 231 + lib/adopt.js | 66 + lib/adventures.js | 356 ++ lib/adventures/return-of-the-phantoms.js | 688 +++ lib/adventures/training-grounds.js | 198 + lib/amf3.js | 278 ++ lib/avatars.js | 148 + lib/badges.js | 129 + lib/bans.js | 199 + lib/buddies.js | 224 + lib/buddygames.js | 369 ++ lib/captcha.js | 120 + lib/cdn.js | 174 + lib/chatlog.js | 107 + lib/colours.js | 73 + lib/commands.js | 527 +++ lib/defpacks.js | 503 ++ lib/dens.js | 434 ++ lib/disguises.js | 74 + lib/ecard-art.json | 4 + lib/ecards.js | 345 ++ lib/epicdens.js | 64 + lib/erase.js | 25 + lib/extramusic.js | 123 + lib/games.json | 118 + lib/http.js | 755 +++ lib/items.js | 167 + lib/limits.js | 137 + lib/log.js | 33 + lib/manage.js | 589 +++ lib/masterpieces.js | 333 ++ lib/minigames.js | 622 +++ lib/moderation.js | 184 + lib/modlog.js | 31 + lib/modpanel.js | 447 ++ lib/names.js | 77 + lib/panel.js | 846 ++++ lib/parties.js | 276 ++ lib/pets.js | 238 + lib/player.js | 100 + lib/reports.js | 97 + lib/reserved-names.txt | 27 + lib/retention.js | 52 + lib/roominfo.js | 101 + lib/sale-dates.json | 4829 ++++++++++++++++++++ lib/sales.js | 103 + lib/sfs.js | 279 ++ lib/shop-stock.json | 111 + lib/shopstock.js | 103 + lib/signup.js | 109 + lib/staff.js | 97 + lib/stubs.js | 12 + lib/support.js | 156 + lib/totp.js | 204 + lib/trades.js | 434 ++ lib/wall-art.json | 53 + lib/walls.js | 354 ++ lib/world.js | 1518 ++++++ lib/worlditems.js | 75 + package.json | 14 + public/account.html | 1301 ++++++ public/admin.html | 1502 ++++++ public/badges/artist.png | Bin 0 -> 1335 bytes public/badges/booster.png | Bin 0 -> 2483 bytes public/badges/bughunter.png | Bin 0 -> 1486 bytes public/badges/contributor.png | Bin 0 -> 1361 bytes public/badges/developer.png | Bin 0 -> 1386 bytes public/badges/discord.png | Bin 0 -> 2437 bytes public/badges/early.png | Bin 0 -> 1360 bytes public/badges/eventwinner.png | Bin 0 -> 1297 bytes public/badges/friend.png | Bin 0 -> 1398 bytes public/badges/helper.png | Bin 0 -> 1268 bytes public/badges/moderator.png | Bin 0 -> 1223 bytes public/badges/owner.png | Bin 0 -> 1232 bytes public/badges/partner.png | Bin 0 -> 1264 bytes public/badges/supporter.png | Bin 0 -> 1403 bytes public/badges/tester.png | Bin 0 -> 1307 bytes public/ban-icon.png | Bin 0 -> 3999 bytes public/bio-icon.png | Bin 0 -> 10255 bytes public/captcha.html | 62 + public/captcha.js | 83 + public/commands.html | 259 ++ public/filter/level1.txt | 51 + public/filter/level2.txt | 35 + public/fonts/CCDigitalDelivery-Bold.otf | Bin 0 -> 38764 bytes public/fonts/CCDigitalDelivery-Regular.otf | Bin 0 -> 33460 bytes public/game.html | 118 + public/home.html | 420 ++ public/logo-square.png | Bin 0 -> 39740 bytes public/logo.png | Bin 0 -> 42679 bytes public/mod.html | 981 ++++ public/privacy.html | 257 ++ public/register.html | 358 ++ public/shop.html | 305 ++ public/signup/hero_bunny.svg | 1 + public/signup/hero_koala.svg | 1 + public/signup/hero_monkey.svg | 1 + public/signup/hero_panda.svg | 1 + public/signup/hero_penguin.svg | 1 + public/signup/hero_rhino.svg | 1 + public/signup/hero_seal.svg | 1 + public/signup/hero_tiger.svg | 1 + public/signup/hero_wolf.svg | 1 + public/signup/thumb_bunny.svg | 1 + public/signup/thumb_koala.svg | 1 + public/signup/thumb_monkey.svg | 1 + public/signup/thumb_panda.svg | 1 + public/signup/thumb_penguin.svg | 1 + public/signup/thumb_rhino.svg | 1 + public/signup/thumb_seal.svg | 1 + public/signup/thumb_tiger.svg | 1 + public/signup/thumb_wolf.svg | 1 + public/terms.html | 240 + server.js | 80 + test/account.js | 231 + test/buddygames.js | 311 ++ test/features.js | 666 +++ test/harness.js | 173 + test/qol.js | 206 + test/restored.js | 328 ++ test/smoke.js | 658 +++ tools/build-client.sh | 64 + tools/client-test.js | 27 + tools/find-art.py | 87 + tools/hud/dump.py | 85 + tools/hud/transplant-nametag.py | 168 + tools/make-badges.py | 362 ++ tools/make-bio-tab.py | 162 + tools/make-emote.py | 309 ++ tools/pack-for-vps.sh | 32 + tools/publish-public.sh | 83 + tools/reset-admin-password.js | 15 + tools/room-assets.js | 49 + tools/room-history.js | 131 + tools/room-info.js | 11 + tools/sale-history.js | 88 + tools/shop-stock.py | 321 ++ 144 files changed, 31026 insertions(+) create mode 100644 .gitignore create mode 100644 config.js create mode 100644 deploy/burrow-update.service create mode 100644 deploy/burrow-update.timer create mode 100644 deploy/update.sh create mode 100644 lib/accounts.js create mode 100644 lib/achievements.js create mode 100644 lib/admin.js create mode 100644 lib/adopt.js create mode 100644 lib/adventures.js create mode 100644 lib/adventures/return-of-the-phantoms.js create mode 100644 lib/adventures/training-grounds.js create mode 100644 lib/amf3.js create mode 100644 lib/avatars.js create mode 100644 lib/badges.js create mode 100644 lib/bans.js create mode 100644 lib/buddies.js create mode 100644 lib/buddygames.js create mode 100644 lib/captcha.js create mode 100644 lib/cdn.js create mode 100644 lib/chatlog.js create mode 100644 lib/colours.js create mode 100644 lib/commands.js create mode 100644 lib/defpacks.js create mode 100644 lib/dens.js create mode 100644 lib/disguises.js create mode 100644 lib/ecard-art.json create mode 100644 lib/ecards.js create mode 100644 lib/epicdens.js create mode 100644 lib/erase.js create mode 100644 lib/extramusic.js create mode 100644 lib/games.json create mode 100644 lib/http.js create mode 100644 lib/items.js create mode 100644 lib/limits.js create mode 100644 lib/log.js create mode 100644 lib/manage.js create mode 100644 lib/masterpieces.js create mode 100644 lib/minigames.js create mode 100644 lib/moderation.js create mode 100644 lib/modlog.js create mode 100644 lib/modpanel.js create mode 100644 lib/names.js create mode 100644 lib/panel.js create mode 100644 lib/parties.js create mode 100644 lib/pets.js create mode 100644 lib/player.js create mode 100644 lib/reports.js create mode 100644 lib/reserved-names.txt create mode 100644 lib/retention.js create mode 100644 lib/roominfo.js create mode 100644 lib/sale-dates.json create mode 100644 lib/sales.js create mode 100644 lib/sfs.js create mode 100644 lib/shop-stock.json create mode 100644 lib/shopstock.js create mode 100644 lib/signup.js create mode 100644 lib/staff.js create mode 100644 lib/stubs.js create mode 100644 lib/support.js create mode 100644 lib/totp.js create mode 100644 lib/trades.js create mode 100644 lib/wall-art.json create mode 100644 lib/walls.js create mode 100644 lib/world.js create mode 100644 lib/worlditems.js create mode 100644 package.json create mode 100644 public/account.html create mode 100644 public/admin.html create mode 100644 public/badges/artist.png create mode 100644 public/badges/booster.png create mode 100644 public/badges/bughunter.png create mode 100644 public/badges/contributor.png create mode 100644 public/badges/developer.png create mode 100644 public/badges/discord.png create mode 100644 public/badges/early.png create mode 100644 public/badges/eventwinner.png create mode 100644 public/badges/friend.png create mode 100644 public/badges/helper.png create mode 100644 public/badges/moderator.png create mode 100644 public/badges/owner.png create mode 100644 public/badges/partner.png create mode 100644 public/badges/supporter.png create mode 100644 public/badges/tester.png create mode 100644 public/ban-icon.png create mode 100644 public/bio-icon.png create mode 100644 public/captcha.html create mode 100644 public/captcha.js create mode 100644 public/commands.html create mode 100644 public/filter/level1.txt create mode 100644 public/filter/level2.txt create mode 100644 public/fonts/CCDigitalDelivery-Bold.otf create mode 100644 public/fonts/CCDigitalDelivery-Regular.otf create mode 100644 public/game.html create mode 100644 public/home.html create mode 100644 public/logo-square.png create mode 100644 public/logo.png create mode 100644 public/mod.html create mode 100644 public/privacy.html create mode 100644 public/register.html create mode 100644 public/shop.html create mode 100644 public/signup/hero_bunny.svg create mode 100644 public/signup/hero_koala.svg create mode 100644 public/signup/hero_monkey.svg create mode 100644 public/signup/hero_panda.svg create mode 100644 public/signup/hero_penguin.svg create mode 100644 public/signup/hero_rhino.svg create mode 100644 public/signup/hero_seal.svg create mode 100644 public/signup/hero_tiger.svg create mode 100644 public/signup/hero_wolf.svg create mode 100644 public/signup/thumb_bunny.svg create mode 100644 public/signup/thumb_koala.svg create mode 100644 public/signup/thumb_monkey.svg create mode 100644 public/signup/thumb_panda.svg create mode 100644 public/signup/thumb_penguin.svg create mode 100644 public/signup/thumb_rhino.svg create mode 100644 public/signup/thumb_seal.svg create mode 100644 public/signup/thumb_tiger.svg create mode 100644 public/signup/thumb_wolf.svg create mode 100644 public/terms.html create mode 100644 server.js create mode 100644 test/account.js create mode 100644 test/buddygames.js create mode 100644 test/features.js create mode 100644 test/harness.js create mode 100644 test/qol.js create mode 100644 test/restored.js create mode 100644 test/smoke.js create mode 100755 tools/build-client.sh create mode 100644 tools/client-test.js create mode 100644 tools/find-art.py create mode 100644 tools/hud/dump.py create mode 100644 tools/hud/transplant-nametag.py create mode 100644 tools/make-badges.py create mode 100644 tools/make-bio-tab.py create mode 100644 tools/make-emote.py create mode 100644 tools/pack-for-vps.sh create mode 100644 tools/publish-public.sh create mode 100644 tools/reset-admin-password.js create mode 100644 tools/room-assets.js create mode 100644 tools/room-history.js create mode 100644 tools/room-info.js create mode 100644 tools/sale-history.js create mode 100644 tools/shop-stock.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f70af02 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +# Accounts, login tokens and logs +data/ + +# Assets mirrored from the official CDN; re-downloaded on demand +cache/ + +# Third-party decompiler and its output; see HANDOFF.md for how to restore them +tools/ffdec/ +tools/decompiled/ +tools/hud/hud.xml +tools/hud/hud.pickle +tools/hud/__pycache__/ + +node_modules/ +*.log +tools/recorder.js +SITE.md + +# python leaves these beside the tools +__pycache__/ + +# kept in the private repository, never here +*.md +/swf +/swf-src +/client-updates +/HANDOFF.md +/DISCOVERIES.md +/GOING-PUBLIC.md diff --git a/config.js b/config.js new file mode 100644 index 0000000..b62ba46 --- /dev/null +++ b/config.js @@ -0,0 +1,307 @@ +"use strict"; + +const path = require("path"); + +const env = process.env; +const LOOPBACK_NAMES = ["127.0.0.1", "::1", "localhost"]; +const bindAddress = env.AJ_BIND || "127.0.0.1"; +const httpPort = Number(env.AJ_HTTP_PORT || 8080); +const gamePort = Number(env.AJ_GAME_PORT || 9339); +// with a certificate both ports speak TLS. the launcher follows suit when its +// own config.js uses an https:// address. +const tls = env.AJ_TLS_CERT && env.AJ_TLS_KEY ? {certFile: env.AJ_TLS_CERT, keyFile: env.AJ_TLS_KEY} : null; +// AJ_PUBLIC_URL: the address players reach this server at +// ("https://play.burrow.moe", with a port if it is not the usual one). it +// is the one switch for a server strangers can reach, whether this process +// listens on a public address itself or sits behind a reverse proxy or a +// tunnel: with it set the server knows it is public, tells the game that +// address, marks its cookies Secure when it is an https:// one, and trusts +// no request for coming from this machine (behind a proxy they all do). +const publicUrl = env.AJ_PUBLIC_URL ? new URL(env.AJ_PUBLIC_URL) : null; +const host = env.AJ_HOST || (publicUrl ? publicUrl.hostname : "127.0.0.1"); +// AJ_SITE_URL: where the web pages are (the home page, sign-up, the account +// page, the moderator panel, the terms), when that is another name than the +// game server's ("https://burrow.moe" beside AJ_PUBLIC_URL's +// "https://play.burrow.moe"). the server answers to both; a web page asked +// for under the game server's name is sent on to this one. +const siteUrl = env.AJ_SITE_URL ? new URL(env.AJ_SITE_URL) : null; +// reachable from other machines? several defaults get stricter when it is. +const isPublic = Boolean(publicUrl) || !LOOPBACK_NAMES.includes(bindAddress) || !LOOPBACK_NAMES.includes(env.AJ_GAME_BIND || bindAddress); +// AJ_TRUSTED_PROXY=1: a reverse proxy on this machine is the only thing that +// reaches the web port, and the visitor's address is the last one in the +// X-Forwarded-For header it sets. without it every visitor behind a proxy +// has the proxy's address, and the per-address limits see one address. +const trustedProxy = env.AJ_TRUSTED_PROXY === "1"; +// the game port can listen wider than the web port: a proxy (cloudflare, say) +// carries web pages but not the game's own protocol +const gameBindAddress = env.AJ_GAME_BIND || bindAddress; +const baseUrl = publicUrl ? `${publicUrl.origin}/` : `${tls ? "https" : "http"}://${host}:${httpPort}/`; +// settings that contradict each other are refused at start (server.js) +// rather than left to be found out. +const problems = []; +if (publicUrl && env.AJ_TRUST_LOCAL === "1") { + problems.push("AJ_PUBLIC_URL and AJ_TRUST_LOCAL=1 cannot both be set: behind a proxy every request looks local"); +} +if (trustedProxy && !LOOPBACK_NAMES.includes(bindAddress)) { + problems.push("AJ_TRUSTED_PROXY=1 needs AJ_BIND to be 127.0.0.1: anyone who reaches the port directly could name any address as theirs"); +} +if ((publicUrl || !LOOPBACK_NAMES.includes(bindAddress)) && env.AJ_REGISTER === "1") { + problems.push("AJ_REGISTER=1 cannot be used on a public server: an account made that way has agreed to nothing"); +} +if (Boolean(env.AJ_TURNSTILE_SITE_KEY) !== Boolean(env.AJ_TURNSTILE_SECRET)) { + problems.push("AJ_TURNSTILE_SITE_KEY and AJ_TURNSTILE_SECRET go together: set both or neither"); +} +if (siteUrl && (!publicUrl || !/^https?:$/.test(siteUrl.protocol))) { + problems.push("AJ_SITE_URL needs AJ_PUBLIC_URL, and must be an http:// or https:// address"); +} +if (publicUrl && !/^https?:$/.test(publicUrl.protocol)) { + problems.push("AJ_PUBLIC_URL must be an http:// or https:// address"); +} + +module.exports = { + // address the client is told to use. the patched ajclient.swf always opens + // its game socket to 127.0.0.1, so only change this together with the SWF. + host, + bindAddress, + gameBindAddress, + isPublic, + publicUrl, + trustedProxy, + problems, + tls, + // behind a trusted proxy the proxy encrypts the web port; the certificate is the game port's + webTls: trustedProxy ? null : tls, + // requests from this machine may use the item finder for any account and + // list accounts. never with AJ_PUBLIC_URL set; AJ_TRUST_LOCAL=0 turns it + // off otherwise. (A request that came through a proxy is never taken for + // local, whatever is set: lib/limits.js.) + trustLocalRequests: !publicUrl && env.AJ_TRUST_LOCAL !== "0", + httpPort, + gamePort, + baseUrl, + // the web pages' address: baseUrl unless AJ_SITE_URL names another + siteUrl: siteUrl ? `${siteUrl.origin}/` : baseUrl, + // cookies are only sent back over an encrypted connection when players + // have one, whoever does the encrypting. + secureCookies: baseUrl.startsWith("https:"), + // the admin panel answers this machine alone on a public server (reach it + // through an SSH tunnel), plus the addresses listed in AJ_ADMIN_ALLOW, + // separated by commas. on a local server it answers whoever can reach it. + adminAllow: (env.AJ_ADMIN_ALLOW || "").split(",").map(address => address.trim()).filter(Boolean), + + // cloudflare turnstile (lib/captcha.js): a captcha wherever a password is + // tried or an account is made, with both set. off without them. + turnstile: env.AJ_TURNSTILE_SITE_KEY && env.AJ_TURNSTILE_SECRET + ? {siteKey: env.AJ_TURNSTILE_SITE_KEY, secret: env.AJ_TURNSTILE_SECRET} : null, + + // asset mirror: anything not served locally is fetched once from here and + // cached in cacheDir. set AJ_OFFLINE=1 to serve from the cache only. + upstreamContent: env.AJ_UPSTREAM || "https://ajcontent.akamaized.net/", + offline: env.AJ_OFFLINE === "1", + deployVersion: env.AJ_DEPLOY_VERSION || "1830", + // older builds the CDN still serves, asked in turn for a room file the + // current build has dropped. 1828 is the last with the Summer Carnival. + olderBuilds: ["1828"], + // the client adds this to every asset address, so raising it makes every + // client fetch everything afresh. raise it whenever the server starts + // serving an asset differently (4: item defs with all eyes for all animals; + // 5: re-dated item packs, the room pack, HUD artwork with the 2014 name tag; + // 6: the party pack; 14 and 15: more rows in the Theme list; 16: clothing + // for every animal, and last-seen times on player cards; 17 and 18: the + // banned label on player cards). + // 19 to 25: the comforts of 2026-10-11, see HANDOFF.md. + // 39: chat drawn as text and never as markup, the chat filter, and the + // game no longer open to SWFs from other addresses. + // 40: the chat filter's window laid out again. + // 41: the game's text says "Burrow" where it said Animal Jam. + buildVersion: env.AJ_BUILD_VERSION || "41", + // what the official CDN is asked for; not ours to change. + upstreamBuildVersion: "3", + + // the patched game client and the font file its assets import, both in + // swf/ (ajclient.before-finder.swf there is the base the client is rebuilt + // from, see the README). + clientSwf: env.AJ_CLIENT_SWF || path.join(__dirname, "swf", "ajclient.swf"), + sharedFontsSwf: path.join(__dirname, "swf", "sharedFonts.swf"), + // the HUD artwork (assets/HUDAssets.swf on the CDN), served from here + // because it is changed: see "Rebuild" in the README. + hudAssetsSwf: path.join(__dirname, "swf", "HUDAssets.swf"), + dataDir: env.AJ_DATA_DIR || path.join(__dirname, "data"), + cacheDir: path.join(__dirname, "cache"), + // updates for installed clients, served at /client/ (the client's + // tools/make-update.js writes them here; they are in the repository) + clientUpdatesDir: env.AJ_CLIENT_UPDATES_DIR || path.join(__dirname, "client-updates"), + publicDir: path.join(__dirname, "public"), + + // accounts are made through the client's Create Account screens or the + // /register page. set AJ_REGISTER=1 to also create one whenever an unknown + // username logs in (handy for throwaway test accounts). + registerOnLogin: env.AJ_REGISTER === "1", + + // the terms of service and the privacy policy (public/terms.html, + // public/privacy.html). A sign-up records the version agreed to: change + // it when either text changes in a way that matters. the values under it + // are written into both pages. the emails and the host's country are + // placeholders until set; the operator is, at the owner's word, said to + // be in the EU without a name or a country. + termsVersion: "2026-10-13", + legalEmail: env.AJ_LEGAL_EMAIL || "legal@burrow.moe", + adminEmail: env.AJ_ADMIN_EMAIL || "admin@burrow.moe", + operator: env.AJ_OPERATOR || "an individual based in the European Union", + hostedIn: env.AJ_HOSTED_IN || "[country of the hosting provider]", + + // links on the home page; an empty download reads "Soon" + downloadUrl: env.AJ_DOWNLOAD_URL || "", + githubUrl: env.AJ_GITHUB_URL || "", + discordUrl: env.AJ_DISCORD_URL || "", + + // 2+ is a member. 4 and 5 unlock the client's developer debug overlays. + // no account type gives powers over other players; running the server is + // done from the admin panel at /admin (lib/panel.js). + defaultAccountType: 2, + // looks of the lands players can pick with the Theme list. the official CDN + // keeps past builds (35 of them, November 2022 to today), each with that + // month's version of every land, so a theme is first of all the build to + // take room files from. `rooms` then names rooms shown as another room + // file: the room list still carries seasonal copies of some lands that the + // official game stopped using years ago, and those are older than any + // build. `label` is for people; the list the game shows is in + // swf-src/MySettings.as, in the same order. + // + // the first eight are the latest year's seasons. the rest is every other + // season and year there is (DISCOVERIES.md, "Older designs of the lands", + // says what was looked through and how each was dated): one row for each + // season of each year the builds cover, then one for each year's worth + // of leftover seasonal room files. most differ from today's version of + // their season by a handful of decorations; the ones that show more: + // - 1636 and 1637: the Township's painting before it was redone in 2023 + // and Club Geoz was built. + // - 1691 and earlier: the Flag Shop in Sarepia, before it became the + // Hall of Animals. + // - friendship2018: the Township on its winter 2017 painting with the + // old arcade front, and Mt. shiveer before the bridge to Balloosh. + // - freedom2021: Freedom Day's fireworks, which today's July build no + // longer has. + themes: { + halloween: {label: "Halloween", build: 1830}, + fall: {label: "Fall", build: 1829}, + jamaalidays: {label: "Jamaalidays", build: 1810}, + winter: {label: "Winter", build: 1811}, + friendship: {label: "Friendship", build: 1815}, + lucky: {label: "Lucky Day", build: 1817}, + spring: {label: "Spring", build: 1820}, + summer: {label: "Summer", build: 1828}, + halloween2025: {label: "Halloween 2025", build: 1803}, + fall2025: {label: "Fall 2025", build: 1807}, + summer2025: {label: "Summer 2025", build: 1731}, + lucky2025: {label: "Lucky Day 2025", build: 1711}, + summer2024: {label: "Summer 2024", build: 1691}, + spring2024: {label: "Spring 2024", build: 1678}, + lucky2024: {label: "Lucky Day 2024", build: 1676}, + jamaalidays2022: {label: "Jamaalidays 2022", build: 1637}, + fall2022: {label: "Fall 2022", build: 1636}, + freedom2021: {label: "Freedom Day 2021", build: 1824, rooms: {"sarepia.room_main": "sarepia.room_main_freedom"}}, + jamaalidays2020: {label: "Jamaalidays 2020", build: 1810, rooms: {"sarepia.room_main": "sarepia.room_main_jamaalidays"}}, + spring2020: {label: "Spring 2020", build: 1820, rooms: {"canyon_path.room_main": "canyon_path.room_main_main"}}, + jamaalidays2018: { + label: "Jamaalidays 2018", + build: 1810, + rooms: { + "lost_temple_of_zios.room_main": "lost_temple_of_zios.room_main_jamaalidays", + "balloosh.room_main": "balloosh.room_main_jamaalidays", + }, + }, + summer2018: {label: "Summer 2018", build: 1828, rooms: {"sarepia.room_main": "sarepia.room_main_summer"}}, + lucky2018: {label: "Lucky Day 2018", build: 1817, rooms: {"mountains_of_shivveer.room_main": "mountains_of_shivveer.room_main_lucky"}}, + friendship2018: { + label: "Friendship 2018", + build: 1815, + rooms: { + "jamaa_township.room_main": "jamaa_township.room_main_friendship", + "mountains_of_shivveer.room_main": "mountains_of_shivveer.room_main_friendship", + "crystal_sands.room_main": "crystal_sands.room_main_friendship", + "lost_temple_of_zios.room_main": "lost_temple_of_zios.room_main_friendship", + }, + }, + // the Phantom Vortex rooms as saved in 2011 and 2013: no shop, no fog. + halloween2013: { + label: "Halloween 2013", + build: 1830, + rooms: Object.fromEntries([1, 2, 3, 4, 5].map(n => [`holidays_and_celebrations.room_jamaa_halloween${n}`, `rholidays_and_celebrations.room_jamaa_halloween${n}`])), + }, + }, + // rooms shown as another version of themselves in some months (1-12). + // both are versions the official game put up for a while and no door + // leads to today; when it did so is not recorded, so the months are ours: + // the Canyons Pathway with the plushie scavenger hunt's stand in spring, + // and the Conservation Museum with its "Antlers and Tusks" exhibit in + // place of the savannah one every other month. + roomSwaps: [ + {room: "canyon_path.room_main", shown: "canyon_path.room_main_main", months: [3, 4]}, + {room: "appondale.room_museum", shown: "appondale.room_museum_ant", months: [2, 4, 6, 8, 10, 12]}, + ], + startupRoom: "jamaa_township.room_main", + shards: [{id: 1, name: "Aldan"}], + maxUsersPerRoom: 80, + // everything in every shop for nothing (AJ_FREE_SHOPS=1). off unless + // asked for: what the game's shops make of a price of 0 has not been seen. + freeShops: env.AJ_FREE_SHOPS === "1", + // smooth movement in the client (AJClient.smoothOn in the SWF) for players + // who never chose: on, or with AJ_SMOOTH=0 off for everyone who has not + // chosen "Graphics: Smooth" themselves. the way back if it misbehaves. + smooth: env.AJ_SMOOTH !== "0", + partyMinutes: 120, + // row of the den-room defPack every player's den uses (1 = the small free den). + denDefId: 1, + // every currency of every account is raised to at least this at each login, + // so nobody runs dry while testing. + minimumCurrency: 10000000, + + // limits on what strangers can do. requests from the server's own machine + // are exempt from the per-address ones (see trustLocalRequests). + registrationsPerHour: 5, // per address + failedLoginsPerTenMinutes: 10, // per address, and 3x this per account + errorReportsPerMinute: 30, // per address + maxConnectionsPerAddress: 10, // game sockets + // the asset mirror (lib/cdn.js): files asked for that are not in the + // cache yet, per address; how long the official CDN is waited for; and + // how big the cache may grow (files are still fetched and served past + // that, only not kept). + cacheMissesPerTenMinutes: 1500, // a first visit with an empty cache fetches several hundred files + upstreamTimeoutMs: 20000, + maxCacheBytes: Number(env.AJ_MAX_CACHE_MB || 8192) * 1024 * 1024, + maxConnections: 2000, + maxHttpConnections: 2000, // open at once, in all + maxHttpConnectionsPerAddress: 40, // the game opens a good many at once while it loads + httpSocketTimeoutMs: 60000, // a connection nothing moves on is closed + tlsHandshakeTimeoutMs: 10000, + maxMessagesPerTenSeconds: 400, // per game socket; walking sends a few a second + loginTimeoutMs: 30000, // a game socket must log in within this + idleTimeoutMs: 15 * 60000, // the client sends a keep-alive far more often + tokenLifetimeDays: 30, // login tokens kept by the launcher's "remember me" + maxChatLength: 300, + // days typed chat and whispers are kept for the moderator panel's chat + // history (lib/chatlog.js); 0 keeps none. + chatLogDays: env.AJ_CHAT_LOG_DAYS === undefined ? 30 : Math.max(0, Number(env.AJ_CHAT_LOG_DAYS) || 0), + chatLinesPerWindow: 5, // typed chat lines one player may send ... + chatWindowMs: 3000, // ... in this long + maxBytesPerTenSeconds: 512 * 1024, // per game socket; saving a full den is about 40 KB + // custom colours (lib/colours.js). every one ever made is sent to every + // player at every login and is never taken out again, so there is an end + // to how many one account may add in a day and to the table as a whole. + customColoursPerDay: 30, + maxCustomColours: 20000, + + // may a client pick, when it logs in, how the game should treat the + // account for that session: member or not, guide, moderator, membership + // days left (the custom client's "advanced" settings)? it changes what that + // player's own game shows and the badge others see, never what the server + // lets them do. on by default only for a local server; + // AJ_LOGIN_CHOICES=1 / 0 forces it. + loginChoices: env.AJ_LOGIN_CHOICES === undefined ? !isPublic : env.AJ_LOGIN_CHOICES === "1", + + // log every game packet in both directions (login tokens are masked), plus + // the client's media-load traces. on by default only for a local server; + // AJ_QUIET=1 / AJ_QUIET=0 forces it off / on. + logPackets: env.AJ_QUIET === undefined ? !isPublic : env.AJ_QUIET !== "1", +}; diff --git a/deploy/burrow-update.service b/deploy/burrow-update.service new file mode 100644 index 0000000..8d29871 --- /dev/null +++ b/deploy/burrow-update.service @@ -0,0 +1,7 @@ +[Unit] +Description=Update the Burrow server from GitHub +After=network-online.target + +[Service] +Type=oneshot +ExecStart=/bin/bash /home/aj/ajc-private-server/deploy/update.sh diff --git a/deploy/burrow-update.timer b/deploy/burrow-update.timer new file mode 100644 index 0000000..7d33f3c --- /dev/null +++ b/deploy/burrow-update.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Look for a new Burrow server every two minutes + +[Timer] +OnBootSec=2min +OnUnitActiveSec=2min + +[Install] +WantedBy=timers.target diff --git a/deploy/update.sh b/deploy/update.sh new file mode 100644 index 0000000..a5c07d3 --- /dev/null +++ b/deploy/update.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# brings the server to origin's main and restarts it when the change needs it. +# run as root by burrow-update.timer; git itself runs as the server's user. +set -euo pipefail + +dir=${BURROW_DIR:-/home/aj/ajc-private-server} +user=${BURROW_USER:-aj} +service=${BURROW_SERVICE:-burrow} +branch=${BURROW_BRANCH:-main} + +git() { runuser -u "$user" -- git -C "$dir" "$@"; } + +git fetch --quiet origin "$branch" +old=$(git rev-parse HEAD) +new=$(git rev-parse "origin/$branch") +[ "$old" != "$new" ] || exit 0 + +# only a fast-forward: a server that was edited by hand is left for a person +git merge --quiet --ff-only "origin/$branch" + +# a file that does not parse would take the game down on restart +for file in $(git diff --name-only "$old" "$new" -- '*.js'); do + if [ -f "$dir/$file" ] && ! runuser -u "$user" -- node --check "$dir/$file"; then + git reset --quiet --hard "$old" + echo "update to $new refused: $file does not parse; staying on $old" >&2 + exit 1 + fi +done + +# public/ is read from disk on every request; the rest is loaded once, at start +if git diff --name-only "$old" "$new" | grep -qvE '^(public/|client-updates/|test/|tools/|deploy/|[^/]+\.md$|\.gitignore$)'; then + systemctl restart "$service" + echo "updated $old -> $new, restarted $service" +else + echo "updated $old -> $new, no restart needed" +fi diff --git a/lib/accounts.js b/lib/accounts.js new file mode 100644 index 0000000..2509c2c --- /dev/null +++ b/lib/accounts.js @@ -0,0 +1,694 @@ +"use strict"; + +const crypto = require("crypto"); +const fs = require("fs"); +const path = require("path"); +const {DatabaseSync} = require("node:sqlite"); +const config = require("../config.js"); +const defpacks = require("./defpacks.js"); +const names = require("./names.js"); + +// accounts live in a SQLite database. identity and credentials are columns; +// everything a player owns (animals, items, pets, den, buddies, ...) is one +// JSON document per account in `state`. +// +// every account is held in memory while the server runs. game code changes +// those objects directly and then calls save(), which has every account +// whose state changed written back, a moment later: however many times it +// is called in that moment, the accounts are gone through once (flush). + +const SCHEMA = ` + CREATE TABLE IF NOT EXISTS accounts ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + username TEXT NOT NULL, + username_key TEXT NOT NULL UNIQUE, + password_salt TEXT NOT NULL, + password_hash TEXT NOT NULL, + created_at INTEGER NOT NULL, + state TEXT NOT NULL + ); + CREATE TABLE IF NOT EXISTS settings ( + key TEXT PRIMARY KEY, + value TEXT NOT NULL + ); + CREATE TABLE IF NOT EXISTS retired_names ( + name_key TEXT PRIMARY KEY, + until INTEGER NOT NULL + ); + CREATE TABLE IF NOT EXISTS tokens ( + token TEXT PRIMARY KEY, + account_id INTEGER NOT NULL REFERENCES accounts(id) ON DELETE CASCADE, + created_at INTEGER NOT NULL + ); +`; + +// fields stored in their own columns rather than in `state`. +const COLUMN_FIELDS = ["id", "username", "salt", "hash", "createdAt"]; +// how the game treats the account this session; set again at every login. +const SESSION_FIELDS = ["accountType", "isGuide", "isModerator", "membershipDays", "startInDen", "startRoom"]; +const DEFAULT_MEMBERSHIP_DAYS = 9999; +const MAX_ACCOUNT_TYPE = 5; +const MAX_MEMBERSHIP_DAYS = 99999; + +const USERNAME_PATTERN = /^[A-Za-z0-9 .-]{3,20}$/; +const MIN_LETTERS = 3; // the client's own rule (SbiConstants.USERNAME_REGEX) +const MIN_PASSWORD_LENGTH = 10; +const MAX_DEN_SLOTS = 200; // DenSwitch.nextFreeSlotIdx +const DEN_OPEN = 2; // den privacy: 0 locked, 1 buddies only, 2 everyone +const MAX_PASSWORD_LENGTH = 100; +// parts of the game a player can switch off for their own account, each +// enforced where the game asks for it (featureOn below). +// the Early Member badge (lib/badges.js) goes to an account made while +// there are no more than this many. +const EARLY_MEMBERS = 100; +const EARLY_BADGE = "early"; +const EARLY_SETTING = "earlyMembersGiven"; + +const FEATURES = ["chat", "buddies", "trading", "jamagrams", "gameInvites", "wall"]; +const MAX_LOGINS_KEPT = 40; +const LOGIN_DAYS_KEPT = 90; // and none older than this: they hold addresses + +let db = null; +const byKey = new Map(); // lowercased username -> account +const byId = new Map(); +const savedState = new Map(); // account id -> state JSON as last written +// A name somebody gave up (a rename, a deleted account) is nobody's to take +// for a while: whoever had it is still known by it to the players they met. +const NAME_HELD_DAYS = 30; +const retired = new Map(); // lowercased username -> until (seconds) +const tokens = new Map(); // SHA-256 of a login token -> {id, createdAt} + +// tokens are as good as passwords, so only their hashes are stored. +const TOKEN_HEX_LENGTH = 48; +const MAX_TOKENS_PER_ACCOUNT = 10; +const tokenHash = token => crypto.createHash("sha256").update(token).digest("hex"); +const tokenExpired = createdAt => now() - createdAt > config.tokenLifetimeDays * 86400; + +const now = () => Math.floor(Date.now() / 1000); + +const hashPassword = (password, salt) => crypto.scryptSync(password, salt, 32).toString("hex"); +// the same off the main thread, for the sign-ins strangers can repeat: a +// password check takes long enough that a row of them would hold the game up. +const hashPasswordAsync = (password, salt) => new Promise((resolve, reject) => { + crypto.scrypt(password, salt, 32, (err, hash) => (err ? reject(err) : resolve(hash.toString("hex")))); +}); +// checked against when the name is nobody's, so that a wrong name takes as +// long to refuse as a wrong password. +const NOBODY_SALT = crypto.randomBytes(16).toString("hex"); + +// eyes and pattern an animal type starts with. custom ("special") animals +// carry their own pattern. +const newAvatar = (ids, name, type, customAvId) => { + const def = defpacks.avatarDef(type); + const custom = defpacks.customAvatarDef(customAvId); + return { + ...ids, + name, + type: Number(type), + customAvId: custom ? Number(customAvId) : -1, + colors: [def.colorLayer1, Number(custom && custom.overrideColorLayer2) || def.colorLayer2, def.colorLayer3].map(Number), + eyes: Number(def.baseEyesId) || 0, + pattern: Number(custom ? custom.patternRefId : def.basePatternId) || 0, + petInvId: 0, + }; +}; + +// an animal's inventory id is a bit's place in what the client keeps for +// every piece of clothing, "which of my animals wear this" +// (item.EquippedAvatars): 32 words of 32 bits and no more, and a bit past +// them is an error that ends the login. so it is a slot, 1 to 1000, and +// never a number from the item counter. +const MAX_AVATAR_SLOT = 1000; +const freeAvatarSlot = account => { + const taken = new Set(account.avatars.map(avatar => avatar.avInvId)); + let slot = 1; + while (taken.has(slot)) { + slot++; + } + return slot; +}; + +// brings accounts saved by older versions up to the current shape. +const normalize = account => { + if (!account.avatars) { + const old = account.avatar; + account.avatars = [{...newAvatar({perUserAvId: old.perUserAvId, avInvId: old.avInvId}, old.name, old.type, old.customAvId), colors: old.colors}]; + account.activeAvatar = old.perUserAvId; + delete account.avatar; + } + account.currency = account.currency || {}; + account.items = account.items || []; // {inv, def, color, on: [avInvId, ...]} + // animals made before their inventory ids were slots (above) have ids + // from the item counter: they move into free slots, and what their + // clothes say about who wears them follows. + for (const avatar of account.avatars.filter(candidate => !(candidate.avInvId >= 1 && candidate.avInvId <= MAX_AVATAR_SLOT))) { + const old = avatar.avInvId; + avatar.avInvId = 0; // out of the way while a slot is looked for + avatar.avInvId = freeAvatarSlot(account); + for (const item of account.items) { + item.on = (item.on || []).map(avInvId => (avInvId === old ? avatar.avInvId : avInvId)); + } + if (account.outfitUndo && account.outfitUndo.avInvId === old) { + account.outfitUndo.avInvId = avatar.avInvId; + } + } + account.pets = account.pets || []; // {inv, lBits, uBits, eBits, name, createdAt} + account.dens = account.dens || [{inv: 0, def: config.denDefId}]; // den rooms owned + account.activeDen = account.activeDen || 0; // inv of the den in use + // A den's id is its slot on the den switcher, 0 to 199 (lib/dens.js). dens + // bought before that was known have ids from the item counter: they move + // into the first free slots, and what points at them follows. + if (account.dens.some(den => den.inv >= MAX_DEN_SLOTS)) { + const taken = new Set(account.dens.map(den => den.inv).filter(inv => inv < MAX_DEN_SLOTS)); + const moved = new Map(); + for (const den of account.dens.filter(candidate => candidate.inv >= MAX_DEN_SLOTS)) { + let slot = 0; + while (taken.has(slot)) { + slot++; + } + taken.add(slot); + moved.set(den.inv, slot); + den.inv = slot; + } + account.activeDen = moved.has(account.activeDen) ? moved.get(account.activeDen) : account.activeDen; + for (const item of account.denItems || []) { + item.den = moved.has(item.den) ? moved.get(item.den) : item.den; + } + } + account.denPrivacy = account.denPrivacy === undefined ? DEN_OPEN : account.denPrivacy; + account.denItems = account.denItems || []; // {inv, def, version, placed, den, x, y, flip, mannequin?, image?}: lib/dens.js + for (const item of account.denItems) { + item.den = item.den === undefined ? account.activeDen : item.den; // which den it is placed in + } + account.userVars = account.userVars || {}; + account.theme = account.theme || ""; // seasonal look of the lands, see themes in config.js + account.lastSeen = account.lastSeen || 0; // when they last left the game, in seconds; 0 = never recorded + // what the player set on the account page (lib/manage.js). + account.features = {...Object.fromEntries(FEATURES.map(name => [name, true])), ...account.features}; // false = switched off + account.locked = account.locked === true; // nobody gets into the game until its owner unlocks it + account.logins = account.logins || []; // {at, via, address, ok}, newest first: lib/accounts.js recordLogin + account.roomThemes = account.roomThemes || {}; // room -> theme, for rooms given a look of their own ("!theme here") + account.randomTheme = account.randomTheme === true; // a theme picked afresh at every login + account.denVisits = account.denVisits || []; // {at, name}, newest first: who came into their den + account.buddyNotes = account.buddyNotes || {}; // lowercased username -> the player's own note about that buddy + account.tradeHistory = account.tradeHistory || []; // {at, with, got: [names], gave: [names]}, newest first + account.outfitUndo = account.outfitUndo || null; // {avInvId, items: [inv]}: what an animal wore before its last change + account.denNames = account.denNames || {}; // den inv -> a name of the player's own ("!den name") + account.finderGiven = account.finderGiven || {}; // "kind:id" -> {count, at}: what they took from the item finder + account.tradeOffers = account.tradeOffers || []; // offers left for this account while its owner was away: lib/trades.js + account.denUndo = account.denUndo || null; // the den as it stood before it was last cleared: {den, items} + account.buddies = account.buddies || []; // lowercased usernames + account.blocked = account.blocked || []; + account.buddyRequests = account.buddyRequests || []; // lowercased usernames of who asked, see lib/buddies.js + account.tradeList = account.tradeList || []; // {type, inv}; types as in TradeItem + account.achievements = account.achievements || []; // {inv, def}, see lib/achievements.js + account.adoptAPets = account.adoptAPets || []; // {inv, def, ts, seen}, see lib/adopt.js + account.ecards = account.ecards || []; // the Jam-A-Gram inbox, see lib/ecards.js + account.ecardPrivacy = account.ecardPrivacy || 0; // 0 everyone, 1 buddies only, 2 nobody + // the Jammer Wall, see lib/walls.js. privacy: 0 nobody, 1 buddies only, 2 everyone. + account.wall = account.wall || {privacy: DEN_OPEN, posts: [], params: {bg: "19"}, visits: 0, hidden: [], modified: 0, readAt: 0}; + account.outfits = account.outfits || []; // {name, items: [inv, ...]}, see lib/commands.js + account.denLayouts = account.denLayouts || []; // {name, den, items: [{def, version, x, y, flip}]} + account.hideBlocked = account.hideBlocked === true; // do not show me players I blocked + // the name tag: colour in the low byte, badge above it, bit 16 hides the + // adventure level shape (avatar.NameBar.setColorAndBadge). + account.nameBarData = Number.isInteger(account.nameBarData) ? account.nameBarData : 0; + account.disguise = Number.isInteger(account.disguise) ? account.disguise : 0; // NPC id, see lib/disguises.js + // shown on the player's card: lib/badges.js. + account.discord = typeof account.discord === "string" ? account.discord : ""; // their Discord username, as they gave it + account.badges = Array.isArray(account.badges) ? account.badges : []; // badge ids, given in the admin panel + account.bio = typeof account.bio === "string" ? account.bio : ""; // their own words, for the card's Bio tab + // the chat filter, which the player's own game applies (AJClient in the + // patched SWF; "xfl" in lib/world.js): {level: 1 slurs and threats, 2 + // swearing too, 0 off; mode: 0 stars over the words, 1 the message left + // out; words: their own, commas between; chosen: have they been asked}. + // an account that has not chosen has no filter: that is the start. + account.filter = account.filter && typeof account.filter === "object" && account.filter.chosen ? account.filter : {level: 0, mode: 0, words: "", chosen: false}; + // two-step sign-in: lib/totp.js. + account.totp = account.totp || null; + account.totpSetup = account.totpSetup || null; + account.devices = Array.isArray(account.devices) ? account.devices : []; + account.nextInv = account.nextInv || 2; + account.numLogins = account.numLogins || 0; + account.uuid = account.uuid || crypto.randomUUID(); + setLoginChoices(account, null); + return account; +}; + +// sets how the game treats the account for the coming session. `choices` is +// what the client asked for at login ({accountType, isGuide, isModerator, +// membershipDays}, each optional); anything missing, invalid or not allowed +// by config.loginChoices gets the usual value. +const MAX_START_ROOM = 80; + +function setLoginChoices(account, choices) { + const asked = config.loginChoices && choices && typeof choices === "object" ? choices : {}; + const whole = (value, max) => Number.isInteger(value) && value >= 0 && value <= max; + account.accountType = whole(asked.accountType, MAX_ACCOUNT_TYPE) ? asked.accountType : config.defaultAccountType; + account.isGuide = asked.isGuide === true; + account.isModerator = asked.isModerator === true; + account.membershipDays = whole(asked.membershipDays, MAX_MEMBERSHIP_DAYS) ? asked.membershipDays : DEFAULT_MEMBERSHIP_DAYS; + // where to start is the player's to say on any server: their own den in + // place of the township (the custom client's "Start in your own den"). + account.startInDen = Boolean(choices && typeof choices === "object" && choices.startInDen === true); + // ... or a room or den by name ("denf", "jamaa_township.room_main"); + // lib/world.js checks that there is such a place. + const room = choices && typeof choices === "object" ? choices.startRoom : null; + account.startRoom = typeof room === "string" && room.length <= MAX_START_ROOM && !room.includes("%") ? room.trim() : ""; +} + +const stateJson = account => JSON.stringify(Object.fromEntries(Object.entries(account) + .filter(([field]) => !COLUMN_FIELDS.includes(field) && !SESSION_FIELDS.includes(field)))); + +const remember = account => { + byKey.set(account.username.toLowerCase(), account); + byId.set(account.id, account); +}; + +const insert = (username, salt, hash, createdAt, state) => { + const account = normalize({username, salt, hash, createdAt, ...state}); + const json = stateJson(account); + const result = db.prepare("INSERT INTO accounts (username, username_key, password_salt, password_hash, created_at, state) VALUES (?, ?, ?, ?, ?, ?)") + .run(username, username.toLowerCase(), salt, hash, createdAt, json); + account.id = Number(result.lastInsertRowid); + savedState.set(account.id, json); + remember(account); + return account; +}; + +// one-time import of the accounts.json file earlier versions kept. +const importLegacyFile = () => { + const file = path.join(config.dataDir, "accounts.json"); + if (!fs.existsSync(file) || db.prepare("SELECT COUNT(*) AS count FROM accounts").get().count > 0) { + return; + } + const legacy = JSON.parse(fs.readFileSync(file, "utf8")); + db.exec("BEGIN"); + for (const old of Object.values(legacy.accounts)) { + const {id, username, salt, hash, createdAt, ...state} = old; + if (!byKey.has(username.trim().toLowerCase())) { + insert(username.trim(), salt, hash, createdAt || now(), state); + } + } + for (const [token, usernameKey] of Object.entries(legacy.tokens || {})) { + const account = byKey.get(usernameKey.trim()); + if (account) { + db.prepare("INSERT INTO tokens (token, account_id, created_at) VALUES (?, ?, ?)").run(token, account.id, now()); + } + } + db.exec("COMMIT"); + fs.renameSync(file, `${file}.imported`); + console.log(`[accounts] imported ${byKey.size} accounts from accounts.json`); +}; + +const load = () => { + fs.mkdirSync(config.dataDir, {recursive: true}); + db = new DatabaseSync(path.join(config.dataDir, "game.sqlite")); + // busy_timeout: something else writing to the file for a moment (a tool, + // a copy being made) is waited for, not an error. + db.exec("PRAGMA journal_mode = WAL; PRAGMA foreign_keys = ON; PRAGMA busy_timeout = 5000;"); + db.exec(SCHEMA); + for (const row of db.prepare("SELECT * FROM accounts").all()) { + const account = normalize({ + id: row.id, + username: row.username, + salt: row.password_salt, + hash: row.password_hash, + createdAt: row.created_at, + ...JSON.parse(row.state), + }); + savedState.set(account.id, row.state); + remember(account); + } + importLegacyFile(); + db.prepare("DELETE FROM retired_names WHERE until < ?").run(now()); + for (const row of db.prepare("SELECT name_key, until FROM retired_names").all()) { + retired.set(row.name_key, row.until); + } + // trade offers left on an account name who made them by account id + // (lib/trades.js). ones from before that named a username: the id is + // filled in, and an offer by nobody still here is dropped. + for (const account of byId.values()) { + for (const offer of account.tradeOffers) { + if (offer.fromId === undefined) { + const maker = byKey.get(String(offer.from)); + offer.fromId = maker ? maker.id : 0; + } + } + account.tradeOffers = account.tradeOffers.filter(offer => byId.has(offer.fromId)); + } + // accounts made before some names were set aside keep theirs; whoever + // runs the server is told which, to rename by hand if they see fit. + const unusual = [...byId.values()].filter(account => names.refused(account.username)).map(account => account.username); + if (unusual.length) { + console.log(`[accounts] usernames that could not be chosen today: ${unusual.slice(0, 50).join(", ")}${unusual.length > 50 ? ", ..." : ""}`); + } + // once: the Early Member badge for the accounts that were there before + // it existed, the oldest hundred of them. + if (!setting(EARLY_SETTING)) { + const oldest = [...byId.values()].sort((one, other) => one.createdAt - other.createdAt || one.id - other.id).slice(0, EARLY_MEMBERS); + for (const account of oldest) { + if (!account.badges.includes(EARLY_BADGE)) { + account.badges.push(EARLY_BADGE); + } + } + flush(); + setSetting(EARLY_SETTING, "1"); + } + // tokens stored as issued by earlier versions are replaced by their hashes. + const rehash = db.prepare("UPDATE tokens SET token = ? WHERE token = ?"); + for (const row of db.prepare("SELECT token FROM tokens WHERE length(token) = ?").all(TOKEN_HEX_LENGTH)) { + rehash.run(tokenHash(row.token), row.token); + } + db.prepare("DELETE FROM tokens WHERE created_at < ?").run(now() - config.tokenLifetimeDays * 86400); + for (const row of db.prepare("SELECT token, account_id, created_at FROM tokens").all()) { + tokens.set(row.token, {id: row.account_id, createdAt: row.created_at}); + } + console.log(`[accounts] ${byKey.size} accounts in ${path.join(config.dataDir, "game.sqlite")}`); +}; + +// writes every account whose state changed since it was last written, in +// one transaction. +const flush = () => { + clearTimeout(saveTimer); + saveTimer = null; + if (!db) { + return; + } + const changed = []; + for (const account of byId.values()) { + const json = stateJson(account); + if (savedState.get(account.id) !== json) { + changed.push([account.id, json]); + } + } + if (changed.length === 0) { + return; + } + const update = db.prepare("UPDATE accounts SET state = ? WHERE id = ?"); + db.exec("BEGIN"); + try { + for (const [id, json] of changed) { + update.run(json, id); + } + db.exec("COMMIT"); + } + catch (err) { + db.exec("ROLLBACK"); + throw err; + } + for (const [id, json] of changed) { + savedState.set(id, json); + } +}; + +// "Something changed": the accounts are written within SAVE_DELAY_MS. going +// through every account costs more the more there are, and game code calls +// this after nearly every message (and some of it a hundred times in a +// row), so the going-through is done once for all the calls of a moment. +// what a crash can lose is that moment; a stop of the server writes first +// (server.js). +const SAVE_DELAY_MS = 1000; +let saveTimer = null; +const save = () => { + if (saveTimer === null) { + saveTimer = setTimeout(() => { + try { + flush(); + } + catch (err) { + console.error(`[accounts] could not save: ${err.message}`); + save(); // tried again in a moment: nothing is lost while the server runs + } + }, SAVE_DELAY_MS); + } +}; + +// A copy of the whole database, made once a day into data/backups/ and the +// latest BACKUPS_KEPT kept. it is a whole file of its own (VACUUM INTO), to +// be copied somewhere else by whoever runs the server: a copy on the same +// disk is no help when the disk goes. +const BACKUPS_KEPT = 14; +const backup = () => { + const folder = path.join(config.dataDir, "backups"); + const file = path.join(folder, `game-${new Date().toISOString().slice(0, 10)}.sqlite`); + if (fs.existsSync(file)) { + return; + } + fs.mkdirSync(folder, {recursive: true, mode: 0o700}); + flush(); + db.prepare("VACUUM INTO ?").run(file); + fs.chmodSync(file, 0o600); + const old = fs.readdirSync(folder).filter(name => /^game-\d{4}-\d{2}-\d{2}\.sqlite$/.test(name)).sort().slice(0, -BACKUPS_KEPT); + for (const name of old) { + fs.unlinkSync(path.join(folder, name)); + } + console.log(`[accounts] backup written: ${file}`); +}; +const startBackups = () => { + const attempt = () => { + try { + backup(); + } + catch (err) { + console.error(`[accounts] backup failed: ${err.message}`); + } + }; + attempt(); + setInterval(attempt, 3600000).unref(); +}; + +const usernameProblem = username => { + if (typeof username !== "string" || !USERNAME_PATTERN.test(username) || username !== username.trim() || /\s{2,}/.test(username) + || (username.match(/[A-Za-z]/g) || []).length < MIN_LETTERS) { + return "invalid_username"; + } + if (byKey.has(username.toLowerCase()) || (retired.get(username.toLowerCase()) || 0) > now()) { + return "username_taken"; + } + // staff-like names and slurs (lib/names.js). + return names.refused(username) ? "name_not_allowed" : null; +}; + +const retire = key => { + const until = now() + NAME_HELD_DAYS * 86400; + retired.set(key, until); + db.prepare("INSERT INTO retired_names (name_key, until) VALUES (?, ?) ON CONFLICT(name_key) DO UPDATE SET until = excluded.until").run(key, until); +}; + +// A new password: ten characters or more, with a capital letter, a small +// one and a digit among them. passwords chosen before this rule still sign +// in; it is asked of the next one. +const passwordProblem = password => + (typeof password !== "string" || password.length < MIN_PASSWORD_LENGTH || password.length > MAX_PASSWORD_LENGTH + || !/[A-Z]/.test(password) || !/[a-z]/.test(password) || !/[0-9]/.test(password) ? "invalid_password" : null); + +// creates an account. `avatar` gives the first animal's {type, name}; the +// name may be left out, and is then the player's. there is no default +// animal: whoever signs up picks one. +// returns {account} or {error: "invalid_username" | "username_taken" | +// "invalid_password" | "choose_animal"}. +const register = (username, password, avatar = {}) => { + username = typeof username === "string" ? username.trim() : username; + const error = usernameProblem(username) || passwordProblem(password) || (defpacks.avatarDef(avatar.type) ? null : "choose_animal"); + if (error) { + return {error}; + } + const type = Number(avatar.type); + const salt = crypto.randomBytes(16).toString("hex"); + const account = insert(username, salt, hashPassword(password, salt), now(), { + avatars: [newAvatar({perUserAvId: 1, avInvId: 1}, avatar.name || username, type, -1)], + activeAvatar: 1, + // early Member, for an account made while there are no more than a hundred. + badges: byId.size < EARLY_MEMBERS ? [EARLY_BADGE] : [], + }); + console.log(`[accounts] registered "${username}" (id ${account.id})`); + return {account}; +}; + +const authenticate = (username, password) => { + // "name" and "name " are the same account. + const account = typeof username === "string" ? byKey.get(username.trim().toLowerCase()) : null; + if (typeof password !== "string" || !password) { + return null; + } + if (password.length > MAX_PASSWORD_LENGTH) { + return null; + } + if (!account) { + // throwaway test accounts (AJ_REGISTER=1) are the one sign-up with no + // choice of animal to make. + if (config.registerOnLogin) { + return register(username, password, {type: defpacks.defaultAvatarType()}).account || null; + } + hashPassword(password, NOBODY_SALT); + return null; + } + const hash = Buffer.from(hashPassword(password, account.salt), "hex"); + return crypto.timingSafeEqual(hash, Buffer.from(account.hash, "hex")) ? account : null; +}; + +// the same, with the password worked out off the main thread (above). +const authenticateAsync = async (username, password) => { + const account = typeof username === "string" ? byKey.get(username.trim().toLowerCase()) : null; + if (typeof password !== "string" || !password || password.length > MAX_PASSWORD_LENGTH) { + return null; + } + if (!account) { + if (config.registerOnLogin) { + return register(username, password, {type: defpacks.defaultAvatarType()}).account || null; + } + await hashPasswordAsync(password, NOBODY_SALT); + return null; + } + const {salt, hash: stored} = account; + const hash = Buffer.from(await hashPasswordAsync(password, salt), "hex"); + // the account may have gone, or got a new password, in the meantime. + return byId.get(account.id) === account && account.hash === stored && crypto.timingSafeEqual(hash, Buffer.from(stored, "hex")) ? account : null; +}; + +// gives the account a new password and signs it out everywhere. returns +// "invalid_password" when the password is not acceptable, else null. +const setPassword = (account, password) => { + const problem = passwordProblem(password); + if (problem) { + return problem; + } + account.salt = crypto.randomBytes(16).toString("hex"); + account.hash = hashPassword(password, account.salt); + db.prepare("UPDATE accounts SET password_salt = ?, password_hash = ? WHERE id = ?").run(account.salt, account.hash, account.id); + revokeTokens(account); + account.devices = []; // every device gives its two-step code again (lib/totp.js) + flush(); + return null; +}; + +// the only limits on a username the admin sets by hand: it has to be storable +// and able to reach the game at all. the database needs some text and a name +// nobody else has; "%" and control characters cannot travel through the game +// protocol ("%" separates its fields), so such a name could never log in. +// MAX_STORED_USERNAME is a sanity cap, not a rule of the game. +const MAX_STORED_USERNAME = 100; +const storableUsernameProblem = username => { + if (typeof username !== "string" || username.length === 0 || username.length > MAX_STORED_USERNAME + || /[%\u0000-\u001f\u007f]/.test(username) || username.includes("]]>")) { + return "invalid_username"; + } + return byKey.has(username.toLowerCase()) ? "username_taken" : null; +}; + +// gives the account a new username, and carries it into everyone's buddy and +// block lists. returns "invalid_username" or "username_taken", else null. +// the player must not be online: the game knows them by the old name. +// with `anyName` (the admin panel) the sign-up rules about length and +// characters do not apply; see storableUsernameProblem. +const rename = (account, username, anyName = false) => { + // spaces around a name are dropped: logging in drops them too. + username = typeof username === "string" ? username.trim() : username; + const oldKey = account.username.toLowerCase(); + // only changing the capitals of one's own name is not "taken". + const problem = typeof username === "string" && username.toLowerCase() === oldKey && username !== account.username + ? null : (anyName ? storableUsernameProblem : usernameProblem)(username); + if (problem) { + return problem; + } + const newKey = username.toLowerCase(); + if (newKey !== oldKey) { + retire(oldKey); + retired.delete(newKey); // the admin gave out a held name + db.prepare("DELETE FROM retired_names WHERE name_key = ?").run(newKey); + } + db.prepare("UPDATE accounts SET username = ?, username_key = ? WHERE id = ?").run(username, newKey, account.id); + console.log(`[accounts] renamed "${account.username}" to "${username}" (id ${account.id})`); + byKey.delete(oldKey); + account.username = username; + byKey.set(newKey, account); + for (const other of byId.values()) { + other.buddies = other.buddies.map(name => (name === oldKey ? newKey : name)); + other.blocked = other.blocked.map(name => (name === oldKey ? newKey : name)); + other.buddyRequests = other.buddyRequests.map(name => (name === oldKey ? newKey : name)); + } + save(); + return null; +}; + +// is this part of the game switched on for the account (FEATURES)? +const featureOn = (account, name) => account.features[name] !== false; + +// notes a sign-in, or a wrong password, in the account's own history. +// `via` is "game" (the game itself connecting), "launcher" (signing in to +// play) or "web" (the account page). the caller saves. +const recordLogin = (account, via, address, ok = true) => { + account.logins.unshift({at: now(), via, address: String(address || "").replace(/^::ffff:/, "").slice(0, 60), ok}); + account.logins = account.logins.filter(login => login.at > now() - LOGIN_DAYS_KEPT * 86400).slice(0, MAX_LOGINS_KEPT); +}; + +const revokeTokens = account => { + db.prepare("DELETE FROM tokens WHERE account_id = ?").run(account.id); + for (const [hash, entry] of tokens) { + if (entry.id === account.id) { + tokens.delete(hash); + } + } +}; + +// deletes the account for good, and its name from everyone's buddy and +// block lists. +const remove = account => { + const key = account.username.toLowerCase(); + revokeTokens(account); + db.prepare("DELETE FROM accounts WHERE id = ?").run(account.id); + byKey.delete(key); + byId.delete(account.id); + savedState.delete(account.id); + retire(key); + for (const other of byId.values()) { + other.tradeOffers = other.tradeOffers.filter(offer => offer.fromId !== account.id); + other.buddies = other.buddies.filter(name => name !== key); + other.blocked = other.blocked.filter(name => name !== key); + other.buddyRequests = other.buddyRequests.filter(name => name !== key); + } + save(); + console.log(`[accounts] deleted "${account.username}" (id ${account.id})`); +}; + +// small server-wide values kept in the database (the admin panel's password). +const setting = key => { + const row = db.prepare("SELECT value FROM settings WHERE key = ?").get(key); + return row ? row.value : null; +}; + +const setSetting = (key, value) => { + db.prepare("INSERT INTO settings (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value").run(key, value); +}; + +// one token serves as both auth_token and refresh_token. it stops working +// after config.tokenLifetimeDays, and each account keeps only its newest few. +const issueToken = account => { + const token = crypto.randomBytes(TOKEN_HEX_LENGTH / 2).toString("hex"); + const hash = tokenHash(token); + const createdAt = now(); + db.prepare("INSERT INTO tokens (token, account_id, created_at) VALUES (?, ?, ?)").run(hash, account.id, createdAt); + tokens.set(hash, {id: account.id, createdAt}); + const mine = [...tokens].filter(([, entry]) => entry.id === account.id).sort((a, b) => b[1].createdAt - a[1].createdAt); + for (const [oldHash] of mine.slice(MAX_TOKENS_PER_ACCOUNT)) { + db.prepare("DELETE FROM tokens WHERE token = ?").run(oldHash); + tokens.delete(oldHash); + } + return token; +}; + +const byToken = token => { + const entry = typeof token === "string" && token.length === TOKEN_HEX_LENGTH ? tokens.get(tokenHash(token)) : null; + return entry && !tokenExpired(entry.createdAt) ? byId.get(entry.id) || null : null; +}; + +const byName = username => byKey.get(String(username).toLowerCase()) || null; + +const accountById = id => byId.get(Number(id)) || null; + +const all = () => [...byId.values()]; + +const database = () => db; + +module.exports = {FEATURES, featureOn, recordLogin, revokeTokens, load, save, flush, startBackups, database, setLoginChoices, setPassword, rename, remove, setting, setSetting, hashPassword, register, usernameProblem, authenticate, authenticateAsync, issueToken, byToken, byName, byId: accountById, newAvatar, freeAvatarSlot, all}; diff --git a/lib/achievements.js b/lib/achievements.js new file mode 100644 index 0000000..7316c16 --- /dev/null +++ b/lib/achievements.js @@ -0,0 +1,167 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const defpacks = require("./defpacks.js"); + +// achievements (client side: AchievementManager, AchievementXtCommManager). +// an achievement def names a user var and the value it has to reach. most +// user vars are counters the official servers kept ("gems earned", "buddies +// added"); the ones this server can count itself are kept here, and the rest +// are whatever the client last set them to (see "zs" in world.js). +// +// A player's achievements are {inv, def} pairs in account.achievements. the +// client learns about a new one from the reply to a user var change. + +// counters only the server changes; a client's own "zs" for one is ignored. +const VARS = { + gemsEarned: 1, + gemsSpent: 2, + denItemsBought: 3, + clothesBought: 4, + jamAGramsSent: 38, + giftsSent: 39, + buddiesAdded: 40, + animals: 51, + pets: 212, + adoptAPets: 426, + worldItemsTaken: 439, // one bit per gift found in the lands (lib/worlditems.js) +}; +const SERVER_VARS = new Set(Object.values(VARS)); +const CURRENCY_GEMS = "gems"; + +let findOnline = () => null; + +let byVar = null; +const defsFor = varId => { + if (!byVar) { + byVar = new Map(); + for (const def of defpacks.achievementDefs()) { + byVar.set(def.userVarRef, [...(byVar.get(def.userVarRef) || []), def]); + } + } + return byVar.get(Number(varId)) || []; +}; + +// gives the account every achievement its value of `varId` has earned and +// returns the new ones. the caller saves. +const award = (account, varId) => { + const value = Number(account.userVars[varId]) || 0; + const earned = []; + for (const def of defsFor(varId)) { + if (value >= def.triggerAmount && !account.achievements.some(have => have.def === def.id)) { + const achievement = {inv: account.nextInv++, def: def.id}; + account.achievements.push(achievement); + earned.push(achievement); + } + } + return earned; +}; + +// AchievementXtCommManager.setUserVarResponse: [varId, value, newCount, +// (invId, defId)...]. sent unasked it still updates the client's copy of the +// var and pops up the new achievements. +const sendVar = (session, varId, earned = []) => { + session.sendXt("zs", -1, varId, session.account.userVars[varId], earned.length, + ...earned.flatMap(achievement => [achievement.inv, achievement.def])); +}; + +// sets a user var, hands out what that earns and tells the player if they +// are online. the caller saves. +const set = (account, varId, value) => { + if (account.userVars[varId] === value) { + return; + } + account.userVars[varId] = value; + const earned = award(account, varId); + const session = findOnline(account.username); + if (session) { + sendVar(session, varId, earned); + } +}; + +const add = (account, varId, amount = 1) => set(account, varId, (Number(account.userVars[varId]) || 0) + amount); + +// counts a change of some currency towards "gems earned" / "gems spent". +const currencyChanged = (account, currencyName, delta) => { + if (currencyName === CURRENCY_GEMS && delta !== 0) { + add(account, delta > 0 ? VARS.gemsEarned : VARS.gemsSpent, Math.abs(delta)); + } +}; + +// brings the counters that mirror what an account owns up to date (accounts +// from before achievements existed, gifts from the admin panel, ...). +const refresh = account => { + set(account, VARS.animals, Math.max(Number(account.userVars[VARS.animals]) || 0, account.avatars.length)); + set(account, VARS.pets, Math.max(Number(account.userVars[VARS.pets]) || 0, account.pets.length)); + set(account, VARS.buddiesAdded, Math.max(Number(account.userVars[VARS.buddiesAdded]) || 0, account.buddies.length)); + set(account, VARS.adoptAPets, account.adoptAPets.length); +}; + +// gives one achievement outright (the admin panel). false if unknown or owned. +const grant = (account, defId) => { + const def = defpacks.achievementDefs().find(candidate => candidate.id === Number(defId)); + if (!def || account.achievements.some(have => have.def === def.id)) { + return false; + } + const achievement = {inv: account.nextInv++, def: def.id}; + account.achievements.push(achievement); + accounts.save(); + const session = findOnline(account.username); + if (session) { + if (account.userVars[def.userVarRef] === undefined) { + account.userVars[def.userVarRef] = 0; + } + sendVar(session, def.userVarRef, [achievement]); + } + return true; +}; + +// for the account page: how many achievements the account has, and for +// each thing the game counts, how far along it is. the defs carry no +// readable title, only an internal name like "2_Gems_10000_Gems_Earned". +const label = def => String(def.name).split("_").filter(word => word && !/^\d+$/.test(word)) + .filter((word, index, words) => word !== words[index - 1]).join(" "); +const progress = account => { + const all = defpacks.achievementDefs(); + const have = new Set(account.achievements.map(achievement => achievement.def)); + const groups = new Map(); + for (const def of all) { + groups.set(def.userVarRef, [...(groups.get(def.userVarRef) || []), def]); + } + const counted = [...groups].map(([varId, defs]) => { + const steps = defs.map(def => def.triggerAmount).sort((one, other) => one - other); + const value = Number(account.userVars[varId]) || 0; + const next = steps.find(step => step > value); + return {name: label(defs[defs.length - 1]), value, next: next === undefined ? null : next, earned: defs.filter(def => have.has(def.id)).length, of: defs.length}; + }); + return {earned: have.size, of: all.length, counted: counted.sort((one, other) => one.name.localeCompare(other.name))}; +}; + +const handlers = { + // AchievementXtCommManager.getAchievementsResponse: [username, count, + // (invId, defId)...]; a count of -1 says "nothing new since you last asked". + za(session, roomId, [username]) { + const account = accounts.byName(username); + const list = account ? account.achievements : []; + session.sendXt("za", -1, account ? account.username : username, list.length, ...list.flatMap(achievement => [achievement.inv, achievement.def])); + }, +}; + +module.exports = { + // is this a user var some achievement watches, and not one of the server's own? + counts: varId => !SERVER_VARS.has(Number(varId)) && defsFor(varId).length > 0, + VARS, + SERVER_VARS, + handlers, + award, + sendVar, + set, + add, + currencyChanged, + refresh, + grant, + progress, + setFinder(finder) { + findOnline = finder; + }, +}; diff --git a/lib/admin.js b/lib/admin.js new file mode 100644 index 0000000..87951eb --- /dev/null +++ b/lib/admin.js @@ -0,0 +1,231 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const bans = require("./bans.js"); +const captcha = require("./captcha.js"); +const defpacks = require("./defpacks.js"); +const config = require("../config.js"); +const dens = require("./dens.js"); +const limits = require("./limits.js"); +const world = require("./world.js"); +const {addClothing, sendClothingAdded, isUint} = require("./player.js"); + +// backs the item finder page (/shop): look any item up by id or name and put +// it straight into an account, since in-game shops only stock a slice each. + +const MAX_RESULTS = 60; +const givesPerMinute = limits.limiter(120, 60000); // per account, from anywhere but this machine +const MAX_FAVOURITES = 200; // finder items remembered per account +// the nine animals the official sign-up page offers (public/register.html +// has their pictures): tiger, wolf, koala, panda, monkey, bunny, rhino, seal, penguin. +const STARTER_ANIMALS = [1, 4, 5, 6, 7, 8, 13, 18, 24]; + +let catalog = null; + +const buildCatalog = () => [ + ...defpacks.clothingIds().map(id => { + const def = defpacks.itemDef(id); + return {kind: "clothing", id, name: defpacks.string(def.titleStrId), cost: Number(def.value), colors: String(def.colors).split(",").length}; + }), + ...defpacks.denItemIds().map(id => { + const def = defpacks.denItemDef(id); + return {kind: "den", id, name: defpacks.string(def.nameStrId) || def.abbrName, cost: Number(def.cost), colors: 1}; + }), +].map(entry => ({...entry, search: entry.name.toLowerCase()})); + +// `favourites` is an account's finderGiven, or null: with nothing typed, the +// items that account took most often come first, the latest first among +// equals. (The in-game finder says whose search it is.) +const search = (params, favourites = null) => { + catalog = catalog || buildCatalog(); + const kind = params.get("kind") || "all"; + const words = (params.get("q") || "").toLowerCase().split(/\s+/).filter(Boolean); + const matches = catalog.filter(entry => (kind === "all" || entry.kind === kind) + && words.every(word => entry.search.includes(word) || String(entry.id) === word)); + matches.sort((a, b) => words.includes(String(b.id)) - words.includes(String(a.id))); + if (words.length === 0 && favourites) { + const taken = entry => favourites[`${entry.kind}:${entry.id}`] || {count: 0, at: 0}; + matches.sort((a, b) => taken(b).count - taken(a).count || taken(b).at - taken(a).at); + } + return { + total: matches.length, + results: matches.slice(0, MAX_RESULTS).map(({kind: entryKind, id, name, cost, colors}) => ({kind: entryKind, id, name, cost, colors})), + }; +}; + +const give = body => { + const account = accounts.byName(body.username); + if (!account) { + return {status: 404, body: {error: "No such account"}}; + } + const session = world.findOnline(account.username); + if (body.kind === "clothing") { + const def = defpacks.itemDef(body.id); + const colors = def ? String(def.colors).split(",") : []; + // `color` is a raw colour id of the caller's choosing; otherwise one of + // the item's own colours is picked by `colorIndex`. + const custom = body.color !== undefined && body.color !== ""; + if (custom && !isUint(String(body.color))) { + return {status: 400, body: {error: "The colour id must be a whole number from 0 to 4294967295"}}; + } + const color = custom ? String(body.color) : colors[Number(body.colorIndex) || 0]; + if (!def || !defpacks.clothingIds().includes(Number(def.id)) || color === undefined) { + return {status: 400, body: {error: "No such clothing item or colour"}}; + } + const item = addClothing(account, def.id, color); + if (!item) { + return {status: 409, body: {error: "That inventory is full"}}; + } + accounts.save(); + if (session) { + sendClothingAdded(session, item); + } + } + else if (body.kind === "den") { + if (!defpacks.denItemIds().includes(Number(body.id))) { + return {status: 400, body: {error: "No such den item"}}; + } + if (!dens.giveDenItem(account, body.id)) { + return {status: 409, body: {error: "That inventory is full"}}; + } + if (session) { + dens.sendDenItems(session); + } + } + else { + return {status: 400, body: {error: "Unknown item kind"}}; + } + // what this account takes from the finder, for its favourites. + const key = `${body.kind}:${Number(body.id)}`; + account.finderGiven[key] = {count: ((account.finderGiven[key] || {}).count || 0) + 1, at: Math.floor(Date.now() / 1000)}; + const kept = Object.entries(account.finderGiven).sort((one, other) => other[1].at - one[1].at).slice(0, MAX_FAVOURITES); + account.finderGiven = Object.fromEntries(kept); + accounts.save(); + return {status: 200, body: {ok: true, online: Boolean(session)}}; +}; + +const FORBIDDEN = {status: 403, body: {error: "forbidden"}}; + +// the account a login token is for, while it may play. A ban leaves the +// token alone (so that the client can ask about the ban with it, below), +// and it is good for nothing else until the ban is over. +const holderOf = token => { + const account = accounts.byToken(token); + return account && world.moderation.banRemaining(account) === 0 ? account : null; +}; + +// `from.local` marks a request made on the server's own machine: the owner, +// who may use the finder for any account. everyone else can only give items +// to the account whose login token they hold, which is how the in-game +// finder calls it. +const handle = async (route, params, body, from) => { + switch (route) { + case "GET /api/search": { + const asking = accounts.byName(params.get("username") || ""); + const known = asking && (from.local || holderOf(params.get("token")) === asking); + return {status: 200, body: search(params, known ? asking.finderGiven : null)}; + } + case "GET /api/accounts": + if (!from.local) { + return FORBIDDEN; + } + return {status: 200, body: accounts.all().map(account => ({username: account.username, online: Boolean(world.findOnline(account.username))}))}; + case "POST /api/give": { + const owner = holderOf((body || {}).token); + if (!from.local && (!owner || owner !== accounts.byName((body || {}).username))) { + return FORBIDDEN; + } + if (!from.local && !givesPerMinute.allow(owner.id)) { + return {status: 429, body: {error: "Too many at once. Try again in a minute."}}; + } + return give(body || {}); + } + case "POST /api/theme": { + const account = accounts.byName((body || {}).username); + if (!account || (!from.local && holderOf((body || {}).token) !== account)) { + return FORBIDDEN; + } + return world.setTheme(account, String((body || {}).theme)) + ? {status: 200, body: {ok: true, theme: account.theme}} + : {status: 400, body: {error: "Unknown theme"}}; + } + // for the settings menu's Outfits and Den layouts lists (gui.MySettings + // in the patched client): the names saved, and a way to run the chat + // commands that save, wear and load them. + case "GET /api/saved": { + const account = accounts.byName(params.get("username")); + if (!account || (!from.local && holderOf(params.get("token")) !== account)) { + return FORBIDDEN; + } + return {status: 200, body: {outfits: account.outfits.map(entry => entry.name), layouts: account.denLayouts.map(entry => entry.name)}}; + } + case "POST /api/command": { + const account = accounts.byName((body || {}).username); + if (!account || (!from.local && holderOf((body || {}).token) !== account)) { + return FORBIDDEN; + } + const text = String((body || {}).text || ""); + if (!/^!(outfit|den) (wear|load|savenew|off|undo)( [a-z0-9]{1,20})?$/.test(text)) { + return {status: 400, body: {error: "Unknown command"}}; + } + return world.runCommand(account, text) ? {status: 200, body: {ok: true}} : {status: 409, body: {error: "Not in the game"}}; + } + // what a client shows beside its login form and in the game's top bar: + // how many are playing (the world map says as much), and since when the + // server has been up. + case "GET /api/status": + return {status: 200, body: {online: world.players().length, uptimeSeconds: Math.floor(process.uptime())}}; + // is the holder of this login token banned, or the address they ask + // from? the client asks when its game stops, to say why. the reason is + // for the banned player, and the token says that is who asks. + case "POST /api/ban": { + const account = accounts.byToken((body || {}).token); + if (!account) { + return FORBIDDEN; + } + const ban = world.moderation.banOf(account); + const addressBan = ban ? null : bans.addressBan(from.address); + return {status: 200, body: ban ? {banned: "account", banned_seconds: ban.seconds, ban_reason: ban.reason} + : addressBan ? {banned: "address", banned_seconds: world.moderation.PERMANENT, ban_reason: addressBan.reason} : {banned: null}}; + } + case "POST /api/register": { + if (bans.addressBan(from.address)) { + return {status: 403, body: {error: "address_banned"}}; + } + const {username, password, avatarType} = body || {}; + // the terms and the privacy policy, and old enough to agree to them: + // said by the one signing up, on the page or in the client. + if ((body || {}).agreed !== true) { + return {status: 400, body: {error: "agree_first"}}; + } + const captchaProblem = await captcha.check(body, from, "signup"); + if (captchaProblem) { + return {status: captchaProblem === "captcha_unavailable" ? 503 : 400, body: {error: captchaProblem}}; + } + const problem = accounts.usernameProblem(typeof username === "string" ? username.trim() : username); + if (problem) { + return {status: 400, body: {error: problem}}; + } + if (!limits.registrationAllowed(from.address, from.local)) { + return {status: 429, body: {error: "too_many_registrations"}}; + } + // the animals the sign-up page offers; the game's own Create Account + // screens (lib/signup.js) offer theirs. + if (!STARTER_ANIMALS.includes(avatarType)) { + return {status: 400, body: {error: "choose_animal"}}; + } + const result = accounts.register(username, password, {type: avatarType}); + if (result.account) { + result.account.agreed = {version: config.termsVersion, at: Math.floor(Date.now() / 1000)}; + accounts.save(); + } + // the client signs in straight after, and is not asked again. + return result.error ? {status: 400, body: {error: result.error}} + : {status: 200, body: {username: result.account.username, captcha_pass: captcha.issuePass(result.account, from)}}; + } + default: + return {status: 404, body: {error: "not_found"}}; + } +}; + +module.exports = {handle}; diff --git a/lib/adopt.js b/lib/adopt.js new file mode 100644 index 0000000..086c42e --- /dev/null +++ b/lib/adopt.js @@ -0,0 +1,66 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const achievements = require("./achievements.js"); +const defpacks = require("./defpacks.js"); + +// the Adopt-A-Pet checklist (client side: AdoptAPetManager, CheckListPopup): +// the collectable toy pets a player has "found". the real game handed them +// out through codes packed with the toys. here every day's first login finds +// one the player does not have yet, and the admin panel can give any. +// +// account.adoptAPets holds {inv, def, ts, seen}. + +const jamaaDate = () => Math.floor(Date.now() / 86400000); + +// adds one to the account's checklist; null if unknown or already there. +// the caller saves. +const give = (account, defId) => { + if (!defpacks.adoptAPetDef(defId) || account.adoptAPets.some(have => have.def === Number(defId))) { + return null; + } + const found = {inv: account.nextInv++, def: Number(defId), ts: Math.floor(Date.now() / 1000), seen: false}; + account.adoptAPets.push(found); + achievements.set(account, achievements.VARS.adoptAPets, account.adoptAPets.length); + return found; +}; + +// the day's find, at login. the caller saves. +const dailyFind = account => { + if (account.adoptAPetDay === jamaaDate()) { + return null; + } + account.adoptAPetDay = jamaaDate(); + const missing = defpacks.adoptAPetIds().filter(id => + defpacks.adoptAPetDef(id).hidden !== "1" && !account.adoptAPets.some(have => have.def === id)); + return missing.length ? give(account, missing[Math.floor(Math.random() * missing.length)]) : null; +}; + +// GamePlay.onWorldLogIn -> AdoptAPetData: what the login message lists. +const loginList = account => account.adoptAPets.map(found => ({invId: found.inv, defId: found.def, ts: found.ts, hasSeen: found.seen})); + +const handlers = { + // CheckListPopup.onOtherUserUsableAdoptAPetData: [success, count, (defId, invId)...] + pad(session, roomId, [username]) { + const account = accounts.byName(username); + const list = account ? account.adoptAPets : []; + session.sendXt("pad", -1, account ? 1 : 0, list.length, ...list.flatMap(found => [found.def, found.inv])); + }, + + // BuddyCard.onAdoptAPetCount: how many that player has (0 hides the button). + padc(session, roomId, [username]) { + const account = accounts.byName(username); + session.sendXt("padc", -1, account ? account.adoptAPets.length : 0); + }, + + // CheckListPopup: the ones the player has now looked at, [defId, ...]. + pads(session, roomId, defIds) { + const seen = new Set(defIds.map(Number)); + for (const found of session.account.adoptAPets) { + found.seen = found.seen || seen.has(found.def); + } + accounts.save(); + }, +}; + +module.exports = {handlers, give, dailyFind, loginList}; diff --git a/lib/adventures.js b/lib/adventures.js new file mode 100644 index 0000000..ca3ee5d --- /dev/null +++ b/lib/adventures.js @@ -0,0 +1,356 @@ +"use strict"; + +// adventures. the engine is in the client (quest/QuestManager): it places +// the actors named in the room file and plays them. what happens when was +// decided by scripts on the official server, which no file holds, so each +// adventure here is a script written by hand from a recording of the +// official game (tools/recorder.js): lib/adventures/.js says what to +// send when the player triggers an actor, answers one, and so on. +// +// one player to an adventure, each in rooms of their own. + +const accounts = require("./accounts.js"); +const achievements = require("./achievements.js"); +const config = require("../config.js"); +const dens = require("./dens.js"); +const {activeAvatar} = require("./player.js"); + +const scripts = new Map([ + require("./adventures/training-grounds.js"), + require("./adventures/return-of-the-phantoms.js"), +].map(script => [script.defId, script])); + +const LIST_ADVENTURES = 201; // the adventure list's rows: script def ids +const ROOM_TYPE_QUEST = 7; +const CURRENCY_GEMS = 0; +const MAX_LEVEL = 100; + +const HEARTS = 6; // a player's health, and what a phantom's zap takes of it +const ZAP = 2; +const GIFT_DEN_ITEM = 1; +const GIFT_GEMS = 3; + +// the XP a level starts at. the recordings show three levels: 50 XP to +// level 1, 200 more to level 2, and about 450 more to level 3 (5 XP into +// level 2 shown as 1%, 55 as 12%). that is 50 times the level squared, and +// the levels after are taken to go on so. +const levelXp = level => 50 * level * (level + 1) * (2 * level + 1) / 6; +const levelFor = xp => { + let level = 0; + while (level < MAX_LEVEL && xp >= levelXp(level + 1)) { + level++; + } + return level; +}; +const xpOf = avatar => Math.max(avatar.questXp || 0, levelXp(avatar.questLevel || 0)); +// how far through its level, in percent (QuestManager.handleXpUpdate). +const percent = xp => { + const level = levelFor(xp); + return Math.round((xp - levelXp(level)) * 100 / (levelXp(level + 1) - levelXp(level))); +}; + +module.exports = ({enterRoom, joinRoom, tell}) => { + const playing = session => (session.quest && session.room === session.quest.room ? session.quest : null); + + const tools = (session, quest) => { + const q = { + me: session.id, + vars: quest.vars, + send(cmd, ...fields) { + if (playing(session) === quest) { + session.sendXt(cmd, -1, ...fields); + } + }, + after(ms, action) { + setTimeout(() => { + try { + if (playing(session) === quest) { + action(); + } + } + catch (err) { + console.error(`[adventure] ${quest.script.title}: a timed step failed: ${err.stack}`); + } + }, ms).unref(); + }, + // QuestManager.handleXpUpdate: [earned, total, level before, level + // now, percent, the actor the number floats over]. + xp(amount, actor = "") { + const avatar = activeAvatar(session.account); + const before = xpOf(avatar); + const level = levelFor(before); + avatar.questXp = before + amount; + avatar.questLevel = levelFor(avatar.questXp); + if (amount > 0) { + accounts.save(); + } + q.send("quxp", amount, avatar.questXp, level, avatar.questLevel, percent(avatar.questXp), actor); + if (avatar.questLevel > level) { + // A new level: full health, the animal's numbers, then the level. + quest.hearts = HEARTS; + q.send("quhp", session.id, 100, HEARTS, HEARTS, HEARTS); + q.send("qusu", 10, 200, 1, 200); + q.send("qulu", session.id, avatar.questLevel); + } + }, + // what the player carries (an actor's name), and using it up: + // command 7 takes it out of their hands. + held: () => quest.held, + use() { + quest.held = null; + q.send("qcmd", 7); + }, + // goes to another of the adventure's rooms, to stand at `spawn`. + room(key, spawn) { + const place = quest.script.rooms[key]; + q.send("qcmd", 14, 0, spawn); + const room = enter(session, quest.script, place); + if (room) { + quest.room = room; + q.send("qmusic", place.music); + } + }, + // the prizes to choose from at the end: [GIFT_DEN_ITEM, def id, 0] + // or [GIFT_GEMS, amount, amount] each (QuestManager.handlePickGift). + offer(gifts) { + quest.gifts = gifts; + q.send("qpgift", gifts.length, 0, ...gifts.flat()); + }, + level: () => levelFor(xpOf(activeAvatar(session.account))), + gems(amount) { + const {account} = session; + account.currency.gems = (account.currency.gems || 0) + amount; + achievements.currencyChanged(account, "gems", amount); + accounts.save(); + session.sendXt("cu", -1, CURRENCY_GEMS, account.currency.gems, 0); + }, + }; + return q; + }; + + const run = (session, kind, key, ...args) => { + const quest = playing(session); + if (!quest) { + return; + } + const table = quest.script.on[kind]; + // A script may answer a whole family of actors: [pattern, handler] in + // "Like", the handler given the actor's name. + const family = key === null ? null : (quest.script.on[`${kind}Like`] || []).find(([pattern]) => pattern.test(key)); + const handler = key === null ? table : (table || {})[key]; + if (handler) { + handler(tools(session, quest), ...args); + } + else if (family) { + family[1](tools(session, quest), key, ...args); + } + else if (key !== null && kind !== "pickedUp") { + console.log(`[adventure] ${quest.script.title}: nothing written for "${kind} ${key}"`); + } + }; + + // QuestXtCommManager.questStartResponse: [script def, players, actor + // count, when the script was written, then for each actor its name, + // type, def id (a name for type 16), state, visible, needs a click, path, + // and the state of its artwork]. the room join follows it. + const enter = (session, script, place) => enterRoom(session, `quest_${session.id}_${script.defId}_${Date.now()}__${place.room}`, + place.room, place.name, config.shards[0].id, {roomType: ROOM_TYPE_QUEST, secondaryDefId: script.defId, nameStringId: place.nameStringId, + joinFlags: [0, 1, 0, 1, 0]}); // a game room, and temporary + + const start = (session, script) => { + const returnTo = session.room.name; + session.questLobby = null; + session.sendXt("qs", session.room.id, script.defId, 1, script.actors.length, script.written, ...script.actors.flat()); + session.sendXt("qcmd", -1, 38, script.objective); + session.sendXt("qmusic", -1, script.rooms.start.music); + const room = enter(session, script, script.rooms.start); + if (!room) { + return; + } + session.quest = {script, room, returnTo, vars: {}, loaded: false, held: null, hearts: HEARTS, gifts: null, gift: null}; + tools(session, session.quest).xp(0); + }; + + const handlers = { + // QuestXtCommManager.sendQuestCreateJoinPublic: [room, script def, + // difficulty, 0]. A refusal is [0, reason]; "NV" is "Failed to join!". + qj(session, roomId, [, defId]) { + const script = scripts.get(Number(defId)); + if (!script || !session.room || playing(session)) { + session.sendXt("qj", -1, 0, "NV"); + if (!script) { + tell(session, "That adventure is not on this server yet."); + } + return; + } + if (!script.lobby) { + start(session, script); + return; + } + // an adventure for several waits for its players: [1, 1, script + // def, 0], then who is waiting ("qw"). the player's own Start + // button, or the client by itself, then asks to begin ("qs"). + session.questLobby = script; + session.sendXt("qj", session.room.id, 1, 1, script.defId, 0); + session.sendXt("qw", session.room.id, session.id); + }, + // QuestXtCommManager.sendQuestStartRequest: [room] + qs(session) { + if (session.questLobby && session.room && !playing(session)) { + start(session, session.questLobby); + } + }, + // ... and leaving the wait + qjx(session) { + session.questLobby = null; + session.sendXt("qjx", -1, 1); + }, + // the private lobby asks the same way: [room, script def, difficulty]. + qjc(session, roomId, params) { + handlers.qj(session, roomId, params); + }, + + // "What was moved?", once the room is up: nothing is answered, and it + // is where a script begins. + qmi(session) { + const quest = playing(session); + if (quest && !quest.loaded) { + quest.loaded = true; + run(session, "loaded", null); + } + }, + + // [actor, 0]: walked into, or clicked + qat(session, roomId, [actor]) { + run(session, "trigger", String(actor)); + }, + // [actor, ?, answer]: a talk read to its end + qaskr(session, roomId, [actor]) { + run(session, "answer", String(actor)); + }, + // [actor, state]: an actor's own change of mind (a phantom noticing the + // player, giving up), which the server only passes round: + // QuestManager.handleQuestActorRequestSeekResponse [actor, state, who]. + qas(session, roomId, [actor, state]) { + if (playing(session) && /^-?\d+$/.test(state)) { + session.sendXt("qas", -1, String(actor), Number(state), session.id); + } + }, + // QuestXtCommManager.questPickUpItem: [actor, who]. answered [1, actor, + // who] (QuestManager.handlePickUpItem); with something in hand already + // it is [0, actor], which has the client ask whether to drop that. + qpup(session, roomId, [actor]) { + const quest = playing(session); + const name = String(actor); + if (!quest || !quest.script.actors.some(row => row[0] === name)) { + return; + } + const refill = quest.script.refills; + if (quest.held && !(refill && refill.test(quest.held) && refill.test(name))) { + session.sendXt("qpup", -1, 0, name, "null"); + return; + } + quest.held = name; + session.sendXt("qpup", -1, 1, name, session.id); + run(session, "pickedUp", name); + }, + // "Yes, drop it": [x, y, the actor wanted, who]. what was held is put + // down there ([4, actor, who, x, y, 0, 150, who, the one wanted]) and + // the other picked up. + qdroppup(session, roomId, [x, y, actor]) { + const quest = playing(session); + const name = String(actor); + if (!quest || !quest.held || ![x, y].every(value => /^-?\d+$/.test(value)) || !quest.script.actors.some(row => row[0] === name)) { + return; + } + session.sendXt("qpup", -1, 4, quest.held, session.id, Number(x), Number(y), 0, 150, session.id, name); + quest.held = name; + session.sendXt("qpup", -1, 1, name, session.id); + run(session, "pickedUp", name); + }, + + // A phantom has zapped the player: [phantom, who, x, y], which goes + // back after the player's health, [who, percent, change, hearts, of] + // (QuestManager.handleHealthUpdate). at none the player is down ("qpd"). + qpzap(session, roomId, [phantom, , x, y]) { + const quest = playing(session); + if (!quest || quest.hearts <= 0 || ![x, y].every(value => /^-?\d+$/.test(value))) { + return; + } + quest.hearts = Math.max(0, quest.hearts - ZAP); + session.sendXt("quhp", -1, session.id, Math.floor(quest.hearts * 100 / HEARTS), -ZAP, quest.hearts, HEARTS); + if (quest.hearts === 0) { + session.sendXt("qpd", -1, session.id); + } + session.sendXt("qpzap", -1, String(phantom), session.id, Number(x), Number(y)); + }, + // ... and asks to get up again: [0, x, y], a place of the client's + // choosing. [who, percent, hearts three times, x, y], then "qprr" 6. + qprr(session, roomId, [, x, y]) { + const quest = playing(session); + if (!quest || quest.hearts > 0 || ![x, y].every(value => /^-?\d+$/.test(value))) { + return; + } + quest.hearts = HEARTS; + session.sendXt("qrspn", -1, session.id, 100, HEARTS, HEARTS, HEARTS, Number(x), Number(y)); + session.sendXt("qprr", -1, HEARTS); + }, + + // the prize picked from those offered: [which, ?, ?], then "done". + qpgift(session, roomId, [index]) { + const quest = playing(session); + if (quest && quest.gifts && quest.gift === null && /^\d+$/.test(index) && Number(index) < quest.gifts.length) { + quest.gift = quest.gifts[Number(index)]; + } + }, + qpgiftdone(session) { + const quest = playing(session); + if (!quest || !quest.gift) { + return; + } + const [kind, value] = quest.gift; + quest.gifts = quest.gift = null; + if (kind === GIFT_DEN_ITEM) { + dens.giveDenItem(session.account, value); + dens.sendDenItems(session); + } + else if (kind === GIFT_GEMS) { + tools(session, quest).gems(value); + } + run(session, "gifted", null); + }, + + // [plant, phantom]: a chomper plant has caught one. nothing comes back. + qpa() {}, + // [plant, phantom, x, y]: ... and eaten it + qep(session, roomId, [plant, phantom, x, y]) { + if (playing(session) && [x, y].every(value => /^-?\d+$/.test(value))) { + run(session, "eaten", null, String(plant), String(phantom), Number(x), Number(y)); + } + }, + // [actor, 0] is answered by the script when the chest is triggered + // ("qat"); [actor, 1] is the chest opened. + qatt(session, roomId, [actor, opened]) { + if (opened === "1") { + run(session, "opened", String(actor)); + } + }, + + // QuestXtCommManager.sendQuestExit. the official game goes to the + // Adventure Base Camp; here it is back to where the player came from. + qx(session) { + const quest = playing(session); + if (quest) { + session.quest = null; + joinRoom(session, quest.returnTo); + } + }, + }; + + return { + handlers, + list: listId => (Number(listId) === LIST_ADVENTURES ? [...scripts.keys()] : null), + }; +}; + +Object.assign(module.exports, {levelXp, MAX_LEVEL}); diff --git a/lib/adventures/return-of-the-phantoms.js b/lib/adventures/return-of-the-phantoms.js new file mode 100644 index 0000000..4e85bbc --- /dev/null +++ b/lib/adventures/return-of-the-phantoms.js @@ -0,0 +1,688 @@ +"use strict"; + +// return of the Phantoms (script def 14), normal mode, written from a +// recording of the official game of 2026-10-12: one player, who plugged +// the four pipes, watered the eight plants, fetched the key from the +// burrow, freed the four bunnies and took a prize; was zapped down once, +// fed four phantoms to the plants and opened two chests. what was sent +// there is sent here. marked "guessed" below is what that run did not do. +// +// commands ("qcmd"): 1 sets an actor's [state, visible, needs a click], +// and state 99 takes it out of the adventure (all that belongs to hard +// mode goes that way at the start); 2 has an actor say a string; 3 has it +// talk and wait for an answer; 7 takes what the player carries; 14 puts +// the player at a spawn point; 38 is the line under the top of the +// screen; 19 ends the adventure. "qcmdVT" sets a counter or a timer, +// "qsp" a phantom's path. + +// kinds of prize (QuestManager.handlePickGift). +const GIFT_DEN_ITEM = 1; +const GIFT_GEMS = 3; + +const set = (q, name, state, visible, click) => q.send("qcmd", 1, name, state, visible, click); +const counter = (q, name, value) => q.send("qcmdVT", 1, name, value, 0, 0); +const say = (q, name, text) => q.send("qcmd", 2, name, text, 1); +const goal = (q, text) => q.send("qcmd", 38, text); +// the official game counts its page views this way; the client is told. +const page = (q, flag, name) => { + counter(q, flag, 1); + q.send("qposturi", `/adventure1-returnofthephantoms/#${name}/#0#001`); + counter(q, flag, 99); +}; +const lizaAppears = (q, name) => { + q.send("qswfs", name, "facesw"); + q.send("qswfs", name, "appear"); + set(q, name, 1, 1, 1); +}; +const phantoms = (q, list) => { + for (const [name, path] of list) { + if (path) { + q.send("qsp", name, path); + } + set(q, name, 1, 1, 1); + } +}; +const pick = letters => letters[Math.floor(Math.random() * letters.length)]; + +const NORMAL_FLOWERS = [1, 2, 3, 4, 9, 10, 11, 12]; +const flowerTrigger = number => (number < 10 ? `flowertrig_${number}` : `flowertrig${number}`); +// everything of hard mode, taken out when a normal adventure begins. +const HARD_ONLY = ["hard", "phan_door_h", "phan_block_h", "phan_trig_h", "blocker_e", "pipe_5", "pipe_6", "sludge_5", "sludge_6", + "flowers_5", "flowers_6", "flowers_7", "flowers_8", "well_1h", "checkpoint2", "spawn_2"]; +const PIPE_GOALS = {5: 3546, 6: 3547}; // "Find 2 more CORKS...", "Find the last CORK..." +// chests the recording opened; the others are guessed at 50. +const CHEST_GEMS = {treasure_3: 100, treasure_4: 50}; +const GUESSED_CHEST_GEMS = 50; +const PRIZES = [[GIFT_DEN_ITEM, 1288, 0], [GIFT_DEN_ITEM, 1289, 0], [GIFT_DEN_ITEM, 1290, 0], [GIFT_GEMS, 500, 500], [GIFT_DEN_ITEM, 1291, 0]]; + +const pipePlugged = (q, pipe) => { + const number = pipe.slice("pipetrig_".length); + // guessed: without a cork in hand the pipe says a cork fits in it. + if (!/^cork_/.test(q.held() || "")) { + say(q, pipe, 3468); + return; + } + if (q.vars.plugged.has(pipe)) { + return; + } + q.vars.plugged.add(pipe); + q.use(); + set(q, `pipe_${number}`, 1, 1, 0); + set(q, `sludge_${number}`, 1, 0, 0); + set(q, pipe, 2, 0, 0); + if (q.vars.plugged.size === 1) { + // the first, with the bunny's cork: phantoms come, and the other three + // pipes can be plugged. + counter(q, "watervar", 1); + phantoms(q, [["phantom_2", "path_2"], ["phantom_3", "path_3"], ["phantom_4", null]]); + q.xp(5, pipe); + q.after(650, () => { + set(q, "bunny_2", 1, 1, 1); + say(q, "bunny_2", 3467); + set(q, "bunny_2", 2, 1, 0); + counter(q, "watervar", 4); + goal(q, 3472); + for (const other of ["pipetrig_2", "pipetrig_3", "pipetrig_4"]) { + set(q, other, 1, 1, 1); + } + q.after(2000, () => { + set(q, "vineblock_2", 1, 0, 0); + set(q, "vine_2", 1, 1, 0); + }); + }); + return; + } + const water = 3 + q.vars.plugged.size; // 5, 6, then 7 for the last + counter(q, "watervar", water); + if (water < 7) { + goal(q, PIPE_GOALS[water]); + q.xp(5, pipe); + return; + } + // the water runs clean: pails at the well, and eight plants to revive. + set(q, "sludgewall", 1, 0, 0); + set(q, "waterfall", 1, 1, 0); + set(q, "water_1", 0, 1, 0); + set(q, "well_1", 0, 1, 0); + set(q, "pail_1", 1, 1, 0); + set(q, "pail_2", 1, 1, 0); + goal(q, 14989); + counter(q, "flower_count", 4); + goal(q, 3478); + set(q, "watervol_1", 1, 0, 0); + for (const number of NORMAL_FLOWERS) { + set(q, flowerTrigger(number), 1, 1, 1); + } + set(q, "bunny_2", 3, 1, 1); + set(q, "bunny_1", 2, 1, 1); + q.xp(15, "waterdone"); + page(q, "10_uri", "10-plugthepipes"); + q.xp(5, pipe); + q.after(2560, () => q.send("qsnd", "ajq_riverclear")); +}; + +const flowerWatered = (q, trigger) => { + const number = trigger.replace(/\D/g, ""); + if (!/^pail_/.test(q.held() || "") || q.vars.watered.has(trigger)) { + return; + } + q.vars.watered.add(trigger); + q.use(); + set(q, `flowers_${number}`, 0, 1, 0); + set(q, trigger, 2, 0, 0); + const count = 4 + q.vars.watered.size; // the counter starts at 4 and ends at 12 + counter(q, "flower_count", count); + goal(q, 3474 + count); // 3479 "... 7 more PLANTS" to 3486 + if (count === 12) { + // the burrow opens. + set(q, "trig_1a", 1, 1, 1); + set(q, "nobody_home", 1, 0, 0); + set(q, "bunnyblocker", 1, 0, 0); + set(q, "burrow_door", 1, 1, 0); + for (const pail of ["pail_1", "pail_2", "pail_3"]) { + set(q, pail, 2, 0, 0); + } + q.xp(15, "flower_count"); + set(q, "bunny_12", 1, 1, 0); + page(q, "20_uri", "20-revivetheplants"); + } + q.xp(5, trigger); +}; + +const bunnyFreed = (q, bunny) => { + const number = Number(bunny.slice("bunny_".length)); + if (!/^bunny_key_/.test(q.held() || "") || q.vars.freed.has(bunny)) { + return; + } + q.vars.freed.add(bunny); + q.use(); + q.xp(10, bunny); + set(q, `cage${number}_f`, 1, 1, 0); + set(q, `cage${number}_b`, 1, 1, 0); + q.send("qswfs", bunny, "dance"); + set(q, bunny, 1, 1, 0); + const count = q.vars.freed.size; + counter(q, "trap_count", count); + goal(q, 3572 + count); // "Find 3 KEYS..." down to "Adventure COMPLETE!" + if (count === 4) { + q.xp(25, "trap_count"); + lizaAppears(q, "liza_2"); + page(q, "30_uri", "30-rescuethebunnies"); + } + say(q, bunny, 3561 + number); // bunny_7 says 3568, ... bunny_10 3571 +}; + +module.exports = { + defId: 14, + title: "Return of the Phantoms", + lobby: true, + rooms: { + start: {room: "adventures.room_adventure_1x", name: "On An Adventure", nameStringId: 18324, music: "ajq_musquest"}, + burrow: {room: "adventures.room_adventure_1a", name: "On an Adventure", nameStringId: 18324, music: "ajq_musbunnyburrow"}, + }, + written: "2017-10-30 22:02:01", + objective: 3465, // "TALK to Liza." + refills: /^pail_/, // a pail in hand is filled again at the well + + // name, type, def, state, visible, needs a click, path, artwork state + actors: [ + ["queststart", 18, 0, 0, 1, 1, "", ""], + ["questready", 7, 0, 0, 1, 1, "", ""], + ["checkpoint2", 27, 0, 0, 1, 1, "", ""], + ["checkpoint4", 27, 0, 0, 1, 1, "", ""], + ["start_init", 8, 0, 0, 0, 1, "", ""], + ["water_time", 8, 0, 0, 0, 1, "", ""], + ["bunnytimer_1", 8, 0, 0, 0, 1, "", ""], + ["bunnytimer_2", 8, 0, 0, 0, 1, "", ""], + ["bunnytimer_3", 8, 0, 0, 0, 1, "", ""], + ["bunnytimer_4", 8, 0, 0, 0, 1, "", ""], + ["blocktimer_1", 8, 0, 0, 0, 1, "", ""], + ["phan_timer_1", 8, 0, 0, 0, 1, "", ""], + ["gifttimer", 8, 0, 0, 0, 1, "", ""], + ["players", 7, 0, 0, 1, 1, "", ""], + ["waterdone", 7, 0, 0, 1, 1, "", ""], + ["watervar", 7, 0, 0, 0, 1, "", ""], + ["flower_count", 7, 0, 0, 0, 1, "", ""], + ["trap_count", 7, 0, 0, 0, 1, "", ""], + ["spawn_1_a", 9, 1, 0, 1, 1, "", ""], + ["trig_1_a", 3, 0, 0, 1, 1, "", ""], + ["spawn_1a", 9, 0, 0, 1, 1, "", ""], + ["trig_1a", 3, 0, 0, 0, 1, "", ""], + ["spawn_1_b", 9, 2, 0, 1, 1, "", ""], + ["trig_1_b", 3, 0, 0, 1, 1, "", ""], + ["spawn_1b", 9, 0, 0, 1, 1, "", ""], + ["trig_1b", 3, 0, 0, 1, 1, "", ""], + ["liza_1", 1, 21, 0, 0, 1, "", ""], + ["liza_2", 1, 21, 0, 0, 1, "", ""], + ["bunny_1", 1, 88, 0, 1, 1, "", "facesw"], + ["bunny_2", 1, 89, 0, 1, 1, "", ""], + ["bunny_3", 1, 90, 0, 1, 1, "", "facesw"], + ["bunnytrig_3", 3, 0, 0, 1, 1, "", ""], + ["bunny_4", 1, 91, 0, 1, 1, "", "facesw"], + ["bunny_5", 1, 92, 0, 1, 1, "", ""], + ["bunny_6", 1, 93, 0, 1, 1, "", ""], + ["bunny_7", 1, 94, 0, 1, 1, "", ""], + ["bunny_8", 1, 95, 0, 1, 1, "", ""], + ["bunny_9", 1, 96, 0, 1, 1, "", "facesw"], + ["bunny_10", 1, 97, 0, 1, 1, "", "facesw"], + ["bunny_11", 1, 98, 0, 1, 1, "", ""], + ["bunny_12", 1, 101, 0, 1, 1, "", "facesw"], + ["nobody_home", 1, 44, 0, 1, 1, "", ""], + ["pipeinfo_1", 1, 116, 0, 0, 1, "", ""], + ["pipeinfo_2", 1, 116, 0, 0, 1, "", ""], + ["pipeinfo_3", 1, 116, 0, 0, 1, "", ""], + ["pipeinfo_4", 1, 116, 0, 0, 1, "", ""], + ["pipeinfo_5", 1, 116, 0, 0, 1, "", ""], + ["pipeinfo_6", 1, 116, 0, 0, 1, "", ""], + ["pipetrig_1", 1, 69, 0, 0, 1, "", ""], + ["pipetrig_2", 1, 69, 0, 0, 1, "", ""], + ["pipetrig_3", 1, 69, 0, 0, 1, "", ""], + ["pipetrig_4", 1, 69, 0, 0, 1, "", ""], + ["pipetrig_5", 1, 69, 0, 0, 1, "", ""], + ["pipetrig_6", 1, 69, 0, 0, 1, "", ""], + ["flowerinfo_1", 1, 116, 0, 0, 1, "", ""], + ["flowerinfo_2", 1, 116, 0, 0, 1, "", ""], + ["flowerinfo_3", 1, 116, 0, 0, 1, "", ""], + ["flowerinfo_4", 1, 116, 0, 0, 1, "", ""], + ["flowerinfo_5", 1, 116, 0, 0, 1, "", ""], + ["flowerinfo_6", 1, 116, 0, 0, 1, "", ""], + ["flowerinfo_7", 1, 116, 0, 0, 1, "", ""], + ["flowerinfo_8", 1, 116, 0, 0, 1, "", ""], + ["flowerinfo_9", 1, 116, 0, 0, 1, "", ""], + ["flowerinfo10", 1, 116, 0, 0, 1, "", ""], + ["flowerinfo11", 1, 116, 0, 0, 1, "", ""], + ["flowerinfo12", 1, 116, 0, 0, 1, "", ""], + ["flowertrig_1", 1, 67, 0, 0, 1, "", ""], + ["flowertrig_2", 1, 67, 0, 0, 1, "", ""], + ["flowertrig_3", 1, 67, 0, 0, 1, "", ""], + ["flowertrig_4", 1, 67, 0, 0, 1, "", ""], + ["flowertrig_5", 1, 67, 0, 0, 1, "", ""], + ["flowertrig_6", 1, 67, 0, 0, 1, "", ""], + ["flowertrig_7", 1, 67, 0, 0, 1, "", ""], + ["flowertrig_8", 1, 67, 0, 0, 1, "", ""], + ["flowertrig_9", 1, 67, 0, 0, 1, "", ""], + ["flowertrig10", 1, 67, 0, 0, 1, "", ""], + ["flowertrig11", 1, 67, 0, 0, 1, "", ""], + ["flowertrig12", 1, 67, 0, 0, 1, "", ""], + ["plant_1", 21, 100, 0, 1, 1, "", ""], + ["plant_2", 21, 100, 0, 1, 1, "", ""], + ["plant_3", 21, 100, 0, 1, 1, "", ""], + ["plant_4", 21, 100, 0, 1, 1, "", ""], + ["plant_5", 21, 100, 0, 1, 1, "", ""], + ["plant_6", 21, 100, 0, 1, 1, "", ""], + ["plant_7", 21, 100, 0, 1, 1, "", ""], + ["plant_8", 21, 100, 0, 1, 1, "", ""], + ["plant_9", 21, 100, 0, 1, 1, "", ""], + ["plant_10", 21, 100, 0, 1, 1, "", ""], + ["plant_11", 21, 100, 0, 1, 1, "", ""], + ["plant_12", 21, 100, 0, 1, 1, "", ""], + ["plant_13", 21, 100, 0, 1, 1, "", ""], + ["plant_14", 21, 100, 0, 1, 1, "", ""], + ["plant_15", 21, 100, 0, 1, 1, "", ""], + ["plant_16", 21, 100, 0, 1, 1, "", ""], + ["plant_17", 21, 100, 0, 1, 1, "", ""], + ["plant_18", 21, 100, 0, 1, 1, "", ""], + ["path_1", 20, 0, 0, 0, 1, "", ""], + ["path_2", 20, 0, 0, 0, 1, "", ""], + ["path_2_h", 20, 0, 0, 0, 1, "", ""], + ["path_3", 20, 0, 0, 0, 1, "", ""], + ["path_3_h", 20, 0, 0, 0, 1, "", ""], + ["path_5", 20, 0, 0, 0, 1, "", ""], + ["path_5_h", 20, 0, 0, 0, 1, "", ""], + ["path_6", 20, 0, 0, 0, 1, "", ""], + ["path_7", 20, 0, 0, 0, 1, "", ""], + ["path_8a", 20, 0, 0, 0, 1, "", ""], + ["path_8b", 20, 0, 0, 0, 1, "", ""], + ["path_9", 20, 0, 0, 0, 1, "", ""], + ["path_9_h", 20, 0, 0, 0, 1, "", ""], + ["path_11", 20, 0, 0, 0, 1, "", ""], + ["path_11_h", 20, 0, 0, 0, 1, "", ""], + ["path_12", 20, 0, 0, 0, 1, "", ""], + ["path_12_h", 20, 0, 0, 0, 1, "", ""], + ["path_13_h", 20, 0, 0, 0, 1, "", ""], + ["path_14_h", 20, 0, 0, 0, 1, "", ""], + ["path_15_h", 20, 0, 0, 0, 1, "", ""], + ["path_17_h", 20, 0, 0, 0, 1, "", ""], + ["path_18_h", 20, 0, 0, 0, 1, "", ""], + ["path_19_h", 20, 0, 0, 0, 1, "", ""], + ["pail_1", 17, 1955, 0, 0, 1, "", ""], + ["pail_2", 17, 1955, 0, 0, 1, "", ""], + ["pail_3", 17, 1955, 0, 0, 1, "", ""], + ["cork_1", 15, 1937, 0, 0, 1, "", ""], + ["cork_2a", 15, 1937, 0, 0, 1, "", ""], + ["cork_2a_h", 15, 1937, 0, 0, 1, "", ""], + ["cork_2b", 15, 1937, 0, 0, 1, "", ""], + ["cork_2b_h", 15, 1937, 0, 0, 1, "", ""], + ["cork_2c", 15, 1937, 0, 0, 1, "", ""], + ["cork_2c_h", 15, 1937, 0, 0, 1, "", ""], + ["cork_3a", 15, 1937, 0, 0, 1, "", ""], + ["cork_3a_h", 15, 1937, 0, 0, 1, "", ""], + ["cork_3b", 15, 1937, 0, 0, 1, "", ""], + ["cork_3b_h", 15, 1937, 0, 0, 1, "", ""], + ["cork_3c", 15, 1937, 0, 0, 1, "", ""], + ["cork_3c_h", 15, 1937, 0, 0, 1, "", ""], + ["cork_4a", 15, 1937, 0, 0, 1, "", ""], + ["cork_4a_h", 15, 1937, 0, 0, 1, "", ""], + ["cork_4b", 15, 1937, 0, 0, 1, "", ""], + ["cork_4b_h", 15, 1937, 0, 0, 1, "", ""], + ["cork_4c", 15, 1937, 0, 0, 1, "", ""], + ["cork_4c_h", 15, 1937, 0, 0, 1, "", ""], + ["cork_5a_h", 15, 1937, 0, 0, 1, "", ""], + ["cork_5b_h", 15, 1937, 0, 0, 1, "", ""], + ["cork_5c_h", 15, 1937, 0, 0, 1, "", ""], + ["cork_6a_h", 15, 1937, 0, 0, 1, "", ""], + ["cork_6b_h", 15, 1937, 0, 0, 1, "", ""], + ["cork_6c_h", 15, 1937, 0, 0, 1, "", ""], + ["spawn_1", 16, "ajq_spawnpointlp", 0, 1, 1, "", ""], + ["spawn_2", 16, "ajq_spawnpointlp", 0, 1, 1, "", ""], + ["spawn_3", 16, "ajq_spawnpointlp", 0, 1, 1, "", ""], + ["spawn_4", 16, "ajq_spawnpointlp", 0, 1, 1, "", ""], + ["waterfall", 16, "ajq_waterfall_lp", 0, 0, 1, "", ""], + ["sludgewall", 16, "ajq_sludge_lp", 0, 1, 1, "", ""], + ["sludge_1", 16, "ajq_sludge_lp", 0, 1, 1, "", ""], + ["sludge_2", 16, "ajq_sludge_lp", 0, 1, 1, "", ""], + ["sludge_3", 16, "ajq_sludge_lp", 0, 1, 1, "", ""], + ["sludge_4", 16, "ajq_sludge_lp", 0, 1, 1, "", ""], + ["sludge_5", 16, "ajq_sludge_lp", 0, 1, 1, "", ""], + ["sludge_6", 16, "ajq_sludge_lp", 0, 1, 1, "", ""], + ["portal", 16, "ajq_portalgatelp", 0, 0, 1, "", ""], + ["diffvol_1", 5, 0, 0, 1, 1, "", ""], + ["diffvol_2", 5, 0, 0, 1, 1, "", ""], + ["diffvol_3", 5, 0, 0, 1, 1, "", ""], + ["bunnyblocker", 5, 0, 0, 1, 1, "", ""], + ["phan_block_e", 5, 0, 0, 1, 1, "", ""], + ["phan_block_h", 5, 0, 0, 1, 1, "", ""], + ["watervol_1", 5, 0, 0, 1, 1, "", ""], + ["vineblock_1", 5, 0, 0, 1, 1, "", ""], + ["vineblock_2", 5, 0, 0, 1, 1, "", ""], + ["blocker_h", 5, 0, 0, 1, 1, "", ""], + ["blocker_e", 5, 0, 0, 1, 1, "", ""], + ["exit_block", 5, 0, 0, 1, 1, "", ""], + ["bunnyvol_1", 5, 0, 0, 1, 1, "", ""], + ["bunnytrig_1", 1, 45, 0, 1, 1, "", ""], + ["cheatchq", 3, 0, 0, 1, 1, "", ""], + ["phan_trig_e", 1, 44, 0, 1, 1, "", ""], + ["phan_trig_h", 1, 44, 0, 1, 1, "", ""], + ["phan_key_1", 15, 1912, 0, 0, 1, "", ""], + ["cage10_f", 2, 0, 0, 1, 1, "", ""], + ["cage10_b", 2, 0, 0, 1, 1, "", ""], + ["cage9_f", 2, 0, 0, 1, 1, "", ""], + ["cage9_b", 2, 0, 0, 1, 1, "", ""], + ["cage8_f", 2, 0, 0, 1, 1, "", ""], + ["cage8_b", 2, 0, 0, 1, 1, "", ""], + ["cage7_f", 2, 0, 0, 1, 1, "", ""], + ["cage7_b", 2, 0, 0, 1, 1, "", ""], + ["burrow_door", 2, 0, 0, 1, 1, "", ""], + ["bunnytile_1", 2, 0, 0, 1, 1, "", ""], + ["bunnyblock_1", 2, 0, 0, 1, 1, "", ""], + ["phan_door_e", 2, 0, 0, 1, 1, "", ""], + ["phan_door_h", 2, 0, 0, 1, 1, "", ""], + ["vine_1", 2, 0, 0, 1, 1, "", ""], + ["vine_2", 2, 0, 0, 1, 1, "", ""], + ["well_1", 2, 0, 0, 1, 1, "", ""], + ["well_1h", 2, 0, 0, 1, 1, "", ""], + ["water_1", 2, 0, 0, 1, 1, "", ""], + ["easy", 2, 0, 0, 1, 1, "", ""], + ["hard", 2, 0, 0, 1, 1, "", ""], + ["pipe_1", 2, 0, 0, 1, 1, "", ""], + ["pipe_2", 2, 0, 0, 1, 1, "", ""], + ["pipe_3", 2, 0, 0, 1, 1, "", ""], + ["pipe_4", 2, 0, 0, 1, 1, "", ""], + ["pipe_5", 2, 0, 0, 1, 1, "", ""], + ["pipe_6", 2, 0, 0, 1, 1, "", ""], + ["flowers_1", 2, 0, 0, 1, 1, "", ""], + ["flowers_2", 2, 0, 0, 1, 1, "", ""], + ["flowers_3", 2, 0, 0, 1, 1, "", ""], + ["flowers_4", 2, 0, 0, 1, 1, "", ""], + ["flowers_5", 2, 0, 0, 1, 1, "", ""], + ["flowers_6", 2, 0, 0, 1, 1, "", ""], + ["flowers_7", 2, 0, 0, 1, 1, "", ""], + ["flowers_8", 2, 0, 0, 1, 1, "", ""], + ["flowers_9", 2, 0, 0, 1, 1, "", ""], + ["flowers_10", 2, 0, 0, 1, 1, "", ""], + ["flowers_11", 2, 0, 0, 1, 1, "", ""], + ["flowers_12", 2, 0, 0, 1, 1, "", ""], + ["exit_port", 2, 0, 0, 1, 1, "", ""], + ["phantom_1", 11, 2, 0, 0, 1, "", ""], + ["phantom_2", 11, 2, 0, 0, 1, "", ""], + ["phantom_2_h", 11, 2, 0, 0, 1, "", ""], + ["phantom_3", 11, 2, 0, 0, 1, "", ""], + ["phantom_3_h", 11, 2, 0, 0, 1, "", ""], + ["phantom_4", 11, 2, 0, 0, 1, "", ""], + ["phantom_5__a", 11, 2, 0, 0, 1, "", ""], + ["phantom_5__b", 11, 2, 0, 0, 1, "", ""], + ["phantom_5__c", 11, 2, 0, 0, 1, "", ""], + ["phantom_5_h", 11, 2, 0, 0, 1, "", ""], + ["phantom_6", 11, 2, 0, 0, 1, "", ""], + ["phantom_7", 11, 2, 0, 0, 1, "", ""], + ["phantom_8__a", 11, 2, 0, 0, 1, "", ""], + ["phantom_8__b", 11, 2, 0, 0, 1, "", ""], + ["phantom_9", 11, 2, 0, 0, 1, "", ""], + ["phantom_9a_h", 11, 2, 0, 0, 1, "", ""], + ["phantom_9b_h", 11, 2, 0, 0, 1, "", ""], + ["phantom_9c_h", 11, 2, 0, 0, 1, "", ""], + ["phantom_10", 11, 2, 0, 0, 1, "", ""], + ["phantom_11", 11, 2, 0, 0, 1, "", ""], + ["phantom_11_h", 11, 2, 0, 0, 1, "", ""], + ["phantom_12", 11, 2, 0, 0, 1, "", ""], + ["phantom_12_h", 11, 2, 0, 0, 1, "", ""], + ["phantom_13", 11, 2, 0, 0, 1, "", ""], + ["phantom_13_h", 11, 2, 0, 0, 1, "", ""], + ["phantom_14", 11, 2, 0, 0, 1, "", ""], + ["phantom_14_h", 11, 2, 0, 0, 1, "", ""], + ["phantom_15", 11, 2, 0, 0, 1, "", ""], + ["phantom_15_h", 11, 2, 0, 0, 1, "", ""], + ["phantom_16_h", 11, 2, 0, 0, 1, "", ""], + ["phantom_17_h", 11, 2, 0, 0, 1, "", ""], + ["phantom_18_h", 11, 2, 0, 0, 1, "", ""], + ["phantom_19_h", 11, 2, 0, 0, 1, "", ""], + ["phantoff1", 8, 0, 0, 0, 1, "", ""], + ["phantoff2", 8, 0, 0, 0, 1, "", ""], + ["phantoff2h", 8, 0, 0, 0, 1, "", ""], + ["phantoff3", 8, 0, 0, 0, 1, "", ""], + ["phantoff3h", 8, 0, 0, 0, 1, "", ""], + ["phantoff4", 8, 0, 0, 0, 1, "", ""], + ["phantoff5a", 8, 0, 0, 0, 1, "", ""], + ["phantoff5b", 8, 0, 0, 0, 1, "", ""], + ["phantoff5c", 8, 0, 0, 0, 1, "", ""], + ["phantoff5h", 8, 0, 0, 0, 1, "", ""], + ["phantoff6", 8, 0, 0, 0, 1, "", ""], + ["phantoff7", 8, 0, 0, 0, 1, "", ""], + ["phantoff8a", 8, 0, 0, 0, 1, "", ""], + ["phantoff8b", 8, 0, 0, 0, 1, "", ""], + ["phantoff9", 8, 0, 0, 0, 1, "", ""], + ["phantoff9a", 8, 0, 0, 0, 1, "", ""], + ["phantoff9b", 8, 0, 0, 0, 1, "", ""], + ["phantoff9c", 8, 0, 0, 0, 1, "", ""], + ["phantoff10", 8, 0, 0, 0, 1, "", ""], + ["phantoff11", 8, 0, 0, 0, 1, "", ""], + ["phantoff11h", 8, 0, 0, 0, 1, "", ""], + ["phantoff12", 8, 0, 0, 0, 1, "", ""], + ["phantoff12h", 8, 0, 0, 0, 1, "", ""], + ["phantoff13", 8, 0, 0, 0, 1, "", ""], + ["phantoff13h", 8, 0, 0, 0, 1, "", ""], + ["phantoff14", 8, 0, 0, 0, 1, "", ""], + ["phantoff14h", 8, 0, 0, 0, 1, "", ""], + ["phantoff15", 8, 0, 0, 0, 1, "", ""], + ["phantoff15h", 8, 0, 0, 0, 1, "", ""], + ["phantoff16h", 8, 0, 0, 0, 1, "", ""], + ["phantoff17h", 8, 0, 0, 0, 1, "", ""], + ["phantoff18h", 8, 0, 0, 0, 1, "", ""], + ["phantoff19h", 8, 0, 0, 0, 1, "", ""], + ["treasure_1", 13, 39, 0, 1, 1, "", ""], + ["treasure_2", 13, 39, 0, 1, 1, "", ""], + ["treasure_3", 13, 39, 0, 1, 1, "", ""], + ["treasure_4", 13, 39, 0, 1, 1, "", ""], + ["treasure_5", 13, 39, 0, 1, 1, "", ""], + ["treasure_6", 13, 39, 0, 1, 1, "", ""], + ["treasure_7", 13, 39, 0, 1, 1, "", ""], + ["bunny_key_1a", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_1b", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_1c", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_1d", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_1e", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_1f", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_2a", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_2b", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_2c", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_2d", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_2e", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_2f", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_3a", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_3b", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_3c", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_3d", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_3e", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_3f", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_4a", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_4b", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_4c", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_4d", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_4e", 15, 1912, 0, 0, 1, "", ""], + ["bunny_key_4f", 15, 1912, 0, 0, 1, "", ""], + ["exit_vol", 3, 0, 0, 1, 1, "", ""], + ["secret_1", 3, 0, 0, 1, 1, "", ""], + ["secret_2", 3, 0, 0, 1, 1, "", ""], + ["00_uri", 7, 0, 0, 0, 1, "", ""], + ["10_uri", 7, 0, 0, 0, 1, "", ""], + ["20_uri", 7, 0, 0, 0, 1, "", ""], + ["30_uri", 7, 0, 0, 0, 1, "", ""], + ["40_uri", 7, 0, 0, 0, 1, "", ""], + ["diff_level", 7, 0, 0, 1, 1, "", ""], + ["live_players", 7, 0, 1, 0, 1, "", ""], + ["playermember", 7, 0, 0, 1, 1, "", ""], ], + + on: { + trigger: { + // sent by the client each time one of the rooms is up. + questready(q) { + if (q.vars.begun) { + return; + } + Object.assign(q.vars, {begun: true, plugged: new Set(), watered: new Set(), freed: new Set(), eaten: new Set(), opened: new Set()}); + counter(q, "start_init", 1); + q.after(270, () => { + lizaAppears(q, "liza_1"); + set(q, "well_1", 1, 1, 0); + set(q, "water_1", 1, 1, 0); + for (const number of NORMAL_FLOWERS) { + set(q, `flowers_${number}`, 1, 1, 0); + } + for (const name of HARD_ONLY) { + set(q, name, 99, 0, 0); + } + // each cork and key has several places it may lie in; the + // recording had corks 2a, 3a, 4a and keys 1c to 4c. guessed: + // that the place is drawn by lot. + for (const number of [2, 3, 4]) { + set(q, `cork_${number}${pick("abc")}`, 1, 1, 0); + } + for (const number of [1, 2, 3, 4]) { + set(q, `bunny_key_${number}${pick("abcdef")}`, 1, 1, 0); + } + }); + }, + + liza_1: q => q.send("qcmd", 3, 0, "liza_1", 1, 3461), + liza_2: q => q.send("qcmd", 3, 0, "liza_2", 1, 3495), + bunny_1: q => say(q, "bunny_1", 3462), + bunny_2(q) { + if (q.vars.corkGiven) { + return; + } + q.vars.corkGiven = true; + say(q, "bunny_2", 3463); + set(q, "bunny_2", 2, 1, 0); + set(q, "cork_1", 1, 1, 0); + q.after(47, () => set(q, "pipetrig_1", 1, 1, 1)); + }, + bunnytrig_3: q => say(q, "bunny_3", 3469), + bunny_6(q) { + say(q, "bunny_6", 3488); + set(q, "bunny_6", 1, 1, 0); + if (!q.vars.keyShown) { + q.vars.keyShown = true; + set(q, "phan_key_1", 1, 1, 0); + } + }, + + // the burrow's door and back. the second pair was not walked through + // in the recording and is guessed from the first. + trig_1a: q => q.room("burrow", "spawn_1_a"), + trig_1_a: q => q.room("start", "spawn_1a"), + trig_1b: q => q.room("burrow", "spawn_1_b"), + trig_1_b: q => q.room("start", "spawn_1b"), + + // the phantoms' door, with the burrow's key. + phan_trig_e(q) { + if (q.held() !== "phan_key_1" || q.vars.doorOpen) { + return; + } + q.vars.doorOpen = true; + q.use(); + set(q, "phan_door_e", 1, 1, 0); + set(q, "phan_trig_e", 1, 0, 0); + q.xp(15, "phan_trig_e"); + goal(q, 3490); + phantoms(q, [["phantom_1", "path_1"], ["phantom_6", "path_6"], ["phantom_7", "path_7"], ["phantom_10", null], + ["phantom_11", "path_1"], ["phantom_12", "path_12"], ["phantom_13", null], ["phantom_14", null], ["phantom_15", null]]); + q.after(2964, () => set(q, "phan_block_e", 1, 0, 0)); + }, + + exit_vol: q => q.send("qcmd", 19), + }, + + triggerLike: [ + [/^pipetrig_[1-4]$/, pipePlugged], + [/^flowertrig_?\d+$/, flowerWatered], + [/^bunny_(7|8|9|10)$/, bunnyFreed], + // QuestActor.handleTriggerTreasure: [actor, 3, gems, 0, 1] + [/^treasure_\d+$/, (q, chest) => { + if (!q.vars.opened.has(chest)) { + q.send("qatt", chest, 3, CHEST_GEMS[chest] || GUESSED_CHEST_GEMS, 0, 1); + } + }], + // the gem an eaten phantom leaves, walked into. + [/^phantom_\w+__give_gem$/, (q, gem) => { + const phantom = gem.slice(0, -"__give_gem".length); + if (q.vars.eaten.has(phantom) && !q.vars.opened.has(gem)) { + q.vars.opened.add(gem); + q.gems(25); + q.send("qad", gem, 0, "null"); + } + }], + ], + + // a talk read to its end + answer: { + liza_1(q) { + counter(q, "00_uri", 1); + counter(q, "players", 1); + q.send("qposturi", "/adventure1-returnofthephantoms/#00-start/#0#001"); + counter(q, "00_uri", 99); + set(q, "vineblock_1", 1, 0, 0); + set(q, "vine_1", 1, 1, 0); + q.send("qswfs", "liza_1", "disappear"); + set(q, "liza_1", 2, 1, 1); + set(q, "liza_1", 3, 1, 0); + goal(q, 3466); + }, + liza_2(q) { + if (q.vars.thanked) { + return; + } + q.vars.thanked = true; + set(q, "liza_2", 2, 1, 1); + set(q, "exit_port", 1, 1, 0); + set(q, "portal", 1, 1, 0); + q.xp(50, "liza_2"); + set(q, "liza_2", 3, 1, 0); + q.after(565, () => { + page(q, "40_uri", "40-exit"); + q.offer(PRIZES); + }); + }, + }, + + pickedUp: { + // the bunnies outside hear of the key. + phan_key_1(q) { + q.after(47, () => { + set(q, "bunny_1", 3, 1, 1); + set(q, "bunny_2", 4, 1, 1); + set(q, "bunny_4", 2, 1, 1); + }); + }, + }, + + // A plant ate a phantom ([actor, 50, 1, x, y, ""] has it die there), + // which leaves a gem worth 25 behind. + eaten(q, plant, phantom, x, y) { + if (!/^phantom_\w+$/.test(phantom) || q.vars.eaten.has(phantom)) { + return; + } + q.vars.eaten.add(phantom); + q.send("qad", phantom, 50, 1, x, y, ""); + q.send("qspn", phantom, `${phantom}__give_gem`, 200, 42, 3, 25, "null", "null", "null"); + q.xp(5, phantom); + set(q, phantom, 3, 1, 0); + q.after(1500, () => set(q, phantom, 99, 0, 0)); + }, + + // a chest, opened + openedLike: [ + [/^treasure_\d+$/, (q, chest) => { + if (!q.vars.opened.has(chest)) { + q.vars.opened.add(chest); + q.gems(CHEST_GEMS[chest] || GUESSED_CHEST_GEMS); + q.xp(5, chest); + } + }], + ], + + // the prize taken + gifted(q) { + q.after(960, () => set(q, "exit_block", 1, 0, 0)); + }, + }, +}; diff --git a/lib/adventures/training-grounds.js b/lib/adventures/training-grounds.js new file mode 100644 index 0000000..12e4856 --- /dev/null +++ b/lib/adventures/training-grounds.js @@ -0,0 +1,198 @@ +"use strict"; + +// the Training Grounds ("Adventure Tutorial", script def 15), written from +// a recording of the official game of 2026-10-12: one player, who talked +// to Liza four times, fed the four phantoms to the plants, crept past the +// rest unseen and opened the chest. everything sent here was seen sent +// there, in this order. not in the recording, so not here: being caught by +// a phantom. +// +// commands ("qcmd"): 1 sets an actor's [state, visible, needs a click]; +// 3 has it talk (a string id); 38 is the line under the screen's top; 19 +// ends the adventure. "qswfs" plays a state of an actor's artwork. + +const liza = (q, name, ...artwork) => { + for (const state of artwork) { + q.send("qswfs", name, state); + } + q.send("qcmd", 1, name, 1, 1, 1); +}; +const TALKS = {liza_1: 3149, liza_2: 3150, liza_3: 3155, liza_4: 3151}; +const talk = name => q => q.send("qcmd", 3, 0, name, 1, TALKS[name]); +// Liza leaves in two steps and is put away a little later. +const leaves = (q, name, between, gone) => { + q.send("qswfs", name, "disappear"); + q.send("qcmd", 1, name, 2, 1, 1); + between(); + q.send("qcmd", 1, name, 3, 1, 0); + q.after(gone, () => q.send("qcmd", 1, name, 4, 0, 0)); +}; +const TRAPPED_LINES = [3539, 3540, 3541]; + +module.exports = { + defId: 15, + title: "Training Grounds", + rooms: {start: {room: "adventures.room_adventure_tutorial", name: "Adventure Tutorial", nameStringId: 18326, music: "ajq_mustutorial"}}, + written: "2018-03-14 22:04:55", + objective: 3152, // "TALK to Liza." + + // name, type, def, state, visible, needs a click, path, artwork state + actors: [ + ["queststart", 18, 0, 0, 1, 1, "", ""], + ["checkpoint", 16, "ajq_spawnpointlp", 0, 1, 1, "", ""], + ["portal", 16, "ajq_portalgatelp", 0, 0, 1, "", ""], + ["lizatimer_1", 8, 0, 0, 0, 1, "", ""], + ["liza_1", 1, 21, 0, 0, 1, "", ""], + ["liza_2", 1, 21, 0, 0, 1, "", ""], + ["lizatimer_2", 8, 0, 0, 0, 1, "", ""], + ["lizatimer_3", 8, 0, 0, 0, 1, "", ""], + ["lizatrig_1", 3, 0, 0, 1, 1, "", ""], + ["blockvol_1", 5, 0, 0, 1, 1, "", ""], + ["blockvol_2", 5, 0, 0, 1, 1, "", ""], + ["blockvol_3", 5, 0, 0, 1, 1, "", ""], + ["block_1", 2, 0, 0, 1, 1, "", ""], + ["block_2", 2, 0, 0, 1, 1, "", ""], + ["block_3", 2, 0, 0, 1, 1, "", ""], + ["phantom_1", 11, 2, 0, 1, 1, "", ""], + ["phantom_2", 11, 2, 0, 1, 1, "", ""], + ["phantom_3", 11, 2, 0, 1, 1, "", ""], + ["phantom_4__a", 11, 2, 0, 1, 1, "", ""], + ["phantom_4__b", 11, 2, 0, 1, 1, "", ""], + ["plant_0", 21, 100, 0, 1, 1, "", ""], + ["plant_1", 21, 100, 0, 1, 1, "", ""], + ["plant_2", 21, 100, 0, 1, 1, "", ""], + ["plant_3", 21, 100, 0, 1, 1, "", ""], + ["plant_4", 21, 100, 0, 1, 1, "", ""], + ["phantom_5", 11, 2, 0, 1, 1, "path_5", ""], + ["phantom_6", 11, 2, 0, 1, 1, "path_6", ""], + ["phantom_7", 11, 2, 0, 1, 1, "path_7", ""], + ["phantom_8", 11, 2, 0, 1, 1, "path_8", ""], + ["phantom_9", 11, 2, 0, 1, 1, "path_9", ""], + ["phantom_10", 11, 2, 0, 1, 1, "path_10", ""], + ["phantom_11", 11, 2, 0, 1, 1, "path_11", ""], + ["phantom_12", 11, 2, 0, 1, 1, "path_12", ""], + ["phantom_13", 11, 2, 0, 1, 1, "path_13", ""], + ["phantom_14", 11, 2, 0, 1, 1, "path_14", ""], + ["treasure_1", 13, 39, 0, 0, 1, "", ""], + ["exitblock", 5, 0, 0, 1, 1, "", ""], + ["exit", 2, 0, 0, 1, 1, "", ""], + ["exitvol", 3, 0, 0, 1, 1, "", ""], + ["liza_3", 1, 21, 0, 0, 1, "", ""], + ["lizatimer_4", 8, 0, 0, 0, 1, "", ""], + ["lizatrig_3", 3, 0, 0, 1, 1, "", ""], + ["liza_4", 1, 21, 0, 0, 1, "", ""], + ["lizatimer_5", 8, 0, 0, 0, 1, "", ""], + ["trap_count", 7, 0, 0, 0, 1, "", ""], + ["traptimer", 8, 0, 0, 0, 1, "", ""], + ["path_5", 20, 0, 0, 1, 1, "", ""], + ["path_6", 20, 0, 0, 1, 1, "", ""], + ["path_7", 20, 0, 0, 1, 1, "", ""], + ["path_8", 20, 0, 0, 1, 1, "", ""], + ["path_9", 20, 0, 0, 1, 1, "", ""], + ["path_10", 20, 0, 0, 1, 1, "", ""], + ["path_11", 20, 0, 0, 1, 1, "", ""], + ["path_12", 20, 0, 0, 1, 1, "", ""], + ["path_13", 20, 0, 0, 1, 1, "", ""], + ["path_14", 20, 0, 0, 1, 1, "", ""], + ["diff_level", 7, 0, 0, 1, 1, "", ""], + ["live_players", 7, 0, 1, 0, 1, "", ""], ], + + on: { + loaded(q) { + q.vars.trapped = 0; + q.after(1700, () => liza(q, "liza_1", "facesw", "appear")); + }, + + // walked into, or clicked + trigger: { + liza_1: talk("liza_1"), + liza_2: talk("liza_2"), + liza_3: talk("liza_3"), + liza_4: talk("liza_4"), + lizatrig_1(q) { + liza(q, "liza_2", "facesw", "appear"); + q.send("qcmd", 1, "lizatrig_1", 1, 0, 0); + }, + lizatrig_3(q) { + liza(q, "liza_4", "appear"); + q.send("qposturi", "/adventure0-tutorial/#20-sneakpastthephantoms/#0#001"); + q.send("qcmd", 1, "lizatrig_3", 1, 0, 0); + }, + // QuestActor.handleTriggerTreasure: [actor, 3, gems, 0, 1] + treasure_1(q) { + q.send("qatt", "treasure_1", 3, 250, 0, 1); + q.send("qposturi", "/adventure0-tutorial/#30-exit/#0#001"); + }, + exitvol(q) { + q.send("qcmd", 19); + }, + }, + + // a talk read to its end + answer: { + liza_1(q) { + q.send("qposturi", "/adventure0-tutorial/#00-start/#0#001"); + q.send("qcmd", 1, "block_1", 1, 1, 0); + q.send("qcmd", 1, "blockvol_1", 1, 0, 0); + q.send("qcmd", 38, 3157); + leaves(q, "liza_1", () => {}, 2200); + }, + liza_2(q) { + q.send("qcmd", 1, "blockvol_2", 1, 0, 0); + q.send("qcmd", 1, "block_2", 1, 1, 0); + leaves(q, "liza_2", () => {}, 2950); + q.send("qcmd", 38, 3538); + }, + liza_3(q) { + q.send("qcmd", 1, "block_3", 1, 1, 0); + q.send("qcmd", 1, "blockvol_3", 1, 0, 0); + q.send("qcmd", 38, 3542); + leaves(q, "liza_3", () => {}, 2580); + }, + liza_4(q) { + q.send("qcmd", 1, "treasure_1", 1, 1, 1); + leaves(q, "liza_4", () => q.send("qcmd", 38, 3543), 2700); + // the recording's animal was level 0 and got 50 XP here, which made + // it level 1. guessed: that this is for a first time only. + if (q.level() === 0) { + q.after(690, () => q.xp(50, "lizatimer_5")); + } + }, + }, + + // A plant ate a phantom: [actor, 50, 1, x, y, ""] has it die there. + eaten(q, plant, phantom, x, y) { + if (!/^phantom_\w+$/.test(phantom) || q.vars.trapped >= 4) { + return; + } + q.vars.trapped++; + q.send("qad", phantom, 50, 1, x, y, ""); + q.send("qcmdVT", 1, "trap_count", q.vars.trapped, 0, 0); + if (q.vars.trapped < 4) { + q.send("qcmd", 38, TRAPPED_LINES[q.vars.trapped - 1]); + } + else { + q.send("qposturi", "/adventure0-tutorial/#10-trapthephantoms/#0#001"); + q.send("qcmd", 38, 3152); + q.after(500, () => liza(q, "liza_3", "facesw", "appear")); + } + q.xp(1, phantom); + }, + + // the chest, opened + opened: { + treasure_1(q) { + if (q.vars.opened) { + return; + } + q.vars.opened = true; + q.gems(250); + q.xp(1, "treasure_1"); + q.send("qcmd", 1, "exitblock", 1, 0, 0); + q.send("qcmd", 1, "exit", 1, 1, 0); + q.send("qcmd", 1, "portal", 1, 1, 0); + q.send("qposturi", "/adventure0-tutorial/#30-exit/#0#001"); + }, + }, + }, +}; diff --git a/lib/amf3.js b/lib/amf3.js new file mode 100644 index 0000000..13b0cab --- /dev/null +++ b/lib/amf3.js @@ -0,0 +1,278 @@ +"use strict"; + +// minimal AMF3 reader, enough for the game's defPacks (objects, arrays, +// strings and numbers). + +class Amf3Reader { + constructor(buf) { + this.buf = buf; + this.pos = 0; + this.strings = []; + this.objects = []; + this.traits = []; + } + + u29() { + let value = 0; + for (let i = 0; i < 4; i++) { + const b = this.buf[this.pos++]; + if (i === 3) { + return (value << 8) | b; + } + value = (value << 7) | (b & 0x7f); + if (!(b & 0x80)) { + break; + } + } + return value; + } + + string() { + const ref = this.u29(); + if (!(ref & 1)) { + return this.strings[ref >> 1]; + } + const len = ref >> 1; + if (len === 0) { + return ""; + } + const str = this.buf.toString("utf8", this.pos, this.pos + len); + this.pos += len; + this.strings.push(str); + return str; + } + + value() { + const type = this.buf[this.pos++]; + switch (type) { + case 0x00: return undefined; + case 0x01: return null; + case 0x02: return false; + case 0x03: return true; + case 0x04: { + const n = this.u29(); + return n & 0x10000000 ? n - 0x20000000 : n; + } + case 0x05: { + const n = this.buf.readDoubleBE(this.pos); + this.pos += 8; + return n; + } + case 0x06: return this.string(); + case 0x08: { + const ref = this.u29(); + if (!(ref & 1)) { + return this.objects[ref >> 1]; + } + const date = new Date(this.buf.readDoubleBE(this.pos)); + this.pos += 8; + this.objects.push(date); + return date; + } + case 0x09: return this.array(); + case 0x0a: return this.object(); + case 0x0c: { + const ref = this.u29(); + if (!(ref & 1)) { + return this.objects[ref >> 1]; + } + const bytes = this.buf.subarray(this.pos, this.pos + (ref >> 1)); + this.pos += ref >> 1; + this.objects.push(bytes); + return bytes; + } + // Vector., Vector., Vector., Vector. + case 0x0d: + case 0x0e: + case 0x0f: + case 0x10: { + const ref = this.u29(); + if (!(ref & 1)) { + return this.objects[ref >> 1]; + } + const out = []; + this.objects.push(out); + this.pos += 1; // fixed-length flag + if (type === 0x10) { + this.string(); // element class name + } + for (let i = 0; i < ref >> 1; i++) { + if (type === 0x10) { + out.push(this.value()); + } + else if (type === 0x0f) { + out.push(this.buf.readDoubleBE(this.pos)); + this.pos += 8; + } + else { + out.push(type === 0x0d ? this.buf.readInt32BE(this.pos) : this.buf.readUInt32BE(this.pos)); + this.pos += 4; + } + } + return out; + } + default: + throw new Error(`Unsupported AMF3 type 0x${type.toString(16)} at ${this.pos - 1}`); + } + } + + array() { + const ref = this.u29(); + if (!(ref & 1)) { + return this.objects[ref >> 1]; + } + const dense = ref >> 1; + const assoc = {}; + let hasAssoc = false; + const out = []; + this.objects.push(out); + for (let key = this.string(); key !== ""; key = this.string()) { + assoc[key] = this.value(); + hasAssoc = true; + } + for (let i = 0; i < dense; i++) { + out.push(this.value()); + } + if (hasAssoc) { + Object.assign(out, assoc); + } + return out; + } + + object() { + const ref = this.u29(); + if (!(ref & 1)) { + return this.objects[ref >> 1]; + } + let traits; + if (!(ref & 2)) { + traits = this.traits[ref >> 2]; + } + else { + if (ref & 4) { + throw new Error("Externalizable AMF3 objects are not supported"); + } + traits = {dynamic: Boolean(ref & 8), names: []}; + const count = ref >> 4; + this.string(); // class name + for (let i = 0; i < count; i++) { + traits.names.push(this.string()); + } + this.traits.push(traits); + } + const out = {}; + this.objects.push(out); + for (const name of traits.names) { + out[name] = this.value(); + } + if (traits.dynamic) { + for (let key = this.string(); key !== ""; key = this.string()) { + out[key] = this.value(); + } + } + return out; + } +} + +// writer for what the reader above produces from a defPack: plain objects, +// arrays (with or without string keys), strings, numbers, booleans and null. +// nothing is written as a reference except repeated strings. +class Amf3Writer { + constructor() { + this.parts = []; + this.strings = new Map(); + } + + u29(value) { + if (value < 0x80) { + this.parts.push(Buffer.from([value])); + } + else if (value < 0x4000) { + this.parts.push(Buffer.from([(value >> 7) | 0x80, value & 0x7f])); + } + else if (value < 0x200000) { + this.parts.push(Buffer.from([(value >> 14) | 0x80, ((value >> 7) & 0x7f) | 0x80, value & 0x7f])); + } + else { + this.parts.push(Buffer.from([(value >> 22) | 0x80, ((value >> 15) & 0x7f) | 0x80, ((value >> 8) & 0x7f) | 0x80, value & 0xff])); + } + } + + string(text) { + if (text === "") { + this.u29(1); + } + else if (this.strings.has(text)) { + this.u29(this.strings.get(text) << 1); + } + else { + this.strings.set(text, this.strings.size); + const bytes = Buffer.from(text, "utf8"); + this.u29((bytes.length << 1) | 1); + this.parts.push(bytes); + } + } + + pairs(entries) { + for (const [key, value] of entries) { + this.string(key); + this.value(value); + } + this.string(""); + } + + value(value) { + if (value === undefined) { + this.parts.push(Buffer.from([0x00])); + } + else if (value === null) { + this.parts.push(Buffer.from([0x01])); + } + else if (typeof value === "boolean") { + this.parts.push(Buffer.from([value ? 0x03 : 0x02])); + } + else if (typeof value === "number") { + if (Number.isInteger(value) && value >= -0x10000000 && value < 0x10000000) { + this.parts.push(Buffer.from([0x04])); + this.u29(value & 0x1fffffff); + } + else { + const bytes = Buffer.alloc(9); + bytes[0] = 0x05; + bytes.writeDoubleBE(value, 1); + this.parts.push(bytes); + } + } + else if (typeof value === "string") { + this.parts.push(Buffer.from([0x06])); + this.string(value); + } + else if (Array.isArray(value)) { + this.parts.push(Buffer.from([0x09])); + this.u29((value.length << 1) | 1); + // string keys set on the array beside its numbered elements. + this.pairs(Object.entries(value).filter(([key]) => !/^\d+$/.test(key))); + for (const element of value) { + this.value(element); + } + } + else if (typeof value === "object" && !Buffer.isBuffer(value)) { + // A dynamic object of no class, with its traits written in place. + this.parts.push(Buffer.from([0x0a, 0x0b])); + this.string(""); + this.pairs(Object.entries(value)); + } + else { + throw new Error("Cannot write this value as AMF3"); + } + } +} + +module.exports = { + decode: buf => new Amf3Reader(buf).value(), + encode: value => { + const writer = new Amf3Writer(); + writer.value(value); + return Buffer.concat(writer.parts); + }, +}; diff --git a/lib/avatars.js b/lib/avatars.js new file mode 100644 index 0000000..dad5ae4 --- /dev/null +++ b/lib/avatars.js @@ -0,0 +1,148 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const colours = require("./colours.js"); +const badges = require("./badges.js"); +const defpacks = require("./defpacks.js"); +const {activeAvatar, activePet, wornItems, lastSeenField, isUint} = require("./player.js"); + +// owning several animals (client side: AvatarSwitch, AvatarXtCommManager). +// new animals are free. + +const MAX_AVATARS = 1000; // where the client's animal switcher stops counting + +// AvatarXtCommManager.avatarGetResponse status +const PLAYER_OFFLINE = 0; +const PLAYER_ONLINE = 1; +const PLAYER_UNKNOWN = 3; + +// avatar.NameBar: colour ids 0-10, a badge by its place in the badge list, +// and one bit for "hide my adventure level". +const NAME_BAR_COLORS = 10; +const validNameBarData = (value, account) => Number.isInteger(value) && value >= 0 + && (value & 0xFF) <= NAME_BAR_COLORS + && (value >> 8 & 0xFF) < defpacks.badgeIds().length + && badges.mayWear(account, defpacks.badgeIds()[value >> 8 & 0xFF]) // the ones the admin gives: lib/badges.js + && (value >> 16) <= 1; + +module.exports = ({others, findOnline, findBySfsId, refreshForOthers, petFields}) => { + // A player's card: who they are, the animal they are using and what it + // wears. AvatarXtCommManager.avatarGetResponse reads [username, uuid, + // status, accountType, isGuide, daysSinceLogin, perUserAvId, avInvId, + // nameBarData, avatarType, customAvatarId, 3 colours, avatarName, eyesDefId, + // patternDefId, questLevel, clothingCount, sfsUserId, moderatedFlag, pet + // lBits/uBits/eBits/name, (itemDefId, colour)...]. + const sendPlayerCard = (session, account, requestedName) => { + if (!account) { + session.sendXt("ag", -1, requestedName, "", PLAYER_UNKNOWN); + return; + } + const targetSession = findOnline(account.username); + const avatar = activeAvatar(account); + const worn = wornItems(account, avatar); + session.sendXt("ag", -1, account.username, account.uuid, targetSession ? PLAYER_ONLINE : PLAYER_OFFLINE, + account.accountType, account.isGuide ? 1 : 0, lastSeenField(account, Boolean(targetSession)), + avatar.perUserAvId, avatar.avInvId, account.nameBarData, avatar.type, avatar.customAvId, ...avatar.colors, avatar.name, + avatar.eyes, avatar.pattern, avatar.questLevel || 0, worn.length, targetSession ? targetSession.id : -1, 1, + ...petFields(activePet(account)).slice(0, 4), + ...worn.flatMap(item => [item.def, item.color])); + }; + + return { + // [username, ?] + ag(session, roomId, [username]) { + sendPlayerCard(session, accounts.byName(username), username); + }, + + // [sfsUserId, ?]: the same, for a player met in a room + ags(session, roomId, [sfsUserId]) { + const target = findBySfsId(Number(sfsUserId)); + if (target) { + sendPlayerCard(session, target.account, target.account.username); + } + }, + + // AvatarSwitch.addNewWorldAvatar: [nameId1, nameId2, nameId3, avatarType, + // customAvatarId, diamondDefId, shopId]. the name is kept as its three + // localization ids, which is what LocalizationManager.translateAvatarName reads. + aa(session, roomId, [name1, name2, name3, type, customAvId]) { + const {account} = session; + const custom = defpacks.customAvatarDef(customAvId); + if (![name1, name2, name3].every(isUint) || !defpacks.avatarDef(type) || account.avatars.length >= MAX_AVATARS + || (custom && Number(custom.avatarRef) !== Number(type))) { + // AvatarSwitch.addAvatarResponse: [status, perUserAvId, avInvId] + session.sendXt("aa", -1, 0, 0, 0); + return; + } + // the inventory id is a slot: the client cannot count past 1,023 there + // (accounts.freeAvatarSlot). + const avatar = accounts.newAvatar({perUserAvId: account.nextInv++, avInvId: accounts.freeAvatarSlot(account)}, `${name1}|${name2}|${name3}`, type, customAvId); + account.avatars.push(avatar); + accounts.save(); + session.sendXt("aa", -1, 1, avatar.perUserAvId, avatar.avInvId); + }, + + // AvatarSwitch.switchAvatars: [perUserAvId]. everyone in the room gets the + // reply (AvatarSwitch.avatarSwitchResponse / transformEnterFrameHandler); + // it ends differently for the player who switched. + as(session, roomId, [perUserAvId]) { + const {account} = session; + const avatar = account.avatars.find(candidate => candidate.perUserAvId === Number(perUserAvId)); + if (!avatar) { + session.sendXt("as", -1, 0); + return; + } + account.activeAvatar = avatar.perUserAvId; + accounts.save(); + const messageRoom = session.room ? session.room.id : -1; + const common = [1, session.id, avatar.perUserAvId, avatar.avInvId, avatar.customAvId, avatar.type, ...avatar.colors, avatar.name]; + session.sendXt("as", messageRoom, ...common, avatar.petInvId, avatar.questLevel || 0); + if (session.pos) { + for (const other of others(session)) { + other.sendXt("as", messageRoom, ...common, ...petFields(activePet(account)), avatar.questLevel || 0); + } + } + }, + + // AvatarSwitch.avatarKillResponse: [success, ?] + ak(session, roomId, [perUserAvId]) { + const {account} = session; + const avatar = account.avatars.find(candidate => candidate.perUserAvId === Number(perUserAvId)); + if (!avatar || avatar === activeAvatar(account) || account.avatars.length < 2) { + session.sendXt("ak", -1, 0, 0); + return; + } + account.avatars = account.avatars.filter(candidate => candidate !== avatar); + for (const item of account.items) { + item.on = item.on.filter(avInvId => avInvId !== avatar.avInvId); + } + accounts.save(); + session.sendXt("ak", -1, 1, 0); + }, + + // AvatarXtCommManager.requestColorChange: [color1, color2, color3, nameBarData] + ap(session, roomId, colors) { + if (!colors.slice(0, 3).every(isUint) || colors.length < 3 || !colors.slice(0, 3).every(color => colours.known(Number(color)))) { + session.sendXt("ap", -1, 0); + return; + } + activeAvatar(session.account).colors = colors.slice(0, 3).map(Number); + // the name tag is the account's, not the animal's. the client only + // sends it along here, changed or not. + const nameBarData = Number(colors[3]); + const tagChanged = colors.length > 3 && validNameBarData(nameBarData, session.account) && nameBarData !== session.account.nameBarData; + if (tagChanged) { + session.account.nameBarData = nameBarData; + } + accounts.save(); + session.sendXt("ap", -1, 1); + refreshForOthers(session); + if (tagChanged) { + // AvatarXtCommManager "an": [sfsUserId, nameBarData] + for (const other of others(session)) { + other.sendXt("an", session.room.id, session.id, nameBarData); + } + } + }, + }; +}; diff --git a/lib/badges.js b/lib/badges.js new file mode 100644 index 0000000..2eb0592 --- /dev/null +++ b/lib/badges.js @@ -0,0 +1,129 @@ +"use strict"; + +const path = require("path"); +const cdn = require("./cdn.js"); + +// what a player's card shows about the account beyond the game's own: +// marks the admin gives in the panel, the player's Discord username and +// their bio, both of which they set themselves on the account page. all of +// it is for show: a badge gives no power over anything or anyone. +// +// every badge is drawn on the player's card, after the username in the +// name bar (buddy.BuddyCard in the SWF), as public/badges/.png; the +// card is told its id and label. the Discord username is drawn there too, +// last. ids and labels must stay free of "," "|" and "%", which separate +// them on the way to the client. +// +// A badge with `tag` is a name tag badge as well: one more of the icons a +// player picks for their name tag in the animal editor, beside the game's +// own 62. it is a row added to the badge pack (defPack 1049) that clients get, with +// a picture of ours (swf/badges/.swf, served as media `tag.media`) and +// an unlock flag: the editor only offers a badge whose `pendingFlagsBit` is +// set in the flags the login message carries (gui.AvatarEditor +// .onNamebarBadgeIdsLoaded), so it is offered to the accounts that hold it +// and to nobody else, from their next login. the server refuses a name tag +// that names one the account does not hold (lib/avatars.js). the def ids +// must follow the game's own without a gap: a name tag names its badge by +// its place in the list, and the editor takes that to be the def id less +// one. so a badge added later goes on the end and none is ever taken out. +// +// tools/make-badges.py draws both pictures of a badge from one outline. +// +// early Member is given by the server itself, to an account made while +// there are no more than a hundred (lib/accounts.js); the admin may give +// it and take it away like any other. + +// in the order they are listed and drawn. +const BADGES = [ + {id: "owner", label: "Owner", tag: {def: 63, media: 20001, bit: 8}}, + {id: "moderator", label: "Moderator", tag: {def: 64, media: 20002, bit: 9}}, + {id: "contributor", label: "Contributor", tag: {def: 65, media: 20003, bit: 10}}, + {id: "developer", label: "Developer", tag: {def: 66, media: 20004, bit: 11}}, + {id: "artist", label: "Artist", tag: {def: 67, media: 20005, bit: 12}}, + {id: "helper", label: "Helper", tag: {def: 68, media: 20006, bit: 13}}, + {id: "bughunter", label: "Bug Hunter", tag: {def: 69, media: 20007, bit: 14}}, + {id: "eventwinner", label: "Event Winner", tag: {def: 70, media: 20008, bit: 15}}, + {id: "tester", label: "Tester", tag: {def: 71, media: 20009, bit: 16}}, + {id: "friend", label: "Friend", tag: {def: 72, media: 20010, bit: 17}}, + {id: "supporter", label: "Supporter", tag: {def: 73, media: 20011, bit: 18}}, + {id: "partner", label: "Partner", tag: {def: 74, media: 20012, bit: 19}}, + {id: "early", label: "Early Member", tag: {def: 75, media: 20013, bit: 20}}, + {id: "booster", label: "Discord Server Booster"}, // on the card only +]; +const TAG_BADGES = BADGES.filter(badge => badge.tag); + +const known = id => BADGES.some(badge => badge.id === id); + +const of = account => BADGES.filter(badge => account.badges.includes(badge.id)); + +const set = (account, ids) => { + account.badges = BADGES.map(badge => badge.id).filter(id => Array.isArray(ids) && ids.includes(id)); +}; + +// A Discord username as Discord has them now: 2 to 32 of a-z, 0-9, "_" and +// ".", with no two dots in a row. nobody checks that it is theirs. +const DISCORD_NAME = /^(?!.*\.\.)[a-z0-9_.]{2,32}$/; + +// returns the username as it will be kept ("" for none), or null when it +// cannot be one. A leading "@" and capitals are forgiven. +const discordName = text => { + const name = String(text === undefined || text === null ? "" : text).trim().replace(/^@/, "").toLowerCase(); + return name === "" || DISCORD_NAME.test(name) ? name : null; +}; + +// A bio, the player's own words on the Bio tab of their card: up to +// MAX_BIO characters on at most MAX_BIO_LINES lines. returns it as it will +// be kept ("" for none), or null when it is too long. "%" cannot travel in +// the game's messages and is left out. +const MAX_BIO = 200; +const MAX_BIO_LINES = 8; +const bioText = text => { + const bio = String(text === undefined || text === null ? "" : text) + .replace(/\r\n?/g, "\n") + .replace(/[\u0000-\u0009\u000b-\u001f\u007f%]/g, "") + .split("\n").map(line => line.trim()).join("\n") + .replace(/\n{3,}/g, "\n\n") + .trim(); + return [...bio].length <= MAX_BIO && bio.split("\n").length <= MAX_BIO_LINES ? bio : null; +}; + +// for the card: "id|label,id|label". +const cardField = account => of(account).map(badge => `${badge.id}|${badge.label}`).join(","); + +// adds the name tag badges' rows to the badge pack, which is keyed by def +// id and has rows of {id, mediaRefId, pendingFlagsBit}, all strings. +const addTagDefs = pack => { + for (const {tag} of TAG_BADGES) { + const row = []; + row.id = String(tag.def); + row.mediaRefId = String(tag.media); + row.pendingFlagsBit = String(tag.bit); + pack[tag.def] = row; + } + return pack; +}; + +// the bits to add to an account's login flags: one for each name tag badge +// it holds. +const loginFlags = account => of(account).reduce((flags, badge) => (badge.tag ? flags | 1 << badge.tag.bit : flags), 0); + +// may the account's name tag show the badge with this def id? any of the +// game's own, and those of ours it holds. +const mayWear = (account, defId) => { + const badge = TAG_BADGES.find(candidate => candidate.tag.def === Number(defId)); + return !badge || account.badges.includes(badge.id); +}; + +// the file behind a request for one of the name tag badges' pictures +// ("/media/"), or null when `relPath` is not one. +const mediaFiles = new Map(TAG_BADGES.map(badge => + [cdn.hashedPath(`media/${badge.tag.media}`), path.join(__dirname, "..", "swf", "badges", `${badge.id}.swf`)])); +const mediaFile = relPath => mediaFiles.get(relPath) || null; + +// the Bio tab's artwork (swf/biotab.swf, made by tools/make-bio-tab.py), +// which the card asks for as media BIO_TAB_MEDIA, or null. +const BIO_TAB_MEDIA = 20100; +const bioTabPath = cdn.hashedPath(`media/${BIO_TAB_MEDIA}`); +const cardMedia = relPath => (relPath === bioTabPath ? path.join(__dirname, "..", "swf", "biotab.swf") : null); + +module.exports = {BADGES, MAX_BIO, MAX_BIO_LINES, known, of, set, discordName, bioText, cardField, cardMedia, addTagDefs, loginFlags, mayWear, mediaFile}; diff --git a/lib/bans.js b/lib/bans.js new file mode 100644 index 0000000..3f691eb --- /dev/null +++ b/lib/bans.js @@ -0,0 +1,199 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const limits = require("./limits.js"); +const net = require("net"); + +// what bans keep beside the account's own `bannedUntil`: banned addresses, +// each account's one appeal, and a record of every ban given and lifted. +// +// an address ban is for good, and is of the address alone: the accounts +// that were used from it are not banned with it (a VPN's address is many +// people's). it keeps that address out of the game and out of signing up; +// the account page still opens there, where a player can ask about it or +// delete their account. this machine's own address cannot be banned, which +// is also the address of everyone when a proxy or a tunnel stands in front +// and the server has not been told (AJ_TRUSTED_PROXY). + +const SCHEMA = ` + CREATE TABLE IF NOT EXISTS ban_log ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + at INTEGER NOT NULL, + account_id INTEGER, + username TEXT NOT NULL DEFAULT '', + address TEXT NOT NULL DEFAULT '', + action TEXT NOT NULL, + seconds INTEGER NOT NULL DEFAULT 0, + reason TEXT NOT NULL DEFAULT '', + by TEXT NOT NULL DEFAULT '' + ); + CREATE TABLE IF NOT EXISTS address_bans ( + address_key TEXT PRIMARY KEY, + address TEXT NOT NULL, + reason TEXT NOT NULL, + by TEXT NOT NULL, + created_at INTEGER NOT NULL + ); + CREATE TABLE IF NOT EXISTS appeals ( + account_id INTEGER PRIMARY KEY, + created_at INTEGER NOT NULL, + username TEXT NOT NULL, + text TEXT NOT NULL, + address_key TEXT NOT NULL DEFAULT '', + status TEXT NOT NULL DEFAULT 'waiting', + reply TEXT NOT NULL DEFAULT '', + handled_at INTEGER + ); +`; + +const WAITING = "waiting"; +const APPROVED = "approved"; +const DENIED = "denied"; +const MAX_REASON = 300; +const MAX_APPEAL = 1000; +const MAX_REPLY = 500; +const MAX_ADDRESS_BANS = 10000; +const HISTORY_SHOWN = 50; + +const now = () => Math.floor(Date.now() / 1000); +const db = () => accounts.database(); +// A line break is kept; the other control characters are not. +const clean = (text, max) => String(text === undefined || text === null ? "" : text).replace(/[\u0000-\u0009\u000b-\u001f\u007f]/g, " ").trim().slice(0, max); + +// A ban's reason as it is kept and shown: something is always said. +const NO_REASON = "Not provided"; +const reasonText = text => clean(text, MAX_REASON) || NO_REASON; + +const banned = new Map(); // address as limits count it -> {key, address, reason, by, createdAt} + +const addressRow = row => ({key: row.address_key, address: row.address, reason: row.reason, by: row.by, createdAt: row.created_at}); + +const load = () => { + db().exec(SCHEMA); + for (const row of db().prepare("SELECT * FROM address_bans").all()) { + banned.set(row.address_key, addressRow(row)); + } +}; + +// `entry`: {account, address, action, seconds, reason, by}. actions: "ban", +// "unban", "reason", "address_ban", "address_unban", "appeal", +// "appeal_approved", "appeal_denied". A ban that runs out leaves no line. +const record = entry => { + db().prepare("INSERT INTO ban_log (at, account_id, username, address, action, seconds, reason, by) VALUES (?, ?, ?, ?, ?, ?, ?, ?)") + .run(now(), entry.account ? entry.account.id : null, entry.account ? entry.account.username : "", entry.address || "", + entry.action, entry.seconds || 0, entry.reason || "", entry.by || ""); +}; + +const logRow = row => ({at: row.at, username: row.username, address: row.address, action: row.action, seconds: row.seconds, reason: row.reason, by: row.by}); + +const historyOf = account => + db().prepare("SELECT * FROM ban_log WHERE account_id = ? ORDER BY id DESC LIMIT ?").all(account.id, HISTORY_SHOWN).map(logRow); + +const addressBan = address => banned.get(limits.key(address)) || null; + +// returns {ban} or {error: "not_an_address" | "own_address" | "already" | "too_many"}. +const banAddress = (address, reason, by) => { + const text = String(address || "").trim().replace(/^::ffff:(?=\d+\.\d+\.\d+\.\d+$)/i, ""); + if (!net.isIP(text)) { + return {error: "not_an_address"}; + } + // this machine: the owner at home, and with a proxy or a tunnel in front + // everybody else as well. + if (limits.isLoopback(text) || /^(0\.0\.0\.0|::|0:0:0:0:0:0:0:[01])$/.test(text)) { + return {error: "own_address"}; + } + const key = limits.key(text); + if (banned.has(key)) { + return {error: "already"}; + } + if (banned.size >= MAX_ADDRESS_BANS) { + return {error: "too_many"}; + } + const ban = {key, address: text, reason: reasonText(reason), by, createdAt: now()}; + db().prepare("INSERT INTO address_bans (address_key, address, reason, by, created_at) VALUES (?, ?, ?, ?, ?)").run(key, ban.address, ban.reason, by, ban.createdAt); + banned.set(key, ban); + record({address: key, action: "address_ban", seconds: -1, reason: ban.reason, by}); + return {ban}; +}; + +// `key` as a listing gave it, or any address the ban covers. +const unbanAddress = (key, by) => { + const ban = banned.get(String(key)) || addressBan(key); + if (!ban) { + return false; + } + db().prepare("DELETE FROM address_bans WHERE address_key = ?").run(ban.key); + banned.delete(ban.key); + record({address: ban.key, action: "address_unban", by}); + return true; +}; + +const addressBans = () => [...banned.values()].sort((one, other) => other.createdAt - one.createdAt); + +const appealRow = row => ({ + accountId: row.account_id, + createdAt: row.created_at, + username: row.username, + text: row.text, + addressKey: row.address_key, + status: row.status, + reply: row.reply, + handledAt: row.handled_at, +}); + +const appealOf = account => { + const row = db().prepare("SELECT * FROM appeals WHERE account_id = ?").get(account.id); + return row ? appealRow(row) : null; +}; + +// `addressKey` when it is (also) about the address they wrote from. +// returns {appeal} or {error: "empty" | "already"}. +const appeal = (account, text, addressKey = "") => { + const body = clean(text, MAX_APPEAL); + if (!body) { + return {error: "empty"}; + } + if (appealOf(account)) { + return {error: "already"}; + } + db().prepare("INSERT INTO appeals (account_id, created_at, username, text, address_key) VALUES (?, ?, ?, ?, ?)").run(account.id, now(), account.username, body, addressKey); + record({account, address: addressKey, action: "appeal"}); + console.log(`[bans] "${account.username}" appealed`); + return {appeal: appealOf(account)}; +}; + +// appeals waiting, oldest first; or with `handled`, the latest answered. +const appeals = (handled = false) => db() + .prepare(handled + ? "SELECT * FROM appeals WHERE status <> ? ORDER BY handled_at DESC LIMIT 200" + : "SELECT * FROM appeals WHERE status = ? ORDER BY created_at LIMIT 500") + .all(WAITING).map(appealRow); + +const waitingAppeal = accountId => { + const row = db().prepare("SELECT * FROM appeals WHERE account_id = ? AND status = ?").get(Number(accountId), WAITING); + return row ? appealRow(row) : null; +}; + +// the caller lifts the bans when it approves. +const answerAppeal = (accountId, approved, reply, by) => { + const answered = db().prepare("UPDATE appeals SET status = ?, reply = ?, handled_at = ? WHERE account_id = ? AND status = ?") + .run(approved ? APPROVED : DENIED, clean(reply, MAX_REPLY), now(), Number(accountId), WAITING).changes > 0; + if (answered) { + const account = accounts.byId(Number(accountId)); + record({account, action: approved ? "appeal_approved" : "appeal_denied", reason: clean(reply, MAX_REPLY), by}); + } + return answered; +}; + +const openAppeals = () => db().prepare("SELECT COUNT(*) AS count FROM appeals WHERE status = ?").get(WAITING).count; + +// an account being deleted: what it wrote goes with it. the record of what +// was done about it stays, under the name it had. +const forget = account => { + db().prepare("DELETE FROM appeals WHERE account_id = ?").run(account.id); +}; + +module.exports = { + load, record, historyOf, addressBan, banAddress, unbanAddress, addressBans, appealOf, appeal, appeals, waitingAppeal, answerAppeal, + openAppeals, forget, clean, reasonText, NO_REASON, MAX_REASON, MAX_APPEAL, MAX_REPLY, +}; diff --git a/lib/buddies.js b/lib/buddies.js new file mode 100644 index 0000000..a8fde33 --- /dev/null +++ b/lib/buddies.js @@ -0,0 +1,224 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const achievements = require("./achievements.js"); +const limits = require("./limits.js"); +const {activeAvatar} = require("./player.js"); + +// buddy lists and blocking (client side: BuddyXtCommManager, BuddyManager). +// buddies are mutual and stored on both accounts as lowercased usernames. + +const MAX_BUDDIES = 1337; +const MAX_BLOCKED = 1000; // as on the account page (lib/world.js) + +// BuddyManager.buddyAddRequestResponseHandler status codes +const REQUEST_INCOMING = 0; +const REQUEST_SENT = 1; +const REQUEST_TARGET_FULL = 2; +const REQUEST_NOT_ACCEPTING = 3; +const REQUEST_OWN_LIST_FULL = 4; +const REQUEST_UNBLOCK_FIRST = 5; + +// BuddyManager.buddyStatusResponseHandler buddyFlag values +const STATUS_UPDATE = 0; +const STATUS_ACCEPTED_YOUR_REQUEST = 1; + +const USERNAME_SHOWN = 1; // userNameModeratedFlag: > 0 shows the real name + +// requests waiting for an answer are kept on the asked account, as +// `buddyRequests`: lowercased usernames of who asked. someone not in the +// game is shown theirs when they next arrive. +const MAX_WAITING_REQUESTS = 50; + +const key = account => account.username.toLowerCase(); +// requests one account may send: enough for anyone making friends, too few +// to fill other players' waiting lists with. +const requestsPerTenMinutes = limits.limiter(20, 600000); + +// BuddyCard.buddyRoomResponseHandler shows this on the buddy's card: the +// name the room goes by on screen. it tells a den by the word "Den" in it, +// and reads a hosted party's name as three string ids. +const roomTitle = room => room.displayName; + +module.exports = ({findOnline, onBlocked, onUnblocked, partyTimeLeft}) => { + // BuddyXtCommManager.buddyStatusResponse: [1, username, uuid, moderatedFlag, + // online, accountType, buddyFlag, avatarName, perUserAvId, partyTimeLeft] + const sendStatus = (to, account, buddyFlag) => { + const avatar = activeAvatar(account); + to.sendXt("bs", -1, 1, account.username, account.uuid, USERNAME_SHOWN, findOnline(account.username) ? 1 : 0, + account.accountType, buddyFlag, avatar.name, avatar.perUserAvId, partyTimeLeft(account)); + }; + + const announce = account => { + for (const name of account.buddies) { + const buddy = findOnline(name); + if (buddy) { + sendStatus(buddy, account, STATUS_UPDATE); + } + } + }; + + const hasOnlineBuddies = account => account.buddies.some(name => Boolean(findOnline(name))); + + const handlers = { + // BuddyManager.buddyListResponseHandler: [0, onlineCount, (username, uuid, + // moderatedFlag, accountType, partyTimeLeft)..., offlineCount, (username, + // uuid, moderatedFlag, accountType)...], then blockedListResponseHandler: + // [1, count, username...] + bl(session) { + const buddies = session.account.buddies.map(accounts.byName).filter(Boolean); + const online = buddies.filter(buddy => findOnline(buddy.username)); + const offline = buddies.filter(buddy => !findOnline(buddy.username)); + session.sendXt("bl", -1, 0, + online.length, ...online.flatMap(buddy => [buddy.username, buddy.uuid, USERNAME_SHOWN, buddy.accountType, partyTimeLeft(buddy)]), + offline.length, ...offline.flatMap(buddy => [buddy.username, buddy.uuid, USERNAME_SHOWN, buddy.accountType])); + session.sendXt("bl", -1, 1, session.account.blocked.length, ...session.account.blocked); + // for the patched buddy list (gui.itemWindows.ItemWindowBuddyList): + // when each offline buddy was last seen, as [count, (username, seconds)...]. + session.sendXt("xls", -1, offline.length, ...offline.flatMap(buddy => [buddy.username, buddy.lastSeen || buddy.lastLogin || 0])); + }, + + // [username]: ask someone to be a buddy. the requester and the target each + // get a "ba" (buddyAddRequestResponse: [status, username, moderatedFlag]). + ba(session, roomId, [username]) { + const {account} = session; + const target = accounts.byName(username); + const targetSession = target && findOnline(target.username); + const reply = status => session.sendXt("ba", -1, status, target ? target.username : username, USERNAME_SHOWN); + if (!target || target === account || target.blocked.includes(key(account)) + || !accounts.featureOn(account, "buddies") || !accounts.featureOn(target, "buddies") + || (!target.buddyRequests.includes(key(account)) && target.buddyRequests.length >= MAX_WAITING_REQUESTS)) { + reply(REQUEST_NOT_ACCEPTING); + } + else if (account.blocked.includes(key(target))) { + reply(REQUEST_UNBLOCK_FIRST); + } + else if (account.buddies.length >= MAX_BUDDIES) { + reply(REQUEST_OWN_LIST_FULL); + } + else if (target.buddies.length >= MAX_BUDDIES) { + reply(REQUEST_TARGET_FULL); + } + else if (!account.buddies.includes(key(target)) && !target.buddyRequests.includes(key(account)) && !requestsPerTenMinutes.allow(account.id)) { + reply(REQUEST_NOT_ACCEPTING); + } + else if (!account.buddies.includes(key(target))) { + if (!target.buddyRequests.includes(key(account))) { + target.buddyRequests.push(key(account)); + accounts.save(); + } + if (targetSession) { + targetSession.sendXt("ba", -1, REQUEST_INCOMING, account.username, USERNAME_SHOWN); + } + reply(REQUEST_SENT); + } + }, + + // [username, "1" accept | "0" decline]: answer a pending request. + bc(session, roomId, [username, accept]) { + const {account} = session; + const requester = accounts.byName(username); + if (!requester || !account.buddyRequests.includes(key(requester))) { + return; + } + account.buddyRequests = account.buddyRequests.filter(name => name !== key(requester)); + accounts.save(); + const requesterSession = findOnline(requester.username); + if (accept !== "1" || account.buddies.includes(key(requester)) + || account.buddies.length >= MAX_BUDDIES || requester.buddies.length >= MAX_BUDDIES) { + if (requesterSession) { + requesterSession.sendXt("ba", -1, REQUEST_NOT_ACCEPTING, account.username, USERNAME_SHOWN); + } + return; + } + account.buddies.push(key(requester)); + requester.buddies.push(key(account)); + achievements.add(account, achievements.VARS.buddiesAdded); + achievements.add(requester, achievements.VARS.buddiesAdded); + accounts.save(); + sendStatus(session, requester, STATUS_UPDATE); + if (requesterSession) { + sendStatus(requesterSession, account, STATUS_ACCEPTED_YOUR_REQUEST); + } + }, + + // [username]: end a buddyship. both sides get a "bd" naming the other. + bd(session, roomId, [username]) { + const {account} = session; + const other = accounts.byName(username); + if (other) { + account.buddies = account.buddies.filter(name => name !== key(other)); + other.buddies = other.buddies.filter(name => name !== key(account)); + accounts.save(); + const otherSession = findOnline(other.username); + if (otherSession) { + otherSession.sendXt("bd", -1, account.username); + } + } + session.sendXt("bd", -1, other ? other.username : username); + }, + + // BuddyManager.buddyBlockResponseHandler: [username, success] + bb(session, roomId, [username]) { + const {account} = session; + const other = accounts.byName(username); + const added = other && other !== account && !account.blocked.includes(key(other)) && account.blocked.length < MAX_BLOCKED; + if (added) { + account.blocked.push(key(other)); + accounts.save(); + } + session.sendXt("bb", -1, username, other && other !== account && account.blocked.includes(key(other)) ? 1 : 0); + if (added) { + onBlocked(session, other); + } + }, + + bu(session, roomId, [username]) { + const {account} = session; + const other = accounts.byName(username); + const removed = other && account.blocked.includes(key(other)); + account.blocked = account.blocked.filter(name => name !== String(username).toLowerCase()); + accounts.save(); + session.sendXt("bu", -1, username, 1); + if (removed) { + onUnblocked(session, other); + } + }, + + // [username]: is that player blocking me? + bi(session, roomId, [username]) { + const other = accounts.byName(username); + session.sendXt("bi", -1, username, other && other.blocked.includes(key(session.account)) ? 1 : 0); + }, + + // [username]: where is that player? BuddyCard.buddyRoomResponseHandler + // gets [roomName, displayName, displayNameStringId, cannotGoThere]; an + // empty room means offline. the last field greys out the card's "go to" + // button (BuddyCard.checkBuddyRoomAgainstMine), so it is 0: every room + // here can be walked into. someone who blocked the asker looks offline. + br(session, roomId, [username]) { + const target = findOnline(username); + if (target && target.room && !target.account.blocked.includes(key(session.account))) { + session.sendXt("br", -1, target.room.name, roomTitle(target.room), 0, 0); + } + else { + session.sendXt("br", -1, "", "", 0, 0); + } + }, + }; + + // shows a player who has just arrived the requests made while they were + // away. they stay on the account until answered, so one the player did + // not get to is asked again next time. + const greet = session => { + const {account} = session; + const waiting = account.buddyRequests.map(accounts.byName) + .filter(requester => requester && !account.buddies.includes(key(requester)) && !account.blocked.includes(key(requester))); + account.buddyRequests = waiting.map(key); + for (const requester of waiting) { + session.sendXt("ba", -1, REQUEST_INCOMING, requester.username, USERNAME_SHOWN); + } + }; + + return {handlers, announce, hasOnlineBuddies, greet}; +}; diff --git a/lib/buddygames.js b/lib/buddygames.js new file mode 100644 index 0000000..df3001b --- /dev/null +++ b/lib/buddygames.js @@ -0,0 +1,369 @@ +"use strict"; + +// the eight games two buddies play against each other from a player's card +// (client side: game.pVP_*). each has a protocol of its own, which the +// official server spoke and nothing else records; what is here was read off +// each game's `message` method and the code inside its scene file (the +// "theGame" layer of roomDefs/pvp_*/room_main). +// +// half of them the server referees, since the clients only draw what they +// are told: Tic Tac Toe, Four Gems, Rock Paper Scissors, the Shell Game and +// Pairs. the other half run on both clients at once, each simulating the +// same thing from the same inputs, and the server only passes the inputs +// across and says when both are ready to go on: Bowling, Marbles, Scooped. +// +// A game here is given `match`: {ids: [sfsUserId, sfsUserId] in the order +// of the start message, send(player, ...fields), broadcast(...fields), +// over()} and keeps what it likes on `match.state`. `player` is 0 or 1. +// every handler is entered with words that came from a client, so each +// checks what it is given; a message that makes no sense is dropped. + +const other = player => 1 - player; +const coin = () => (Math.random() < 0.5 ? 0 : 1); +const whole = (text, min, max) => { + const value = /^-?\d{1,9}$/.test(String(text)) ? Number(text) : NaN; + return Number.isInteger(value) && value >= min && value <= max ? value : null; +}; +const number = text => { + const value = /^-?\d{1,7}(\.\d{1,20})?(e-?\d{1,3})?$/i.test(String(text)) ? Number(text) : NaN; + return Number.isFinite(value) ? value : null; +}; +const ROUNDS_TO_WIN = 2; // Rock Paper Scissors and the Shell Game: first to win two rounds + +// is there a run of `length` of `player`'s marks through (x, y)? `at(x, y)` +// gives who holds a cell, undefined off the board. +const DIRECTIONS = [[1, 0], [0, 1], [1, 1], [1, -1]]; +const hasLine = (at, x, y, player, length) => DIRECTIONS.some(([dx, dy]) => { + let run = 1; + for (const sign of [1, -1]) { + for (let step = 1; at(x + sign * step * dx, y + sign * step * dy) === player; step++) { + run++; + } + } + return run >= length; +}); + +// tic Tac Toe and Four Gems share their messages: "round" [whose turn, the +// two players] opens, a "mark" is answered to both with [who, where..., won, +// tied, whose turn next], and "invalid" [whose turn] hands the turn on +// after a move that cannot be made or a turn that ran out of time. the +// first player of the start message plays X. +const boardGame = ({width, height, connect, cellOf}) => ({ + ready(match) { + match.state = {cells: new Map(), turn: coin()}; + match.broadcast("round", match.state.turn, ...match.ids); + }, + messages: { + mark(match, player, params) { + const {state} = match; + const at = (x, y) => state.cells.get(`${x},${y}`); + const cell = state && player === state.turn ? cellOf(params, at) : null; + if (!state) { + return; + } + if (!cell || cell.x < 0 || cell.x >= width || cell.y < 0 || cell.y >= height || at(cell.x, cell.y) !== undefined) { + match.send(player, "invalid", state.turn); + return; + } + state.cells.set(`${cell.x},${cell.y}`, player); + const won = hasLine(at, cell.x, cell.y, player, connect); + const tied = !won && state.cells.size === width * height; + state.turn = won || tied ? state.turn : other(player); + match.broadcast("mark", player, ...cell.sent, won ? 1 : 0, tied ? 1 : 0, state.turn); + if (won || tied) { + match.over(); + } + }, + time(match, player) { + const {state} = match; + if (state && player === state.turn) { + state.turn = other(player); + match.broadcast("invalid", state.turn); + } + }, + }, +}); + +const ticTacToe = boardGame({ + width: 3, height: 3, connect: 3, + // [x, y], each 0 to 2 (the scene's cells are p_) + cellOf([x, y]) { + const cell = {x: whole(x, 0, 2), y: whole(y, 0, 2)}; + return cell.x === null || cell.y === null ? null : {...cell, sent: [cell.x, cell.y]}; + }, +}); + +const fourGems = boardGame({ + width: 7, height: 6, connect: 4, + // [column], 0 to 6; the gem drops to the lowest free row + cellOf([column], at) { + const x = whole(column, 0, 6); + if (x === null) { + return null; + } + let y = 0; + while (y < 6 && at(x, y) !== undefined) { + y++; + } + return {x, y, sent: [x]}; + }, +}); + +// Rock Paper Scissors and the Shell Game: no turns. "round" starts the +// clock on both clients; when it runs out each says "time" with what its +// player picked, and both are told "mark" [first player's pick, second +// player's pick, then "1", winner when the game is over, or "0", "1", +// winner when only the round is won, or "0", "0" for a round nobody won]. +// both clients ask for the next round by saying "ready" again. +const pickGame = ({startRound, read, roundWinner}) => ({ + ready(match) { + match.state = match.state || {wins: [0, 0]}; + match.state.picks = [undefined, undefined]; + match.state.round = startRound(); + match.broadcast("round", ...match.ids, ...match.state.round.sent); + }, + messages: { + time(match, player, params) { + const {state} = match; + if (!state || state.picks[player] !== undefined) { + return; + } + state.picks[player] = read(params[0]); + if (state.picks[other(player)] === undefined) { + return; + } + const winner = roundWinner(state.picks, state.round); + if (winner === null) { + match.broadcast("mark", ...state.picks, 0, 0); + return; + } + state.wins[winner]++; + if (state.wins[winner] >= ROUNDS_TO_WIN) { + match.broadcast("mark", ...state.picks, 1, winner); + match.over(); + } + else { + match.broadcast("mark", ...state.picks, 0, 1, winner); + } + }, + }, +}); + +const HANDS = ["rock", "paper", "scissors"]; // each beats the one before it +const NO_HAND = "off"; // nothing picked in time +const rockPaperScissors = pickGame({ + startRound: () => ({sent: []}), + read: hand => (HANDS.includes(hand) ? hand : NO_HAND), + roundWinner([first, second]) { + if (first === second) { + return null; + } + if (first === NO_HAND || second === NO_HAND) { + return first === NO_HAND ? 1 : 0; + } + return (HANDS.indexOf(first) - HANDS.indexOf(second) + 3) % 3 === 1 ? 0 : 1; + }, +}); + +// the round opens with which of the three shells hides the gem; a pick is +// 1 to 3, 0 for none. whoever is right when the other is wrong wins the round. +const SHELLS = 3; +const shellGame = pickGame({ + startRound() { + const shell = 1 + Math.floor(Math.random() * SHELLS); + return {shell, sent: [shell]}; + }, + read: pick => whole(pick, 1, SHELLS) || 0, + roundWinner([first, second], {shell}) { + return (first === shell) === (second === shell) ? null : first === shell ? 0 : 1; + }, +}); + +// pairs: sixteen cards, four to a row, numbered 0 to 15 along the rows. A +// card's picture is its number in the list of 1 to 16, two of which make a +// pair when they differ by 8 (the scene folds 9-16 onto 1-8). "round" names +// the player who starts first, then the other, then the cards. the player +// whose turn it is turns up two ("c1", "c2", which the other is shown), both +// are told "results" [0, matched] and say "rp" when they have watched it, +// and "nextround" lets the game go on: the same player again after a match, +// the other after a miss or a "time". the last pair brings "results" [1, +// winner's id, 0 for a draw]. +const CARDS = 16; +const pairs = { + ready(match) { + const cards = Array.from({length: CARDS}, (_, index) => index + 1); + for (let index = cards.length - 1; index > 0; index--) { + const swap = Math.floor(Math.random() * (index + 1)); + [cards[index], cards[swap]] = [cards[swap], cards[index]]; + } + match.state = {cards, gone: new Set(), turn: coin(), first: null, found: [0, 0], watched: new Set(), showing: false}; + match.broadcast("round", match.ids[match.state.turn], match.ids[other(match.state.turn)], CARDS, ...cards); + }, + messages: { + c1(match, player, [card]) { + const {state} = match; + const index = whole(card, 0, CARDS - 1); + if (state && !state.showing && player === state.turn && state.first === null && index !== null && !state.gone.has(index)) { + state.first = index; + match.send(other(player), "c1", index); + } + }, + c2(match, player, [card]) { + const {state} = match; + const index = whole(card, 0, CARDS - 1); + if (!state || state.showing || player !== state.turn || state.first === null || index === null || index === state.first || state.gone.has(index)) { + return; + } + match.send(other(player), "c2", index); + const matched = (state.cards[index] - state.cards[state.first]) % (CARDS / 2) === 0; + if (matched) { + state.gone.add(index).add(state.first); + state.found[player]++; + } + else { + state.turn = other(player); + } + state.first = null; + if (state.gone.size === CARDS) { + const [mine, theirs] = [state.found[player], state.found[other(player)]]; + match.broadcast("results", 1, mine === theirs ? 0 : match.ids[mine > theirs ? player : other(player)]); + match.over(); + return; + } + state.showing = true; + state.watched.clear(); + match.broadcast("results", 0, matched ? 1 : 0); + }, + time(match, player) { + const {state} = match; + if (state && !state.showing && player === state.turn) { + state.turn = other(player); + state.first = null; + state.showing = true; + state.watched.clear(); + match.broadcast("time"); + } + }, + rp(match, player) { + const {state} = match; + if (state && state.showing && state.watched.add(player).size === 2) { + state.showing = false; + match.broadcast("nextround"); + } + }, + emote: relayEmote, + }, +}; + +// the little faces Pairs and Bowling let players pull at each other. +function relayEmote(match, player, [emote]) { + const face = whole(emote, 0, 1000); + if (face !== null) { + match.send(other(player), "emote", face); + } +} + +// Scooped: a race to build the same ice creams, the order of which both +// clients work out from the start message. each scoop is shown to the +// other player ("sc_click" and the name of the button pressed); whoever +// says "sc_done" first has won, and both are told who. +const scooped = { + ready(match) { + match.state = {done: false}; + match.broadcast("start"); + }, + messages: { + sc_click(match, player, [button]) { + if (match.state && !match.state.done && /^[A-Za-z]\w{0,30}$/.test(String(button))) { + match.send(other(player), "sc_click", button); + } + }, + sc_done(match, player) { + if (match.state && !match.state.done) { + match.state.done = true; + match.broadcast("sc_done", player); + match.over(); + } + }, + }, +}; + +// Bowling: both clients roll every ball through the same simulation, the +// thrower's own and the other from the "ball" [angle, x, y] passed across. +// "round" names who bowls first. after each ball both say "rp" and are let +// on with "nextround"; a thrower who ran out of time says "time", which +// both are told. they keep the score and end the game themselves. +const bowling = { + ready(match) { + const first = coin(); + match.state = {watched: new Set()}; + match.broadcast("round", match.ids[first], match.ids[other(first)]); + }, + messages: { + ball(match, player, params) { + const shot = params.slice(0, 3).map(number); + if (match.state && shot.length === 3 && !shot.includes(null)) { + match.send(other(player), "ball", ...shot); + } + }, + time(match) { + if (match.state) { + match.broadcast("time"); + } + }, + rp(match, player) { + if (match.state && match.state.watched.add(player).size === 2) { + match.state.watched.clear(); + match.broadcast("nextround"); + } + }, + emote: relayEmote, + }, +}; + +// marbles: the same arrangement. the start message picks one of the +// fourteen ways the marbles are laid out; "start" says who shoots first +// (as a place in the start message's list of players); the shooter's aim +// ("pos") and shot ("shoot" [from x, from y, force x, force y]) are passed +// to the other; and when both have said "endTurn", their marbles at rest, +// both are told so and change turns. +const MARBLE_PATTERNS = 14; +const marbles = { + startData: () => [1 + Math.floor(Math.random() * MARBLE_PATTERNS)], + ready(match) { + match.state = {rested: new Set()}; + match.broadcast("start", coin()); + }, + messages: { + pos(match, player, params) { + const spot = params.slice(0, 2).map(value => whole(value, -10000, 10000)); + if (match.state && spot.length === 2 && !spot.includes(null)) { + match.send(other(player), "pos", ...spot); + } + }, + shoot(match, player, params) { + const shot = params.slice(0, 4).map(number); + if (match.state && shot.length === 4 && !shot.includes(null)) { + match.send(other(player), "shoot", ...shot); + } + }, + endTurn(match, player) { + if (match.state && match.state.rested.add(player).size === 2) { + match.state.rested.clear(); + match.broadcast("endTurn"); + } + }, + }, +}; + +// by the game's key in game.IncludeMinigames (`swf` in lib/games.json). +module.exports = { + PVP_TicTacToe: ticTacToe, + PVP_ConnectFour: fourGems, + PVP_RockPaperScissor: rockPaperScissors, + PVP_ShellGame: shellGame, + PVP_Memory: pairs, + PVP_Scooped: scooped, + PVP_Bowling: bowling, + PVP_Marbles: marbles, +}; diff --git a/lib/captcha.js b/lib/captcha.js new file mode 100644 index 0000000..164a0bd --- /dev/null +++ b/lib/captcha.js @@ -0,0 +1,120 @@ +"use strict"; + +const crypto = require("crypto"); +const fs = require("fs"); +const path = require("path"); +const config = require("../config.js"); +const limits = require("./limits.js"); + +// cloudflare turnstile, with AJ_TURNSTILE_SITE_KEY and AJ_TURNSTILE_SECRET +// set: a captcha before every password tried (the client's login, the +// account page, the moderator panel) and every account made (the sign-up +// page, the client). a saved sign-in is not asked. the page shows the +// widget (public/captcha.js) and sends its answer as `captcha`; the answer +// is checked here with cloudflare, and is good for one request. +// +// a sign-in that passed the captcha and then wants a 2FA code, and a +// sign-up the client signs in with straight after, get a pass: good for +// that account from that address for a few minutes, so the second request +// is not asked again. + +const ORIGIN = "https://challenges.cloudflare.com"; +const VERIFY_URL = `${ORIGIN}/turnstile/v0/siteverify`; +const VERIFY_TIMEOUT_MS = 10000; +const MAX_ANSWER_LENGTH = 2048; +const PASS_MS = 600000; +const PASS_USES = 5; +const MAX_PASSES = 10000; + +const on = Boolean(config.turnstile); +const passes = new Map(); // SHA-256 of a pass -> {id: account id, key: address key, expiry, uses} +const sha256 = text => crypto.createHash("sha256").update(String(text)).digest("hex"); + +// for the pages: what each answer means +const MESSAGES = { + captcha_required: "Complete the captcha.", + captcha_failed: "Captcha failed. Try again.", + captcha_unavailable: "Captcha unavailable. Try again later.", +}; + +const issuePass = (account, from) => { + if (!on || !account) { + return undefined; + } + for (const [hash, entry] of passes) { + if (entry.expiry < Date.now() || passes.size >= MAX_PASSES) { + passes.delete(hash); + } + } + const pass = crypto.randomBytes(24).toString("hex"); + passes.set(sha256(pass), {id: account.id, key: from.key, expiry: Date.now() + PASS_MS, uses: 0}); + return pass; +}; + +const passHolds = (pass, account, from) => { + if (typeof pass !== "string" || !account) { + return false; + } + const hash = sha256(pass); + const entry = passes.get(hash); + if (!entry || entry.expiry < Date.now() || entry.id !== account.id || entry.key !== from.key || ++entry.uses > PASS_USES) { + passes.delete(hash); + return false; + } + return true; +}; + +// asks cloudflare about one answer of the widget. null when it was a person. +const verify = async (answer, from, action) => { + if (typeof answer !== "string" || !answer || answer.length > MAX_ANSWER_LENGTH) { + return "captcha_required"; + } + const form = new URLSearchParams({secret: config.turnstile.secret, response: answer}); + if (!limits.isLoopback(from.address)) { + form.set("remoteip", from.address); + } + let result; + try { + const response = await fetch(VERIFY_URL, {method: "POST", body: form, signal: AbortSignal.timeout(VERIFY_TIMEOUT_MS)}); + result = await response.json(); + } + catch (err) { + console.log(`[captcha] cloudflare did not answer: ${err.message}`); + return "captcha_unavailable"; + } + // an answer made for another form is no answer for this one. cloudflare's + // test keys give none. + if (!result || result.success !== true || (result.action && result.action !== action)) { + return "captcha_failed"; + } + return null; +}; + +// null when the request may go on, or why not (a key of MESSAGES). +// `account`, when known, is who a pass would have to be for. requests from +// the server's own machine are not asked, as with the other limits. +const check = async (body, from, action, account) => { + if (!on || from.local) { + return null; + } + if (passHolds(body.captcha_pass, account, from)) { + return null; + } + return verify(body.captcha, from, action); +}; + +// a page's security policy, letting the widget in when it is on. +const policy = csp => (on ? `${csp.replace("script-src ", `script-src 'self' ${ORIGIN} `)}; frame-src ${ORIGIN}` : csp); + +// a page with public/captcha.js asked for under a name that changes with the +// script and the key: cloudflare keeps .js files for hours, whatever the +// server says, and a browser would go on with an old one. +const withScriptVersion = html => { + const version = sha256(fs.readFileSync(path.join(config.publicDir, "captcha.js")) + (on ? config.turnstile.siteKey : "")).slice(0, 12); + return Buffer.from(String(html).replace("src=\"/captcha.js\"", `src="/captcha.js?v=${version}"`)); +}; + +// public/captcha.js with the site key in it ("" when off). +const script = text => text.replace("\"{{siteKey}}\"", JSON.stringify(on ? config.turnstile.siteKey : "")); + +module.exports = {on, check, issuePass, policy, script, withScriptVersion, MESSAGES}; diff --git a/lib/cdn.js b/lib/cdn.js new file mode 100644 index 0000000..a66c6a6 --- /dev/null +++ b/lib/cdn.js @@ -0,0 +1,174 @@ +"use strict"; + +const crypto = require("crypto"); +const fs = require("fs"); +const path = require("path"); +const config = require("../config.js"); + +// mirrors LoaderCache.hashItV2 in the client: the last path component of every +// versioned asset is obfuscated this way before it is requested. +const hashName = name => { + const salted = "W3 7r4Ck h4X0r3rs" + name; + let out = ""; + for (let i = 0; i < salted.length; i++) { + out = i % 2 === 0 ? out + salted[i] : salted[i] + out; + } + return crypto.createHash("md5").update(out).digest("hex"); +}; + +// "defPacks/1003" -> "1830/defPacks/" +const hashedPath = assetPath => { + const parts = assetPath.split("/"); + parts.push(hashName(parts.pop())); + return `${config.deployVersion}/${parts.join("/")}`; +}; + +const missing = new Set(); +const inFlight = new Map(); + +// asset paths are short and plain; anything else is not worth asking the +// upstream CDN about on a stranger's behalf. +const ASSET_PATH = /^[A-Za-z0-9_.\-\/]{1,200}$/; +const MAX_MISSING = 20000; +const MAX_DOWNLOADS = 64; // at once + +// the builds this server has any use for: the one the game runs on, the +// older ones room files are taken from, and the themes' (config.js). the +// official CDN holds a good deal more under other names (every other build, +// and two folders of players' own data); none of that is fetched, kept or +// handed on for anyone. +const BUILDS = new Set([config.deployVersion, ...config.olderBuilds, ...Object.values(config.themes).map(theme => theme.build)].map(String)); + +// the path as it is kept and asked for: "a/./b" and "a//b" are "a/b", and +// nothing climbs out of its build. null for a path that is not an asset's. +const clean = relPath => { + if (typeof relPath !== "string" || !ASSET_PATH.test(relPath)) { + return null; + } + const parts = relPath.split("/").filter(part => part !== "" && part !== "."); + return parts.length >= 2 && !parts.includes("..") && BUILDS.has(parts[0]) ? parts.join("/") : null; +}; + +const cacheFile = relPath => { + const file = path.join(config.cacheDir, relPath); + return file.startsWith(config.cacheDir + path.sep) ? file : null; +}; + +// how much the cache holds: counted once at start (in the background), then +// kept up as files are added. +let cacheBytes = 0; +const measure = async folder => { + for (const entry of await fs.promises.readdir(folder, {withFileTypes: true}).catch(() => [])) { + if (entry.isDirectory()) { + await measure(path.join(folder, entry.name)); + } + else { + cacheBytes += (await fs.promises.stat(path.join(folder, entry.name)).catch(() => ({size: 0}))).size; + } + } +}; +measure(config.cacheDir).then(() => { + if (cacheBytes > config.maxCacheBytes) { + console.log(`[cdn] the cache holds ${Math.round(cacheBytes / 1048576)} MB, over its limit: new files are served but not kept (AJ_MAX_CACHE_MB)`); + } +}); + +const download = async (relPath, file) => { + const url = new URL(relPath, config.upstreamContent); + url.searchParams.set("v", config.upstreamBuildVersion); + const res = await fetch(url, {headers: {"User-Agent": "Mozilla/5.0"}, signal: AbortSignal.timeout(config.upstreamTimeoutMs)}); + if (!res.ok) { + if (res.status === 404 || res.status === 403) { + if (missing.size >= MAX_MISSING) { + missing.clear(); + } + missing.add(relPath); + } + console.log(`[cdn] ${res.status} ${relPath}`); + return null; + } + const body = Buffer.from(await res.arrayBuffer()); + // A cache that cannot be written to (wrong owner, full disk) costs a + // download each time; it must not cost the player the file. + try { + if (cacheBytes + body.length > config.maxCacheBytes) { + return body; + } + cacheBytes += body.length; + await fs.promises.mkdir(path.dirname(file), {recursive: true}); + const tmp = `${file}.${process.pid}.tmp`; + await fs.promises.writeFile(tmp, body); + await fs.promises.rename(tmp, file); + console.log(`[cdn] cached ${relPath} (${body.length} bytes)`); + } + catch (err) { + console.log(`[cdn] could not cache ${relPath}: ${err.message}`); + } + return body; +}; + +// `mayFetch`: may a file that is not in the cache be asked of the official +// CDN for this request? (Whoever asks for too many is given only what is +// there already: lib/http.js.) +const getExact = async (asked, mayFetch = () => true) => { + const relPath = clean(asked); + const file = relPath && cacheFile(relPath); + if (!file) { + return null; + } + try { + return await fs.promises.readFile(file); + } + catch (err) { + if (err.code !== "ENOENT" && err.code !== "EISDIR" && err.code !== "ENOTDIR") { + throw err; + } + } + if (config.offline || missing.has(relPath)) { + return null; + } + if (!inFlight.has(relPath) && (inFlight.size >= MAX_DOWNLOADS || !mayFetch())) { + return null; + } + if (!inFlight.has(relPath)) { + // A download that fails (the CDN not answering in time) is "not there" + // for now, and is tried again the next time the file is asked for. + inFlight.set(relPath, download(relPath, file).catch(err => { + console.log(`[cdn] could not fetch ${relPath}: ${err.message}`); + return null; + }).finally(() => inFlight.delete(relPath))); + } + return inFlight.get(relPath); +}; + +// returns the asset's bytes, or null when it does not exist. A room file the +// current build no longer has is looked for in the older builds named in +// config.olderBuilds (the client asks for everything under the current one). +const CURRENT_ROOM_FILE = new RegExp(`^${config.deployVersion}/(roomDefs/.+)$`); +const get = async (relPath, mayFetch) => { + const body = await getExact(relPath, mayFetch); + const room = body ? null : CURRENT_ROOM_FILE.exec(clean(relPath) || ""); + if (room) { + for (const build of config.olderBuilds) { + const older = await getExact(`${build}/${room[1]}`, mayFetch); + if (older) { + return older; + } + } + } + return body; +}; + +// the asset's bytes if it is already in the cache, else null; never downloads. +const cached = async asked => { + const relPath = clean(asked); + const file = relPath && cacheFile(relPath); + try { + return file ? await fs.promises.readFile(file) : null; + } + catch (err) { + return null; + } +}; + +module.exports = {get, cached, hashName, hashedPath}; diff --git a/lib/chatlog.js b/lib/chatlog.js new file mode 100644 index 0000000..490fc97 --- /dev/null +++ b/lib/chatlog.js @@ -0,0 +1,107 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const config = require("../config.js"); + +// what players typed: chat in a room, and whispers. kept for the moderator +// panel (lib/modpanel.js), which is where a moderator reads what was said +// before deciding anything; nothing else reads it. lines older than +// config.chatLogDays are deleted, and an account's lines go when the +// account is deleted. with chatLogDays 0 nothing is kept at all. + +const SCHEMA = ` + CREATE TABLE IF NOT EXISTS chat_log ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + at INTEGER NOT NULL, + account_id INTEGER NOT NULL, + username TEXT NOT NULL, + room TEXT NOT NULL, + kind TEXT NOT NULL, + to_name TEXT NOT NULL DEFAULT '', + text TEXT NOT NULL + ); + CREATE INDEX IF NOT EXISTS chat_log_account ON chat_log (account_id, id); + CREATE INDEX IF NOT EXISTS chat_log_room ON chat_log (room, id); +`; + +const CHAT = "chat"; +const WHISPER = "whisper"; +const DAY_SECONDS = 86400; +const MAX_TEXT = 600; +const PAGE = 100; +const AROUND = 25; // lines before and after the one asked about + +const now = () => Math.floor(Date.now() / 1000); +const db = () => accounts.database(); + +const prune = () => { + db().prepare("DELETE FROM chat_log WHERE at < ?").run(now() - config.chatLogDays * DAY_SECONDS); +}; + +const load = () => { + db().exec(SCHEMA); + prune(); + setInterval(prune, DAY_SECONDS * 1000 / 4).unref(); +}; + +// A line said in `room` (its name as the world knows it), or with `to` a +// whisper to that player. +const record = (account, room, text, to = "") => { + if (config.chatLogDays <= 0) { + return; + } + db().prepare("INSERT INTO chat_log (at, account_id, username, room, kind, to_name, text) VALUES (?, ?, ?, ?, ?, ?, ?)") + .run(now(), account.id, account.username, String(room || ""), to ? WHISPER : CHAT, to, String(text).slice(0, MAX_TEXT)); +}; + +const row = line => ({id: line.id, at: line.at, username: line.username, room: line.room, whisperTo: line.kind === WHISPER ? line.to_name : "", text: line.text}); + +// lines newest first, a page at a time: by who said them (or was whispered +// to), by room, by words in them, and `before` an id for the next page. +const search = ({username = "", room = "", text = "", before = 0}) => { + const where = []; + const values = []; + if (username) { + where.push("(username = ? COLLATE NOCASE OR to_name = ? COLLATE NOCASE)"); + values.push(username, username); + } + if (room) { + where.push("room LIKE ? ESCAPE '\\'"); + values.push(`%${room.replace(/[\\%_]/g, "\\$&")}%`); + } + if (text) { + where.push("text LIKE ? ESCAPE '\\'"); + values.push(`%${text.replace(/[\\%_]/g, "\\$&")}%`); + } + if (before > 0) { + where.push("id < ?"); + values.push(before); + } + return db().prepare(`SELECT * FROM chat_log ${where.length ? `WHERE ${where.join(" AND ")}` : ""} ORDER BY id DESC LIMIT ?`).all(...values, PAGE).map(row); +}; + +// what was said around one line, oldest first: in its room, or for a +// whisper between its two players. +const around = id => { + const line = db().prepare("SELECT * FROM chat_log WHERE id = ?").get(Number(id)); + if (!line) { + return null; + } + const [same, values] = line.kind === WHISPER + ? ["kind = ? AND ((username = ? AND to_name = ?) OR (username = ? AND to_name = ?))", [WHISPER, line.username, line.to_name, line.to_name, line.username]] + : ["kind = ? AND room = ?", [CHAT, line.room]]; + const earlier = db().prepare(`SELECT * FROM chat_log WHERE ${same} AND id < ? ORDER BY id DESC LIMIT ?`).all(...values, line.id, AROUND).reverse(); + const later = db().prepare(`SELECT * FROM chat_log WHERE ${same} AND id > ? ORDER BY id LIMIT ?`).all(...values, line.id, AROUND); + return {line: row(line), lines: [...earlier, line, ...later].map(row)}; +}; + +// everything an account said that is still kept, oldest first, for the copy +// of their data a player may ask for (lib/manage.js). +const saidBy = account => db().prepare("SELECT * FROM chat_log WHERE account_id = ? ORDER BY id").all(account.id).map(row); + +// an account being deleted: what it said goes with it. +const forget = account => { + db().prepare("DELETE FROM chat_log WHERE account_id = ?").run(account.id); +}; + +module.exports = {load, record, search, around, saidBy, forget, PAGE}; diff --git a/lib/colours.js b/lib/colours.js new file mode 100644 index 0000000..9498f11 --- /dev/null +++ b/lib/colours.js @@ -0,0 +1,73 @@ +"use strict"; + +const accounts = require("./accounts.js"); + +// custom colours. the game stores a colour as four palette indexes packed in +// one number, which leaves no room for "any hex colour". so a number in a +// range no real colour uses (CUSTOM_BASE and up) is instead the id of an +// entry here: the four RGB values that layer is drawn with. the patched +// client keeps the same table (PaletteHelper.customColors); the server sends +// it at login and announces every new entry to everyone before anybody can +// receive a colour that uses it. + +const CUSTOM_BASE = 0xFD000000; // top byte 0xFD: unused by every item and animal def +const config = require("../config.js"); +const MAX_ID = 0xFDFFFFFF; // the last id with the top byte 0xFD +const MAX_RGB = 0xFFFFFF; + +const SCHEMA = "CREATE TABLE IF NOT EXISTS custom_colours (id INTEGER PRIMARY KEY, rgb TEXT NOT NULL UNIQUE)"; + +const byKey = new Map(); // "r1,r2,r3,r4" -> id +const entries = new Map(); // id -> [r1, r2, r3, r4] +let nextId = CUSTOM_BASE; // one past the highest id ever given: ids are never used twice + +const load = () => { + const db = accounts.database(); + db.exec(SCHEMA); + for (const row of db.prepare("SELECT id, rgb FROM custom_colours").all()) { + byKey.set(row.rgb, row.id); + entries.set(row.id, row.rgb.split(",").map(Number)); + nextId = Math.max(nextId, row.id + 1); + } + console.log(`[colours] ${entries.size} custom colours`); +}; + +const valid = rgbs => rgbs.length === 4 && rgbs.every(value => Number.isInteger(value) && value >= 0 && value <= MAX_RGB); + +// the id for these four RGB values, making the entry if it is new and +// `mayCreate` is not false. returns {id, rgbs, created}; null when the +// values are bad, and {full: true} when a new entry would be needed and may +// not be made (the table is full, or the asker has made enough today). +const allocate = (rgbs, mayCreate = true) => { + if (!valid(rgbs)) { + return null; + } + const key = rgbs.join(","); + if (byKey.has(key)) { + return {id: byKey.get(key), rgbs, created: false}; + } + if (!mayCreate || entries.size >= config.maxCustomColours || nextId > MAX_ID) { + return {full: true}; + } + const id = nextId++; + accounts.database().prepare("INSERT INTO custom_colours (id, rgb) VALUES (?, ?)").run(id, key); + byKey.set(key, id); + entries.set(id, rgbs); + return {id, rgbs, created: true}; +}; + +// [id, r1, r2, r3, r4] for every entry, in groups small enough for one message. +const chunks = (size = 200) => { + const all = [...entries].map(([id, rgbs]) => [id, ...rgbs]); + const out = []; + for (let i = 0; i < all.length; i += size) { + out.push(all.slice(i, i + size)); + } + return out; +}; + +// is this number a colour the game can draw: one of its own (anything below +// the custom range), or an entry of the table? +const known = id => id < CUSTOM_BASE || id > MAX_ID || entries.has(id); + +module.exports = {load, allocate, chunks, known, count: () => entries.size}; diff --git a/lib/commands.js b/lib/commands.js new file mode 100644 index 0000000..b9c5245 --- /dev/null +++ b/lib/commands.js @@ -0,0 +1,527 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const chatlog = require("./chatlog.js"); +const defpacks = require("./defpacks.js"); +const disguises = require("./disguises.js"); +const dens = require("./dens.js"); +const {isSilenced} = require("./moderation.js"); +const {MAX_DEN_ITEMS, MAX_WORN, activeAvatar, wornItems} = require("./player.js"); + +// things players can do by typing "!something" in the chat box, for what +// the game has no window for. none of them touches another player: they +// look things up, or change the typist's own outfit, den or settings. +// what a command has to say comes up in a plain message box of the game's +// ("xtl", shown by the patched client), not as a note from Animal Jam HQ. +// +// the chat box only lets through letters, digits, spaces and !'.,():?- +// so that is all a command or a name given to one can be made of. + +const PREFIX = "!"; +const MAX_OUTFITS = 30; +const MAX_LAYOUTS = 20; +const MAX_NAME = 20; +const MAX_LISTED = 40; +const NAME_PATTERN = /^[a-z0-9]{1,20}$/; + +// what each command does is listed for players at /commands +// (public/commands.html): too much to read in a popup in the game. + +// short names for "!go". any room of the room list also goes by its own +// name, with dots ("sarepia.flag_shop"). +const PLACES = { + township: "jamaa_township.room_main", jamaa: "jamaa_township.room_main", + sarepia: "sarepia.room_main", crystal: "crystal_sands.room_main", sands: "crystal_sands.room_main", + coral: "coral_canyons.room_main", canyons: "coral_canyons.room_main", shiveer: "mountains_of_shivveer.room_main", + appondale: "appondale.room_main", zios: "lost_temple_of_zios.room_main", temple: "lost_temple_of_zios.room_main", + kimbara: "aussie.room_main", outback: "aussie.room_main", balloosh: "balloosh.room_main", + bahari: "oceans.bahari_bay", reef: "oceans.crystal_reef", deep: "oceans.deep_sea", kani: "pirate_ship.room_main", + arcade: "jamaa_township.room_arcade", diamonds: "jamaa_township.room_diamonds", alphas: "jamaa_township.room_alphahq", + museum: "appondale.room_museum", chamber: "lost_temple_of_zios.chamber_of_knowledge", aquarium: "crystal_sands.room_tierney", + path: "canyon_path.room_main", carnival: "party.venue_carnival", +}; +const PLAIN_NAME = /^[A-Za-z0-9][A-Za-z0-9 '.-]{0,19}$/; // a typed animal or pet name +const MAX_WHISPER = 200; +const MAX_AGAIN = 100; + +// A hosted party's own name is three string ids, no use outside the game. +const roomTitle = room => (room.partyHost ? `${room.partyHost.username}'s party` : room.displayName); + +module.exports = ({findOnline, players, watchers, sendItemList, blocks, setHideBlocked, refreshForOthers, travel, reloadRoom, buyAgain, ask}) => { + // A plain message box with an OK button. + const tell = (session, text) => session.sendXt("xtl", -1, String(text).replace(/%/g, " percent")); + + const named = (list, name) => list.find(entry => entry.name === name); + + const validName = (session, name) => { + if (!NAME_PATTERN.test(name || "")) { + tell(session, `Give it a name of letters and digits, up to ${MAX_NAME} long.`); + return false; + } + return true; + }; + + // has the animal in use wear exactly the clothes with these inventory + // ids, and remembers what it wore before for "!outfit undo". returns the + // items now worn. + const dress = (session, invs) => { + const {account} = session; + const avatar = activeAvatar(account); + const before = wornItems(account, avatar); + const wanted = account.items.filter(item => invs.includes(item.inv)).slice(0, MAX_WORN); + const takenOff = before.filter(item => !wanted.includes(item)); + account.outfitUndo = {avInvId: avatar.avInvId, items: before.map(item => item.inv)}; + for (const item of takenOff) { + item.on = item.on.filter(avInvId => avInvId !== avatar.avInvId); + } + for (const item of wanted) { + if (!item.on.includes(avatar.avInvId)) { + item.on.push(avatar.avInvId); + } + } + accounts.save(); + // ItemXtCommManager.itemsChangedListResponse, "3" = what is worn + // changed: [3, inUse, perUserAvId, username, colour, onCount, + // offCount, (invIdx, defId)..., offInvIdx...] + session.sendXt("il", -1, 3, 1, avatar.perUserAvId, account.username, 0, wanted.length, takenOff.length, + ...wanted.flatMap(item => [item.inv, item.def]), ...takenOff.map(item => item.inv)); + for (const other of watchers(session)) { + sendItemList(other, session, false); + } + return wanted; + }; + + const outfit = (session, [action, name]) => { + const {account} = session; + const avatar = activeAvatar(account); + switch (action) { + case "off": + dress(session, []); + tell(session, "Everything is off. !outfit undo puts it back on."); + return; + // what this animal wore before the last change made here or in the + // animal editor (lib/items.js keeps it). + case "undo": { + const undo = account.outfitUndo; + if (!undo || undo.avInvId !== avatar.avInvId) { + tell(session, "There is nothing to put back for this animal."); + return; + } + dress(session, undo.items); + tell(session, "Back to what you wore before. !outfit undo again swaps back."); + return; + } + // the next free "outfit N" (the settings menu's "Save what I wear"). + case "savenew": { + let number = 1; + while (named(account.outfits, `outfit${number}`)) { + number++; + } + outfit(session, ["save", `outfit${number}`]); + return; + } + case "save": { + if (!validName(session, name)) { + return; + } + const existing = named(account.outfits, name); + if (!existing && account.outfits.length >= MAX_OUTFITS) { + tell(session, `You already have ${MAX_OUTFITS} outfits. Delete one first.`); + return; + } + const items = wornItems(account, avatar).map(item => item.inv); + account.outfits = [...account.outfits.filter(entry => entry !== existing), {name, items}]; + accounts.save(); + tell(session, `Outfit ${name} saved (${items.length} items).`); + return; + } + case "wear": { + const saved = named(account.outfits, name); + if (!saved) { + tell(session, `You have no outfit called ${name}. Try !outfit list.`); + return; + } + const wanted = dress(session, saved.items); + const missing = saved.items.length - wanted.length; + tell(session, missing ? `Wearing ${name}. ${missing} of its items are no longer yours.` : `Wearing ${name}.`); + return; + } + case "delete": + if (!named(account.outfits, name)) { + tell(session, `You have no outfit called ${name}.`); + return; + } + account.outfits = account.outfits.filter(entry => entry.name !== name); + accounts.save(); + tell(session, `Outfit ${name} deleted.`); + return; + case "list": + tell(session, account.outfits.length ? `Your outfits: ${account.outfits.map(entry => entry.name).join(", ")}` : "You have no saved outfits yet."); + return; + default: + tell(session, "Use: !outfit save NAME, !outfit wear NAME, !outfit list, !outfit delete NAME, !outfit off, !outfit undo"); + } + }; + + const activeDenDef = account => (account.dens.find(den => den.inv === account.activeDen) || account.dens[0]).def; + + const layoutOf = owner => owner.denItems + .filter(item => item.placed && item.den === owner.activeDen) + .map(item => ({def: item.def, version: item.version, x: item.x, y: item.y, flip: item.flip})); + + // lays the account's den in use out as `layout` says, with its own items. + // with `giveMissing`, items it lacks are added to its inventory first. + // returns how many of the layout's items could not be placed. + const applyLayout = (session, layout, giveMissing) => { + const {account} = session; + for (const item of account.denItems.filter(candidate => candidate.den === account.activeDen)) { + item.placed = false; + item.x = item.y = item.flip = 0; + } + const used = new Set(); + let missing = 0; + for (const spot of layout) { + let item = account.denItems.find(candidate => !used.has(candidate) && !candidate.placed + && candidate.def === spot.def && candidate.version === spot.version); + if (!item && giveMissing && account.denItems.length < MAX_DEN_ITEMS && defpacks.denItemIds().includes(spot.def)) { + item = dens.giveDenItem(account, spot.def, spot.version); + } + if (!item) { + missing++; + continue; + } + used.add(item); + Object.assign(item, {placed: true, den: account.activeDen, x: spot.x, y: spot.y, flip: spot.flip}); + } + accounts.save(); + dens.sendDenItems(session); + const room = session.room && session.room.denOwner === account ? session.room : null; + for (const occupant of room ? room.sessions : []) { + dens.sendDenState(occupant, room, false); + } + return missing; + }; + + const den = (session, [action, name]) => { + const {account} = session; + switch (action) { + case "save": { + if (!validName(session, name)) { + return; + } + const existing = named(account.denLayouts, name); + if (!existing && account.denLayouts.length >= MAX_LAYOUTS) { + tell(session, `You already have ${MAX_LAYOUTS} den layouts. Delete one first.`); + return; + } + const items = layoutOf(account); + account.denLayouts = [...account.denLayouts.filter(entry => entry !== existing), {name, den: activeDenDef(account), items}]; + accounts.save(); + tell(session, `Den layout ${name} saved (${items.length} items).`); + return; + } + case "load": { + const saved = named(account.denLayouts, name); + if (!saved) { + tell(session, `You have no den layout called ${name}. Try !den list.`); + return; + } + if (saved.den !== activeDenDef(account)) { + tell(session, `Layout ${name} was made in another kind of den. Switch to that den first.`); + return; + } + const missing = applyLayout(session, saved.items, false); + tell(session, missing ? `Den layout ${name} loaded. ${missing} of its items are no longer yours.` : `Den layout ${name} loaded.`); + return; + } + case "copy": { + const owner = session.room && session.room.denOwner; + if (!owner || owner === account) { + tell(session, "Stand in the den you want to copy, then type !den copy."); + return; + } + if (activeDenDef(owner) !== activeDenDef(account)) { + tell(session, "Your den in use is a different kind of den. Switch to the same kind first."); + return; + } + const missing = applyLayout(session, layoutOf(owner), true); + tell(session, missing ? `Your den now looks like this one, apart from ${missing} items.` : "Your den now looks like this one."); + return; + } + case "savenew": { + let number = 1; + while (named(account.denLayouts, `layout${number}`)) { + number++; + } + den(session, ["save", `layout${number}`]); + return; + } + // what the den's "clear" button took away (lib/dens.js clearDen keeps it). + case "undo": { + const undo = account.denUndo; + if (!undo || undo.den !== account.activeDen) { + tell(session, undo ? "That was another den. Switch to it first." : "There is nothing to put back."); + return; + } + const missing = applyLayout(session, undo.items, false); + account.denUndo = null; + accounts.save(); + tell(session, missing ? `Your den is back as it was, apart from ${missing} items that are no longer yours.` : "Your den is back as it was."); + return; + } + case "delete": + if (!named(account.denLayouts, name)) { + tell(session, `You have no den layout called ${name}.`); + return; + } + account.denLayouts = account.denLayouts.filter(entry => entry.name !== name); + accounts.save(); + tell(session, `Den layout ${name} deleted.`); + return; + case "list": + tell(session, account.denLayouts.length ? `Your den layouts: ${account.denLayouts.map(entry => entry.name).join(", ")}` : "You have no saved den layouts yet."); + return; + default: + tell(session, "Use: !den save NAME, !den load NAME, !den list, !den delete NAME, !den copy, !den undo"); + } + }; + + const commands = { + online(session) { + const names = players().filter(other => !blocks.either(other.account, session.account)).map(other => other.account.username); + const shown = names.slice(0, MAX_LISTED).join(", "); + tell(session, `${names.length} playing: ${shown}${names.length > MAX_LISTED ? ", ..." : ""}`); + }, + + // only for buddies, as with the buddy list's own "go to". + where(session, words) { + const name = words.join(" "); + const target = findOnline(name); + if (!name) { + tell(session, "Use: !where NAME"); + } + else if (!session.account.buddies.includes(name.toLowerCase())) { + tell(session, `${name} is not one of your buddies.`); + } + else if (!target || !target.room) { + tell(session, `${name} is not online.`); + } + else { + tell(session, `${target.account.username} is in ${roomTitle(target.room)}.`); + } + }, + + time(session) { + tell(session, `It is ${new Date().toUTCString()}.`); + }, + + outfit, + den, + + // lib/disguises.js + become(session, [choice]) { + if (!choice || choice === "list") { + tell(session, `You can become: ${disguises.names().join(", ")}, or any character by its number. !become off to be yourself.`); + return; + } + if (choice === "off") { + disguises.set(session, 0, refreshForOthers); + tell(session, "You are yourself again."); + return; + } + const id = disguises.find(choice); + if (!id) { + tell(session, `There is no character called ${choice}. Try !become list.`); + return; + } + const changing = disguises.of(session.account) !== 0; + disguises.set(session, id, refreshForOthers); + tell(session, changing ? "Done. It shows when you next walk into a room." : "Done. !become off to be yourself again."); + }, + + again(session, [choice]) { + const times = choice === undefined ? 1 : Number(choice); + if (!session.lastPurchase || !Number.isInteger(times) || times < 1 || times > MAX_AGAIN) { + tell(session, session.lastPurchase ? `Use: !again N, with N from 1 to ${MAX_AGAIN}` : "Buy something in a shop first; !again then buys more of it."); + return; + } + ask(session, times === 1 ? "Buy one more of the last thing you bought?" : `Buy ${times} more of the last thing you bought?`, () => { + for (let count = 0; count < times; count++) { + buyAgain(session); + } + }); + }, + + go(session, [place]) { + if (!place || place === "list") { + tell(session, `Places: ${Object.keys(PLACES).join(", ")}. Any room also goes by its own name, like sarepia.flag_shop.`); + return; + } + const base = Object.hasOwn(PLACES, place) ? PLACES[place] : place; + if (!defpacks.roomDef(base) || /^(player_den|epic_dens)\./.test(base)) { + tell(session, `There is no place called ${place}. Try !go list.`); + return; + } + travel(session, base); + }, + + // A look for the room they stand in, a look picked afresh at every + // login, or the list of looks (config.themes). + theme(session, [action, choice]) { + const {account} = session; + const themes = require("../config.js").themes; + if (action === "random" && (choice === "on" || choice === "off")) { + account.randomTheme = choice === "on"; + accounts.save(); + tell(session, account.randomTheme ? "The lands get a look picked at random each time you log in." : "The lands keep the look you choose."); + } + else if (action === "here" && session.room && !session.room.denOwner && (choice === "off" || Object.hasOwn(themes, choice))) { + if (choice === "off") { + delete account.roomThemes[session.room.base]; + } + else { + account.roomThemes[session.room.base] = choice; + } + accounts.save(); + reloadRoom(session); + } + else if (action === "list") { + tell(session, `Looks: ${Object.keys(themes).join(", ")}`); + } + else { + tell(session, "Use: !theme list, !theme here NAME, !theme here off, !theme random on, !theme random off"); + } + }, + + // deletes the Jam-A-Grams already read; ones with a gift not yet taken stay. + mail(session, [action]) { + const {account} = session; + if (action !== "clear") { + tell(session, "Use: !mail clear"); + return; + } + const before = account.ecards.length; + account.ecards = account.ecards.filter(card => !card.read || card.gift); + accounts.save(); + tell(session, `${before - account.ecards.length} read Jam-A-Grams deleted. Open your mail again to see.`); + }, + + // every music track, the official ones and this server's extras, as den + // items of theirs: what the den's music list offers is what they own. + music(session, [action]) { + const {account} = session; + if (action !== "all") { + tell(session, "Use: !music all"); + return; + } + const owned = new Set(account.denItems.map(item => item.def)); + const wanted = [...defpacks.musicIds(), ...defpacks.extraMusicIds()].filter(id => !owned.has(id)); + const given = wanted.filter(id => dens.giveDenItem(account, id)).length; + dens.sendDenItems(session); + tell(session, given < wanted.length ? `${given} music tracks added. Your den items are full: recycle some for the rest.` + : wanted.length ? `${wanted.length} music tracks added. They are in your den's music list.` : "You have every music track already."); + }, + + hideblocked(session, [choice]) { + if (choice !== "on" && choice !== "off") { + tell(session, `Blocked players are ${session.account.hideBlocked ? "hidden" : "shown"}. Use: !hideblocked on, or !hideblocked off`); + return; + } + setHideBlocked(session, choice === "on"); + tell(session, choice === "on" ? "Players you have blocked are now hidden from you." : "Players you have blocked are shown again."); + }, + }; + + // commands whose words matter as they were typed, capitals and all. + const asTyped = { + // A whisper: only that buddy sees it, wherever they are. standing in + // the same room it is a chat bubble for the two of them; otherwise a + // message box, the one way the game has to show text from afar. + w(session, [name, ...words]) { + const {account} = session; + const said = words.join(" ").slice(0, MAX_WHISPER); + const target = name ? findOnline(name) : null; + if (!name || !said) { + tell(session, "Use: !w BUDDY message"); + } + else if (!account.buddies.includes(name.toLowerCase())) { + tell(session, `${name} is not one of your buddies.`); + } + else if (!target || !target.room || blocks.either(target.account, account) + || !accounts.featureOn(target.account, "chat") || !accounts.featureOn(account, "chat")) { + tell(session, `${name} cannot be whispered to right now.`); + } + else if (target.room === session.room) { + // "xw" makes the next chat bubble the reader's game draws a + // light green one (gui.ChatBalloon in the patched client). + for (const reader of [session, target]) { + reader.sendXt("xw", -1, 1); + reader.sendXt("uc", session.room.id, session.id, said, 0); + } + chatlog.record(account, session.room.name, said, target.account.username); + } + else { + // from afar there is no bubble to draw: a message box, in the same green. + target.sendXt("xw", -1, 0, account.username, said.replace(/%/g, " percent")); + tell(session, `Whispered to ${target.account.username}.`); + chatlog.record(account, session.room ? session.room.name : "", said, target.account.username); + } + }, + whisper(session, words) { + asTyped.w(session, words); + }, + + // "!den name NEW NAME": what the den in use is called on the screen of + // whoever walks in. anything else after "!den" is the usual command. + den(session, [action, ...words]) { + const {account} = session; + const wanted = words.join(" "); + if (action.toLowerCase() !== "name") { + commands.den(session, [action, ...words].map(word => word.toLowerCase())); + } + else if (wanted.toLowerCase() === "off") { + delete account.denNames[account.activeDen]; + accounts.save(); + tell(session, "This den has its usual name again."); + } + else if (isSilenced(account)) { + tell(session, "You cannot name a den while silenced."); + } + else if (!PLAIN_NAME.test(wanted)) { + tell(session, "Use: !den name NEW NAME (letters, digits and spaces, up to 20), or !den name off"); + } + else { + account.denNames[account.activeDen] = wanted; + accounts.save(); + tell(session, `This den is now called ${wanted}. It shows the next time someone walks in.`); + } + }, + + }; + + return { + // runs `text` if it is a command. returns what to do with the chat line: + // null to swallow it, or the text everyone should see in its place. + run(session, text) { + if (!text.startsWith(PREFIX)) { + return text; + } + const typed = text.slice(PREFIX.length).trim().split(/\s+/); + const [name, ...words] = typed.map(word => word.toLowerCase()); + if (Object.hasOwn(asTyped, name) && (name !== "den" || typed.length > 1)) { + asTyped[name](session, typed.slice(1)); + return null; + } + if (name === "roll") { + // said out loud, so the room can see it was not made up. + return `(rolls a dice: ${1 + Math.floor(Math.random() * 6)})`; + } + if (!Object.hasOwn(commands, name)) { + return text; // "!!!" and the like are just chat + } + commands[name](session, words); + return null; + }, + roomTitle, + }; +}; diff --git a/lib/defpacks.js b/lib/defpacks.js new file mode 100644 index 0000000..3d1749e --- /dev/null +++ b/lib/defpacks.js @@ -0,0 +1,503 @@ +"use strict"; + +const zlib = require("zlib"); +const amf3 = require("./amf3.js"); +const cdn = require("./cdn.js"); +const config = require("../config.js"); +const sales = require("./sales.js"); +const badges = require("./badges.js"); +const extraMusic = require("./extramusic.js"); + +// defPack ids, from loader.DefPacksDefHelper in the client. +const DEF_ITEM = 1000; +const DEF_AVATAR = 1003; +const DEF_ROOM = 1011; +const DEF_LOCALIZATION_EN = 10230; +const DEF_DEN_ITEM = 1030; +const DEF_GENERIC_LIST_TYPE = 1038; +const DEF_DEN_ROOM = 1040; +const DEF_DIAMOND = 1054; +const DEF_PET = 1046; +const DEF_AVATAR_CUSTOM = 1057; +const DEF_ACHIEVEMENTS = 1042; +const DEF_PARTY = 1047; +const DEF_CURRENCY_EXCHANGE = 1051; +const DEF_ADOPT_A_PET = 1061; +const DEF_PET_FOOD = 1062; +const DEF_PET_TOY = 1063; +const DEF_WORLD_ITEMS = 1064; +const DEF_NPC = 1025; +const DEF_NAMEBAR_BADGE = 1049; + +const OFFERED_SPECIAL_TYPES = ["0", "4"]; // den items: plain, mannequin +const DEN_ITEM_MASTERPIECE = 2725; + +const packs = new Map(); + +// A defPack is a raw-deflated AMF3 object. +const loadRaw = async id => { + const raw = await cdn.get(cdn.hashedPath(`defPacks/${id}`)); + if (!raw) { + throw new Error(`defPack ${id} is not available (offline and not cached?)`); + } + return amf3.decode(zlib.inflateRawSync(raw)); +}; + +// the pack with this server's rows in it (SHARED_CHANGES, further down). +const loadChanged = async id => { + const pack = await loadRaw(id); + if (SHARED_CHANGES.has(id)) { + SHARED_CHANGES.get(id)(pack); + } + return pack; +}; + +const LAYER_EYES = "3"; +const TYPE_CLOTHING = "1"; +const EVERY_AVATAR = "9007199254740991"; // avatarUseFlags with a bit set for each animal type + +// rooms the official room pack no longer lists but whose files an older +// build on the CDN still has (lib/cdn.js looks there): the Summer Carnival, +// dropped after build 1828. +const RESTORED_ROOMS = [ + {id: "273", pathName: "party/venue_carnival", type: "0", isPlatformer: "0"}, +]; + +const withRestoredRooms = pack => { + const paths = new Set(Object.values(pack).map(def => def.pathName)); + let next = Math.max(-1, ...Object.keys(pack).map(Number).filter(Number.isInteger)) + 1; + for (const room of RESTORED_ROOMS) { + if (!paths.has(room.pathName)) { + pack[next++] = {...room}; + } + } + return pack; +}; + +// parties. five party defs point at rooms that are in no build's room list +// and whose files are nowhere to be found (the 2012 New Year's party, an +// older Jamaaliday Jam, the Trading Party, a leap-year room, one hostable +// venue), and seven party rooms on the CDN have no party def pointing at +// them. put together here: +// - the Trading Party is held in the trading barn (the unused twin of the +// barn players can host in), since its own room is gone; +// - the restaurant and the dance club among the unused rooms become +// parties of their own, with a title and list picture borrowed from +// what is nearest. +// - the other four unused rooms are earlier copies of venues players can +// host in (cake, vet, bakery, medieval castle). they become parties too, +// under the names the game has for those venues and with their pictures. +// - party 36 is the "AJHQ" button of the world map's Epic Dens window. it +// led to whichever showcase den was on that month; lib/epicdens.js picks +// the room, so here it only gets a title that fits them all. +const PARTY_STAND_IN_ROOMS = new Map([["6", "515"]]); // party def id -> room def id +const ADDED_PARTIES = [ + // "Restaurant", the Dinner Party's picture, party/venue_p_diner + {id: "52", titleStrId: "703", mediaRefId: "1234", roomDefId: "472"}, + // "Dance Party", the hostable dance club's picture, party/venue_pl_dance_club + {id: "53", titleStrId: "24279", mediaRefId: "4424", roomDefId: "519"}, + // "Birthday Party", "Science Party", "Bakery Party", "Medieval Party": + // party/venue_pl_birthday_cake, _vet_science, _res_bakery, _castle_medieval + {id: "54", titleStrId: "24271", mediaRefId: "4422", roomDefId: "514"}, + {id: "55", titleStrId: "24277", mediaRefId: "4425", roomDefId: "517"}, + {id: "56", titleStrId: "24275", mediaRefId: "4421", roomDefId: "518"}, + {id: "57", titleStrId: "24273", mediaRefId: "4423", roomDefId: "520"}, +]; +const PARTY_EPIC_DENS = "36"; +const STRING_EPIC_DENS = "8700"; +const PARTY_DEFAULTS = {iconMediaRefId: "0", avatarDefId: "0", restrictions: "0", avatarDefFlags: "0", petDefScalableFlags: "0", isGame: "0", isCustom: "0"}; + +const withRestoredParties = pack => { + const ids = new Set(); + for (const def of Object.values(pack)) { + ids.add(String(def.id)); + if (PARTY_STAND_IN_ROOMS.has(String(def.id))) { + def.roomDefId = PARTY_STAND_IN_ROOMS.get(String(def.id)); + } + if (String(def.id) === PARTY_EPIC_DENS) { + def.titleStrId = STRING_EPIC_DENS; + } + } + let next = Math.max(-1, ...Object.keys(pack).map(Number).filter(Number.isInteger)) + 1; + for (const party of ADDED_PARTIES) { + if (!ids.has(party.id)) { + pack[next++] = {...PARTY_DEFAULTS, ...party}; + } + } + return pack; +}; + +// text of our own, for things the game has no string for. added to the +// English localization pack under ids far above the game's (about 41,000). +const ADDED_STRINGS = { + 9000001: "Castle (2010 draft)", + 9000002: "Water Park (three slides)", + 9000003: "Water Park (five slides)", + 9000004: "Crystal Palace (concept)", + // the buddy game the client's files call "fourGem"; no string says so. + 9000005: "Four Gems", +}; + +// the game under this server's name. its text says "Animal Jam", "Animal +// Jam Classic", "AJ Classic" and "AJ" in some six hundred places (shop and +// item names, phrases of the chat menus, popups, "AJHQ"); here they all say +// "Burrow", in capitals where the game shouted. web addresses are left as +// they are: "animaljam.com" is a place, not a name. +const NAME = "Burrow"; +const renamed = text => text + .replace(/Animal Jam Classic|AJ Classic|Animal Jam(?!\.com)|\bAJ(?=HQ\b)|\bAJ\b/gi, (found, at) => { + // "aj" in small letters is somebody's word, not the game's name. + if (/^aj$/i.test(found) && found !== "AJ") { + return found; + } + const shouted = found === found.toUpperCase() && !/^AJ/.test(found); + return (shouted ? NAME.toUpperCase() : NAME) + (text.slice(at + found.length, at + found.length + 2) === "HQ" ? " " : ""); + }); +const withOurName = pack => { + for (const [id, text] of Object.entries(pack)) { + if (typeof text === "string" && /Animal Jam|AJ/i.test(text)) { + pack[id] = renamed(text); + } + } + return pack; +}; + +const withAddedStrings = pack => withOurName(Object.assign(pack, ADDED_STRINGS, extraMusic.strings())); + +// the extra music tracks (lib/extramusic.js), as den items like the +// official tracks. +const withExtraMusic = pack => { + const rows = Object.values(pack); + const template = rows.find(def => Number(def.id) === extraMusic.TEMPLATE); + const present = new Set(rows.map(def => String(def.id))); + let next = Math.max(-1, ...Object.keys(pack).map(Number).filter(Number.isInteger)) + 1; + for (const def of template ? extraMusic.defs(template) : []) { + if (!present.has(def.id)) { + pack[next++] = def; + } + } + return pack; +}; + +// den rooms on the CDN that no den def sells: four early drafts, each one +// drawing where the finished den has many parts. they are sold like any +// den, with the picture of the den they turned into. +const ADDED_DENS = [ + {id: "62", titleStrRef: "9000001", mediaRef: "83", iconMediaRef: "84", roomDefId: "130"}, // player_den/room_castle_lrg + {id: "63", titleStrRef: "9000002", mediaRef: "425", iconMediaRef: "1026", roomDefId: "187"}, // room_main_waterpark3 + {id: "64", titleStrRef: "9000003", mediaRef: "425", iconMediaRef: "1026", roomDefId: "186"}, // room_main_waterpark4 + {id: "65", titleStrRef: "9000004", mediaRef: "2777", iconMediaRef: "2776", roomDefId: "441"}, // room_main_epicpalace +]; +const DEN_DEFAULTS = {cost: "5000", enviroType: "0", storeStatus: "0", membersOnly: "0", availabilityStartTime: null, availabilityEndTime: null}; + +const withAddedDens = pack => { + const ids = new Set(Object.values(pack).map(def => String(def.id))); + let next = Math.max(-1, ...Object.keys(pack).map(Number).filter(Number.isInteger)) + 1; + for (const den of ADDED_DENS) { + if (!ids.has(den.id)) { + pack[next++] = {...DEN_DEFAULTS, ...den}; + } + } + return pack; +}; + +// with config.freeShops everything in every shop costs nothing: every +// account has ten million of each currency anyway (config.minimumCurrency), +// so a price is only a number to read past. the field a price is in differs +// by pack. +const PRICE_FIELDS = new Map([[DEF_ITEM, "value"], [DEF_DEN_ITEM, "cost"], [DEF_DIAMOND, "cost"], [DEF_PET, "cost"], [DEF_DEN_ROOM, "cost"]]); +const withoutPrices = (id, change = pack => pack) => pack => { + change(pack); + if (config.freeShops && PRICE_FIELDS.has(id)) { + for (const def of Object.values(pack)) { + if (def && def[PRICE_FIELDS.get(id)] !== undefined) { + def[PRICE_FIELDS.get(id)] = "0"; + } + } + } + return pack; +}; + +// what both the server and the clients get changed: rows put back or added. +const SHARED_CHANGES = new Map([ + [DEF_ROOM, withRestoredRooms], + [DEF_PARTY, withRestoredParties], + [DEF_DEN_ROOM, withoutPrices(DEF_DEN_ROOM, withAddedDens)], + [DEF_DEN_ITEM, withoutPrices(DEF_DEN_ITEM, withExtraMusic)], + [DEF_ITEM, withoutPrices(DEF_ITEM)], + [DEF_DIAMOND, withoutPrices(DEF_DIAMOND)], + [DEF_PET, withoutPrices(DEF_PET)], + [DEF_LOCALIZATION_EN, withAddedStrings], + [DEF_NAMEBAR_BADGE, badges.addTagDefs], // the name tag badges the admin gives: lib/badges.js +]); + +// den items and clothing that are in the tables and were never, or not for +// years, in a shop: the Beta set, items named for testing, and items with +// no name. they get a shop each (ODDITY_SHOPS in lib/world.js) and are on +// sale there whatever their dates say. worked out in init(). +const TEST_DEN_ITEMS = [584, 1517, 1518, 2196, 2199, 2200, 3118, 3123]; +const FOUNDERS_HAT = 215; +let oddDenItemIds = []; +let oddClothingIds = []; + +const alwaysOnSale = (pack, ids) => { + const wanted = new Set(ids.map(String)); + for (const def of Object.values(pack)) { + if (wanted.has(String(def.id))) { + def.availabilityStartTime = "0"; + def.availabilityEndTime = "0"; + } + } +}; + +// the packs clients get in a form of their own, each made by changing the +// official one: +// items every eye type usable by every animal. the official pack +// keeps the two ocean eyes to the animals that have art for +// them; on any other animal they are simply not drawn, which +// is wanted here as a way to have no eyes. +// (ItemXtCommManager.canUseItem is the check.) Clothing +// likewise: the official pack keeps each item to the animals +// it was drawn for (no beret on a penguin). and sale dates. +// den items, the diamond shop +// sale dates (lib/sales.js), which is why these are made +// again each day. +// animals, pets, dens +// no sale dates at all. +// rooms, parties, dens, strings, name tag badges +// the rows put back or added (SHARED_CHANGES). +const CLIENT_PACKS = new Map([ + [DEF_ITEM, pack => { + for (const def of Object.values(pack)) { + if (def.type === TYPE_CLOTHING || (def.type === "0" && def.layerId === LAYER_EYES)) { + def.avatarUseFlags = EVERY_AVATAR; + } + } + sales.stamp("clothing", pack); + alwaysOnSale(pack, oddClothingIds); + }], + [DEF_DEN_ITEM, pack => { + sales.stamp("denItems", pack); + alwaysOnSale(pack, oddDenItemIds); + }], + [DEF_DIAMOND, pack => sales.stamp("diamond", pack)], + // animals, pets and dens are never out of season here. the official pack + // dates the "travelling" animals and a few pets and dens, and the client + // will not offer what its dates do not cover. + [DEF_AVATAR, sales.always], + [DEF_PET, sales.always], + [DEF_DEN_ROOM, sales.always], + [DEF_ROOM, () => {}], + [DEF_PARTY, () => {}], + [DEF_LOCALIZATION_EN, () => {}], + [DEF_NAMEBAR_BADGE, () => {}], +]); +const clientPackPaths = new Map([...CLIENT_PACKS.keys()].map(id => [cdn.hashedPath(`defPacks/${id}`), id])); +const clientPackBodies = new Map(); // id -> {day, allOnSale, body} + +// the pack at `relPath` as clients should get it, or null when it is not +// one of the above (and comes straight from the CDN). +const clientPack = async relPath => { + const id = clientPackPaths.get(relPath); + if (id === undefined) { + return null; + } + const made = clientPackBodies.get(id); + if (made && made.day === sales.today() && made.allOnSale === sales.everythingOnSale()) { + return made.body; + } + const pack = await loadChanged(id); + CLIENT_PACKS.get(id)(pack); + const body = zlib.deflateRawSync(amf3.encode(pack)); + clientPackBodies.set(id, {day: sales.today(), allOnSale: sales.everythingOnSale(), body}); + return body; +}; + +// most packs are tables: an object of rows keyed by row index. +const load = async id => { + if (!packs.has(id)) { + packs.set(id, Object.values(await loadChanged(id))); + } + return packs.get(id); +}; + +let avatarDefs = new Map(); +let roomDefsByPath = new Map(); +let itemDefs = new Map(); +let clothingIds = []; +let petIds = []; +let customAvatarDefs = new Map(); +let denItemDefs = new Map(); +let denItemIds = []; +let petDefs = new Map(); +let strings = {}; // localization id -> English text +let stringIds = null; // English text -> localization id, built when first asked +let denRoomPaths = new Map(); +let diamondDefs = new Map(); // diamond def id -> {id, type, refId, cost} +let denRoomDefs = new Map(); // den room def id -> "player_den/..." room path +let listTypes = new Map(); // generic list id -> defPack type of its entries +let patternLists = new Map(); // generic list id -> pattern item ids of a custom avatar +let achievementDefs = []; // {id, userVarRef, triggerAmount} +let exchangeDefs = new Map(); // id -> {cost, costType, result, resultType} +let adoptAPetDefs = new Map(); +let partyDefs = new Map(); // id -> {id, room ("party.venue_x"), restrictions, avatarDefFlags, isCustom, isGame} +let worldItemDefs = new Map(); +let petFoodDefs = []; +let petToyDefs = []; +let musicIds = []; // den items that are music tracks +let roomDefsById = new Map(); +let badgeIds = []; // name tag badges, ascending +let npcDefs = new Map(); // the characters of the adventures, see lib/disguises.js + +// A pack whose feature can be done without: missing (offline and never +// cached) just leaves that feature empty. +const loadOptional = async id => { + try { + return await load(id); + } + catch (err) { + console.log(`[defs] ${err.message}; the feature that uses it is off`); + return []; + } +}; + +const init = async () => { + avatarDefs = new Map((await load(DEF_AVATAR)).map(def => [Number(def.id), def])); + roomDefsByPath = new Map((await load(DEF_ROOM)).map(def => [String(def.pathName).toLowerCase(), def])); + const roomPathsById = new Map((await load(DEF_ROOM)).map(def => [Number(def.id), String(def.pathName)])); + denRoomDefs = new Map((await load(DEF_DEN_ROOM)).map(def => [Number(def.id), def])); + denRoomPaths = new Map((await load(DEF_DEN_ROOM)).map(def => [Number(def.id), roomPathsById.get(Number(def.roomDefId))])); + diamondDefs = new Map((await load(DEF_DIAMOND)).map(def => [Number(def.id), def])); + badgeIds = (await loadOptional(DEF_NAMEBAR_BADGE)).map(def => Number(def.id)).sort((one, other) => one - other); + listTypes = new Map((await load(DEF_GENERIC_LIST_TYPE)).map(def => [Number(def.id), Number(def.typeId)])); + itemDefs = new Map((await load(DEF_ITEM)).map(def => [Number(def.id), def])); + // type 1 = clothing and accessories; type 0 = body parts, eyes and patterns + clothingIds = [...itemDefs].filter(([, def]) => def.type === "1").map(([id]) => id); + petDefs = new Map((await load(DEF_PET)).map(def => [Number(def.id), def])); + petIds = [...petDefs.keys()]; + denItemDefs = new Map((await load(DEF_DEN_ITEM)).map(def => [Number(def.id), def])); + // special types carry extra state (a den portal's destination, a shop's + // stock, ...). of those only mannequins (4) are modelled, in lib/dens.js, + // so plain den items and mannequins are what is offered. + // the Masterpiece item is a painting's frame, made in the Art Studio and + // nowhere else (lib/masterpieces.js). + denItemIds = [...denItemDefs].filter(([id, def]) => OFFERED_SPECIAL_TYPES.includes(def.specialType) && id !== DEN_ITEM_MASTERPIECE).map(([id]) => id); + strings = await loadChanged(DEF_LOCALIZATION_EN); + // the Beta set first, then the test items, then the nameless ones (some + // 260, many of them one item in several colours): a shop shows its list + // in the order given. + const isBeta = id => /beta/i.test(denItemDefs.get(id).abbrName); + const isTest = id => TEST_DEN_ITEMS.includes(id); + const isNameless = id => !strings[denItemDefs.get(id).nameStrId]; + oddDenItemIds = [ + ...denItemIds.filter(isBeta), + ...denItemIds.filter(id => isTest(id) && !isBeta(id)), + ...denItemIds.filter(id => isNameless(id) && !isBeta(id) && !isTest(id)), + ]; + oddClothingIds = [FOUNDERS_HAT, ...clothingIds.filter(id => id !== FOUNDERS_HAT && !strings[itemDefs.get(id).titleStrId])]; + customAvatarDefs = new Map((await load(DEF_AVATAR_CUSTOM)).map(def => [Number(def.id), def])); + for (const def of await load(DEF_AVATAR_CUSTOM)) { + const listId = Number(def.patternListRefId); + patternLists.set(listId, [...(patternLists.get(listId) || []), Number(def.patternRefId)]); + } + roomDefsById = new Map((await load(DEF_ROOM)).map(def => [Number(def.id), def])); + // typeCat 4 is music (the jukebox tracks; also what a hosted party plays) + musicIds = [...denItemDefs].filter(([id, def]) => def.typeCat === "4" && def.specialType === "0" && !extraMusic.ids.includes(id)).map(([id]) => id); + achievementDefs = (await loadOptional(DEF_ACHIEVEMENTS)) + .map(def => ({id: Number(def.id), userVarRef: Number(def.userVarRef), triggerAmount: Number(def.triggerAmount), name: String(def.name)})) + .filter(def => def.userVarRef > 0 && !/REUSE/.test(def.name)); + exchangeDefs = new Map((await loadOptional(DEF_CURRENCY_EXCHANGE)).map(def => [Number(def.id), + {id: Number(def.id), cost: Number(def.cost), costType: Number(def.costType), result: Number(def.result), resultType: Number(def.resultType)}])); + adoptAPetDefs = new Map((await loadOptional(DEF_ADOPT_A_PET)).map(def => [Number(def.id), def])); + worldItemDefs = new Map((await loadOptional(DEF_WORLD_ITEMS)).map(def => [Number(def.id), def])); + petFoodDefs = await loadOptional(DEF_PET_FOOD); + petToyDefs = await loadOptional(DEF_PET_TOY); + npcDefs = new Map((await loadOptional(DEF_NPC)).map(def => [Number(def.id), def])); + partyDefs = new Map((await loadOptional(DEF_PARTY)).map(def => { + const room = roomPathsById.get(Number(def.roomDefId)); + return [Number(def.id), { + id: Number(def.id), + room: room && room.replace(/\//g, ".").toLowerCase(), + titleStrId: Number(def.titleStrId), + restrictions: Number(def.restrictions), + avatarDefFlags: String(def.avatarDefFlags), + isCustom: def.isCustom === "1", + isGame: def.isGame === "1", + }]; + })); + console.log(`[defs] ${avatarDefs.size} avatars, ${roomDefsByPath.size} rooms, ${clothingIds.length} clothing items, ${denItemIds.length} den items, ${petIds.length} pets`); +}; + +module.exports = { + init, + load, + itemDef: id => itemDefs.get(Number(id)), + clothingIds: () => clothingIds, + petIds: () => petIds, + denItemDef: id => denItemDefs.get(Number(id)), + denItemIds: () => denItemIds, + clientPack, + string: id => (Object.hasOwn(strings, id) ? String(strings[id]) : ""), + stringId: text => { + if (!stringIds) { + stringIds = new Map(); + for (const [id, value] of Object.entries(strings)) { + if (typeof value === "string" && !stringIds.has(value)) { + stringIds.set(value, Number(id)); + } + } + } + return stringIds.get(text) || 0; + }, + badgeIds: () => badgeIds, + npcDef: id => npcDefs.get(Number(id)), + oddDenItemIds: () => oddDenItemIds, + // den items that exist to be given by id and are in no shop. + unsoldDenItemIds: () => extraMusic.ids, + oddClothingIds: () => oddClothingIds, + roomPaths: () => [...roomDefsByPath.keys()], + customAvatarDef: id => customAvatarDefs.get(Number(id)), + avatarDef: type => avatarDefs.get(Number(type)), + denRoomName: denDefId => { + const pathName = denRoomPaths.get(Number(denDefId)); + return pathName && pathName.replace(/\//g, "."); + }, + denRoomDef: id => denRoomDefs.get(Number(id)), + denRoomIds: () => [...denRoomDefs.keys()], + // what a diamond-priced thing is sold as: `type` says what `refId` is the + // def id of (see DIAMOND_TYPES), `cost` is in diamonds. + diamondDef: id => diamondDefs.get(Number(id)), + diamondIds: () => [...diamondDefs.keys()], + listType: listId => listTypes.get(Number(listId)), + // every generic list id whose entries are of this defPack type, ascending. + listsOfType: type => [...listTypes].filter(([, listType]) => listType === type).map(([id]) => id).sort((a, b) => a - b), + achievementDefs: () => achievementDefs, + exchangeDef: id => exchangeDefs.get(Number(id)), + exchangeDefs: () => [...exchangeDefs.values()], + adoptAPetDef: id => adoptAPetDefs.get(Number(id)), + adoptAPetIds: () => [...adoptAPetDefs.keys()], + partyDef: id => partyDefs.get(Number(id)), + partyDefs: () => [...partyDefs.values()], + worldItemDef: id => worldItemDefs.get(Number(id)), + worldItemIds: () => [...worldItemDefs.keys()], + petDef: id => petDefs.get(Number(id)), + petFoodDefs: () => petFoodDefs, + petToyDefs: () => petToyDefs, + musicIds: () => musicIds, + extraMusicIds: () => extraMusic.ids, + roomDefById: id => roomDefsById.get(Number(id)), + patternList: listId => patternLists.get(Number(listId)), + avatarTypes: () => [...avatarDefs.keys()], + // first non-member land animal, falling back to whatever the pack lists + // first. + defaultAvatarType: () => { + for (const [id, def] of avatarDefs) { + if (def.membersOnly !== "1" && (Number(def.enviroTypeFlags) & 1)) { + return id; + } + } + return avatarDefs.keys().next().value; + }, + // "jamaa_township.room_main" -> row of the room defPack + roomDef: roomName => roomDefsByPath.get(roomName.replace(/\./g, "/").toLowerCase()), +}; diff --git a/lib/dens.js b/lib/dens.js new file mode 100644 index 0000000..def728f --- /dev/null +++ b/lib/dens.js @@ -0,0 +1,434 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const achievements = require("./achievements.js"); +const config = require("../config.js"); +const defpacks = require("./defpacks.js"); +const epicDens = require("./epicdens.js"); +const masterpieces = require("./masterpieces.js"); +const {CURRENCIES, MAX_DEN_ITEMS, hasRoom, activeAvatar, resolvePurchase, isUint} = require("./player.js"); + +// den items: owning, placing and recycling furniture (client side: +// DenXtCommManager, DenItemHolder, DenEditor). + +const MAX_DENS = 200; +const MAX_SAVED_AT_ONCE = 1000; // den items in one save: as many as a den holds (gui.DenEditor) +const MAX_RECYCLED_AT_ONCE = 500; +const DEF_DEN_ROOM = 1040; + +// den privacy (BuddyCard.onDenPrivacyResponse) +const DEN_LOCKED = 0; +const DEN_BUDDIES_ONLY = 1; +const DEN_OPEN = 2; + +// loadRoom's roomType for a den (DenXtCommManager.denChangeResponse) +const ROOM_TYPE_DEN = 2; + +const activeDen = account => account.dens.find(den => den.inv === account.activeDen) || account.dens[0]; + +const canEnter = (owner, visitor) => owner === visitor || owner.denPrivacy === DEN_OPEN + || (owner.denPrivacy === DEN_BUDDIES_ONLY && owner.buddies.includes(visitor.username.toLowerCase())); +const RECYCLE_FRACTION = 0.3; // matches recyclePercentage sent at login +const FIELDS_PER_SAVED_ITEM = 17; +const REF_DEN_ITEM = "0"; // "1" would be a pet placed in the den +const CURRENCY_DIAMONDS = 3; + +// mannequins: den items (special type 4) that stand as an animal in clothes +// of the owner's. what one wears is kept on the den item as `mannequin`: +// {colors: [base, pattern, eyes], pattern, eyes, worn: [tail, leg, back, +// neck, head]}, the five being inventory ids of clothing, 0 for none. A 0 +// colour or def means the animal type's own (MannequinData.setupBodMods). +// the clothes stay in the owner's inventory and may leave it; a mannequin +// simply stops wearing what is no longer there. +const SPECIAL_MANNEQUIN = "4"; +// which clothing layers go in which of the five places (MannequinData.updateLayer). +const MANNEQUIN_SLOT_LAYERS = [["4"], ["5"], ["6"], ["7"], ["8", "9", "10"]]; +const LAYER_PATTERN = "2"; +const LAYER_EYES = "3"; + +const isMannequin = item => (defpacks.denItemDef(item.def) || {}).specialType === SPECIAL_MANNEQUIN; + +const mannequinOf = item => item.mannequin || {colors: [0, 0, 0], pattern: 0, eyes: 0, worn: [0, 0, 0, 0, 0]}; + +const mannequinBody = ({colors, pattern, eyes}) => [colors[0], colors[1], pattern, colors[2], eyes]; + +// the clothing a mannequin of `owner`'s wears, slot by slot (undefined for +// an empty slot or a piece the owner no longer has). +const mannequinClothes = (owner, item) => mannequinOf(item).worn.map(inv => (inv ? owner.items.find(piece => piece.inv === inv) : undefined)); + +// for the owner's own list (MannequinData.setupDataInvIdsOnly): the body, +// then the five inventory ids. +const mannequinOwnFields = (owner, item) => + (isMannequin(item) ? [...mannequinBody(mannequinOf(item)), ...mannequinClothes(owner, item).map(piece => (piece ? piece.inv : 0))] : []); + +// for whoever looks at the den (setupDataFull): the body, then for each +// slot the clothing's def id and, when there is one, its colour and +// inventory id. +const mannequinShownFields = (owner, item) => + (isMannequin(item) ? [...mannequinBody(mannequinOf(item)), ...mannequinClothes(owner, item).flatMap(piece => (piece ? [piece.def, piece.color, piece.inv] : [0]))] : []); + +// what the den editor sent for one mannequin, checked: [baseColor, +// patternColor, patternDefId, eyeColor, eyeDefId, tail, leg, back, neck, +// head]. null when any of it is not a whole number in range. +const readMannequin = (account, fields) => { + if (fields.length !== 10 || !fields.every(isUint)) { + return null; + } + const [base, patternColor, pattern, eyeColor, eyes, ...worn] = fields.map(Number); + const bodyPart = (defId, layer) => (defId && (defpacks.itemDef(defId) || {}).layerId === layer ? defId : 0); + return { + colors: [base, patternColor, eyeColor], + pattern: bodyPart(pattern, LAYER_PATTERN), + eyes: bodyPart(eyes, LAYER_EYES), + worn: worn.map((inv, slot) => { + const piece = inv && account.items.find(candidate => candidate.inv === inv); + const def = piece && defpacks.itemDef(piece.def); + return def && MANNEQUIN_SLOT_LAYERS[slot].includes(def.layerId) ? inv : 0; + }), + }; +}; + +// DenXtCommManager.denItemsResponse: [activeDenIdx, count, ?, (invIdx, defId, +// placed, version, approved, imageId, creatorDbId, creatorUuid, [mannequin], +// denStoreInvId)...]. the three after "approved" are a masterpiece's +// (lib/masterpieces.js); one not approved yet the client keeps out of dens, +// trades and the recycler. +const sendDenItems = session => { + const {account} = session; + const {denItems} = account; + session.sendXt("di", -1, account.activeDen, denItems.length, 0, + ...denItems.flatMap(item => [item.inv, item.def, item.placed ? 1 : 0, item.version, masterpieces.itemApproved(item), ...masterpieces.itemFields(item), + ...mannequinOwnFields(account, item), 0])); +}; + +// DenXtCommManager.denStateResponse: [itemCount, petCount, forceReload, +// (invIdx, defId, placed, x, y, version, flipped, userNameLink, imageId, +// creatorDbId, creatorUuid, [mannequin], ?)...]. forceReload makes the client finish a +// pending room change, so it is set when the den has just been entered. +const sendDenState = (session, room, forceReload = true) => { + const placed = room.denOwner.denItems.filter(item => item.placed && item.den === room.denOwner.activeDen && masterpieces.itemApproved(item)); + session.sendXt("ds", room.id, placed.length, 0, forceReload ? 1 : 0, + ...placed.flatMap(item => [item.inv, item.def, 1, item.x, item.y, item.version, item.flip, "", ...masterpieces.itemFields(item), + ...mannequinShownFields(room.denOwner, item), 0])); +}; + +// adds a den item to an account; used by purchases, prizes and the item +// finder. null when the inventory is full. +const giveDenItem = (account, defId, version = 0) => { + if (!hasRoom(account, "denItems")) { + return null; + } + const item = {inv: account.nextInv++, def: Number(defId), version: Number(version) || 0, placed: false, den: account.activeDen, x: 0, y: 0, flip: 0}; + account.denItems.push(item); + accounts.save(); + return item; +}; + +// puts every placed item back in the owner's inventory and empties the den +// on the screens of everyone inside it (DenXtCommManager.denEmptyResponse). +const clearDen = (owner, findOnline) => { + // kept so that "!den undo" can put it back (lib/commands.js). + const placed = owner.denItems.filter(item => item.placed && item.den === owner.activeDen); + if (placed.length) { + owner.denUndo = {den: owner.activeDen, items: placed.map(item => ({def: item.def, version: item.version, x: item.x, y: item.y, flip: item.flip}))}; + } + for (const item of owner.denItems.filter(candidate => candidate.den === owner.activeDen)) { + item.placed = false; + item.x = item.y = item.flip = 0; + } + accounts.save(); + const ownerSession = findOnline(owner.username); + const room = ownerSession && ownerSession.room && ownerSession.room.denOwner === owner ? ownerSession.room : null; + for (const session of room ? room.sessions : []) { + session.sendXt("de", room.id); + } + if (ownerSession) { + sendDenItems(ownerSession); + } +}; + +// the room a player's den in use is: {base, defId, enviroType, roomType, secondaryDefId}. +const denRoom = owner => { + const den = activeDen(owner); + const base = defpacks.denRoomName(den.def) || defpacks.denRoomName(config.denDefId); + const def = defpacks.roomDef(base); + return {base, defId: Number(def.id), enviroType: Number(def.type), roomType: ROOM_TYPE_DEN, secondaryDefId: den.def}; +}; + +// RoomXtCommManager.roomPropertiesResponse -> RoomManagerWorld.loadRoom +// (path, enviroType, roomType, secondaryDefId, zoom, roomDefId, customData) +const sendRoomProperties = (session, room) => { + // customData is JSON the room is made with; made when asked for, so that + // it is current (a function on the room, or nothing). + const customData = room.customData ? JSON.stringify(room.customData()) : ""; + session.sendXt("rp", room.id, room.base, room.enviroType, room.roomType, room.secondaryDefId, 100, room.defId, customData); +}; + +const handlers = ({others, findOnline}) => { + const inOwnDen = session => session.room && session.room.denOwner === session.account; + + // DenXtCommManager.denListResponse: [count, (invId, denDefId)...] + const sendDenList = session => { + const {dens} = session.account; + session.sendXt("dl", -1, dens.length, ...dens.flatMap(den => [den.inv, den.def])); + }; + + // A den room from a den shop, paid for in gems. the client asks for the + // den list again by itself once the purchase is confirmed. + // A den's inventory id is the slot it sits in on the den switcher (0 to + // 199): the client asks for the slot it wants filled, keeps its den list + // by that number and looks the new den up there when the purchase is + // confirmed (DenSwitcher.purchasedDenRoomCallback). + const freeSlot = (account, wanted) => { + const taken = new Set(account.dens.map(den => den.inv)); + if (Number.isInteger(wanted) && wanted >= 0 && wanted < MAX_DENS && !taken.has(wanted)) { + return wanted; + } + return Array.from({length: MAX_DENS}, (_, slot) => slot).find(slot => !taken.has(slot)); + }; + + const buyDen = (session, defId, isDiamond, slot) => { + const {account} = session; + // den rooms priced in gems have no currency field of their own. + const purchase = resolvePurchase(defId, isDiamond, "denRoom", id => ({cost: Number((defpacks.denRoomDef(id) || {}).cost) || 0, currencyType: 0})); + const currency = purchase && CURRENCIES[purchase.currencyType]; + if (!purchase || !defpacks.denRoomDef(purchase.defId) || !defpacks.denRoomName(purchase.defId) || account.dens.length >= MAX_DENS + || (account.currency[currency] || 0) < purchase.cost) { + session.sendXt("db", -1, 0, "", 0, 0, 0); + return; + } + account.currency[currency] -= purchase.cost; + achievements.currencyChanged(account, currency, -purchase.cost); + account.dens.push({inv: freeSlot(account, /^\d{1,3}$/.test(String(slot)) ? Number(slot) : NaN), def: purchase.defId}); + accounts.save(); + session.sendXt("db", -1, 1, account.currency[currency], 0, purchase.currencyType, 0); + sendDenList(session); + }; + + // A painting framed: the Art Studio's purchase (lib/masterpieces.js, step + // 3), paid with two diamonds or with a Masterpiece Token from the + // inventory. the reply's last field is the new item's inventory id. + const buyMasterpiece = (session, defId, frame, withToken, paintingId) => { + const {account} = session; + const diamond = defpacks.diamondDef(defId); + const cost = diamond ? Number(diamond.cost) : 0; + const token = account.denItems.find(item => item.def === masterpieces.TOKEN_DEN_ITEM); + if (defId !== masterpieces.DIAMOND_DEF || !diamond || !masterpieces.claimable(account, paintingId, frame) + || account.denItems.length >= MAX_DEN_ITEMS || (withToken ? !token : (account.currency.diamonds || 0) < cost)) { + session.sendXt("db", -1, 0, "", 0, 0, 0); + return; + } + if (withToken) { + account.denItems.splice(account.denItems.indexOf(token), 1); + } + else { + account.currency.diamonds -= cost; + achievements.currencyChanged(account, "diamonds", -cost); + } + masterpieces.claim(paintingId, frame); + const item = giveDenItem(account, masterpieces.DEN_ITEM, frame); + item.image = String(paintingId); + accounts.save(); + console.log(`[world] ${account.username} made masterpiece ${item.image}${masterpieces.itemApproved(item) ? "" : " (waiting for review in the admin panel)"}`); + session.sendXt("db", -1, 1, account.currency.diamonds || 0, 0, CURRENCY_DIAMONDS, item.inv); + sendDenItems(session); + }; + + return { + di(session) { + sendDenItems(session); + }, + + // PlayerWallGui.setupMasterpieces and the like: [username] -> the + // approved masterpieces that player has (denMasterpieceInventoryResponse: + // [count, (defId, invIdx, version, approved, imageId, creatorDbId, + // creatorUuid)...]). + dmi(session, roomId, [username]) { + const owner = accounts.byName(username); + const hung = owner ? owner.denItems.filter(item => item.image && masterpieces.itemApproved(item)) : []; + session.sendXt("dmi", -1, hung.length, ...hung.flatMap(item => [item.def, item.inv, item.version, "true", ...masterpieces.itemFields(item)])); + }, + + // MasterpiecePreview: [ownerName, paintingId] -> [who painted it] + dmc(session, roomId, [, paintingId]) { + const maker = masterpieces.creatorOf(paintingId); + session.sendXt("dmc", -1, maker ? maker.username : ""); + }, + + // DenXtCommManager.requestBuy: ["0" item | "-1" den room, shopId, defId, + // version (items) or den slot (rooms), isDiamondItem, ...]. for something + // priced in diamonds defId is its diamond def's id. the reply + // (denBuyResponse) is [status, newAmount, ?, currencyType, ?]. + db(session, roomId, [kind, shopId, defId, version, isDiamondItem, isMasterpiece, withToken, paintingId]) { + const {account} = session; + if (kind === "-1") { + buyDen(session, defId, isDiamondItem === "1", version); + return; + } + if (kind === "0" && isMasterpiece === "1") { + buyMasterpiece(session, Number(defId), Number(version), withToken === "1", paintingId); + return; + } + const purchase = resolvePurchase(defId, isDiamondItem === "1", "denItem", id => { + const own = defpacks.denItemDef(id); + return {cost: own ? Number(own.cost) : 0, currencyType: own ? Number(own.currencyType) : -1}; + }); + const def = purchase && defpacks.denItemDef(purchase.defId); + const currency = purchase && CURRENCIES[purchase.currencyType]; + // combined costs and special item types other than mannequins are refused. + if (kind !== "0" || !def || !defpacks.denItemIds().includes(purchase.defId) || !currency + || account.denItems.length >= MAX_DEN_ITEMS || (account.currency[currency] || 0) < purchase.cost) { + session.sendXt("db", -1, 0, "", 0, 0, 0); + return; + } + account.currency[currency] -= purchase.cost; + achievements.currencyChanged(account, currency, -purchase.cost); + achievements.add(account, achievements.VARS.denItemsBought); + giveDenItem(account, purchase.defId, version); + session.sendXt("db", -1, 1, account.currency[currency], 0, purchase.currencyType, 0); + sendDenItems(session); + }, + + // DenXtCommManager.requestDenStateChange: [count, (refType, invIdx, placed, + // x, y, flipped, userNameLink, 10 mannequin fields)...]. the reply + // (DenEditor.onDenSaveSet) lists the inventory ids that were applied. + ds(session, roomId, params) { + const {account} = session; + const count = Number(params[0]); + if (!Number.isInteger(count) || count < 0 || count > MAX_SAVED_AT_ONCE || params.length !== 1 + count * FIELDS_PER_SAVED_ITEM) { + session.sendXt("dss", -1); + return; + } + const applied = []; + const byInv = new Map(account.denItems.map(candidate => [candidate.inv, candidate])); + const mannequins = account.denItems.filter(candidate => candidate.mannequin); + for (let i = 0; i < count; i++) { + const [refType, invIdx, placed, x, y, flip, , ...outfit] = params.slice(1 + i * FIELDS_PER_SAVED_ITEM, 1 + (i + 1) * FIELDS_PER_SAVED_ITEM); + const item = byInv.get(Number(invIdx)); + if (refType !== REF_DEN_ITEM || !item || ![x, y, flip].every(value => Number.isInteger(Number(value))) + || (placed === "1" && !masterpieces.itemApproved(item))) { + continue; + } + item.placed = placed === "1"; + item.den = account.activeDen; + item.x = item.placed ? Number(x) : 0; + item.y = item.placed ? Number(y) : 0; + item.flip = item.placed ? Number(flip) : 0; + const mannequin = isMannequin(item) && readMannequin(account, outfit); + if (mannequin) { + // A piece of clothing is on one mannequin at a time. + for (const other of mannequins) { + if (other !== item && other.mannequin) { + other.mannequin.worn = other.mannequin.worn.map(inv => (mannequin.worn.includes(inv) ? 0 : inv)); + } + } + if (!item.mannequin) { + mannequins.push(item); + } + item.mannequin = mannequin; + } + applied.push(item.inv); + } + accounts.save(); + session.sendXt("dss", -1, ...applied); + if (inOwnDen(session)) { + for (const other of others(session)) { + sendDenState(other, session.room, false); + } + } + }, + + // DenXtCommManager.requestRecycle: ["0" items | "-1" den rooms, "inv,inv,..."]. + // the reply (denRecycleResponse) is [count, newGemTotal, ...recycledInvIdx], + // and the recycling window then waits for a den item list (its + // recycleDiCallback) before it lets go of its spinner. + dr(session, roomId, [kind, invList]) { + const {account} = session; + const recycled = []; + for (const invIdx of kind === "0" ? new Set(String(invList).split(",", MAX_RECYCLED_AT_ONCE).map(Number)) : []) { + const index = account.denItems.findIndex(item => item.inv === invIdx); + if (index === -1 || !masterpieces.itemApproved(account.denItems[index])) { + continue; + } + const def = defpacks.denItemDef(account.denItems[index].def); + if (def && def.currencyType === "0") { + const refund = Number(def.recycleValue) || Math.floor(Number(def.cost) * RECYCLE_FRACTION); + account.currency.gems += refund; + achievements.currencyChanged(account, "gems", refund); + } + account.denItems.splice(index, 1); + recycled.push(invIdx); + } + accounts.save(); + session.sendXt("dr", -1, recycled.length, account.currency.gems, ...recycled); + if (recycled.length) { + sendDenItems(session); + } + if (recycled.length && inOwnDen(session)) { + for (const other of others(session)) { + sendDenState(other, session.room, false); + } + } + }, + + // DenXtCommManager.requestEmptyDen: the owner's own "clear den" button. + de(session) { + clearDen(session.account, findOnline); + if (!inOwnDen(session)) { + session.sendXt("de", -1); + } + }, + + dl(session) { + sendDenList(session); + }, + + // DenXtCommManager.requestDenChange: [denInvIdx]. the reply + // (denChangeResponse: [denDefId, perUserAvId, petInvId]) makes the owner's + // client load the new den; visitors are sent the new room as well. + dc(session, roomId, [invIdx]) { + const {account} = session; + const den = account.dens.find(candidate => candidate.inv === Number(invIdx)); + if (!den) { + return; + } + account.activeDen = den.inv; + accounts.save(); + const avatar = activeAvatar(account); + session.sendXt("dc", -1, den.def, avatar.perUserAvId, avatar.petInvId); + if (inOwnDen(session)) { + const {room} = session; + Object.assign(room, denRoom(account)); + for (const other of others(session)) { + sendRoomProperties(other, room); + } + for (const occupant of room.sessions) { + sendDenState(occupant, room); + } + } + }, + + // the "Epic Dens" list on the world map (denHighestResponse: [count, + // name...]): today's showcase dens, see lib/epicdens.js. + dh(session) { + const names = epicDens.list(); + session.sendXt("dh", -1, names.length, ...names); + }, + + // ["1", username]: who may enter that player's den? + // (BuddyManager.onDenPrivacyResponse: [username, setting]) + // ["0", setting]: change one's own setting. + dp(session, roomId, [mode, value]) { + if (mode === "1") { + const owner = accounts.byName(value); + session.sendXt("dp", -1, value, owner ? owner.denPrivacy : DEN_LOCKED); + } + else if ([DEN_LOCKED, DEN_BUDDIES_ONLY, DEN_OPEN].includes(Number(value))) { + session.account.denPrivacy = Number(value); + accounts.save(); + } + }, + }; +}; + +module.exports = {handlers, sendDenState, sendDenItems, sendRoomProperties, giveDenItem, clearDen, denRoom, canEnter, DEF_DEN_ROOM}; diff --git a/lib/disguises.js b/lib/disguises.js new file mode 100644 index 0000000..4e7683b --- /dev/null +++ b/lib/disguises.js @@ -0,0 +1,74 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const defpacks = require("./defpacks.js"); + +// playing as one of the game's characters ("!become liza"). +// +// the alphas were animals players could not be: in 2013 they were animal +// types of their own (2, 3, 9 to 12, since given to the eagle, deer, hyena, +// otter, polar bear and owl), and that artwork is gone. what is left of +// them is in the NPC table (defPack 1025): the clips the adventures put on +// the map, each a drawing that can stand, face left or right, talk, cast +// and so on, but not walk. +// +// the client has one way to draw a player as something from that table: +// the Phantomizer den item, which swaps a player's animal for NPC 2, a +// phantom, that then follows it about (DenXtCommManager.denPhantomResponse, +// "dph": [ok, sfsUserId, on]). the patched client takes the NPC's id from +// one more field of that message (XtReplyDemuxer, avatar.NPCView in +// swf-src/). so a disguise is a "dph" that follows a player's animal +// wherever the client is told of the animal. +// +// what does not work, by the nature of it: the clip glides, as it has no +// walk; the animal under it still does everything, unseen (sit, dance, +// clothes); and a client keeps the first disguise it drew for an animal +// until that animal is drawn afresh, so changing from one to another shows +// when the player next changes rooms. + +const NPC_PHANTOM = 2; // what the client draws when no id is given +const TYPE_CLIP = "0"; +const TYPE_ANIMAL = "1"; // an ordinary animal in an outfit: the villagers of the adventures + +// the names "!become" takes, with the NPC each is. +const NAMED = new Map([ + ["peck", 20], ["liza", 21], ["greely", 22], ["graham", 23], ["gilbert", 24], ["cosmo", 25], ["tavie", 219], + ["phantom", NPC_PHANTOM], +]); + +// is this NPC one a player can be drawn as? clips with no artwork (two +// rows have none) would leave them invisible. +const usable = id => { + const def = defpacks.npcDef(id); + return Boolean(def) && (def.type === TYPE_ANIMAL || (def.type === TYPE_CLIP && Number(def.mediaRefId) > 0)); +}; + +// the NPC id for what a player typed (a name above or a number), or null. +const find = text => { + const word = String(text).toLowerCase(); + const id = NAMED.has(word) ? NAMED.get(word) : /^\d{1,4}$/.test(word) ? Number(word) : NaN; + return usable(id) ? id : null; +}; + +const of = account => (usable(account.disguise) ? account.disguise : 0); + +// tells `to` how `subject` (a session whose animal `to` has just been told +// of, or has on screen) is disguised, if at all. +const show = (to, subject) => { + const id = of(subject.account); + if (id) { + to.sendXt("dph", -1, 1, subject.id, 1, id); + } +}; + +// puts a disguise on (an NPC id) or takes it off (0). the player's own +// client is told here; `redraw` puts their animal on everyone else's screen +// afresh, which brings the disguise with it (`show`). +const set = (session, id, redraw) => { + session.account.disguise = id; + accounts.save(); + session.sendXt("dph", -1, 1, session.id, id ? 1 : 0, id || NPC_PHANTOM); + redraw(session); +}; + +module.exports = {find, of, show, set, names: () => [...NAMED.keys()]}; diff --git a/lib/ecard-art.json b/lib/ecard-art.json new file mode 100644 index 0000000..3771fe5 --- /dev/null +++ b/lib/ecard-art.json @@ -0,0 +1,4 @@ +{ + "cards": [1,2,3,4,5,7,8,86,118,119,124,128,152,154,155,201,283,284,329,346,355,356,361,380,382,384,385,387,388,389,390,391,1188,1206,1211,1222,1228,1242,1249,1250,1251,1354,1426,1520,1627,1768,1933,2235,2649,2697,2700,2702,2703,2704,2705,2706,2707,2708,2709,2711,2712,2713,2714,2715,2716,2717,2720,2723,2762,2763,2805,2806,2807,2808,2809,2810,2811,2812,2813,2814,2815,2816,2817,2818,2819,2820,2821,2822,2823,2824,2825,2826,2827,2828,3749,4393,4410,4411,4434,4435,4451,4452,4453,4454,4455,4457,4460,4461,4462,4464,4465,4466,4467,4468,4469,4470,4477,4478,4479,4538,4539,4540,4541,4542,4543,4544,4545,4546,4547,4548,4549,4777,4778,4779,4780,4855,4856,4946,5023,5024,5026,5066,5067,5068,5069,5070,5071,5073,5074,5075,5076,5077,5078,5079,5080,5081,5082,5083,5084,5085,5086,5087,5088,5089,5090,5091,5092,5093,5094,5095,5099,5100,5738,5980,5981,6130,6138,9013,9014,9015,9016,9017,9167,9170,9172,9174,9175,9326,9327,9328,9329,9330,9331,9332], + "stamps": [10,11,12,13,15,16,17,18,19,20,21,22,23] +} diff --git a/lib/ecards.js b/lib/ecards.js new file mode 100644 index 0000000..0ac5ef4 --- /dev/null +++ b/lib/ecards.js @@ -0,0 +1,345 @@ +"use strict"; + +const fs = require("fs"); +const path = require("path"); +const accounts = require("./accounts.js"); +const achievements = require("./achievements.js"); +const defpacks = require("./defpacks.js"); +const dens = require("./dens.js"); +const limits = require("./limits.js"); +const {isSilenced} = require("./moderation.js"); +const {CURRENCIES, hasRoom, addClothing, sendClothingAdded, sendClothingRemoved} = require("./player.js"); + +// Jam-A-Grams (client side: ECardManager, ECardInbox, ECardCreation, +// ECardXtCommManager): a card, a stamp, a short message and perhaps a gift, +// kept in the receiver's inbox (account.ecards) until they delete it. +// +// which cards and stamps exist was a list on the official servers. the ones +// offered here were found by looking through the CDN's media files for card +// artwork (tools/find-art.py found what is in lib/ecard-art.json). + +// ECard.type: what, if anything, comes with the card +const TYPE_PLAIN = 0; +const TYPE_CLOTHING = 1; +const TYPE_DEN_ITEM = 3; +const TYPE_GEMS = 4; +const TYPE_DIAMONDS = 9; +const CURRENCY_OF = {[TYPE_GEMS]: 0, [TYPE_DIAMONDS]: 3}; + +// ECard senderType +const FROM_PLAYER = 0; +// "The voice": Animal Jam HQ. the sender's name is then the id of a +// localization string, the inbox shows the AJ badge in place of a stamp and +// the gift comes in the HQ gift popup (ECardInbox.setupGiftPopup). +const FROM_HQ = 1; +// A card the client never lists: it opens as a gift popup by itself, at +// login or when told to look (StartupPopups.redemptionCardsRequest). the +// inbox cannot open gems or diamonds, so those come this way. +const FROM_REDEMPTION = 2; +const HQ_NAME_STRING = 15964; // "Animal Jam HQ" in the game's text, "Burrow HQ" as this server sends it (lib/defpacks.js) +const HQ_NAME = "Burrow HQ"; +const MEMBER = 2; // account type the client draws a full name bar for +// ECard specialType: the receiver is shown "Secret Valentine" as the sender. +const SECRET_VALENTINE = 1; + +// ECardCreation.onSentResponseCallback +const SENT = 1; +const INBOX_FULL = -1; +const NOT_ACCEPTING = -2; +const FAILED = 0; + +// who may send to a player (ECardInbox's settings popup). +const FROM_EVERYONE = 0; +const FROM_BUDDIES = 1; +const FROM_NOBODY = 2; + +const LIST_CARDS = 10; +const LIST_STAMPS = 44; +const MAX_INBOX = 500; +const MAX_MESSAGE = 200; +const USERNAME_SHOWN = 1; + +const art = JSON.parse(fs.readFileSync(path.join(__dirname, "ecard-art.json"), "utf8")); +const sendsPerTenMinutes = limits.limiter(40, 600000); + +const now = () => Math.floor(Date.now() / 1000); +const clean = text => String(text).replace(/[\u0000-\u001f\u007f%]/g, " ").trim().slice(0, MAX_MESSAGE); + +module.exports = ({findOnline, blocks}) => { + // A card from the server carrying gems or diamonds: one of the popups. + const isRedemption = card => Boolean(card.hq && card.gift && Object.hasOwn(CURRENCY_OF, card.gift.type)); + + // who sent a card: by account id, and for cards from before ids were + // kept by the name on them. + const senderOf = card => (card.fromId ? accounts.byId(card.fromId) : accounts.byName(card.from)); + + // the 17 fields ECard.init takes, for one card. A secret valentine's + // sender is known here (reports about it reach them) but not sent. + const fields = card => { + const sender = card.hq ? null : senderOf(card); + const senderType = isRedemption(card) ? FROM_REDEMPTION : card.hq ? FROM_HQ : FROM_PLAYER; + const name = card.secret ? "" : senderType === FROM_HQ ? HQ_NAME_STRING : card.hq ? HQ_NAME : card.from; + return [ + card.id, name, card.card, card.stamp, card.read ? 1 : 0, card.msg, card.gift ? card.gift.type : TYPE_PLAIN, + card.gift ? card.gift.def : 0, card.gift ? card.gift.color : 0, card.gift ? card.gift.name : 0, + card.hq || card.secret ? MEMBER : sender ? sender.accountType : 0, + 0, // name bar data + 0, // secondary type + senderType, + USERNAME_SHOWN, + "", // additional gift data + card.secret ? SECRET_VALENTINE : 0, + ]; + }; + + const inInbox = account => account.ecards.filter(card => !isRedemption(card)); + const unread = account => inInbox(account).filter(card => !card.read).length; + // gift popups waiting for the player: numRedemptionCards in the login message. + const redemptions = account => account.ecards.filter(isRedemption).length; + + // puts a card in an inbox and, if its owner is playing, on their screen + // (ECardXtCommManager.eCardPushHandler). the caller saves. + const deliver = (to, card) => { + const stored = {id: to.nextInv++, read: false, ts: now(), ...card}; + to.ecards.push(stored); + const session = findOnline(to.username); + if (session && isRedemption(stored)) { + // GameRedemptionXtCommManager.handleRedeemCodeResponse: "a code was + // redeemed", which has the client fetch its cards and open the popups. + session.sendXt("grc", -1, 1, "", 0); + } + else if (session) { + session.sendXt("ep", -1, ...fields(stored)); + } + return stored; + }; + + // A gift from the server itself (the admin panel), as a Jam-A-Gram from + // Animal Jam HQ. `gift` is {kind: "clothing" | "den", id, color} for an + // item, which waits in the inbox, or {kind: "gems" | "diamonds", amount}, + // which pops up by itself. returns null, or why it could not be sent. + const sendFromHq = (to, text, gift) => { + if (to.ecards.length >= MAX_INBOX) { + return "Their Jam-A-Gram inbox is full"; + } + let attached; + if (gift.kind === "clothing") { + const def = defpacks.itemDef(gift.id); + const colors = def ? String(def.colors).split(",") : []; + if (!def || !defpacks.clothingIds().includes(Number(def.id))) { + return "No such clothing item"; + } + attached = {type: TYPE_CLOTHING, def: Number(def.id), color: Number(gift.color === undefined ? colors[0] : gift.color), name: Number(def.titleStrId)}; + } + else if (gift.kind === "den") { + const def = defpacks.denItemIds().includes(Number(gift.id)) && defpacks.denItemDef(gift.id); + if (!def) { + return "No such den item"; + } + attached = {type: TYPE_DEN_ITEM, def: Number(def.id), color: 0, name: Number(def.nameStrId), version: 0}; + } + else { + // for these the card's "gift id" and "gift name" are both the amount. + attached = {type: gift.kind === "gems" ? TYPE_GEMS : TYPE_DIAMONDS, def: gift.amount, color: 0, name: gift.amount}; + } + // the gift popup takes a message that starts with a number for the id of + // a localization string (StartupPopups.setupGiftPopup). + const message = clean(text).replace(/^(?=[\s+-]*\d)/, "Gift: "); + deliver(to, {from: HQ_NAME, hq: true, card: art.cards[0], stamp: 0, msg: message, gift: attached}); + accounts.save(); + return null; + }; + + // A card from Animal Jam HQ with words and nothing else, for news the + // server has for one player. false when their inbox is full. + const noteFromHq = (to, text) => { + if (to.ecards.length >= MAX_INBOX) { + return false; + } + deliver(to, {from: HQ_NAME, hq: true, card: art.cards[0], stamp: 0, msg: clean(text).replace(/^(?=[\s+-]*\d)/, "Note: "), gift: null}); + accounts.save(); + return true; + }; + + // the gift a sender attached: one of their own items, taken out of their + // inventory until the receiver accepts or throws the card away. + const takeGift = (session, type, invIdx) => { + const {account} = session; + if (type === TYPE_CLOTHING) { + const item = account.items.find(candidate => candidate.inv === invIdx); + const def = item && defpacks.itemDef(item.def); + if (!def) { + return null; + } + account.items.splice(account.items.indexOf(item), 1); + account.tradeList = account.tradeList.filter(listed => !(listed.type === 0 && listed.inv === item.inv)); + sendClothingRemoved(session, item.inv); + return {type, def: item.def, color: item.color, name: Number(def.titleStrId)}; + } + if (type === TYPE_DEN_ITEM) { + const item = account.denItems.find(candidate => candidate.inv === invIdx); + const def = item && defpacks.denItemDef(item.def); + // mannequins and the like stay home, and so do paintings: a card has + // no way to say which painting it carries. + if (!def || def.specialType !== "0" || item.image) { + return null; + } + account.denItems.splice(account.denItems.indexOf(item), 1); + account.tradeList = account.tradeList.filter(listed => !(listed.type === 1 && listed.inv === item.inv)); + dens.sendDenItems(session); + return {type, def: item.def, color: 0, name: Number(def.nameStrId), version: item.version}; + } + return null; + }; + + const giveGift = (session, gift) => { + const {account} = session; + if (gift.type === TYPE_CLOTHING) { + sendClothingAdded(session, addClothing(account, gift.def, gift.color)); + } + else if (gift.type === TYPE_DEN_ITEM) { + dens.giveDenItem(account, gift.def, gift.version); + dens.sendDenItems(session); + } + else if (Object.hasOwn(CURRENCY_OF, gift.type)) { + const currency = CURRENCIES[CURRENCY_OF[gift.type]]; + account.currency[currency] = (account.currency[currency] || 0) + gift.def; + achievements.currencyChanged(account, currency, gift.def); + // ItemXtCommManager.currencyUpdateResponse: [currencyType, newAmount, reason] + session.sendXt("cu", -1, CURRENCY_OF[gift.type], account.currency[currency], 0); + } + }; + + const mayReceiveFrom = (to, from) => { + if (blocks.either(to, from) || to.ecardPrivacy === FROM_NOBODY || !accounts.featureOn(to, "jamagrams")) { + return false; + } + return to.ecardPrivacy !== FROM_BUDDIES || to.buddies.includes(from.username.toLowerCase()); + }; + + const handlers = { + // ECardXtCommManager.eCardListResponse: [count, 17 fields per card...]. + // the client reverses what it is sent, to show the newest first. + // [forPopups]: "1" when it is looking for gift popups to open rather + // than filling the inbox; only then are those cards in the list. + el(session, roomId, [forPopups]) { + const cards = forPopups === "1" ? session.account.ecards : inInbox(session.account); + session.sendXt("el", -1, cards.length, ...cards.flatMap(fields)); + }, + + // ECardCreation.sendECard: [to, cardMediaId, stampMediaId, messageType, + // message, giftType, giftInvIdx, isValentine] + es(session, roomId, [toName, card, stamp, , message, giftType, giftInvIdx, isValentine]) { + const {account} = session; + const to = accounts.byName(toName); + const reply = status => session.sendXt("es", -1, status); + // silenced: no words of their own reach anyone, in a card either. + if (!to || to === account || !art.cards.includes(Number(card)) || !art.stamps.includes(Number(stamp)) + || !accounts.featureOn(account, "jamagrams") || (isSilenced(account) && clean(message || "") !== "") + || !sendsPerTenMinutes.allow(account.id)) { + reply(FAILED); + return; + } + if (!mayReceiveFrom(to, account)) { + reply(NOT_ACCEPTING); + return; + } + if (to.ecards.length >= MAX_INBOX) { + reply(INBOX_FULL); + return; + } + const wantsGift = [TYPE_CLOTHING, TYPE_DEN_ITEM].includes(Number(giftType)); + const gift = wantsGift ? takeGift(session, Number(giftType), Number(giftInvIdx)) : null; + if (wantsGift && !gift) { + reply(FAILED); + return; + } + deliver(to, {from: account.username, fromId: account.id, card: Number(card), stamp: Number(stamp), msg: clean(message || ""), gift, + ...(isValentine === "1" ? {secret: true} : {})}); + achievements.add(account, achievements.VARS.jamAGramsSent); + if (gift) { + achievements.add(account, achievements.VARS.giftsSent); + } + accounts.save(); + reply(SENT); + }, + + // [msgId] -> eCardReadResponse: [msgId, success] + er(session, roomId, [msgId]) { + const card = session.account.ecards.find(candidate => candidate.id === Number(msgId)); + if (card) { + card.read = true; + accounts.save(); + } + session.sendXt("er", -1, msgId, card ? 1 : 0); + }, + + // [msgId] -> eCardDeleteResponse: [success, count, msgId...]. A gift + // still in the card goes with it. + ed(session, roomId, [msgId]) { + const {account} = session; + const before = account.ecards.length; + account.ecards = account.ecards.filter(card => card.id !== Number(msgId)); + accounts.save(); + session.sendXt("ed", -1, 1, before - account.ecards.length, ...(before === account.ecards.length ? [] : [msgId])); + }, + + // [msgId, "1" keep | "0" discard] -> eCardGiftResponse: [msgId, success] + eg(session, roomId, [msgId, accept]) { + const card = session.account.ecards.find(candidate => candidate.id === Number(msgId)); + if (!card || !card.gift) { + session.sendXt("eg", -1, msgId, 0); + return; + } + const {gift} = card; + // no room for it: it stays in the card until there is. + if (accept === "1" && ((gift.type === TYPE_CLOTHING && !hasRoom(session.account, "items")) + || (gift.type === TYPE_DEN_ITEM && !hasRoom(session.account, "denItems")))) { + session.sendXt("eg", -1, msgId, 0); + return; + } + if (isRedemption(card)) { + // A popup's card is gone once answered, as the client assumes. + session.account.ecards = session.account.ecards.filter(candidate => candidate !== card); + } + card.gift = null; + if (accept === "1") { + giveGift(session, gift); + } + accounts.save(); + session.sendXt("eg", -1, msgId, 1); + }, + + // [setting] -> eCardIsolationHandler: [success] + ei(session, roomId, [setting]) { + const value = Number(setting); + const valid = [FROM_EVERYONE, FROM_BUDDIES, FROM_NOBODY].includes(value); + if (valid) { + session.account.ecardPrivacy = value; + accounts.save(); + } + session.sendXt("ei", -1, valid ? 1 : 0); + }, + + // answering a buddy request that came as a card; requests here do not. + eb() {}, + // "I closed the inbox after deleting something": nothing is cached here. + ec() {}, + }; + + // GenericListXtCommManager.handleMediaResponse: (mediaId, name) pairs; null + // when `listId` is neither the cards' nor the stamps' list. + const list = listId => { + const ids = {[LIST_CARDS]: art.cards, [LIST_STAMPS]: art.stamps}[Number(listId)]; + return ids ? ids.flatMap(id => [id, 0]) : null; + }; + + // who sent the newest secret valentine in this inbox: the game reports + // such a card as being from "Secret Valentine". + const secretSender = account => { + const card = [...account.ecards].reverse().find(candidate => candidate.secret); + return card ? senderOf(card) : null; + }; + + return {handlers, list, unread, redemptions, sendFromHq, noteFromHq, secretSender, SECRET_NAME: "Secret Valentine"}; +}; diff --git a/lib/epicdens.js b/lib/epicdens.js new file mode 100644 index 0000000..4e32274 --- /dev/null +++ b/lib/epicdens.js @@ -0,0 +1,64 @@ +"use strict"; + +const defpacks = require("./defpacks.js"); + +// Epic Dens: the world map's list of dens worth a visit (client side: +// VolumeSelector, DenXtCommManager.requestDenHighest). +// +// the official list named players, and its "AJHQ" button led to a showcase +// den Animal Jam HQ had furnished, a new one every so often, held as party +// 36. those showcase dens are still on the CDN, 53 of them, each a whole +// room with its furniture in the file. here the list is the showcase dens: +// the client shows a name per row and asks to enter "den", which +// the server answers by putting the player in the room. the client draws +// twenty rows at most, so the list is a different twenty each day, and the +// AJHQ button goes to one more. +// +// the files do not say what the dens were called. each is named after the +// den type it was built in, going by its file name. +const KINDS = new Map([ + ["skyden", "Sky Kingdom"], ["ginger", "Gingerbread House"], ["winterp", "Winter Palace"], ["lcastle", "Lucky Castle"], + ["beach", "Beach House"], ["crystal_", "Crystal Palace"], ["sprgctg", "Spring Cottage"], ["peck", "Peck's Den"], + ["pixel", "Pixel Place"], ["greely", "Greely's Hideout"], ["gilbert", "Gilbert's Palace"], ["haunted", "Haunted Manor"], + ["snofort", "Snow Fort"], ["cottage", "Friendship Cottage"], ["liza", "Liza's Garden"], ["barn", "Ol' Barn"], + ["solarcade", "Sol Arcade"], ["graham", "Graham's Observatory"], ["bounce", "Bounce House"], ["cosmotree", "Cosmo's Tree House"], + ["waterpark", "Water Park"], ["greelyhalloween", "Haunted Hideout"], ["fallfree", "Autumn House"], + ["friendshipfortress", "Friendship Fortress"], ["epicbetaden", "Epic Beta Den"], +]); +const FOLDER = "epic_dens/room_"; +const ROWS_SHOWN = 20; // VolumeSelector.createDenWindows + +let dens = null; // [{name, base}], in room id order + +const all = () => { + if (!dens) { + const count = new Map(); + dens = defpacks.roomPaths().filter(path => path.startsWith(FOLDER)).map(path => { + const base = path.replace(/\//g, "."); + const kind = path.slice(FOLDER.length).replace(/\d*$/, ""); + return {title: KINDS.get(kind) || kind, base, id: Number(defpacks.roomDef(base).id)}; + }).sort((one, other) => one.id - other.id); + // "Sky Kingdom 2" where there are several of a kind. + for (const den of dens) { + count.set(den.title, (count.get(den.title) || 0) + 1); + den.number = count.get(den.title); + } + for (const den of dens) { + den.name = count.get(den.title) > 1 ? `${den.title} ${den.number}` : den.title; + } + } + return dens; +}; + +const today = () => Math.floor(Date.now() / 86400000); + +// the names in today's list. +const fromToday = (day, offset) => all()[(day * ROWS_SHOWN + offset) % all().length]; +const list = (day = today()) => Array.from({length: Math.min(ROWS_SHOWN, all().length)}, (_, i) => fromToday(day, i).name); + +const byName = name => all().find(den => den.name.toLowerCase() === String(name).toLowerCase()); + +// the den behind the AJHQ button today: the one after today's list. +const featured = (day = today()) => fromToday(day, ROWS_SHOWN); + +module.exports = {all, list, byName, featured}; diff --git a/lib/erase.js b/lib/erase.js new file mode 100644 index 0000000..11866d5 --- /dev/null +++ b/lib/erase.js @@ -0,0 +1,25 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const bans = require("./bans.js"); +const chatlog = require("./chatlog.js"); +const masterpieces = require("./masterpieces.js"); +const support = require("./support.js"); +const world = require("./world.js"); + +// an account deleted for good, by its owner (lib/manage.js) or by the admin +// (lib/panel.js), and what was kept about it elsewhere with it: its chat +// lines, its appeal, its feedback and username requests, and the paintings +// it made (from whoever holds one by now). what stays is said in the +// privacy policy (public/privacy.html): the record of bans and of what +// moderators did, under the name it had, until lib/retention.js ends it. +// the caller has taken the account out of the world and its pages. +module.exports = account => { + for (const id of masterpieces.madeBy(account)) { + world.removeMasterpiece(id); + } + bans.forget(account); + chatlog.forget(account); + support.forget(account); + accounts.remove(account); +}; diff --git a/lib/extramusic.js b/lib/extramusic.js new file mode 100644 index 0000000..b55da38 --- /dev/null +++ b/lib/extramusic.js @@ -0,0 +1,123 @@ +"use strict"; + +const zlib = require("zlib"); +const amf3 = require("./amf3.js"); +const cdn = require("./cdn.js"); + +// extra den music: sounds found in the game's files that nothing plays, or +// that only one room plays, made into music den items (see "Odd audio" in +// DISCOVERIES.md). they are not in any shop; the item finder and the admin +// panel's gifts give them by id. +// +// A music den item plays "audio/.mp3" from the content server +// (DenItemHolder), and the CDN has no such files for these. each one's +// sound sits inside a media file or a room file as an MP3 (a DefineSound +// tag of a zlib-compressed SWF), so the file is cut out of there when a +// client first asks for it. nothing of it is kept in this repository. + +const FIRST_ID = 6001; // the official den items end at 5925 +const STRING_BASE = 9000100; +const VOLUME = "40"; // the def's `flag`, as the official tracks have it +const TEMPLATE = 614; // "Jam On": each new row starts as a copy of this track's + +// {file, title, sound: the sound's exported name ("" for the only, unnamed +// one), and where it is: a media id, or a room file and the asset in it} +const TRACKS = [ + {file: "XtraNarration", title: "Narration", media: 1904, sound: "Narration"}, + {file: "XtraUnnamed", title: "Unnamed Sound", media: 46, sound: ""}, + {file: "XtraPhantomKings", title: "Phantom Kings", media: 2680, sound: "ajq_q7phntmKings.wav"}, + {file: "XtraYearBook", title: "TV Yearbook", media: 5828, sound: "ajq_tvYearBook"}, + {file: "XtraUSBKey", title: "Phantom USB Key", media: 5828, sound: "ajq_phntmUSBkey"}, + {file: "XtraNightingale", title: "Nightingale", media: 2365, sound: "ajq_nightingaleFull"}, + {file: "XtraVolcano", title: "Volcano", media: 2507, sound: "aj_musVolcanoFull"}, + ...[1, 2, 3, 4].map(layer => ({file: `XtraConcert${layer}`, title: `Concert Layer ${layer}`, + room: "party/venue_concert", asset: "Concert\\Concert_Party_Front_Lights.swf", sound: `layer${layer}`})), +].map((track, index) => ({...track, id: FIRST_ID + index, stringId: STRING_BASE + index})); + +const ids = TRACKS.map(track => track.id); + +// rows for the den item pack, each a copy of an official track's row. +const defs = template => TRACKS.map(track => ({ + ...template, id: String(track.id), nameStrId: String(track.stringId), abbrName: track.file, cost: "0", membersOnly: "0", + flag: VOLUME, availabilityStartTime: null, availabilityEndTime: null, +})); + +const strings = () => Object.fromEntries(TRACKS.map(track => [track.stringId, track.title])); + +const TAG_DEFINE_SOUND = 14; +const TAG_EXPORT = 56; +const TAG_SYMBOL_CLASS = 76; +const FORMAT_MP3 = 2; + +const soundIn = (swf, name) => { + if (swf.toString("latin1", 0, 3) !== "CWS") { + return null; + } + const body = zlib.inflateSync(swf.subarray(8)); + const sounds = new Map(); // character id -> MP3 data + const names = new Map(); // character id -> exported name + let at = Math.ceil((5 + 4 * (body[0] >> 3)) / 8) + 4; // past the frame size, rate and count + while (at + 2 <= body.length) { + const head = body.readUInt16LE(at); + at += 2; + let length = head & 0x3F; + if (length === 0x3F) { + length = body.readUInt32LE(at); + at += 4; + } + const tag = body.subarray(at, at + length); + at += length; + if (head >> 6 === TAG_DEFINE_SOUND && tag.length > 9 && tag[2] >> 4 === FORMAT_MP3) { + sounds.set(tag.readUInt16LE(0), tag.subarray(9)); // id, flags, sample count, seek samples, then the frames + } + else if (head >> 6 === TAG_SYMBOL_CLASS || head >> 6 === TAG_EXPORT) { + let pos = 2; + for (let left = tag.readUInt16LE(0); left > 0 && pos + 2 < tag.length; left--) { + const end = tag.indexOf(0, pos + 2); + names.set(tag.readUInt16LE(pos), tag.toString("utf8", pos + 2, end)); + pos = end + 1; + } + } + } + for (const [id, data] of sounds) { + if ((names.get(id) || "") === name) { + return Buffer.from(data); + } + } + return null; +}; + +const extract = async track => { + if (track.media) { + const swf = await cdn.get(cdn.hashedPath(`media/${track.media}`)); + return swf ? soundIn(swf, track.sound) : null; + } + const room = await cdn.get(cdn.hashedPath(`roomDefs/${track.room}.xroom`)); + const asset = room && amf3.decode(zlib.inflateSync(room)).assets + .find(candidate => String(candidate.name).toLowerCase() === track.asset.toLowerCase()); + return asset && Buffer.isBuffer(asset.ba) ? soundIn(asset.ba, track.sound) : null; +}; + +const audioPaths = new Map(TRACKS.map(track => [cdn.hashedPath(`audio/${track.file}.mp3`), track])); +const made = new Map(); // track -> promise of its MP3 + +// what to answer a content request with when it is for one of these +// tracks' audio: {body, type}; undefined when it is not, and {body: null} +// when the source could not be read. (Music items have no picture: the +// den's music list shows their names.) +const asset = async relPath => { + const track = audioPaths.get(relPath); + if (!track) { + return undefined; + } + if (!made.has(track)) { + made.set(track, extract(track).catch(() => null)); + } + const body = await made.get(track); + if (!body) { + made.delete(track); // offline, perhaps: try again next time + } + return {body, type: "audio/mpeg"}; +}; + +module.exports = {TRACKS, ids, defs, strings, asset, TEMPLATE}; diff --git a/lib/games.json b/lib/games.json new file mode 100644 index 0000000..7311eff --- /dev/null +++ b/lib/games.json @@ -0,0 +1,118 @@ +[ + {"id": 4, "swf": "Pachinko", "title": "Gem Ball", "type": 1, "vars": [16, 17, 0], "icon": 4295}, + {"id": 5, "swf": "MiniGame_Memory", "title": "Double Up", "type": 1, "vars": [6, 7, 83], "icon": 4291}, + {"id": 6, "swf": "MoatMadness", "title": "Overflow", "type": 1, "vars": [8, 9, 80], "icon": 4300}, + {"id": 10, "swf": "ParachuteGlider", "title": "Wind Rider", "type": 1, "vars": [12, 13, 79], "start": "seed", "icon": 4311}, + {"id": 11, "swf": "Trivia", "title": "Temple of Trivia", "type": 1, "vars": [10, 11, 0], "ready": false, "icon": 4309}, + {"id": 12, "swf": "RiverRace", "title": "River Race", "type": 1, "vars": [22, 23, 0], "start": "seed"}, + {"id": 13, "swf": "PhantomFighter", "title": "Phantom Fighter", "type": 1, "vars": [14, 15, 84], "icon": 4312}, + {"id": 14, "swf": "SpiderShooter", "title": "Spider Zapper", "type": 1, "vars": [18, 19, 82], "start": "seed", "icon": 4305}, + {"id": 15, "swf": "MicroPopcorn", "title": "Popcorn Machine", "type": 0}, + {"id": 16, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 17, "swf": "MicroSmoothie", "title": "Smoothie Machine", "type": 0}, + {"id": 19, "swf": "WindRider", "title": "Sky High", "type": 1, "vars": [26, 27, 0], "icon": 4304}, + {"id": 20, "swf": "Twister", "title": "Twister", "type": 1, "vars": [24, 25, 81], "icon": 4310}, + {"id": 22, "swf": "DistanceChallenge", "title": "Long Shot", "type": 1, "vars": [20, 21, 0], "icon": 4298}, + {"id": 23, "swf": "ArtStudioPrint", "title": "Coloring", "type": 1}, + {"id": 26, "swf": "ArtStudioPottery", "title": "Pottery", "type": 1}, + {"id": 27, "swf": "MicroPhantom", "title": "Phantom Vortex", "type": 0}, + {"id": 28, "swf": "TowerDefense", "title": "Pest Control", "type": 1, "vars": [130, 131, 132], "icon": 4301}, + {"id": 30, "swf": "GemBreaker", "title": "Gem Breaker", "type": 1, "vars": [91, 93, 92], "start": "seedAndPlayers", "icon": 4313}, + {"id": 34, "swf": "MicroMiraSays", "title": "Mira Says", "type": 1, "vars": [77, 76, 0], "icon": 4299}, + {"id": 35, "swf": "FortSmasher", "title": "Fruit Slinger", "type": 1, "vars": [143, 144, 145], "ready": false, "icon": 4294}, + {"id": 36, "swf": "MicroHotCocoa", "title": "Hot Cocoa Machine", "type": 0}, + {"id": 37, "swf": "SuperSort", "title": "Super Sort", "type": 1, "vars": [31, 32, 37], "icon": 4307}, + {"id": 39, "swf": "PillBugs", "title": "Pill Bugs", "type": 1, "vars": [277, 278, 279], "icon": 4303}, + {"id": 40, "swf": "BradyExpeditions", "title": "Brady Expeditions", "type": 1}, + {"id": 41, "swf": "PhantomsTreasure", "title": "Phantom's Treasure", "type": 1, "vars": [281, 283, 282], "icon": 4302}, + {"id": 42, "swf": "FeedingFrenzy", "title": "Eat 'Em Up", "type": 1, "vars": [284, 285, 0], "icon": 4292}, + {"id": 43, "swf": "MicroPetWash", "title": "Pet Wash", "type": 0}, + {"id": 48, "swf": "FashionShow", "title": "Best Dressed", "type": 1, "vars": [292, 293, 294], "ready": false, "icon": 4288}, + {"id": 51, "swf": "ArtStudioPainting", "title": "Painting", "type": 1}, + {"id": 52, "swf": "MicroPetSalon", "title": "Pet Stop", "type": 0}, + {"id": 55, "swf": "MicroGameInvasion", "title": "Phantom Invasion", "type": 0}, + {"id": 57, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 59, "swf": "MicroCrane", "title": "The Claw", "type": 0, "icon": 4290}, + {"id": 60, "swf": "TouchPool", "title": "Touch Pool", "type": 1, "vars": [310, 308, 309], "icon": 5229}, + {"id": 61, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 62, "swf": "HorseRace", "title": "Jamaa Derby", "type": 1, "vars": [327, 328, 330], "ready": false, "icon": 4297}, + {"id": 63, "swf": "MicroPuppy", "title": "Disc Toss", "type": 0, "vars": [313, 314, 315], "pet": 4}, + {"id": 64, "swf": "MicroDucky", "title": "Ducky Dash", "type": 0, "vars": [316, 317, 318], "pet": 3}, + {"id": 65, "swf": "MicroSnake", "title": "Sssssnake", "type": 0, "vars": [321, 322, 323], "pet": 11}, + {"id": 66, "swf": "FashionShow", "title": "Best Dressed", "type": 1, "vars": [292, 293, 294], "ready": false, "icon": 4289}, + {"id": 68, "swf": "Skeeball", "title": "Phantom Ball", "type": 1, "tickets": 10}, + {"id": 69, "swf": "WhackPhantom", "title": "Whack-A-Phantom", "type": 1, "tickets": 10}, + {"id": 70, "swf": "CandyCatcher", "title": "Candy Catch", "type": 1, "tickets": 10}, + {"id": 71, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 72, "swf": "MicroGameInvasion", "title": "Phantom Invasion", "type": 0}, + {"id": 73, "swf": "ArtPrintPlayPortrait", "title": "Painting", "type": 1}, + {"id": 74, "swf": "CottonCandy", "title": "Cotton Candy Machine", "type": 0}, + {"id": 75, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 76, "swf": "ArtStudioPrint", "title": "Coloring", "type": 1}, + {"id": 77, "swf": "FallingPhantoms", "title": "Falling Phantoms", "type": 1, "vars": [344, 345, 346], "ready": false, "icon": 4293}, + {"id": 78, "swf": "DolphinRace", "title": "Splash and Dash", "type": 1, "vars": [357, 358, 360], "ready": false, "icon": 4306}, + {"id": 80, "swf": "ShootingGallery", "title": "Carnival Darts", "type": 1, "tickets": 100}, + {"id": 81, "swf": "MicroPetSalon", "title": "Pet Stop", "type": 0}, + {"id": 82, "swf": "FastFoodies", "title": "Fast Foodies", "type": 1, "vars": [445, 444, 446], "icon": 5727}, + {"id": 83, "swf": "HedgeHog", "title": "Hedge Hog", "type": 1, "vars": [349, 350, 351], "icon": 4296}, + {"id": 85, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 86, "swf": "ArtStudioPrint", "title": "Coloring", "type": 1}, + {"id": 87, "swf": "BradyChemistrySet", "title": "Brady's Lab", "type": 0}, + {"id": 88, "swf": "SafetyQuiz", "title": "Safety Quiz", "type": 0}, + {"id": 94, "swf": "EagleFlap", "title": "Swoopy Eagle", "type": 1, "vars": [378, 377, 0], "icon": 4308}, + {"id": 96, "swf": "DunkAPhantom", "title": "Dunk-A-Phantom", "type": 1, "tickets": 10}, + {"id": 97, "swf": "SpotOn", "title": "Spot On", "type": 1, "vars": [386, 387, 388], "icon": 4321}, + {"id": 99, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 100, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 102, "swf": "TrueFalse", "title": "Best Guess", "type": 1, "vars": [403, 405, 0], "ready": false}, + {"id": 103, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 104, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 105, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 106, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 107, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 109, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 110, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 116, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 117, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 118, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 119, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 120, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 121, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 123, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 125, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 126, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 127, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 128, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 129, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 130, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 131, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 132, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 133, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 134, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 136, "swf": "ArtStudioPrint", "title": "Coloring", "type": 1}, + {"id": 138, "swf": "FastFoodies", "title": "Fast Foodies", "type": 1, "vars": [445, 444, 446]}, + {"id": 139, "swf": "ArtStudioGridDrawing", "title": "Pixel Painting", "type": 1}, + {"id": 140, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 141, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 142, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 143, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 144, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 145, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 146, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 147, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 148, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 149, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 150, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 153, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 154, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 155, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 156, "swf": "MicroCrane", "title": "The Claw", "type": 0}, + {"id": 89, "swf": "PVP_TicTacToe", "title": "Tic Tac Toe", "type": 0, "vars": [86, 87, 0], "buddy": true, "card": 5063}, + {"id": 90, "swf": "PVP_ConnectFour", "title": "Four Gems", "type": 0, "vars": [86, 87, 0], "buddy": true, "card": 5057}, + {"id": 91, "swf": "PVP_RockPaperScissor", "title": "Rock Paper Scissors", "type": 0, "vars": [86, 87, 0], "buddy": true, "card": 5060}, + {"id": 92, "swf": "PVP_ShellGame", "title": "Shell Game", "type": 0, "vars": [86, 87, 0], "buddy": true, "card": 5062}, + {"id": 93, "swf": "PVP_Memory", "title": "Pairs", "type": 0, "vars": [86, 87, 0], "buddy": true, "card": 5059}, + {"id": 95, "swf": "PVP_Scooped", "title": "Scooped", "type": 0, "vars": [86, 87, 0], "buddy": true, "card": 5061}, + {"id": 98, "swf": "PVP_Bowling", "title": "Bowling", "type": 0, "vars": [86, 87, 0], "buddy": true, "card": 5056}, + {"id": 101, "swf": "PVP_Marbles", "title": "Marbles", "type": 0, "vars": [86, 87, 0], "buddy": true, "card": 5058} +] diff --git a/lib/http.js b/lib/http.js new file mode 100644 index 0000000..fb8d950 --- /dev/null +++ b/lib/http.js @@ -0,0 +1,755 @@ +"use strict"; + +const crypto = require("crypto"); +const fs = require("fs"); +const http = require("http"); +const https = require("https"); +const path = require("path"); +const accounts = require("./accounts.js"); +const admin = require("./admin.js"); +const bans = require("./bans.js"); +const captcha = require("./captcha.js"); +const cdn = require("./cdn.js"); +const config = require("../config.js"); +const defpacks = require("./defpacks.js"); +const limits = require("./limits.js"); +const manage = require("./manage.js"); +const modpanel = require("./modpanel.js"); +const badges = require("./badges.js"); +const extraMusic = require("./extramusic.js"); +const masterpieces = require("./masterpieces.js"); +const panel = require("./panel.js"); +const totp = require("./totp.js"); +const world = require("./world.js"); + +// stands in for every web service the launcher and the SWF talk to: +// www (flashvars), authenticator, player-session-data, ajelectronapi, the +// game host page and the content CDN. + +const CROSS_DOMAIN = '' + + ''; + +const MIME = { + ".html": "text/html; charset=utf-8", + ".js": "text/javascript", + ".json": "application/json", + ".xml": "text/xml", + ".swf": "application/x-shockwave-flash", + ".png": "image/png", + ".svg": "image/svg+xml", + ".jpg": "image/jpeg", + ".mp3": "audio/mpeg", + ".txt": "text/plain", + ".otf": "font/otf", +}; + +const flashVars = () => ({ + content: config.baseUrl, + // the game's own server to the SWF, whatever its name: it loads the card + // badges, the bio and ban icons and the chat filter's lists from here, + // and calls /api here. the client lets the game load from no other name. + website: config.baseUrl, + mdUrl: `${config.baseUrl}game/`, + playerWallHost: `${config.baseUrl}wall`, + smartfoxServer: config.host, + blueboxServer: config.host, + smartfoxPort: String(config.gamePort), + blueboxPort: String(config.httpPort), + build_version: config.buildVersion, + deploy_version: config.deployVersion, + // for the custom client: are its advanced login settings honoured here? + loginChoices: config.loginChoices, + smoke_version: config.deployVersion, + clientURL: `${config.baseUrl}${config.deployVersion}/ajclient.swf?v=${config.buildVersion}`, + startupRoom: config.startupRoom, + // "-1" turns the client's stats socket off. + sbStatTrackerIp: "-1", + sbStatModulator: "0", + currentTimestamp: Math.floor(Date.now() / 1000), + country: "US", + locale: "en", +}); + +const readJson = req => new Promise((resolve, reject) => { + const chunks = []; + let size = 0; + req.on("data", chunk => { + size += chunk.length; + if (size > 64 * 1024) { + reject(new Error("body too large")); + req.destroy(); + } + else { + chunks.push(chunk); + } + }); + req.on("end", () => { + try { + resolve(chunks.length ? JSON.parse(Buffer.concat(chunks).toString()) : {}); + } + catch (err) { + reject(err); + } + }); + req.on("error", reject); +}); + +const readBody = (req, maxBytes) => new Promise((resolve, reject) => { + const chunks = []; + let size = 0; + req.on("data", chunk => { + size += chunk.length; + if (size > maxBytes) { + reject(new Error("body too large")); + req.destroy(); + } + else { + chunks.push(chunk); + } + }); + req.on("end", () => resolve(Buffer.concat(chunks))); + req.on("error", reject); +}); + +// the parts of a multipart/form-data body, as a Map of field name -> +// Buffer. empty when the body is not one. +const formParts = (contentType, body) => { + const parts = new Map(); + const boundary = /boundary=("?)([^";]{1,200})\1/.exec(contentType || ""); + if (!boundary) { + return parts; + } + const mark = Buffer.from(`--${boundary[2]}`); + let at = body.indexOf(mark); + while (at !== -1) { + const next = body.indexOf(mark, at + mark.length); + const headEnd = body.indexOf("\r\n\r\n", at); + if (next === -1 || headEnd === -1 || headEnd > next) { + break; + } + const name = /name="([^"]{1,100})"/.exec(body.toString("latin1", at + mark.length, headEnd)); + if (name) { + parts.set(name[1], body.subarray(headEnd + 4, next - 2)); // without the line break before the mark + } + at = next; + } + return parts; +}; + +const send = (res, status, body, type = "application/json") => { + const data = Buffer.isBuffer(body) ? body : Buffer.from(typeof body === "string" ? body : JSON.stringify(body)); + res.writeHead(status, {"Content-Type": type, "Content-Length": data.length}); + res.end(res.req && res.req.method === "HEAD" ? undefined : data); +}; + +// wrong passwords allowed per address before further tries from it are +// refused for a while. the address is what is blocked, never the account: +// blocking an account would let anybody keep its owner out by guessing at +// it, and guessing from many addresses is what makes it dear. +const TEN_MINUTES_MS = 600000; +const failuresByAddress = limits.limiter(config.failedLoginsPerTenMinutes, TEN_MINUTES_MS); +const searches = limits.limiter(120, 60000); // item finder searches, per address +const cacheMisses = limits.limiter(config.cacheMissesPerTenMinutes, TEN_MINUTES_MS); // files fetched from the official CDN for one address +const errorReports = limits.limiter(config.errorReportsPerMinute, 60000); +const paintingPosts = limits.limiter(60, TEN_MINUTES_MS); // per address; each also needs a token from the game +const PAINTING_PATH = /^\/masterpieces\/([0-9a-f-]{36})$/; + +// where clients ask for the HUD artwork; ours is a changed copy. +const HUD_ASSETS_PATH = cdn.hashedPath("assets/HUDAssets.swf"); +const MAX_REPORT_LENGTH = 4000; + +// client errors are also kept in a file of their own, so they outlive a +// server whose output only went to a terminal. +const CLIENT_ERROR_FILE = path.join(config.dataDir, "client-errors.log"); +const MAX_CLIENT_ERROR_FILE = 5 * 1024 * 1024; +const keepClientError = text => { + fs.promises.stat(CLIENT_ERROR_FILE).then(stat => stat.size, () => 0) + .then(size => (size < MAX_CLIENT_ERROR_FILE ? fs.promises.appendFile(CLIENT_ERROR_FILE, text) : null)) + .catch(() => {}); +}; +const THEMED_ROOM = /^(\d+)\/roomDefs\/theme_(\d+)\/(.+)$/; + +// the web pages, as against what the game and the client load +const SITE_PAGES = /^\/(?:register|terms|privacy|commands|shop|account|mod)?\/?$/; + +// origins a client's own page has: a file, as browsers name it. +const CLIENT_ORIGINS = ["null", "file://"]; + +// one of this server's plain pages (sign-up, the commands, the item finder), +// with the headers the account page and the panel have: nothing loaded from +// elsewhere, nothing sent elsewhere, no frame. +const PAGE_HEADERS = { + "X-Frame-Options": "DENY", + "Referrer-Policy": "no-referrer", + "Content-Security-Policy": "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; connect-src 'self'; img-src 'self' data:; font-src 'self'; " + + "form-action 'none'; frame-ancestors 'none'; base-uri 'none'", +}; +// the same, for the pages that show the captcha (lib/captcha.js) +const CAPTCHA_PAGE_HEADERS = {...PAGE_HEADERS, "Content-Security-Policy": captcha.policy(PAGE_HEADERS["Content-Security-Policy"])}; +// the terms and the privacy policy carry who runs this server and where to +// write, from config.js. +const LEGAL_VALUES = {legalEmail: config.legalEmail, adminEmail: config.adminEmail, operator: config.operator, hostedIn: config.hostedIn, + version: config.termsVersion, site: new URL(config.siteUrl).host}; +const escapeHtml = text => String(text).replace(/[&<>"]/g, sign => ({"&": "&", "<": "<", ">": ">", "\"": """})[sign]); +const sendLegalPage = async (res, file) => { + for (const [name, value] of Object.entries(PAGE_HEADERS)) { + res.setHeader(name, value); + } + const page = (await fs.promises.readFile(path.join(config.publicDir, file), "utf8")) + .replace(/\{\{(\w+)\}\}/g, (whole, name) => (Object.hasOwn(LEGAL_VALUES, name) ? escapeHtml(LEGAL_VALUES[name]) : whole)); + send(res, 200, page, MIME[".html"]); +}; +// a web address or a path on this server; anything else is dropped +const pageLink = text => (/^https?:\/\/[^\s"<>]+$/.test(text) || /^\/[^/\s"<>][^\s"<>]*$/.test(text) ? text : ""); +const HOME_VALUES = {downloadUrl: pageLink(config.downloadUrl), githubUrl: pageLink(config.githubUrl), discordUrl: pageLink(config.discordUrl)}; +const sendHomePage = async res => { + for (const [name, value] of Object.entries(PAGE_HEADERS)) { + res.setHeader(name, value); + } + const page = (await fs.promises.readFile(path.join(config.publicDir, "home.html"), "utf8")) + .replace(/\{\{(\w+)\}\}/g, (whole, name) => (Object.hasOwn(HOME_VALUES, name) ? escapeHtml(HOME_VALUES[name]) : whole)); + send(res, 200, page, MIME[".html"]); +}; +const sendPage = async (res, file, headers = PAGE_HEADERS) => { + for (const [name, value] of Object.entries(headers)) { + res.setHeader(name, value); + } + send(res, 200, captcha.withScriptVersion(await fs.promises.readFile(path.join(config.publicDir, file))), MIME[".html"]); +}; + +// A username that was rejected (lib/moderation.js) is replaced as part of +// signing in: the sign-in that proved who it is gets a ticket in place of a +// login token, and the ticket with a new name finishes the sign-in. A ticket +// is good for a few minutes and a few tries. +const RENAME_TICKET_MS = 600000; +const RENAME_TRIES = 20; +const renameTickets = new Map(); // SHA-256 of a ticket -> {id, expiry, tries, deviceToken} +const ticketHash = ticket => crypto.createHash("sha256").update(String(ticket)).digest("hex"); + +const renameTicket = (account, deviceToken) => { + for (const [hash, entry] of renameTickets) { + if (entry.expiry < Date.now() || entry.id === account.id) { + renameTickets.delete(hash); + } + } + const ticket = crypto.randomBytes(24).toString("hex"); + renameTickets.set(ticketHash(ticket), {id: account.id, expiry: Date.now() + RENAME_TICKET_MS, tries: 0, deviceToken}); + return ticket; +}; + +// the second half of such a sign-in: {rename_ticket, new_username}. +const renameAndSignIn = (res, body, from) => { + const hash = ticketHash(body.rename_ticket); + const entry = renameTickets.get(hash); + const account = entry && entry.expiry > Date.now() ? accounts.byId(entry.id) : null; + if (!account || !account.nameRejected || account.locked || world.moderation.banRemaining(account) !== 0 || bans.addressBan(from.address) + || ++entry.tries > RENAME_TRIES) { + renameTickets.delete(hash); + send(res, 401, {error_code: 101, error: "rename_expired"}); + return; + } + const wanted = typeof body.new_username === "string" ? body.new_username.trim() : ""; + world.disconnect(account); + const problem = wanted.toLowerCase() === account.username.toLowerCase() ? "same_name" : accounts.rename(account, wanted); + if (problem) { + send(res, 401, {error_code: 101, error: "name_rejected", rename_ticket: body.rename_ticket, name_error: problem}); + return; + } + renameTickets.delete(hash); + delete account.nameRejected; + manage.forget(account); + accounts.recordLogin(account, "launcher", from.address); + accounts.save(); + console.log(`[accounts] a rejected username was replaced by "${account.username}"`); + accounts.setLoginChoices(account, body.login_choices); + const token = accounts.issueToken(account); + send(res, 200, {auth_token: token, refresh_token: token, device_token: entry.deviceToken}); +}; + +const authenticate = async (req, res, from) => { + const body = await readJson(req); + if (body.rename_ticket !== undefined) { + renameAndSignIn(res, body, from); + return; + } + const byRefresh = body.refresh_token !== undefined; + const accountKey = String(body.username).trim().toLowerCase(); + if (!from.local && failuresByAddress.blocked(from.key)) { + send(res, 429, {error_code: 429, error: "too_many_attempts"}); + return; + } + // a password is not looked at before the captcha. the custom client + // knows these errors; the official launcher shows them as a wrong password. + const captchaProblem = byRefresh ? null : await captcha.check(body, from, "login", accounts.byName(accountKey)); + if (captchaProblem) { + send(res, captchaProblem === "captcha_unavailable" ? 503 : 401, {error_code: 101, error: captchaProblem}); + return; + } + const account = byRefresh + ? accounts.byToken(body.refresh_token) + : await accounts.authenticateAsync(body.username, body.password); + if (!account) { + failuresByAddress.record(from.key); + if (!byRefresh) { + // A wrong password shows in the account's own login history. + const tried = accounts.byName(accountKey); + if (tried) { + accounts.recordLogin(tried, "launcher", from.address, false); + accounts.save(); + } + } + // error_code 100 = expired refresh token, 101 = wrong credentials + send(res, 401, {error_code: byRefresh ? 100 : 101}); + return; + } + // banned: said here, with how long is left (-1 for good), where a client + // can show it. the game itself would only be refused at its socket with + // the one line it has for that, which says neither. the password (or the + // saved sign-in) was right, so this tells nobody anything a player's card + // does not. + // the reason goes with it: whoever got this far is the banned player. + const ban = world.moderation.banOf(account); + if (ban) { + send(res, 401, {error_code: 101, error: "account_banned", banned_seconds: ban.seconds, ban_reason: ban.reason}); + return; + } + // A banned address (lib/bans.js): for good, whoever signs in from it. + const addressBan = bans.addressBan(from.address); + if (addressBan) { + send(res, 401, {error_code: 101, error: "address_banned", banned_seconds: world.moderation.PERMANENT, ban_reason: addressBan.reason}); + return; + } + // locked by its owner on the account page: the password is right, and + // still nobody gets in. the launcher shows this as a failed sign-in. + if (account.locked) { + send(res, 401, {error_code: 101, error: "account_locked"}); + return; + } + // two-step sign-in (lib/totp.js): after the password, a code from the + // player's authenticator app, unless this device gave one in the last 30 + // days and kept the token it got for it. A saved sign-in is not asked: + // it was given after a code, and lasts no longer than such a token. the + // custom client knows these errors; the official launcher shows them as a + // wrong password, and cannot give a code. + let deviceToken; + if (!byRefresh && totp.isOn(account) && !totp.deviceTrusted(account, body.device_token)) { + if (body.totp === undefined || body.totp === "") { + send(res, 401, {error_code: 101, error: "totp_required", captcha_pass: captcha.issuePass(account, from)}); + return; + } + if (!totp.verify(account, String(body.totp))) { + failuresByAddress.record(from.key); + accounts.recordLogin(account, "launcher", from.address, false); + accounts.save(); + send(res, 401, {error_code: 101, error: "totp_wrong", captcha_pass: captcha.issuePass(account, from)}); + return; + } + if (body.remember_device === true) { + deviceToken = totp.trustDevice(account, "launcher"); + } + } + // its username was rejected: a new one first (above). the official + // launcher shows this as a wrong password; the account page asks too. + if (account.nameRejected) { + accounts.save(); // a two-step code just used stays used + send(res, 401, {error_code: 101, error: "name_rejected", rename_ticket: renameTicket(account, deviceToken)}); + return; + } + if (!byRefresh) { + accounts.recordLogin(account, "launcher", from.address); + accounts.save(); + } + // the custom client's advanced settings; the official launcher sends none. + accounts.setLoginChoices(account, body.login_choices); + const token = byRefresh ? body.refresh_token : accounts.issueToken(account); + send(res, 200, {auth_token: token, refresh_token: token, device_token: deviceToken}); +}; + +const player = (req, res) => { + const match = /^Bearer (.+)$/.exec(req.headers.authorization || ""); + const account = match && accounts.byToken(match[1]); + if (!account) { + send(res, 401, {error: "invalid_token"}); + return; + } + send(res, 200, { + id: account.id, + screen_name: account.username, + game_account_type: account.accountType, + language: "en", + game_server: config.host, + }); +}; + +const handle = async (req, res) => { + const url = new URL(req.url, config.baseUrl); + const route = `${req.method} ${url.pathname}`; + + const from = limits.clientOf(req); + + // the web pages live under the site's name (config.siteUrl): one asked + // for under the game server's name is sent there. what the game and the + // client load stays here, the client's captcha page among it. + if ((req.method === "GET" || req.method === "HEAD") && config.siteUrl !== config.baseUrl + && String(req.headers.host || "").toLowerCase() === new URL(config.baseUrl).host && SITE_PAGES.test(url.pathname)) { + res.writeHead(301, {Location: new URL(url.pathname + url.search, config.siteUrl).href, "Content-Length": 0}); + res.end(); + return; + } + + const isAdmin = url.pathname === "/admin" || url.pathname.startsWith("/admin/"); + const isAccount = url.pathname === "/account" || url.pathname.startsWith("/account/"); + const isMod = url.pathname === "/mod" || url.pathname.startsWith("/mod/"); + + // the pages that keep a cookie answer only under this server's own names: + // a request sent here by a page of another name (one whose name was made + // to point at this machine, say) is not theirs to make. nor is such a + // request ever this machine's own, wherever it came from. + if (!limits.hostAllowed(req)) { + if (isAdmin || isAccount || isMod) { + send(res, 421, {error: "wrong_host"}); + return; + } + from.local = false; + } + + // the admin panel sets its own, stricter headers: none of the cross-origin + // allowances below apply to it. on a public server it is not there at all + // for anyone but this machine and the addresses named (config.adminAllow). + if (isAdmin) { + if (config.isPublic && !from.direct && !config.adminAllow.includes(from.address)) { + send(res, 404, "Not found", "text/plain"); + return; + } + await panel.handle(req, res, url, from, {send, readJson}); + return; + } + + if (isAccount) { + await manage.handle(req, res, url, from, {send, readJson}); + return; + } + + // and the moderator panel (lib/modpanel.js), which is there for anyone to + // reach: its moderators are players, wherever they are. + if (isMod) { + await modpanel.handle(req, res, url, from, {send, readJson}); + return; + } + + // the clients' own pages are files, which browsers call the origin "null": + // those and this server's pages may read what the rest answers. no cookie + // is used outside /account and /admin. + const {origin} = req.headers; + if (origin && (CLIENT_ORIGINS.includes(origin) || limits.originAllowed(req))) { + res.setHeader("Access-Control-Allow-Origin", origin); + res.setHeader("Access-Control-Allow-Credentials", "true"); + res.setHeader("Vary", "Origin"); + } + res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS"); + res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization"); + res.setHeader("Cache-Control", "no-cache"); + res.setHeader("X-Content-Type-Options", "nosniff"); + + if (req.method === "OPTIONS") { + res.writeHead(204); + res.end(); + return; + } + + if (url.pathname.startsWith("/api/")) { + // the item finder's API changes accounts, so other sites open in a + // browser on this machine must not be able to call it. + if (!limits.originAllowed(req)) { + send(res, 403, {error: "forbidden"}); + return; + } + if (url.pathname === "/api/search" && !from.local && !searches.allow(from.key)) { + send(res, 429, {error: "too_many_requests"}); + return; + } + const result = await admin.handle(route, url.searchParams, req.method === "POST" ? await readJson(req) : null, from); + send(res, result.status, result.body); + return; + } + + const signupArt = req.method === "GET" && /^\/signup\/((?:thumb|hero)_[a-z]+\.svg)$/.exec(url.pathname); + if (signupArt) { + const art = await fs.promises.readFile(path.join(config.publicDir, "signup", signupArt[1])).catch(() => null); + res.setHeader("Cache-Control", "public, max-age=86400"); + send(res, art ? 200 : 404, art || "Not found", art ? MIME[".svg"] : "text/plain"); + return; + } + + // the font of the web pages, which is the game's own text font and the + // client's (public/fonts/). + const font = req.method === "GET" && /^\/fonts\/(CCDigitalDelivery-(?:Regular|Bold)\.otf)$/.exec(url.pathname); + if (font) { + res.setHeader("Cache-Control", "public, max-age=604800"); + send(res, 200, await fs.promises.readFile(path.join(config.publicDir, "fonts", font[1])), MIME[".otf"]); + return; + } + + // the chat filter's two word lists (public/filter/), which each player's + // game fetches and applies itself. read from disk each time, so that a + // change to a list is there for the next player to start the game. + const wordList = req.method === "GET" && /^\/filter\/(level[12]\.txt)$/.exec(url.pathname); + if (wordList) { + const list = await fs.promises.readFile(path.join(config.publicDir, "filter", wordList[1])).catch(() => null); + send(res, list ? 200 : 404, list || "Not found", "text/plain; charset=utf-8"); + return; + } + + // updates for the installed clients (config.clientUpdatesDir). each is + // signed, and the clients check that themselves; the bundle's name + // carries its version, so it never changes once published. + const clientUpdate = req.method === "GET" && /^\/client\/(latest\.json|app-\d+\.\d+\.\d+\.burrow)$/.exec(url.pathname); + if (clientUpdate) { + const file = await fs.promises.readFile(path.join(config.clientUpdatesDir, clientUpdate[1])).catch(() => null); + const manifest = clientUpdate[1] === "latest.json"; + res.setHeader("Cache-Control", manifest ? "no-cache" : "public, max-age=31536000, immutable"); + send(res, file ? 200 : 404, file || "Not found", file ? (manifest ? MIME[".json"] : "application/octet-stream") : "text/plain"); + return; + } + + // the badges and the Discord mark on player cards (public/badges/, lib/badges.js). + const badgeArt = req.method === "GET" && /^\/badges\/([a-z0-9]{1,30}\.png)$/.exec(url.pathname); + if (badgeArt) { + const art = await fs.promises.readFile(path.join(config.publicDir, "badges", badgeArt[1])).catch(() => null); + res.setHeader("Cache-Control", "public, max-age=3600"); + send(res, art ? 200 : 404, art || "Not found", art ? MIME[".png"] : "text/plain"); + return; + } + + switch (route) { + case "GET /register": + await sendPage(res, "register.html", CAPTCHA_PAGE_HEADERS); + return; + // the captcha on its own, for the client, whose login page is a file + // that cloudflare's widget does not run in. + case "GET /captcha": + await sendPage(res, "captcha.html", CAPTCHA_PAGE_HEADERS); + return; + case "GET /captcha.js": { + const text = await fs.promises.readFile(path.join(config.publicDir, "captcha.js"), "utf8"); + send(res, 200, captcha.script(text), "text/javascript; charset=utf-8"); + return; + } + case "GET /terms": + await sendLegalPage(res, "terms.html"); + return; + case "GET /privacy": + await sendLegalPage(res, "privacy.html"); + return; + case "GET /": + await sendHomePage(res); + return; + case "GET /logo.png": + case "GET /logo-square.png": + case "GET /favicon.ico": + res.setHeader("Cache-Control", "public, max-age=86400"); + send(res, 200, await fs.promises.readFile(path.join(config.publicDir, url.pathname === "/logo.png" ? "logo.png" : "logo-square.png")), MIME[".png"]); + return; + case "GET /ban-icon.png": // the banned label on player cards (swf-src/BuddyCard.as) + res.setHeader("Cache-Control", "public, max-age=86400"); + send(res, 200, await fs.promises.readFile(path.join(config.publicDir, "ban-icon.png")), MIME[".png"]); + return; + case "GET /bio-icon.png": // the button of the card's Bio tab + res.setHeader("Cache-Control", "public, max-age=86400"); + send(res, 200, await fs.promises.readFile(path.join(config.publicDir, "bio-icon.png")), MIME[".png"]); + return; + case "GET /commands": + await sendPage(res, "commands.html"); + return; + case "GET /shop": + await sendPage(res, "shop.html"); + return; + case "GET /flashvars": + send(res, 200, flashVars()); + return; + case "POST /authenticate": + await authenticate(req, res, from); + return; + case "GET /player": + player(req, res); + return; + case "POST /v1/login": + await readJson(req); + send(res, 200, {}); + return; + case "POST /v1/reportError": { + // the launcher and the SWF both report crashes here; they are the best + // clue for what the server got wrong. the patched SWF also sends + // progress traces for media loads this way, which are only worth + // having while debugging locally. + const report = await readJson(req); + // later lines are indented so a report cannot pass off its own text as + // one of the server's log lines. + const message = String(report.message).slice(0, MAX_REPORT_LENGTH).replace(/[^\x20-\x7e\n\t]/g, "?").replace(/\n\s*/g, "\n\t"); + const section = String(report.section).slice(0, 20).replace(/[^\w-]/g, "?"); + const trace = message.startsWith("media "); + if (trace ? config.logPackets : from.local || errorReports.allow(from.key)) { + console.log(`[${trace ? "client-trace" : "client-error"}] (${section}) ${message}`); + if (!trace) { + keepClientError(`${new Date().toISOString()} (${section}) ${message}\n`); + } + } + send(res, 200, {}); + return; + } + // the Jammer Wall service (playerWallHost in the flashvars); every + // command carries a token the game socket handed out, see lib/walls.js. + case "POST /wall": + send(res, 200, world.walls.http(await readJson(req))); + return; + // the Art Studio posts a painting to be made a masterpiece of (the + // mdUrl flashvar + "mp"): a form with the token the game socket handed + // out and the picture. ArtStudioPainting.onSendComplete reads the reply. + case "POST /game/mp": { + if (!from.local && !paintingPosts.allow(from.key)) { + send(res, 429, {success: false}); + return; + } + const parts = formParts(req.headers["content-type"], await readBody(req, masterpieces.MAX_IMAGE_BYTES + 16 * 1024)); + const uuid = masterpieces.upload(String(parts.get("authToken") || ""), parts.get("image")); + send(res, 200, uuid ? {success: true, uuid} : {success: false}); + return; + } + case "GET /crossdomain.xml": + send(res, 200, CROSS_DOMAIN, "text/xml"); + return; + case "GET /gameClient/game/index.html": + // not to be put in a frame of anyone's; the client shows it in a view of its own. + res.setHeader("X-Frame-Options", "DENY"); + res.setHeader("Referrer-Policy", "no-referrer"); + send(res, 200, await fs.promises.readFile(path.join(config.publicDir, "game.html")), MIME[".html"]); + return; + } + + if (req.method !== "GET" && req.method !== "HEAD") { + console.log(`[http] unhandled ${route}`); + send(res, 404, {error: "not_found"}); + return; + } + + if (config.logPackets) { + console.log(`[http] GET ${url.pathname}`); + } + + // asset SWFs import their fonts from this fixed path next to the game page; + // the launcher ships its own copy. + if (url.pathname === "/gameClient/sharedFonts.swf") { + send(res, 200, await fs.promises.readFile(config.sharedFontsSwf), MIME[".swf"]); + return; + } + + // the patched client is served in place of the CDN's own copy. + if (url.pathname.endsWith("/ajclient.swf")) { + send(res, 200, await fs.promises.readFile(config.clientSwf), MIME[".swf"]); + return; + } + + // A painting, by its id (MasterpieceFileServer). + const painting = PAINTING_PATH.exec(url.pathname); + if (painting) { + const playingFrom = account => { + const session = world.findOnline(account.username); + return session ? limits.key(session.address) : null; + }; + const picture = masterpieces.mayView(painting[1], from.key, playingFrom) || from.local ? masterpieces.image(painting[1]) : null; + send(res, picture ? 200 : 404, picture || "Not found", picture ? MIME[".jpg"] : "text/plain"); + return; + } + + const relPath = decodeURIComponent(url.pathname).replace(/^\/+/, ""); + if (relPath === HUD_ASSETS_PATH) { + send(res, 200, await fs.promises.readFile(config.hudAssetsSwf), MIME[".swf"]); + return; + } + // the name tag badges of ours and the card's Bio tab, which the CDN has no file for. + const badgeMedia = badges.mediaFile(relPath) || badges.cardMedia(relPath); + if (badgeMedia) { + const body = await fs.promises.readFile(badgeMedia).catch(() => null); + send(res, body ? 200 : 404, body || "Not found", body ? MIME[".swf"] : "text/plain"); + return; + } + // the extra den music tracks, which the CDN does not have as files. + const extra = await extraMusic.asset(relPath); + if (extra) { + send(res, extra.body ? 200 : 404, extra.body || "Not found", extra.body ? extra.type : "text/plain"); + return; + } + const clientPack = await defpacks.clientPack(relPath); + if (clientPack) { + send(res, 200, clientPack, "application/octet-stream"); + return; + } + // A room file in a seasonal theme ("/roomDefs/theme_/...", see roomAsSeenBy in world.js) comes from that other build, + // or from the current one when the room did not exist yet back then. + const themed = THEMED_ROOM.exec(relPath); + const mayFetch = () => from.local || cacheMisses.allow(from.key); + const body = (themed && Object.values(config.themes).some(theme => theme.build === Number(themed[2])) && await cdn.get(`${themed[2]}/roomDefs/${themed[3]}`, mayFetch)) + || await cdn.get(themed ? `${themed[1]}/roomDefs/${themed[3]}` : relPath, mayFetch); + if (!body) { + console.log(`[http] 404 ${url.pathname}`); + send(res, 404, "Not found", "text/plain"); + return; + } + res.setHeader("Cache-Control", "public, max-age=86400"); + send(res, 200, body, MIME[path.extname(relPath).toLowerCase()] || "application/octet-stream"); +}; + +const start = () => new Promise((resolve, reject) => { + const onRequest = (req, res) => { + handle(req, res).catch(err => { + console.log(`[http] ${req.method} ${req.url} failed: ${err.message}`); + if (!res.headersSent) { + send(res, 500, {error: "server_error"}); + } + else { + res.destroy(); + } + }); + }; + const server = config.webTls + ? https.createServer({cert: fs.readFileSync(config.webTls.certFile), key: fs.readFileSync(config.webTls.keyFile)}, onRequest) + : http.createServer(onRequest); + // nobody gets to hold a request open by trickling it in, nor a reply by + // never reading it; and there is an end to how many connections there + // may be, in all and from one address. + server.requestTimeout = 30000; + server.headersTimeout = 15000; + server.timeout = config.httpSocketTimeoutMs; + server.maxConnections = config.maxHttpConnections; + const open = new Map(); // address, as limits count it -> connections + server.on("connection", socket => { + const address = limits.key(socket.remoteAddress); + // behind a proxy every connection is the proxy's own. + if (limits.isLoopback(socket.remoteAddress)) { + return; + } + const count = (open.get(address) || 0) + 1; + if (count > config.maxHttpConnectionsPerAddress) { + socket.destroy(); + return; + } + open.set(address, count); + socket.once("close", () => { + const left = open.get(address) - 1; + if (left > 0) { + open.set(address, left); + } + else { + open.delete(address); + } + }); + }); + server.once("error", reject); + server.listen(config.httpPort, config.bindAddress, () => { + console.log(`[http] listening on ${config.bindAddress}:${config.httpPort}${config.webTls ? " (TLS)" : ""}`); + resolve(server); + }); +}); + +module.exports = {start}; diff --git a/lib/items.js b/lib/items.js new file mode 100644 index 0000000..a3972e6 --- /dev/null +++ b/lib/items.js @@ -0,0 +1,167 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const achievements = require("./achievements.js"); +const defpacks = require("./defpacks.js"); +const {CURRENCIES, MAX_ITEMS, MAX_WORN, activeAvatar, addClothing, sendClothingAdded, sendClothingRemoved, resolvePurchase} = require("./player.js"); + +// clothing: buying, wearing and recycling (client side: ItemXtCommManager). + +const DEF_ITEM = 1000; +const DEF_DIAMOND = 1054; +const DEF_COMBINED_LIST = 1060; +const DEF_CURRENCY_EXCHANGE = 1051; +const SHOP_TYPES = [DEF_ITEM, DEF_DIAMOND, DEF_COMBINED_LIST]; // kinds of shop that sell clothing +const TYPE_CLOTHING = "1"; +const LAYER_PATTERN = "2"; +const LAYER_EYES = "3"; +const MAX_RECYCLED_AT_ONCE = 500; +const MAX_USED_AT_ONCE = 200; // pieces put on or taken off in one message +const RECYCLE_FRACTION = 0.3; // matches recyclePercentage sent at login + +module.exports = ({others, sendItemList}) => { + // ItemXtCommManager.itemBuyResponse: [status, shopId, newAmount, currencyType] + const buyFailed = (session, shopId) => session.sendXt("ib", -1, 0, shopId, "", 0); + + return { + // shop.requestItemBuy: [shopId, 1, defId, colorIndex, isDiamondItem, + // denItemInvIdx, username]. for an item priced in diamonds defId is its + // diamond def's id. + ib(session, roomId, [shopId, , defId, colorIndex, isDiamondItem]) { + const {account} = session; + const purchase = resolvePurchase(defId, isDiamondItem === "1", "clothing", id => { + const own = defpacks.itemDef(id); + return {cost: own ? Number(own.value) : 0, currencyType: own ? Number(own.currencyType) : -1}; + }); + const def = purchase && defpacks.itemDef(purchase.defId); + const colors = def ? String(def.colors).split(",") : []; + const currency = purchase && CURRENCIES[purchase.currencyType]; + // only clothing bought with a single currency is supported; combined + // costs are refused. + if (!SHOP_TYPES.includes(defpacks.listType(shopId)) || !def || def.type !== TYPE_CLOTHING + || !currency || !/^\d{1,3}$/.test(colorIndex) || colors[colorIndex] === undefined || account.items.length >= MAX_ITEMS + || (account.currency[currency] || 0) < purchase.cost) { + buyFailed(session, shopId); + return; + } + account.currency[currency] -= purchase.cost; + achievements.currencyChanged(account, currency, -purchase.cost); + achievements.add(account, achievements.VARS.clothesBought); + const item = addClothing(account, def.id, colors[colorIndex]); + accounts.save(); + sendClothingAdded(session, item); + session.sendXt("ib", -1, 1, shopId, account.currency[currency], purchase.currencyType); + }, + + // ItemXtCommManager.requestItemUse: [onCount, offCount, ...invIdxOn, ...invIdxOff] + // for the animal in use. eyes and patterns are sent as minus their def id. + iu(session, roomId, params) { + const {account} = session; + const onCount = Number(params[0]); + const offCount = Number(params[1]); + const ids = params.slice(2).map(Number); + if (!Number.isInteger(onCount) || !Number.isInteger(offCount) || onCount < 0 || offCount < 0 + || ids.length !== onCount + offCount || ids.length > MAX_USED_AT_ONCE || !ids.every(Number.isInteger)) { + session.sendXt("iu", -1, 0); + return; + } + const avatar = activeAvatar(account); + // for "!outfit undo" (lib/commands.js). + account.outfitUndo = {avInvId: avatar.avInvId, items: account.items.filter(item => item.on.includes(avatar.avInvId)).map(item => item.inv)}; + // returns the item's def id when the change was one this player can make. + const setWorn = (invIdx, worn) => { + if (invIdx < 0) { + const def = defpacks.itemDef(-invIdx); + if (def && def.layerId === LAYER_EYES && worn) { + avatar.eyes = -invIdx; + } + else if (def && def.layerId === LAYER_PATTERN && (worn || avatar.pattern === -invIdx)) { + avatar.pattern = worn ? -invIdx : 0; + } + return def ? -invIdx : null; + } + const item = account.items.find(candidate => candidate.inv === invIdx); + if (item) { + item.on = item.on.filter(avInvId => avInvId !== avatar.avInvId); + // no more than MAX_WORN on one animal: what is over stays off. + if (worn && account.items.filter(candidate => candidate.on.includes(avatar.avInvId)).length >= MAX_WORN) { + return null; + } + if (worn) { + item.on.push(avatar.avInvId); + } + } + return item ? item.def : null; + }; + const off = ids.slice(onCount).filter(invIdx => setWorn(invIdx, false) !== null); + const on = ids.slice(0, onCount).map(invIdx => [invIdx, setWorn(invIdx, true)]).filter(([, def]) => def !== null); + accounts.save(); + // ItemXtCommManager.itemUseResponse + session.sendXt("iu", -1, 1); + // the reply only closes the editor. the animal in the room is redrawn + // from this: itemsChangedListResponse, "3" = what is worn changed, + // [3, inUse, perUserAvId, username, colour, onCount, offCount, + // (invIdx, defId)..., offInvIdx...]. without it the player goes on + // seeing the old outfit until the next room. + session.sendXt("il", -1, 3, 1, avatar.perUserAvId, account.username, 0, on.length, off.length, ...on.flat(), ...off); + for (const other of others(session)) { + sendItemList(other, session, false); + } + }, + + // shop.requestCurrencyExchange: [shopId, exchangeDefId], one of the deals + // in the currency exchange defPack (gems for tickets, diamonds for gems). + // the reply (currencyExchangeResponse -> Shop.confirmPurchase) is + // [status, new amount of the currency paid with]; the currency received + // gets its own update. + ce(session, roomId, [shopId, defId]) { + const {account} = session; + const def = defpacks.exchangeDef(defId); + const paid = def && CURRENCIES[def.costType]; + const received = def && CURRENCIES[def.resultType]; + if (defpacks.listType(shopId) !== DEF_CURRENCY_EXCHANGE || !paid || !received || (account.currency[paid] || 0) < def.cost) { + session.sendXt("ce", -1, 0, 0); + return; + } + account.currency[paid] -= def.cost; + account.currency[received] = (account.currency[received] || 0) + def.result; + achievements.currencyChanged(account, paid, -def.cost); + achievements.currencyChanged(account, received, def.result); + accounts.save(); + // ItemXtCommManager.currencyUpdateResponse: [currencyType, newAmount, reason] + session.sendXt("cu", -1, def.resultType, account.currency[received], 0); + session.sendXt("ce", -1, 1, account.currency[paid]); + }, + + // ItemXtCommManager.requestItemRecycle: [invIdx, ...]. the reply + // (itemRecycleResponse) is [count, newGemTotal, ...recycledInvIdx], and + // the recycling window then waits, behind its spinner, for the item + // list to change (ItemXtCommManager.checkIlCallbacks). + ir(session, roomId, params) { + const {account} = session; + const recycled = []; + for (const invIdx of new Set(params.slice(0, MAX_RECYCLED_AT_ONCE).map(Number))) { + const index = account.items.findIndex(item => item.inv === invIdx); + if (index === -1) { + continue; + } + const def = defpacks.itemDef(account.items[index].def); + const refund = def ? Number(def.recycleValue) || Math.floor(Number(def.value) * RECYCLE_FRACTION) : 0; + if (def && def.currencyType === "0") { + account.currency.gems = (account.currency.gems || 0) + refund; + achievements.currencyChanged(account, "gems", refund); + } + account.items.splice(index, 1); + recycled.push(invIdx); + } + accounts.save(); + session.sendXt("ir", -1, recycled.length, account.currency.gems || 0, ...recycled); + if (recycled.length) { + sendClothingRemoved(session, recycled); + for (const other of others(session)) { + sendItemList(other, session, false); + } + } + }, + }; +}; diff --git a/lib/limits.js b/lib/limits.js new file mode 100644 index 0000000..b6d8602 --- /dev/null +++ b/lib/limits.js @@ -0,0 +1,137 @@ +"use strict"; + +const config = require("../config.js"); + +// small in-memory rate limits for the parts of the server that strangers can +// reach: logins, sign-ups, error reports and the game socket; and who a web +// request is from. + +const LOOPBACK = ["127.0.0.1", "::1"]; +const MAX_KEYS = 100000; +const MAX_KEY_LENGTH = 64; + +// an address as limits count it. an IPv4 address is itself (also when it +// arrives written as an IPv6 one, "::ffff:1.2.3.4"). an IPv6 address is its +// first four groups, the /64: that is what one customer is given, and all +// 2^64 addresses in it are theirs to use. +const key = address => { + const text = String(address || "").replace(/^::ffff:(?=\d+\.\d+\.\d+\.\d+$)/i, "").toLowerCase(); + if (!text.includes(":")) { + return text.slice(0, MAX_KEY_LENGTH); + } + const [head, tail = ""] = text.split("%")[0].split("::"); + const front = head ? head.split(":") : []; + const back = tail ? tail.split(":") : []; + const groups = text.includes("::") ? [...front, ...Array(Math.max(0, 8 - front.length - back.length)).fill("0"), ...back] : front; + return groups.slice(0, 4).map(group => group.replace(/^0+(?=.)/, "")).join(":").slice(0, MAX_KEY_LENGTH); +}; + +const isLoopback = address => LOOPBACK.includes(String(address || "").replace(/^::ffff:/i, "")); + +// is this address the server's own machine, and does that count for +// anything here? (It must not when a local reverse proxy forwards everyone.) +const isTrustedLocal = address => config.trustLocalRequests && isLoopback(address); + +// who a web request is from: {address, key, local, direct}. +// address the visitor's, for showing (the last hop a trusted proxy +// reports, else the connection's own) +// key the same as limits count it (above) +// direct it came from this machine and through no proxy: somebody at +// the server itself, or an SSH tunnel to it +// local direct, and requests from this machine are trusted (config) +// A request that carries a forwarding header came through a proxy or a +// tunnel, whatever else is set, and is never taken for this machine's own. +const clientOf = req => { + const own = String(req.socket.remoteAddress || "").replace(/^::ffff:/i, ""); + const forwarded = req.headers["x-forwarded-for"] || req.headers.forwarded || req.headers["cf-connecting-ip"] || req.headers["x-real-ip"]; + const hops = String(req.headers["x-forwarded-for"] || "").split(",").map(hop => hop.trim()).filter(Boolean); + const address = config.trustedProxy && isLoopback(own) && hops.length ? hops[hops.length - 1].replace(/^::ffff:/i, "").slice(0, 60) : own; + const direct = isLoopback(own) && !forwarded; + return {address, key: key(address), direct, local: direct && config.trustLocalRequests}; +}; + +// the names this server answers to: what a Host header, or the Origin of a +// request that changes something, may say. A page from anywhere else that +// got a browser to send a request here (DNS rebinding, a cross-site form) +// names another. +const ownHosts = (() => { + const base = new URL(config.baseUrl); + const site = new URL(config.siteUrl); + const names = new Set([base.host, base.hostname, site.host, site.hostname]); + for (const name of ["127.0.0.1", "localhost", "[::1]", config.bindAddress, config.host]) { + names.add(`${name}:${config.httpPort}`); + } + return names; +})(); +// an SSH tunnel to the server (`ssh -L :127.0.0.1:8080`) arrives on +// this machine's loopback with no forwarding header, under a loopback name +// and whatever port its far end chose: that is the server's own too. +const TUNNEL_HOST = /^(?:127\.0\.0\.1|localhost|\[::1\]):\d{1,5}$/; +const throughTunnel = req => TUNNEL_HOST.test(String(req.headers.host || "").toLowerCase()) && clientOf(req).direct; +const hostAllowed = req => ownHosts.has(String(req.headers.host || "").toLowerCase()) || throughTunnel(req); +// A request that changes something must come from this server's own pages. +// one with no Origin is not a browser's cross-site request. +const originAllowed = req => { + const {origin} = req.headers; + if (!origin) { + return true; + } + try { + const from = new URL(origin).host; + // through a tunnel only the page of that very address: another page on + // this computer's loopback, on another port, is another site. + return ownHosts.has(from) || (throughTunnel(req) && from === String(req.headers.host).toLowerCase()); + } + catch (err) { + return false; + } +}; + +// allows `max` events per `windowMs` for each key. +const limiter = (max, windowMs) => { + const events = new Map(); // key -> timestamps inside the window + const named = name => String(name).slice(0, MAX_KEY_LENGTH); + const recent = name => (events.get(named(name)) || []).filter(time => time > Date.now() - windowMs); + const timer = setInterval(() => { + for (const name of events.keys()) { + if (recent(name).length === 0) { + events.delete(name); + } + } + }, Math.max(windowMs, 10000)); + timer.unref(); + return { + blocked: name => recent(name).length >= max, + record(name) { + const times = [...recent(name), Date.now()]; + // full: the keys longest in the table make room, a few at a time. + // (Emptying it would let whoever filled it start afresh.) + if (!events.has(named(name)) && events.size >= MAX_KEYS) { + let dropped = 0; + for (const oldest of events.keys()) { + events.delete(oldest); + if (++dropped >= 100) { + break; + } + } + } + events.delete(named(name)); // so that it counts as the newest + events.set(named(name), times.slice(-max)); + }, + allow(name) { + if (this.blocked(name)) { + return false; + } + this.record(name); + return true; + }, + }; +}; + +// sign-ups from one address, shared by the /register page and the client's +// Create Account screens. `trusted` is for a request already known to be +// this machine's own. +const registrations = limiter(config.registrationsPerHour, 3600000); +const registrationAllowed = (address, trusted = false) => trusted || registrations.allow(key(address)); + +module.exports = {limiter, key, isLoopback, isTrustedLocal, clientOf, hostAllowed, originAllowed, registrationAllowed}; diff --git a/lib/log.js b/lib/log.js new file mode 100644 index 0000000..21c5417 --- /dev/null +++ b/lib/log.js @@ -0,0 +1,33 @@ +"use strict"; + +// keeps the most recent lines the server printed, for the admin panel's log +// view. requiring this module is what starts the capture. + +const MAX_LINES = 5000; +const MAX_LINE_LENGTH = 2000; + +const lines = []; // {id, time, text} +let nextId = 1; + +const capture = original => (...args) => { + original(...args); + const text = args.map(arg => (typeof arg === "string" ? arg : String(arg && arg.stack ? arg.stack : JSON.stringify(arg)))).join(" "); + for (const line of text.split("\n")) { + lines.push({id: nextId++, time: Date.now(), text: line.slice(0, MAX_LINE_LENGTH)}); + } + if (lines.length > MAX_LINES) { + lines.splice(0, lines.length - MAX_LINES); + } +}; + +console.log = capture(console.log.bind(console)); +console.error = capture(console.error.bind(console)); + +// lines newer than id `after` whose text contains `filter` (any case), newest +// `limit` of them, oldest first. +const recent = (after = 0, filter = "", limit = 500) => { + const wanted = filter.toLowerCase(); + return lines.filter(line => line.id > after && (!wanted || line.text.toLowerCase().includes(wanted))).slice(-limit); +}; + +module.exports = {recent, count: () => nextId - 1}; diff --git a/lib/manage.js b/lib/manage.js new file mode 100644 index 0000000..67d7f0d --- /dev/null +++ b/lib/manage.js @@ -0,0 +1,589 @@ +"use strict"; + +const crypto = require("crypto"); +const fs = require("fs"); +const path = require("path"); +const accounts = require("./accounts.js"); +const config = require("../config.js"); +const limits = require("./limits.js"); +const achievements = require("./achievements.js"); +const badges = require("./badges.js"); +const bans = require("./bans.js"); +const captcha = require("./captcha.js"); +const chatlog = require("./chatlog.js"); +const erase = require("./erase.js"); +const masterpieces = require("./masterpieces.js"); +const defpacks = require("./defpacks.js"); +const support = require("./support.js"); +const totp = require("./totp.js"); +const world = require("./world.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 +// password; that sets a cookie only this page's requests send back +// (HttpOnly, SameSite=Strict, Path=/account). sessions live in memory, so +// restarting the server signs everyone out of the page (not out of the game). +// +// A locked account can still sign in here: this is where it is unlocked. +// +// A banned account, or anyone signing in from a banned address, gets another +// page altogether: what the ban is and why, one appeal, and the way out +// (signing out, or deleting the account). the password and two-step sign-in +// stay within reach, in case the account is in other hands. nothing else of +// the account is sent or may be changed until the ban is over. + +const COOKIE = "ajc_account"; +// A device that gave its two-step code keeps this for 30 days (lib/totp.js). +const DEVICE_COOKIE = "ajc_device"; +const SESSION_HOURS = 12; +const TEN_MINUTES_MS = 600000; +const MAX_NOTE = 120; + +// wrong passwords before further tries from an address are refused for a +// while, as for the launcher's sign-in (lib/http.js). +const failuresByAddress = limits.limiter(config.failedLoginsPerTenMinutes, TEN_MINUTES_MS); +// the password is asked for again before the changes that matter. A page +// left open, or one that fell into other hands, gets this many wrong tries +// at it and is then signed out. +const WRONG_PASSWORDS_ALLOWED = 5; +const wrongPasswords = limits.limiter(WRONG_PASSWORDS_ALLOWED, TEN_MINUTES_MS); +// what may be done from the page of a ban (above). +const BANNED_MAY = ["password", "twoStepStart", "twoStepConfirm", "twoStepOff", "forgetDevices", "delete", "appeal"]; +// and from the page of a rejected username: the same, with a new name in +// place of an appeal. +const RENAMING_MAY = ["password", "twoStepStart", "twoStepConfirm", "twoStepOff", "forgetDevices", "delete", "newName"]; +// things that write to the database, per account. +const writesPerTenMinutes = limits.limiter(60, TEN_MINUTES_MS); + +const sessions = new Map(); // SHA-256 of a session token -> {id: account id, expiry: ms} + +const sha256 = text => crypto.createHash("sha256").update(text).digest("hex"); + +const cookieToken = req => { + const match = new RegExp(`(?:^|;\\s*)${COOKIE}=([0-9a-f]{48})(?:;|$)`).exec(req.headers.cookie || ""); + return match ? match[1] : null; +}; + +const cookieHeader = (token, maxAgeSeconds, name = COOKIE) => + `${name}=${token}; Path=/account; HttpOnly; SameSite=Strict; Max-Age=${maxAgeSeconds}${config.secureCookies ? "; Secure" : ""}`; + +const deviceCookie = req => { + const match = new RegExp(`(?:^|;\\s*)${DEVICE_COOKIE}=([0-9a-f]{48})(?:;|$)`).exec(req.headers.cookie || ""); + return match ? match[1] : null; +}; + +const signedInAs = req => { + const token = cookieToken(req); + const session = token && sessions.get(sha256(token)); + return session && session.expiry > Date.now() ? accounts.byId(session.id) : null; +}; + +const signIn = (res, account, otherCookies = []) => { + for (const [hash, session] of sessions) { + if (session.expiry < Date.now()) { + sessions.delete(hash); + } + } + const token = crypto.randomBytes(24).toString("hex"); + sessions.set(sha256(token), {id: account.id, expiry: Date.now() + SESSION_HOURS * 3600000}); + res.setHeader("Set-Cookie", [cookieHeader(token, SESSION_HOURS * 3600), ...otherCookies]); +}; + +// ends the account's sessions on this page, all but the one making `req`. +const signOutOthers = (account, req) => { + const keep = req && cookieToken(req) ? sha256(cookieToken(req)) : null; + for (const [hash, session] of sessions) { + if (session.id === account.id && hash !== keep) { + sessions.delete(hash); + } + } +}; + +const twoStepOf = account => ({on: totp.isOn(account), since: account.totp ? account.totp.since : null, + recoveryLeft: account.totp ? account.totp.recovery.length : 0, devices: totp.freshDevices(account).length, deviceDays: totp.DEVICE_DAYS}); + +// the ban in the way of this account from where it is asked about: its own, +// or else the one on that address. {kind, permanent, seconds, reason, +// since, addressKey}, or null. +const banFor = (account, from) => { + const own = world.moderation.banOf(account); + if (own) { + return {kind: "account", permanent: own.seconds === world.moderation.PERMANENT, seconds: own.seconds, reason: own.reason, since: own.since, addressKey: ""}; + } + const address = bans.addressBan(from.address); + return address ? {kind: "address", permanent: true, seconds: world.moderation.PERMANENT, reason: address.reason, since: address.createdAt, addressKey: address.key} : null; +}; + +// all the page of a ban is given. +const bannedProfile = (account, ban) => { + const appeal = bans.appealOf(account); + return { + username: account.username, + banned: {kind: ban.kind, permanent: ban.permanent, seconds: ban.seconds, reason: ban.reason, since: ban.since}, + appeal: appeal && {createdAt: appeal.createdAt, text: appeal.text, status: appeal.status, reply: appeal.reply, handledAt: appeal.handledAt}, + appealLimit: bans.MAX_APPEAL, + twoStep: twoStepOf(account), + }; +}; + +const profile = (account, from) => { + const ban = banFor(account, from); + if (ban) { + return bannedProfile(account, ban); + } + // A rejected username (lib/moderation.js): a new one before anything else. + if (account.nameRejected) { + return {username: account.username, banned: null, nameRejected: true, twoStep: twoStepOf(account)}; + } + const avatar = account.avatars.find(candidate => candidate.perUserAvId === account.activeAvatar) || account.avatars[0]; + return { + username: account.username, + createdAt: account.createdAt, + lastSeen: account.lastSeen || account.lastLogin || null, + online: Boolean(world.findOnline(account.username)), + logins: account.numLogins || 0, + animals: account.avatars.length, + animalType: avatar ? avatar.type : null, + items: account.items.length, + denItems: account.denItems.length, + pets: account.pets.length, + buddies: account.buddies.length, + banned: null, + locked: account.locked, + twoStep: twoStepOf(account), + discord: account.discord, + bio: account.bio, + bioLimit: badges.MAX_BIO, + badges: badges.of(account).map(badge => badge.label), + features: Object.fromEntries(accounts.FEATURES.map(name => [name, accounts.featureOn(account, name)])), + history: account.logins, + denVisits: account.denVisits, + trades: account.tradeHistory, + buddyList: account.buddies.map(key => { + const buddy = accounts.byName(key); + return {name: buddy ? buddy.username : key, online: Boolean(buddy && world.findOnline(buddy.username)), note: account.buddyNotes[key] || ""}; + }).sort((one, other) => one.name.localeCompare(other.name)), + blocked: account.blocked.map(key => (accounts.byName(key) || {username: key}).username).sort(), + achievements: achievements.progress(account), + offers: {incoming: world.tradeOffers.incoming(account), outgoing: world.tradeOffers.outgoing(account)}, + nameRequests: support.nameRequestsOf(account), + feedback: support.feedbackOf(account), + }; +}; + +// everything kept about the account, for its owner to take away: the +// account as it is stored, without what would let someone in (the password's +// hash, the 2FA secret, device passes), and what other tables hold of it. +// what others wrote about it (reports, a moderator's notes) is not theirs +// to be handed, and is not here. +const SECRET_FIELDS = ["salt", "hash", "totp", "totpSetup", "devices"]; +const dataOf = account => ({ + exportedAt: new Date().toISOString(), + server: config.baseUrl, + account: {...Object.fromEntries(Object.entries(account).filter(([field]) => !SECRET_FIELDS.includes(field))), twoStepOn: totp.isOn(account)}, + chat: chatlog.saidBy(account), + banRecord: bans.historyOf(account), + appeal: bans.appealOf(account), + usernameRequests: support.nameRequestsOf(account), + feedback: support.feedbackOf(account), + paintings: masterpieces.madeBy(account), +}); + +const NAME_ERRORS = { + invalid_username: "3 to 20 letters, digits, spaces, dots or dashes, with at least three letters.", + username_taken: "Username taken.", + name_not_allowed: "That name is not allowed.", + same_name: "That is already your username.", +}; +const OFFER_ERRORS = { + unavailable: "You cannot trade with them.", + not_listed: "No longer on their trade list.", + nothing: "Pick something to give.", + not_yours: "You no longer have one of those.", + too_many: "Too many offers waiting.", +}; +const FEEDBACK_ERRORS = { + empty: "Write something first.", + unknown_kind: "Pick feedback or a bug report.", + too_many: "Too many today. Try tomorrow.", +}; + +// is `password` the account's own? A wrong one counts, and after a few the +// page is signed out (the caller of `act` sees to that). +const passwordAgain = (account, password) => { + if (wrongPasswords.blocked(account.id)) { + return false; + } + const right = accounts.authenticate(account.username, password) === account; + if (!right) { + wrongPasswords.record(account.id); + } + return right; +}; + +// one change to the signed-in account. returns {ok: text} or {error: text}. +const act = (account, body, req, from, res) => { + const ban = banFor(account, from); + if (ban && !BANNED_MAY.includes(body.action)) { + return {error: "Not while banned."}; + } + if (!ban && account.nameRejected && !RENAMING_MAY.includes(body.action)) { + return {error: "Choose a new username first."}; + } + switch (body.action) { + // in place of a rejected username, at once and under the sign-up rules. + case "newName": { + if (!account.nameRejected || ban) { + return {error: "Your username was not rejected."}; + } + const wanted = typeof body.newName === "string" ? body.newName.trim() : ""; + if (wanted.toLowerCase() === account.username.toLowerCase()) { + return {error: NAME_ERRORS.same_name}; + } + world.disconnect(account); + const problem = accounts.rename(account, wanted); + if (problem) { + return {error: NAME_ERRORS[problem] || NAME_ERRORS.invalid_username}; + } + delete account.nameRejected; + accounts.save(); + console.log(`[account] a rejected username was replaced by "${account.username}" from ${from.address}`); + return {ok: "Saved."}; + } + // one for each account, ever: an answer that wants a follow-up says + // where to go with it. + case "appeal": { + if (!ban) { + return {error: "You are not banned."}; + } + const result = bans.appeal(account, body.text, ban.addressKey); + return result.error ? {error: result.error === "empty" ? "Write something first." : "Already appealed."} : {ok: "Sent."}; + } + case "password": { + // asked for again: a page left open is not enough to take an account over. + if (!passwordAgain(account, body.current)) { + return {error: "Wrong password."}; + } + if (accounts.setPassword(account, body.password)) { + return {error: "Passwords need 10 characters or more, with a capital letter, a small letter and a digit."}; + } + world.moderation.actions.kick(account); + signOutOthers(account, req); + console.log(`[account] "${account.username}" changed their password from ${from.address}`); + return {ok: "Password changed."}; + } + case "requestName": { + const result = support.requestName(account, body.newName, body.reason); + return result.error ? {error: NAME_ERRORS[result.error]} : {ok: `Requested "${result.request.newName}".`}; + } + case "withdrawName": + return support.withdrawNameRequest(account) ? {ok: "Withdrawn."} : {error: "No request waiting."}; + case "feedback": { + const result = support.sendFeedback(account, String(body.kind), body.text); + return result.error ? {error: FEEDBACK_ERRORS[result.error]} : {ok: body.kind === "bug" ? "Bug report sent." : "Feedback sent."}; + } + case "lock": { + account.locked = body.locked === true; + if (account.locked) { + // out of the game now, and no saved sign-in gets back in. + accounts.revokeTokens(account); + world.moderation.actions.kick(account); + } + accounts.save(); + console.log(`[account] "${account.username}" ${account.locked ? "locked" : "unlocked"} from ${from.address}`); + return {ok: account.locked ? "Locked." : "Unlocked."}; + } + case "feature": { + if (!accounts.FEATURES.includes(body.feature) || typeof body.on !== "boolean") { + return {error: "Unknown setting."}; + } + account.features[body.feature] = body.on; + accounts.save(); + return {ok: "Saved."}; + } + // two-step sign-in (lib/totp.js). turning it on: the password again, + // then a secret for their authenticator app, then a code from the app + // to show it took. saved sign-ins end, so every device passes it once. + case "twoStepStart": { + if (totp.isOn(account)) { + return {error: "2FA is already on."}; + } + if (!passwordAgain(account, body.current)) { + return {error: "Wrong password."}; + } + const setup = totp.begin(account); + accounts.save(); + return {ok: "Scan the code.", setup}; + } + case "twoStepConfirm": { + const recovery = totp.confirm(account, body.code); + if (!recovery) { + accounts.save(); + return {error: "Wrong code."}; + } + accounts.revokeTokens(account); + accounts.save(); + console.log(`[account] "${account.username}" turned two-step sign-in on from ${from.address}`); + return {ok: "2FA is on.", recovery}; + } + // turning it off: the password and a code (or a recovery code). + case "twoStepOff": { + if (!totp.isOn(account)) { + return {error: "2FA is not on."}; + } + if (!passwordAgain(account, body.current)) { + return {error: "Wrong password."}; + } + if (!totp.verify(account, String(body.code || ""))) { + accounts.save(); + return {error: "Wrong code."}; + } + totp.turnOff(account); + accounts.save(); + res.setHeader("Set-Cookie", cookieHeader("", 0, DEVICE_COOKIE)); + console.log(`[account] "${account.username}" turned two-step sign-in off from ${from.address}`); + return {ok: "2FA is off."}; + } + case "forgetDevices": + totp.forgetDevices(account); + accounts.save(); + return {ok: "Trusted devices forgotten."}; + // their bio, for the Bio tab of their card in the game. empty takes it off. + case "bio": { + // typed words others read: not while they cannot chat. + if (world.moderation.isSilenced(account)) { + return {error: "You cannot change your bio while silenced."}; + } + const bio = badges.bioText(body.text); + if (bio === null) { + return {error: `At most ${badges.MAX_BIO} characters on ${badges.MAX_BIO_LINES} lines.`}; + } + account.bio = bio; + accounts.save(); + return {ok: bio ? "Saved." : "Removed."}; + } + // their Discord username, for their card in the game. empty takes it off. + case "discord": { + const name = badges.discordName(body.name); + if (name === null) { + return {error: "Not a Discord username."}; + } + account.discord = name; + accounts.save(); + return {ok: name ? "Saved." : "Removed."}; + } + // the player's own words about a buddy; only they see them. + case "buddyNote": { + const key = String(body.name || "").toLowerCase(); + if (!account.buddies.includes(key)) { + return {error: "Not a buddy."}; + } + const note = String(body.note || "").replace(/[\u0000-\u001f\u007f]/g, " ").trim().slice(0, MAX_NOTE); + if (note) { + account.buddyNotes[key] = note; + } + else { + delete account.buddyNotes[key]; + } + accounts.save(); + return {ok: "Saved."}; + } + // blocking and unblocking, as the game's own buttons do it. + case "block": + case "unblock": { + const target = accounts.byName(String(body.name || "").trim()); + if (!target || target === account) { + return {error: "No such player."}; + } + return world.setBlocked(account, target, body.action === "block") + ? {ok: body.action === "block" ? "Blocked." : "Unblocked."} + : {error: body.action === "block" ? "Already blocked, or your list is full." : "Not blocked."}; + } + // an offer for something on another player's trade list, left for them + // to answer on their own page. + case "offer": { + const problem = world.tradeOffers.make(account, accounts.byName(String(body.to || "").trim()), body.wanted, body.offered); + return problem ? {error: OFFER_ERRORS[problem]} : {ok: "Offer sent."}; + } + case "answerOffer": { + const problem = world.tradeOffers.answer(account, body.id, body.accept === true, world.refreshInventories); + return problem ? {error: problem === "gone" ? "That offer is no longer possible." : "No such offer."} + : {ok: body.accept === true ? "Traded." : "Declined."}; + } + case "withdrawOffer": + return world.tradeOffers.withdraw(account, String(body.to || ""), body.id) ? {ok: "Withdrawn."} : {error: "No such offer."}; + case "signOutEverywhere": + accounts.revokeTokens(account); + totp.forgetDevices(account); + accounts.save(); + world.moderation.actions.kick(account); + signOutOthers(account, req); + return {ok: "Signed out everywhere."}; + // for good: the password again, and the username typed out. + case "delete": { + if (!passwordAgain(account, body.current)) { + return {error: "Wrong password."}; + } + if (String(body.confirm || "").trim().toLowerCase() !== account.username.toLowerCase()) { + return {error: "Username does not match."}; + } + const name = account.username; + world.disconnect(account); + signOutOthers(account, null); + erase(account); + console.log(`[account] "${name}" deleted their account from ${from.address}`); + return {ok: "Account deleted.", deleted: true}; + } + default: + return {error: "Unknown action."}; + } +}; + +const PAGE_HEADERS = { + "Cache-Control": "no-store", + "X-Frame-Options": "DENY", + "X-Content-Type-Options": "nosniff", + "Referrer-Policy": "no-referrer", + "Content-Security-Policy": captcha.policy("default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; connect-src 'self'; img-src 'self' data:; font-src 'self'; " + + "form-action 'none'; frame-ancestors 'none'; base-uri 'none'"), +}; + +// A request that changes something must come from this server's own page. +const sameOrigin = limits.originAllowed; + +// `from` is {address, local}; `web` is {send, readJson} from lib/http.js. +const handle = async (req, res, url, from, web) => { + for (const [name, value] of Object.entries(PAGE_HEADERS)) { + res.setHeader(name, value); + } + const reply = (status, body) => web.send(res, status, body); + const route = `${req.method} ${url.pathname.replace(/\/$/, "") || "/account"}`; + + if (route === "GET /account") { + web.send(res, 200, captcha.withScriptVersion(await fs.promises.readFile(path.join(config.publicDir, "account.html"))), "text/html; charset=utf-8"); + return; + } + if (req.method === "POST" && !sameOrigin(req)) { + reply(403, {error: "forbidden"}); + return; + } + const body = req.method === "POST" ? await web.readJson(req) : {}; + + switch (route) { + case "POST /account/api/login": { + const key = String(body.username || "").trim().toLowerCase(); + if (!from.local && failuresByAddress.blocked(from.key)) { + reply(429, {error: "Too many attempts. Try later."}); + return; + } + // looked up first: with AJ_REGISTER=1 authenticate() would make the account. + const known = accounts.byName(key); + const captchaProblem = await captcha.check({captcha: body.captcha, captcha_pass: body.captchaPass}, from, "login", known); + if (captchaProblem) { + reply(captchaProblem === "captcha_unavailable" ? 503 : 401, {error: captcha.MESSAGES[captchaProblem], captcha: true}); + return; + } + const account = known && await accounts.authenticateAsync(known.username, body.password) === known ? known : null; + if (!account) { + failuresByAddress.record(from.key); + if (known) { + accounts.recordLogin(known, "web", from.address, false); + accounts.save(); + } + reply(401, {error: "Wrong username or password."}); + return; + } + // two-step sign-in: a code after the password, unless this browser + // gave one in the last 30 days (lib/totp.js). + const cookies = []; + if (totp.isOn(account) && !totp.deviceTrusted(account, deviceCookie(req))) { + if (!body.code) { + reply(401, {error: "Enter your 2FA code.", twoStep: true, captchaPass: captcha.issuePass(account, from)}); + return; + } + if (!totp.verify(account, String(body.code))) { + failuresByAddress.record(from.key); + accounts.recordLogin(account, "web", from.address, false); + accounts.save(); + reply(401, {error: "Wrong code.", twoStep: true, captchaPass: captcha.issuePass(account, from)}); + return; + } + if (body.rememberDevice === true) { + cookies.push(cookieHeader(totp.trustDevice(account, "web"), totp.DEVICE_DAYS * 86400, DEVICE_COOKIE)); + } + } + accounts.recordLogin(account, "web", from.address); + accounts.save(); + signIn(res, account, cookies); + reply(200, {ok: true}); + return; + } + case "POST /account/api/logout": { + const token = cookieToken(req); + if (token) { + sessions.delete(sha256(token)); + } + res.setHeader("Set-Cookie", cookieHeader("", 0)); + reply(200, {ok: true}); + return; + } + } + + const account = signedInAs(req); + if (!account) { + reply(401, {error: "Sign in first."}); + return; + } + switch (route) { + // A copy of their data, as a file. also from the page of a ban. + case "GET /account/api/export": + if (!writesPerTenMinutes.allow(account.id)) { + reply(429, {error: "Too many. Try later."}); + return; + } + res.setHeader("Content-Disposition", `attachment; filename="burrow-data-${account.id}.json"`); + web.send(res, 200, JSON.stringify(dataOf(account), null, 2)); + return; + case "GET /account/api/me": + reply(200, profile(account, from)); + return; + // for the trade offer form: what the player could give, and what + // another player has up for trade. + case "GET /account/api/tradable": { + if (banFor(account, from) || account.nameRejected) { + reply(403, {error: "Not now."}); + return; + } + const other = accounts.byName(url.searchParams.get("of") || ""); + reply(200, {mine: world.tradeOffers.owned(account), theirs: other && other !== account ? world.tradeOffers.listed(other) : [], + found: Boolean(other && other !== account)}); + return; + } + case "POST /account/api/act": { + if (!writesPerTenMinutes.allow(account.id)) { + reply(429, {error: "Too many changes. Try later."}); + return; + } + const result = act(account, body, req, from, res); + // too many wrong passwords on this page: it is signed out. + if (!result.deleted && wrongPasswords.blocked(account.id)) { + signOutOthers(account, null); + res.setHeader("Set-Cookie", cookieHeader("", 0)); + reply(401, {error: "Too many wrong passwords. Sign in again."}); + return; + } + if (result.deleted) { + res.setHeader("Set-Cookie", cookieHeader("", 0)); + } + reply(result.ok ? 200 : 400, result.ok && !result.deleted ? {...result, account: profile(account, from)} : result); + return; + } + default: + reply(404, {error: "not_found"}); + } +}; + +// called when an account's name changes or it is deleted: its page sessions end. +const forget = account => signOutOthers(account, null); + +module.exports = {handle, forget}; diff --git a/lib/masterpieces.js b/lib/masterpieces.js new file mode 100644 index 0000000..7994556 --- /dev/null +++ b/lib/masterpieces.js @@ -0,0 +1,333 @@ +"use strict"; + +const crypto = require("crypto"); +const fs = require("fs"); +const path = require("path"); +const config = require("../config.js"); +const accounts = require("./accounts.js"); +const limits = require("./limits.js"); + +// masterpieces: paintings from the Art Studio, framed and hung in a den +// (client side: game.artStudioPainting.ArtStudioPainting, the same in +// ArtStudioGridDrawing, masterpiece.MasterpieceDisplayItem, +// gui.MasterpiecePreview). +// +// how one comes about, in the client's order: +// 1. the game asks for an upload token over the game socket ("gmtkn"). +// 2. it posts the painting, a JPEG, with that token to the web server +// (the mdUrl flashvar + "mp") and is told the painting's id. +// 3. it buys the Masterpiece den item (diamond def 221) naming that id +// and the frame picked, for two diamonds or a Masterpiece Token. +// 4. the item is in the inventory but "not approved": the client will +// not place, trade or recycle it. whoever runs the server looks at it +// in the admin panel and approves or rejects it. (That review can be +// switched off there; paintings are then approved as they are bought.) +// Everyone's client fetches a painting from "masterpieces/" on the +// content server when it has to draw it. +// +// A painting lives here, in a table of its own: who made it and where it +// stands. the picture is a file, data/masterpieces/.jpg (the table's +// `image` column held it once, and is left empty now: pictures made the +// one file with every account in it many times its size). the den item made from it carries the painting's id +// (`image` on the den item, see lib/dens.js) and can change hands; the +// painting's maker stays who it was. + +const SCHEMA = ` + CREATE TABLE IF NOT EXISTS masterpieces ( + id TEXT PRIMARY KEY, + creator_id INTEGER NOT NULL, + created_at INTEGER NOT NULL, + status INTEGER NOT NULL, + frame INTEGER NOT NULL, + reviewed_at INTEGER, + likes TEXT NOT NULL, + image BLOB NOT NULL + ); +`; + +const UPLOADED = 0; // posted, not made into an item yet +const PENDING = 1; // an item, waiting to be looked at +const APPROVED = 2; + +const DEN_ITEM = 2725; // "Masterpiece" (DenItem.isCustom) +const TOKEN_DEN_ITEM = 2947; // "Masterpiece Token": pays for one in place of diamonds +const DIAMOND_DEF = 221; // what the Art Studio buys +// the frames, in the order the client numbers them (generic list 424; a +// masterpiece's den item "version" is an index into it), with each one's +// name string. they are media files; the order is ours, since the game's +// own list is gone, and must not change once masterpieces exist. +const FRAMES = [ + [4813, 25174], [4816, 25175], [4814, 25177], [4815, 25176], [4851, 25308], [4888, 25306], [4892, 25307], [4941, 25305], + [5688, 28858], [5733, 29009], [5780, 29304], [5948, 29967], [5949, 29968], [6075, 30265], [6077, 30266], [6170, 30375], + [6921, 31954], [7139, 32409], [7164, 32479], [7186, 32594], [7232, 32663], [7254, 32753], [7277, 32754], [7324, 32755], +]; +const LIST_FRAMES_OFFERED = 416; +const LIST_FRAMES_IN_ORDER = 424; + +const REVIEW_SETTING = "masterpiece_review"; // "0" = approve as they are bought +const MAX_IMAGE_BYTES = 2 * 1024 * 1024; +const TOKEN_MINUTES = 15; +const UNCLAIMED_MINUTES = 60; +const MAX_WAITING_PER_ACCOUNT = 30; // waiting to be looked at +const MAX_APPROVED_PER_ACCOUNT = 300; // on show, of one maker's +const MAX_SIDE = 4096; // pixels, either way +const NO_IMAGE = Buffer.alloc(0); +const folder = () => path.join(config.dataDir, "masterpieces"); +const fileOf = id => path.join(folder(), `${id}.jpg`); +const GALLERY_SPOTS = 12; // PartyManager.setupMasterpiecesInRoom + +const uploadsPerHour = limits.limiter(30, 3600000); +const now = () => Math.floor(Date.now() / 1000); +const db = () => accounts.database(); + +const known = new Map(); // id -> {id, creator, createdAt, status, frame, likes: [account ids]} +const tokens = new Map(); // upload token -> {account id, expires (ms)} + +const load = () => { + db().exec(SCHEMA); + fs.mkdirSync(folder(), {recursive: true}); + // pictures still in the table move out into files, once. + for (const row of db().prepare("SELECT id FROM masterpieces WHERE length(image) > 0").all()) { + const {image: picture} = db().prepare("SELECT image FROM masterpieces WHERE id = ?").get(row.id); + fs.writeFileSync(fileOf(row.id), Buffer.from(picture)); + db().prepare("UPDATE masterpieces SET image = ? WHERE id = ?").run(NO_IMAGE, row.id); + } + for (const row of db().prepare("SELECT id, creator_id, created_at, status, frame, likes FROM masterpieces").all()) { + known.set(row.id, {id: row.id, creator: row.creator_id, createdAt: row.created_at, status: row.status, frame: row.frame, likes: JSON.parse(row.likes)}); + } +}; + +const needsReview = () => accounts.setting(REVIEW_SETTING) !== "0"; +const setNeedsReview = on => accounts.setSetting(REVIEW_SETTING, on ? "1" : "0"); + +const forget = id => { + known.delete(id); + db().prepare("DELETE FROM masterpieces WHERE id = ?").run(id); + fs.rmSync(fileOf(id), {force: true}); +}; + +// paintings posted and never framed are thrown away after a while. +const sweep = () => { + for (const [token, entry] of tokens) { + if (entry.expires < Date.now()) { + tokens.delete(token); + } + } + for (const painting of [...known.values()]) { + if (painting.status === UPLOADED && painting.createdAt < now() - UNCLAIMED_MINUTES * 60) { + forget(painting.id); + } + } +}; +setInterval(() => { + try { + sweep(); + } + catch (err) { + console.error(`[masterpieces] sweep failed: ${err.message}`); + } +}, 600000).unref(); + +// A token for one upload by this account (step 1). +const issueToken = account => { + for (const [token, entry] of tokens) { + if (entry.account === account.id) { + tokens.delete(token); + } + } + const token = crypto.randomBytes(16).toString("hex"); + tokens.set(token, {account: account.id, expires: Date.now() + TOKEN_MINUTES * 60000}); + return token; +}; + +// is this a JPEG picture, whole and of a sane size? every viewer's game +// decodes it, so it is read through here first: the start mark, then one +// well-formed segment after another up to the picture data, among them a +// frame header saying how big it is, and the end mark last. +const looksLikeJpeg = image => { + if (image.length < 100 || image[0] !== 0xFF || image[1] !== 0xD8 || image[image.length - 2] !== 0xFF || image[image.length - 1] !== 0xD9) { + return false; + } + let at = 2; + let sized = false; + while (at + 4 <= image.length) { + if (image[at] !== 0xFF) { + return false; + } + const marker = image[at + 1]; + if (marker === 0xFF) { + at++; // padding between segments + continue; + } + const length = image.readUInt16BE(at + 2); + if (length < 2 || at + 2 + length > image.length) { + return false; + } + // start of frame: baseline, extended or progressive. [precision, height, width, ...] + if (marker >= 0xC0 && marker <= 0xC2) { + const height = image.readUInt16BE(at + 5); + const width = image.readUInt16BE(at + 7); + if (length < 8 || height < 1 || width < 1 || height > MAX_SIDE || width > MAX_SIDE) { + return false; + } + sized = true; + } + // start of scan: the picture data follows, to the end mark. + if (marker === 0xDA) { + return sized; + } + at += 2 + length; + } + return false; +}; + +// step 2. returns the new painting's id, or null when the token is not +// good, the picture is not a JPEG of a sane size, or the account has posted +// too many. +const upload = (token, image) => { + const entry = typeof token === "string" ? tokens.get(token) : null; + tokens.delete(token); + if (!entry || entry.expires < Date.now() || !Buffer.isBuffer(image) || image.length > MAX_IMAGE_BYTES || !looksLikeJpeg(image) + || !uploadsPerHour.allow(entry.account)) { + return null; + } + // one painting at a time is between the easel and the frame. + for (const painting of [...known.values()]) { + if (painting.creator === entry.account && painting.status === UPLOADED) { + forget(painting.id); + } + } + const painting = {id: crypto.randomUUID(), creator: entry.account, createdAt: now(), status: UPLOADED, frame: 0, likes: []}; + fs.writeFileSync(fileOf(painting.id), image); + db().prepare("INSERT INTO masterpieces (id, creator_id, created_at, status, frame, likes, image) VALUES (?, ?, ?, ?, ?, '[]', ?)") + .run(painting.id, painting.creator, painting.createdAt, painting.status, painting.frame, NO_IMAGE); + known.set(painting.id, painting); + return painting.id; +}; + +const setStatus = (painting, status) => { + painting.status = status; + db().prepare("UPDATE masterpieces SET status = ?, frame = ?, reviewed_at = ? WHERE id = ?") + .run(status, painting.frame, status === APPROVED ? now() : null, painting.id); +}; + +// may this account make an item of that painting, in that frame? (Step 3, +// before anything is paid.) +const claimable = (account, id, frame) => { + const painting = known.get(String(id)); + const mine = [...known.values()].filter(other => other.creator === account.id); + const waiting = mine.filter(other => other.status === PENDING).length; + const shown = mine.filter(other => other.status === APPROVED).length; + return Boolean(painting) && painting.creator === account.id && painting.status === UPLOADED + && Number.isInteger(frame) && frame >= 0 && frame < FRAMES.length && waiting < MAX_WAITING_PER_ACCOUNT && shown < MAX_APPROVED_PER_ACCOUNT; +}; + +// step 3, paid for: the painting is an item now. true when it is approved +// on the spot. +const claim = (id, frame) => { + const painting = known.get(String(id)); + painting.frame = frame; + setStatus(painting, needsReview() ? PENDING : APPROVED); + return painting.status === APPROVED; +}; + +const get = id => known.get(String(id)) || null; + +// the picture itself, or null. (Ids are the ones made here, so the file's +// name is never a visitor's to choose.) +const image = id => { + if (!known.has(String(id))) { + return null; + } + try { + return fs.readFileSync(fileOf(String(id))); + } + catch (err) { + return null; + } +}; + +// may the picture be handed to whoever asks at this address (as limits +// count addresses)? once approved, to anyone: every game that draws it asks +// for it. before that only to its maker, known by the address their game is +// connected from: a picture nobody has looked at is not something this +// server puts on show for the world at a link. `addressOf` gives the +// address an account is playing from, or null. +const mayView = (id, address, addressOf) => { + const painting = known.get(String(id)); + if (!painting) { + return false; + } + const maker = accounts.byId(painting.creator); + return painting.status === APPROVED || Boolean(maker && addressOf(maker) && addressOf(maker) === address); +}; + +const approve = id => { + const painting = get(id); + if (!painting || painting.status !== PENDING) { + return false; + } + setStatus(painting, APPROVED); + return true; +}; + +// is a den item fit to be shown, traded and recycled? anything that is not +// a painting is. +const itemApproved = item => !item.image || (known.has(item.image) && known.get(item.image).status === APPROVED); + +const creatorOf = id => { + const painting = get(id); + return painting ? accounts.byId(painting.creator) : null; +}; + +// the three fields that follow a den item wherever the client is told of +// one: the painting's id, and its maker's database id and uuid. +const itemFields = item => { + const maker = item.image ? creatorOf(item.image) : null; + return [item.image || "", maker ? maker.id : -1, maker ? maker.uuid : ""]; +}; + +// the like button of the preview window: one like an account. +const like = (id, account) => { + const painting = get(id); + if (!painting || painting.status !== APPROVED || painting.creator === account.id || painting.likes.includes(account.id)) { + return false; + } + painting.likes.push(account.id); + db().prepare("UPDATE masterpieces SET likes = ? WHERE id = ?").run(JSON.stringify(painting.likes), painting.id); + return true; +}; + +// what hangs in the Masterpiece Gallery party and on Jammer Central's +// board: approved paintings, the most liked first and the newest among +// equals ({pool, pluspool} of MasterpieceDisplayItem.initFromPool objects). +const gallery = () => { + const hung = [...known.values()].filter(painting => painting.status === APPROVED && creatorOf(painting.id)) + .sort((one, other) => other.likes.length - one.likes.length || other.createdAt - one.createdAt) + .slice(0, GALLERY_SPOTS * 2) + .map(painting => { + const maker = creatorOf(painting.id); + return {frameId: painting.frame, resourceId: painting.id, userName: maker.username, creatorDBId: maker.id, creatorId: maker.uuid}; + }); + return {pool: hung.slice(0, GALLERY_SPOTS), pluspool: hung.slice(GALLERY_SPOTS)}; +}; + +const list = status => [...known.values()].filter(painting => painting.status === status) + .sort((one, other) => other.createdAt - one.createdAt) + .map(painting => { + const maker = creatorOf(painting.id); + return {id: painting.id, creator: maker ? maker.username : "(deleted account)", createdAt: painting.createdAt, frame: painting.frame, likes: painting.likes.length}; + }); + +const madeBy = account => [...known.values()].filter(painting => painting.creator === account.id).map(painting => painting.id); + +// generic lists: (mediaId, name string id) pairs, or null when `listId` is +// not one of the frame lists (GenericListXtCommManager.handleMediaResponse). +const frameList = listId => + ([LIST_FRAMES_OFFERED, LIST_FRAMES_IN_ORDER].includes(Number(listId)) ? FRAMES.flat() : null); + +module.exports = { + load, issueToken, upload, claimable, claim, get, image, mayView, approve, forget, itemApproved, itemFields, creatorOf, like, gallery, list, frameList, + needsReview, setNeedsReview, madeBy, + PENDING, APPROVED, DEN_ITEM, TOKEN_DEN_ITEM, DIAMOND_DEF, MAX_IMAGE_BYTES, +}; diff --git a/lib/minigames.js b/lib/minigames.js new file mode 100644 index 0000000..0123582 --- /dev/null +++ b/lib/minigames.js @@ -0,0 +1,622 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const achievements = require("./achievements.js"); +const defpacks = require("./defpacks.js"); +const buddyGames = require("./buddygames.js"); +const masterpieces = require("./masterpieces.js"); +const dens = require("./dens.js"); +const limits = require("./limits.js"); +const {activeAvatar, addClothing, sendClothingAdded} = require("./player.js"); + +// minigames (client side: MinigameManager, MinigameXtCommManager and the +// game.* classes). the games themselves are compiled into the client; what +// the official server kept was the table saying which game def id is which +// game (the "game" defPack is gone from the CDN) and the session around a +// game: the room it runs in, the start signal, gem awards, and for some +// games a few messages of their own. +// +// lib/games.json is that table, put back together from what still names the +// ids: arcade-machine den items (gameDefId and a name), the room files (which +// id stands where), the names GameCardPopup has for each game class, and the +// achievement defs (which user vars a game counts in). entries: +// id game def id +// swf the game's key in game.IncludeMinigames +// title its name; sent as the id of the localization string that says so +// type 0 runs in a window over the room ("in-room"), 1 replaces the room +// vars user vars: games played, and two the game uses as it likes +// pet pet species the player must have out (the pet games) +// start what the game waits for after it says "ready": see START +// ready false: needs more from the server than is here yet; not playable +// tickets a carnival game: how many points of its score make one ticket +// icon media id of its picture in the HUD's Games window; the games with +// one are the ones that window lists +// buddy true: one of the eight games two players play from a player's +// card (lib/buddygames.js). their ids are ours: nothing in the +// client names them, and the official table is gone. +// card a buddy game's picture, on the card's game tab and in the +// invitation +// +// every other game is played alone (minPlayers = maxPlayers = 1): the +// multiplayer ones each have a protocol of their own between the players. + +const games = new Map(require("./games.json").map(game => [game.id, game])); + +const IN_ROOM = 0; +const MAX_GEMS_PER_AWARD = 5000; +const MAX_MASTERY_PER_AWARD = 100; +const MASTERY_FULL = 100; +const CURRENCY_GEMS = 0; +const CLAW_COST = 5; // gems a go +const CLAW_WIN_CHANCE = 0.4; +const SKY_HIGH_PRIZE_CHANCE = 0.5; +const SAFETY_QUIZ_PRIZE = 1179; // den item, SafetyQuiz.init +const TOUCH_POOL_PRIZES = [867, 869, 872, 868, 870, 871]; // den items, TouchPool.init +const LANG_ENG = 0; +const FALLBACK_TITLE = "Games"; +const MAX_INFO_REQUEST = 100; +// A game id the table does not have: it still gets its sign, and says +// "not ready" when clicked. +const UNKNOWN_GAME = {swf: "", title: FALLBACK_TITLE, type: 0, ready: false}; +const INVASION_WIN = 11; // MicroGameInvasion.keptItem +const CARNIVAL_COST = 5; // gems a go +const MAX_TICKETS_PER_GO = 300; +const CURRENCY_TICKETS = 1; +const INVASION_COST = 10; // gems a go, as the machine's own screen says + +const awardsPerMinute = limits.limiter(120, 60000); +const invitesPerMinute = limits.limiter(20, 60000); +const LEFT_NOTICE_DELAY_MS = 2500; +const GAME_PAINTING = 51; +const GAME_PIXEL_PAINTING = 139; +// marbles sends the shooter's aim four times a second; nothing needs more. +const messagesPerMinute = limits.limiter(900, 60000); + +// the "start" message a game waits for once it has said it is ready. +const START = { + seed: () => [serial()], + seedAndPlayers: game => [serial(), game.players.length], +}; + +// serial numbers the client mixes into its award messages; any number will do. +function serial() { + return 1 + Math.floor(Math.random() * 1000000); +} + +let nextGameRoomId = 500000; // well clear of the world's room ids + +module.exports = ({tell, leaveRoom, findOnline, blocks}) => { + // MinigameInfo.init, the 19 fields the "mi" reply carries for a game. + const info = game => [ + game.id, + // never 0: the client throws on a string it cannot find. + defpacks.stringId(game.title) || defpacks.stringId(FALLBACK_TITLE), + game.swf, // extName + game.swf, // swfName + game.buddy ? 2 : 1, game.buddy ? 2 : 1, // min and max players + 0, // max spectators + game.type, + // the game card: the title picture on the "play" popup (not known), and + // for a buddy game the picture in the invitation. + game.card || 0, + ...(game.vars || [0, 0, 0]), + game.buddy ? 1 : 0, // ready for player-versus-player: listed on players' cards + 1, // gem multiplier + game.pet || 0, + 0, // pro mode user var + 0, // leaderboard user var + game.icon || game.card || 0, // its picture in the Games window or on a card's game tab + 0, // required avatar type + ]; + + // an invitation to a buddy game that has not been answered: both players + // have {def, sender, target} as `invite`. dropping it tells the other + // side "no" (MinigameManager.pvpResponse: [gameDefId, 1]). + const dropInvite = (session, tellOther = true) => { + const {invite} = session; + if (!invite) { + return; + } + invite.sender.invite = invite.target.invite = null; + const other = invite.sender === session ? invite.target : invite.sender; + if (tellOther) { + other.sendXt("mp", -1, invite.def.id, 1); + } + }; + + // takes the player out of the game they are in, if any, and out of an + // invitation. + const leave = session => { + dropInvite(session); + const {game} = session; + if (!game) { + return; + } + session.game = null; + game.players = game.players.filter(player => player !== session); + // the games' own "player left": [sfsUserId]. A buddy game takes it for + // a win, so the one still looking at the result of a game that has been + // decided is not told. three of them only the clients know the end of + // (lib/buddygames.js), and at their end both players leave within a + // moment of each other: there the news waits a little, and reaches + // only a player who is still in the game by then. + const tellOthers = () => { + for (const other of game.players.filter(player => player.game === game)) { + other.sendXt("ml", game.roomId, session.id); + } + }; + if (!game.match) { + tellOthers(); + } + else if (!game.match.finished) { + setTimeout(() => { + try { + tellOthers(); + } + catch (err) { + console.error(`[minigames] could not tell of a player leaving: ${err.message}`); + } + }, LEFT_NOTICE_DELAY_MS).unref(); + } + }; + + // MinigameManager.startGame: [playerCount, sfsUserId..., then for each + // player an id and their username, then whatever the game adds], which + // the game reads as "ms". the id is the animal's (perUserAvId): the games + // that draw their players ask for that animal by it. + const start = game => { + game.started = true; + for (const player of game.players) { + player.sendXt("ms", game.roomId, game.players.length, ...game.players.map(other => other.id), + ...game.players.flatMap(other => [activeAvatar(other.account).perUserAvId, other.account.username]), + ...(game.startData || [])); + } + }; + + // RoomXtCommManager.roomJoinResponse for a game's own room: a temporary + // game room, which for a game that runs in a window is a "sub room" + // beside the room the player stays in. then the serial numbers the game's + // first awards are to be signed with (MinigameManager.minigameGems, + // minigamePetMastery) and who is in the game (joinGameResponse). + const seat = (session, game, music) => { + const avatar = activeAvatar(session.account); + session.game = game; + session.sendXt("rj", -1, 1, `game${game.def.id}_${game.roomId}`, game.roomId, game.players.length, game.players.length, 0, 0, + 0, 1, 0, 1, game.def.type === IN_ROOM ? 1 : 0, // isPrivate, isGame, isLimbo, isTemp, isSubRoom + "", 0, avatar.perUserAvId, avatar.petInvId, LANG_ENG, music, 1); + session.gemSerial = serial(); + session.masterySerial = serial(); + session.sendXt("mg", game.roomId, session.gemSerial, 1); + session.sendXt("ma", game.roomId, session.masterySerial, 0); + session.sendXt("mj", game.roomId, ...game.players.map(player => player.id)); + }; + + // starts a buddy game between two players (lib/buddygames.js says what + // `match` is). it runs in a window over whatever room each is in. + const startMatch = (def, sender, target) => { + const referee = buddyGames[def.swf]; + const game = {roomId: nextGameRoomId++, def, players: [sender, target], started: false, ready: new Set(), + startData: referee.startData ? referee.startData() : []}; + const seats = [sender, target]; + game.match = { + ids: seats.map(session => session.id), + state: null, + finished: false, + ready: new Set(), + send: (player, ...fields) => seats[player].sendXt("mm", game.roomId, ...fields), + broadcast: (...fields) => seats.forEach(session => session.sendXt("mm", game.roomId, ...fields)), + over() { + game.match.finished = true; + }, + seatOf: session => seats.indexOf(session), + }; + for (const session of seats) { + seat(session, game, session.room ? session.room.customMusicDef : 0); + } + start(game); + }; + + const matchMessage = (session, game, word, params) => { + const {match} = game; + const referee = buddyGames[game.def.swf]; + const player = match.seatOf(session); + // nothing more is refereed once the game is decided or a player has gone. + if (player === -1 || match.finished || game.players.length < 2 || !messagesPerMinute.allow(session.account.id)) { + return; + } + if (word === "ready") { + // both say so before the first round, and again before each further one. + if (match.ready.add(player).size === 2) { + match.ready.clear(); + referee.ready(match); + } + } + else if (Object.hasOwn(referee.messages, word)) { + referee.messages[word](match, player, params); + } + }; + + // den items a claw machine can drop: the plushies, of the machine's own + // animal when it is named for one ("The Wolf Claw"). + let plushies = null; + const clawPrizes = game => { + plushies = plushies || defpacks.denItemIds().filter(id => /plush/i.test(defpacks.denItemDef(id).abbrName)); + const item = defpacks.denItemIds().map(id => defpacks.denItemDef(id)).find(def => Number(def.gameDefId) === game.id); + const animal = item ? /^ArcCraneGame(.+)$/.exec(item.abbrName) : null; + const own = animal ? plushies.filter(id => defpacks.denItemDef(id).abbrName.toLowerCase().includes(animal[1].toLowerCase())) : []; + return own.length ? own : plushies; + }; + + // what Phantom Invasion gives: den items named for phantoms, the arcade + // machines aside. + let phantomItems = null; + const invasionPrizes = () => { + phantomItems = phantomItems || defpacks.denItemIds().filter(id => /phantom/i.test(defpacks.denItemDef(id).abbrName) + && !/^Arc/.test(defpacks.denItemDef(id).abbrName) && defpacks.string(defpacks.denItemDef(id).nameStrId)); + return phantomItems.length ? phantomItems : defpacks.denItemIds().slice(0, 1); + }; + + // the Summer Carnival's games (Skeeball and the rest share one protocol): + // the server opens with "pz" and a serial number, "pg" pays for a go and + // brings a second one, and "gr" reports the score, signed with both, and + // is answered with the tickets it earned. how many points make a ticket + // was the official server's to know; games.json has a guess per game. + const hideSerial = sn => (sn + 5) * 3 - 7; // undone by the games as (x + 7) / 3 - 5 + const carnival = { + pg(session, game, params, reply) { + const {account} = session; + if ((account.currency.gems || 0) < CARNIVAL_COST) { + reply("pg", "0"); + return; + } + account.currency.gems -= CARNIVAL_COST; + achievements.currencyChanged(account, "gems", -CARNIVAL_COST); + accounts.save(); + session.sendXt("cu", -1, CURRENCY_GEMS, account.currency.gems, 0); + game.serial2 = serial(); + reply("pg", "1", hideSerial(game.serial2)); + }, + gr(session, game, [a, b, c], reply) { + const {account} = session; + const score = (Number(a) - (game.serial1 + 49) * 5) / 7 - 29; + const valid = game.serial2 !== undefined && Number.isInteger(score) && score >= 0 + && Number(b) === (score + 49) * 3 + (game.serial2 + 83) * 5 + && Number(c) === (game.serial1 + score) * 3 + score * 3 + && awardsPerMinute.allow(account.id); + game.serial2 = undefined; // one score a go + const tickets = valid ? Math.min(MAX_TICKETS_PER_GO, Math.ceil(score / game.def.tickets)) : 0; + if (tickets > 0) { + account.currency.tickets = (account.currency.tickets || 0) + tickets; + achievements.currencyChanged(account, "tickets", tickets); + accounts.save(); + session.sendXt("cu", -1, CURRENCY_TICKETS, account.currency.tickets, 0); + } + reply("gr", tickets); + }, + }; + + const uploadToken = (session, game, [, purpose], reply) => { + reply("tkn", 1, 0, masterpieces.issueToken(session.account), 0, purpose === undefined ? 1 : Number(purpose) || 1); + }; + + // what a game asks of the server while it runs, by game class and then by + // the message's first word. `reply` answers the asker as an "mm". + const MESSAGES = { + // the claw machines: "cp" pays for a go and learns whether the claw + // will hold and what on ([won, isDenItem, defId, ?, version]; anything + // but 1 or 0 for `won` means "not enough gems"); "cd" keeps (1) or + // leaves (0) what came out. + MicroCrane: { + cp(session, game, params, reply) { + const {account} = session; + if ((account.currency.gems || 0) < CLAW_COST) { + reply("cp", "2"); + return; + } + account.currency.gems -= CLAW_COST; + achievements.currencyChanged(account, "gems", -CLAW_COST); + accounts.save(); + session.sendXt("cu", -1, CURRENCY_GEMS, account.currency.gems, 0); + const prizes = clawPrizes(game.def); + const won = prizes.length > 0 && Math.random() < CLAW_WIN_CHANCE; + session.clawPrize = won ? prizes[Math.floor(Math.random() * prizes.length)] : null; + reply("cp", won ? "1" : "0", "1", session.clawPrize || 0, 0, 0); + }, + cd(session, game, [keep]) { + if (keep === "1" && session.clawPrize) { + dens.giveDenItem(session.account, session.clawPrize); + dens.sendDenItems(session); + } + session.clawPrize = null; + }, + }, + // sky High: "gw" on reaching the top -> [won, clothingDefId, ?, colour]; + // "gd" keeps (1) or leaves (0) the prize. + WindRider: { + go() {}, + gw(session, game, params, reply) { + const ids = defpacks.clothingIds(); + const def = Math.random() < SKY_HIGH_PRIZE_CHANCE ? defpacks.itemDef(ids[Math.floor(Math.random() * ids.length)]) : null; + session.gamePrize = def ? {def: Number(def.id), color: Number(String(def.colors).split(",")[0])} : null; + reply("gw", def ? "1" : "0", def ? def.id : 0, 0, def ? session.gamePrize.color : 0); + }, + gd(session, game, [keep]) { + if (keep === "1" && session.gamePrize) { + sendClothingAdded(session, addClothing(session.account, session.gamePrize.def, session.gamePrize.color)); + accounts.save(); + } + session.gamePrize = null; + }, + }, + // the safety quiz: "hs" asks for a serial number, and "hp", signed with + // it, claims the quiz's one prize. + SafetyQuiz: { + hs(session, game, params, reply) { + session.prizeSerial = serial(); + reply("hs", session.prizeSerial); + }, + hp(session, game, [, check]) { + if (session.prizeSerial !== undefined && Number(check) === (session.prizeSerial + session.id) * 3) { + dens.giveDenItem(session.account, SAFETY_QUIZ_PRIZE); + dens.sendDenItems(session); + } + session.prizeSerial = undefined; + }, + }, + // brady Barr's expeditions ask for the same serial; their prizes hang on + // the theatre's films and are not given. + BradyExpeditions: { + hs(session, game, params, reply) { + reply("hs", serial()); + }, + hp() {}, + }, + // the touch pool: the same again, with six prizes; which one is in the + // first number. + TouchPool: { + ts(session, game, params, reply) { + session.prizeSerial = serial(); + reply("ts", session.prizeSerial); + }, + tp(session, game, [signed, check]) { + const sn = session.prizeSerial; + const prize = sn === undefined ? -1 : (Number(signed) - (session.id + 99) * 3 - (sn + 49) * 5) / 5; + if (TOUCH_POOL_PRIZES[prize] !== undefined && Number(check) === (sn + session.id + prize) * 3 + prize * 3) { + dens.giveDenItem(session.account, TOUCH_POOL_PRIZES[prize]); + dens.sendDenItems(session); + } + session.prizeSerial = undefined; // one prize a serial number + }, + }, + // phantom Invasion: "cp" pays for a go and names the prize a win will + // bring, [ok, serial, isDenItem, defId, ?, version]; the game itself + // decides whether it was won. "cd", signed with the serial, keeps it; + // "cd 2" leaves it and "cd 0" is a lost round. + MicroGameInvasion: { + cp(session, game, params, reply) { + const {account} = session; + if ((account.currency.gems || 0) < INVASION_COST) { + reply("cp", "2"); + return; + } + account.currency.gems -= INVASION_COST; + achievements.currencyChanged(account, "gems", -INVASION_COST); + accounts.save(); + session.sendXt("cu", -1, CURRENCY_GEMS, account.currency.gems, 0); + const prizes = invasionPrizes(); + session.prizeSerial = serial(); + session.gamePrize = prizes[Math.floor(Math.random() * prizes.length)]; + reply("cp", "1", session.prizeSerial, "1", session.gamePrize, 0, 0); + }, + cd(session, game, [signed, check]) { + const sn = session.prizeSerial; + const won = sn !== undefined && session.gamePrize + && Number(signed) === INVASION_WIN * 5 + (session.id + 99) * 3 + (sn + 49) * 5 + && Number(check) === (sn + session.id + INVASION_WIN) * 3 + INVASION_WIN * 3; + if (won) { + dens.giveDenItem(session.account, session.gamePrize); + dens.sendDenItems(session); + } + session.prizeSerial = undefined; + session.gamePrize = null; + }, + }, + // the Art Studio's two easels: "gmtkn" asks for a token to post a + // painting with (lib/masterpieces.js). the game reads [word, ok, ?, + // token, ?, what the token is for], the last as it was sent. + ArtStudioPainting: {gmtkn: uploadToken}, + ArtStudioGridDrawing: {gmtkn: uploadToken}, + // the Phantom Vortex's prize machine: anything but "0" is "no prize". + MicroPhantom: { + pi(session, game, params, reply) { + reply("cp", "1"); + }, + }, + }; + + const handlers = { + // MinigameXtCommManager.handleMinigameInfo: [count, 19 fields a game...]. + // RoomManagerWorld asks for every game standing in a room at once and + // draws none of their signs unless it hears about all of them. + mi(session, roomId, ids) { + const asked = ids.slice(0, MAX_INFO_REQUEST).map(Number).filter(id => Number.isInteger(id) && id > 0); + // the easel's "play" popup offers both painting games and reads the + // second one's description without having asked for it + // (GameCardPopup, for game 51): it goes along. + if (asked.includes(GAME_PAINTING) && !asked.includes(GAME_PIXEL_PAINTING)) { + asked.push(GAME_PIXEL_PAINTING); + } + const known = asked.map(id => games.get(id) || {...UNKNOWN_GAME, id}); + session.sendXt("mi", -1, known.length, ...known.flatMap(info)); + }, + + // MinigameManager.launchGame: [gameDefId, multiplayer, proModeId, ?]. + mj(session, roomId, [gameDefId]) { + leave(session); // a game left without a word, if any + const def = games.get(Number(gameDefId)); + if (!def || def.ready === false || def.buddy || !session.room) { + // "as": the one refusal that puts the client back as it was. it + // comes with a popup about switching animals, hence one of our own. + session.sendXt("mj", -1, "as", 0); + tell(session, "That game is not ready on this server yet."); + return; + } + const game = {roomId: nextGameRoomId++, def, players: [session], started: false, ready: new Set()}; + const music = session.room.customMusicDef; // the client takes this from every room join + if (def.type !== IN_ROOM) { + // the game takes the room's place: the player is gone from the + // world until they come back with an ordinary room join. + game.returnTo = session.room.name; + leaveRoom(session); + } + seat(session, game, music); + start(game); + if (def.tickets) { + game.serial1 = serial(); + session.sendXt("mm", game.roomId, "pz", hideSerial(game.serial1)); + } + }, + + // "Start now", from a waiting list; nobody waits here. + ms() {}, + + // MinigameManager.msg: [gameDefId, word, ...]. the game's own protocol. + mm(session, roomId, [gameDefId, word, ...params]) { + const {game} = session; + if (!game || game.def.id !== Number(gameDefId)) { + return; + } + if (game.match) { + matchMessage(session, game, String(word), params); + return; + } + const reply = (...fields) => session.sendXt("mm", game.roomId, ...fields); + const own = game.def.tickets ? carnival : MESSAGES[game.def.swf]; + if (own && Object.hasOwn(own, word)) { + own[word](session, game, params, reply); + } + else if (word === "ready" && game.def.start && Object.hasOwn(START, game.def.start)) { + game.ready.add(session); + if (game.ready.size === game.players.length) { + for (const player of game.players) { + player.sendXt("mm", game.roomId, "start", ...START[game.def.start](game)); + } + } + } + }, + + // leaving an in-room game: [subRoomId]. (A game that took the room's + // place is left by joining a room again.) + rl(session) { + leave(session); + }, + ml(session) { + leave(session); + }, + + // MinigameManager.sendGemAward: three numbers made of the amount, the + // game, the player's sfs id and the serial number last handed out (the + // second, which names the game, is not checked: not every game says + // which it is). the reply is the next serial number. + mg(session, roomId, [a, , c]) { + const {account, game} = session; + const sn = session.gemSerial; + const amount = (Number(a) - (session.id + 99) * 3 - (sn + 49) * 5) / 7 - 29; + const valid = game && sn !== undefined && Number.isInteger(amount) && amount > 0 && amount <= MAX_GEMS_PER_AWARD + && Number(c) === (sn + session.id + amount) * 3 + amount * 3 + && awardsPerMinute.allow(account.id); + if (valid) { + account.currency.gems = (account.currency.gems || 0) + amount; + achievements.currencyChanged(account, "gems", amount); + accounts.save(); + } + session.gemSerial = serial(); + session.sendXt("mg", -1, session.gemSerial, 0); + }, + + // MinigameManager.sendMasteryPoints, the same for the pet's mastery. the + // second field of the reply says its mastery is now full. + ma(session, roomId, [a, b, c]) { + const {account, game} = session; + const sn = session.masterySerial; + const amount = (Number(a) - (session.id + 99) * 3 - (sn + 49) * 5) / 7 - 29; + const pet = account.pets.find(candidate => candidate.inv === activeAvatar(account).petInvId); + const valid = game && pet && sn !== undefined && Number.isInteger(amount) && amount > 0 && amount <= MAX_MASTERY_PER_AWARD + && Number(c) === (sn + session.id + amount) * 3 + amount * 3 && Number(b) === (game.def.id + 49) * 3 + (sn + 83) * 5; + let nowFull = false; + if (valid && (pet.mastery || 0) < MASTERY_FULL) { + pet.mastery = Math.min(MASTERY_FULL, (pet.mastery || 0) + amount); + nowFull = pet.mastery === MASTERY_FULL; + accounts.save(); + } + session.masterySerial = serial(); + session.sendXt("ma", -1, session.masterySerial, nowFull ? 1 : 0); + }, + + // high scores for the leaderboards, which are not kept. + msv() {}, + // MinigameManager.leaderBoardResponse: [gameDefId, count, ...] + mlb(session, roomId, [gameDefId]) { + session.sendXt("mlb", -1, gameDefId, 0); + }, + // the buddy games (MinigameXtCommManager.sendMinigamePvpMsg): [gameDefId, + // 0, username] invites that player; [gameDefId, 0] from the invited + // player says yes, and [gameDefId, 1] from either says no or never mind. + // MinigameManager.pvpResponse reads [gameDefId, 0, who is asking, their + // name may be shown] and [gameDefId, 1] for "no". + mp(session, roomId, [gameDefId, status, username]) { + const def = games.get(Number(gameDefId)); + if (status !== "0") { + dropInvite(session); + return; + } + if (username === undefined || username === "") { + const {invite} = session; + if (invite && invite.target === session && invite.def === def && !invite.sender.game && !session.game) { + dropInvite(session, false); + startMatch(def, invite.sender, session); + } + else { + dropInvite(session); + } + return; + } + const target = findOnline(username); + const free = other => other && other.room && !other.game && !other.invite; + if (!def || !def.buddy || !free(session) || !free(target) || target === session + || blocks.either(session.account, target.account) || !invitesPerMinute.allow(session.account.id) + || !accounts.featureOn(session.account, "gameInvites") || !accounts.featureOn(target.account, "gameInvites")) { + // "They said no" is all the client has for an invitation that cannot be made. + dropInvite(session); + session.sendXt("mp", -1, def ? def.id : Number(gameDefId) || 0, 1); + return; + } + session.invite = target.invite = {def, sender: session, target}; + target.sendXt("mp", -1, def.id, 0, session.account.username, 1); + }, + // an open challenge to whoever walks up (UserCommXtCommManager.sendCustomPVPMessage); not offered. + mcp() {}, + }; + + // the HUD's Games window (GameJoinPopup, generic list 341): the playable + // games that have a picture for it, by name. + const library = [...games.values()].filter(game => game.icon && game.ready !== false) + .sort((one, other) => one.title.localeCompare(other.title)).map(game => game.id); + + // the buddy games' descriptions, sent unasked when a player arrives: a + // player's card lists whichever games the client has heard are ready to + // be played against another player (MinigameInfoCache.getAllReadyForPvpGameDefs). + const greet = session => { + const buddy = [...games.values()].filter(game => game.buddy && Object.hasOwn(buddyGames, game.swf)); + session.sendXt("mi", -1, buddy.length, ...buddy.flatMap(info)); + }; + + return { + handlers, + leave, + greet, + library: () => library, + // the room a player in a room-replacing game came from, for the panel. + playing: session => (session.game ? session.game.def.title : null), + }; +}; diff --git a/lib/moderation.js b/lib/moderation.js new file mode 100644 index 0000000..ca6772f --- /dev/null +++ b/lib/moderation.js @@ -0,0 +1,184 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const achievements = require("./achievements.js"); +const bans = require("./bans.js"); +const dens = require("./dens.js"); +const {CURRENCIES} = require("./player.js"); + +// moderation: kick, ban, silence, clear a den, grant gems, message a player. +// these are done from the admin panel (lib/panel.js). no game account has +// them: the client's own moderator requests (FacilitatorXtCommManager) are +// always refused. + +const PERMANENT = -1; +const SECONDS_PER_MINUTE = 60; +const CURRENCY_GEMS = 0; +// ItemXtCommManager.currencyUpdateResponse: with this as the reason the +// client says "You earned N ..." in a popup when the amount went up. +const REASON_ANNOUNCE = 3; + +const now = () => Math.floor(Date.now() / 1000); + +// seconds of ban left, PERMANENT, or 0 when not banned. +const banRemaining = account => { + if (account.bannedUntil === PERMANENT) { + return PERMANENT; + } + return Math.max(0, (account.bannedUntil || 0) - now()); +}; + +// the ban an account is under, for whoever may know why (the banned player, +// and whoever runs the server): {seconds, reason, by, since}, or null. +const banOf = account => { + const seconds = banRemaining(account); + return seconds === 0 ? null : {seconds, reason: account.banReason || bans.NO_REASON, by: account.bannedBy || "", since: account.bannedAt || null}; +}; + +const isSilenced = account => account.silencedUntil === PERMANENT || (account.silencedUntil || 0) > now(); + +// seconds of silence left, PERMANENT, or 0 when the account may chat. +const silenceRemaining = account => { + if (account.silencedUntil === PERMANENT) { + return PERMANENT; + } + return Math.max(0, (account.silencedUntil || 0) - now()); +}; + +module.exports = ({findOnline}) => { + // FacilitatorXtCommManager.facilitatorDisciplineResponse: what the affected + // player's client is told. + const discipline = (session, ...fields) => session.sendXt("fd", -1, ...fields); + + // A "message from moderator" popup; also used to answer chat commands. + const notify = (session, text) => discipline(session, "fp", text, 0); + + const actions = { + kick(target) { + const session = findOnline(target.username); + if (!session) { + return false; + } + discipline(session, "fk", 0); + session.close(); + return true; + }, + + // duration in seconds, or PERMANENT. the reason is for the banned + // player and whoever runs the server, nobody else; `by` is who gave it. + ban(target, duration, reason = "", by = "") { + target.bannedUntil = duration === PERMANENT ? PERMANENT : now() + duration; + target.banReason = bans.reasonText(reason); + target.bannedBy = by; + target.bannedAt = now(); + accounts.save(); + bans.record({account: target, action: "ban", seconds: duration, reason: target.banReason, by}); + const session = findOnline(target.username); + if (session) { + discipline(session, "fb", 1, duration); + session.close(); + } + return true; + }, + + unban(target, by = "") { + const was = banRemaining(target) !== 0; + delete target.bannedUntil; + delete target.banReason; + delete target.bannedBy; + delete target.bannedAt; + accounts.save(); + if (was) { + bans.record({account: target, action: "unban", by}); + } + return true; + }, + + // another reason for the ban they are under; its length stays. + banReason(target, reason, by = "") { + if (banRemaining(target) === 0) { + return false; + } + target.banReason = bans.reasonText(reason); + accounts.save(); + bans.record({account: target, action: "reason", reason: target.banReason, by}); + return true; + }, + + // duration in seconds, PERMANENT, or 0 to lift + silence(target, duration) { + target.silencedUntil = duration === PERMANENT ? PERMANENT : (duration > 0 ? now() + duration : 0); + accounts.save(); + const session = findOnline(target.username); + if (session) { + // minutes, negative for "until further notice", 0 for "you may type again" + discipline(session, "fs", duration === PERMANENT ? PERMANENT : Math.ceil(duration / SECONDS_PER_MINUTE)); + } + return true; + }, + + // their username will not do: they are put out, every saved sign-in + // ends, and the next sign-in asks for another name before it lets them + // in (lib/http.js, lib/manage.js). the name itself stays until then. + rejectName(target, by = "") { + target.nameRejected = {by, at: now()}; + accounts.revokeTokens(target); + accounts.save(); + actions.kick(target); + return true; + }, + + // taken back: the name will do after all. + acceptName(target) { + delete target.nameRejected; + accounts.save(); + return true; + }, + + clearDen(target) { + dens.clearDen(target, findOnline); + return true; + }, + + grantGems(target, amount) { + return actions.grantCurrency(target, CURRENCY_GEMS, amount, false); + }, + + // adds to (or with a negative amount takes from) one of a player's + // currencies: an index into CURRENCIES. `announce` has their game say so. + grantCurrency(target, currencyType, amount, announce = true) { + const name = CURRENCIES[currencyType]; + if (!name) { + return false; + } + const before = target.currency[name] || 0; + target.currency[name] = Math.max(0, before + amount); + achievements.currencyChanged(target, name, target.currency[name] - before); + accounts.save(); + const session = findOnline(target.username); + if (session) { + // ItemXtCommManager.currencyUpdateResponse: [currencyType, newAmount, reason] + session.sendXt("cu", -1, currencyType, target.currency[name], announce ? REASON_ANNOUNCE : 0); + } + return true; + }, + + message(target, text) { + const session = findOnline(target.username); + if (!session) { + return false; + } + notify(session, text); + return true; + }, + }; + + // the client's moderator requests, refused whoever sends them. each + // expects [0] for failure; "fc" (clear den) has no reply at all. + const refuse = reply => session => session.sendXt(reply, -1, 0); + const handlers = {fk: refuse("fk"), fb: refuse("fb"), fs: refuse("fs"), fm: refuse("fm"), fg: refuse("fg"), fp: refuse("fp"), fc() {}}; + + return {handlers, actions, banRemaining, banOf, isSilenced, silenceRemaining, PERMANENT}; +}; + +Object.assign(module.exports, {isSilenced, banRemaining, banOf}); diff --git a/lib/modlog.js b/lib/modlog.js new file mode 100644 index 0000000..66f4d32 --- /dev/null +++ b/lib/modlog.js @@ -0,0 +1,31 @@ +"use strict"; + +const accounts = require("./accounts.js"); + +// what each moderator did in the moderator panel (lib/modpanel.js), for +// whoever runs the server to read in the admin panel. never pruned. + +const SCHEMA = ` + CREATE TABLE IF NOT EXISTS mod_log ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + at INTEGER NOT NULL, + by TEXT NOT NULL, + action TEXT NOT NULL, + target TEXT NOT NULL DEFAULT '', + detail TEXT NOT NULL DEFAULT '' + ); +`; +const MAX_DETAIL = 400; +const SHOWN = 300; + +const load = () => accounts.database().exec(SCHEMA); + +const record = (by, action, target = "", detail = "") => { + accounts.database().prepare("INSERT INTO mod_log (at, by, action, target, detail) VALUES (?, ?, ?, ?, ?)") + .run(Math.floor(Date.now() / 1000), by, action, String(target), String(detail).slice(0, MAX_DETAIL)); + console.log(`[mod] ${by}: ${action}${target ? ` "${target}"` : ""}`); +}; + +const recent = () => accounts.database().prepare("SELECT at, by, action, target, detail FROM mod_log ORDER BY id DESC LIMIT ?").all(SHOWN); + +module.exports = {load, record, recent}; diff --git a/lib/modpanel.js b/lib/modpanel.js new file mode 100644 index 0000000..c293193 --- /dev/null +++ b/lib/modpanel.js @@ -0,0 +1,447 @@ +"use strict"; + +const crypto = require("crypto"); +const fs = require("fs"); +const path = require("path"); +const accounts = require("./accounts.js"); +const bans = require("./bans.js"); +const captcha = require("./captcha.js"); +const chatlog = require("./chatlog.js"); +const config = require("../config.js"); +const limits = require("./limits.js"); +const manage = require("./manage.js"); +const masterpieces = require("./masterpieces.js"); +const modlog = require("./modlog.js"); +const reports = require("./reports.js"); +const staff = require("./staff.js"); +const support = require("./support.js"); +const totp = require("./totp.js"); +const world = require("./world.js"); + +// the moderator panel at /mod: what a moderator needs to look after the +// players, and no more. it is apart from the admin panel (lib/panel.js), +// which stays whoever runs the server's alone. +// +// A moderator is a game account the admin marked as one (`moderator` on the +// account). they sign in here with that account's username and password and +// a code from their authenticator app, every time: an account without 2FA +// cannot sign in at all, and a trusted device is not taken for a code. +// being a moderator gives the account nothing in the game itself. +// +// what it does not give: addresses, sign-in histories, the server's log, +// what an account owns, passwords, renaming, deleting, gifts. an address +// can be banned through its player (the one they last signed in from) and +// shows here with its end left out. another moderator cannot be acted on. +// everything done here is written down (lib/modlog.js) under the +// moderator's name, for the admin panel. + +const COOKIE = "ajc_mod"; +const SESSION_HOURS = 12; +const TEN_MINUTES_MS = 600000; +const MAX_BAN_HOURS = 24 * 365 * 10; +const MAX_MESSAGE_LENGTH = 200; +const MAX_FOUND = 50; + +const failuresByAddress = limits.limiter(config.failedLoginsPerTenMinutes, TEN_MINUTES_MS); +const actionsPerTenMinutes = limits.limiter(300, TEN_MINUTES_MS); // per moderator + +const sessions = new Map(); // SHA-256 of a session token -> {id: account id, expiry: ms} + +const sha256 = text => crypto.createHash("sha256").update(text).digest("hex"); + +const cookieToken = req => { + const match = new RegExp(`(?:^|;\\s*)${COOKIE}=([0-9a-f]{48})(?:;|$)`).exec(req.headers.cookie || ""); + return match ? match[1] : null; +}; + +const cookieHeader = (token, maxAgeSeconds) => + `${COOKIE}=${token}; Path=/mod; HttpOnly; SameSite=Strict; Max-Age=${maxAgeSeconds}${config.secureCookies ? "; Secure" : ""}`; + +// may this account use the panel (still)? +const mayModerate = account => Boolean(account && account.moderator && totp.isOn(account) && !account.locked + && world.moderation.banRemaining(account) === 0); + +const signedInAs = req => { + const token = cookieToken(req); + const session = token && sessions.get(sha256(token)); + const account = session && session.expiry > Date.now() ? accounts.byId(session.id) : null; + return mayModerate(account) ? account : null; +}; + +// ends the account's sessions here: it is no longer a moderator, or its +// password or name changed. +const forget = account => { + for (const [hash, session] of sessions) { + if (session.id === account.id) { + sessions.delete(hash); + } + } +}; + +const playerRow = (account, playing) => { + const ban = world.moderation.banOf(account); + return { + username: account.username, + createdAt: account.createdAt, + lastSeen: account.lastSeen || account.lastLogin || null, + online: playing.has(account.username), + room: playing.get(account.username) || null, + banned: ban ? ban.seconds : 0, + banReason: ban ? ban.reason : "", + silenced: world.moderation.silenceRemaining(account), + nameRejected: Boolean(account.nameRejected), + moderator: Boolean(account.moderator), + bio: account.bio, + discord: account.discord, + }; +}; + +const playing = () => new Map(world.players().map(player => [player.username, player.room || "(between rooms)"])); + +const findPlayers = query => { + const wanted = String(query || "").trim().toLowerCase().slice(0, 100); + const online = playing(); + return accounts.all() + .filter(account => account.username.toLowerCase().includes(wanted)) + .sort((a, b) => Number(online.has(b.username)) - Number(online.has(a.username)) || a.username.localeCompare(b.username)) + .slice(0, MAX_FOUND) + .map(account => playerRow(account, online)); +}; + +// one player: the row, what was done about their bans (without addresses), +// their appeal, and the reports about them still waiting. +const playerDetail = account => ({ + ...playerRow(account, playing()), + history: bans.historyOf(account).map(({at, action, seconds, reason, by}) => ({at, action, seconds, reason, by})), + appeal: bans.appealOf(account), + openReports: reports.list(false).filter(report => report.target.toLowerCase() === account.username.toLowerCase()).length, +}); + +// an address with its end left out, and a name to lift its ban by. +const maskedAddress = ban => ({ + id: sha256(ban.key).slice(0, 16), + address: ban.key.includes(":") ? `${ban.key.split(":").slice(0, 2).join(":")}:…` : `${ban.key.split(".").slice(0, 2).join(".")}.…`, + reason: ban.reason, + by: ban.by, + createdAt: ban.createdAt, +}); + +const wholeNumber = (value, min, max) => (Number.isInteger(value) && value >= min && value <= max ? value : null); + +const act = (mod, target, body) => { + const {actions, PERMANENT} = world.moderation; + const name = target.username; + const by = mod.username; + if (target === mod) { + return {error: "That is you."}; + } + if (target.moderator) { + return {error: "Another moderator is the admin's to deal with."}; + } + switch (body.action) { + case "ban": { + const hours = wholeNumber(body.hours, 0, MAX_BAN_HOURS); + if (hours === null) { + return {error: "Hours as a whole number, or 0 for permanent."}; + } + actions.ban(target, hours === 0 ? PERMANENT : hours * 3600, body.reason, by); + manage.forget(target); + return {ok: hours === 0 ? `${name} is banned permanently.` : `${name} is banned for ${hours} hours.`, detail: `${hours || "permanent"} · ${target.banReason}`}; + } + case "banReason": + return actions.banReason(target, body.reason, by) ? {ok: "Reason saved.", detail: target.banReason} : {error: `${name} is not banned.`}; + case "unban": + if (world.moderation.banRemaining(target) === 0) { + return {error: `${name} is not banned.`}; + } + actions.unban(target, by); + return {ok: `${name} is no longer banned.`}; + // counted in hours here; the game's own notice counts minutes. + case "silence": { + const hours = wholeNumber(body.hours, 0, MAX_BAN_HOURS); + if (hours === null) { + return {error: "Hours as a whole number, or 0 for until lifted."}; + } + actions.silence(target, hours === 0 ? PERMANENT : hours * 3600); + return {ok: hours === 0 ? `${name} cannot chat until it is lifted.` : `${name} cannot chat for ${hours} hours.`, detail: String(hours || "until lifted")}; + } + case "unsilence": + actions.silence(target, 0); + return {ok: `${name} can chat again.`}; + case "kick": + return actions.kick(target) ? {ok: `${name} was disconnected.`} : {error: `${name} is not online.`}; + case "message": { + const text = String(body.text || "").trim().slice(0, MAX_MESSAGE_LENGTH); + if (!text) { + return {error: "The message is empty."}; + } + return actions.message(target, text) ? {ok: `Shown to ${name}.`, detail: text} : {error: `${name} is not online.`}; + } + case "rejectName": + if (target.nameRejected) { + return {error: "Already rejected."}; + } + actions.rejectName(target, by); + manage.forget(target); + return {ok: `${name} is signed out and picks a new name at the next sign-in.`}; + case "acceptName": + if (!target.nameRejected) { + return {error: "Not rejected."}; + } + actions.acceptName(target); + return {ok: `${name} keeps the name.`}; + case "clearBio": + target.bio = ""; + accounts.save(); + return {ok: "Bio cleared."}; + // the address they last signed in from, for good. which address that + // is, the moderator is not told. + case "banAddress": { + const last = target.logins.find(login => login.ok && login.address); + if (!last) { + return {error: "No address is known for them."}; + } + const result = staff.banAddress(last.address, body.reason, by); + if (result.error) { + return {error: result.error.startsWith("That is this machine") ? "Their address cannot be banned." : result.error}; + } + return {ok: "Their address is banned.", detail: result.ban.reason}; + } + default: + return {error: "Unknown action."}; + } +}; + +const PAGE_HEADERS = { + "Cache-Control": "no-store", + "X-Frame-Options": "DENY", + "X-Content-Type-Options": "nosniff", + "Referrer-Policy": "no-referrer", + "Content-Security-Policy": captcha.policy("default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; connect-src 'self'; img-src 'self' data:; font-src 'self'; " + + "form-action 'none'; frame-ancestors 'none'; base-uri 'none'"), +}; + +// `from` is {address, key, local}; `web` is {send, readJson} from lib/http.js. +const handle = async (req, res, url, from, web) => { + for (const [name, value] of Object.entries(PAGE_HEADERS)) { + res.setHeader(name, value); + } + const reply = (status, body) => web.send(res, status, body); + const route = `${req.method} ${url.pathname.replace(/\/$/, "") || "/mod"}`; + + if (route === "GET /mod") { + web.send(res, 200, captcha.withScriptVersion(await fs.promises.readFile(path.join(config.publicDir, "mod.html"))), "text/html; charset=utf-8"); + return; + } + if (req.method === "POST" && !limits.originAllowed(req)) { + reply(403, {error: "forbidden"}); + return; + } + const body = req.method === "POST" ? await web.readJson(req) : {}; + + switch (route) { + case "GET /mod/api/state": { + const mod = signedInAs(req); + reply(200, {signedIn: Boolean(mod), username: mod ? mod.username : ""}); + return; + } + // username, password and a code, all three every time. + case "POST /mod/api/login": { + if (!from.local && failuresByAddress.blocked(from.key)) { + reply(429, {error: "Too many attempts. Try later."}); + return; + } + const captchaProblem = await captcha.check({captcha: body.captcha}, from, "login"); + if (captchaProblem) { + reply(captchaProblem === "captcha_unavailable" ? 503 : 401, {error: captcha.MESSAGES[captchaProblem]}); + return; + } + // looked up first: with AJ_REGISTER=1 authenticate() would make the account. + const known = accounts.byName(String(body.username || "").trim()); + const account = known && await accounts.authenticateAsync(known.username, body.password) === known ? known : null; + // one answer for a wrong password and for an account that is no + // moderator: who the moderators are is nobody's to find out here. + if (!account || !account.moderator) { + failuresByAddress.record(from.key); + if (known && !account) { + accounts.recordLogin(known, "mod", from.address, false); + accounts.save(); + } + reply(401, {error: "Wrong username or password."}); + return; + } + if (!totp.isOn(account)) { + reply(403, {error: "Turn on 2FA on your account page first."}); + return; + } + if (!mayModerate(account)) { + reply(403, {error: "This account cannot sign in here now."}); + return; + } + if (!totp.verify(account, String(body.code || ""))) { + failuresByAddress.record(from.key); + accounts.recordLogin(account, "mod", from.address, false); + accounts.save(); + reply(401, {error: "Wrong code."}); + return; + } + accounts.recordLogin(account, "mod", from.address); + accounts.save(); + for (const [hash, session] of sessions) { + if (session.expiry < Date.now()) { + sessions.delete(hash); + } + } + const token = crypto.randomBytes(24).toString("hex"); + sessions.set(sha256(token), {id: account.id, expiry: Date.now() + SESSION_HOURS * 3600000}); + res.setHeader("Set-Cookie", cookieHeader(token, SESSION_HOURS * 3600)); + modlog.record(account.username, "signed in"); + reply(200, {ok: true, username: account.username}); + return; + } + case "POST /mod/api/logout": { + const token = cookieToken(req); + if (token) { + sessions.delete(sha256(token)); + } + res.setHeader("Set-Cookie", cookieHeader("", 0)); + reply(200, {ok: true}); + return; + } + } + + const mod = signedInAs(req); + if (!mod) { + reply(401, {error: "Sign in first."}); + return; + } + if (req.method === "POST" && !actionsPerTenMinutes.allow(mod.id)) { + reply(429, {error: "Too many at once. Try later."}); + return; + } + // what was done, under the moderator's name; then the answer. + const done = (result, action, target = "", detail = "") => { + if (result.ok) { + modlog.record(mod.username, action, target, result.detail || detail); + } + reply(result.ok ? 200 : 400, result.ok ? {ok: result.ok} : {error: result.error}); + }; + + switch (route) { + case "GET /mod/api/overview": + reply(200, {online: world.players().length, reports: reports.openCount(), requests: support.nameRequests(false).length + bans.openAppeals(), + paintings: masterpieces.list(masterpieces.PENDING).length}); + return; + + case "GET /mod/api/players": + reply(200, {players: findPlayers(url.searchParams.get("q"))}); + return; + + case "GET /mod/api/player": { + const account = accounts.byName(url.searchParams.get("username") || ""); + reply(account ? 200 : 404, account ? playerDetail(account) : {error: "No such player."}); + return; + } + + case "POST /mod/api/act": { + const target = accounts.byName(String(body.username || "")); + if (!target) { + reply(404, {error: "No such player."}); + return; + } + done(act(mod, target, body), String(body.action), target.username); + return; + } + + // what players typed (lib/chatlog.js): a page of lines, or the lines + // around one of them. + case "GET /mod/api/chat": { + const params = url.searchParams; + const lines = chatlog.search({username: (params.get("username") || "").trim().slice(0, 100), room: (params.get("room") || "").trim().slice(0, 100), + text: (params.get("text") || "").trim().slice(0, 100), before: Number(params.get("before")) || 0}); + reply(200, {lines, more: lines.length === chatlog.PAGE, days: config.chatLogDays}); + return; + } + case "GET /mod/api/chat/around": { + const found = chatlog.around(url.searchParams.get("id")); + reply(found ? 200 : 404, found || {error: "No such line."}); + return; + } + + case "GET /mod/api/reports": + reply(200, {reports: reports.list(url.searchParams.get("handled") === "1"), open: reports.openCount()}); + return; + + case "POST /mod/api/report": + done(reports.markHandled(Number(body.id)) ? {ok: "Marked as dealt with."} : {error: "No such report waiting."}, "report dealt with", "", `#${Number(body.id)}`); + return; + + // requests for another username, and ban appeals. + case "GET /mod/api/requests": { + const handled = url.searchParams.get("handled") === "1"; + reply(200, {names: support.nameRequests(handled), appeals: staff.appealsFor(handled).map(({addressKey, address, ...appeal}) => ({...appeal, ofAddress: Boolean(address)}))}); + return; + } + case "POST /mod/api/request": { + if (body.action === "appealApprove" || body.action === "appealDeny") { + const result = staff.answerAppeal(body.id, body.action === "appealApprove", body.reply, mod.username); + done(result, body.action === "appealApprove" ? "appeal approved" : "appeal denied", result.username, bans.clean(body.reply, bans.MAX_REPLY)); + } + else if (body.action === "approve" || body.action === "deny") { + const result = staff.answerNameRequest(body.id, body.action === "approve"); + done(result, body.action === "approve" ? "name request approved" : "name request denied", result.username); + } + else { + reply(400, {error: "Unknown action."}); + } + return; + } + + case "GET /mod/api/bans": + reply(200, {accounts: staff.disciplined(), addresses: bans.addressBans().map(maskedAddress)}); + return; + + case "POST /mod/api/address": { + const ban = bans.addressBans().find(entry => sha256(entry.key).slice(0, 16) === String(body.id)); + done(ban && bans.unbanAddress(ban.key, mod.username) ? {ok: "No longer banned."} : {error: "Not banned."}, "address unbanned", "", ban ? ban.reason : ""); + return; + } + + // paintings players framed (lib/masterpieces.js). + case "GET /mod/api/masterpieces": + reply(200, {waiting: masterpieces.list(masterpieces.PENDING), approved: masterpieces.list(masterpieces.APPROVED)}); + return; + + case "GET /mod/api/masterpiece": { + const picture = masterpieces.image(url.searchParams.get("id") || ""); + if (!picture) { + reply(404, {error: "No such painting."}); + return; + } + res.setHeader("Cache-Control", "private, max-age=3600"); + web.send(res, 200, picture, "image/jpeg"); + return; + } + + case "POST /mod/api/masterpiece": { + const id = String(body.id || ""); + const maker = masterpieces.creatorOf(id); + const result = body.action === "approve" + ? (world.approveMasterpiece(id) ? {ok: "Approved."} : {error: "No such painting waiting."}) + : body.action === "reject" || body.action === "remove" + ? (world.removeMasterpiece(id) ? {ok: "Removed for good. Its maker was told and given a Masterpiece Token."} : {error: "No such painting."}) + : {error: "Unknown action."}; + done(result, `painting ${body.action === "approve" ? "approved" : "removed"}`, maker ? maker.username : "", id); + return; + } + + default: + reply(404, {error: "not_found"}); + } +}; + +const moderators = () => accounts.all().filter(account => account.moderator) + .map(account => ({username: account.username, twoStep: totp.isOn(account), lastSeen: account.lastSeen || null})) + .sort((a, b) => a.username.localeCompare(b.username)); + +module.exports = {handle, forget, moderators}; diff --git a/lib/names.js b/lib/names.js new file mode 100644 index 0000000..80e4691 --- /dev/null +++ b/lib/names.js @@ -0,0 +1,77 @@ +"use strict"; + +const fs = require("fs"); +const path = require("path"); +const config = require("../config.js"); + +// which usernames a player may not choose (sign-up, and a request for a new +// name): the ones that would pass for whoever runs the game, and slurs. +// deliberately loose. A name is refused for BEING such a word, or having +// one as one of its words; a name that merely contains one is let through, +// and whoever runs the server deals with the odd one by hand (rename, in +// the admin panel). the lists are files, read again when they change: +// lib/reserved-names.txt staff-like names +// public/filter/level1.txt the chat filter's first level: slurs, threats +// and the names of the Epic Dens, which are how a showcase den is asked for. + +const RESERVED_FILE = path.join(__dirname, "reserved-names.txt"); +const SLURS_FILE = path.join(config.publicDir, "filter", "level1.txt"); +const DIGITS = {0: "o", 1: "i", 3: "e", 4: "a", 5: "s", 7: "t"}; + +// A word as it is compared: small letters, digits at either end dropped +// ("mod123"), digits inside read as the letters they stand in for. this and +// the matching below are the chat filter's own rules (AJClient.filterText +// in the patched client), since the slurs are its first list. +const plain = word => word.toLowerCase().replace(/^\d+|\d+$/g, "").replace(/\d/g, digit => DIGITS[digit] || "").replace(/[^a-z]/g, ""); +// A letter drawn out ("mooood") is undone, but only for a word that has one +// drawn out three times or more: "coon" must not be the same word as "con". +const squash = word => word.replace(/(.)\1+/g, "$1"); +const stretched = word => /(.)\1\1/.test(word); + +// the entries of a list file: [{text, prefix}], text made plain as above. +const lists = new Map(); // file -> {mtime, entries} +const read = file => { + let mtime = 0; + try { + mtime = fs.statSync(file).mtimeMs; + } + catch (err) { + return []; + } + const kept = lists.get(file); + if (kept && kept.mtime === mtime) { + return kept.entries; + } + const entries = fs.readFileSync(file, "utf8").split(/\r?\n/).map(line => line.trim()).filter(line => line && !line.startsWith("#")) + .map(line => ({text: line.replace(/\*$/, "").split(/\s+/).map(plain).join(""), prefix: line.endsWith("*")})).filter(entry => entry.text.length >= 2); + lists.set(file, {mtime, entries}); + return entries; +}; + +let epicDens = null; +const denNames = () => { + if (!epicDens) { + try { + const names = require("./epicdens.js").all().map(den => plain(den.name)); + if (names.length === 0) { + return names; // the game's data is not loaded yet + } + epicDens = names; + } + catch (err) { + return []; + } + } + return epicDens; +}; + +const refused = username => { + const words = String(username).split(/[ .-]+/).map(plain).filter(Boolean); + const whole = plain(String(username)); + const same = (word, entry) => word === entry.text || (entry.prefix && word.startsWith(entry.text)) + || (stretched(word) && (squash(word) === squash(entry.text) || (entry.prefix && squash(word).startsWith(squash(entry.text))))); + const hit = entry => same(whole, entry) || words.some(word => same(word, entry)); + return read(RESERVED_FILE).some(hit) || read(SLURS_FILE).some(hit) || denNames().includes(whole); +}; + +module.exports = {refused, plain}; diff --git a/lib/panel.js b/lib/panel.js new file mode 100644 index 0000000..95c6afa --- /dev/null +++ b/lib/panel.js @@ -0,0 +1,846 @@ +"use strict"; + +const crypto = require("crypto"); +const fs = require("fs"); +const path = require("path"); +const accounts = require("./accounts.js"); +const achievements = require("./achievements.js"); +const adopt = require("./adopt.js"); +const badges = require("./badges.js"); +const bans = require("./bans.js"); +const colours = require("./colours.js"); +const config = require("../config.js"); +const defpacks = require("./defpacks.js"); +const limits = require("./limits.js"); +const log = require("./log.js"); +const masterpieces = require("./masterpieces.js"); +const modlog = require("./modlog.js"); +const modpanel = require("./modpanel.js"); +const erase = require("./erase.js"); +const reports = require("./reports.js"); +const sales = require("./sales.js"); +const staff = require("./staff.js"); +const support = require("./support.js"); +const totp = require("./totp.js"); +const manage = require("./manage.js"); +const world = require("./world.js"); +const {activeAvatar} = require("./player.js"); + +// the admin panel at /admin: the only place the server is administered from. +// it has one password, chosen the first time the panel is opened and kept as +// a salted scrypt hash in the database. no game account has admin powers. +// +// signing in sets a cookie that only this panel's pages send back (HttpOnly, +// SameSite=Strict, Path=/admin); sessions live in memory, so restarting the +// server signs everyone out. + +const PASSWORD_SETTING = "admin_password"; // "salt:hash" +const COOKIE = "ajc_admin"; +const SESSION_HOURS = 12; +const MIN_PASSWORD_LENGTH = 8; +const MAX_PASSWORD_LENGTH = 200; +const MAX_MESSAGE_LENGTH = 200; +const MAX_BAN_HOURS = 24 * 365 * 10; +const MAX_GEMS = 1000000000; +const TEN_MINUTES_MS = 600000; +const DAY_SECONDS = 86400; +const MAX_ANNOUNCEMENT = 300; +const MAX_OWNED_LISTED = 300; +// currencies the panel can hand out, as indexes into CURRENCIES. +const GIFT_CURRENCIES = {gems: 0, tickets: 1, diamonds: 3}; +// who a ban is written down as given by. the panel has one password and so +// one name; moderators with sign-ins of their own will each have theirs. +const BY = "admin"; + +// wrong passwords (and wrong setup codes) allowed per address before further +// tries from it are refused for a while. there is deliberately no overall +// limit: it would let a stranger lock the real admin out. +const failuresByAddress = limits.limiter(8, TEN_MINUTES_MS); + +const sessions = new Map(); // SHA-256 of a session token -> expiry (ms) +let setupCode = null; // needed to choose the first password from another machine + +const sha256 = text => crypto.createHash("sha256").update(text).digest("hex"); +const now = () => Math.floor(Date.now() / 1000); + +const hasPassword = () => accounts.setting(PASSWORD_SETTING) !== null; + +const storePassword = password => { + const salt = crypto.randomBytes(16).toString("hex"); + accounts.setSetting(PASSWORD_SETTING, `${salt}:${accounts.hashPassword(password, salt)}`); +}; + +const passwordMatches = password => { + const [salt, hash] = (accounts.setting(PASSWORD_SETTING) || ":").split(":"); + if (typeof password !== "string" || !salt || password.length > MAX_PASSWORD_LENGTH) { + return false; + } + return crypto.timingSafeEqual(Buffer.from(accounts.hashPassword(password, salt), "hex"), Buffer.from(hash, "hex")); +}; + +const passwordAcceptable = password => + typeof password === "string" && password.length >= MIN_PASSWORD_LENGTH && password.length <= MAX_PASSWORD_LENGTH; + +const load = () => { + if (!hasPassword()) { + setupCode = crypto.randomBytes(5).toString("hex"); + console.log(`[admin] no admin password yet: open ${config.baseUrl}admin to choose one` + + ` (from another machine it will ask for this setup code: ${setupCode})`); + } +}; + +const cookieToken = req => { + const match = new RegExp(`(?:^|;\\s*)${COOKIE}=([0-9a-f]{48})(?:;|$)`).exec(req.headers.cookie || ""); + return match ? match[1] : null; +}; + +const signedIn = req => { + const token = cookieToken(req); + const expiry = token && sessions.get(sha256(token)); + if (!expiry || expiry < Date.now()) { + return false; + } + return true; +}; + +const cookieHeader = (token, maxAgeSeconds) => + `${COOKIE}=${token}; Path=/admin; HttpOnly; SameSite=Strict; Max-Age=${maxAgeSeconds}${config.secureCookies ? "; Secure" : ""}`; + +const signIn = res => { + for (const [hash, expiry] of sessions) { + if (expiry < Date.now()) { + sessions.delete(hash); + } + } + const token = crypto.randomBytes(24).toString("hex"); + sessions.set(sha256(token), Date.now() + SESSION_HOURS * 3600000); + res.setHeader("Set-Cookie", cookieHeader(token, SESSION_HOURS * 3600)); +}; + +const signOut = (req, res) => { + const token = cookieToken(req); + if (token) { + sessions.delete(sha256(token)); + } + res.setHeader("Set-Cookie", cookieHeader("", 0)); +}; + +const accountRow = (account, playing) => { + const ban = world.moderation.banRemaining(account); + return { + id: account.id, + username: account.username, + createdAt: account.createdAt, + lastLogin: account.lastLogin || null, + lastSeen: account.lastSeen || null, + locked: account.locked, + twoStep: totp.isOn(account), + discord: account.discord, + bio: account.bio, + badges: account.badges, + featuresOff: accounts.FEATURES.filter(name => !accounts.featureOn(account, name)), + logins: account.numLogins, + online: playing.has(account.username), + room: playing.get(account.username) || null, + // seconds left, -1 for permanent, 0 for not banned + banned: ban, + banReason: ban === 0 ? "" : account.banReason || bans.NO_REASON, + moderator: Boolean(account.moderator), + nameRejected: Boolean(account.nameRejected), + silenced: world.moderation.isSilenced(account), + animals: account.avatars.length, + level: activeAvatar(account).questLevel || 0, + items: account.items.length + account.denItems.length, + gems: account.currency.gems || 0, + }; +}; + +const overview = () => { + const players = world.players(); + const all = accounts.all(); + const rooms = new Map(); + for (const player of players) { + const room = player.room || "(between rooms)"; + rooms.set(room, (rooms.get(room) || 0) + 1); + } + return { + stats: { + online: players.length, + accounts: all.length, + newToday: all.filter(account => account.createdAt > now() - DAY_SECONDS).length, + activeToday: all.filter(account => (account.lastLogin || 0) > now() - DAY_SECONDS).length, + banned: all.filter(account => world.moderation.banRemaining(account) !== 0).length, + clientErrors: log.recent(0, "[client-error]", Infinity).length, + reports: reports.openCount(), + support: support.openCount() + bans.openAppeals(), + masterpieces: masterpieces.list(masterpieces.PENDING).length, + }, + server: { + address: config.baseUrl, + uptimeSeconds: Math.floor(process.uptime()), + memoryMb: Math.round(process.memoryUsage().rss / 1048576), + node: process.version, + reachableFromOtherMachines: config.isPublic, + encrypted: config.secureCookies, + packetLog: config.logPackets, + customColours: colours.count(), + }, + players, + rooms: [...rooms].map(([name, count]) => ({name, count})).sort((a, b) => b.count - a.count), + }; +}; + +const ownedBy = account => { + const counted = (entries, nameOf) => { + const counts = new Map(); + for (const entry of entries) { + counts.set(entry.def, (counts.get(entry.def) || 0) + 1); + } + return [...counts].map(([def, count]) => ({id: def, name: nameOf(def) || `#${def}`, count})) + .sort((a, b) => a.name.localeCompare(b.name)).slice(0, MAX_OWNED_LISTED); + }; + const clothingName = def => defpacks.string((defpacks.itemDef(def) || {}).titleStrId); + const denItemName = def => { + const item = defpacks.denItemDef(def) || {}; + return defpacks.string(item.nameStrId) || item.abbrName; + }; + return { + username: account.username, + currency: Object.fromEntries(Object.keys(GIFT_CURRENCIES).map(name => [name, account.currency[name] || 0])), + animals: account.avatars.map(avatar => defpacks.string((defpacks.avatarDef(avatar.type) || {}).titleStrId) || `Animal type ${avatar.type}`), + pets: account.pets.map(pet => defpacks.string((defpacks.petDef(pet.lBits & 0xFF) || {}).titleStrId) || `Pet type ${pet.lBits & 0xFF}`), + dens: account.dens.length, + clothing: counted(account.items, clothingName), + clothingTotal: account.items.length, + denItems: counted(account.denItems, denItemName), + denItemsTotal: account.denItems.length, + buddies: account.buddies, + blocked: account.blocked, + achievements: account.achievements.length, + adoptAPets: account.adoptAPets.length, + jamAGrams: account.ecards.length, + wallPosts: account.wall.posts.length, + outfits: account.outfits.map(outfit => outfit.name), + denLayouts: account.denLayouts.map(layout => layout.name), + hidesBlockedPlayers: account.hideBlocked, + }; +}; + +// ---- the Debug page: getting into rooms nothing leads to, and seeing what +// sale dates hide. for whoever runs the server to look around with; it gives +// a player nothing they keep. + +// rooms found to be unused, unfinished or otherwise out of reach (see +// DISCOVERIES.md), with what they are. +const ROOM_NOTES = { + "lost_temple_of_zios/room_chamberbase": "reached from a hidden spot on the world map (bottom left, under Appondale); its shop sells the odd den items", + "appondale/room_museum_ant": "the museum with its Antlers and Tusks exhibit; shown in place of the usual one in even months", + "first_five/room_firstfive": "the new-player tutorial room", + "canyon_path/room_main_main": "the Canyons Pathway with the plushie hunt's stand; shown in March and April", + "activitygeography/room_main": "scene of a geography activity", + "world_map/room_main": "the world map, as a room", + "reuseplayer_den/content/pd_burrow/pd_burrow": "a stray copy of the burrow den", + "holidays_and_celebrations/halloween/room_main": "Halloween room no portal leads to", + "party/venue_pl_birthday_cake": "earlier copy of a hostable venue; now the Birthday Party", + "party/venue_pl_vet_science": "earlier copy of a hostable venue; now the Science Party", + "party/venue_pl_res_bakery": "earlier copy of a hostable venue; now the Bakery Party", + "party/venue_pl_castle_medieval": "earlier copy of a hostable venue; now the Medieval Party", + "player_den/room_castle_lrg": "a draft den; sold in the den shops now", + "player_den/room_main_waterpark3": "a draft den; sold in the den shops now", + "player_den/room_main_waterpark4": "a draft den; sold in the den shops now", + "player_den/room_main_epicpalace": "a draft den; sold in the den shops now", + "riverraceassets/room_main_new": "a newer River Race scene", + "prototypehorserace/room_main": "prototype of Jamaa Derby", +}; +const ROOM_GROUP_NOTES = { + epic_dens: "the Epic Dens showcase; twenty a day are in the world map's Epic Dens list", + holidays_and_celebrations: "Halloween rooms: copies of the Phantom Vortex room the lands lead to in October", + rholidays_and_celebrations: "Halloween rooms, older set", + adventures: "adventure maps; nothing in them moves", +}; + +const debugState = () => ({ + players: world.players().map(player => player.username).sort((a, b) => a.localeCompare(b)), + rooms: defpacks.roomPaths().map(roomPath => { + const group = roomPath.split("/")[0]; + return {path: roomPath, group, note: ROOM_NOTES[roomPath] || ROOM_GROUP_NOTES[group] || ""}; + }).sort((a, b) => a.path.localeCompare(b.path)), + everythingOnSale: sales.everythingOnSale(), +}); + +const debugAct = body => { + if (body.action === "teleport") { + const account = accounts.byName(String(body.username || "")); + if (!account) { + return {error: "No such account."}; + } + const problem = world.teleport(account, String(body.room || "")); + return problem ? {error: `${problem}.`} : {ok: `${account.username} is on the way to ${body.room}.`}; + } + if (body.action === "everythingOnSale") { + sales.setEverythingOnSale(body.on === true); + return {ok: body.on === true + ? "Sale dates are off: every item shows, for players who start the game from now on." + : "Sale dates are back on, for players who start the game from now on."}; + } + return {error: "Unknown debug action."}; +}; + +// what was done about an account's bans, its appeal, and the addresses it +// signed in from (newest first, each once), for banning one of them. +const banRecord = account => { + const seen = new Map(); + for (const login of account.logins) { + if (login.address && !seen.has(login.address)) { + seen.set(login.address, {address: login.address, at: login.at, banned: Boolean(bans.addressBan(login.address)), + own: limits.isLoopback(login.address)}); + } + } + return {history: bans.historyOf(account), appeal: bans.appealOf(account), addresses: [...seen.values()]}; +}; + +// bans an address for good, or lifts that. returns {ok: text} or {error: text}. +const addressAct = body => { + if (body.action === "ban") { + const result = staff.banAddress(body.address, body.reason, BY); + if (result.error) { + return result; + } + const {out} = result; + return {ok: `${result.ban.key} is banned.${out ? ` ${out} playing from it ${out === 1 ? "was" : "were"} disconnected.` : ""}`}; + } + if (body.action === "unban") { + return bans.unbanAddress(String(body.address || ""), BY) ? {ok: "No longer banned."} : {error: "Not banned."}; + } + return {error: "Unknown action."}; +}; + +// A gift from the panel. gems, diamonds and items arrive as a Jam-A-Gram +// from Animal Jam HQ, whether or not the player is online: an item waits in +// their inbox, gems and diamonds open as a gift popup (lib/ecards.js). the +// rest has no such card and goes straight into the account. +const gift = (account, body) => { + const name = account.username; + const text = String(body.text || "").trim().slice(0, MAX_MESSAGE_LENGTH) || "A gift for you!"; + if (Object.hasOwn(GIFT_CURRENCIES, body.kind)) { + const amount = wholeNumber(body.amount, 1, MAX_GEMS); + if (amount === null) { + return {error: "Give a whole number above zero."}; + } + if (body.kind === "tickets") { + world.moderation.actions.grantCurrency(account, GIFT_CURRENCIES.tickets, amount); + return {ok: `${name} was given ${amount.toLocaleString()} tickets.`}; + } + const problem = world.ecards.sendFromHq(account, text, {kind: body.kind, amount}); + return problem ? {error: `${problem}.`} : {ok: `A Jam-A-Gram with ${amount.toLocaleString()} ${body.kind} is on its way to ${name}.`}; + } + if (body.kind === "clothing" || body.kind === "den") { + const color = body.color === undefined || body.color === "" ? undefined : wholeNumber(Number(body.color), 0, 0xFFFFFFFF); + if (color === null) { + return {error: "The colour id must be a whole number from 0 to 4294967295."}; + } + const problem = world.ecards.sendFromHq(account, text, {kind: body.kind, id: body.id, color}); + return problem ? {error: `${problem}.`} : {ok: `A Jam-A-Gram with that item is in ${name}'s inbox.`}; + } + if (body.kind === "adopt") { + const ids = body.id === "all" ? defpacks.adoptAPetIds() : [body.id]; + const given = ids.filter(id => adopt.give(account, id)).length; + accounts.save(); + return given ? {ok: `${name} has ${given} more on their Adopt-A-Pet checklist (it shows after their next login).`} + : {error: "No such Adopt-A-Pet, or they already have it."}; + } + if (body.kind === "achievement") { + return achievements.grant(account, body.id) ? {ok: `${name} has that achievement now.`} + : {error: "No such achievement, or they already have it."}; + } + return {error: "Unknown kind of gift."}; +}; + +const MAX_QUEST_LEVEL = 100; + +const wholeNumber = (value, min, max) => (Number.isInteger(value) && value >= min && value <= max ? value : null); + +// returns {ok: text} or {error: text}. +const act = (account, body) => { + const {actions, PERMANENT} = world.moderation; + const name = account.username; + switch (body.action) { + case "password": { + if (accounts.setPassword(account, body.password)) { + return {error: "Passwords need 10 characters or more, with a capital letter, a small letter and a digit."}; + } + actions.kick(account); + manage.forget(account); // their account page too, whoever has it open + modpanel.forget(account); + return {ok: `${name} has a new password and was signed out.`}; + } + // the owner locks and unlocks on the account page; this is for when + // they cannot. + case "unlock": + account.locked = false; + accounts.save(); + return {ok: `${name} is unlocked.`}; + // for a player who lost their phone and their recovery codes: their + // password alone signs them in again. + case "twoStepOff": + if (!totp.isOn(account)) { + return {error: `${name} does not use 2FA.`}; + } + totp.turnOff(account); + accounts.save(); + return {ok: `2FA is off for ${name}.`}; + case "rename": { + world.disconnect(account); + manage.forget(account); + modpanel.forget(account); + // the admin may pick any name the server can store and the game can carry. + const problem = accounts.rename(account, body.newName, true); + if (problem) { + return {error: problem === "username_taken" ? "That username is taken." + : "That name cannot be used: it must not be empty, be over 100 characters, or contain % or control characters."}; + } + return {ok: `${name} is now called ${account.username}. They log in with the new name and the same password.`, username: account.username}; + } + // for trying out what a player's card says about when they were last + // seen: any time in the past, in seconds. it is overwritten the next + // time they leave the game. + case "lastSeen": { + const when = wholeNumber(body.when, 1, Math.floor(Date.now() / 1000)); + if (when === null) { + return {error: "Pick a date and time in the past."}; + } + account.lastSeen = when; + accounts.save(); + return {ok: `${name} was last seen ${new Date(when * 1000).toISOString().replace("T", " ").slice(0, 16)} UTC, as far as the game knows.`}; + } + // the adventure level of the animal they are using. + case "level": { + const level = wholeNumber(body.level, 0, MAX_QUEST_LEVEL); + if (level === null) { + return {error: `0 to ${MAX_QUEST_LEVEL}.`}; + } + world.setQuestLevel(account, level); + return {ok: `${name}'s animal is level ${level}.`}; + } + // their badges (lib/badges.js): the whole set at once. + case "badges": { + if (!Array.isArray(body.badges) || !body.badges.every(badges.known)) { + return {error: "Unknown badge."}; + } + badges.set(account, body.badges); + accounts.save(); + world.checkNameTag(account); + return {ok: account.badges.length ? `${name} has: ${badges.of(account).map(badge => badge.label).join(", ")}.` : `${name} has no badges.`}; + } + // their Discord username, which they otherwise set on the account + // page; empty takes it off. + case "discord": { + const discord = badges.discordName(body.name); + if (discord === null) { + return {error: "Not a Discord username."}; + } + account.discord = discord; + accounts.save(); + return {ok: discord ? `Discord set to "${discord}".` : "Discord cleared."}; + } + // their bio, which they otherwise write on the account page; empty + // takes it off. + case "bio": { + const bio = badges.bioText(body.text); + if (bio === null) { + return {error: `At most ${badges.MAX_BIO} characters on ${badges.MAX_BIO_LINES} lines.`}; + } + account.bio = bio; + accounts.save(); + return {ok: bio ? "Bio set." : "Bio cleared."}; + } + case "ban": { + const hours = wholeNumber(body.hours, 0, MAX_BAN_HOURS); + if (hours === null) { + return {error: "Give the ban a whole number of hours, or 0 for permanent."}; + } + actions.ban(account, hours === 0 ? PERMANENT : hours * 3600, body.reason, BY); + // out of the account page as well. (They may sign in to it again: it + // shows them the ban and little else, lib/manage.js.) Saved sign-ins + // are left: nothing takes one while the ban lasts but the client's + // question about the ban itself (lib/admin.js). + manage.forget(account); + return {ok: hours === 0 ? `${name} is banned permanently.` : `${name} is banned for ${hours} hours.`}; + } + case "banReason": + return actions.banReason(account, body.reason, BY) ? {ok: "Reason saved."} : {error: `${name} is not banned.`}; + case "unban": + actions.unban(account, BY); + return {ok: `${name} is no longer banned.`}; + case "kick": + return actions.kick(account) ? {ok: `${name} was disconnected.`} : {error: `${name} is not online.`}; + // counted in hours; the game's own notice counts minutes. + case "silence": { + const hours = wholeNumber(body.hours, 0, MAX_BAN_HOURS); + if (hours === null) { + return {error: "Give a whole number of hours, or 0 for until lifted."}; + } + actions.silence(account, hours === 0 ? PERMANENT : hours * 3600); + return {ok: hours === 0 ? `${name} cannot chat until you lift it.` : `${name} cannot chat for ${hours} hours.`}; + } + // A moderator may use the moderator panel (lib/modpanel.js), with this + // account's password and its 2FA, which it has to have. + case "moderator": + if (body.on === true) { + account.moderator = true; + } + else { + delete account.moderator; + modpanel.forget(account); + } + accounts.save(); + return {ok: body.on === true + ? `${name} is a moderator.${totp.isOn(account) ? "" : " They have no 2FA yet and cannot sign in to the moderator panel until they turn it on."}` + : `${name} is no longer a moderator.`}; + case "rejectName": + actions.rejectName(account, BY); + manage.forget(account); + modpanel.forget(account); + return {ok: `${name} is signed out and picks a new name at the next sign-in.`}; + case "acceptName": + actions.acceptName(account); + return {ok: `${name} keeps the name.`}; + case "unsilence": + actions.silence(account, 0); + return {ok: `${name} can chat again.`}; + case "message": { + const text = String(body.text || "").trim().slice(0, MAX_MESSAGE_LENGTH); + if (!text) { + return {error: "The message is empty."}; + } + return actions.message(account, text) ? {ok: `Message shown to ${name}.`} : {error: `${name} is not online.`}; + } + case "clearDen": + actions.clearDen(account); + return {ok: `Everything in ${name}'s den went back to their inventory.`}; + case "gems": { + const amount = wholeNumber(body.amount, -MAX_GEMS, MAX_GEMS); + if (amount === null) { + return {error: "Give a whole number of gems (negative to take away)."}; + } + actions.grantGems(account, amount); + return {ok: `${name} now has ${account.currency.gems} gems.`}; + } + case "gift": + return gift(account, body); + case "delete": + world.disconnect(account); + manage.forget(account); + modpanel.forget(account); + erase(account); + return {ok: `${name} was deleted.`}; + default: + return {error: "Unknown action."}; + } +}; + +const PAGE_HEADERS = { + "Cache-Control": "no-store", + "X-Frame-Options": "DENY", + "X-Content-Type-Options": "nosniff", + "Referrer-Policy": "no-referrer", + "Content-Security-Policy": "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; connect-src 'self'; img-src 'self' data:; font-src 'self'; " + + "form-action 'none'; frame-ancestors 'none'; base-uri 'none'", +}; + +// A request that changes something must come from the panel's own page. +const sameOrigin = limits.originAllowed; + +const tooManyFailures = address => failuresByAddress.blocked(address); +const recordFailure = address => failuresByAddress.record(address); + +// `from` is {address, local}; `web` is {send, readJson} from lib/http.js. +const handle = async (req, res, url, from, web) => { + for (const [name, value] of Object.entries(PAGE_HEADERS)) { + res.setHeader(name, value); + } + const reply = (status, body) => web.send(res, status, body); + const route = `${req.method} ${url.pathname.replace(/\/$/, "") || "/admin"}`; + + if (route === "GET /admin") { + web.send(res, 200, await fs.promises.readFile(path.join(config.publicDir, "admin.html")), "text/html; charset=utf-8"); + return; + } + if (req.method === "POST" && !sameOrigin(req)) { + reply(403, {error: "forbidden"}); + return; + } + const body = req.method === "POST" ? await web.readJson(req) : {}; + + switch (route) { + case "GET /admin/api/state": + reply(200, {needsSetup: !hasPassword(), needsSetupCode: !from.local, signedIn: signedIn(req)}); + return; + + // choosing the first password. whoever is at the server's own machine may; + // anyone else must give the code the server printed when it started. + case "POST /admin/api/setup": { + if (hasPassword()) { + reply(409, {error: "The admin password has already been chosen."}); + return; + } + if (tooManyFailures(from.key)) { + reply(429, {error: "Too many attempts. Try again in a few minutes."}); + return; + } + setupCode = setupCode || crypto.randomBytes(5).toString("hex"); + const code = String(body.code || "").trim().toLowerCase(); + if (!from.local && (code.length !== setupCode.length || !crypto.timingSafeEqual(Buffer.from(code), Buffer.from(setupCode)))) { + recordFailure(from.key); + reply(403, {error: "That is not the setup code. It is in the server's output, on the line starting [admin]."}); + return; + } + if (!passwordAcceptable(body.password)) { + reply(400, {error: `Choose a password of at least ${MIN_PASSWORD_LENGTH} characters.`}); + return; + } + storePassword(body.password); + setupCode = null; + console.log(`[admin] admin password chosen from ${from.address}`); + signIn(res); + reply(200, {ok: true}); + return; + } + + case "POST /admin/api/login": { + if (tooManyFailures(from.key)) { + reply(429, {error: "Too many attempts. Try again in a few minutes."}); + return; + } + if (!hasPassword() || !passwordMatches(body.password)) { + recordFailure(from.key); + console.log(`[admin] failed sign-in from ${from.address}`); + reply(401, {error: "Wrong password."}); + return; + } + console.log(`[admin] signed in from ${from.address}`); + signIn(res); + reply(200, {ok: true}); + return; + } + + case "POST /admin/api/logout": + signOut(req, res); + reply(200, {ok: true}); + return; + } + + if (!signedIn(req)) { + reply(401, {error: "Sign in first."}); + return; + } + + switch (route) { + case "GET /admin/api/overview": + reply(200, overview()); + return; + + case "GET /admin/api/accounts": { + const playing = new Map(world.players().map(player => [player.username, player.room || "(between rooms)"])); + reply(200, {accounts: accounts.all().map(account => accountRow(account, playing)), badges: badges.BADGES}); + return; + } + + case "GET /admin/api/logs": { + const lines = log.recent(Number(url.searchParams.get("after")) || 0, (url.searchParams.get("filter") || "").slice(0, 100)); + reply(200, {lines, newest: log.count()}); + return; + } + + case "POST /admin/api/account": { + const account = accounts.byName(String(body.username || "")); + if (!account) { + reply(404, {error: "No such account."}); + return; + } + const result = act(account, body); + if (result.ok) { + console.log(`[admin] ${body.action} on "${account.username}"`); + } + reply(result.ok ? 200 : 400, result); + return; + } + + case "GET /admin/api/owned": { + const account = accounts.byName(url.searchParams.get("username") || ""); + reply(account ? 200 : 404, account ? ownedBy(account) : {error: "No such account."}); + return; + } + + case "GET /admin/api/bans": + reply(200, {accounts: staff.disciplined(), addresses: bans.addressBans()}); + return; + + // who may use the moderator panel, and what each did there. + case "GET /admin/api/moderators": + reply(200, {moderators: modpanel.moderators(), log: modlog.recent()}); + return; + + case "GET /admin/api/banrecord": { + const account = accounts.byName(url.searchParams.get("username") || ""); + reply(account ? 200 : 404, account ? banRecord(account) : {error: "No such account."}); + return; + } + + case "POST /admin/api/address": { + const result = addressAct(body); + if (result.ok) { + console.log(`[admin] address ${body.action}: ${limits.key(body.address)}`); + } + reply(result.ok ? 200 : 400, result); + return; + } + + case "GET /admin/api/messages": + reply(200, {motd: world.motd(), rooms: world.rooms()}); + return; + + case "GET /admin/api/debug": + reply(200, debugState()); + return; + + case "POST /admin/api/debug": { + const result = debugAct(body); + if (result.ok) { + console.log(`[admin] debug: ${body.action} ${body.action === "teleport" ? `${body.username} -> ${body.room}` : body.on === true}`); + } + reply(result.ok ? 200 : 400, result); + return; + } + + // the message everyone is shown when they arrive; empty for none. + case "POST /admin/api/motd": + world.setMotd(String(body.text || "")); + console.log("[admin] message of the day changed"); + reply(200, {ok: world.motd() ? "Players will see this when they arrive." : "There is no message of the day now.", motd: world.motd()}); + return; + + // A message for everyone playing, or everyone in one room. + case "POST /admin/api/announce": { + const text = String(body.text || "").trim().slice(0, MAX_ANNOUNCEMENT); + if (!text) { + reply(400, {error: "The message is empty."}); + return; + } + const reached = world.announce(text, body.room ? String(body.room) : null); + console.log(`[admin] announcement to ${body.room ? `room ${body.room}` : "everyone"} (${reached} players)`); + reply(200, {ok: reached === 1 ? "Shown to 1 player." : `Shown to ${reached} players.`}); + return; + } + + // paintings players made masterpieces of (lib/masterpieces.js): the + // ones waiting to be looked at, and the ones on show. + case "GET /admin/api/masterpieces": + reply(200, { + review: masterpieces.needsReview(), + waiting: masterpieces.list(masterpieces.PENDING), + approved: masterpieces.list(masterpieces.APPROVED), + }); + return; + + case "GET /admin/api/masterpiece": { + const picture = masterpieces.image(url.searchParams.get("id") || ""); + if (!picture) { + reply(404, {error: "No such painting."}); + return; + } + res.setHeader("Cache-Control", "private, max-age=3600"); + web.send(res, 200, picture, "image/jpeg"); + return; + } + + case "POST /admin/api/masterpiece": { + const id = String(body.id || ""); + let result; + if (body.action === "review") { + masterpieces.setNeedsReview(body.on === true); + result = {ok: body.on === true ? "New masterpieces wait here until you approve them." + : "New masterpieces are approved as they are made. Ones already waiting still wait."}; + } + else if (body.action === "approve") { + result = world.approveMasterpiece(id) ? {ok: "Approved. Its maker has been told and can hang it now."} : {error: "No such painting waiting."}; + } + else if (body.action === "reject" || body.action === "remove") { + result = world.removeMasterpiece(id) + ? {ok: "Removed for good. Its maker has been told and given a Masterpiece Token."} : {error: "No such painting."}; + } + else { + result = {error: "Unknown action."}; + } + if (result.ok) { + console.log(`[admin] masterpiece ${body.action} ${id || body.on === true}`); + } + reply(result.ok ? 200 : 400, result); + return; + } + + case "GET /admin/api/reports": + reply(200, {reports: reports.list(url.searchParams.get("handled") === "1"), open: reports.openCount()}); + return; + + case "POST /admin/api/report": + if (!reports.markHandled(Number(body.id))) { + reply(404, {error: "No such report waiting."}); + return; + } + reply(200, {ok: "Marked as dealt with."}); + return; + + // what players sent from the account page: requests for a new username, + // and feedback and bug reports (lib/support.js). + case "GET /admin/api/support": { + const handled = url.searchParams.get("handled") === "1"; + reply(200, {names: support.nameRequests(handled), feedback: support.feedback(handled), appeals: staff.appealsFor(handled), + open: support.openCount() + bans.openAppeals()}); + return; + } + + case "POST /admin/api/support": { + let result; + if (body.action === "appealApprove" || body.action === "appealDeny") { + result = staff.answerAppeal(body.id, body.action === "appealApprove", body.reply, BY); + } + else if (body.action === "read") { + result = support.markFeedbackRead(body.id) ? {ok: "Marked as read."} : {error: "No such message waiting."}; + } + else if (body.action === "approve" || body.action === "deny") { + result = staff.answerNameRequest(body.id, body.action === "approve"); + } + else { + result = {error: "Unknown action."}; + } + if (result.ok) { + console.log(`[admin] support: ${body.action} ${Number(body.id)}`); + } + reply(result.ok ? 200 : 400, result); + return; + } + + case "POST /admin/api/password": { + if (!passwordMatches(body.current)) { + reply(403, {error: "The current password is wrong."}); + return; + } + if (!passwordAcceptable(body.password)) { + reply(400, {error: `Choose a password of at least ${MIN_PASSWORD_LENGTH} characters.`}); + return; + } + storePassword(body.password); + sessions.clear(); + signIn(res); + console.log("[admin] admin password changed"); + reply(200, {ok: true}); + return; + } + + default: + reply(404, {error: "not_found"}); + } +}; + +module.exports = {load, handle, PASSWORD_SETTING}; diff --git a/lib/parties.js b/lib/parties.js new file mode 100644 index 0000000..819359e --- /dev/null +++ b/lib/parties.js @@ -0,0 +1,276 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const config = require("../config.js"); +const defpacks = require("./defpacks.js"); +const epicDens = require("./epicdens.js"); +const masterpieces = require("./masterpieces.js"); +const {activeAvatar, isUint} = require("./player.js"); + +// parties (client side: PartyManager, PartyPopup, CustomPartyCreatePopup). +// +// "AJ parties" are the game's own party rooms. the real game opened a few +// at a time on a timetable; here every one whose room exists is open all +// the time. A party room is called "party". +// +// "Jammer parties" are hosted by players: pick one of the party rooms made +// for it, a three-word name and the music, pay a diamond, and the party is +// listed for everyone until it ends. its room is "pparty", +// which is how the client tells whose party it is in. + +const ROOM_TYPE_PARTY = 5; // RoomManagerWorld: clientInfo.roomType in a party +const CURRENCY_DIAMONDS = 3; +const HOST_COST = 1; // diamonds; CustomPartyCreatePopup shows this price +const NOT_HOSTING = -1; +const ALWAYS_OPEN_SECONDS = 86400; +// the world map's "AJHQ" button asks for this party: today's showcase den. +const PARTY_EPIC_DEN = 36; +const PARTY_GALLERY = 47; // PartyManager.PARTY_DEF_MASTERPIECE + +// PartyManager restrictions +const RESTRICT_AVATAR = 1; +const RESTRICT_PET = 4; +const RESTRICT_PET_ONLY = 8; + +// generic lists the party windows ask for. +const LIST_CUSTOM_PARTY_DEFS = 370; +const LIST_PARTY_MUSIC = 401; +// the three name wheels of CustomPartyCreatePopup, as ranges of ids in the +// localization defPack ("Epic" ... "Trading", "Birthday" ... "Animal", +// "Den" ... "Alliance"). 24138 sits in the first range but is a den item's name. +const NAME_LISTS = new Map([ + [386, [24135, 24161]], + [387, [24162, 24185]], + [388, [24186, 24210]], +]); +const NOT_A_NAME = 24138; +const MAX_PARTIES = 200; + +const now = () => Math.floor(Date.now() / 1000); + +module.exports = ({enterRoom, findOnline, blocks}) => { + // parties being hosted: lowercased host username -> {host, defId, name, music, endsAt} + const hosted = new Map(); + + const joinable = def => def && def.room && defpacks.roomDef(def.room) && !def.isGame; + const ajParties = () => defpacks.partyDefs().filter(def => joinable(def) && !def.isCustom); + const customDefs = () => defpacks.partyDefs().filter(def => joinable(def) && def.isCustom); + + const nameList = listId => { + const [first, last] = NAME_LISTS.get(Number(listId)); + return Array.from({length: last - first + 1}, (_, i) => first + i).filter(id => id !== NOT_A_NAME); + }; + const validName = (listId, id) => isUint(id) && nameList(listId).includes(Number(id)); + + const partyOf = account => { + const party = hosted.get(account.username.toLowerCase()); + if (party && party.endsAt <= now()) { + hosted.delete(account.username.toLowerCase()); + return null; + } + return party || null; + }; + + // seconds the account's own party has left; NOT_HOSTING without one. + const timeLeft = account => { + const party = partyOf(account); + return party ? party.endsAt - now() : NOT_HOSTING; + }; + + const liveParties = () => [...hosted.values()].filter(party => partyOf(party.host)); + + // PartyManager.roomSoireeResponse: [0, reason, ...]; "NA" wrong animal, + // "NP" no pet, each with the party def the barrier popup is about. + const refuse = (session, reason, defId) => session.sendXt("sj", -1, 0, reason, defId); + + const joinAjParty = (session, defId) => { + const def = defpacks.partyDef(defId); + if (!joinable(def) || def.isCustom) { + refuse(session, "NM", defId); + return; + } + const avatar = activeAvatar(session.account); + if (def.restrictions === RESTRICT_AVATAR && !((BigInt(def.avatarDefFlags) >> BigInt(avatar.type - 1)) & 1n)) { + refuse(session, "NA", def.id); + return; + } + if ([RESTRICT_PET, RESTRICT_PET_ONLY].includes(def.restrictions) && !avatar.petInvId) { + refuse(session, "NP", def.id); + return; + } + const shard = config.shards[0]; + if (def.id === PARTY_EPIC_DEN) { + // A room to each showcase den, so that whoever is inside when the day + // turns stays where they are. + const den = epicDens.featured(); + enterRoom(session, `party${def.id}_${den.id}`, den.base, den.name, shard.id, {roomType: ROOM_TYPE_PARTY, secondaryDefId: def.id}); + return; + } + // the Masterpiece Gallery hangs players' paintings on its walls: the + // room is told which with its properties (PartyManager.setupMasterpiecesInRoom, + // which also has to be given the two lists when there are none). + enterRoom(session, `party${def.id}`, def.room, defpacks.string(def.titleStrId) || "Party", shard.id, + {roomType: ROOM_TYPE_PARTY, secondaryDefId: def.id, ...(def.id === PARTY_GALLERY ? {customData: masterpieces.gallery} : {})}); + }; + + // PartyManager.customPartyJoinResponse: [success, reason] + const joinHosted = (session, host) => { + const party = host && partyOf(host); + if (!party || blocks.either(host, session.account)) { + session.sendXt("sjp", -1, 0, party ? "BLK" : "NPP"); + return; + } + const def = defpacks.partyDef(party.defId); + const room = enterRoom(session, `pparty${host.username}`, def.room, party.name, config.shards[0].id, + {roomType: ROOM_TYPE_PARTY, secondaryDefId: def.id, customMusicDef: party.music, partyHost: host}); + if (room) { + session.sendXt("sjp", -1, 1); + } + }; + + // ends a party: everyone in it goes back to the starting room. + const end = (party, sendHome) => { + hosted.delete(party.host.username.toLowerCase()); + const hostSession = findOnline(party.host.username); + if (hostSession) { + // PartyManager.customPartyKillResponse: [diamonds refunded] + hostSession.sendXt("spk", -1, 0); + } + sendHome(`pparty${party.host.username}`); + }; + + const handlers = { + // PartyPopup.partyListResponse: [?, count, (partyDefId, secondsToStart, + // secondsToEnd)...] + sl(session) { + const list = ajParties(); + session.sendXt("sl", -1, 0, list.length, ...list.flatMap(def => [def.id, 0, ALWAYS_OPEN_SECONDS])); + }, + + // [partyDefId] + sj(session, roomId, [defId]) { + joinAjParty(session, defId); + }, + + // PartyPopup.customPartyListResponse: [success, total, first, pageSize, + // count, (hostUuid, "nameId|nameId|nameId", server node, partyDefId, + // secondsLeft)...]. the node has to be this server's own address + // (SFClient.serverIp) or the client tries to change servers. + slp(session) { + const list = liveParties().filter(party => !blocks.either(party.host, session.account)); + session.sendXt("slp", -1, 1, list.length, 0, list.length, list.length, + ...list.flatMap(party => [party.host.uuid, party.name, config.host, party.defId, party.endsAt - now()])); + }, + + // CustomPartyCreatePopup: [partyDefId, nameId1, nameId2, nameId3, + // musicDenItemId]. PartyManager.customPartyCreateResponse reads + // [1, isHost, secondsLeft] or [0, reason]. + scp(session, roomId, [defId, name1, name2, name3, music]) { + const {account} = session; + const def = defpacks.partyDef(defId); + const fail = reason => session.sendXt("scp", -1, 0, reason); + if (!joinable(def) || !def.isCustom || !validName(386, name1) || !validName(387, name2) || !validName(388, name3) + || !defpacks.musicIds().includes(Number(music))) { + fail("INV"); + return; + } + if (partyOf(account)) { + fail("EXISTS"); + return; + } + if ((account.currency.diamonds || 0) < HOST_COST) { + fail("ND"); + return; + } + if (liveParties().length >= MAX_PARTIES) { + fail("DIS"); + return; + } + account.currency.diamonds -= HOST_COST; + accounts.save(); + const party = {host: account, defId: def.id, name: `${name1}|${name2}|${name3}`, music: Number(music), endsAt: now() + config.partyMinutes * 60}; + hosted.set(account.username.toLowerCase(), party); + console.log(`[world] ${account.username} is hosting a party (def ${def.id})`); + session.sendXt("cu", -1, CURRENCY_DIAMONDS, account.currency.diamonds, 0); + session.sendXt("scp", -1, 1, 1, party.endsAt - now()); + joinHosted(session, account); + }, + + // PartyManager.customPartyIsHostingResponse: [hostUuid] -> seconds left + // of that player's party, -1 when there is none. + sphp(session, roomId, [uuid]) { + const party = liveParties().find(candidate => candidate.host.uuid === uuid); + session.sendXt("sphp", -1, party ? party.endsAt - now() : NOT_HOSTING); + }, + + // PartyManager.onGetPartyNodeId: [hostUuid] -> [success, hostUuid, node] + spn(session, roomId, [uuid]) { + const party = liveParties().find(candidate => candidate.host.uuid === uuid); + session.sendXt("spn", -1, party ? 1 : 0, uuid, config.host); + }, + + // [hostUuid] + sjp(session, roomId, [uuid]) { + const party = liveParties().find(candidate => candidate.host.uuid === uuid); + joinHosted(session, party ? party.host : null); + }, + + // PartyXtCommManager.sendPartyMasterpiece: the paintings on show, as + // JSON (BulletinBoard.onMasterpiecesLoaded reads pool[0]); empty for none. + sm(session) { + const gallery = masterpieces.gallery(); + session.sendXt("sm", -1, gallery.pool.length ? JSON.stringify(gallery) : ""); + }, + }; + + // "party12" / "ppartyAlice", from a buddy's "go to": joins it. false when + // the name is not a party room's. + const joinByRoomName = (session, name) => { + const aj = /^party(\d+)(?:_\d+)?$/.exec(name); + if (aj) { + joinAjParty(session, aj[1]); + return true; + } + if (/^pparty/i.test(name)) { + joinHosted(session, accounts.byName(name.slice(6))); + return true; + } + return false; + }; + + // parties whose time is up, checked once a minute. + const expire = sendHome => { + for (const party of [...hosted.values()]) { + if (party.endsAt <= now()) { + end(party, sendHome); + } + } + }; + + // generic lists: null when `listId` is not one of the party windows'. + const list = listId => { + if (Number(listId) === LIST_CUSTOM_PARTY_DEFS) { + return customDefs().map(def => def.id); + } + if (Number(listId) === LIST_PARTY_MUSIC) { + return defpacks.musicIds(); + } + return NAME_LISTS.has(Number(listId)) ? nameList(listId) : null; + }; + + return { + handlers, + timeLeft, + joinByRoomName, + expire, + list, + // the host left the game or was removed: the party goes with them. + forget(account, sendHome) { + const party = hosted.get(account.username.toLowerCase()); + if (party) { + end(party, sendHome); + } + }, + partyOf, + }; +}; diff --git a/lib/pets.js b/lib/pets.js new file mode 100644 index 0000000..6c5d2d8 --- /dev/null +++ b/lib/pets.js @@ -0,0 +1,238 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const achievements = require("./achievements.js"); +const defpacks = require("./defpacks.js"); +const {activeAvatar, isUint} = require("./player.js"); + +// pets (client side: PetManager, PetXtCommManager). A pet's species and look +// are packed into three integers by PetManager.packPetBits; the species is +// the low byte of the first. pets are free. + +const MAX_PETS = 1000; +const DEF_PET_FOOD = 1062; +const DEF_PET_TOY = 1063; +// generic list 432: the personalities a pet can have, as the ids of their +// names in the localization defPack ("Adventurous" ... "Zany"). +const PERSONALITY_LIST = 432; +const PERSONALITIES = [25865, 25932]; +// A pet has ten foods and ten toys it might favour (its def's foodListId and +// toyListId). which ten is not in any file: only the lists' ids and all the +// foods and toys are. both packs run in the order the lists were made, ten +// to a list, so a list is taken to be the ten at its place in that order. +// the newest pet's two lists (437, 438) have the lowest ids but come last. +const PER_LIST = 10; +const LATE_LISTS = [437, 438]; +// mastery (PetInventory: at 100 the pet may wear its mastery item). it grew +// from playing minigames with the pet; here it grows as the pet is walked +// from room to room. +const MASTERY_FULL = 100; +const MASTERY_PER_ROOM = 5; +const MASTERY_BITS = 0xF00; // the part of uBits PetInventory writes +const SECONDS_TO_HATCH = 259200; // PetManager.hasHatched + +const random = (min, max) => min + Math.floor(Math.random() * (max - min + 1)); + +const listOrder = type => { + const ids = defpacks.listsOfType(type); + return [...ids.filter(id => !LATE_LISTS.includes(id)), ...ids.filter(id => LATE_LISTS.includes(id))]; +}; + +// the foods (DEF_PET_FOOD) or toys (DEF_PET_TOY) of one list, as defs. +const favourites = (type, listId) => { + const index = listOrder(type).indexOf(Number(listId)); + const defs = type === DEF_PET_FOOD ? defpacks.petFoodDefs() : defpacks.petToyDefs(); + return index === -1 ? [] : defs.slice(index * PER_LIST, (index + 1) * PER_LIST); +}; + +// GenericListXtCommManager.handleMediaResponse: (defId, name string id) pairs. +const favouritesList = (type, listId) => favourites(type, listId).flatMap(def => [def.id, def.titleStrId]); + +const personalityList = () => Array.from({length: PERSONALITIES[1] - PERSONALITIES[0] + 1}, (_, i) => PERSONALITIES[0] + i); + +const pick = list => (list.length ? Number(list[random(0, list.length - 1)].id) : 0); + +// what PetCertificatePopup shows: a personality, a favourite toy and food. +const giveCharacter = pet => { + const def = defpacks.petDef(pet.lBits & 0xFF) || {}; + // eggs hatch at once here; one bought when they took three days has its + // wait ended. + if (def.isEgg === "1") { + pet.createdAt = Math.min(pet.createdAt, Math.floor(Date.now() / 1000) - SECONDS_TO_HATCH); + } + pet.personality = pet.personality || random(...PERSONALITIES); + pet.toy = pet.toy || pick(favourites(DEF_PET_TOY, def.toyListId)); + pet.food = pet.food || pick(favourites(DEF_PET_FOOD, def.foodListId)); +}; + +// called when a player walks into a room with a pet out. +const walked = account => { + const pet = account.pets.find(candidate => candidate.inv === activeAvatar(account).petInvId); + if (pet && (pet.mastery || 0) < MASTERY_FULL) { + pet.mastery = Math.min(MASTERY_FULL, (pet.mastery || 0) + MASTERY_PER_ROOM); + } +}; + +module.exports = ({others, findOnline, petFields}) => { + // PetManager.onPetCreateResponse: [success, newAmount, currencyType, invIdx, + // lBits, uBits, eBits, name, createdTs, personality, toy, food, ?] + const create = (session, [lBits, uBits, eBits, name1, name2]) => { + const {account} = session; + if (![lBits, uBits, eBits, name1, name2].every(isUint) || !defpacks.petIds().includes(Number(lBits) & 0xFF) + || account.pets.length >= MAX_PETS) { + session.sendXt("pc", -1, 0); + return; + } + const isEgg = (defpacks.petDef(Number(lBits) & 0xFF) || {}).isEgg === "1"; + const pet = { + inv: account.nextInv++, + lBits: Number(lBits), + uBits: Number(uBits), + eBits: Number(eBits), + // two localization ids, read by LocalizationManager.translatePetName. + // an egg is named when it has hatched (EggPetHatchedPopup, "pn"). + name: isEgg ? "" : `${name1}|${name2}`, + // an egg hatches three days after this (PetManager.hasHatched), so + // an egg is made that much in the past: it hatches at once. + createdAt: Math.floor(Date.now() / 1000) - (isEgg ? SECONDS_TO_HATCH : 0), + mastery: 0, + }; + giveCharacter(pet); + account.pets.push(pet); + achievements.set(account, achievements.VARS.pets, Math.max(Number(account.userVars[achievements.VARS.pets]) || 0, account.pets.length)); + accounts.save(); + session.sendXt("pc", -1, 1, account.currency.gems || 0, 0, pet.inv, ...petFields(pet), 0); + }; + + const ownPet = (account, invIdx) => account.pets.find(candidate => candidate.inv === Number(invIdx)); + + const handlers = { + // PetManager.onPetListResponse: [found, username, count, (invIdx, + // createdTs, name, lBits, uBits, eBits, mastery, personality, toy, food, + // denStoreInvId)...] + pl(session, roomId, [username]) { + // anybody's, playing or not: a player's card shows their pets. + const owner = accounts.byName(username); + const target = findOnline(username); + const pets = owner ? owner.pets : []; + session.sendXt("pl", -1, 1, username, pets.length, + ...pets.flatMap(pet => [pet.inv, pet.createdAt, pet.name, pet.lBits, pet.uBits, pet.eBits, + pet.mastery || 0, pet.personality || 0, pet.toy || 0, pet.food || 0, 0])); + if (target === session) { + // PetManager.unlockedPets: a bit per pet species (bit = id - 1). the + // pet picker dereferences this, so it must arrive before the picker + // opens; every species is unlocked. + const words = Math.ceil(Math.max(...defpacks.petIds()) / 32); + session.sendXt("pu", -1, Array(words).fill(4294967295).join(",")); + } + }, + + // PetCreator: [shopId, lBits, uBits, eBits, nameId1, nameId2, fromRedemption] + pc(session, roomId, params) { + create(session, params.slice(1)); + }, + + // same, for diamond-shop pets: [shopId, diamondDefId, lBits, uBits, eBits, nameId1, nameId2, fromRedemption] + pb(session, roomId, params) { + create(session, params.slice(2)); + }, + + // [petInvIdx], 0 = walk without a pet. PetManager.onPetSwitchResponse reads + // the pet's inventory id for its owner and the pet's look for everyone else. + ps(session, roomId, [invIdx]) { + const {account} = session; + const pet = account.pets.find(candidate => candidate.inv === Number(invIdx)) || null; + if (!pet && invIdx !== "0") { + session.sendXt("ps", -1, 0); + return; + } + activeAvatar(account).petInvId = pet ? pet.inv : 0; + accounts.save(); + const messageRoom = session.room ? session.room.id : -1; + session.sendXt("ps", messageRoom, 1, session.id, pet ? pet.inv : 0); + if (session.pos) { + for (const other of others(session)) { + other.sendXt("ps", messageRoom, 1, session.id, ...petFields(pet)); + } + } + }, + + // PetManager.onPetDismissResponse: [success, invIdx] + pd(session, roomId, [invIdx]) { + const {account} = session; + const pet = account.pets.find(candidate => candidate.inv === Number(invIdx)); + if (!pet) { + session.sendXt("pd", -1, 0, invIdx); + return; + } + account.pets = account.pets.filter(candidate => candidate !== pet); + for (const avatar of account.avatars) { + if (avatar.petInvId === pet.inv) { + avatar.petInvId = 0; + } + } + accounts.save(); + session.sendXt("pd", -1, 1, pet.inv); + }, + + // PetInventory: [masteryItem, petInvIdx] puts the pet's mastery item on + // or off, once its mastery is full. the reply (onPetMasteryResponse) is + // [success, invIdx, lBits, uBits, eBits]. + pm(session, roomId, [masteryItem, invIdx]) { + const {account} = session; + const pet = ownPet(account, invIdx); + const item = Number(masteryItem); + if (!pet || !Number.isInteger(item) || item < 0 || item > 15 || (pet.mastery || 0) < MASTERY_FULL) { + session.sendXt("pm", -1, 0); + return; + } + pet.uBits = ((pet.uBits & ~MASTERY_BITS) | (item << 8)) >>> 0; + accounts.save(); + session.sendXt("pm", -1, 1, pet.inv, pet.lBits, pet.uBits, pet.eBits); + if (pet.inv === activeAvatar(account).petInvId && session.pos) { + for (const other of others(session)) { + other.sendXt("ps", session.room.id, 1, session.id, ...petFields(pet)); + } + } + }, + + // EggPetHatchedPopup: [petInvIdx, nameId1, nameId2] names a pet hatched + // from an egg. PetManager.onPetEggNameResponse: [success, invIdx, name]. + pn(session, roomId, [invIdx, name1, name2]) { + const pet = ownPet(session.account, invIdx); + const def = pet && defpacks.petDef(pet.lBits & 0xFF); + if (!pet || ![name1, name2].every(isUint) || pet.name || !def || def.isEgg !== "1" + || pet.createdAt + SECONDS_TO_HATCH > Math.floor(Date.now() / 1000)) { + session.sendXt("pn", -1, 0, invIdx, pet ? pet.name : ""); + return; + } + pet.name = `${name1}|${name2}`; + accounts.save(); + session.sendXt("pn", -1, 1, pet.inv, pet.name); + }, + + // the pet salon minigame (MicroPetSalon via MinigameManager.sendPetItemRequest): + // [a, b, c, enviroType], the pet in use's three accessories, which + // PetManager.packPetBits keeps in bits 12 to 23 of uBits. the reply + // (PetManager.onPetItemsResponse) is [success, gems, invIdx, lBits, uBits, eBits]. + pi(session, roomId, [a, b, c]) { + const {account} = session; + const pet = ownPet(account, activeAvatar(account).petInvId); + const parts = [a, b, c].map(Number); + if (!pet || !parts.every(part => Number.isInteger(part) && part >= 0 && part <= 15)) { + session.sendXt("pi", -1, 0); + return; + } + pet.uBits = ((pet.uBits & 0xFFF) | (parts[0] << 12) | (parts[1] << 16) | (parts[2] << 20)) >>> 0; + accounts.save(); + session.sendXt("pi", -1, 1, account.currency.gems || 0, pet.inv, pet.lBits, pet.uBits, pet.eBits); + if (session.pos) { + for (const other of others(session)) { + other.sendXt("ps", session.room.id, 1, session.id, ...petFields(pet)); + } + } + }, + }; + + return {handlers, walked, giveCharacter, favouritesList, personalityList, PERSONALITY_LIST}; +}; diff --git a/lib/player.js b/lib/player.js new file mode 100644 index 0000000..ff1792a --- /dev/null +++ b/lib/player.js @@ -0,0 +1,100 @@ +"use strict"; + +const defpacks = require("./defpacks.js"); +// accessors over an account's animals, pets and items (shape: accounts.js). + +// SbiConstants.CURRENCY_NAMES; an item's currencyType indexes into this. +const CURRENCIES = ["gems", "tickets", "orbs", "diamonds", "straw", "bamboo", "wood", "stone", "silver", "gold", "gemstone", "ecoCredits"]; +const CURRENCY_DIAMONDS = 3; + +// what a diamond def's refId points at (DiamondItem.isAccessory and friends). +const DIAMOND_TYPES = {clothing: "0", denItem: "1", pet: "2", avatar: "3", denRoom: "4", customAvatar: "5"}; + +// shops send a diamond def id instead of the item's own def id when the item +// is priced in diamonds. resolves either form to {defId, cost, currencyType}, +// with `ownPrice(defId)` giving {cost, currencyType} for an ordinary item; null +// when the diamond def does not exist or is not of the expected kind. +const resolvePurchase = (defId, isDiamond, kind, ownPrice) => { + if (!isDiamond) { + return {defId: Number(defId), ...ownPrice(defId)}; + } + const diamond = defpacks.diamondDef(defId); + return diamond && diamond.type === DIAMOND_TYPES[kind] + ? {defId: Number(diamond.refId), cost: Number(diamond.cost), currencyType: CURRENCY_DIAMONDS} + : null; +}; + +const activeAvatar = account => account.avatars.find(avatar => avatar.perUserAvId === account.activeAvatar) || account.avatars[0]; + +// the requested animal, or the one in use when the id is unknown. +const avatarById = (account, perUserAvId) => + account.avatars.find(avatar => avatar.perUserAvId === Number(perUserAvId)) || activeAvatar(account); + +const activePet = account => account.pets.find(pet => pet.inv === activeAvatar(account).petInvId) || null; + +const wornItems = (account, avatar) => account.items.filter(item => item.on.includes(avatar.avInvId)); + +// item.EquippedAvatars: comma-separated 32-bit words, one bit per avInvId of +// an animal wearing the item. +const equippedBits = item => { + const words = [0]; + for (const avInvId of item.on) { + const word = avInvId >>> 5; + while (words.length <= word) { + words.push(0); + } + words[word] = (words[word] | (1 << (avInvId & 31))) >>> 0; + } + return words.join(","); +}; + +// how much an account may hold, as the patched client counts +// (shop.ShopManager), and how many pieces one animal may wear at once: the +// seven places clothes go, three to a place, and a few to spare. everyone in +// a room is sent what each animal there wears. +const MAX_ITEMS = 5000; +const MAX_DEN_ITEMS = 5000; +const MAX_WORN = 24; +// has the account room for `count` more? `kind` is "items" (clothing) or "denItems". +const hasRoom = (account, kind, count = 1) => account[kind].length + count <= (kind === "items" ? MAX_ITEMS : MAX_DEN_ITEMS); + +// adds a clothing item to an account's inventory (the caller saves); null +// when the inventory is full. +const addClothing = (account, defId, color) => { + if (!hasRoom(account, "items")) { + return null; + } + const item = {inv: account.nextInv++, def: Number(defId), color: Number(color), on: []}; + account.items.push(item); + return item; +}; + +// ItemXtCommManager.itemsChangedListResponse ("2" = inventory changed): tells +// a connected player about a new item. [type, inUse, perUserAvId, username, +// color, addedCount, removedCount, (invIdx, defId)..., removedInvIdx...] +const sendClothingAdded = (session, item) => { + if (!item) { + return; // the inventory was full + } + session.sendXt("il", -1, 2, 0, activeAvatar(session.account).perUserAvId, session.account.username, item.color, 1, 0, item.inv, item.def); +}; + +// the same message, for items that left the inventory (one inventory id or +// a list of them). +const sendClothingRemoved = (session, inv) => { + const gone = [].concat(inv); + session.sendXt("il", -1, 2, 0, activeAvatar(session.account).perUserAvId, session.account.username, 0, 0, gone.length, ...gone); +}; + +// what goes in the "days since last login" field of a player's card. the +// patched client (swf-src/BuddyCard.as) takes it as the time the player was +// last seen, in seconds, to show as a time of day and a date; -2 is "online +// now" and -1 "unknown", which the official client showed as "More than 30 +// Days". +const LAST_SEEN_ONLINE = -2; +const LAST_SEEN_UNKNOWN = -1; +const lastSeenField = (account, isOnline) => (isOnline ? LAST_SEEN_ONLINE : account.lastSeen || account.lastLogin || LAST_SEEN_UNKNOWN); + +const isUint = text => /^\d{1,10}$/.test(text) && Number(text) <= 0xFFFFFFFF; + +module.exports = {MAX_ITEMS, MAX_DEN_ITEMS, MAX_WORN, hasRoom, CURRENCIES, DIAMOND_TYPES, resolvePurchase, activeAvatar, avatarById, activePet, wornItems, equippedBits, addClothing, sendClothingAdded, sendClothingRemoved, lastSeenField, isUint}; diff --git a/lib/reports.js b/lib/reports.js new file mode 100644 index 0000000..7fb523e --- /dev/null +++ b/lib/reports.js @@ -0,0 +1,97 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const limits = require("./limits.js"); + +// player reports (client side: ReportAPlayer, FacilitatorXtCommManager). A +// report is who, about whom, one of the game's fixed reasons, and what the +// reporter typed about it (the patched report window has a text box; the +// game's own had none). they wait in the admin panel's Reports page. + +const SCHEMA = ` + CREATE TABLE IF NOT EXISTS reports ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + created_at INTEGER NOT NULL, + reporter TEXT NOT NULL, + target TEXT NOT NULL, + reason INTEGER NOT NULL, + detail TEXT NOT NULL, + context TEXT NOT NULL, + room TEXT NOT NULL, + handled_at INTEGER + ); +`; + +// ReportAPlayer.reasonIdForReason, in the game's own words. +const REASONS = { + 1: "Being a bully", + 2: "Bad words", + 3: "Personal info", + 4: "Safety", + 5: "Inappropriate den", + 6: "Scamming", + 7: "Inappropriate behavior", + 13: "Inappropriate username", + 14: "Inappropriate Jam-A-Gram", + 15: "Inappropriate Jammer Wall post", + 16: "Inappropriate Masterpiece", +}; +const MAX_DETAIL = 200; +const MAX_CONTEXT = 4000; +const MAX_OPEN = 5000; // reports waiting; further ones are dropped +const MERGE_SECONDS = 10; + +const perTenMinutes = limits.limiter(10, 600000); +const now = () => Math.floor(Date.now() / 1000); +const clean = (text, max) => String(text === undefined ? "" : text).replace(/[\u0000-\u0008\u000b-\u001f\u007f]/g, " ").trim().slice(0, max); + +const load = () => accounts.database().exec(SCHEMA); + +const openCount = () => accounts.database().prepare("SELECT COUNT(*) AS count FROM reports WHERE handled_at IS NULL").get().count; + +// files a report. the patched client sends what was typed in a message of +// its own just before the game's usual report message, so a second report +// by the same player about the same player within a few seconds is the +// same one: its typed text is kept and nothing new is filed. +// returns false when the reporter has sent too many. +const file = ({reporter, target, reason, detail = "", context = "", room = ""}) => { + const db = accounts.database(); + const recent = db.prepare("SELECT id, detail FROM reports WHERE reporter = ? AND target = ? AND created_at >= ? ORDER BY id DESC LIMIT 1") + .get(reporter, target, now() - MERGE_SECONDS); + if (recent) { + if (!recent.detail && detail) { + db.prepare("UPDATE reports SET detail = ? WHERE id = ?").run(clean(detail, MAX_DETAIL), recent.id); + } + return true; + } + if (!perTenMinutes.allow(reporter.toLowerCase()) || openCount() >= MAX_OPEN) { + return false; + } + db.prepare("INSERT INTO reports (created_at, reporter, target, reason, detail, context, room) VALUES (?, ?, ?, ?, ?, ?, ?)") + .run(now(), reporter, target, Number.isInteger(reason) ? reason : 0, clean(detail, MAX_DETAIL), clean(context, MAX_CONTEXT), clean(room, 100)); + console.log(`[world] ${reporter} reported "${target}" (${REASONS[reason] || `reason ${reason}`})`); + return true; +}; + +const row = report => ({ + id: report.id, + createdAt: report.created_at, + reporter: report.reporter, + target: report.target, + reason: REASONS[report.reason] || `Reason ${report.reason}`, + detail: report.detail, + context: report.context, + room: report.room, + handledAt: report.handled_at, +}); + +// reports waiting, oldest first; or with `handled`, the latest dealt with. +const list = (handled = false) => accounts.database() + .prepare(handled + ? "SELECT * FROM reports WHERE handled_at IS NOT NULL ORDER BY handled_at DESC LIMIT 200" + : "SELECT * FROM reports WHERE handled_at IS NULL ORDER BY id LIMIT 500") + .all().map(row); + +const markHandled = id => accounts.database().prepare("UPDATE reports SET handled_at = ? WHERE id = ? AND handled_at IS NULL").run(now(), id).changes > 0; + +module.exports = {load, file, list, markHandled, openCount, MAX_DETAIL}; diff --git a/lib/reserved-names.txt b/lib/reserved-names.txt new file mode 100644 index 0000000..4828e77 --- /dev/null +++ b/lib/reserved-names.txt @@ -0,0 +1,27 @@ +# Names nobody may sign up with: the ones that would pass for whoever runs +# the game. One to a line; capitals, spaces, dots and dashes do not matter. +# +# A username is refused when it is one of these, or when one of its words is +# ("Admin Bob", "AJHQ-Liza"): never for merely containing one ("Badminton" +# is fine). The names of the Epic Dens are refused too (they are how a den +# is asked for), and so is anything in public/filter/level1.txt. Read again +# whenever it changes. The admin panel's own rename is not held to this. + +ajhq +aj hq +animal jam hq +animaljam +animal jam +wildworks +wild works +moderator +mod +mods +admin +admins +administrator +staff +owner +developer +support +official diff --git a/lib/retention.js b/lib/retention.js new file mode 100644 index 0000000..bed52ee --- /dev/null +++ b/lib/retention.js @@ -0,0 +1,52 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const config = require("../config.js"); +const fs = require("fs"); +const path = require("path"); + +// how long the records about players are kept, as the privacy policy says +// (public/privacy.html): change one and change the other. run at start and +// once a day. chat has its own, shorter time (lib/chatlog.js), and sign-in +// histories are trimmed as they are written (lib/accounts.js). + +const DAY_SECONDS = 86400; +const YEAR_DAYS = 365; +// the game clients' error reports (data/client-errors.log, lib/http.js) are +// emptied this often, so nothing in the file is older. +const ERROR_REPORT_DAYS = 30; +const ERRORS_CLEARED = "client_errors_cleared"; + +const sweep = () => { + const db = accounts.database(); + const before = Math.floor(Date.now() / 1000) - YEAR_DAYS * DAY_SECONDS; + // reports, feedback and username requests, a year after they were dealt with. + db.prepare("DELETE FROM reports WHERE handled_at IS NOT NULL AND handled_at < ?").run(before); + db.prepare("DELETE FROM feedback WHERE handled_at IS NOT NULL AND handled_at < ?").run(before); + db.prepare("DELETE FROM name_requests WHERE handled_at IS NOT NULL AND handled_at < ?").run(before); + // what moderators did, after a year. + db.prepare("DELETE FROM mod_log WHERE at < ?").run(before); + // the record of bans: while the account exists, and a year past it (or + // for a line about an address, a year). + db.prepare("DELETE FROM ban_log WHERE at < ? AND (account_id IS NULL OR account_id NOT IN (SELECT id FROM accounts))").run(before); + const now = Math.floor(Date.now() / 1000); + const cleared = Number(accounts.setting(ERRORS_CLEARED)) || 0; + if (cleared === 0) { + accounts.setSetting(ERRORS_CLEARED, String(now)); + } + else if (now - cleared > ERROR_REPORT_DAYS * DAY_SECONDS) { + try { + fs.truncateSync(path.join(config.dataDir, "client-errors.log")); + } + catch (err) { + } + accounts.setSetting(ERRORS_CLEARED, String(now)); + } +}; + +const load = () => { + sweep(); + setInterval(sweep, DAY_SECONDS * 1000).unref(); +}; + +module.exports = {load, sweep, YEAR_DAYS}; diff --git a/lib/roominfo.js b/lib/roominfo.js new file mode 100644 index 0000000..bc8a85b --- /dev/null +++ b/lib/roominfo.js @@ -0,0 +1,101 @@ +"use strict"; + +const zlib = require("zlib"); +const amf3 = require("./amf3.js"); +const cdn = require("./cdn.js"); +const defpacks = require("./defpacks.js"); + +// what a room's own file says about it: its name ("Jam Mart Clothing"), +// which the client shows in the corner of the screen, and which shops stand +// in it. the room defPack has neither, and a shop's title is not in any +// defPack at all: the official server sent both along. the file is the +// same one the client loads to draw the room (roomDefs/.xroom: zlib, +// then AMF3), so reading it here costs no extra download once anyone has +// been in the room. + +// what the room editor left in files nobody named. +const UNNAMED = "Display Name"; +// rooms whose file has no name and whose path does not spell it either. +const NAMES = new Map([ + ["jamaa_township.room_diamonds", "Diamond Shop"], + ["jamaa_township.room_alphahq", "Alpha Headquarters"], + ["oceans.deep_sea", "Deep Blue"], + ["aussie.room_main", "Kimbara Outback"], + ["aussie.room_aushop", "Outback Imports"], + ["aussie.room_hos", "Medical Center"], +]); +const VOLUME_SHOP = 12; // ActorVolume.type: clicking it opens generic list `typeDefId` + +const rooms = new Map(); // "jamaa_township.clothes_shop" -> {name, shops: Set of list ids} +const loading = new Map(); + +const filePath = base => cdn.hashedPath(`roomDefs/${base.replace(/\./g, "/")}.xroom`); + +const parse = body => { + const room = amf3.decode(zlib.inflateSync(body)); + const settings = (room.actors.ActorSettings || [])[0] || {}; + const volumes = room.actors.ActorVolume || []; + return { + name: typeof settings.name === "string" && settings.name.trim() !== UNNAMED ? settings.name.trim() : "", + shops: new Set(volumes.filter(volume => Number(volume.type) === VOLUME_SHOP).map(volume => Number(volume.typeDefId))), + }; +}; + +const remember = (base, body) => { + try { + rooms.set(base, body ? parse(body) : {name: "", shops: new Set()}); + } + catch (err) { + rooms.set(base, {name: "", shops: new Set()}); + } +}; + +// reads the room's file, downloading it if nobody has been there yet. +// nothing waits on this: the first player ever to enter a room gets the +// fallback name below, everyone after them the real one. +const ensure = base => { + if (rooms.has(base) || loading.has(base)) { + return; + } + loading.set(base, cdn.get(filePath(base)) + .then(body => remember(base, body), () => {}) + .finally(() => loading.delete(base))); +}; + +// at start: every room whose file is already in the cache. +const preload = async () => { + for (const path of defpacks.roomPaths()) { + const base = path.replace(/\//g, "."); + const body = await cdn.cached(filePath(base)); + if (body) { + remember(base, body); + } + } + console.log(`[rooms] names of ${rooms.size} rooms read from the cache`); +}; + +// A name made from the path, for a room not read yet or left unnamed: +// "jamaa_township.room_main" -> "Jamaa Township", "oceans.crystal_reef" -> +// "Crystal Reef". the seasonal versions of a land ("room_main_summer") are +// that land. +const titleCase = text => text.split("_").filter(Boolean).map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(" "); +const fallbackName = base => { + const [folder, room = ""] = base.split("."); + return NAMES.get(base) || (/^room_main|^main_room|^$/.test(room) ? titleCase(folder) : titleCase(room.replace(/^room_/, ""))); +}; + +const name = base => (rooms.get(base) || {}).name || fallbackName(base); + +// the title of a shop opened in this room, as the id of a localization +// string (Shop.gotItemListCallback), or "" to leave the shop window's own. +// A shop's title was its room's name ("Jam Mart Clothing", "Epic Wonders"); +// a shop standing in a land's main room has no name of its own to be found. +const shopTitle = (base, listId) => { + const room = rooms.get(base); + if (!room || !room.shops.has(Number(listId)) || /\.room_main/.test(base)) { + return ""; + } + return defpacks.stringId(name(base)) || ""; +}; + +module.exports = {ensure, preload, name, shopTitle}; diff --git a/lib/sale-dates.json b/lib/sale-dates.json new file mode 100644 index 0000000..64a84ce --- /dev/null +++ b/lib/sale-dates.json @@ -0,0 +1,4829 @@ +{ + "builds": [1636,1830], + "clothing": { + "21": [[17259,17653]], + "63": [[19048,19152],[19777,19830],[20137,20198],[20508,20569]], + "65": [[18427,18961],[19867,19961],[20224,20287],[20588,20651]], + "125": [[19959,20053],[20331,20425],[20695,20758]], + "133": [[19958,20052],[20329,20423],[20693,20756]], + "135": [[19019,19128],[19749,19821],[20112,20173],[20483,20544]], + "137": [[19939,20033],[20312,20406],[20676,20739]], + "139": [[17259,17653]], + "140": [[19022,19134],[19739,19812],[20103,20164],[20474,20535]], + "144": [[17253,17630],[19988,20051],[20349,20442],[20713,20806]], + "147": [[19960,20054],[20333,20427],[20697,20760]], + "152": [[18997,19074],[19725,19798],[20090,20151],[20460,20522]], + "161": [[17255,17632]], + "162": [[19874,19968],[20226,20289],[20590,20653]], + "209": [[19177,19189],[19537,19552],[19902,19920],[20265,20291],[20629,20656]], + "211": [[19177,19189],[19539,19552],[19908,19923],[20271,20291],[20633,20656]], + "214": [[19179,19189],[19540,19552],[19908,19923],[20272,20287],[20635,20652]], + "220": [[19268,19308],[19633,19673],[20011,20039],[20377,20404],[20741,20769]], + "221": [[17259,17653]], + "224": [[19277,19308],[19637,19673],[19998,20039],[20369,20404],[20733,20769]], + "228": [[19280,19308],[19652,19673],[20003,20039],[20362,20404],[20726,20769]], + "235": [[17259,17653]], + "238": [[19288,19308],[19659,19673],[20012,20039],[20378,20404],[20742,20769]], + "241": [[19299,19338],[19672,19703],[20035,20069],[20401,20434]], + "244": [[19297,19338],[19664,19703],[20049,20069],[20412,20434]], + "245": [[18972,19004],[19336,19369],[19700,19734],[20068,20100],[20430,20465]], + "246": [[19327,19398],[20448,20465]], + "247": [[18977,19004],[19343,19369],[19712,19734],[20078,20100],[20440,20465]], + "248": [[18985,19004],[19350,19369],[19693,19734],[20059,20100],[20423,20465]], + "250": [[19008,19082],[19728,19766],[20093,20154],[20464,20525]], + "255": [[19034,19053],[19753,19784],[20132,20149],[20504,20514]], + "256": [[19027,19063],[19756,19784],[20121,20149],[20491,20514]], + "259": [[19139,19253],[19862,19956],[20221,20284],[20585,20648]], + "261": [[18332,18355]], + "262": [[19061,19094],[19793,19825],[20157,20180],[20523,20545]], + "263": [[19063,19094],[19798,19825],[20154,20180],[20525,20545]], + "264": [[19059,19094],[19785,19815],[20148,20180],[20518,20545]], + "266": [[17226,17649]], + "267": [[17226,17658]], + "269": [[19745,19835],[20109,20170],[20481,20542]], + "294": [[18157,18569]], + "297": [[19270,19308],[19641,19673],[20007,20039],[20371,20404],[20735,20769]], + "307": [[17293,17652]], + "310": [[17292,17651]], + "313": [[19069,19251],[20175,20269],[20538,20632]], + "321": [[19267,19308],[19639,19673],[20005,20039],[20368,20404],[20732,20769]], + "322": [[19284,19308],[19653,19673],[20015,20039],[20380,20404],[20744,20769]], + "323": [[17776,18440]], + "328": [[19289,19308],[19655,19673],[20017,20039],[20382,20404],[20746,20769]], + "331": [[19292,19308],[19657,19673],[20019,20039],[20385,20404],[20749,20769]], + "333": [[19731,19764],[20095,20156],[20464,20525]], + "334": [[18993,19073],[20086,20169],[20457,20539]], + "336": [[18978,19004],[19331,19369],[19703,19734],[20069,20100],[20425,20465]], + "339": [[18965,19004],[19340,19369],[19705,19734],[20071,20100],[20445,20465]], + "340": [[18966,19004],[19338,19369],[19705,19734],[20071,20100],[20443,20465]], + "343": [[17259,17653]], + "346": [[17226,17649]], + "351": [[17289,17648]], + "352": [[17226,17649]], + "354": [[17226,17649]], + "357": [[19024,19053],[19754,19783],[20116,20159],[20487,20524]], + "358": [[19033,19053],[19759,19784],[20122,20149],[20492,20514]], + "359": [[19028,19053],[19755,19784],[20119,20149],[20490,20514]], + "360": [[17226,17649]], + "363": [[20459,20551]], + "377": [[19062,19094],[19792,19825],[20150,20180],[20516,20545]], + "378": [[19064,19094],[19789,19815],[20156,20180],[20526,20545]], + "381": [[19058,19094],[19798,19825],[20152,20180],[20519,20545]], + "382": [[19055,19094],[19795,19825],[20164,20180],[20529,20545]], + "390": [[17226,17649]], + "391": [[17226,17649]], + "396": [[20098,20159],[20470,20531]], + "398": [[19266,19308],[19631,19673],[20018,20039],[20382,20404],[20746,20769]], + "417": [[19930,20024],[20294,20388],[20659,20753]], + "418": [[19182,19266],[19918,20012],[20284,20378],[20648,20742]], + "426": [[19937,20031],[20308,20402],[20672,20735]], + "433": [[18314,18395]], + "435": [[17942,18436]], + "439": [[19177,19189],[19537,19552],[19907,19923],[20272,20287],[20635,20652]], + "440": [[19177,19189],[19537,19552],[19907,19923],[20272,20287],[20635,20652]], + "441": [[16977,17367]], + "442": [[19177,19189],[19537,19552],[19907,19923],[20272,20287],[20635,20652]], + "443": [[19177,19189],[19537,19552],[19907,19923],[20272,20287],[20635,20652]], + "444": [[19177,19189],[19537,19552],[19907,19923],[20272,20287],[20635,20652]], + "450": [[17226,17649]], + "453": [[19868,19962],[20231,20294],[20595,20658]], + "456": [[19869,19963],[20233,20296],[20597,20660]], + "473": [[19154,19259],[19881,19975],[20245,20308],[20609,20672]], + "481": [[19281,19308],[19639,19673],[20011,20039],[20373,20404],[20737,20769]], + "483": [[19258,19308],[19633,19673],[20001,20039],[20364,20404],[20728,20769]], + "484": [[19293,19308],[19660,19673],[20005,20039],[20370,20404],[20734,20769]], + "485": [[19281,19308],[19633,19673],[20001,20039],[20362,20404],[20726,20769]], + "486": [[17280,17653]], + "487": [[19287,19308],[19658,19673],[20026,20039],[20362,20404],[20726,20769]], + "491": [[19278,19308],[19647,19673],[20016,20039],[20382,20404],[20746,20769]], + "493": [[19296,19308],[19660,19673],[19998,20039],[20364,20404],[20728,20769]], + "494": [[19280,19308],[19649,19673],[20013,20039],[20378,20404],[20742,20769]], + "495": [[19270,19308],[19629,19673],[20004,20039],[20376,20404],[20740,20769]], + "501": [[19294,19308],[19661,19673],[20004,20039],[20362,20404],[20726,20769]], + "502": [[19286,19308],[19656,19673],[20019,20039],[20384,20404],[20748,20769]], + "503": [[19276,19308],[19647,19673],[20011,20039],[20375,20404],[20739,20769]], + "504": [[19635,19673],[20003,20039],[20366,20404],[20730,20769]], + "505": [[19273,19308],[19643,19673],[20009,20039],[20373,20404],[20737,20769]], + "506": [[17226,17649]], + "528": [[18968,19004],[19333,19369],[19711,19734],[20077,20100],[20434,20465]], + "529": [[17251,17628]], + "538": [[17226,17649]], + "543": [[19031,19053],[19761,19784],[20130,20149],[20496,20514]], + "547": [[18419,18813]], + "577": [[19973,20066],[20337,20430],[20701,20764]], + "578": [[19973,20066],[20337,20430],[20701,20764]], + "594": [[17226,17649]], + "595": [[17226,17649]], + "596": [[17227,17650]], + "597": [[18472,18946]], + "598": [[18460,18945]], + "601": [[18097,18442]], + "612": [[19178,19189],[19543,19552],[19912,19924],[20276,20287],[20640,20652]], + "613": [[19176,19189],[19535,19552],[19906,19920],[20269,20291],[20632,20656]], + "614": [[19175,19189],[19536,19552],[19903,19920],[20266,20291],[20630,20656]], + "629": [[19923,20017],[20296,20390],[20661,20755]], + "646": [[19091,19176],[19820,19913],[20195,20288],[20559,20622]], + "652": [[18998,19272],[19752,19845],[20114,20175],[20485,20546]], + "663": [[19293,19308],[19657,19673],[19996,20039],[20360,20404],[20724,20769]], + "664": [[19291,19308],[19648,19673],[19998,20039],[20362,20404],[20726,20769]], + "665": [[17250,17627]], + "676": [[17226,17649]], + "690": [[18979,19004],[19349,19369],[19692,19734],[20058,20100],[20424,20465]], + "692": [[18983,19004],[19353,19369],[19698,19734],[20427,20465]], + "703": [[19747,19840],[20112,20173],[20484,20545]], + "707": [[19020,19130],[19750,19832],[20113,20174],[20484,20545]], + "710": [[18999,19075],[19734,19806],[20097,20158],[20468,20529]], + "713": [[19015,19126],[19732,19804],[20096,20157],[20467,20528]], + "714": [[18987,19072],[20090,20185],[20455,20534]], + "718": [[19027,19063],[19759,19784],[20118,20149],[20490,20514]], + "720": [[19025,19053],[19753,19784],[20120,20149],[20489,20514]], + "721": [[19025,19053],[19753,19784],[20120,20149],[20490,20514]], + "724": [[19058,19094],[19792,19825],[20152,20180],[20520,20545]], + "725": [[18313,18353]], + "726": [[18325,18355]], + "729": [[19053,19084],[19784,19815],[20150,20180],[20519,20545]], + "730": [[17280,17653]], + "731": [[17259,17653]], + "732": [[17259,17646]], + "743": [[19972,20065],[20335,20428],[20698,20762]], + "761": [[18425,18813]], + "766": [[17943,18437]], + "767": [[19132,19192],[19860,19954],[20219,20282],[20583,20646]], + "774": [[17226,17649]], + "779": [[19238,19368],[19610,19704],[19987,20080],[20348,20441],[20712,20805]], + "780": [[20085,20174],[20441,20465]], + "781": [[19177,19189],[19537,19552],[19907,19923],[20272,20287],[20635,20652]], + "782": [[19177,19189],[19537,19552],[19907,19923],[20272,20287],[20635,20652]], + "783": [[19173,19189],[19541,19552],[19909,19923],[20273,20287],[20637,20652]], + "784": [[17226,17649]], + "785": [[17226,17649]], + "796": [[19945,20039],[20324,20418],[20688,20751]], + "810": [[19944,20038],[20322,20416],[20686,20749]], + "812": [[19974,20006],[20339,20432],[20703,20796]], + "819": [[19625,19749]], + "820": [[19623,19747]], + "821": [[19624,19748]], + "822": [[17226,17649]], + "823": [[18035,18439]], + "828": [[19272,19308],[19632,19673],[19997,20039],[20356,20404],[20725,20769]], + "829": [[19265,19308],[19630,19673],[19999,20039],[20361,20404],[20725,20769]], + "830": [[19260,19308],[19629,19673],[19998,20039],[20359,20404],[20723,20769]], + "831": [[19266,19308],[19635,19673],[20001,20039],[20362,20404],[20726,20769]], + "834": [[19259,19308],[19627,19673],[19997,20039],[20357,20404],[20721,20769]], + "835": [[19271,19308],[19643,19673],[20013,20039],[20379,20404],[20743,20769]], + "836": [[19270,19308],[19642,19673],[20006,20039],[20372,20404],[20736,20769]], + "837": [[19272,19308],[19635,19673],[20018,20039],[20378,20404],[20742,20769]], + "838": [[19295,19308],[19657,19673],[20027,20039],[20391,20404],[20755,20769]], + "839": [[19274,19308],[19635,19673],[19998,20039],[20365,20404],[20729,20769]], + "840": [[19282,19308],[19640,19673],[19998,20039],[20372,20404],[20736,20769]], + "849": [[18978,19004],[19344,19369],[19690,19734],[20058,20100],[20424,20465]], + "850": [[19006,19079],[19727,19800],[20092,20153],[20463,20524]], + "852": [[19012,19120],[19729,19802],[20094,20155],[20465,20526]], + "869": [[19315,19469],[19679,19835],[20044,20200],[20410,20504]], + "870": [[18980,19004],[19348,19369],[19692,19734],[20058,20100],[20423,20465]], + "871": [[18984,19004],[19350,19369],[19693,19734],[20059,20100],[20423,20465]], + "872": [[18962,19004],[19715,19734],[20082,20100],[20446,20465]], + "873": [[18999,19077],[19744,19803],[20105,20166],[20475,20536]], + "874": [[18997,19075],[19737,19799],[20102,20163],[20472,20533]], + "877": [[18973,19004],[19337,19369],[19713,19734],[20079,20100],[20442,20465]], + "889": [[18293,18332]], + "891": [[19036,19053],[19767,19784],[20131,20149],[20500,20514]], + "892": [[19028,19053],[19757,19784],[20122,20149],[20492,20514]], + "901": [[19036,19053],[19761,19784],[20126,20149],[20497,20514]], + "905": [[19025,19053],[19766,19784],[20128,20149],[20493,20514]], + "911": [[19060,19094],[19788,19815],[20166,20180],[20529,20545]], + "912": [[19067,19094],[19787,19815],[20159,20180],[20524,20545]], + "925": [[19097,19124],[19811,19844],[20207,20239],[20570,20633]], + "930": [[17226,17649]], + "938": [[19088,19173],[19818,19911],[20188,20281],[20549,20612]], + "939": [[19077,19168],[19805,19899],[20172,20266],[20533,20627]], + "943": [[19895,19989],[20252,20315],[20616,20679]], + "945": [[19896,19990],[20254,20317],[20618,20681]], + "946": [[19897,19991],[20259,20322],[20623,20686]], + "974": [[19174,19189],[19538,19552],[19904,19920],[20267,20291],[20631,20656]], + "981": [[17944,18323]], + "983": [[19283,19308],[19651,19673],[20022,20039],[20388,20404],[20750,20769]], + "998": [[17226,17649]], + "1001": [[18467,19241]], + "1003": [[19224,19238],[19589,19603],[19953,19969],[20319,20353],[20683,20718]], + "1004": [[19221,19238],[19588,19603],[19952,19969],[20317,20353],[20681,20718]], + "1005": [[19222,19238],[19587,19603],[19951,19969],[20315,20353],[20679,20718]], + "1033": [[19273,19308],[19649,19673],[20020,20039],[20384,20404],[20748,20769]], + "1034": [[19269,19308],[19633,19673],[20021,20039],[20380,20404],[20744,20769]], + "1035": [[19271,19308],[19633,19673],[20021,20039],[20382,20404],[20746,20769]], + "1036": [[18517,18944]], + "1037": [[19245,19365],[19617,19711],[19995,20083],[20355,20448],[20719,20812]], + "1044": [[17226,17649]], + "1052": [[18967,19004],[19710,19734],[20076,20100],[20439,20465]], + "1055": [[19321,19400],[19685,19765],[20051,20131],[20423,20465]], + "1056": [[19711,19713],[20077,20079]], + "1060": [[18981,19004],[19340,19369],[19698,19734],[20064,20100],[20425,20465]], + "1061": [[18962,19004],[19333,19369],[19705,19734],[20071,20100],[20432,20465]], + "1063": [[18970,19004],[19334,19369],[19703,19734],[20069,20100],[20431,20465]], + "1064": [[18971,19004],[19335,19369],[19701,19734],[20067,20100],[20429,20465]], + "1065": [[18969,19004],[19707,19734],[20075,20100],[20437,20465]], + "1083": [[18966,19004],[19329,19369],[19708,19734],[20074,20100],[20435,20465]], + "1085": [[19014,19124],[19748,19820],[20111,20172],[20482,20543]], + "1087": [[18994,19066],[19730,19795],[20091,20152],[20461,20522]], + "1092": [[17909,18803]], + "1096": [[18293,18332]], + "1097": [[19029,19053],[19762,19784],[20125,20149],[20496,20514]], + "1098": [[19035,19053],[19766,19784],[20133,20149],[20506,20514]], + "1099": [[19740,19830],[20107,20168]], + "1104": [[18304,18324]], + "1105": [[18306,18324]], + "1106": [[19026,19053],[19753,19783],[20115,20159],[20486,20524]], + "1112": [[17440,17491]], + "1113": [[19053,19094],[19789,19815],[20160,20180],[20527,20545]], + "1114": [[19057,19094],[19791,19825],[20162,20180],[20527,20545]], + "1115": [[19052,19084],[19783,19815],[20145,20180],[20516,20545]], + "1127": [[19065,19081],[19796,19812],[20161,20177],[20526,20542]], + "1128": [[19055,19094],[19790,19825],[20164,20180],[20528,20545]], + "1154": [[19946,20040],[20326,20420],[20690,20753]], + "1155": [[17440,17490]], + "1181": [[19140,19239],[19875,19907],[20240,20296],[20605,20661]], + "1208": [[17295,17661]], + "1218": [[18507,18905]], + "1219": [[18509,18908]], + "1220": [[18510,18909]], + "1221": [[19175,19189],[19536,19552],[19909,19923],[20273,20287],[20637,20652]], + "1222": [[19176,19189],[19539,19552],[19907,19920],[20268,20291],[20634,20656]], + "1223": [[19177,19189],[19541,19552],[19911,19923],[20275,20287],[20639,20652]], + "1237": [[19925,20019],[20289,20383],[20654,20748]], + "1241": [[19938,20032],[20310,20404],[20674,20737]], + "1247": [[19179,19261],[19916,20010],[20280,20374],[20644,20738]], + "1251": [[19931,20025],[20303,20397],[20668,20762]], + "1263": [[18307,18390]], + "1269": [[19276,19308],[19630,19673],[20026,20039],[20389,20404],[20753,20769]], + "1270": [[19286,19308],[19644,19673],[20003,20039],[20368,20404],[20732,20769]], + "1271": [[19267,19308],[19634,19673],[20005,20039],[20367,20404],[20731,20769]], + "1272": [[19275,19308],[19641,19673],[20012,20039],[20380,20404],[20744,20769]], + "1273": [[19285,19308],[19655,19673],[20019,20039],[20385,20404],[20749,20769]], + "1285": [[19267,19308],[19636,19673],[20002,20039],[20362,20404],[20726,20769]], + "1286": [[19284,19308],[19641,19673],[20008,20039],[20371,20404],[20735,20769]], + "1287": [[19269,19308],[19638,19673],[20008,20039],[20374,20404],[20738,20769]], + "1288": [[19267,19308],[19637,19673],[20007,20039],[20373,20404],[20737,20769]], + "1289": [[19266,19308],[19631,19673],[20000,20039],[20362,20404],[20726,20769]], + "1291": [[19291,19308],[19648,19673],[20017,20039],[20383,20404],[20747,20769]], + "1292": [[19283,19308],[19639,19673],[20010,20039],[20371,20404],[20735,20769]], + "1296": [[19601,19694],[19979,20072],[20341,20434],[20705,20798]], + "1297": [[19236,19365],[19602,19695],[19980,20073],[20342,20435],[20706,20799]], + "1298": [[19301,19348],[19665,19713],[20043,20079],[20408,20444]], + "1306": [[18232,18274]], + "1307": [[19239,19370],[19615,19709],[19993,20079],[20351,20444],[20715,20808]], + "1308": [[19298,19338],[19666,19703],[20036,20069],[20412,20434]], + "1316": [[19735,19808],[20099,20162],[20414,20508],[20470,20531]], + "1317": [[18982,19004],[19332,19369],[19706,19734],[20072,20100],[20433,20465]], + "1318": [[19738,19814],[20101,20162],[20472,20533]], + "1319": [[18962,19004],[19328,19369],[19697,19734],[20063,20100],[20427,20465]], + "1320": [[18967,19004],[19329,19369],[19697,19734],[20063,20100],[20431,20465]], + "1322": [[17889,17891]], + "1324": [[18964,19004],[19330,19369],[19704,19734],[20070,20100],[20437,20465]], + "1325": [[18975,19004],[19339,19369],[19704,19734],[20070,20100],[20425,20465]], + "1326": [[19013,19122],[19743,19817],[20108,20169],[20479,20540]], + "1350": [[19023,19053],[19754,19783],[20117,20159],[20485,20524]], + "1375": [[19055,19094],[19799,19825],[20147,20180],[20519,20545]], + "1376": [[19066,19094],[19786,19815],[20155,20180],[20522,20545]], + "1377": [[18315,18373],[20529,20545]], + "1378": [[19065,19094],[19788,19825],[20149,20180],[20516,20545]], + "1393": [[19056,19094],[19784,19815],[20153,20180],[20521,20545]], + "1429": [[19071,19166],[19806,19900],[20177,20271],[20540,20634]], + "1430": [[19181,19264],[19917,20011],[20282,20376],[20646,20740]], + "1431": [[19098,19124],[19813,19845],[20194,20226],[20547,20579],[20547,20583]], + "1432": [[19096,19124],[19812,19845],[20201,20233],[20547,20579]], + "1433": [[19099,19124],[19813,19845],[20199,20231],[20545,20577]], + "1439": [[19076,19167],[19807,19901],[20179,20273],[20542,20636]], + "1440": [[19090,19174],[19819,19912],[20180,20274],[20551,20614]], + "1441": [[19085,19172],[19815,19908],[20194,20287],[20558,20621]], + "1442": [[17278,17573]], + "1443": [[18045,18441]], + "1446": [[17284,17653]], + "1494": [[19141,19240],[19876,19908],[20242,20296],[20607,20661]], + "1534": [[19924,20018],[20287,20381],[20652,20746]], + "1535": [[19147,19248],[19883,19977],[20247,20310],[20611,20674]], + "1540": [[19932,20026],[20301,20395],[20666,20760]], + "1567": [[19821,19823]], + "1577": [[19237,19367],[19609,19703],[19986,20079],[20346,20439],[20710,20803]], + "1578": [[19235,19366],[19608,19702],[19981,20074],[20344,20437],[20708,20801]], + "1614": [[19285,19308],[19654,19673],[20023,20039],[20390,20404],[20751,20769]], + "1615": [[19274,19308],[19631,19673],[20023,20039],[20387,20404],[20751,20769]], + "1648": [[19274,19308],[19650,19673],[20021,20039],[20386,20404],[20749,20769]], + "1649": [[19272,19308],[19645,19673],[20015,20039],[20381,20404],[20745,20769]], + "1650": [[19279,19308],[19640,19673],[20009,20039],[20375,20404],[20739,20769]], + "1651": [[19288,19308],[19646,19673],[20001,20039],[20366,20404],[20730,20769]], + "1663": [[17490,17492]], + "1664": [[17497,17499]], + "1665": [[19005,19078],[19741,19814],[20104,20165],[20475,20536]], + "1666": [[19007,19080],[19742,19816],[20106,20167],[20477,20538]], + "1667": [[19307,19338],[19671,19703],[20037,20069],[20403,20434]], + "1668": [[19000,19076],[19736,19810],[20100,20161],[20471,20532]], + "1669": [[19316,19469],[19680,19835],[20056,20200],[20418,20512]], + "1670": [[19686,19809],[20053,20174],[20416,20510]], + "1671": [[18216,18324]], + "1672": [[19244,19371],[19616,19710],[20029,20079],[20393,20444],[20758,20809]], + "1673": [[19246,19372],[19622,19716],[19994,20081],[20353,20446],[20717,20810]], + "1680": [[17510,17539]], + "1682": [[17502,17539]], + "1683": [[17503,17539]], + "1686": [[17508,17539]], + "1687": [[17509,17539]], + "1688": [[18976,19004],[19342,19369],[19694,19734],[20060,20100],[20425,20465]], + "1723": [[18972,19004],[19345,19369],[19711,19734],[20077,20100],[20444,20465]], + "1726": [[18991,19014],[19355,19379],[19722,19744],[20088,20110],[20450,20475]], + "1728": [[19041,19148],[19770,19862],[20140,20201],[20511,20572]], + "1729": [[19042,19149],[19771,19863],[20142,20203],[20513,20576]], + "1730": [[19043,19150],[19772,19864],[20144,20205],[20515,20578]], + "1736": [[17559,18304],[20208,20210],[20566,20659]], + "1748": [[19032,19053],[19764,19784],[20129,20149],[20495,20514]], + "1749": [[19031,19053],[19763,19784],[20127,20149],[20494,20514]], + "1750": [[19037,19053],[19755,19784],[20123,20149],[20495,20514]], + "1751": [[19033,19053],[19760,19784],[20124,20149],[20493,20514]], + "1752": [[19025,19053],[19754,19783],[20117,20159],[20488,20524]], + "1760": [[19021,19132],[19746,19818],[20110,20171],[20481,20542]], + "1764": [[19068,19094],[19797,19825],[20160,20180],[20525,20545]], + "1765": [[19070,19165],[19804,19898],[20170,20264],[20531,20625]], + "1778": [[19092,19177],[19832,19925],[20203,20235],[20566,20629]], + "1779": [[19078,19169],[19803,19897],[20168,20262],[20535,20629]], + "1780": [[19083,19170],[19814,19907],[20187,20280],[20565,20628]], + "1781": [[19084,19171],[19834,19927],[20197,20290],[20561,20624]], + "1793": [[17696,17718],[19684,19690]], + "1794": [[17696,17718]], + "1795": [[19106,19182],[19827,19920],[20190,20283],[20554,20617]], + "1796": [[19118,19183],[19848,19942],[20212,20275],[20576,20639]], + "1797": [[19125,19190],[19855,19949],[20217,20280],[20581,20644]], + "1808": [[17648,17729]], + "1809": [[17646,17725]], + "1810": [[17655,17707]], + "1815": [[18390,18875]], + "1816": [[19105,19180],[19825,19918],[20183,20276],[20572,20635]], + "1817": [[19104,19178],[19846,19940],[20210,20273],[20574,20637]], + "1818": [[19120,19185],[19853,19947],[20214,20277],[20578,20641]], + "1840": [[17707,17709]], + "1841": [[17714,17716]], + "1862": [[17721,17723]], + "1863": [[17728,17730]], + "1864": [[17735,17737]], + "1879": [[17742,17744]], + "1880": [[17749,17751]], + "1896": [[17756,17758]], + "1897": [[17763,17765]], + "1908": [[17770,17772]], + "1909": [[17777,17779]], + "1910": [[17784,17786]], + "1911": [[17791,17793]], + "1912": [[17798,17800]], + "1918": [[17805,17807]], + "1919": [[17812,17814]], + "1920": [[17819,17821]], + "1921": [[17826,17828]], + "1922": [[17833,17835]], + "1923": [[17840,17842]], + "1929": [[19270,19308],[19644,19673],[20014,20039],[20380,20404],[20744,20769]], + "1930": [[19279,19308],[19637,19673],[20015,20039],[20375,20404],[20739,20769]], + "1936": [[17847,17849]], + "1937": [[17854,17856]], + "1938": [[19309,19348],[19673,19713],[20042,20079],[20406,20444]], + "1939": [[19298,19348],[19662,19713],[20033,20079],[20399,20444]], + "1949": [[17861,17863]], + "1950": [[17868,17870]], + "1957": [[18986,19004],[19351,19369],[19714,19734],[20081,20100],[20444,20465]], + "1958": [[18974,19004],[19341,19369],[19696,19734],[20062,20100],[20425,20465]], + "1959": [[18984,19004],[19346,19369],[19699,19734],[20065,20100],[20429,20465]], + "1960": [[18985,19004],[19347,19369],[19700,19734],[20066,20100],[20433,20465]], + "1967": [[18965,19004],[19339,19369],[19699,19734],[20065,20100],[20428,20465]], + "1968": [[17870,17908],[20447,20465]], + "1969": [[17875,17908],[20447,20465]], + "1970": [[17875,17908],[20447,20465]], + "1971": [[17875,17877]], + "1972": [[17882,17884]], + "1973": [[17896,17898]], + "1974": [[17897,17913]], + "1975": [[17903,17905]], + "1977": [[17910,17912]], + "1978": [[17917,17919]], + "1979": [[17924,17926]], + "1980": [[17931,17933]], + "1982": [[17938,17940]], + "1983": [[17945,17947]], + "1984": [[17952,17954]], + "1985": [[17959,17961]], + "1986": [[17966,17968]], + "1987": [[17964,17966]], + "1988": [[17973,17975]], + "1989": [[17980,17982]], + "1990": [[17987,17989]], + "1996": [[17994,17996]], + "1997": [[18001,18003]], + "1998": [[18008,18010]], + "2001": [[18015,18017]], + "2007": [[18029,18031]], + "2008": [[18022,18024]], + "2009": [[18036,18038]], + "2010": [[18043,18045]], + "2011": [[18050,18052]], + "2012": [[18057,18059]], + "2014": [[18071,18073]], + "2025": [[18078,18080]], + "2026": [[18085,18087]], + "2027": [[18095,18100]], + "2028": [[18095,18100]], + "2029": [[18095,18100]], + "2030": [[18095,18100]], + "2031": [[18095,18100]], + "2032": [[18095,18100]], + "2033": [[18095,18100]], + "2034": [[18095,18100]], + "2035": [[18095,18100]], + "2036": [[18095,18100]], + "2037": [[18095,18100]], + "2038": [[18095,18100]], + "2039": [[18092,18094]], + "2040": [[18099,18101]], + "2071": [[18106,18108]], + "2072": [[18113,18115]], + "2074": [[19223,19238],[19589,19603],[19950,19969],[20315,20353],[20679,20718]], + "2075": [[19225,19238],[19589,19603],[19950,19969],[20317,20353],[20681,20718]], + "2076": [[19222,19238],[19588,19603],[19950,19969],[20313,20353],[20677,20718]], + "2077": [[19224,19238],[19590,19603],[19950,19969],[20319,20353],[20683,20718]], + "2078": [[19224,19238],[19587,19603],[19950,19969],[20307,20353],[20670,20718]], + "2079": [[19224,19238],[19587,19603],[19950,19969],[20309,20353],[20673,20718]], + "2080": [[19224,19238],[19590,19603],[19950,19969],[20321,20353],[20685,20718]], + "2081": [[19226,19238],[19590,19603],[19950,19969],[20323,20353],[20687,20718]], + "2082": [[19220,19238],[19588,19603],[19950,19969],[20311,20353],[20675,20718]], + "2088": [[18120,18122]], + "2089": [[18127,18129]], + "2103": [[18134,18136]], + "2104": [[18141,18143]], + "2105": [[18148,18150]], + "2106": [[18155,18157]], + "2117": [[18162,18164]], + "2118": [[18169,18171]], + "2119": [[18176,18178]], + "2120": [[18183,18185]], + "2132": [[18190,18192]], + "2133": [[18197,18199]], + "2144": [[18204,18206]], + "2145": [[18211,18213]], + "2146": [[18218,18220]], + "2147": [[18225,18227]], + "2148": [[18239,18241]], + "2149": [[18232,18234]], + "2167": [[18246,18248]], + "2168": [[18253,18255]], + "2169": [[18260,18262]], + "2170": [[18267,18269]], + "2171": [[18274,18276]], + "2182": [[18281,18283]], + "2183": [[18288,18290]], + "2187": [[18295,18297]], + "2188": [[18302,18304]], + "2189": [[18309,18311]], + "2190": [[18316,18318]], + "2191": [[18323,18325]], + "2192": [[18330,18332]], + "2193": [[18337,18339]], + "2194": [[18344,18346]], + "2195": [[18351,18353]], + "2196": [[18358,18360]], + "2197": [[18365,18367]], + "2198": [[18372,18374]], + "2199": [[18386,18388]], + "2200": [[18379,18381]], + "2209": [[18388,18460]], + "2210": [[18388,18460]], + "2211": [[18390,18461]], + "2212": [[18391,18462]], + "2213": [[18394,18464]], + "2214": [[18395,18463]], + "2215": [[18396,18465]], + "2216": [[18397,18465]], + "2217": [[18398,18466]], + "2218": [[18398,18466]], + "2219": [[18399,18467]], + "2220": [[18401,18468]], + "2221": [[18400,18402]], + "2222": [[18393,18395]], + "2223": [[18407,18409]], + "2224": [[18414,18416]], + "2238": [[18421,18423]], + "2239": [[18428,18430]], + "2240": [[18435,18437]], + "2241": [[18442,18444]], + "2249": [[18456,18458]], + "2250": [[18449,18451]], + "2251": [[18470,18472]], + "2252": [[18463,18465]], + "2256": [[18484,18486]], + "2257": [[18477,18479]], + "2259": [[18491,18493]], + "2260": [[18498,18500]], + "2261": [[18505,18507]], + "2265": [[18512,18514]], + "2266": [[18519,18521]], + "2267": [[18526,18528]], + "2268": [[18533,18535]], + "2274": [[18540,18542]], + "2275": [[18547,18549]], + "2276": [[18554,18556]], + "2277": [[18568,18570]], + "2278": [[18561,18563]], + "2284": [[18575,18577]], + "2285": [[18582,18584]], + "2286": [[18589,18591]], + "2287": [[18596,18598]], + "2295": [[18603,18605]], + "2296": [[18610,18612]], + "2297": [[18617,18619]], + "2298": [[18624,18626]], + "2299": [[18631,18633]], + "2315": [[18638,18640]], + "2316": [[18645,18647]], + "2317": [[18652,18654]], + "2318": [[18659,18661]], + "2329": [[18666,18668]], + "2330": [[18673,18675]], + "2331": [[18680,18682]], + "2332": [[18687,18689]], + "2338": [[18694,18696]], + "2339": [[18701,18703]], + "2340": [[18708,18710]], + "2341": [[18715,18717]], + "2347": [[18722,18724]], + "2348": [[18729,18731]], + "2349": [[18736,18738]], + "2350": [[18743,18745]], + "2351": [[18750,18752]], + "2387": [[18767,18772]], + "2388": [[18767,18772]], + "2389": [[18767,18772]], + "2390": [[18767,18772]], + "2391": [[18767,18772]], + "2392": [[18767,18772]], + "2393": [[18767,18772]], + "2394": [[18767,18772]], + "2395": [[18767,18772]], + "2396": [[18767,18772]], + "2397": [[18767,18772]], + "2398": [[18767,18772]], + "2399": [[18767,18772]], + "2400": [[18767,18772]], + "2401": [[18767,18772]], + "2402": [[18757,18759]], + "2403": [[18764,18766]], + "2404": [[18771,18773]], + "2405": [[18778,18780]], + "2406": [[18830,18835]], + "2407": [[18830,18835]], + "2408": [[18830,18835]], + "2409": [[18830,18835]], + "2410": [[18830,18835]], + "2411": [[18830,18835]], + "2422": [[18785,18787]], + "2423": [[18792,18794]], + "2424": [[18799,18801]], + "2425": [[18806,18808]], + "2426": [[18788,18793]], + "2427": [[18788,18793]], + "2445": [[18837,18842]], + "2446": [[18837,18842]], + "2447": [[18837,18842]], + "2448": [[18837,18842]], + "2449": [[18837,18842]], + "2450": [[18837,18842]], + "2451": [[18837,18842]], + "2452": [[18837,18842]], + "2453": [[18813,18815]], + "2454": [[18820,18822]], + "2455": [[18827,18829]], + "2456": [[18834,18836]], + "2457": [[18843,18849]], + "2471": [[18843,18849]], + "2472": [[18843,18849]], + "2473": [[18843,18849]], + "2474": [[18843,18849]], + "2475": [[18843,18849]], + "2478": [[18869,18871]], + "2479": [[18862,18864]], + "2480": [[18855,18857]], + "2481": [[18848,18850]], + "2497": [[18876,18878]], + "2498": [[18883,18885]], + "2499": [[18890,18892]], + "2500": [[18897,18899]], + "2501": [[18904,18906]], + "2522": [[18873,18919]], + "2523": [[18884,18919]], + "2525": [[18891,18919]], + "2526": [[18886,18919]], + "2527": [[18892,18919]], + "2528": [[18893,18919]], + "2529": [[18898,18919]], + "2530": [[18899,18919]], + "2532": [[18881,18919]], + "2533": [[18896,18919]], + "2534": [[18900,18919]], + "2535": [[18888,18919]], + "2540": [[18877,18919]], + "2541": [[18880,18919]], + "2542": [[18895,18919]], + "2543": [[18903,18919]], + "2544": [[18888,18919]], + "2545": [[18875,18919]], + "2546": [[18901,18919]], + "2547": [[18907,18919]], + "2548": [[18906,18919]], + "2549": [[18874,18919]], + "2550": [[18902,18919]], + "2552": [[18911,18913]], + "2553": [[18918,18920]], + "2554": [[18925,18927]], + "2555": [[18932,18934]], + "2566": [[18906,18916]], + "2572": [[18906,18916]], + "2575": [[18906,18916]], + "2576": [[18906,18916]], + "2577": [[18906,18916]], + "2578": [[18906,18916]], + "2579": [[18921,18930]], + "2582": [[18921,18930]], + "2584": [[18921,18930]], + "2585": [[18921,18930]], + "2591": [[18921,18930]], + "2596": [[18914,18923]], + "2598": [[18914,18923]], + "2600": [[18914,18923]], + "2603": [[18914,18923]], + "2604": [[18914,18923]], + "2605": [[18928,18937]], + "2607": [[18928,18937]], + "2611": [[18928,18937]], + "2617": [[18928,18937]], + "2628": [[18939,18941]], + "2629": [[18946,18948]], + "2630": [[18953,18955]], + "2631": [[18960,18962]], + "2643": [[18967,18969]], + "2644": [[18974,18976]], + "2645": [[18981,18983]], + "2646": [[18988,18990]], + "2647": [[18995,18997]], + "2648": [[18962,18972]], + "2649": [[18962,18972]], + "2650": [[18962,18972]], + "2651": [[18962,18972]], + "2652": [[18962,18972]], + "2653": [[18962,18972]], + "2654": [[18962,18972]], + "2655": [[18962,18972]], + "2656": [[18962,18972]], + "2657": [[18962,18972]], + "2658": [[18962,18972]], + "2659": [[18962,18972]], + "2660": [[18970,18979]], + "2661": [[18970,18979]], + "2662": [[18970,18979]], + "2663": [[18970,18979]], + "2664": [[18970,18979]], + "2665": [[18970,18979]], + "2666": [[18970,18979]], + "2667": [[18970,18979]], + "2668": [[18970,18979]], + "2669": [[18970,18979]], + "2670": [[18970,18979]], + "2671": [[18970,18979]], + "2672": [[18970,18979]], + "2673": [[18977,18986]], + "2674": [[18977,18986]], + "2675": [[18977,18986]], + "2676": [[18977,18986]], + "2677": [[18977,18986]], + "2678": [[18977,18986]], + "2679": [[18977,18986]], + "2680": [[18977,18986]], + "2681": [[18977,18986]], + "2682": [[18977,18986]], + "2683": [[18977,18986]], + "2684": [[18977,18986]], + "2685": [[18984,18993]], + "2686": [[18984,18993]], + "2687": [[18984,18993]], + "2688": [[18984,18993]], + "2689": [[18984,18993]], + "2690": [[18984,18993]], + "2691": [[18984,18993]], + "2692": [[18984,18993]], + "2693": [[18984,18993]], + "2694": [[18984,18993]], + "2695": [[18984,18993]], + "2696": [[18984,18993]], + "2697": [[18984,18993]], + "2717": [[19002,19004]], + "2718": [[19009,19011]], + "2719": [[19016,19018]], + "2720": [[19023,19025]], + "2731": [[19030,19032]], + "2732": [[19037,19039]], + "2733": [[19044,19046]], + "2734": [[19051,19053]], + "2745": [[19058,19060]], + "2746": [[19065,19067]], + "2747": [[19072,19074]], + "2748": [[19079,19081]], + "2749": [[19086,19088]], + "2760": [[19093,19095]], + "2761": [[19100,19102]], + "2762": [[19107,19109]], + "2763": [[19114,19116]], + "2808": [[19121,19123]], + "2809": [[19128,19130]], + "2810": [[19135,19137]], + "2811": [[19142,19144]], + "2897": [[19149,19151]], + "2898": [[19156,19158]], + "2899": [[19163,19165]], + "2900": [[19170,19172]], + "2901": [[19177,19179]], + "2972": [[19184,19186]], + "2973": [[19191,19193]], + "2974": [[19198,19200]], + "2975": [[19205,19207]], + "3001": [[19212,19214]], + "3002": [[19219,19221]], + "3003": [[19226,19228]], + "3004": [[19233,19235]], + "3005": [[19229,19234]], + "3006": [[19229,19234]], + "3007": [[19229,19234]], + "3008": [[19229,19234]], + "3009": [[19229,19234]], + "3010": [[19229,19234]], + "3011": [[19229,19234]], + "3012": [[19229,19234]], + "3013": [[19229,19234]], + "3014": [[19229,19234]], + "3015": [[19229,19234]], + "3016": [[19229,19234]], + "3027": [[19240,19242]], + "3028": [[19247,19249]], + "3029": [[19254,19256]], + "3030": [[19261,19263]], + "3031": [[19268,19270]], + "3042": [[19270,19280]], + "3047": [[19270,19280]], + "3053": [[19270,19280]], + "3054": [[19270,19280]], + "3055": [[19278,19287]], + "3056": [[19278,19287]], + "3065": [[19278,19287]], + "3067": [[19278,19287]], + "3073": [[19285,19294]], + "3075": [[19285,19294]], + "3078": [[19285,19294]], + "3079": [[19285,19294]], + "3081": [[19292,19301]], + "3087": [[19292,19301],[19649,19658]], + "3090": [[19292,19301],[19649,19658]], + "3094": [[19275,19277]], + "3095": [[19282,19284]], + "3096": [[19289,19291]], + "3097": [[19296,19298]], + "3110": [[19303,19305]], + "3111": [[19310,19312]], + "3112": [[19317,19319]], + "3113": [[19324,19326]], + "3124": [[19331,19333]], + "3125": [[19338,19340]], + "3126": [[19345,19347]], + "3127": [[19352,19354]], + "3128": [[19359,19361]], + "3144": [[19366,19368]], + "3145": [[19373,19375]], + "3146": [[19387,19389]], + "3181": [[19394,19396]], + "3182": [[19401,19403]], + "3183": [[19408,19410]], + "3184": [[19415,19417]], + "3195": [[19422,19424]], + "3196": [[19429,19431]], + "3197": [[19436,19438]], + "3198": [[19443,19445]], + "3199": [[19450,19452]], + "3214": [[19457,19459]], + "3215": [[19464,19466]], + "3216": [[19471,19473]], + "3217": [[19478,19480]], + "3218": [[19839,19932],[20198,20291],[20563,20626]], + "3219": [[19841,19934],[20205,20237],[20568,20631]], + "3235": [[19485,19487]], + "3236": [[19492,19494]], + "3237": [[19499,19501]], + "3238": [[19506,19508]], + "3253": [[19513,19515]], + "3254": [[19520,19522]], + "3255": [[19527,19529]], + "3256": [[19534,19536]], + "3257": [[19541,19543]], + "3258": [[19541,19552],[19910,19923],[20274,20287],[20638,20652]], + "3259": [[19542,19552],[19911,19923],[20275,20287],[20639,20652]], + "3275": [[19548,19550]], + "3276": [[19555,19557]], + "3277": [[19562,19564]], + "3278": [[19569,19571]], + "3289": [[19576,19578]], + "3290": [[19583,19585]], + "3291": [[19590,19592]], + "3292": [[19597,19599]], + "3293": [[19604,19606]], + "3304": [[19611,19613]], + "3305": [[19618,19620]], + "3306": [[19625,19627]], + "3333": [[19635,19644]], + "3339": [[19635,19644]], + "3349": [[19632,19634]], + "3350": [[19639,19641]], + "3351": [[19646,19648]], + "3352": [[19653,19655]], + "3363": [[19667,19669]], + "3364": [[19674,19676]], + "3365": [[19681,19683]], + "3366": [[19688,19690]], + "3369": [[19684,19690]], + "3375": [[19695,19697]], + "3376": [[19702,19704]], + "3377": [[19709,19711]], + "3378": [[19716,19718]], + "3379": [[19723,19725]], + "3385": [[19693,19695],[20059,20066]], + "3386": [[19693,19695],[20059,20066]], + "3387": [[19695,19697],[20424,20431]], + "3388": [[19695,19697],[20424,20431]], + "3389": [[19697,19699],[20061,20066]], + "3390": [[19699,19701],[20426,20431]], + "3391": [[19699,19701],[20426,20431]], + "3392": [[19701,19703],[20067,20069]], + "3393": [[19703,19705],[20069,20071]], + "3394": [[19705,19707],[20438,20440]], + "3395": [[19705,19707],[20438,20440]], + "3396": [[19707,19709],[20073,20075]], + "3397": [[19709,19711]], + "3398": [[19709,19711],[20450,20452]], + "3399": [[19711,19713],[20077,20079]], + "3400": [[19713,19715],[20442,20444]], + "3401": [[19713,19715],[20442,20444]], + "3402": [[19715,19717],[20430,20432]], + "3403": [[19715,19717]], + "3404": [[19717,19719],[20434,20436]], + "3405": [[19717,19719],[20434,20436]], + "3406": [[19719,19721],[20452,20454]], + "3407": [[19719,19721],[20452,20454]], + "3408": [[19721,19723],[20087,20089]], + "3409": [[19721,19723],[20087,20089]], + "3410": [[19701,19703],[20067,20069]], + "3411": [[19703,19705],[20069,20071]], + "3412": [[19697,19699],[20061,20066]], + "3413": [[19707,19709],[20073,20075]], + "3424": [[19730,19732]], + "3425": [[19737,19739]], + "3426": [[19744,19746]], + "3427": [[19751,19753]], + "3440": [[19758,19760]], + "3442": [[19772,19774]], + "3443": [[19779,19781]], + "3444": [[19786,19788]], + "3463": [[19793,19795]], + "3464": [[19800,19802]], + "3465": [[19807,19809]], + "3466": [[19814,19816]], + "3477": [[19821,19823]], + "3478": [[19828,19830]], + "3479": [[19835,19837]], + "3480": [[19842,19844]], + "3517": [[19849,19851]], + "3518": [[19856,19858]], + "3519": [[19863,19865]], + "3520": [[19870,19872]], + "3521": [[19877,19879]], + "3559": [[19884,19886]], + "3560": [[19891,19893]], + "3561": [[19898,19900]], + "3562": [[19905,19907]], + "3598": [[19912,19914]], + "3599": [[19919,19921]], + "3600": [[19926,19928]], + "3601": [[19933,19935]], + "3616": [[19940,19942]], + "3617": [[19947,19949]], + "3618": [[19954,19956]], + "3619": [[19961,19963]], + "3620": [[19968,19970]], + "3631": [[19975,19977]], + "3632": [[19982,19984]], + "3633": [[19989,19991]], + "3634": [[19996,19998]], + "3647": [[19998,20008]], + "3648": [[19998,20008]], + "3649": [[19998,20008]], + "3650": [[19998,20008]], + "3651": [[19998,20008]], + "3657": [[20006,20015]], + "3658": [[20006,20015]], + "3659": [[20006,20015]], + "3660": [[20006,20015]], + "3661": [[20006,20015]], + "3662": [[20006,20015]], + "3678": [[20020,20029]], + "3679": [[20020,20029]], + "3680": [[20020,20029]], + "3681": [[20020,20029]], + "3682": [[20020,20029]], + "3688": [[20003,20005]], + "3689": [[20010,20012]], + "3690": [[20017,20019]], + "3691": [[20024,20026]], + "3692": [[20031,20033]], + "3753": [[20038,20040]], + "3754": [[20045,20047]], + "3755": [[20052,20054]], + "3756": [[20059,20061]], + "3770": [[20066,20068]], + "3771": [[20073,20075]], + "3772": [[20080,20082]], + "3773": [[20087,20089]], + "3780": [[20085,20087],[20428,20431]], + "3781": [[20085,20087],[20428,20431]], + "3782": [[20063,20066]], + "3783": [[20063,20066]], + "3784": [[20065,20067]], + "3785": [[20065,20067]], + "3786": [[20071,20073]], + "3787": [[20071,20073]], + "3788": [[20075,20077]], + "3789": [[20075,20077]], + "3790": [[20079,20081]], + "3791": [[20079,20081]], + "3792": [[20081,20083]], + "3793": [[20081,20083]], + "3794": [[20083,20085]], + "3795": [[20083,20085]], + "3796": [[20094,20096]], + "3807": [[20101,20103]], + "3808": [[20108,20110]], + "3809": [[20115,20117]], + "3823": [[20122,20124]], + "3824": [[20129,20131]], + "3825": [[20136,20138]], + "3826": [[20143,20145]], + "3827": [[20133,20149],[20498,20514]], + "3852": [[20150,20152]], + "3853": [[20157,20159]], + "3854": [[20164,20166]], + "3855": [[20171,20173]], + "3856": [[20178,20180]], + "3872": [[20185,20187]], + "3873": [[20192,20194]], + "3874": [[20199,20201]], + "3875": [[20206,20208]], + "3876": [[20185,20278],[20552,20615]], + "3877": [[20192,20285],[20556,20619]], + "3906": [[20213,20215]], + "3907": [[20220,20222]], + "3908": [[20227,20229]], + "3909": [[20234,20236]], + "3910": [[20241,20243]], + "3911": [[20228,20291],[20592,20655]], + "3912": [[20235,20298],[20599,20662]], + "3953": [[20248,20250]], + "3954": [[20255,20257]], + "3955": [[20262,20264]], + "3956": [[20269,20271]], + "3957": [[20256,20288],[20620,20652]], + "4024": [[20276,20278],[20318,20320]], + "4025": [[20283,20285]], + "4026": [[20290,20292]], + "4027": [[20297,20299]], + "4028": [[20304,20306]], + "4029": [[20279,20373],[20643,20737]], + "4046": [[20311,20313]], + "4047": [[20318,20320]], + "4048": [[20325,20327]], + "4049": [[20332,20334]], + "4050": [[20314,20348],[20679,20713]], + "4051": [[20315,20348],[20680,20713]], + "4052": [[20316,20348],[20681,20713]], + "4053": [[20328,20348],[20693,20713]], + "4054": [[20318,20348],[20683,20713]], + "4055": [[20332,20348],[20697,20713]], + "4056": [[20321,20348],[20686,20713]], + "4057": [[20322,20348],[20687,20713]], + "4058": [[20323,20348],[20688,20713]], + "4059": [[20324,20348],[20689,20713]], + "4060": [[20325,20348],[20690,20713]], + "4061": [[20326,20348],[20691,20713]], + "4062": [[20331,20348],[20696,20713]], + "4063": [[20329,20348],[20694,20713]], + "4064": [[20330,20348],[20695,20713]], + "4065": [[20317,20348],[20682,20713]], + "4066": [[20319,20348],[20684,20713]], + "4067": [[20333,20348],[20698,20713]], + "4082": [[20339,20341]], + "4083": [[20346,20348]], + "4084": [[20353,20355]], + "4085": [[20360,20362]], + "4130": [[20367,20369]], + "4131": [[20374,20376]], + "4132": [[20381,20383]], + "4133": [[20388,20390]], + "4134": [[20395,20397]], + "4147": [[20402,20404]], + "4148": [[20409,20411]], + "4149": [[20416,20418]], + "4150": [[20423,20425]], + "4170": [[20425,20435]], + "4171": [[20425,20435]], + "4172": [[20425,20435]], + "4178": [[20433,20442]], + "4179": [[20433,20442]], + "4180": [[20433,20442]], + "4186": [[20440,20449]], + "4187": [[20440,20449]], + "4188": [[20440,20449]], + "4194": [[20447,20455]], + "4195": [[20447,20455]], + "4196": [[20447,20455]], + "4197": [[20430,20432]], + "4198": [[20437,20439]], + "4199": [[20444,20446]], + "4200": [[20451,20453]], + "4201": [[20458,20460]], + "4212": [[20432,20434]], + "4213": [[20432,20434]], + "4214": [[20436,20438]], + "4215": [[20436,20438]], + "4216": [[20440,20442]], + "4217": [[20440,20442]], + "4218": [[20446,20448]], + "4219": [[20446,20448]], + "4220": [[20448,20450]], + "4221": [[20448,20450]], + "4222": [[20444,20446]], + "4223": [[20444,20446]], + "4229": [[20465,20467]], + "4230": [[20472,20474]], + "4231": [[20479,20481]], + "4232": [[20486,20488]], + "4233": [[20454,20486]], + "4234": [[20485,20514]], + "4243": [[20493,20495]], + "4244": [[20500,20502]], + "4245": [[20507,20509]], + "4246": [[20514,20516]], + "4247": [[20498,20514]], + "4248": [[20501,20516]], + "4249": [[20501,20516]], + "4250": [[20501,20516]], + "4251": [[20501,20516]], + "4252": [[20501,20516]], + "4266": [[20521,20523]], + "4267": [[20528,20530]], + "4268": [[20535,20537]], + "4269": [[20542,20544]], + "4270": [[20534,20628]], + "4271": [[20544,20563]], + "4272": [[20537,20631]], + "4273": [[20536,20607]], + "4274": [[20529,20545]], + "4275": [[20532,20626]], + "4279": [[20513,20545]], + "4280": [[20544,20575]], + "4291": [[20549,20551]], + "4292": [[20556,20558]], + "4293": [[20563,20565]], + "4294": [[20570,20572]], + "4295": [[20577,20579]], + "4296": [[20574,20606]], + "4333": [[20584,20586]], + "4334": [[20591,20593]], + "4335": [[20605,20607]], + "4336": [[20605,20636]], + "4369": [[20619,20621]], + "4370": [[20626,20628]], + "4371": [[20633,20635]], + "4372": [[20635,20667]], + "4416": [[20640,20642]], + "4417": [[20647,20649]], + "4418": [[20654,20656]], + "4419": [[20661,20663]], + "4420": [[20668,20670]], + "4421": [[20666,20698]], + "4484": [[20675,20677]], + "4485": [[20682,20684]], + "4486": [[20689,20691]], + "4487": [[20696,20698]], + "4488": [[20697,20728]], + "4508": [[20703,20705]], + "4509": [[20710,20712]], + "4510": [[20717,20719]], + "4511": [[20724,20726]], + "4512": [[20727,20759]], + "4525": [[20698,20728]], + "4594": [[20731,20733]], + "4595": [[20738,20740]], + "4596": [[20745,20747]], + "4597": [[20752,20754]], + "4598": [[20759,20761]], + "4599": [[20758,20789]] + }, + "denItems": { + "9": [[20345,20438],[20709,20803]], + "13": [[20337,20430],[20701,20795]], + "27": [[20340,20433],[20704,20798]], + "39": [[19033,19053],[19758,19784],[20134,20149],[20505,20514]], + "50": [[19033,19053],[19758,19784],[20133,20149],[20504,20514]], + "347": [[17216,17597]], + "355": [[19174,19189],[19535,19552],[19905,19920],[20265,20291],[20629,20656]], + "364": [[19031,19053]], + "374": [[19031,19053]], + "386": [[19269,19292],[19634,19657]], + "396": [[19268,19308],[19630,19673],[20001,20039],[20363,20404],[20727,20769]], + "397": [[19269,19308],[19631,19673],[20001,20039],[20365,20404],[20729,20769]], + "398": [[19266,19308],[19627,19673],[19997,20039],[20358,20404],[20722,20769]], + "403": [[19275,19308],[19637,19673],[20007,20039],[20379,20404],[20743,20769]], + "404": [[19289,19308],[19648,19673],[20015,20039],[20381,20404],[20745,20769]], + "411": [[19296,19308],[19661,19673],[20027,20039],[20392,20404],[20757,20769]], + "412": [[17197,17595]], + "419": [[17355,17586]], + "421": [[18851,18856]], + "425": [[18997,19089],[20059,20100],[20423,20465]], + "426": [[19019,19139],[19729,19803],[20092,20153],[20461,20522]], + "436": [[17583,17645]], + "533": [[17015,17131]], + "545": [[18419,18903]], + "715": [[18242,18274],[19338,19369],[19703,19734],[20069,20100],[20428,20465]], + "731": [[19131,19136]], + "732": [[19327,19369],[19690,19734],[20058,20100],[20423,20465]], + "736": [[19322,19369],[19686,19734],[20052,20100],[20419,20513]], + "740": [[18981,19004],[19330,19369],[19697,19734],[20063,20100],[20426,20465]], + "759": [[16924,17023]], + "774": [[17653,17787]], + "790": [[17936,17953]], + "791": [[19032,19053],[19758,19784],[20120,20149],[20489,20514]], + "793": [[19759,19784],[20132,20149],[20503,20514]], + "794": [[19761,19784],[20126,20149],[20497,20514]], + "802": [[17057,17420]], + "803": [[19008,19091],[19747,19815],[20112,20173],[20477,20538]], + "812": [[17379,17464]], + "819": [[17904,17988]], + "820": [[19014,19133]], + "839": [[19004,19104],[19378,19450],[20107,20168],[20477,20538]], + "840": [[19003,19100],[19740,19813],[20104,20165],[20475,20536]], + "841": [[18988,19073],[20084,20200],[20449,20539]], + "842": [[18999,19091],[19729,19803],[20092,20153],[20461,20522]], + "844": [[17588,17619]], + "845": [[17590,17619]], + "852": [[17171,17515]], + "902": [[17905,17990]], + "922": [[19502,19607],[19912,19945],[20300,20333],[20665,20698]], + "933": [[19287,19308],[19646,19673],[20010,20039],[20386,20404],[20750,20769]], + "934": [[19280,19308],[19641,19673],[20017,20039],[20383,20404],[20747,20769]], + "935": [[19271,19308],[19632,19673],[20002,20039],[20369,20404],[20733,20769]], + "936": [[19277,19308],[19639,19673],[20008,20039],[20368,20404],[20732,20769]], + "937": [[19281,19308],[19642,19673],[20021,20039],[20390,20404],[20754,20769]], + "938": [[17251,17629]], + "939": [[17244,17622]], + "1015": [[17257,17262]], + "1022": [[19174,19189],[19537,19552],[19908,19923],[20271,20291],[20635,20656]], + "1023": [[19174,19189],[19537,19552],[19908,19923],[20271,20291],[20635,20656]], + "1024": [[19174,19189],[19537,19552],[19908,19923],[20271,20291],[20635,20656]], + "1025": [[19174,19189],[19537,19552],[19908,19923],[20271,20291],[20635,20656]], + "1026": [[19174,19189],[19537,19552],[19908,19923],[20271,20291],[20635,20656]], + "1027": [[19174,19189],[19537,19552],[19908,19923],[20271,20291],[20635,20656]], + "1028": [[19174,19189],[19537,19552],[19908,19923],[20271,20291],[20635,20656]], + "1029": [[19174,19189],[19537,19552],[19908,19923],[20271,20291],[20635,20656]], + "1030": [[19174,19189],[19537,19552],[19908,19923],[20271,20291],[20635,20656]], + "1031": [[19174,19189],[19537,19552],[19908,19923],[20271,20291],[20635,20656]], + "1032": [[19174,19189],[19537,19552],[19908,19923],[20271,20291],[20635,20656]], + "1033": [[19174,19189],[19537,19552],[19908,19923],[20271,20291],[20635,20656]], + "1034": [[19174,19189],[19537,19552],[19908,19923],[20271,20291],[20635,20656]], + "1035": [[19174,19189],[19537,19552],[19908,19923],[20271,20291],[20635,20656]], + "1036": [[19174,19189],[19537,19552],[19908,19923],[20271,20291],[20635,20656]], + "1037": [[19174,19189],[19537,19552],[19908,19923],[20271,20291],[20635,20656]], + "1040": [[19753,19799],[20145,20206],[20510,20571]], + "1045": [[17287,17680]], + "1057": [[17058,17424]], + "1058": [[17059,17425]], + "1079": [[16922,17030]], + "1080": [[19951,20045],[20315,20353],[20680,20718]], + "1084": [[17287,17677]], + "1085": [[17287,17678]], + "1087": [[17287,17679]], + "1098": [[17446,17847]], + "1102": [[19885,19979],[20240,20343],[20613,20707]], + "1132": [[19289,19308],[19646,19673],[20022,20039],[20372,20404],[20736,20769]], + "1134": [[19215,19257],[19578,19622],[19938,19988],[20308,20353],[20672,20718]], + "1135": [[19305,19348],[19669,19713],[20035,20079],[20398,20444]], + "1137": [[19270,19308],[19641,19673],[20010,20039],[20370,20404],[20734,20769]], + "1139": [[19265,19308],[19627,19673],[19997,20039],[20356,20404],[20720,20769]], + "1142": [[19272,19308],[19642,19673],[20003,20039],[20367,20404],[20731,20769]], + "1143": [[19275,19308],[19644,19673],[20006,20039],[20371,20404],[20735,20769]], + "1144": [[19267,19308],[19640,19673],[20000,20039],[20363,20404],[20726,20769]], + "1145": [[18009,18903],[20196,20289],[20563,20656]], + "1146": [[19290,19308],[19648,19673],[20012,20039],[20375,20404],[20739,20769]], + "1147": [[19279,19308],[19646,19673],[20009,20039],[20373,20404],[20737,20769]], + "1152": [[19236,19377],[19662,19713],[20034,20079],[20397,20444],[20761,20809]], + "1153": [[19298,19348],[19662,19713],[20033,20079],[20398,20444]], + "1158": [[18964,19004],[19333,19369],[19695,19734],[20061,20100],[20425,20465]], + "1161": [[17865,17908]], + "1173": [[17167,17561]], + "1176": [[18993,19025],[19358,19390],[19723,19755],[20089,20121],[20454,20486]], + "1178": [[19024,19053],[19754,19784],[20120,20149],[20485,20514]], + "1207": [[19052,19084],[19783,19815],[20148,20180],[20513,20545]], + "1208": [[19083,19114],[19814,19845],[20179,20210],[20544,20575]], + "1209": [[19113,19145],[19478,19510],[19844,19876],[20209,20241],[20574,20606]], + "1210": [[19144,19175],[19509,19540],[19875,19906],[20240,20271],[20605,20636]], + "1211": [[19174,19206],[19539,19571],[19905,19937],[20270,20302],[20635,20667]], + "1215": [[19205,19237],[19570,19602],[19936,19968],[20301,20333],[20666,20698]], + "1216": [[19236,19267],[19601,19632],[19967,19998],[20332,20363],[20697,20728]], + "1217": [[19266,19298],[19631,19663],[19997,20029],[20362,20394],[20727,20759]], + "1218": [[19297,19328],[19662,19693],[20028,20059],[20393,20424],[20758,20789]], + "1219": [[19327,19359],[19692,19724],[20058,20090],[20423,20455]], + "1222": [[19565,19660],[19926,19959],[20291,20324],[20656,20689]], + "1223": [[19565,19661],[19926,19959],[20294,20327],[20659,20692]], + "1229": [[17353,17662],[19586,19622],[19935,19988],[20307,20353],[20670,20718]], + "1231": [[17351,17661],[19587,19622],[20308,20353],[20672,20718]], + "1233": [[17646,17760]], + "1242": [[19565,19663],[19926,19959],[20298,20331],[20663,20696]], + "1243": [[19565,19662],[19926,19959],[20296,20329],[20661,20694]], + "1263": [[19565,19658],[19926,19959],[20287,20320],[20652,20685]], + "1264": [[19565,19659],[19926,19959],[20289,20322],[20654,20687]], + "1307": [[18851,18856]], + "1349": [[18974,19004],[19342,19369],[19707,19734],[20073,20100],[20432,20465]], + "1351": [[17149,17172]], + "1353": [[20068,20070],[20439,20441]], + "1362": [[19334,19369],[19700,19734],[20066,20100],[20425,20465]], + "1363": [[18981,19004],[19351,19369],[19709,19734],[20075,20100],[20435,20465]], + "1365": [[18965,19004],[19328,19369],[19690,19734],[20058,20100],[20423,20465]], + "1397": [[17903,18025]], + "1398": [[19022,19142],[19750,19844],[20114,20175],[20485,20546]], + "1399": [[17902,18023]], + "1411": [[17179,17298]], + "1412": [[19021,19140],[19753,19852],[20116,20177],[20487,20548]], + "1413": [[19013,19131]], + "1415": [[19030,19053],[19756,19784],[20118,20149],[20489,20514]], + "1417": [[19028,19053],[19757,19784],[20123,20149],[20494,20514]], + "1418": [[18666,18696],[19764,19784],[20130,20149],[20501,20514]], + "1420": [[18809,18814]], + "1423": [[19025,19053],[19753,19784],[20118,20149],[20489,20514]], + "1429": [[19026,19145],[19754,19854],[20117,20178],[20488,20549]], + "1431": [[17197,17595]], + "1438": [[17898,17981]], + "1441": [[19056,19094],[19786,19815],[20151,20180],[20518,20545]], + "1443": [[19054,19084],[19775,19815],[20143,20180],[20514,20545]], + "1446": [[17948,17984]], + "1447": [[17078,17130]], + "1450": [[18809,18814]], + "1480": [[17488,17736]], + "1484": [[17489,17738]], + "1511": [[16225,17518]], + "1512": [[17425,18320]], + "1513": [[19851,19945],[20218,20312],[20582,20676]], + "1515": [[19850,19944],[20216,20310],[20580,20674]], + "1520": [[19289,19308],[19648,19673],[20014,20039],[20376,20404],[20740,20769]], + "1522": [[19296,19308],[19660,19673],[20026,20039],[20389,20404],[20753,20769]], + "1524": [[17388,17393]], + "1529": [[17388,17393]], + "1531": [[17750,19221]], + "1532": [[18406,19237]], + "1537": [[17379,17465]], + "1545": [[19251,19386],[19614,19708],[20030,20079],[20395,20444],[20759,20809]], + "1546": [[19087,19196],[19465,19608],[19831,19924],[20199,20292],[20559,20652]], + "1557": [[19610,19704],[19991,20084],[20349,20442],[20713,20807]], + "1565": [[19277,19308],[19639,19673],[20010,20039],[20387,20404],[20751,20769]], + "1566": [[19273,19308],[19636,19673],[20004,20039],[20372,20404],[20736,20769]], + "1568": [[19284,19308],[19643,19673],[20004,20039],[20371,20404],[20735,20769]], + "1569": [[19285,19308],[19644,19673],[20006,20039],[20377,20404],[20741,20769]], + "1572": [[19278,19308],[19640,19673],[20012,20039],[20375,20404],[20739,20769]], + "1574": [[19274,19308],[19637,19673],[20007,20039],[20379,20404],[20743,20769]], + "1576": [[19266,19308],[19648,19673],[20015,20039],[20374,20404],[20738,20769]], + "1584": [[19318,19348],[19682,19713],[20048,20079],[20403,20444]], + "1585": [[19273,19308],[19636,19673],[20005,20039],[20373,20404],[20737,20769]], + "1586": [[18851,18856]], + "1598": [[17379,17466]], + "1602": [[19181,19309],[19548,19683],[19927,20052],[20291,20385],[20655,20749]], + "1605": [[17356,17584]], + "1607": [[19325,19459],[19689,19835],[20054,20200],[20413,20507]], + "1618": [[18047,18233]], + "1619": [[18045,18231]], + "1620": [[18045,18232]], + "1621": [[18049,18235]], + "1630": [[17136,17482]], + "1640": [[19625,19749]], + "1643": [[19624,19748]], + "1645": [[19621,19745]], + "1646": [[19617,19741]], + "1648": [[19626,19750]], + "1685": [[19627,19751]], + "1686": [[19628,19752]], + "1687": [[19619,19747]], + "1689": [[19623,19747]], + "1691": [[19620,19744]], + "1718": [[19616,19740]], + "1719": [[19618,19742]], + "1746": [[19172,19195],[19875,19896],[20240,20261],[20605,20626]], + "1749": [[19172,19195],[19875,19896],[20240,20261],[20605,20626]], + "1750": [[19172,19195],[19875,19896],[20240,20261],[20605,20626]], + "1760": [[19172,19195],[19875,19896],[20240,20261],[20605,20626]], + "1761": [[19172,19195],[19875,19896],[20240,20261],[20605,20626]], + "1762": [[19172,19195],[19875,19896],[20240,20261],[20605,20626]], + "1763": [[19172,19195],[19875,19896],[20240,20261],[20605,20626]], + "1764": [[19172,19195],[19875,19896],[20240,20261],[20605,20626]], + "1765": [[19172,19195],[19875,19896],[20240,20261],[20605,20626]], + "1766": [[19172,19195],[19875,19896],[20240,20261],[20605,20626]], + "1768": [[19172,19195],[19875,19896],[20240,20261],[20605,20626]], + "1769": [[19172,19195],[19875,19896],[20240,20261],[20605,20626]], + "1770": [[19172,19195],[19875,19896],[20240,20261],[20605,20626]], + "1771": [[20133,20149],[20508,20514]], + "1788": [[16989,17056]], + "1789": [[18788,18793]], + "1790": [[18788,18793]], + "1791": [[18788,18793]], + "1792": [[16995,17060]], + "1793": [[16996,17061]], + "1794": [[16988,17063]], + "1799": [[16988,17064]], + "1800": [[16988,17065]], + "1801": [[16988,17062]], + "1802": [[16988,17066]], + "1803": [[16988,17067]], + "1804": [[17181,17297]], + "1805": [[17183,17296]], + "1807": [[17180,17295]], + "1809": [[18987,19072],[20085,20200],[20451,20539]], + "1810": [[19016,19136],[19716,19734],[20082,20100],[20443,20465]], + "1818": [[18962,19004],[19331,19369],[19695,19734],[20061,20100],[20425,20465]], + "1819": [[16995,17069]], + "1821": [[19319,19348],[19683,19713],[20049,20079],[20404,20444]], + "1826": [[18990,19078],[20086,20174],[20446,20539]], + "1827": [[18983,19004],[19350,19369],[19716,19734],[20082,20100],[20444,20465]], + "1828": [[18991,19079],[19358,19432]], + "1829": [[19012,19128],[19744,19837],[20109,20170],[20479,20540]], + "1830": [[18992,19080],[19359,19432]], + "1837": [[18982,19004]], + "1838": [[19010,19126],[19728,19802],[20091,20152],[20461,20522]], + "1840": [[18973,19004],[19341,19369],[19706,19734],[20072,20100],[20431,20465]], + "1843": [[18985,19004],[19351,19369],[19715,19734],[20081,20100],[20442,20465]], + "1845": [[17144,17504]], + "1851": [[19326,19459],[19690,19830],[20056,20195],[20418,20512]], + "1865": [[19185,19312],[19530,19624],[19886,19980],[20250,20344],[20614,20708]], + "1866": [[19192,19316],[19530,19623],[19887,19981],[20251,20345],[20615,20709]], + "1870": [[19317,19348],[19681,19713],[20047,20079],[20415,20444]], + "1874": [[19187,19313],[19530,19622],[19888,19982],[20252,20346],[20616,20710]], + "1877": [[19732,19806],[20095,20156],[20466,20527]], + "1878": [[19733,19807],[20097,20158],[20468,20529]], + "1881": [[19734,19808],[20098,20159],[20469,20530]], + "1882": [[19735,19808],[20099,20162],[20469,20530]], + "1883": [[19736,19809],[20101,20162],[20471,20532]], + "1886": [[19737,19810],[20101,20162],[20472,20533]], + "1888": [[19738,19811],[20102,20163],[20473,20534]], + "1889": [[19198,19320],[19530,19621],[19890,19984],[20253,20347],[20617,20711]], + "1890": [[19739,19811],[20103,20164],[20474,20535]], + "1891": [[19195,19319],[19530,19620],[19891,19985],[20254,20348],[20618,20712]], + "1893": [[18993,19025],[19358,19390],[19723,19755],[20089,20121],[20454,20486]], + "1894": [[18993,19025],[19358,19390],[19723,19755],[20089,20121],[20454,20486]], + "1901": [[17906,17991]], + "1908": [[19024,19053],[19754,19784],[20120,20149],[20485,20514]], + "1909": [[19024,19053],[19754,19784],[20120,20149],[20485,20514]], + "1912": [[19052,19084],[19783,19815],[20148,20180],[20513,20545]], + "1913": [[19052,19084],[19783,19815],[20148,20180],[20513,20545]], + "1926": [[19194,19318],[19530,19619],[19892,19986],[20255,20349],[20619,20713]], + "1927": [[19199,19321],[19530,19630],[19879,19973],[20244,20338],[20607,20702]], + "1929": [[19193,19317],[19530,19629],[19881,19975],[20245,20339],[20609,20703]], + "1930": [[19200,19322],[19530,19628],[19882,19976],[20246,20340],[20610,20704]], + "1931": [[19188,19314],[19530,19627],[19883,19977],[20247,20341],[20611,20705]], + "1932": [[18964,19004],[19332,19369],[19694,19734],[20060,20100],[20424,20465]], + "1934": [[18958,19068],[19330,19369],[19694,19734],[20060,20100],[20424,20465]], + "1935": [[18968,19004],[19335,19369],[19700,19734],[20066,20100],[20425,20465]], + "1938": [[19332,19369],[19697,19734],[20063,20100],[20425,20465]], + "1940": [[17211,17222]], + "1941": [[20237,20242]], + "1942": [[20237,20242]], + "1943": [[20237,20242]], + "1944": [[19028,19053],[19757,19784],[20121,20149],[20492,20514]], + "1948": [[19866,19871]], + "1958": [[19184,19311],[19530,19626],[19884,19978],[20248,20342],[20612,20706]], + "1959": [[19191,19315],[19530,19625],[19885,19979],[20249,20343],[20613,20707]], + "1960": [[19032,19053],[19761,19784],[20133,20149],[20504,20514]], + "1961": [[19028,19053]], + "1962": [[19028,19053],[19757,19784],[20121,20149],[20492,20514]], + "1964": [[18290,18333]], + "1965": [[20237,20242]], + "1966": [[20237,20242]], + "1967": [[20237,20242]], + "1968": [[20237,20242]], + "1969": [[20237,20242]], + "1971": [[20237,20242]], + "1972": [[20237,20242]], + "1985": [[17584,17619]], + "1992": [[19083,19114],[19814,19845],[20179,20210],[20544,20575]], + "1994": [[19083,19114],[19814,19845],[20179,20210],[20544,20575]], + "2011": [[17589,17619]], + "2014": [[17589,17619]], + "2018": [[19113,19145],[19478,19510],[19844,19876],[20209,20241],[20574,20606]], + "2019": [[18327,18360]], + "2020": [[19113,19145],[19478,19510],[19844,19876],[20209,20241],[20574,20606]], + "2042": [[19144,19175],[19509,19540],[19875,19906],[20240,20271],[20605,20636]], + "2043": [[19144,19175],[19509,19540],[19875,19906],[20240,20271],[20605,20636]], + "2044": [[17239,17260]], + "2045": [[19065,19081],[19796,19812],[20161,20177],[20526,20542]], + "2046": [[17239,17260]], + "2047": [[19065,19081],[19796,19812],[20161,20177],[20526,20542]], + "2048": [[19065,19081],[19796,19812],[20161,20177],[20526,20542]], + "2049": [[19065,19081],[19796,19812],[20161,20177],[20526,20542]], + "2074": [[19756,19799],[20122,20149],[20493,20514]], + "2084": [[19174,19189],[19537,19552],[19908,19923],[20271,20291],[20635,20656]], + "2085": [[19174,19189],[19537,19552],[19908,19923],[20271,20291],[20635,20656]], + "2086": [[19174,19189],[19537,19552],[19908,19923],[20271,20291],[20635,20656]], + "2087": [[19174,19189],[19537,19552],[19908,19923],[20271,20291],[20635,20656]], + "2089": [[19758,19804],[20141,20263],[20511,20628]], + "2090": [[19758,19804],[20143,20265],[20515,20630]], + "2095": [[19899,19993],[20255,20349],[20619,20713]], + "2114": [[19137,19276],[19505,19627],[19903,19997],[20261,20355],[20625,20719]], + "2117": [[19145,19258],[19507,19673],[19871,19965],[20222,20316],[20586,20680]], + "2170": [[19174,19206],[19539,19571],[19905,19937],[20270,20302],[20635,20667]], + "2171": [[19174,19206],[19539,19571],[19905,19937],[20270,20302],[20635,20667]], + "2177": [[16974,17364]], + "2180": [[16974,17364]], + "2184": [[16974,17364]], + "2185": [[16974,17364]], + "2191": [[16988,17072]], + "2194": [[19205,19237],[19570,19602],[19936,19968],[20301,20333],[20666,20698]], + "2195": [[19205,19237],[19570,19602],[19936,19968],[20301,20333],[20666,20698]], + "2207": [[17900,17983]], + "2208": [[17901,17984]], + "2229": [[18402,18855]], + "2232": [[18402,18855]], + "2270": [[16988,17073]], + "2284": [[19236,19267],[19601,19632],[19967,19998],[20332,20363],[20697,20728]], + "2285": [[19236,19267],[19601,19632],[19967,19998],[20332,20363],[20697,20728]], + "2295": [[19225,19238],[19591,19603],[19956,19969],[20318,20353],[20683,20718]], + "2296": [[19222,19238],[19588,19603],[19950,19969],[20314,20353],[20679,20718]], + "2298": [[19224,19238],[19590,19603],[19955,19969],[20317,20353],[20682,20718]], + "2304": [[17016,17133]], + "2321": [[19266,19298],[19631,19663],[19997,20029],[20362,20394],[20727,20759]], + "2322": [[19266,19298],[19631,19663],[19997,20029],[20362,20394],[20727,20759]], + "2324": [[19297,19328],[19662,19693],[20028,20059],[20393,20424],[20758,20789]], + "2325": [[19297,19328],[19662,19693],[20028,20059],[20393,20424],[20758,20789]], + "2326": [[19327,19359],[19692,19724],[20058,20090],[20423,20455]], + "2328": [[19327,19359],[19692,19724],[20058,20090],[20423,20455]], + "2339": [[19288,19308],[19647,19673],[20012,20039],[20374,20404],[20738,20769]], + "2340": [[19270,19308],[19632,19673],[20002,20039],[20368,20404],[20732,20769]], + "2344": [[19286,19308],[19645,19673],[20009,20039],[20385,20404],[20749,20769]], + "2345": [[19276,19308],[19639,19673],[20009,20039],[20386,20404],[20750,20769]], + "2347": [[19277,19308],[19639,19673],[20011,20039],[20374,20404],[20738,20769]], + "2353": [[17723,19041]], + "2354": [[18063,19211]], + "2358": [[16998,17371]], + "2359": [[19293,19308],[19657,19673],[20024,20039],[20382,20404],[20746,20769]], + "2361": [[19183,19310],[19555,19684],[19934,20028],[20300,20394],[20664,20758]], + "2387": [[19821,19836]], + "2396": [[19816,19909],[20209,20303],[20573,20666]], + "2397": [[18816,18821]], + "2398": [[18816,18821]], + "2399": [[18816,18821]], + "2401": [[19297,19348],[20031,20079],[20395,20444],[20759,20809]], + "2402": [[19321,19348],[19685,19713],[20050,20079],[20416,20444]], + "2404": [[18418,18903]], + "2408": [[17772,18880],[20180,20235],[20542,20600]], + "2409": [[17772,18878],[20180,20235],[20542,20600]], + "2410": [[17774,18881],[20180,20235],[20542,20600]], + "2411": [[19299,19348],[20033,20079],[20397,20444],[20761,20809]], + "2412": [[19303,19348],[19667,19713]], + "2417": [[18145,18259]], + "2418": [[19001,19096],[19731,19805],[20094,20155],[20465,20526]], + "2419": [[19017,19137],[19747,19841],[20111,20172],[20482,20543]], + "2420": [[18136,19232]], + "2421": [[18128,19222]], + "2422": [[18129,19223]], + "2423": [[18129,19225]], + "2424": [[18131,19226]], + "2425": [[18132,19227]], + "2426": [[18130,19224]], + "2427": [[18133,19228]], + "2428": [[18135,19230]], + "2429": [[18137,19233]], + "2430": [[18139,19234]], + "2431": [[18141,19235]], + "2434": [[18605,18638]], + "2435": [[18980,19004]], + "2437": [[17002,17390]], + "2438": [[17002,17390]], + "2447": [[19351,19369],[19713,19734],[20079,20100],[20441,20465]], + "2448": [[19342,19369],[19709,19734],[20075,20100],[20436,20465]], + "2449": [[17884,17908],[19929,19934]], + "2452": [[19929,19934]], + "2453": [[19929,19934]], + "2455": [[18609,18711],[19342,19369],[19708,19734],[20074,20100],[20433,20465]], + "2456": [[19929,19934]], + "2461": [[18967,19004],[19338,19369],[19702,19734],[20068,20100],[20425,20465]], + "2462": [[18962,19004],[19329,19369],[19693,19734],[20059,20100],[20424,20465]], + "2464": [[17205,17230]], + "2465": [[19031,19053],[19757,19784],[20124,20149],[20495,20514]], + "2466": [[19035,19053],[19767,19784],[20130,20149],[20501,20514]], + "2468": [[19032,19053],[19762,19784],[20127,20149],[20498,20514]], + "2469": [[17205,17224]], + "2470": [[17200,17227]], + "2471": [[18290,18335]], + "2472": [[19033,19053],[19763,19784],[20128,20149],[20499,20514]], + "2473": [[19029,19053],[19759,19784],[20123,20149],[20494,20514]], + "2474": [[19031,19053],[19761,19784],[20126,20149],[20497,20514]], + "2477": [[19053,19084],[19783,19815],[20155,20180],[20524,20545]], + "2479": [[18992,19014],[19356,19379],[19721,19744],[20087,20110],[20450,20475]], + "2480": [[18992,19014],[19357,19379],[19722,19744],[20088,20110],[20450,20475]], + "2483": [[17149,17524]], + "2488": [[18993,19082],[19724,19797],[20090,20162],[20455,20539]], + "2489": [[18994,19083],[19725,19798],[20091,20163],[20457,20539]], + "2490": [[18995,19084],[19726,19799],[20092,20164],[20459,20539]], + "2491": [[18996,19085],[19725,19800],[20090,20165],[20460,20522]], + "2493": [[18997,19086],[19727,19801],[20090,20166],[20460,20522]], + "2494": [[18998,19087],[19728,19801],[20090,20167],[20460,20522]], + "2501": [[18816,18821]], + "2502": [[18816,18821]], + "2503": [[18816,18821]], + "2510": [[19052,19084],[19783,19815],[20146,20180],[20517,20545]], + "2511": [[19053,19094],[19784,19815],[20147,20180],[20517,20545]], + "2512": [[17587,17619]], + "2525": [[17775,18879],[20180,20235],[20544,20600]], + "2526": [[17776,18877],[20180,20235],[20545,20600]], + "2527": [[17777,18875],[20182,20235],[20546,20600]], + "2528": [[17778,18876],[20182,20235],[20549,20581]], + "2529": [[17779,18882],[20186,20235],[20551,20583]], + "2530": [[17780,18883],[20191,20235],[20558,20590]], + "2531": [[17781,18884],[20183,20235],[20547,20600]], + "2532": [[17782,18885],[20184,20235],[20548,20600]], + "2545": [[17783,18886],[20185,20235],[20549,20600]], + "2546": [[17787,18890],[20186,20235],[20550,20600]], + "2547": [[17785,18888],[20187,20235],[20551,20600]], + "2548": [[17786,18889],[20184,20235],[20544,20576]], + "2551": [[19159,19271],[19519,19674],[19878,19972],[20223,20317],[20587,20681]], + "2552": [[19158,19269],[19521,19675],[19880,19974],[20225,20319],[20589,20683]], + "2554": [[16988,17074]], + "2555": [[19303,19348],[19667,19713],[20051,20079]], + "2593": [[19348,19369],[19702,19734],[20068,20100],[20427,20465]], + "2597": [[17784,18887],[20189,20235],[20556,20588]], + "2602": [[18318,18458]], + "2606": [[18689,18719]], + "2644": [[19123,19267],[19495,19620],[19889,19983],[20247,20341],[20611,20705]], + "2675": [[17260,17624]], + "2676": [[17261,17625]], + "2677": [[19223,19238],[19589,19603],[19953,19969],[20316,20353],[20681,20718]], + "2678": [[19076,19245],[19481,19678],[19976,20069],[20337,20430],[20701,20795]], + "2679": [[19075,19244],[19480,19677],[19975,20068],[20336,20429],[20700,20794]], + "2680": [[19074,19246],[19488,19676],[19973,20066],[20341,20434],[20706,20799]], + "2681": [[19073,19243],[19479,19676],[19980,20073],[20340,20433],[20704,20798]], + "2682": [[19078,19247],[19482,19680],[19978,20071],[20339,20432],[20703,20797]], + "2683": [[19077,19246],[19480,19679],[19977,20070],[20338,20431],[20702,20796]], + "2702": [[18816,18821]], + "2731": [[17257,17319]], + "2732": [[18025,19214]], + "2733": [[18026,19215]], + "2734": [[18027,19216]], + "2735": [[18028,19217]], + "2736": [[18029,19218]], + "2737": [[18030,19219]], + "2738": [[18031,19220]], + "2739": [[17004,17391]], + "2740": [[17006,17393]], + "2741": [[17011,17398]], + "2742": [[17004,17391]], + "2743": [[17004,17391]], + "2744": [[17005,17392]], + "2745": [[17015,17371]], + "2746": [[17010,17397]], + "2747": [[17013,17400]], + "2748": [[17008,17395]], + "2749": [[17012,17399]], + "2750": [[17009,17396]], + "2754": [[17016,17382]], + "2755": [[17016,17382]], + "2756": [[17016,17382]], + "2757": [[17016,17382]], + "2758": [[17016,17382]], + "2770": [[17002,17388]], + "2772": [[17017,17373]], + "2773": [[18851,18856]], + "2774": [[18420,18903]], + "2776": [[18416,18954]], + "2777": [[18422,18953]], + "2778": [[18426,18903]], + "2779": [[18425,18903]], + "2780": [[17066,17443]], + "2786": [[19907,19922],[20272,20287],[20637,20652]], + "2787": [[19907,19922],[20272,20287],[20637,20652]], + "2788": [[19907,19922],[20272,20287],[20637,20652]], + "2792": [[17022,17388]], + "2799": [[19273,19308],[19637,19673],[20006,20039],[20377,20404],[20741,20769]], + "2801": [[19270,19308],[19635,19673],[20000,20039],[20362,20404],[20726,20769]], + "2805": [[17047,17410]], + "2812": [[18809,18814]], + "2819": [[18851,18856]], + "2820": [[18851,18856]], + "2821": [[18851,18856]], + "2834": [[19267,19308],[19630,19673],[19999,20039],[20361,20404],[20725,20769]], + "2837": [[19292,19308],[19652,19673],[20020,20039],[20389,20404],[20753,20769]], + "2845": [[17079,17439]], + "2846": [[19266,19308],[19629,19673],[19998,20039],[20359,20404],[20723,20769]], + "2847": [[19266,19308],[19629,19673],[19998,20039],[20360,20404],[20724,20769]], + "2848": [[19275,19308],[19638,19673],[20008,20039],[20384,20404],[20748,20769]], + "2849": [[19268,19308],[19631,19673],[20001,20039],[20364,20404],[20728,20769]], + "2850": [[19271,19308],[19632,19673],[20003,20039],[20370,20404],[20734,20769]], + "2852": [[19269,19308],[19631,19673],[20002,20039],[20367,20404],[20731,20769]], + "2856": [[19275,19308],[19649,19673],[20004,20039],[20365,20404],[20729,20769]], + "2857": [[19277,19308],[19651,19673],[20006,20039],[20368,20404],[20732,20769]], + "2858": [[19279,19308],[19655,19673],[20013,20039],[20375,20404],[20739,20769]], + "2859": [[19278,19308],[19653,19673],[20011,20039],[20372,20404],[20736,20769]], + "2860": [[19280,19308],[19657,19673],[20018,20039],[20379,20404],[20743,20769]], + "2862": [[19276,19308],[19659,19673],[20020,20039],[20382,20404],[20746,20769]], + "2864": [[18143,18298]], + "2865": [[19243,19384],[19611,19705],[20028,20079],[20393,20444],[20758,20809]], + "2866": [[19300,19348],[19664,19713],[20033,20079],[20398,20444]], + "2867": [[19265,19373],[19662,19713],[20033,20079],[20398,20444]], + "2869": [[19729,19797],[20093,20154],[20461,20522]], + "2886": [[18962,19004],[19326,19369],[19692,19734],[20058,20100],[20423,20465]], + "2887": [[17879,17908]], + "2890": [[18851,18856]], + "2891": [[18851,18856]], + "2892": [[18851,18856]], + "2909": [[18963,19004]], + "2910": [[19929,19934]], + "2911": [[18979,19004],[19347,19369],[19714,19734],[20080,20100],[20440,20465]], + "2912": [[18971,19004],[19331,19369],[19695,19734],[20061,20100],[20423,20465]], + "2914": [[18984,19004],[19349,19369],[19715,19734],[20081,20100],[20441,20465]], + "2915": [[19929,19934]], + "2920": [[18816,18821]], + "2921": [[18816,18821]], + "2922": [[19762,19799],[20135,20149],[20503,20514]], + "2923": [[19887,19892]], + "2924": [[19887,19892]], + "2957": [[17184,17564]], + "2958": [[17184,17564]], + "2959": [[17149,17530]], + "2960": [[17149,17530]], + "2962": [[17184,17564]], + "2963": [[17184,17564]], + "2976": [[17184,17564]], + "2979": [[17184,17564]], + "2998": [[19866,19871]], + "2999": [[20237,20242]], + "3000": [[20237,20242]], + "3001": [[20237,20242]], + "3002": [[20237,20242]], + "3004": [[19028,19053],[19757,19784],[20122,20149],[20493,20514]], + "3005": [[19027,19053],[19755,19784],[20119,20149],[20490,20514]], + "3006": [[19032,19053],[19763,19784],[20128,20149],[20499,20514]], + "3007": [[19025,19053],[19753,19784],[20120,20149],[20491,20514]], + "3008": [[19025,19053],[19753,19784],[20119,20149],[20490,20514]], + "3012": [[19887,19892]], + "3031": [[18324,18358]], + "3032": [[18322,18361]], + "3033": [[18323,18361]], + "3034": [[19055,19094],[19784,19815],[20148,20180],[20517,20545]], + "3035": [[18321,18357]], + "3043": [[19056,19183]], + "3061": [[17394,17515],[19821,19836]], + "3062": [[17396,17514],[19821,19836]], + "3063": [[17397,17513],[19821,19836]], + "3064": [[18331,18362]], + "3069": [[19887,19892]], + "3070": [[19887,19892]], + "3071": [[19887,19892]], + "3105": [[17262,17267]], + "3124": [[17338,17354]], + "3127": [[17338,17354]], + "3128": [[17338,17354]], + "3129": [[17338,17354]], + "3130": [[17338,17354]], + "3131": [[17338,17354]], + "3132": [[17338,17354]], + "3133": [[17338,17354]], + "3146": [[17440,17494]], + "3168": [[17310,17496]], + "3174": [[19308,19348],[19672,19713],[20038,20079],[20408,20444]], + "3175": [[17310,17495]], + "3185": [[17399,17511],[19821,19836]], + "3186": [[17398,17512],[19821,19836]], + "3189": [[19182,19294],[19556,19656],[19935,20029],[20305,20399],[20666,20760]], + "3190": [[17332,18558]], + "3191": [[19201,19323],[19549,19654],[19928,20022],[20293,20387],[20657,20751]], + "3194": [[19202,19324],[19550,19655],[19929,20023],[20298,20392],[20659,20753]], + "3198": [[19216,19257],[19579,19622],[19939,19988],[20308,20353],[20672,20718]], + "3203": [[19295,19308],[19657,19673],[20025,20039]], + "3218": [[17352,17358]], + "3220": [[17352,17358]], + "3223": [[17352,17358]], + "3224": [[17352,17358]], + "3225": [[17352,17358]], + "3226": [[17352,17358]], + "3231": [[19175,19189],[19536,19552],[19907,19923],[20269,20291],[20633,20656]], + "3232": [[19175,19189],[19538,19552],[19908,19923],[20271,20291],[20635,20656]], + "3233": [[19176,19189],[19539,19552],[19908,19923],[20272,20287],[20635,20652]], + "3234": [[19176,19189],[19540,19552],[19909,19923],[20273,20287],[20637,20652]], + "3235": [[19179,19189],[19543,19552],[19912,19924],[20276,20287],[20640,20652]], + "3236": [[19180,19189],[19544,19552],[19913,19925],[20277,20287],[20641,20652]], + "3294": [[17366,17372]], + "3295": [[17366,17372]], + "3296": [[17366,17372]], + "3297": [[17366,17372]], + "3298": [[17366,17372]], + "3299": [[17366,17372]], + "3300": [[17366,17372]], + "3301": [[17366,17372]], + "3302": [[17366,17372]], + "3303": [[17366,17372]], + "3304": [[17366,17372]], + "3305": [[17366,17372]], + "3311": [[17371,17373]], + "3324": [[17388,17393]], + "3325": [[17388,17393]], + "3327": [[17388,17393]], + "3328": [[17388,17393]], + "3342": [[19267,19308],[19630,19673],[19999,20039],[20362,20404],[20726,20769]], + "3376": [[19235,19377],[19663,19713],[20032,20079],[20396,20444],[20760,20809]], + "3427": [[19612,19706],[19992,20085],[20351,20444],[20715,20809]], + "3428": [[19305,19348],[19669,19713],[20035,20079],[20405,20444]], + "3429": [[19307,19348],[19671,19713],[20037,20079],[20406,20444]], + "3430": [[19309,19348],[19673,19713],[20039,20079],[20407,20444]], + "3431": [[19310,19348],[19674,19713],[20040,20079],[20405,20444]], + "3434": [[19261,19387],[19613,19707],[20029,20079],[20394,20444],[20758,20809]], + "3437": [[19309,19348],[19673,19713],[20039,20079],[20409,20444]], + "3449": [[18966,19004],[19334,19369],[19699,19734],[20065,20100],[20425,20465]], + "3450": [[18964,19004],[19333,19369],[19698,19734],[20064,20100],[20425,20465]], + "3451": [[19929,19934]], + "3452": [[19929,19934]], + "3453": [[19313,19348],[19677,19713],[20043,20079],[20409,20444]], + "3454": [[19311,19348],[19675,19713],[20041,20079],[20408,20444]], + "3455": [[19317,19338],[19681,19703],[20047,20069],[20399,20434]], + "3456": [[19320,19338],[19684,19703],[20055,20069],[20414,20434]], + "3459": [[18986,19004]], + "3460": [[18986,19004]], + "3461": [[18970,19004]], + "3462": [[18964,19004],[19337,19369],[19692,19734],[20058,20100],[20423,20465]], + "3463": [[18965,19004]], + "3464": [[18965,19004]], + "3478": [[17528,17542]], + "3479": [[17528,17542]], + "3503": [[18848,18850]], + "3504": [[19000,19094],[19730,19804],[20093,20154],[20463,20524]], + "3505": [[19005,19088],[19745,19811],[20109,20170],[20474,20535]], + "3507": [[19002,19098],[19732,19806],[20096,20157],[20467,20528]], + "3508": [[19031,19053],[19760,19784],[20131,20149],[20502,20514]], + "3509": [[19027,19053],[19759,19784],[20135,20149],[20506,20514]], + "3511": [[19027,19053],[19753,19784]], + "3513": [[19027,19053],[19753,19784]], + "3514": [[18293,18332]], + "3517": [[19052,19084],[19779,19815],[20144,20180],[20515,20545]], + "3518": [[19053,19084],[19778,19815],[20142,20180],[20513,20545]], + "3521": [[18320,18359]], + "3523": [[19046,19084],[19784,19815],[20148,20180],[20516,20545]], + "3525": [[18324,18357]], + "3561": [[19072,19256],[19485,19682],[19970,20063],[20335,20428],[20698,20793]], + "3589": [[19099,19124],[19807,19840],[20188,20220],[20545,20577]], + "3590": [[17623,17671]], + "3591": [[19099,19124],[19811,19844],[20198,20230],[20552,20584]], + "3592": [[19098,19124],[19810,19843],[20194,20226],[20554,20586]], + "3594": [[19097,19124],[19809,19842],[20191,20223],[20549,20581]], + "3601": [[18354,18854]], + "3602": [[18356,18854]], + "3604": [[18355,18854]], + "3605": [[18357,18854]], + "3606": [[18358,18854]], + "3607": [[18360,18854]], + "3608": [[17696,17718]], + "3609": [[17696,17718],[19684,19690]], + "3610": [[17696,17718]], + "3611": [[17696,17718]], + "3612": [[17696,17718],[19684,19690]], + "3614": [[17696,17718]], + "3615": [[17696,17718],[19684,19690]], + "3616": [[17696,17718]], + "3617": [[17696,17718],[19684,19690]], + "3623": [[19138,19143],[19530,19535]], + "3624": [[19138,19143],[19530,19535]], + "3626": [[19138,19143],[19530,19535]], + "3627": [[19138,19143],[19530,19535]], + "3628": [[19138,19143],[19530,19535]], + "3629": [[19138,19143],[19530,19535]], + "3630": [[19138,19143],[19530,19535]], + "3631": [[19138,19143],[19530,19535]], + "3632": [[19138,19143],[19530,19535]], + "3633": [[19138,19143],[19530,19535]], + "3634": [[19138,19143],[19530,19535]], + "3635": [[19138,19143],[19530,19535]], + "3651": [[17696,17718],[19684,19690]], + "3665": [[19207,19213]], + "3666": [[19207,19213]], + "3667": [[19207,19213]], + "3668": [[19207,19213]], + "3669": [[19207,19213]], + "3670": [[19207,19213]], + "3671": [[19207,19213]], + "3672": [[19207,19213]], + "3673": [[19207,19213]], + "3674": [[19207,19213]], + "3675": [[19207,19213]], + "3676": [[19207,19213]], + "3683": [[19144,19150]], + "3684": [[19144,19150]], + "3685": [[19144,19150]], + "3686": [[19144,19150]], + "3687": [[19144,19150]], + "3688": [[19144,19150]], + "3689": [[19144,19150]], + "3690": [[19144,19150]], + "3691": [[19144,19150]], + "3692": [[19144,19150]], + "3693": [[19144,19150]], + "3694": [[19144,19150]], + "3707": [[19173,19178]], + "3708": [[19173,19178]], + "3709": [[19173,19178]], + "3710": [[19173,19178]], + "3711": [[19173,19178]], + "3712": [[19173,19178]], + "3713": [[19173,19178]], + "3714": [[19173,19178]], + "3715": [[19173,19178]], + "3716": [[19173,19178]], + "3717": [[19173,19178]], + "3718": [[19173,19178]], + "3727": [[19159,19164]], + "3728": [[19159,19164]], + "3729": [[19159,19164]], + "3730": [[19159,19164]], + "3731": [[19159,19164]], + "3732": [[19159,19164]], + "3733": [[19159,19164]], + "3734": [[19159,19164]], + "3735": [[19159,19164]], + "3736": [[19159,19164]], + "3737": [[19159,19164]], + "3739": [[19159,19164]], + "3740": [[19131,19136]], + "3741": [[19131,19136]], + "3742": [[19131,19136]], + "3743": [[19131,19136],[19530,19535]], + "3744": [[19131,19136]], + "3745": [[19131,19136]], + "3746": [[19131,19136]], + "3747": [[19131,19136]], + "3748": [[19131,19136]], + "3749": [[19131,19136]], + "3750": [[19131,19136]], + "3772": [[19144,19259],[19510,19647],[19874,19916],[20240,20271],[20605,20636]], + "3831": [[19282,19308],[19643,19673],[20018,20039],[20387,20404],[20751,20769]], + "3832": [[19275,19308],[19638,19673],[20008,20039],[20384,20404],[20748,20769]], + "3833": [[19285,19308],[19644,19673],[20007,20039],[20378,20404],[20742,20769]], + "3834": [[19283,19308],[19643,19673],[20003,20039],[20369,20404],[20733,20769]], + "3835": [[19270,19308],[19633,19673],[19998,20039],[20362,20404],[20726,20769]], + "3836": [[19270,19308],[19633,19673],[19998,20039],[20362,20404],[20726,20769]], + "3837": [[19283,19308],[19643,19673],[20002,20039],[20366,20404],[20730,20769]], + "3838": [[19272,19308],[19635,19673],[20000,20039],[20362,20404],[20726,20769]], + "3839": [[19282,19308],[19642,19673],[20025,20039]], + "3840": [[19274,19308],[19637,19673],[20006,20039],[20378,20404],[20742,20769]], + "3841": [[19279,19308],[19640,19673],[20014,20039],[20380,20404],[20744,20769]], + "3870": [[19272,19308],[19635,19673],[20000,20039],[20362,20404],[20726,20769]], + "3876": [[19285,19308],[19653,19673],[20019,20039],[20378,20404],[20742,20769]], + "3877": [[19281,19308],[19642,19673],[20023,20039]], + "3878": [[19284,19308],[19644,19673],[20005,20039],[20372,20404],[20736,20769]], + "3879": [[19293,19308],[19654,19673],[20022,20039],[20390,20404],[20754,20769]], + "3880": [[19296,19308],[19658,19673],[20026,20039],[20391,20404],[20755,20769]], + "3882": [[19288,19308],[19647,19673],[20013,20039],[20375,20404],[20739,20769]], + "3883": [[19295,19308],[19656,19673],[20024,20039]], + "3884": [[18912,18943],[19655,19673],[20012,20039],[20380,20404],[20744,20769]], + "3885": [[19270,19308],[19635,19673],[20003,20039],[20370,20404],[20734,20769]], + "3886": [[19286,19308],[19645,19673],[20008,20039],[20380,20404],[20744,20769]], + "3887": [[19294,19308],[19655,19673],[20023,20039]], + "3889": [[19319,19338],[19683,19703],[20049,20069],[20412,20434]], + "3890": [[19298,19348],[19662,19713],[20033,20079],[20398,20444]], + "3891": [[19311,19338],[19675,19703],[20041,20069],[20411,20434]], + "3893": [[19313,19348],[19677,19713],[20043,20079],[20399,20444]], + "3894": [[19314,19348],[19678,19713],[20044,20079],[20400,20444]], + "3895": [[19306,19348],[19670,19713],[20036,20079],[20406,20444]], + "3933": [[18986,19004],[19351,19369],[19716,19734],[20082,20100],[20443,20465]], + "3936": [[18982,19004],[19345,19369],[19699,19734],[20065,20100],[20427,20465]], + "3944": [[18602,18635]], + "3945": [[18603,18636]], + "3946": [[18604,18682]], + "3947": [[17874,17908]], + "3948": [[18607,18640]], + "3949": [[18606,18639]], + "3950": [[18213,18230]], + "3951": [[18974,19004]], + "3952": [[18608,18641]], + "3958": [[18967,19004],[19332,19369],[19712,19734],[20078,20100],[20438,20465]], + "3959": [[18977,19004],[19341,19369],[19705,19734],[20071,20100],[20427,20465]], + "3960": [[18968,19004],[19338,19369],[19702,19734],[20068,20100],[20429,20465]], + "3961": [[17883,18446]], + "3962": [[17886,18444]], + "3963": [[17887,18443]], + "3964": [[17888,18446]], + "3965": [[17889,18447]], + "3967": [[17890,18447]], + "3968": [[17928,17953]], + "3969": [[17930,17953]], + "3970": [[17929,17953]], + "3971": [[17931,17953]], + "3972": [[17932,17953]], + "3973": [[18290,18334]], + "3975": [[18290,18336]], + "3989": [[18290,18338]], + "3990": [[19033,19053],[19764,19784],[20129,20149],[20500,20514]], + "3992": [[18290,18339]], + "3996": [[18325,18355]], + "3997": [[18333,18362]], + "3998": [[18329,18369]], + "3999": [[19068,19094],[19799,19825],[20164,20180],[20529,20545]], + "4000": [[18327,18360]], + "4001": [[18326,18361]], + "4002": [[18332,18362]], + "4004": [[18328,18361]], + "4005": [[18331,18359]], + "4006": [[18323,18361]], + "4010": [[17905,17922]], + "4038": [[19065,19081],[19796,19812],[20161,20177],[20526,20542]], + "4039": [[19065,19081],[19796,19812],[20161,20177],[20526,20542]], + "4040": [[19065,19081],[19796,19812],[20161,20177],[20526,20542]], + "4041": [[19065,19081],[19796,19812],[20161,20177],[20526,20542]], + "4042": [[19065,19081],[19796,19812],[20161,20177],[20526,20542]], + "4043": [[19065,19081],[19796,19812],[20161,20177],[20526,20542]], + "4051": [[17991,18037],[19808,19841],[20189,20221],[20546,20578]], + "4052": [[17995,18044],[19809,19842],[20192,20224],[20550,20582]], + "4053": [[17996,18050],[19809,19842],[20192,20224],[20550,20582]], + "4054": [[19098,19124],[19810,19843],[20196,20228]], + "4055": [[19808,19841],[20190,20222],[20547,20579]], + "4056": [[17992,18039],[19810,19843],[20193,20225],[20552,20584]], + "4057": [[17997,18046],[19812,19845],[20197,20229],[20551,20583]], + "4058": [[17998,18054],[19807,19840],[20186,20218],[20548,20580]], + "4059": [[17993,18040],[19811,19844],[20195,20227],[20556,20588]], + "4060": [[17989,18036],[19806,19839],[20188,20220],[20542,20576]], + "4061": [[19813,19845],[20198,20230],[20548,20580]], + "4062": [[17994,18043],[19811,19844],[20196,20228],[20558,20590]], + "4063": [[18005,18156]], + "4065": [[18014,18179]], + "4066": [[18006,18158]], + "4067": [[18007,18159]], + "4068": [[19142,19290],[19528,19631],[19919,20013],[20278,20372],[20642,20736]], + "4069": [[17989,18152]], + "4070": [[18001,18155]], + "4071": [[19163,19273],[19569,19688],[19915,20009],[20282,20376],[20646,20740]], + "4072": [[19166,19297],[19838,19931],[20256,20350],[20620,20714]], + "4081": [[18352,18815]], + "4082": [[19082,19195],[19814,19835],[20176,20198],[20541,20563]], + "4083": [[19083,19104],[19814,19835],[20178,20198],[20543,20563]], + "4084": [[19080,19104],[19814,19835],[20174,20198],[20539,20563]], + "4085": [[19081,19104],[19814,19835],[20175,20198],[20540,20563]], + "4086": [[19081,19104],[19814,19835],[20180,20198],[20542,20563]], + "4089": [[19167,19389],[19527,19653],[19898,19992],[20259,20353],[20623,20717]], + "4090": [[19164,19295],[19607,19701],[19985,20078],[20346,20439],[20710,20804]], + "4091": [[18408,18956]], + "4092": [[19138,19250],[19500,19632],[19864,19958],[20257,20351],[20621,20715]], + "4093": [[18416,18951]], + "4097": [[18409,18950]], + "4098": [[18410,18952]], + "4100": [[19135,19383],[19506,19649],[19884,19978],[20245,20339],[20609,20703]], + "4101": [[19170,19326],[19513,19651],[19917,20011],[20279,20373],[20644,20738]], + "4103": [[19150,19261],[19515,19634],[19879,19973],[20260,20354],[20624,20718]], + "4104": [[18052,18198]], + "4105": [[19143,19255],[19501,19657],[19865,19959],[20258,20352],[20622,20716]], + "4106": [[18055,18211]], + "4107": [[19157,19268],[19512,19657],[19893,19987],[20262,20356],[20626,20720]], + "4108": [[19151,19262],[19513,19633],[19899,19993],[20264,20358],[20628,20722]], + "4110": [[19152,19263],[19514,19664],[19900,19994]], + "4112": [[19168,19391],[19520,19652],[19891,19985],[20252,20346],[20616,20710]], + "4113": [[18429,18903]], + "4114": [[19169,19298],[19922,20016],[20289,20383],[20653,20747]], + "4115": [[18430,18903]], + "4116": [[18419,18903]], + "4117": [[18431,18903]], + "4118": [[19171,19300],[19920,20014],[20284,20378],[20648,20742]], + "4119": [[19172,19301],[19921,20015],[20287,20381],[20651,20745]], + "4138": [[18816,18821]], + "4150": [[18019,18549]], + "4163": [[19172,19195],[19508,19530],[19875,19896],[20240,20261],[20605,20626]], + "4179": [[19186,19328],[19562,19645],[19924,20018],[20283,20377],[20648,20742]], + "4180": [[19217,19257],[19580,19622],[19944,19988],[20311,20353],[20675,20718]], + "4181": [[19239,19379],[19845,19939],[20229,20323],[20593,20687]], + "4182": [[19218,19257],[19581,19622],[19945,19988],[20312,20353],[20676,20718]], + "4183": [[19238,19379],[19844,19938],[20227,20321],[20591,20685]], + "4184": [[19237,19378],[19843,19936],[20226,20320],[20590,20684]], + "4210": [[19226,19238],[19588,19603],[19954,19969],[20314,20353],[20679,20718]], + "4211": [[19226,19238],[19589,19603],[19954,19969],[20316,20353],[20681,20718]], + "4212": [[19223,19238],[19587,19603],[19950,19969],[20310,20353],[20675,20718]], + "4213": [[19225,19238],[19587,19603],[19952,19969],[20312,20353],[20677,20718]], + "4274": [[19292,19308],[19653,19673],[20021,20039],[20389,20404],[20753,20769]], + "4275": [[19291,19308],[19650,19673],[20018,20039],[20383,20404],[20747,20769]], + "4276": [[19278,19308],[19640,19673],[20013,20039],[20376,20404],[20740,20769]], + "4279": [[19280,19308],[19641,19673],[20019,20039],[20388,20404],[20752,20769]], + "4280": [[19279,19308],[19641,19673],[20015,20039],[20381,20404],[20745,20769]], + "4281": [[19272,19308],[19636,19673],[20004,20039],[20371,20404],[20735,20769]], + "4282": [[19283,19308],[19634,19673],[20005,20039],[20366,20404],[20730,20769]], + "4283": [[19270,19308],[19632,19673],[20003,20039],[20364,20404],[20728,20769]], + "4286": [[19312,19338],[19676,19703],[20042,20069],[20398,20444]], + "4290": [[18971,19004],[19339,19369],[19704,19734],[20070,20100],[20429,20465]], + "4291": [[18972,19004],[19340,19369],[19705,19734],[20071,20100],[20430,20465]], + "4292": [[18973,19004],[19341,19369],[19706,19734],[20072,20100],[20434,20465]], + "4309": [[19008,19123],[19749,19843],[20113,20174],[20484,20545]], + "4310": [[19005,19120],[19743,19834],[20108,20169],[20478,20539]], + "4311": [[19006,19121],[19743,19836],[20108,20169],[20478,20539]], + "4312": [[19007,19122],[19748,19842],[20112,20173],[20483,20544]], + "4314": [[19002,19083],[19730,19813],[20095,20156],[20461,20522]], + "4316": [[18989,19076],[20447,20539]], + "4361": [[19018,19138]], + "4362": [[18997,19090],[20086,20164],[20453,20539]], + "4363": [[19003,19102],[19741,19814],[20105,20166],[20475,20536]], + "4365": [[19040,19146],[19774,19809],[20138,20199],[20509,20564]], + "4366": [[19041,19147],[19776,19809],[20139,20200],[20510,20565]], + "4367": [[19043,19190],[19777,19870],[20140,20201],[20511,20566]], + "4383": [[19045,19191],[19778,19875],[20141,20202],[20512,20567]], + "4384": [[19034,19053],[19755,19795],[20124,20149],[20495,20514]], + "4385": [[19034,19053],[19755,19794],[20125,20149],[20496,20514]], + "4386": [[19035,19053],[19755,19798],[20127,20149],[20498,20514]], + "4387": [[19035,19053],[19755,19796],[20129,20149],[20500,20514]], + "4388": [[19036,19053],[19755,19799],[20135,20149],[20506,20514]], + "4389": [[19036,19053],[19755,19797],[20131,20149],[20502,20514]], + "4392": [[19038,19053],[19768,19804],[20136,20149],[20507,20514]], + "4449": [[19062,19094],[19792,19825],[20154,20180],[20524,20545]], + "4450": [[19064,19094],[19794,19825],[20156,20180],[20524,20545]], + "4451": [[19063,19094],[19793,19825],[20155,20180],[20524,20545]], + "4452": [[19065,19094],[19795,19825],[20157,20180],[20524,20545]], + "4453": [[18332,18812]], + "4454": [[19066,19094],[19797,19825],[20158,20180],[20524,20545]], + "4455": [[19067,19081],[19798,19825],[20159,20180],[20524,20545]], + "4456": [[19053,19094],[19791,19825],[20153,20180],[20521,20545]], + "4457": [[19060,19094],[19788,19815],[20153,20180],[20522,20545]], + "4458": [[19056,19094],[19790,19825],[20153,20180],[20520,20545]], + "4459": [[19058,19094],[19789,19815],[20153,20180],[20523,20545]], + "4460": [[19062,19094],[19799,19825],[20150,20180],[20517,20545]], + "4464": [[19080,19104],[19814,19835],[20177,20198],[20539,20563]], + "4465": [[19079,19104],[19814,19835],[20178,20198],[20541,20563]], + "4466": [[19079,19104],[19814,19835],[20179,20198],[20543,20563]], + "4467": [[19083,19104],[19815,19835],[20179,20198],[20544,20563]], + "4469": [[19082,19104],[19814,19835],[20177,20198],[20542,20563]], + "4520": [[19094,19202],[19466,19617],[19836,19929],[20200,20293],[20561,20654]], + "4522": [[19095,19203],[19484,19681],[19852,19946],[20220,20314],[20584,20678]], + "4523": [[19100,19204],[19467,19618],[19837,19930],[20201,20294],[20563,20656]], + "4524": [[19088,19197],[19457,19612],[19822,19915],[20202,20295],[20565,20658]], + "4525": [[19089,19198],[19458,19613],[19823,19916],[20204,20297],[20566,20659]], + "4526": [[19093,19201],[19460,19615],[19829,19922],[20206,20299],[20570,20661]], + "4527": [[19091,19200],[19459,19614],[19824,19917],[20205,20298],[20568,20661]], + "4528": [[19088,19199],[19464,19616],[19830,19923],[20208,20301],[20572,20665]], + "4529": [[19071,19194],[19805,19899],[20169,20263],[20533,20627]], + "4530": [[19070,19193],[19804,19898],[20171,20265],[20535,20629]], + "4531": [[19069,19192],[19803,19897],[20173,20267],[20537,20631]], + "4559": [[19172,19195],[19508,19530],[19875,19896],[20240,20261],[20605,20626]], + "4560": [[19172,19195],[19508,19530],[19875,19896],[20240,20261],[20605,20626]], + "4561": [[19172,19195],[19508,19530],[19875,19896],[20240,20261],[20605,20626]], + "4562": [[19172,19195],[19508,19530],[19875,19896],[20240,20261],[20605,20626]], + "4563": [[19172,19195],[19508,19530],[19875,19896],[20240,20261],[20605,20626]], + "4564": [[19172,19195],[19508,19530],[19875,19896],[20240,20261],[20605,20626]], + "4568": [[19172,19195],[19508,19530],[19875,19896],[20240,20261],[20605,20626]], + "4584": [[18434,18903]], + "4585": [[18430,18903]], + "4586": [[18433,18903]], + "4587": [[18432,18903]], + "4589": [[19156,19265],[19511,19635],[19872,19966],[20236,20330],[20600,20694]], + "4590": [[19149,19260],[19522,19682],[19914,20008],[20280,20374],[20644,20738]], + "4591": [[19165,19296],[19604,19698],[19982,20075],[20342,20435],[20706,20709]], + "4592": [[19177,19189],[19541,19552],[19910,19923],[20274,20287],[20638,20652]], + "4593": [[19178,19189],[19542,19552],[19911,19923],[20275,20287],[20639,20652]], + "4594": [[19179,19189],[19906,19920],[20267,20291],[20631,20656]], + "4596": [[19240,19380],[19844,19938],[20230,20324],[20594,20688]], + "4613": [[19219,19257],[19582,19622],[19946,19988],[20312,20353],[20676,20718]], + "4614": [[19220,19257],[19583,19622],[19947,19988],[20313,20353],[20677,20718]], + "4615": [[19221,19257],[19584,19622],[19948,19988],[20313,20353],[20677,20718]], + "4616": [[19222,19257],[19592,19622],[19940,19988],[20309,20353],[20673,20718]], + "4617": [[19241,19381],[19846,19940],[20232,20326],[20596,20690]], + "4618": [[19242,19381],[19847,19941],[20234,20328],[20598,20692]], + "4620": [[19233,19374],[19957,20020],[20328,20422],[20692,20755]], + "4622": [[19235,19375],[19606,19700],[19984,20077],[20344,20437],[20708,20802]], + "4623": [[19234,19375],[19605,19699],[19983,20076],[20343,20436],[20707,20801]], + "4624": [[19969,20062],[20330,20424],[20694,20757]], + "4643": [[18845,18990]], + "4644": [[19209,19257],[19571,19622],[19940,19988],[20309,20353],[20673,20718]], + "4645": [[19210,19257],[19573,19622],[19941,19988],[20310,20353],[20674,20718]], + "4646": [[19211,19257],[19574,19622],[19942,19988],[20310,20353],[20674,20718]], + "4647": [[19212,19257],[19575,19622],[19943,19988],[20311,20353],[20675,20718]], + "4648": [[19213,19257],[19576,19622],[19935,19988],[20307,20353],[20670,20718]], + "4649": [[19214,19257],[19577,19622],[19937,19988],[20307,20353],[20670,20718]], + "4650": [[19227,19252],[19595,19617],[19957,19983],[20321,20348],[20685,20713]], + "4651": [[19228,19252],[19595,19617],[19957,19983],[20323,20348],[20687,20713]], + "4652": [[19229,19252],[19596,19617],[19957,19983],[20325,20348],[20689,20713]], + "4653": [[19230,19252],[19596,19617],[19957,19983],[20327,20348],[20691,20713]], + "4655": [[18507,18804],[19585,19622],[19949,19988],[20313,20353],[20677,20718]], + "4656": [[19247,19384],[19603,19697],[19990,20083],[20348,20441],[20712,20806]], + "4657": [[19302,19348],[19666,19713],[20033,20079],[20398,20444]], + "4670": [[19257,19272],[19622,19637],[19988,20003],[20353,20368],[20718,20733]], + "4671": [[19257,19272],[19622,19637],[19988,20003],[20353,20368],[20718,20733]], + "4672": [[19257,19272],[19622,19637],[19988,20003],[20353,20368],[20718,20733]], + "4686": [[19282,19308],[19642,19673],[19998,20039],[20362,20404],[20726,20769]], + "4687": [[19287,19308],[19646,19673],[20011,20039],[20373,20404],[20737,20769]], + "4688": [[19276,19308],[19638,19673],[20009,20039],[20385,20404],[20749,20769]], + "4689": [[19291,19308],[19650,19673],[20017,20039],[20376,20404],[20740,20769]], + "4690": [[19290,19308],[19649,19673],[20016,20039],[20382,20404],[20746,20769]], + "4691": [[19290,19308],[19649,19673],[20017,20039],[20382,20404],[20746,20769]], + "4692": [[19291,19308],[19651,19673],[20019,20039],[20388,20404],[20752,20769]], + "4694": [[18906,18948],[19564,19686]], + "4695": [[18906,18948],[19563,19685]], + "4696": [[18906,18948],[19565,19687]], + "4709": [[19320,19338],[19684,19703],[20055,20069],[20415,20434]], + "4710": [[19320,19338],[19684,19703],[20055,20069],[20416,20434]], + "4712": [[19320,19338],[19684,19703],[20055,20069],[20417,20434]], + "4713": [[19307,19348],[19671,19713],[20037,20079],[20407,20444]], + "4714": [[19310,19348],[19674,19713],[20040,20079],[20410,20444]], + "4721": [[19929,19934]], + "4723": [[19306,19348],[19670,19713],[20036,20079],[20405,20444]], + "4724": [[19301,19348],[19665,19713],[20033,20079],[20398,20444]], + "4725": [[19304,19338],[19668,19703],[20033,20069],[20398,20444]], + "4726": [[19323,19379],[19687,19749],[20053,20115],[20421,20514]], + "4727": [[19315,19348],[19679,19713],[20045,20079],[20401,20444]], + "4728": [[19316,19348],[19680,19713],[20046,20079],[20402,20444]], + "4729": [[18977,19004],[19344,19369],[19711,19734],[20077,20100],[20437,20465]], + "4731": [[18975,19004],[19343,19369],[19710,19734],[20076,20100],[20436,20465]], + "4732": [[18980,19004],[19348,19369],[19709,19734],[20075,20100],[20434,20465]], + "4733": [[18978,19004],[19346,19369],[19713,19734],[20079,20100],[20439,20465]], + "4734": [[18976,19004],[19326,19369],[19696,19734],[20062,20100],[20425,20465]], + "4735": [[18970,19004],[19337,19369],[19701,19734],[20067,20100],[20425,20465]], + "4736": [[18969,19004],[19336,19369],[19701,19734],[20067,20100],[20425,20465]], + "4771": [[19015,19135],[19727,19802],[20091,20152],[20461,20522]], + "4773": [[19023,19143]], + "4774": [[19025,19144],[19752,19850],[20115,20176],[20486,20547]], + "4775": [[19009,19125],[19712,19734],[20078,20100],[20438,20465]], + "4776": [[19009,19124],[19745,19838],[20110,20171],[20480,20541]], + "4777": [[19001,19081],[19740,19808],[20104,20165],[20469,20530]], + "4778": [[19016,19132],[19691,19794],[20057,20159],[20417,20511]], + "4779": [[19024,19053],[19751,19783],[20116,20177],[20482,20543]], + "4780": [[19013,19121],[19731,19805],[20091,20152],[20463,20524]], + "4781": [[18997,19085],[19733,19818],[20103,20164],[20468,20529]], + "4782": [[19013,19129]], + "4783": [[19011,19127],[19746,19839],[20110,20171],[20481,20542]], + "4808": [[19050,19078],[19780,19809],[20146,20161],[20511,20532]], + "4809": [[19050,19078],[19780,19809],[20146,20161],[20511,20532]], + "4810": [[19050,19078],[19780,19809],[20146,20161],[20511,20532]], + "4811": [[19050,19078],[19780,19809],[20146,20161],[20511,20532]], + "4812": [[19050,19078],[19780,19809],[20146,20161],[20511,20532]], + "4813": [[19050,19078],[19780,19809],[20146,20161],[20511,20532]], + "4817": [[19050,19078],[19780,19809],[20146,20161],[20511,20532]], + "4832": [[19037,19053],[19761,19784],[20125,20149],[20496,20514]], + "4835": [[19037,19053],[19766,19784],[20137,20149],[20508,20514]], + "4836": [[19039,19053],[19769,19804],[20137,20149],[20508,20514]], + "4837": [[19029,19053],[19756,19784]], + "4838": [[19029,19053],[19756,19784]], + "4839": [[19030,19053],[19756,19784]], + "4840": [[19037,19053],[19766,19784],[20132,20149],[20504,20514]], + "4841": [[19034,19053],[19760,19784],[20128,20149],[20496,20514]], + "4842": [[19027,19053],[19755,19784],[20121,20149],[20489,20514]], + "4844": [[19030,19053],[19756,19784]], + "4845": [[19037,19053],[19765,19784],[20120,20149],[20491,20514]], + "4858": [[19049,19084],[19781,19815],[20146,20180],[20517,20545]], + "4864": [[19065,19081],[19796,19812],[20161,20177],[20526,20542]], + "4867": [[19058,19094],[19786,19815],[20160,20180],[20525,20545]], + "4868": [[19057,19094],[19785,19815],[20149,20180],[20517,20545]], + "4869": [[19059,19094],[19788,19815],[20162,20180],[20525,20545]], + "4870": [[19047,19084],[19783,19815],[20146,20180],[20517,20545]], + "4874": [[19061,19094],[19787,19815],[20152,20180],[20519,20545]], + "4877": [[19060,19094],[19788,19825],[20164,20180],[20527,20545]], + "4883": [[19084,19254],[19802,19896],[20180,20273],[20544,20637]], + "4884": [[19801,19895],[20167,20261],[20531,20625]], + "4886": [[19086,19164],[19800,19894],[20168,20262],[20533,20627]], + "4887": [[19083,19104],[19816,19835]], + "4888": [[19083,19104],[19815,19835]], + "4889": [[19083,19104],[19816,19835]], + "4890": [[19083,19104],[19815,19835]], + "4891": [[19083,19104],[19817,19835]], + "4892": [[19083,19104],[19817,19835]], + "4893": [[19083,19104],[19817,19835]], + "4894": [[19083,19104],[19816,19835]], + "4907": [[19096,19124],[19807,19840],[20188,20220],[20544,20576]], + "4914": [[19129,19207],[19492,19610],[19858,19952],[20212,20275],[20576,20639]], + "4915": [[19131,19209],[19494,19611],[19860,19954],[20214,20277],[20578,20641]], + "4916": [[19130,19208],[19493,19610],[19859,19953],[20213,20276],[20577,20640]], + "4917": [[19136,19210],[19499,19611],[19861,19955],[20215,20278],[20579,20642]], + "4918": [[19124,19206],[19487,19609],[19857,19951],[20211,20274],[20575,20638]], + "4919": [[19122,19205],[19486,19609],[19856,19950],[20210,20273],[20574,20637]], + "4938": [[18781,18786]], + "4939": [[18781,18786]], + "4940": [[18781,18786]], + "4941": [[18781,18786]], + "4942": [[18781,18786]], + "4943": [[18799,18801]], + "4945": [[18781,18786]], + "4946": [[18802,18807]], + "4947": [[18802,18807]], + "4948": [[18802,18807]], + "4949": [[18802,18807]], + "4950": [[18795,18800]], + "4951": [[18802,18807]], + "4952": [[18802,18807]], + "4953": [[18795,18800]], + "4954": [[18795,18800]], + "4955": [[18795,18800]], + "4956": [[18788,18793]], + "4959": [[18795,18800]], + "4960": [[18795,18800]], + "4961": [[18788,18793]], + "4970": [[18788,18793]], + "4971": [[18788,18793]], + "4972": [[18788,18793]], + "4973": [[18788,18793]], + "4986": [[19600,19694],[19972,20065],[20334,20428],[20698,20793]], + "4987": [[19971,20064],[20334,20427],[20698,20761]], + "4988": [[19970,20063],[20696,20759]], + "5048": [[19737,19810],[20102,20163],[20473,20534]], + "5049": [[19735,19809],[20100,20161],[20470,20531]], + "5050": [[19739,19813],[20103,20164],[20474,20535]], + "5051": [[19741,19814],[20106,20167],[20476,20537]], + "5052": [[19733,19807],[20097,20158],[20468,20529]], + "5053": [[19731,19805],[20094,20155],[20464,20525]], + "5054": [[19730,19804],[20093,20154],[20462,20523]], + "5056": [[19380,19382]], + "5214": [[19684,19690]], + "5215": [[19684,19690]], + "5216": [[19684,19690]], + "5217": [[19684,19690]], + "5218": [[19684,19690]], + "5243": [[19692,19734],[20058,20100],[20423,20465]], + "5244": [[19692,19734],[20058,20100],[20423,20465]], + "5245": [[19692,19734],[20058,20100],[20423,20465]], + "5246": [[19692,19694],[20058,20066]], + "5247": [[19692,19694],[20058,20066]], + "5248": [[19694,19696],[20449,20451]], + "5249": [[19694,19696],[20449,20451]], + "5250": [[19696,19698],[20425,20431]], + "5251": [[19696,19698],[20425,20431]], + "5252": [[19698,19702],[20062,20066],[20435,20437]], + "5253": [[19700,19702],[20423,20431]], + "5254": [[19700,19702],[20423,20431]], + "5255": [[19702,19704],[20060,20066],[20431,20433]], + "5256": [[19704,19706],[20433,20435]], + "5257": [[19704,19706],[20433,20435]], + "5258": [[19706,19708],[20437,20439]], + "5259": [[19706,19708],[20437,20439]], + "5260": [[19708,19710],[20427,20431]], + "5261": [[19708,19710],[20427,20431]], + "5262": [[19710,19712],[20441,20443]], + "5263": [[19710,19712],[20441,20443]], + "5264": [[19712,19714],[20443,20445]], + "5265": [[19712,19714],[20443,20445]], + "5266": [[19714,19716],[20080,20082]], + "5267": [[19716,19718],[20064,20066]], + "5268": [[19718,19720],[20084,20086]], + "5269": [[19720,19722],[20086,20088]], + "5272": [[19720,19722],[20086,20088]], + "5273": [[19718,19720],[20084,20086]], + "5274": [[19702,19704],[20060,20066],[20431,20433]], + "5275": [[19698,19702],[20062,20066],[20435,20437]], + "5276": [[19714,19716],[20080,20082]], + "5277": [[19716,19718],[20064,20066]], + "5291": [[19765,19767]], + "5428": [[20067,20200],[20428,20565]], + "5429": [[20067,20200],[20432,20565]], + "5430": [[20069,20200],[20435,20565]], + "5431": [[20069,20200],[20439,20565]], + "5432": [[20074,20200],[20442,20565]], + "5433": [[20074,20200],[20446,20565]], + "5434": [[20076,20200],[20449,20565]], + "5435": [[20076,20200],[20453,20565]], + "5437": [[20066,20068]], + "5438": [[20066,20068]], + "5439": [[20068,20070],[20439,20441]], + "5440": [[20082,20084]], + "5441": [[20082,20084]], + "5442": [[20070,20072]], + "5443": [[20070,20072]], + "5444": [[20072,20074]], + "5445": [[20072,20074]], + "5446": [[20078,20080]], + "5447": [[20078,20080]], + "5448": [[20076,20078]], + "5449": [[20076,20078]], + "5450": [[20074,20076]], + "5451": [[20074,20076]], + "5467": [[20115,20117]], + "5506": [[20193,20286],[20570,20663]], + "5507": [[20198,20291],[20572,20665]], + "5508": [[20200,20293],[20565,20658]], + "5538": [[20263,20357],[20627,20721]], + "5607": [[20702,20796]], + "5608": [[20714,20819]], + "5609": [[20702,20796]], + "5611": [[20707,20801]], + "5635": [[20713,20728]], + "5658": [[20401,20433]], + "5659": [[20403,20435]], + "5660": [[20408,20440]], + "5661": [[20410,20442]], + "5662": [[20398,20444]], + "5663": [[20398,20444]], + "5664": [[20398,20444]], + "5665": [[20398,20444]], + "5666": [[20398,20444]], + "5667": [[20398,20444]], + "5668": [[20398,20444]], + "5669": [[20398,20444]], + "5670": [[20400,20444]], + "5671": [[20402,20444]], + "5672": [[20404,20444]], + "5673": [[20410,20444]], + "5674": [[20411,20444]], + "5675": [[20417,20444]], + "5676": [[20418,20444]], + "5707": [[20429,20555]], + "5708": [[20431,20555]], + "5724": [[20429,20431]], + "5725": [[20429,20431]], + "5732": [[20445,20447]], + "5733": [[20445,20447]], + "5734": [[20447,20449]], + "5735": [[20447,20449]], + "5736": [[20451,20453]], + "5737": [[20451,20453]], + "5761": [[20500,20502]], + "5793": [[20532,20626]], + "5823": [[20598,20600]], + "5900": [[20727,20769]], + "5901": [[20729,20769]] + }, + "diamond": { + "1": [[18997,19056],[19725,19819],[20423,20545]], + "3": [[19516,19609],[20240,20337]], + "4": [[19116,19196],[19488,19560],[19844,19952],[20216,20316],[20579,20673]], + "5": [[19599,19686],[20321,20400]], + "6": [[17276,17675]], + "9": [[19205,19237],[19570,19602],[19936,19968],[20301,20333],[20666,20698]], + "10": [[19236,19267],[19601,19632],[19967,19998],[20332,20363],[20697,20728]], + "11": [[19160,19344]], + "12": [[18978,19162]], + "13": [[19013,19200]], + "14": [[19292,19357],[20027,20106]], + "15": [[18780,19266],[19537,19616],[20240,20337]], + "24": [[19153,19337]], + "26": [[19200,19329],[19571,19693],[19935,20029],[20306,20401],[20670,20738]], + "27": [[19200,19328],[19571,19692],[19935,20029],[20306,20401],[20670,20738]], + "28": [[19200,19327],[19571,19691],[19935,20029],[20306,20401],[20670,20738]], + "29": [[19200,19326],[19571,19690],[19935,20029],[20306,20401],[20670,20738]], + "30": [[19200,19325],[19571,19689],[19935,20029],[20306,20401],[20670,20738]], + "31": [[19614,19714],[20349,20449]], + "34": [[19200,19280],[19967,20036],[20666,20764]], + "36": [[19690,19734],[20058,20100]], + "37": [[18985,19004]], + "38": [[18962,19000],[19326,19364]], + "39": [[18962,19000],[19326,19364]], + "40": [[18962,19000],[19326,19364]], + "41": [[18962,19000],[19326,19364]], + "43": [[18962,19000],[19326,19364]], + "44": [[18962,19000],[19326,19364]], + "45": [[18962,19000],[19326,19364]], + "46": [[18962,19000],[19326,19364]], + "47": [[18962,19000],[19326,19364]], + "48": [[18691,18755],[20685,20764]], + "49": [[19053,19101],[19788,19840],[20153,20253],[20524,20568]], + "57": [[19083,19114],[19814,19845],[20179,20210],[20544,20575]], + "58": [[18962,18994],[19327,19359],[19692,19724],[20058,20090],[20423,20455]], + "69": [[19215,19280],[19579,19609],[19957,20043],[20314,20358],[20685,20771]], + "70": [[20160,20260]], + "71": [[19649,19735],[20332,20463]], + "79": [[19257,19272],[19622,19637],[19988,20003],[20334,20365],[20713,20736]], + "80": [[19201,19217],[19551,19602],[19929,19980],[20286,20351],[20650,20722]], + "81": [[19508,19623],[20258,20337]], + "83": [[19082,19126],[19810,19903],[20531,20631]], + "84": [[19140,19325],[19501,19689]], + "86": [[19116,19196],[19844,19938],[20574,20673]], + "87": [[19144,19182],[19516,19616],[19879,19924],[20251,20337],[20607,20652]], + "88": [[17660,18030]], + "89": [[17660,18029]], + "90": [[17660,18028]], + "91": [[17660,18027]], + "92": [[17660,18026]], + "97": [[19050,19078],[20120,20183],[20454,20519]], + "99": [[19642,19673],[19999,20039],[20362,20404]], + "101": [[19179,19259],[19905,20008],[20635,20743]], + "102": [[19206,19390]], + "104": [[19052,19084],[19783,19815],[20148,20180],[20513,20545]], + "105": [[20398,20434]], + "109": [[19270,19308],[19643,19673],[19997,20039],[20361,20404],[20726,20769]], + "110": [[20425,20465]], + "111": [[19131,19203],[19844,19966],[20594,20680]], + "113": [[20148,20246]], + "115": [[19474,19546],[20195,20274]], + "116": [[19144,19224],[19614,19700],[20342,20428]], + "117": [[19025,19063],[19753,19784],[20118,20159],[20488,20524]], + "118": [[19025,19063],[19753,19784],[20118,20159],[20488,20524]], + "119": [[19025,19063],[19753,19784],[20118,20159],[20488,20524]], + "120": [[19025,19063],[19753,19784],[20118,20159],[20488,20524]], + "121": [[19025,19063],[19753,19784],[20118,20159],[20488,20524]], + "123": [[19088,19119],[19452,19525],[19816,19847],[20188,20288],[20559,20591]], + "129": [[19116,19266],[19478,19689]], + "130": [[18318,18359],[20145,20180],[20516,20545]], + "131": [[18993,19175]], + "132": [[19116,19196],[19844,19945],[20579,20687]], + "133": [[19543,19644],[20270,20365]], + "134": [[18346,18811],[20167,20180],[20544,20626]], + "137": [[19144,19273],[19508,19555],[19879,19916],[20243,20317],[20607,20682]], + "138": [[19144,19272],[19508,19555],[19879,19916],[20243,20317],[20607,20682]], + "139": [[19144,19271],[19508,19555],[19879,19916],[20243,20317],[20607,20682]], + "140": [[19144,19270],[19508,19555],[19879,19916],[20243,20317],[20607,20682]], + "141": [[19144,19269],[19508,19555],[19879,19916],[20243,20317],[20607,20682]], + "144": [[19502,19567],[20230,20330]], + "145": [[19152,19189],[19523,19553],[19894,19938],[20629,20687]], + "146": [[19313,19364],[20041,20127]], + "147": [[19740,19826],[20089,20197],[20475,20554]], + "148": [[19586,19679],[20314,20407]], + "151": [[18965,19149]], + "152": [[19627,19673],[20362,20404]], + "153": [[19278,19343],[19635,19665],[20013,20092],[20370,20414]], + "154": [[19202,19385]], + "155": [[20089,20235],[20559,20600]], + "156": [[19705,19749]], + "157": [[19298,19338],[19662,19703],[20033,20069],[20397,20434]], + "159": [[18970,19004],[19348,19369],[19701,19734],[20067,20100],[20430,20465]], + "160": [[18973,19004],[19328,19369],[19695,19734],[20061,20100],[20423,20465]], + "161": [[19326,19364],[19690,19734],[20058,20100]], + "162": [[18979,19163]], + "163": [[18962,19000],[19326,19364]], + "164": [[18962,19000],[19326,19364]], + "166": [[17865,17908]], + "167": [[19104,19253],[19471,19680]], + "170": [[18984,19042],[19690,19798],[20454,20526]], + "171": [[19068,19133],[19788,19882],[20516,20610]], + "172": [[19725,19756],[20460,20491]], + "173": [[19161,19345]], + "176": [[19024,19053],[19754,19784],[20120,20149],[20485,20514]], + "177": [[19048,19212]], + "178": [[20089,20235],[20560,20600]], + "179": [[19014,19202]], + "180": [[20118,20149],[20496,20524]], + "181": [[17919,17958],[20120,20149],[20485,20514]], + "184": [[20089,20235],[20561,20600]], + "187": [[19105,19254],[19472,19681]], + "191": [[20089,20235],[20562,20600]], + "192": [[20145,20190]], + "195": [[18140,18909],[19460,19539],[20202,20302]], + "197": [[19154,19338]], + "200": [[19188,19372]], + "201": [[19607,19700],[20335,20428]], + "207": [[19166,19231],[19887,19994],[20615,20708]], + "208": [[20089,20235],[20552,20600]], + "214": [[19053,19147],[19788,19896],[20516,20626],[20516,20631]], + "217": [[20089,20235],[20553,20600]], + "218": [[19189,19373]], + "219": [[19068,19140],[19796,19889],[20145,20183],[20516,20617]], + "220": [[19480,19581],[19814,20043],[20208,20309]], + "222": [[19027,19230]], + "224": [[19452,19518],[20179,20274]], + "226": [[20089,20235],[20554,20600]], + "227": [[16974,16980]], + "228": [[16974,16980]], + "229": [[19452,19567],[20180,20281]], + "230": [[19133,19316],[19494,19680]], + "231": [[18906,18939],[19635,19665],[20335,20428]], + "232": [[19028,19231]], + "233": [[19075,19288]], + "234": [[19530,19588],[19907,19922],[20265,20344]], + "235": [[17004,20235],[20555,20600]], + "243": [[20183,20235],[20547,20600]], + "248": [[19543,19651],[20269,20393]], + "251": [[20184,20235],[20548,20600]], + "253": [[18717,18811],[19474,19532],[20179,20274]], + "254": [[19998,20039],[20726,20769]], + "257": [[20185,20235],[20549,20600]], + "258": [[19049,19213]], + "259": [[16801,17169]], + "260": [[19543,19644],[20300,20386]], + "261": [[20186,20235],[20550,20600]], + "262": [[19222,19294],[19967,20036],[20666,20764]], + "263": [[19250,19315],[19985,20085]], + "264": [[19076,19289]], + "270": [[17121,17127],[20623,20625]], + "271": [[17121,17127],[20614,20616]], + "273": [[19182,19366]], + "275": [[18962,19000],[19326,19364]], + "276": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "277": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "278": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "279": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "280": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "281": [[20187,20235],[20551,20600]], + "282": [[18965,19004],[20434,20465]], + "283": [[18966,19004],[19341,19369],[19698,19734],[20064,20100],[20425,20465]], + "285": [[19166,19210],[19905,19973],[20605,20701]], + "287": [[17149,17155]], + "289": [[17870,20162]], + "290": [[19103,19147],[19831,19910],[20573,20638]], + "291": [[19037,19053],[19767,19784],[20118,20149],[20489,20514]], + "292": [[17919,17958],[20090,20149],[20488,20514]], + "293": [[18997,19071],[19725,19804],[20089,20174],[20460,20539]], + "294": [[18997,19070],[19725,19805],[20089,20174],[20460,20539]], + "295": [[18997,19069],[19725,19806],[20089,20174],[20460,20539]], + "296": [[18997,19068],[19725,19807],[20089,20174],[20460,20539]], + "297": [[18997,19067],[19725,19808],[20089,20174],[20460,20539]], + "298": [[19649,19735],[20384,20463]], + "309": [[18289,18811],[19502,19567],[20209,20309]], + "310": [[19053,19094],[19788,19825],[20145,20190],[20516,20555]], + "311": [[19053,19094],[19788,19825],[20145,20190],[20516,20555]], + "312": [[19053,19094],[19788,19825],[20145,20190],[20516,20555]], + "313": [[19053,19094],[19788,19825],[20145,20190],[20516,20555]], + "314": [[19053,19094],[19788,19825],[20145,20190],[20516,20555]], + "315": [[19054,19084],[19782,19815],[20145,20180],[20516,20545]], + "317": [[19114,19186],[19482,19604],[19847,19941],[20226,20289],[20592,20655]], + "318": [[19134,19193],[19498,19607],[19861,19955],[20224,20287],[20588,20651]], + "319": [[19127,19189],[19490,19606],[19859,19953],[20217,20280],[20581,20644]], + "320": [[19107,19185],[19805,19899],[20170,20264],[20535,20629]], + "321": [[19126,19188],[19488,19605],[19854,19948],[20212,20275],[20577,20640]], + "322": [[19155,19258],[19833,19926],[20204,20267],[20568,20631]], + "323": [[19100,19184],[19802,19896],[20163,20257],[20528,20622]], + "324": [[19153,19258],[19840,19933],[20202,20265],[20566,20629]], + "325": [[19093,19183],[19800,19894],[20156,20250],[20521,20615]], + "326": [[19146,19258],[19826,19919],[20206,20269],[20570,20633]], + "327": [[19133,19191],[19496,19606],[19866,19960],[20219,20282],[20585,20648]], + "328": [[19116,19187],[19484,19605],[19852,19946],[20210,20273],[20575,20638]], + "329": [[19088,19207],[19452,19620],[19816,19909],[20180,20274],[20542,20637]], + "330": [[19088,19206],[19452,19619],[19816,19910],[20180,20274],[20542,20637]], + "331": [[19088,19205],[19452,19618],[19816,19911],[20180,20274],[20542,20637]], + "332": [[19088,19204],[19452,19617],[19816,19912],[20180,20274],[20542,20637]], + "333": [[19088,19203],[19452,19616],[19816,19913],[20180,20274],[20542,20637]], + "346": [[19922,20022],[20650,20748]], + "350": [[19629,19673],[19998,20039],[20370,20404],[20734,20769]], + "354": [[18993,19025],[19358,19390],[19723,19755],[20089,20121],[20454,20486]], + "355": [[19144,19175],[19509,19540],[19875,19906],[20240,20271],[20605,20636]], + "356": [[19174,19206],[19539,19571],[19905,19937],[20270,20302],[20635,20667]], + "357": [[19113,19145],[19478,19510],[19844,19876],[20209,20241],[20574,20606]], + "358": [[17277,20235],[20556,20600]], + "362": [[18185,18949],[19586,19679],[20332,20400]], + "365": [[17291,20235],[20563,20600]], + "367": [[20585,20587]], + "382": [[20058,20183]], + "383": [[17298,20235],[20557,20600]], + "386": [[20513,20515]], + "388": [[17310,17652]], + "389": [[17310,17650]], + "390": [[17310,17649]], + "391": [[17310,17651]], + "392": [[19169,19367],[19862,19956],[20235,20298],[20600,20663]], + "393": [[19204,19388],[19547,19639],[19911,20005],[20272,20366],[20635,20730]], + "394": [[19168,19367],[19860,19954],[20231,20294],[20595,20658]], + "395": [[19172,19367],[19867,19961],[20236,20299],[20601,20664]], + "398": [[17310,17654]], + "399": [[17310,17655]], + "400": [[17310,17656]], + "401": [[17310,17657]], + "402": [[17310,17658]], + "411": [[19119,19260],[19503,19612],[19882,19976],[20265,20328],[20632,20695]], + "418": [[20571,20573]], + "419": [[20416,20418]], + "422": [[20560,20562]], + "423": [[20422,20424]], + "438": [[19096,19175],[19816,19910],[20545,20638]], + "447": [[19200,19280],[19950,20057],[20678,20785]], + "463": [[20688,20690]], + "464": [[20643,20645]], + "465": [[20675,20677]], + "466": [[20654,20656]], + "467": [[20663,20665]], + "468": [[20732,20734]], + "469": [[20726,20728]], + "470": [[20717,20719]], + "476": [[19821,19836]], + "477": [[19821,19836]], + "478": [[19821,19836]], + "479": [[19821,19836]], + "480": [[19821,19836]], + "481": [[20132,20225]], + "482": [[19235,19348],[19599,19713],[19970,20079],[20334,20444],[20698,20809]], + "483": [[19235,19349],[19599,19713],[19969,20079],[20334,20444],[20698,20809]], + "484": [[19235,19350],[19599,19713],[19970,20079],[20334,20444],[20698,20809]], + "485": [[19235,19351],[19599,19713],[19970,20079],[20334,20444],[20698,20809]], + "486": [[19235,19352],[19599,19713],[19970,20079],[20334,20444],[20698,20809]], + "487": [[19571,19686],[20332,20400]], + "488": [[19670,19784],[20412,20505]], + "489": [[19274,19308],[19635,19673],[20001,20039],[20362,20404],[20726,20769]], + "490": [[19275,19308],[19636,19673],[20002,20039],[20362,20404],[20726,20769]], + "491": [[19276,19308],[19637,19673],[20003,20039],[20362,20404],[20726,20769]], + "492": [[19277,19308],[19638,19673],[20004,20039],[20362,20404],[20726,20769]], + "493": [[19278,19308],[19639,19673],[20005,20039],[20362,20404],[20726,20769]], + "494": [[19272,19308],[19632,19673],[19998,20039],[20362,20404],[20726,20769]], + "495": [[19273,19308],[19633,19673],[20000,20039],[20364,20404],[20728,20769]], + "496": [[19274,19308],[19634,19673],[20001,20039],[20365,20404],[20729,20769]], + "497": [[19275,19308],[19635,19673],[20002,20039],[20366,20404],[20730,20769]], + "498": [[19276,19308],[19636,19673],[20003,20039],[20367,20404],[20731,20769]], + "499": [[19277,19308],[19637,19673],[20004,20039],[20368,20404],[20732,20769]], + "500": [[19278,19308],[19638,19673],[20005,20039],[20369,20404],[20733,20769]], + "502": [[19270,19308],[19631,19673],[19997,20039],[20362,20404],[20727,20769]], + "534": [[18970,19028],[19326,19371],[19712,19791],[20058,20113],[20454,20533]], + "535": [[20486,20488]], + "536": [[20473,20475]], + "537": [[20494,20496]], + "538": [[20502,20504]], + "541": [[20388,20390]], + "542": [[20376,20378]], + "556": [[19088,19154],[19816,19917],[20542,20645]], + "557": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "558": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "559": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "560": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "561": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "562": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "563": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "564": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "565": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "566": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "567": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "568": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "569": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "570": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20426,20465]], + "571": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "572": [[18962,19004],[19326,19369],[19690,19734],[20058,20113],[20425,20465]], + "573": [[18962,19004],[19326,19369],[19690,19734],[20058,20113],[20425,20465]], + "574": [[18962,19004],[19326,19369],[19690,19734],[20058,20113],[20425,20465]], + "575": [[18962,19004],[19326,19369],[19690,19734],[20058,20113],[20425,20465]], + "576": [[18962,19004],[19326,19369],[19690,19734],[20058,20113],[20425,20465]], + "577": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "578": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "579": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "580": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "581": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "582": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "583": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "584": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "585": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "586": [[18962,19004],[19326,19369],[19690,19734],[20058,20100],[20425,20465]], + "594": [[19138,19203],[19844,19938],[20574,20673]], + "600": [[19027,19053],[19758,19784],[20119,20149],[20490,20514]], + "601": [[19029,19053],[19760,19784],[20120,20149],[20491,20514]], + "602": [[19031,19053],[19762,19784],[20121,20149],[20492,20514]], + "603": [[19033,19053],[19764,19784],[20122,20149],[20493,20514]], + "604": [[18970,19049],[19698,19812],[20440,20526]], + "610": [[19025,19101],[19753,19847],[20485,20582]], + "625": [[19508,19514]], + "626": [[19508,19514]], + "627": [[19508,19514]], + "628": [[19508,19514]], + "629": [[19508,19514]], + "635": [[19298,19385],[19684,19690],[20033,20120]], + "651": [[19298,19385],[19684,19690],[20055,20141]], + "659": [[17696,17701]], + "660": [[17696,17701]], + "661": [[17696,17701]], + "662": [[17696,17701]], + "663": [[17696,17701]], + "664": [[19243,19308],[19684,19690],[19967,20064]], + "667": [[19146,19330]], + "668": [[19147,19331]], + "669": [[17688,17694]], + "670": [[17688,17694]], + "671": [[17688,17694]], + "672": [[17688,17694]], + "673": [[17688,17694]], + "674": [[17688,17694]], + "675": [[19243,19308],[19684,19690],[19992,20085]], + "676": [[19167,19358]], + "677": [[19168,19359]], + "678": [[17702,17708]], + "679": [[17702,17708]], + "680": [[17702,17708]], + "681": [[17702,17708]], + "682": [[17702,17708]], + "683": [[17702,17708]], + "684": [[17702,17708]], + "685": [[17702,17708]], + "686": [[17702,17708]], + "687": [[17702,17708]], + "688": [[17702,17708]], + "689": [[17702,17708]], + "690": [[17702,17708]], + "691": [[17703,17708]], + "692": [[17703,17708]], + "693": [[17703,17708]], + "694": [[17703,17708]], + "695": [[17703,17705]], + "696": [[17704,17706]], + "697": [[17705,17707]], + "698": [[17706,17708]], + "704": [[19181,19365]], + "705": [[19187,19192]], + "706": [[19187,19192]], + "707": [[19187,19192]], + "708": [[19187,19192]], + "709": [[19187,19192]], + "710": [[19187,19192]], + "711": [[17716,17722]], + "712": [[17716,17722]], + "713": [[17716,17722]], + "714": [[17716,17722]], + "715": [[17716,17722]], + "716": [[17724,17729]], + "717": [[17724,17729]], + "718": [[17724,17729]], + "719": [[17724,17729]], + "720": [[17724,17729]], + "721": [[17724,17729]], + "722": [[17724,17729]], + "723": [[17724,17729]], + "724": [[17724,17729]], + "725": [[17724,17729]], + "726": [[17724,17729]], + "727": [[17710,17712]], + "728": [[17711,17713]], + "729": [[18663,18693]], + "730": [[17713,17715]], + "731": [[20104,20204]], + "732": [[19179,19252],[19905,20001],[20635,20729]], + "733": [[17710,17715]], + "734": [[17710,17715]], + "735": [[17710,17715]], + "736": [[17710,17715]], + "737": [[17710,17715]], + "738": [[17710,17715]], + "739": [[17710,17715]], + "740": [[17710,17715]], + "741": [[19195,19377]], + "742": [[19196,19378]], + "743": [[17730,17736]], + "744": [[17730,17736]], + "745": [[17730,17736]], + "746": [[17730,17736]], + "747": [[17730,17736]], + "748": [[17730,17736]], + "749": [[17730,17736]], + "750": [[17730,17736]], + "751": [[17730,17736]], + "752": [[17730,17736]], + "753": [[17730,17736]], + "754": [[17730,17736]], + "772": [[19179,19266],[19915,20022],[20635,20750]], + "773": [[17744,17750]], + "774": [[17744,17750]], + "775": [[17744,17750]], + "776": [[17744,17750]], + "777": [[17744,17750]], + "778": [[17744,17750]], + "779": [[17744,17750]], + "780": [[17744,17750]], + "781": [[17744,17750]], + "782": [[17744,17750]], + "783": [[17744,17750]], + "784": [[17744,17750]], + "785": [[17752,17757]], + "786": [[17752,17757]], + "787": [[17752,17757]], + "788": [[17752,17757]], + "789": [[17752,17757]], + "790": [[17752,17757]], + "791": [[17752,17757]], + "792": [[17752,17757]], + "793": [[17752,17757]], + "800": [[18858,19059]], + "801": [[18859,19060]], + "802": [[18860,19061]], + "803": [[17766,17771]], + "804": [[18863,19063]], + "805": [[18861,19062]], + "806": [[18864,19067]], + "807": [[18864,19065]], + "808": [[18864,19063]], + "809": [[18864,19061]], + "810": [[18864,19059]], + "811": [[17758,17764]], + "812": [[17758,17764]], + "813": [[17758,17764]], + "814": [[17758,17764]], + "815": [[17758,17764]], + "816": [[17758,17764]], + "817": [[17758,17764]], + "818": [[17758,17764]], + "819": [[17758,17764]], + "820": [[17758,17764]], + "821": [[17758,17764]], + "822": [[17758,17764]], + "823": [[17758,17764]], + "835": [[19235,19322],[19967,20064]], + "841": [[19270,19301],[19627,19673],[19967,20036],[20332,20400],[20666,20764]], + "842": [[19270,19329],[20013,20039],[20734,20769]], + "846": [[19296,19308],[19661,19673],[20027,20039],[20392,20404],[20756,20769]], + "847": [[19290,19308],[19653,19673],[20021,20039],[20377,20404],[20741,20769]], + "848": [[19291,19308],[19654,19673],[20022,20039],[20377,20404],[20741,20769]], + "849": [[19292,19308],[19655,19673],[20023,20039],[20377,20404],[20741,20769]], + "850": [[19293,19308],[19656,19673],[20024,20039],[20377,20404],[20741,20769]], + "851": [[19294,19308],[19657,19673],[20025,20039],[20377,20404],[20741,20769]], + "854": [[19270,19308],[19627,19673],[19998,20039],[20362,20404],[20726,20769]], + "855": [[19270,19308],[19627,19673],[19998,20039],[20362,20404],[20726,20769]], + "856": [[19270,19308],[19627,19673],[19998,20039],[20362,20404],[20726,20769]], + "857": [[19270,19308],[19627,19673],[19998,20039],[20362,20404],[20726,20769]], + "858": [[19270,19308],[19627,19673],[19998,20039],[20362,20404],[20726,20769]], + "860": [[19266,19308],[19631,19663],[19997,20029],[20362,20394],[20727,20759]], + "861": [[19297,19328],[19662,19693],[20028,20059],[20393,20424],[20758,20789]], + "867": [[19194,19199],[19825,19888],[20192,20224],[20556,20588]], + "868": [[19194,19199],[19826,19889],[20194,20226],[20558,20590]], + "869": [[19194,19199],[19827,19890],[20195,20227],[20559,20591]], + "870": [[19194,19199],[19833,19896],[20206,20238],[20571,20603]], + "871": [[19194,19199],[19829,19892],[20199,20231],[20563,20595]], + "872": [[19194,19199],[19824,19887],[20191,20223],[20555,20587]], + "873": [[19194,19199],[19830,19893],[20201,20233],[20565,20597]], + "874": [[19194,19199],[19832,19895],[20204,20236],[20569,20601]], + "875": [[19194,19199],[19823,19886],[20190,20222],[20554,20586]], + "876": [[19194,19199],[19831,19894],[20202,20234],[20567,20599]], + "877": [[19194,19199],[19828,19891],[20197,20229],[20561,20593]], + "878": [[19194,19199],[19822,19885],[20188,20220],[20552,20584]], + "879": [[20097,20192]], + "880": [[19593,19679],[20328,20407]], + "890": [[17856,17862]], + "891": [[17856,17862]], + "892": [[17856,17862]], + "893": [[17856,17862]], + "896": [[18964,19148]], + "914": [[19313,19371],[20033,20120]], + "915": [[18979,19004],[19334,19369],[19706,19734],[20072,20100],[20440,20465]], + "916": [[18986,19004],[19330,19369],[19692,19734],[20058,20100],[20421,20465]], + "917": [[19088,19161],[19816,19910],[20545,20638]], + "918": [[19179,19185]], + "919": [[19179,19185]], + "920": [[19179,19185]], + "921": [[19179,19185]], + "922": [[19179,19185]], + "923": [[19179,19185]], + "924": [[19179,19185]], + "925": [[19179,19185]], + "926": [[19179,19185]], + "927": [[19179,19185]], + "928": [[19179,19185]], + "929": [[19179,19185]], + "930": [[19088,19119],[19816,19847],[20542,20575]], + "931": [[18997,19056],[19740,19819],[20468,20568]], + "932": [[19025,19063],[19753,19784],[20496,20524]], + "933": [[19025,19063],[19753,19784],[20488,20524]], + "934": [[18999,19186]], + "935": [[19000,19188]], + "936": [[19025,19053],[19753,19794],[20118,20149],[20489,20514]], + "937": [[19027,19053],[19753,19794],[20119,20149],[20490,20514]], + "938": [[19028,19053],[19753,19794],[20120,20149],[20491,20514]], + "939": [[19029,19053],[19753,19794],[20128,20149],[20499,20514]], + "940": [[19030,19053],[19753,19794],[20122,20149],[20493,20514]], + "941": [[19031,19053],[19753,19794],[20124,20149],[20495,20514]], + "942": [[19032,19053],[19753,19794],[20121,20149],[20492,20514]], + "943": [[19033,19053],[19753,19794],[20123,20149],[20494,20514]], + "944": [[19034,19053],[19753,19794],[20125,20149],[20496,20514]], + "945": [[19035,19053],[19753,19794],[20126,20149],[20497,20514]], + "946": [[19036,19053],[19753,19794],[20127,20149],[20498,20514]], + "947": [[19320,19326],[19684,19690],[20055,20061],[20420,20426]], + "948": [[19025,19053],[19755,19784],[20129,20149],[20500,20514]], + "949": [[19025,19053],[19757,19784],[20131,20149],[20502,20514]], + "950": [[18667,18697],[19756,19784],[20130,20149],[20501,20514]], + "951": [[18668,18698],[19759,19784],[20132,20149],[20503,20514]], + "952": [[19029,19053],[19761,19784],[20133,20149],[20504,20514]], + "954": [[19278,19343],[20058,20092]], + "955": [[18318,18359],[20145,20180],[20518,20545]], + "956": [[18318,18359],[20148,20180],[20519,20545]], + "957": [[18318,18359],[20150,20180],[20520,20545]], + "958": [[18320,18357],[20152,20180],[20521,20545]], + "959": [[18320,18357],[20153,20180],[20522,20545]], + "960": [[18321,18360],[20155,20180],[20523,20545]], + "961": [[18321,18360],[20157,20180],[20524,20545]], + "962": [[18322,18360],[20159,20180],[20525,20545]], + "963": [[18323,18360],[20160,20180],[20526,20545]], + "964": [[18324,18360],[20162,20180],[20527,20545]], + "965": [[18325,18361],[20163,20180],[20528,20545]], + "966": [[18326,18360],[20164,20180],[20529,20545]], + "967": [[19056,19274]], + "968": [[19057,19275]], + "969": [[19083,19104],[19810,19843],[20174,20198],[20538,20563]], + "970": [[19084,19104],[19812,19845],[20176,20198],[20540,20563]], + "971": [[19085,19104],[19815,19847],[20178,20198],[20542,20563]], + "972": [[19086,19104],[19817,19849],[20180,20198],[20544,20563]], + "973": [[19087,19104],[19461,19482],[19818,19850],[20182,20198],[20546,20563]], + "974": [[19088,19104],[19463,19484],[19820,19852],[20184,20198],[20548,20563]], + "975": [[19089,19104],[19464,19485],[19821,19853],[20185,20198],[20549,20563]], + "976": [[19083,19104],[19811,19844],[20175,20198],[20539,20563]], + "977": [[19084,19104],[19813,19846],[20177,20198],[20541,20563]], + "978": [[19085,19104],[19816,19848],[20179,20198],[20543,20563]], + "979": [[19086,19104],[19460,19481],[19816,19849],[20180,20198],[20545,20563]], + "980": [[19087,19104],[19462,19483],[19819,19851],[20183,20198],[20547,20563]], + "981": [[18717,18743]], + "982": [[18717,18743]], + "983": [[18717,18743]], + "984": [[18717,18743]], + "985": [[18717,18743]], + "986": [[19090,19239],[19465,19671]], + "987": [[19091,19240],[19466,19672]], + "988": [[19159,19231],[19905,19973],[20605,20701]], + "990": [[19116,19245],[19480,19640],[19844,19938],[20208,20303],[20579,20668]], + "991": [[19116,19244],[19480,19639],[19844,19938],[20208,20303],[20579,20668]], + "992": [[19116,19243],[19480,19638],[19844,19938],[20208,20303],[20579,20668]], + "993": [[19116,19242],[19480,19637],[19844,19938],[20208,20303],[20579,20668]], + "994": [[19116,19241],[19480,19636],[19844,19938],[20208,20303],[20579,20668]], + "995": [[18404,18497]], + "996": [[18405,18496]], + "997": [[18406,18496]], + "998": [[18407,18495]], + "999": [[18408,18495]], + "1000": [[18410,18493]], + "1001": [[18411,18493]], + "1002": [[18412,18492]], + "1003": [[18413,18492]], + "1004": [[18414,18491]], + "1005": [[18415,18491]], + "1006": [[18416,18491]], + "1007": [[18808,18909],[19565,19658],[20270,20365]], + "1008": [[18701,18846],[19565,19658],[20269,20372]], + "1009": [[19120,19307],[19483,19671]], + "1010": [[19121,19308],[19482,19672]], + "1011": [[19134,19317],[19493,19681]], + "1012": [[19183,19370],[19549,19640],[19913,20007],[20274,20368],[20638,20732]], + "1013": [[19185,19370],[19550,19641],[19914,20008],[20276,20370],[20640,20734]], + "1014": [[19187,19371],[19551,19642],[19915,20009],[20278,20372],[20642,20736]], + "1015": [[19189,19371],[19552,19643],[19916,20010],[20286,20380],[20643,20737]], + "1016": [[19190,19374],[19553,19644],[19917,20011],[20288,20382],[20645,20739]], + "1017": [[19192,19376],[19554,19645],[19918,20012],[20290,20384],[20647,20741]], + "1018": [[19193,19380],[19555,19646],[19920,20014],[20292,20386],[20649,20743]], + "1019": [[19195,19380],[19556,19647],[19921,20015],[20293,20387],[20650,20744]], + "1020": [[19197,19382],[19557,19648],[19922,20016],[20295,20389],[20652,20746]], + "1021": [[19199,19382],[19558,19649],[19923,20017],[20297,20391],[20654,20748]], + "1022": [[19201,19384],[19559,19650],[19924,20018],[20299,20393],[20656,20750]], + "1023": [[19203,19386],[19560,19651],[19925,20019],[20301,20395],[20658,20752]], + "1025": [[18064,18066]], + "1027": [[19149,19279],[19888,19982],[20244,20307],[20609,20672]], + "1028": [[19151,19281],[19889,19983],[20246,20309],[20613,20676]], + "1029": [[19153,19283],[19890,19984],[20248,20311],[20618,20681]], + "1030": [[19155,19286],[19891,19985],[20250,20313],[20623,20686]], + "1031": [[19157,19291],[19892,19986],[20252,20315],[20627,20690]], + "1032": [[19159,19280],[19888,19982],[20245,20308],[20611,20674]], + "1033": [[19161,19282],[19889,19983],[20247,20310],[20616,20679]], + "1034": [[19163,19284],[19890,19984],[20249,20312],[20620,20683]], + "1035": [[19165,19287],[19891,19985],[20251,20314],[20625,20688]], + "1036": [[19167,19293],[19892,19986],[20253,20316],[20630,20693]], + "1037": [[19148,19503],[20210,20273],[20575,20638]], + "1038": [[19150,19504],[19846,19940],[20212,20275],[20577,20640]], + "1039": [[19152,19505],[19847,19941],[20214,20277],[20579,20642]], + "1040": [[19154,19506],[19848,19942],[20217,20280],[20581,20644]], + "1041": [[19156,19507],[19849,19943],[20219,20282],[20583,20646]], + "1042": [[19158,19508],[19850,19944],[20221,20284],[20585,20648]], + "1043": [[19160,19509],[19851,19945],[20224,20287],[20588,20651]], + "1044": [[19162,19510],[19852,19946],[20226,20289],[20590,20653]], + "1045": [[19164,19511],[19853,19947],[20228,20291],[20592,20655]], + "1046": [[19320,19326],[19684,19690],[20055,20061],[20420,20426]], + "1047": [[18073,18079]], + "1048": [[18073,18079]], + "1049": [[18073,18079]], + "1050": [[18073,18079]], + "1051": [[18073,18079]], + "1052": [[18073,18079]], + "1053": [[18081,18086]], + "1054": [[18081,18086]], + "1055": [[18081,18086]], + "1056": [[18081,18086]], + "1057": [[19320,19326],[19684,19690],[20055,20061],[20420,20426]], + "1058": [[19320,19326],[19684,19690],[20055,20061],[20420,20426]], + "1059": [[19320,19326],[19684,19690],[20055,20061],[20420,20426]], + "1060": [[19320,19326],[19684,19690],[20055,20061],[20420,20426]], + "1061": [[19320,19326],[19684,19690],[20055,20061],[20420,20426]], + "1062": [[18810,18874]], + "1063": [[18812,18845]], + "1064": [[18814,18847]], + "1065": [[18816,18849]], + "1066": [[18818,18851]], + "1067": [[18826,18859]], + "1068": [[18828,18861]], + "1069": [[18830,18863]], + "1070": [[18832,18865]], + "1071": [[18833,18866]], + "1072": [[18835,18868]], + "1073": [[18837,18870]], + "1074": [[18109,18114]], + "1075": [[18109,18114]], + "1076": [[18109,18114]], + "1077": [[18109,18114]], + "1078": [[18109,18114]], + "1079": [[18109,18114]], + "1080": [[18109,18114]], + "1081": [[18109,18114]], + "1082": [[18109,18114]], + "1083": [[18109,18114]], + "1084": [[18109,18114]], + "1085": [[18109,18114]], + "1086": [[18109,18114]], + "1087": [[18109,18114]], + "1088": [[18109,18114]], + "1089": [[18109,18114]], + "1090": [[18109,18114]], + "1091": [[18109,18114]], + "1092": [[18109,18114]], + "1093": [[18109,18114]], + "1094": [[18109,18114]], + "1095": [[18109,18114]], + "1096": [[18109,18114]], + "1097": [[18109,18114]], + "1098": [[18109,18114]], + "1099": [[18109,18114]], + "1100": [[18109,18114]], + "1101": [[18109,18114]], + "1102": [[18109,18114]], + "1103": [[18109,18114]], + "1104": [[18101,18107]], + "1105": [[18101,18107]], + "1106": [[18934,18965],[19677,19791],[20362,20491]], + "1107": [[19480,19581],[20209,20309]], + "1108": [[18115,18121],[19627,19637]], + "1109": [[18115,18121],[19627,19637]], + "1110": [[18115,18121],[19627,19637]], + "1111": [[18115,18121],[19627,19637]], + "1112": [[18115,18121],[19627,19637]], + "1113": [[18115,18121],[19627,19637]], + "1114": [[18115,18121],[19627,19637]], + "1115": [[18115,18121],[19627,19637]], + "1116": [[18115,18121],[19627,19637]], + "1117": [[18115,18121],[19627,19637]], + "1118": [[18860,18874]], + "1119": [[18860,18874]], + "1120": [[18860,18874]], + "1121": [[18860,18874]], + "1122": [[18860,18874]], + "1123": [[18880,19153]], + "1124": [[18881,19154]], + "1125": [[18882,19155]], + "1126": [[18884,19156]], + "1127": [[18885,19157]], + "1128": [[18886,19158]], + "1129": [[18887,19159]], + "1130": [[18888,19160]], + "1131": [[18889,19161]], + "1132": [[18890,19162]], + "1133": [[18880,19150]], + "1134": [[18880,19151]], + "1135": [[18881,19152]], + "1136": [[18882,19153]], + "1137": [[18883,19154]], + "1138": [[18884,19155]], + "1139": [[18885,19156]], + "1140": [[18886,19157]], + "1141": [[18887,19159]], + "1142": [[18888,19160]], + "1143": [[18129,18135]], + "1144": [[18129,18135]], + "1145": [[18129,18135]], + "1146": [[18129,18135]], + "1147": [[18129,18135]], + "1148": [[18129,18135]], + "1149": [[18129,18135]], + "1150": [[18129,18135]], + "1151": [[18137,18142]], + "1152": [[18137,18142]], + "1153": [[18137,18142]], + "1154": [[18137,18142]], + "1155": [[18137,18142]], + "1156": [[18137,18142]], + "1157": [[18137,18142]], + "1158": [[18137,18142]], + "1159": [[19200,19287],[19943,20057],[20678,20778]], + "1160": [[19662,19791],[20362,20491]], + "1171": [[18926,18943],[20747,20769]], + "1172": [[19279,19308],[19640,19673],[20006,20039],[20370,20404],[20734,20769]], + "1173": [[19284,19308],[19649,19673],[20010,20039],[20374,20404],[20738,20769]], + "1174": [[19286,19308],[19654,19673],[20012,20039],[20376,20404],[20740,20769]], + "1175": [[19282,19308],[19647,19673],[20009,20039],[20373,20404],[20737,20769]], + "1176": [[19281,19308],[19644,19673],[20008,20039],[20372,20404],[20736,20769]], + "1177": [[19292,19308],[19651,19673],[20011,20039],[20375,20404],[20739,20769]], + "1178": [[18185,18222]], + "1179": [[19280,19308],[19642,19673],[20007,20039],[20371,20404],[20735,20769]], + "1180": [[18557,18583]], + "1181": [[20076,20176]], + "1182": [[18550,18583]], + "1183": [[18550,18583]], + "1184": [[18550,18583]], + "1185": [[18550,18583]], + "1186": [[18550,18583]], + "1187": [[18550,18583]], + "1188": [[18550,18583]], + "1189": [[18550,18583]], + "1190": [[18550,18583]], + "1191": [[18550,18583]], + "1192": [[19144,19182],[19508,19546],[19867,19910],[20179,20274],[20545,20638]], + "1193": [[18936,19268]], + "1194": [[18937,19267]], + "1195": [[18938,19265]], + "1196": [[18939,19264]], + "1197": [[18940,19262]], + "1198": [[18942,19268]], + "1199": [[18943,19267]], + "1200": [[18944,19265]], + "1201": [[18945,19264]], + "1202": [[18946,19262]], + "1203": [[18938,19247]], + "1204": [[18940,19248]], + "1205": [[18942,19249]], + "1206": [[18947,19252]], + "1207": [[18944,19250]], + "1208": [[18945,19251]], + "1209": [[18948,19253]], + "1210": [[18949,19254]], + "1211": [[18950,19255]], + "1212": [[18951,19256]], + "1213": [[18952,19257]], + "1214": [[19235,19322],[19970,20071]], + "1216": [[18984,19028],[19719,19791],[20454,20519]], + "1217": [[18241,18273],[19746,19779],[20110,20171],[20486,20547]], + "1218": [[18241,18273],[19744,19777],[20108,20169],[20484,20545]], + "1219": [[18241,18273],[19742,19775],[20106,20167],[20482,20543]], + "1220": [[18241,18273],[19740,19773],[20104,20165],[20475,20536]], + "1221": [[18241,18273],[19738,19771],[20102,20163],[20473,20534]], + "1222": [[18241,18273],[19736,19769],[20100,20161],[20471,20532]], + "1223": [[18241,18273],[19734,19767],[20098,20159],[20469,20530]], + "1224": [[18241,18273],[19732,19765],[20096,20157],[20474,20535]], + "1225": [[18241,18273],[19730,19763],[20094,20155],[20472,20533]], + "1226": [[18241,18273],[19728,19761],[20092,20153],[20470,20531]], + "1227": [[18241,18273],[19725,19758],[20090,20151],[20468,20529]], + "1228": [[18241,18272],[19894,19899]], + "1229": [[18241,18272],[19894,19899]], + "1230": [[18241,18272],[19894,19899]], + "1231": [[18241,18272],[19894,19899]], + "1232": [[18241,18272],[19894,19899]], + "1233": [[18241,18272],[19894,19899]], + "1234": [[18241,18272],[19894,19899]], + "1235": [[18241,18272],[19894,19899]], + "1236": [[18241,18272],[19894,19899]], + "1237": [[18241,18272],[19894,19899]], + "1238": [[18879,18965],[19684,19770],[20405,20498]], + "1239": [[18600,18838]], + "1240": [[18601,18838]], + "1241": [[18602,18838]], + "1242": [[18603,18838]], + "1243": [[18604,18838]], + "1244": [[18605,18838]], + "1245": [[18606,18838]], + "1246": [[18607,18838]], + "1247": [[18608,18838]], + "1248": [[18609,18838]], + "1249": [[18610,18817],[20444,20491]], + "1250": [[18611,18816],[20444,20491]], + "1251": [[18612,18816],[20444,20491]], + "1252": [[18613,18646],[20444,20491]], + "1253": [[18614,18816],[20444,20491]], + "1254": [[18615,18815],[20444,20491]], + "1255": [[18616,18815],[20444,20491]], + "1256": [[18617,18815],[20444,20491]], + "1257": [[20444,20491]], + "1258": [[18619,18644],[20444,20491]], + "1259": [[18620,18644],[20444,20491]], + "1260": [[18621,18644],[20444,20491]], + "1261": [[19112,19489]], + "1262": [[19111,19487]], + "1263": [[19113,19485]], + "1264": [[19092,19488]], + "1265": [[19094,19490]], + "1266": [[19096,19491]], + "1267": [[19098,19492]], + "1268": [[19101,19493]], + "1269": [[19103,19494]], + "1270": [[19106,19495]], + "1271": [[19108,19496]], + "1272": [[19109,19497]], + "1273": [[19110,19498]], + "1274": [[19111,19499]], + "1275": [[19115,19501]], + "1276": [[19114,19500]], + "1277": [[19117,19502]], + "1359": [[18768,19118]], + "1360": [[18769,19116]], + "1361": [[18770,19114]], + "1362": [[18771,19112]], + "1363": [[18772,19110]], + "1364": [[18774,19108]], + "1365": [[18775,19103]], + "1366": [[18776,19101]], + "1367": [[18777,19099]], + "1368": [[18778,19097]], + "1369": [[18766,19095]], + "1370": [[18767,19093]], + "1371": [[18754,19105]], + "1372": [[18755,19109]], + "1373": [[18761,19111]], + "1374": [[18762,19113]], + "1375": [[18768,19115]], + "1376": [[18775,19117]], + "1378": [[18758,19119]], + "1405": [[18845,19050],[19510,19686]], + "1406": [[18846,19051],[19511,19687]], + "1407": [[18847,19052],[19518,19691]], + "1408": [[18848,19053],[19512,19688]], + "1409": [[18849,19054],[19514,19689]], + "1410": [[18850,19055],[19516,19690]], + "1411": [[18851,19056],[19520,19692]], + "1412": [[18845,19044],[19511,19675]], + "1413": [[18846,19045],[19512,19676]], + "1414": [[18847,19046],[19510,19674]], + "1415": [[18848,19047],[19514,19677]], + "1416": [[18849,19048],[19515,19678]], + "1417": [[18850,19049],[19520,19683]], + "1418": [[18851,19050],[19516,19679]], + "1419": [[18852,19051],[19521,19684]], + "1420": [[18853,19052],[19522,19685]], + "1421": [[18854,19053],[19519,19682]], + "1422": [[18855,19054],[19517,19680]], + "1423": [[18856,19055],[19518,19681]], + "1424": [[19230,19252],[19596,19617],[19961,19983],[20321,20348],[20685,20713]], + "1425": [[19231,19252],[19596,19617],[19963,19983],[20322,20348],[20686,20713]], + "1426": [[19232,19252],[19596,19617],[19965,19983],[20324,20348],[20688,20713]], + "1427": [[19233,19252],[19596,19617],[19966,19983],[20325,20348],[20689,20713]], + "1428": [[19234,19252],[19596,19617],[19967,19983],[20326,20348],[20690,20713]], + "1429": [[19235,19252],[19596,19617],[19968,19983],[20327,20348],[20691,20713]], + "1430": [[19231,19252],[19596,19617],[19962,19983],[20321,20348],[20685,20713]], + "1431": [[19227,19252],[19595,19617],[19957,19983],[20321,20348],[20685,20713]], + "1432": [[19228,19252],[19595,19617],[19958,19983],[20321,20348],[20685,20713]], + "1433": [[19229,19252],[19595,19617],[19959,19983],[20321,20348],[20685,20713]], + "1434": [[19229,19252],[19595,19617],[19960,19983],[20321,20348],[20685,20713]], + "1435": [[19232,19252],[19596,19617],[19964,19983],[20323,20348],[20687,20713]], + "1436": [[18466,18644]], + "1437": [[18466,18638]], + "1438": [[18466,18640]], + "1439": [[19230,19252],[19594,19617],[19957,19983],[20321,20348],[20685,20713]], + "1440": [[18491,18786]], + "1441": [[18491,18786]], + "1442": [[18491,18786]], + "1443": [[17897,18609]], + "1444": [[19244,19277],[19607,19642],[19979,20008],[20348,20373],[20713,20738]], + "1445": [[19237,19277],[19599,19642],[19972,20008],[20334,20373],[20706,20738]], + "1446": [[19241,19277],[19604,19642],[19976,20008],[20342,20373],[20710,20738]], + "1447": [[19238,19277],[19601,19642],[19973,20008],[20337,20373],[20707,20738]], + "1448": [[19243,19277],[19606,19642],[19978,20008],[20346,20373],[20712,20738]], + "1449": [[19246,19277],[19609,19642],[19981,20008],[20352,20373],[20715,20738]], + "1450": [[19239,19277],[19602,19642],[19974,20008],[20339,20373],[20708,20738]], + "1451": [[19242,19277],[19605,19642],[19977,20008],[20344,20373],[20711,20738]], + "1452": [[19240,19277],[19603,19642],[19975,20008],[20341,20373],[20709,20738]], + "1453": [[19245,19277],[19608,19642],[19980,20008],[20350,20373],[20714,20738]], + "1454": [[19247,19277],[19610,19642],[19982,20008],[20354,20373],[20716,20738]], + "1455": [[18387,18688]], + "1456": [[18387,18689]], + "1457": [[18387,18690]], + "1458": [[18387,18691]], + "1459": [[18387,18692]], + "1460": [[18519,18642]], + "1461": [[18519,18643]], + "1462": [[18519,18644]], + "1463": [[18519,18645]], + "1464": [[18519,18646]], + "1465": [[18519,18647]], + "1466": [[18519,18648]], + "1467": [[18519,18649]], + "1468": [[18519,18528]], + "1469": [[18519,18651]], + "1470": [[18519,18652]], + "1471": [[18519,18653]], + "1472": [[18598,18784]], + "1473": [[18598,18784]], + "1474": [[18598,18784]], + "1475": [[18598,18784]], + "1476": [[18598,18784]], + "1477": [[18598,18769]], + "1478": [[18598,18768]], + "1479": [[18598,18766]], + "1480": [[18598,18765]], + "1481": [[18598,18764]], + "1482": [[18598,18763]], + "1483": [[18598,18762]], + "1484": [[18598,18761]], + "1485": [[18598,18760]], + "1486": [[18598,18759]], + "1487": [[18598,18758]], + "1488": [[18598,18757]], + "1489": [[18635,18790]], + "1490": [[18638,18790]], + "1491": [[18633,18790]], + "1492": [[18636,18790]], + "1493": [[18637,18790]], + "1494": [[18639,18780]], + "1495": [[18640,18779]], + "1496": [[18641,18778]], + "1497": [[18642,18777]], + "1498": [[18643,18776]], + "1499": [[18644,18775]], + "1500": [[18645,18774]], + "1501": [[18646,18773]], + "1502": [[18647,18772]], + "1503": [[18648,18771]], + "1504": [[18649,18770]], + "1505": [[18650,18770]], + "1512": [[18675,18836]], + "1513": [[18676,18836]], + "1514": [[18677,18836]], + "1515": [[18678,18836]], + "1516": [[18674,18836]], + "1517": [[18679,18817]], + "1518": [[18680,18817]], + "1519": [[18682,18818]], + "1520": [[18683,18818]], + "1521": [[18684,18818]], + "1522": [[18685,18819]], + "1523": [[18686,18819]], + "1524": [[18688,18820]], + "1525": [[18689,18820]], + "1526": [[18690,18820]], + "1527": [[18687,18821]], + "1528": [[18681,18821]], + "1529": [[18689,18789]], + "1531": [[18691,18789]], + "1533": [[18692,18789]], + "1535": [[18693,18789]], + "1537": [[18694,18789]], + "1539": [[18695,18789]], + "1540": [[18696,18789]], + "1541": [[18697,18789]], + "1542": [[18698,18789]], + "1543": [[18699,18789]], + "1544": [[18700,18789]], + "1545": [[18701,18789]], + "1546": [[18702,18789]], + "1547": [[18703,18789]], + "1548": [[18704,18789]], + "1549": [[18705,18789]], + "1550": [[18706,18789]], + "1551": [[18717,18829]], + "1552": [[18719,18829]], + "1553": [[18725,18829]], + "1554": [[18727,18829]], + "1555": [[18732,18829]], + "1556": [[18721,18822]], + "1557": [[18722,18822]], + "1558": [[18723,18822]], + "1559": [[18728,18823]], + "1560": [[18729,18823]], + "1561": [[18730,18823]], + "1562": [[18731,18824]], + "1563": [[18732,18824]], + "1564": [[18733,18824]], + "1565": [[18724,18825],[20166,20180],[20530,20545]], + "1566": [[18746,18825]], + "1567": [[18718,18825]], + "1568": [[18754,18955]], + "1569": [[18755,18954]], + "1570": [[18756,18953]], + "1571": [[18757,18950]], + "1572": [[18758,18949]], + "1573": [[18759,18947]], + "1574": [[18760,18946]], + "1575": [[18761,18945]], + "1576": [[18762,18944]], + "1577": [[18763,18943]], + "1578": [[18764,18942]], + "1579": [[18765,18941]], + "1585": [[18782,18814]], + "1586": [[18783,18815]], + "1587": [[18784,18816]], + "1588": [[18786,18818]], + "1589": [[18787,18819]], + "1590": [[18788,18820]], + "1591": [[18789,18821]], + "1592": [[18790,18822]], + "1593": [[18791,18823]], + "1594": [[18793,18825]], + "1595": [[18794,18913]], + "1596": [[18795,18827]], + "1597": [[18796,18828]], + "1598": [[18797,18829]], + "1599": [[18798,18830]], + "1600": [[18800,18832]], + "1601": [[18801,18833]], + "1602": [[18774,18779]], + "1603": [[18774,18779]], + "1604": [[18774,18779]], + "1605": [[18774,18779]], + "1606": [[18774,18779]], + "1607": [[18774,18779]], + "1608": [[18774,18779]], + "1609": [[18774,18779]], + "1610": [[18774,18779]], + "1611": [[18774,18779]], + "1612": [[18774,18779]], + "1613": [[18774,18779]], + "1614": [[18774,18779]], + "1615": [[18774,18779]], + "1616": [[18774,18779]], + "1617": [[18774,18779]], + "1618": [[18774,18779]], + "1619": [[18774,18779]], + "1620": [[18774,18779]], + "1621": [[18774,18779]], + "1622": [[18774,18779]], + "1623": [[18774,18779]], + "1624": [[18774,18779]], + "1625": [[18774,18779]], + "1626": [[18774,18779]], + "1627": [[18774,18779]], + "1628": [[18774,18779]], + "1629": [[18774,18779]], + "1630": [[18774,18779]], + "1631": [[18774,18779]], + "1632": [[18808,18841]], + "1633": [[18811,18844]], + "1634": [[18814,18847]], + "1635": [[18816,18849]], + "1636": [[18818,18851]], + "1637": [[18819,18852]], + "1638": [[18821,18854]], + "1639": [[18820,18853]], + "1640": [[18829,18862]], + "1641": [[18831,18864]], + "1642": [[18836,18869]], + "1643": [[18815,18848]], + "1644": [[18822,18855]], + "1645": [[18824,18857]], + "1646": [[18817,18850]], + "1647": [[18827,18860]], + "1648": [[18834,18867]], + "1649": [[18802,18807]], + "1650": [[18802,18807]], + "1651": [[18802,18807]], + "1652": [[18802,18807]], + "1653": [[18802,18807]], + "1664": [[18809,18814],[19523,19528]], + "1665": [[18823,18828]], + "1666": [[18823,18828]], + "1667": [[18823,18828]], + "1668": [[18823,18828]], + "1669": [[18823,18828]], + "1670": [[18823,18828]], + "1671": [[18823,18828]], + "1672": [[18809,18814]], + "1695": [[18873,18919]], + "1696": [[18873,18919]], + "1697": [[18873,18919]], + "1698": [[18873,18919]], + "1699": [[18875,18919]], + "1700": [[18887,18919]], + "1701": [[18887,18919]], + "1702": [[18887,18919]], + "1703": [[18887,18919]], + "1704": [[18882,18919]], + "1705": [[18894,18919]], + "1706": [[18871,18919]], + "1707": [[18871,18919]], + "1708": [[18871,18919]], + "1709": [[18871,18919]], + "1710": [[18871,18919]], + "1711": [[18881,18919]], + "1712": [[18879,18919]], + "1713": [[18889,18919]], + "1714": [[18895,18919]], + "1715": [[18874,18919]], + "1716": [[18880,18919]], + "1717": [[18885,18919]], + "1718": [[18905,18919]], + "1719": [[18872,18919]], + "1720": [[18878,18919]], + "1721": [[18872,18919]], + "1732": [[18906,18916]], + "1733": [[18906,18916]], + "1734": [[18906,18916]], + "1735": [[18906,18916]], + "1736": [[18906,18916]], + "1737": [[18906,18916]], + "1738": [[18906,18916]], + "1739": [[18914,18923]], + "1740": [[18914,18923]], + "1741": [[18914,18923]], + "1742": [[18914,18923]], + "1743": [[18914,18923]], + "1744": [[18914,18923]], + "1745": [[18914,18923]], + "1746": [[18914,18923]], + "1747": [[18921,18930]], + "1748": [[18921,18930]], + "1749": [[18921,18930]], + "1750": [[18921,18930]], + "1751": [[18921,18930]], + "1752": [[18921,18930]], + "1753": [[18921,18930]], + "1754": [[18921,18930]], + "1755": [[18928,18937]], + "1756": [[18928,18937]], + "1757": [[18928,18937]], + "1758": [[18928,18937]], + "1759": [[18928,18937]], + "1760": [[18928,18937]], + "1761": [[18928,18937]], + "1762": [[18928,18937]], + "1763": [[18928,18937]], + "1784": [[18962,18972]], + "1785": [[18962,18972]], + "1786": [[18962,18972]], + "1787": [[18962,18972]], + "1788": [[18962,18972]], + "1789": [[18962,18972]], + "1790": [[18962,18972]], + "1791": [[18962,18972]], + "1792": [[18962,18972]], + "1793": [[18970,18979]], + "1794": [[18970,18979]], + "1795": [[18970,18979]], + "1796": [[18970,18979]], + "1797": [[18970,18979]], + "1798": [[18970,18979]], + "1799": [[18970,18979]], + "1800": [[18970,18979]], + "1801": [[18970,18979]], + "1802": [[18977,18986]], + "1803": [[18977,18986]], + "1804": [[18977,18986]], + "1805": [[18977,18986]], + "1806": [[18977,18986]], + "1807": [[18977,18986]], + "1808": [[18977,18986]], + "1809": [[18977,18986]], + "1810": [[18984,18993]], + "1811": [[18984,18993]], + "1812": [[18984,18993]], + "1813": [[18984,18993]], + "1814": [[18984,18993]], + "1815": [[18984,18993]], + "1816": [[18984,18993]], + "1817": [[18984,18993]], + "1818": [[18984,18993]], + "1869": [[19131,19136]], + "1870": [[19131,19136]], + "1871": [[19131,19136]], + "1872": [[19131,19136]], + "1873": [[19131,19136]], + "1874": [[19131,19136]], + "1875": [[19131,19136]], + "1876": [[19131,19136]], + "1877": [[19131,19136]], + "1878": [[19131,19136]], + "1879": [[19131,19136]], + "1880": [[19131,19136]], + "1881": [[19131,19136]], + "1882": [[19131,19136]], + "1883": [[19131,19136]], + "1884": [[19138,19143]], + "1885": [[19138,19143]], + "1886": [[19138,19143]], + "1887": [[19138,19143]], + "1888": [[19138,19143]], + "1889": [[19138,19143]], + "1890": [[19138,19143]], + "1891": [[19138,19143]], + "1892": [[19138,19143]], + "1893": [[19138,19143]], + "1894": [[19138,19143]], + "1895": [[19138,19143]], + "1896": [[19138,19143]], + "1897": [[19138,19143]], + "1898": [[19138,19143]], + "1909": [[19144,19150]], + "1910": [[19144,19150]], + "1911": [[19144,19150]], + "1912": [[19144,19150]], + "1913": [[19144,19150]], + "1914": [[19144,19150]], + "1915": [[19144,19150]], + "1916": [[19144,19150]], + "1917": [[19144,19150]], + "1918": [[19144,19150]], + "1919": [[19144,19150]], + "1920": [[19144,19150]], + "1921": [[19144,19150]], + "1922": [[19144,19150]], + "1923": [[19144,19150]], + "1924": [[19152,19157]], + "1925": [[19152,19157]], + "1926": [[19152,19157]], + "1927": [[19152,19157]], + "1928": [[19152,19157]], + "1929": [[19152,19157]], + "1930": [[19152,19157]], + "1931": [[19152,19157]], + "1932": [[19152,19157]], + "1933": [[19152,19157]], + "1934": [[19152,19157]], + "1935": [[19152,19157]], + "1936": [[19152,19157]], + "1937": [[19152,19157]], + "1938": [[19152,19157]], + "1939": [[19159,19164]], + "1940": [[19159,19164]], + "1941": [[19159,19164]], + "1942": [[19159,19164]], + "1943": [[19159,19164]], + "1944": [[19159,19164]], + "1945": [[19159,19164]], + "1946": [[19159,19164]], + "1947": [[19159,19164]], + "1948": [[19159,19164]], + "1949": [[19159,19164]], + "1950": [[19159,19164]], + "1951": [[19159,19164]], + "1952": [[19159,19164]], + "1953": [[19159,19164]], + "1954": [[19166,19171]], + "1955": [[19166,19171]], + "1956": [[19166,19171]], + "1957": [[19166,19171]], + "1958": [[19166,19171]], + "1959": [[19166,19171]], + "1960": [[19166,19171]], + "1961": [[19166,19171]], + "1962": [[19166,19171]], + "1963": [[19166,19171]], + "1964": [[19166,19171]], + "1965": [[19166,19171]], + "1966": [[19166,19171]], + "1967": [[19166,19171]], + "1968": [[19166,19171]], + "1969": [[19173,19178]], + "1970": [[19173,19178]], + "1971": [[19173,19178]], + "1972": [[19173,19178]], + "1973": [[19173,19178]], + "1974": [[19173,19178]], + "1975": [[19173,19178]], + "1976": [[19173,19178]], + "1977": [[19173,19178]], + "1978": [[19173,19178]], + "1979": [[19173,19178]], + "1980": [[19173,19178]], + "1981": [[19173,19178]], + "1982": [[19173,19178]], + "1983": [[19173,19178]], + "1994": [[19179,19185]], + "1995": [[19179,19185]], + "1996": [[19179,19185]], + "1997": [[19179,19185]], + "1998": [[19179,19185]], + "1999": [[19179,19185]], + "2000": [[19179,19185]], + "2001": [[19179,19185]], + "2002": [[19179,19185]], + "2003": [[19179,19185]], + "2004": [[19179,19185]], + "2005": [[19179,19185]], + "2006": [[19179,19185]], + "2007": [[19179,19185]], + "2008": [[19179,19185]], + "2009": [[19187,19192]], + "2010": [[19187,19192]], + "2011": [[19187,19192]], + "2012": [[19187,19192]], + "2013": [[19187,19192]], + "2014": [[19187,19192]], + "2015": [[19187,19192]], + "2016": [[19187,19192]], + "2017": [[19187,19192]], + "2018": [[19187,19192]], + "2019": [[19187,19192]], + "2020": [[19187,19192]], + "2021": [[19187,19192]], + "2022": [[19187,19192]], + "2023": [[19187,19192]], + "2024": [[19194,19199]], + "2025": [[19194,19199]], + "2026": [[19194,19199]], + "2027": [[19194,19199]], + "2028": [[19194,19199]], + "2029": [[19194,19199]], + "2030": [[19194,19199]], + "2031": [[19194,19199]], + "2032": [[19194,19199]], + "2033": [[19194,19199]], + "2034": [[19194,19199]], + "2035": [[19194,19199]], + "2036": [[19194,19199]], + "2037": [[19194,19199]], + "2038": [[19194,19199]], + "2039": [[19201,19206]], + "2040": [[19201,19206]], + "2041": [[19201,19206]], + "2042": [[19201,19206]], + "2043": [[19201,19206]], + "2044": [[19201,19206]], + "2045": [[19201,19206]], + "2046": [[19201,19206]], + "2047": [[19201,19206]], + "2048": [[19201,19206]], + "2049": [[19201,19206]], + "2050": [[19201,19206]], + "2051": [[19201,19206]], + "2052": [[19201,19206]], + "2053": [[19201,19206]], + "2064": [[19208,19213]], + "2065": [[19208,19213]], + "2066": [[19208,19213]], + "2067": [[19208,19213]], + "2068": [[19208,19213]], + "2069": [[19208,19213]], + "2070": [[19208,19213]], + "2071": [[19208,19213]], + "2072": [[19208,19213]], + "2073": [[19208,19213]], + "2074": [[19208,19213]], + "2075": [[19208,19213]], + "2076": [[19208,19213]], + "2077": [[19208,19213]], + "2078": [[19208,19213]], + "2099": [[19270,19280]], + "2100": [[19270,19280]], + "2101": [[19270,19280]], + "2102": [[19270,19280]], + "2103": [[19270,19280]], + "2104": [[19270,19280]], + "2105": [[19270,19280]], + "2106": [[19270,19280]], + "2107": [[19278,19287]], + "2108": [[19278,19287]], + "2109": [[19278,19287]], + "2110": [[19278,19287]], + "2111": [[19278,19287]], + "2112": [[19278,19287]], + "2113": [[19278,19287]], + "2114": [[19278,19287]], + "2115": [[19278,19287]], + "2116": [[19285,19294]], + "2117": [[19285,19294]], + "2118": [[19285,19294]], + "2119": [[19285,19294]], + "2120": [[19285,19294]], + "2121": [[19285,19294]], + "2122": [[19285,19294]], + "2123": [[19285,19294]], + "2124": [[19285,19294]], + "2125": [[19292,19301]], + "2126": [[19292,19301]], + "2127": [[19292,19301]], + "2128": [[19292,19301]], + "2129": [[19292,19301],[19649,19658]], + "2130": [[19292,19301],[19649,19658]], + "2131": [[19292,19301],[19649,19658]], + "2132": [[19292,19301],[19649,19658]], + "2133": [[19292,19301],[19649,19658]], + "2134": [[19292,19301],[19649,19658]], + "2145": [[19326,19369],[20058,20100],[20425,20465]], + "2156": [[19326,19369],[19684,19690],[20420,20426]], + "2157": [[19326,19369],[19695,19734],[20061,20100],[20424,20465]], + "2158": [[19326,19369],[19697,19734],[20063,20100],[20426,20465]], + "2159": [[19326,19369],[19697,19734],[20063,20100],[20426,20465]], + "2160": [[19326,19369],[19693,19734],[20059,20100],[20423,20465]], + "2161": [[19348,19369],[19715,19734],[20081,20100],[20441,20465]], + "2162": [[19348,19369],[19715,19734],[20081,20100],[20442,20465]], + "2163": [[19334,19369],[19696,19734],[20062,20100],[20425,20465]], + "2164": [[19334,19369],[19698,19734],[20064,20100],[20426,20465]], + "2165": [[19334,19369],[19699,19734],[20065,20100],[20426,20465]], + "2166": [[19334,19369],[19700,19734],[20066,20100],[20426,20465]], + "2167": [[19334,19369],[19701,19734],[20067,20100],[20426,20465]], + "2168": [[19326,19369],[19705,19734],[20071,20100],[20430,20465]], + "2169": [[19348,19369],[19713,19734],[20079,20100],[20438,20465]], + "2170": [[19348,19369],[19714,19734],[20080,20100],[20439,20465]], + "2171": [[19348,19369],[19714,19734],[20080,20100],[20440,20465]], + "2172": [[19326,19369],[19696,19734],[20062,20100],[20425,20465]], + "2173": [[19326,19369],[19701,19734],[20067,20100],[20426,20465]], + "2174": [[19326,19369],[19694,19734],[20060,20100],[20424,20465]], + "2175": [[19326,19369],[19694,19734],[20060,20100],[20424,20465]], + "2176": [[19326,19369],[19693,19734],[20059,20100],[20423,20465]], + "2177": [[19334,19369],[19702,19734],[20068,20100],[20426,20465]], + "2178": [[19326,19369],[19695,19734],[20061,20100],[20425,20465]], + "2179": [[19334,19369],[19703,19734],[20069,20100],[20427,20465]], + "2180": [[19348,19369],[19711,19734],[20077,20100],[20436,20465]], + "2181": [[19341,19369],[19704,19734],[20070,20100],[20428,20465]], + "2182": [[19341,19369],[19705,19734],[20071,20100],[20429,20465]], + "2183": [[19341,19369],[19706,19734],[20431,20465]], + "2184": [[19341,19369],[19707,19734],[20073,20100],[20432,20465]], + "2185": [[19341,19369],[19708,19734],[20074,20100],[20433,20465]], + "2186": [[19341,19369],[19709,19734],[20075,20100],[20434,20465]], + "2187": [[19341,19369],[19710,19734],[20076,20100],[20435,20465]], + "2188": [[19348,19369],[19712,19734],[20078,20100],[20437,20465]], + "2209": [[19753,19794],[20126,20159],[20497,20524]], + "2210": [[19755,19794],[20123,20154],[20494,20519]], + "2211": [[19756,19794],[20129,20159],[20500,20524]], + "2212": [[19757,19794],[20124,20154],[20495,20519]], + "2213": [[19758,19794],[20143,20169],[20514,20534]], + "2214": [[19759,19794],[20144,20169],[20515,20534]], + "2215": [[19760,19794],[20122,20154],[20507,20529]], + "2216": [[19761,19794],[20125,20159],[20496,20524]], + "2217": [[19762,19794],[20127,20159],[20498,20524]], + "2218": [[19763,19794],[20128,20159],[20499,20524]], + "2219": [[19764,19794],[20130,20159],[20501,20524]], + "2220": [[19765,19794],[20131,20159],[20502,20524]], + "2221": [[19766,19794],[20145,20169],[20516,20534]], + "2222": [[19768,19794],[20132,20164],[20503,20529]], + "2223": [[19769,19794],[20133,20164],[20504,20529]], + "2224": [[19770,19794],[20134,20164],[20505,20529]], + "2225": [[19771,19794],[20135,20164],[20506,20529]], + "2226": [[19772,19794],[20136,20164]], + "2227": [[19773,19794],[20137,20164],[20508,20529]], + "2228": [[19774,19794],[20138,20164],[20509,20529]], + "2229": [[19775,19794],[20139,20169],[20510,20534]], + "2230": [[19776,19794],[20140,20169],[20511,20534]], + "2231": [[19777,19794],[20141,20169],[20512,20534]], + "2232": [[19778,19794],[20142,20169],[20513,20534]], + "2263": [[19495,19500]], + "2264": [[19495,19500]], + "2265": [[19495,19500]], + "2266": [[19495,19500]], + "2267": [[19495,19500]], + "2268": [[19495,19500]], + "2269": [[19495,19500]], + "2270": [[19495,19500]], + "2271": [[19495,19500]], + "2272": [[19495,19500]], + "2273": [[19495,19500]], + "2274": [[19495,19500]], + "2275": [[19502,19507]], + "2276": [[19502,19507]], + "2277": [[19502,19507]], + "2278": [[19502,19507]], + "2279": [[19502,19507]], + "2280": [[19502,19507]], + "2281": [[19502,19507]], + "2282": [[19502,19507]], + "2283": [[19502,19507]], + "2284": [[19530,19637],[19879,20064],[20243,20450],[20607,20708]], + "2295": [[19508,19514]], + "2296": [[19508,19514]], + "2297": [[19508,19514]], + "2298": [[19508,19514]], + "2299": [[19508,19514]], + "2300": [[19508,19514]], + "2301": [[19508,19514]], + "2302": [[19508,19514]], + "2303": [[19508,19514]], + "2304": [[19508,19514]], + "2305": [[19508,19514]], + "2306": [[19508,19514]], + "2307": [[19508,19514]], + "2308": [[19516,19521]], + "2309": [[19516,19521]], + "2310": [[19516,19521]], + "2311": [[19516,19521]], + "2312": [[19516,19521]], + "2313": [[19516,19521]], + "2314": [[19516,19521]], + "2315": [[19516,19521]], + "2316": [[19516,19521]], + "2317": [[19516,19521]], + "2318": [[19523,19528]], + "2319": [[19523,19528]], + "2320": [[19523,19528]], + "2321": [[19523,19528]], + "2322": [[19523,19528]], + "2323": [[19523,19528]], + "2324": [[19523,19528]], + "2325": [[19523,19528]], + "2326": [[19523,19528]], + "2327": [[19523,19528]], + "2328": [[19523,19528]], + "2329": [[19530,19631],[19882,19976],[20244,20338],[20607,20702]], + "2330": [[19530,19632],[19883,19977],[20245,20339],[20610,20704]], + "2331": [[19530,19633],[19886,19980],[20246,20340],[20612,20706]], + "2332": [[19530,19634],[19887,19981],[20247,20341],[20614,20708]], + "2333": [[19530,19635],[19888,19982],[20248,20342],[20615,20709]], + "2334": [[19530,19636],[19889,19983],[20249,20343],[20617,20711]], + "2335": [[19530,19637],[19890,19984],[20250,20344],[20619,20713]], + "2336": [[19530,19638],[19892,19986],[20251,20345],[20621,20715]], + "2337": [[19530,19535]], + "2338": [[19530,19535]], + "2339": [[19530,19535]], + "2340": [[19537,19542]], + "2341": [[19537,19542]], + "2342": [[19537,19542]], + "2343": [[19537,19542]], + "2344": [[19537,19542]], + "2345": [[19537,19542]], + "2346": [[19537,19542]], + "2347": [[19537,19542]], + "2348": [[19537,19542]], + "2349": [[19537,19542]], + "2350": [[19537,19542]], + "2351": [[19537,19542]], + "2362": [[19543,19549]], + "2363": [[19543,19549]], + "2364": [[19543,19549]], + "2365": [[19543,19549]], + "2366": [[19543,19549]], + "2367": [[19543,19549]], + "2368": [[19543,19549]], + "2369": [[19543,19549]], + "2370": [[19543,19549]], + "2371": [[19543,19549]], + "2372": [[19551,19556]], + "2373": [[19551,19556]], + "2374": [[19551,19556]], + "2375": [[19551,19556]], + "2376": [[19551,19556]], + "2377": [[19551,19556]], + "2378": [[19551,19556]], + "2379": [[19551,19556]], + "2380": [[19551,19556]], + "2381": [[19551,19556]], + "2382": [[19551,19556]], + "2383": [[19551,19556]], + "2384": [[19558,19563]], + "2385": [[19558,19563]], + "2386": [[19558,19563]], + "2387": [[19558,19563]], + "2388": [[19558,19563]], + "2389": [[19558,19563]], + "2390": [[19558,19563]], + "2391": [[19558,19563]], + "2392": [[19558,19563]], + "2393": [[19558,19563]], + "2394": [[19558,19563]], + "2395": [[19558,19563]], + "2396": [[19565,19570]], + "2397": [[19565,19570]], + "2398": [[19565,19570]], + "2399": [[19565,19570]], + "2400": [[19565,19570]], + "2401": [[19565,19570]], + "2402": [[19565,19570]], + "2403": [[19565,19570]], + "2404": [[19565,19570]], + "2405": [[19565,19570]], + "2406": [[19565,19570]], + "2407": [[19565,19570]], + "2408": [[19551,19556]], + "2409": [[19551,19556]], + "2410": [[19551,19556]], + "2428": [[19571,19577],[19935,19941]], + "2429": [[19571,19577],[19935,19941]], + "2430": [[19571,19577],[19935,19941]], + "2431": [[19571,19577],[19935,19941]], + "2432": [[19571,19577],[19935,19941]], + "2433": [[19571,19577],[19935,19941]], + "2434": [[19571,19577],[19935,19941]], + "2435": [[19571,19577],[19935,19941]], + "2436": [[19571,19577],[19935,19941]], + "2447": [[20027,20036]], + "2448": [[20027,20036]], + "2449": [[20027,20036]], + "2450": [[20027,20036]], + "2451": [[20027,20036]], + "2452": [[20027,20036]], + "2453": [[20027,20036]], + "2454": [[20027,20036]], + "2455": [[20027,20036]], + "2456": [[20027,20036]], + "2457": [[19627,19637]], + "2458": [[19627,19637]], + "2459": [[19627,19637]], + "2460": [[19627,19637]], + "2461": [[19627,19637]], + "2462": [[19627,19637]], + "2463": [[19627,19637]], + "2464": [[19627,19637]], + "2465": [[19627,19637]], + "2466": [[19627,19637]], + "2467": [[19627,19637]], + "2468": [[19635,19644]], + "2469": [[19635,19644]], + "2470": [[19635,19644]], + "2471": [[19635,19644]], + "2472": [[19635,19644]], + "2473": [[19635,19644]], + "2474": [[19635,19644]], + "2475": [[19635,19644]], + "2476": [[19642,19651]], + "2477": [[19642,19651]], + "2478": [[19642,19651]], + "2479": [[19642,19651]], + "2480": [[19642,19651]], + "2481": [[19635,19644]], + "2482": [[19635,19644]], + "2483": [[19635,19644]], + "2484": [[19635,19644]], + "2485": [[19635,19644]], + "2486": [[19635,19644]], + "2487": [[19642,19651]], + "2488": [[19642,19651]], + "2489": [[19642,19651]], + "2490": [[19642,19651]], + "2491": [[19642,19651]], + "2492": [[19642,19651]], + "2493": [[19642,19651]], + "2494": [[19642,19651]], + "2495": [[19649,19658]], + "2496": [[19649,19658]], + "2497": [[19656,19665]], + "2498": [[19656,19665]], + "2499": [[19656,19665]], + "2500": [[19656,19665]], + "2501": [[19656,19665]], + "2502": [[19649,19658]], + "2503": [[19649,19658]], + "2504": [[19649,19658]], + "2505": [[19649,19658]], + "2506": [[19649,19658]], + "2507": [[19649,19658]], + "2508": [[19656,19665]], + "2509": [[19656,19665]], + "2510": [[19656,19665]], + "2511": [[19656,19665]], + "2512": [[19656,19665]], + "2513": [[19656,19665]], + "2514": [[19656,19665]], + "2515": [[19656,19665]], + "2516": [[19660,19662]], + "2527": [[19692,19785]], + "2544": [[19692,19734],[20058,20100],[20423,20465]], + "2545": [[19693,19734],[20059,20100],[20423,20465]], + "2588": [[19725,19805],[20111,20286]], + "2599": [[19765,19767]], + "2610": [[19970,20079],[20349,20444],[20717,20809]], + "2621": [[19859,20071],[20223,20435]], + "2632": [[19859,19864]], + "2633": [[19859,19864]], + "2634": [[19859,19864]], + "2635": [[19859,19864]], + "2636": [[19859,19864]], + "2637": [[19859,19864]], + "2638": [[19859,19864]], + "2639": [[19859,19864]], + "2640": [[19859,19864]], + "2641": [[19859,19864]], + "2642": [[19866,19871]], + "2643": [[19866,19871]], + "2644": [[19866,19871]], + "2645": [[19866,19871]], + "2646": [[19866,19871]], + "2647": [[19866,19871]], + "2648": [[19866,19871]], + "2649": [[19866,19871]], + "2650": [[19866,19871]], + "2651": [[19866,19871]], + "2652": [[19866,19871]], + "2653": [[19866,19871]], + "2654": [[19866,19871]], + "2655": [[19866,19871]], + "2656": [[19866,19871]], + "2657": [[19866,19871]], + "2658": [[19866,19871]], + "2659": [[19873,19878]], + "2660": [[19873,19878]], + "2661": [[19873,19878]], + "2662": [[19873,19878]], + "2663": [[19873,19878]], + "2664": [[19873,19878]], + "2665": [[19873,19878]], + "2666": [[19873,19878]], + "2667": [[19873,19878]], + "2668": [[19873,19878]], + "2669": [[19873,19878]], + "2670": [[19873,19878]], + "2681": [[19879,19885]], + "2682": [[19879,19885]], + "2683": [[19879,19885]], + "2684": [[19879,19885]], + "2685": [[19879,19885]], + "2686": [[19879,19885]], + "2687": [[19879,19885]], + "2688": [[19887,19892]], + "2689": [[19887,19892]], + "2690": [[19887,19892]], + "2691": [[19887,19892]], + "2692": [[19887,19892]], + "2693": [[19887,19892]], + "2694": [[19887,19892]], + "2695": [[19887,19892]], + "2696": [[19887,19892]], + "2697": [[19887,19892]], + "2698": [[19887,19892]], + "2699": [[19887,19892]], + "2700": [[19887,19892]], + "2701": [[19887,19892]], + "2702": [[19887,19892]], + "2703": [[19894,19899]], + "2704": [[19894,19899]], + "2705": [[19894,19899]], + "2706": [[19894,19899]], + "2707": [[19894,19899]], + "2708": [[19894,19899]], + "2709": [[19894,19899]], + "2710": [[19894,19899]], + "2711": [[19894,19899]], + "2712": [[19894,19899]], + "2713": [[19894,19899]], + "2714": [[19901,19906]], + "2715": [[19901,19906]], + "2716": [[19901,19906]], + "2717": [[19901,19906]], + "2718": [[19901,19906]], + "2719": [[19901,19906]], + "2720": [[19901,19906]], + "2721": [[19901,19906]], + "2722": [[19901,19906]], + "2723": [[19901,19906]], + "2724": [[19901,19906]], + "2725": [[19901,19906]], + "2726": [[19901,19906]], + "2727": [[19901,19906]], + "2728": [[19901,19906]], + "2729": [[19901,19906]], + "2730": [[19901,19906]], + "2731": [[19901,19906]], + "2732": [[19901,19906]], + "2733": [[19901,19906]], + "2744": [[19915,19920]], + "2745": [[19915,19920]], + "2746": [[19915,19920]], + "2747": [[19915,19920]], + "2748": [[19915,19920]], + "2749": [[19915,19920]], + "2750": [[19915,19920]], + "2751": [[19915,19920]], + "2752": [[19915,19920]], + "2753": [[19915,19920]], + "2754": [[19915,19920]], + "2755": [[19915,19920]], + "2756": [[19915,19920]], + "2757": [[19915,19920]], + "2758": [[19915,19920]], + "2759": [[19915,19920]], + "2760": [[19915,19920]], + "2761": [[19915,19920]], + "2762": [[19915,19920]], + "2763": [[19915,19920]], + "2764": [[19915,19920]], + "2765": [[19915,19920]], + "2766": [[19915,19920]], + "2767": [[19915,19920]], + "2768": [[19908,19913]], + "2769": [[19908,19913]], + "2770": [[19908,19913]], + "2771": [[19908,19913]], + "2772": [[19908,19913]], + "2773": [[19908,19913]], + "2774": [[19908,19913]], + "2775": [[19908,19913]], + "2776": [[19908,19913]], + "2777": [[19908,19913]], + "2778": [[19908,19913]], + "2779": [[19908,19913]], + "2780": [[19908,19913]], + "2781": [[19908,19913]], + "2782": [[19922,19927],[20364,20366]], + "2783": [[19922,19927],[20370,20372],[20405,20407]], + "2784": [[19922,19927],[20392,20394]], + "2785": [[19922,19927],[20382,20384]], + "2786": [[19922,19927],[20400,20402]], + "2787": [[19922,19927],[20411,20413]], + "2788": [[19922,19927],[20429,20431]], + "2789": [[19922,19927],[20435,20437]], + "2790": [[19922,19927],[20441,20443]], + "2791": [[19922,19927],[20450,20452]], + "2792": [[19922,19927],[20465,20467]], + "2793": [[19922,19927],[20481,20483]], + "2794": [[19922,19927],[20523,20525]], + "2795": [[19922,19927],[20531,20533]], + "2796": [[19922,19927],[20698,20700]], + "2797": [[19922,19927],[20709,20711]], + "2798": [[19922,19927],[20549,20551]], + "2799": [[19922,19927],[20542,20544]], + "2800": [[19922,19927]], + "2801": [[19922,19927]], + "2802": [[19930,19948],[20490,20512]], + "2803": [[19930,19948],[20490,20512]], + "2804": [[19930,19948],[20490,20512]], + "2805": [[19930,19948],[20490,20512]], + "2806": [[19930,19948],[20490,20512]], + "2807": [[19930,19948],[20490,20512]], + "2808": [[19930,19948],[20490,20512]], + "2809": [[19930,19948],[20490,20512]], + "2810": [[19930,19948],[20490,20512]], + "2811": [[19930,19948],[20490,20512]], + "2812": [[19930,19948],[20490,20512]], + "2813": [[19930,19948],[20490,20512]], + "2824": [[19935,19941]], + "2825": [[19935,19941]], + "2826": [[19935,19941]], + "2827": [[19935,19941]], + "2828": [[19935,19941]], + "2829": [[19935,19941]], + "2830": [[19935,19941]], + "2831": [[19935,19941]], + "2832": [[19935,19941]], + "2833": [[19935,19941]], + "2834": [[19935,19988],[20306,20435],[20670,20764]], + "2851": [[19998,20039],[20377,20404],[20741,20769]], + "2857": [[20377,20404],[20741,20769]], + "2858": [[20378,20404],[20742,20769]], + "2859": [[20379,20404],[20743,20769]], + "2860": [[20380,20404],[20744,20769]], + "2861": [[20381,20404],[20745,20769]], + "2862": [[20382,20404],[20746,20769]], + "2863": [[19998,20008]], + "2864": [[19998,20008]], + "2865": [[19998,20008]], + "2866": [[19998,20008]], + "2867": [[19998,20008]], + "2868": [[20006,20015]], + "2869": [[20006,20015]], + "2870": [[20006,20015]], + "2871": [[20006,20015]], + "2872": [[20006,20015]], + "2873": [[20013,20022]], + "2874": [[20013,20022]], + "2875": [[20013,20022]], + "2876": [[20013,20022]], + "2877": [[20013,20022]], + "2878": [[20013,20022]], + "2879": [[20013,20022]], + "2880": [[20013,20022]], + "2881": [[20013,20022]], + "2882": [[20013,20022]], + "2883": [[20020,20029]], + "2884": [[20020,20029]], + "2885": [[20020,20029]], + "2886": [[20020,20029]], + "2887": [[20020,20029]], + "2888": [[20027,20036]], + "2889": [[20027,20036]], + "2890": [[20027,20036]], + "2891": [[20027,20036]], + "2892": [[20027,20036]], + "2893": [[20027,20036]], + "2894": [[20027,20036]], + "2895": [[20027,20036]], + "2896": [[20027,20036]], + "2897": [[20027,20036]], + "2898": [[20027,20036]], + "2899": [[20027,20036]], + "2900": [[20027,20036]], + "2901": [[20027,20036]], + "2902": [[20027,20036]], + "2903": [[20027,20036]], + "2904": [[20027,20036]], + "2905": [[20027,20036]], + "2906": [[20027,20036]], + "2907": [[20027,20036]], + "2908": [[20027,20036]], + "2909": [[20027,20036]], + "2910": [[20027,20036]], + "2911": [[20027,20036]], + "2912": [[20027,20036]], + "2913": [[20027,20036]], + "2914": [[20027,20036]], + "2915": [[20027,20036]], + "2916": [[20027,20036]], + "2917": [[20027,20036]], + "2918": [[20027,20036]], + "2919": [[20027,20036]], + "2920": [[20027,20036]], + "2921": [[20027,20036]], + "2922": [[20027,20036]], + "2923": [[20027,20036]], + "2924": [[20027,20036]], + "2925": [[20027,20036]], + "2926": [[20027,20036]], + "2927": [[20027,20036]], + "2928": [[20027,20036]], + "2929": [[20027,20036]], + "2930": [[20027,20036]], + "2931": [[20027,20036]], + "2932": [[20027,20036]], + "2933": [[20027,20036]], + "2934": [[20027,20036]], + "2935": [[20027,20036]], + "2936": [[20027,20036]], + "2937": [[20027,20036]], + "2951": [[20055,20061],[20420,20426]], + "2952": [[20055,20061],[20420,20426]], + "2953": [[20055,20061],[20420,20426]], + "2954": [[20055,20061],[20420,20426]], + "2955": [[20055,20061],[20420,20426]], + "2956": [[20055,20061],[20420,20426]], + "2957": [[20058,20166],[20425,20465]], + "3007": [[20089,20204]], + "3018": [[20145,20190],[20516,20555]], + "3029": [[20145,20180]], + "3030": [[20147,20180]], + "3031": [[20148,20180]], + "3032": [[20149,20180]], + "3033": [[20150,20180]], + "3034": [[20151,20180]], + "3035": [[20152,20180]], + "3036": [[20153,20180]], + "3037": [[20154,20180]], + "3038": [[20155,20180]], + "3039": [[20156,20180]], + "3040": [[20157,20180]], + "3041": [[20158,20180]], + "3042": [[20159,20180]], + "3043": [[20160,20180]], + "3044": [[20161,20180]], + "3045": [[20162,20180]], + "3046": [[20163,20180]], + "3047": [[20164,20180]], + "3048": [[20173,20198],[20243,20272]], + "3059": [[20180,20235],[20545,20600]], + "3060": [[20182,20235],[20546,20600]], + "3061": [[20208,20271],[20572,20635]], + "3096": [[20230,20235]], + "3097": [[20230,20235]], + "3098": [[20230,20235]], + "3099": [[20230,20235]], + "3100": [[20230,20235]], + "3101": [[20230,20235]], + "3102": [[20230,20235]], + "3103": [[20230,20235]], + "3104": [[20230,20235]], + "3105": [[20230,20235]], + "3106": [[20230,20235]], + "3107": [[20230,20235]], + "3108": [[20230,20235]], + "3109": [[20230,20235]], + "3110": [[20230,20235]], + "3121": [[20243,20249]], + "3122": [[20243,20249]], + "3123": [[20243,20249]], + "3124": [[20243,20249]], + "3125": [[20243,20249]], + "3126": [[20243,20249]], + "3127": [[20243,20249]], + "3128": [[20243,20249]], + "3129": [[20243,20249]], + "3130": [[20243,20249]], + "3131": [[20243,20249]], + "3132": [[20243,20249]], + "3133": [[20251,20256]], + "3134": [[20251,20256]], + "3135": [[20251,20256]], + "3136": [[20251,20256]], + "3137": [[20251,20256]], + "3138": [[20251,20256]], + "3139": [[20251,20256]], + "3140": [[20251,20256]], + "3141": [[20258,20263]], + "3142": [[20258,20263]], + "3143": [[20258,20263]], + "3144": [[20258,20263]], + "3145": [[20258,20263]], + "3146": [[20258,20263]], + "3147": [[20258,20263]], + "3148": [[20258,20263]], + "3149": [[20258,20263]], + "3150": [[20258,20263]], + "3151": [[20258,20263]], + "3152": [[20258,20263]], + "3153": [[20258,20263]], + "3154": [[20258,20263]], + "3155": [[20258,20263]], + "3156": [[20265,20270]], + "3157": [[20265,20270]], + "3158": [[20265,20270]], + "3159": [[20265,20270]], + "3160": [[20265,20270]], + "3161": [[20265,20270]], + "3162": [[20265,20270]], + "3163": [[20265,20270]], + "3164": [[20265,20270]], + "3165": [[20265,20270]], + "3166": [[20265,20270]], + "3167": [[20265,20270]], + "3181": [[20272,20277],[20314,20319]], + "3182": [[20272,20277],[20314,20319]], + "3183": [[20272,20277],[20314,20319]], + "3184": [[20272,20277],[20342,20347]], + "3185": [[20272,20277],[20314,20319]], + "3186": [[20272,20277],[20314,20319]], + "3187": [[20272,20277],[20314,20319]], + "3188": [[20272,20277],[20314,20319]], + "3189": [[20272,20277],[20314,20319]], + "3190": [[20272,20277],[20314,20319]], + "3191": [[20272,20277],[20314,20319]], + "3192": [[20272,20277],[20314,20319]], + "3193": [[20272,20277],[20314,20319]], + "3194": [[20272,20277],[20314,20319]], + "3195": [[20272,20277],[20314,20319]], + "3196": [[20279,20284]], + "3197": [[20279,20284]], + "3198": [[20279,20284]], + "3199": [[20279,20284]], + "3200": [[20279,20284]], + "3201": [[20279,20284]], + "3202": [[20279,20284]], + "3203": [[20279,20284]], + "3204": [[20279,20284]], + "3205": [[20279,20284]], + "3206": [[20279,20284]], + "3207": [[20279,20284]], + "3208": [[20279,20284]], + "3209": [[20279,20284]], + "3210": [[20279,20284]], + "3211": [[20286,20291]], + "3212": [[20286,20291]], + "3213": [[20286,20291]], + "3214": [[20286,20291]], + "3215": [[20286,20291]], + "3216": [[20286,20291]], + "3217": [[20286,20291]], + "3218": [[20286,20291]], + "3219": [[20286,20291]], + "3220": [[20286,20291]], + "3221": [[20286,20291]], + "3222": [[20286,20291]], + "3223": [[20286,20291]], + "3224": [[20286,20291]], + "3225": [[20286,20291]], + "3226": [[20293,20298]], + "3227": [[20293,20298]], + "3228": [[20293,20298]], + "3229": [[20293,20298]], + "3230": [[20293,20298]], + "3231": [[20293,20298]], + "3232": [[20293,20298]], + "3233": [[20293,20298]], + "3234": [[20293,20298]], + "3235": [[20293,20298]], + "3236": [[20293,20298]], + "3237": [[20293,20298]], + "3238": [[20293,20298]], + "3239": [[20300,20305]], + "3240": [[20300,20305]], + "3241": [[20300,20305]], + "3242": [[20300,20305]], + "3243": [[20300,20305]], + "3244": [[20300,20305]], + "3245": [[20300,20305]], + "3246": [[20300,20305]], + "3247": [[20300,20305]], + "3248": [[20300,20305]], + "3249": [[20300,20305]], + "3250": [[20300,20305]], + "3251": [[20306,20421],[20692,20785]], + "3252": [[20300,20414],[20664,20729]], + "3263": [[20306,20312]], + "3264": [[20306,20312]], + "3265": [[20306,20312]], + "3266": [[20306,20312]], + "3267": [[20306,20312]], + "3268": [[20306,20312]], + "3269": [[20306,20421],[20692,20786]], + "3270": [[20306,20421],[20692,20786]], + "3281": [[20356,20456]], + "3282": [[20334,20363],[20700,20728]], + "3283": [[20339,20363],[20704,20728]], + "3284": [[20342,20363],[20707,20728]], + "3285": [[20346,20363],[20711,20728]], + "3286": [[20698,20792]], + "3297": [[20384,20404],[20748,20769]], + "3298": [[20385,20404],[20749,20769]], + "3299": [[20386,20404],[20750,20769]], + "3300": [[20387,20404],[20751,20769]], + "3301": [[20388,20404],[20752,20769]], + "3302": [[20389,20404],[20753,20769]], + "3303": [[20390,20404],[20754,20769]], + "3304": [[20362,20372]], + "3305": [[20362,20372]], + "3306": [[20362,20372]], + "3307": [[20362,20372]], + "3308": [[20362,20372]], + "3309": [[20362,20372]], + "3310": [[20370,20379]], + "3311": [[20370,20379]], + "3312": [[20370,20379]], + "3313": [[20370,20379]], + "3314": [[20370,20379]], + "3315": [[20370,20379]], + "3316": [[20377,20386]], + "3317": [[20377,20386]], + "3318": [[20377,20386]], + "3319": [[20377,20386]], + "3320": [[20377,20386]], + "3321": [[20377,20386]], + "3322": [[20384,20393]], + "3323": [[20384,20393]], + "3324": [[20384,20393]], + "3325": [[20384,20393]], + "3326": [[20384,20393]], + "3327": [[20384,20393]], + "3328": [[20391,20400]], + "3329": [[20391,20400]], + "3330": [[20391,20400]], + "3331": [[20391,20400]], + "3332": [[20391,20400]], + "3333": [[20391,20400]], + "3334": [[20391,20400]], + "3354": [[20362,20404],[20726,20769]], + "3357": [[20368,20370]], + "3358": [[20373,20375]], + "3359": [[20379,20381]], + "3360": [[20385,20387]], + "3361": [[20390,20392]], + "3362": [[20396,20398]], + "3375": [[20420,20426]], + "3384": [[20403,20405]], + "3385": [[20408,20410]], + "3386": [[20414,20416]], + "3387": [[20419,20421]], + "3388": [[20425,20427]], + "3409": [[20425,20540]], + "3410": [[20425,20435]], + "3411": [[20425,20435]], + "3412": [[20425,20435]], + "3413": [[20425,20435]], + "3414": [[20425,20435]], + "3415": [[20433,20442]], + "3416": [[20433,20442]], + "3417": [[20433,20442]], + "3418": [[20433,20442]], + "3419": [[20433,20442]], + "3420": [[20440,20449]], + "3421": [[20440,20449]], + "3422": [[20440,20449]], + "3423": [[20440,20449]], + "3424": [[20440,20449]], + "3425": [[20447,20455]], + "3426": [[20447,20455]], + "3427": [[20447,20455]], + "3428": [[20447,20455]], + "3429": [[20447,20455]], + "3430": [[20432,20434]], + "3431": [[20437,20439]], + "3432": [[20445,20447]], + "3433": [[20453,20455]], + "3434": [[20456,20458]], + "3435": [[20094,20096],[20492,20494]], + "3436": [[20425,20540]], + "3442": [[20460,20491]], + "3443": [[20460,20491]], + "3444": [[20460,20491]], + "3445": [[20460,20491]], + "3446": [[20460,20491]], + "3447": [[20460,20491]], + "3448": [[20461,20491]], + "3449": [[20462,20491]], + "3450": [[20463,20491]], + "3451": [[20464,20491]], + "3452": [[20465,20491]], + "3453": [[20466,20491]], + "3462": [[20469,20471]], + "3463": [[20477,20479]], + "3469": [[20485,20522]], + "3470": [[20485,20522]], + "3471": [[20485,20522]], + "3472": [[20485,20522]], + "3473": [[20485,20522]], + "3474": [[20485,20522]], + "3475": [[20485,20522]], + "3476": [[20485,20522]], + "3477": [[20485,20522]], + "3478": [[20485,20522]], + "3479": [[20485,20522]], + "3480": [[20485,20522]], + "3484": [[20498,20500]], + "3485": [[20507,20509]], + "3497": [[20520,20522]], + "3498": [[20528,20530]], + "3499": [[20538,20540]], + "3510": [[20542,20570]], + "3511": [[20542,20666]], + "3512": [[20546,20548]], + "3513": [[20555,20557]], + "3514": [[20565,20567]], + "3515": [[18384,18386],[20575,20577]], + "3516": [[20579,20581]], + "3526": [[20594,20599]], + "3527": [[20594,20599]], + "3528": [[20594,20599]], + "3529": [[20594,20599]], + "3530": [[20594,20599]], + "3531": [[20594,20599]], + "3532": [[20594,20599]], + "3533": [[20594,20599]], + "3534": [[20594,20599]], + "3535": [[20594,20599]], + "3536": [[20601,20606]], + "3537": [[20601,20606]], + "3538": [[20601,20606]], + "3539": [[20601,20606]], + "3540": [[20601,20606]], + "3541": [[20601,20606]], + "3542": [[20601,20606]], + "3543": [[20601,20606]], + "3544": [[20601,20606]], + "3545": [[20601,20606]], + "3546": [[20601,20606]], + "3547": [[20601,20606]], + "3548": [[20593,20595]], + "3549": [[20603,20605]], + "3551": [[20622,20715]], + "3562": [[20607,20613]], + "3563": [[20607,20613]], + "3564": [[20607,20613]], + "3565": [[20607,20613]], + "3566": [[20607,20613]], + "3567": [[20607,20613]], + "3568": [[20607,20613]], + "3569": [[20607,20613]], + "3570": [[20607,20613]], + "3571": [[20607,20613]], + "3572": [[20615,20620]], + "3573": [[20615,20620]], + "3574": [[20615,20620]], + "3575": [[20615,20620]], + "3576": [[20615,20620]], + "3577": [[20615,20620]], + "3578": [[20622,20627]], + "3579": [[20622,20627]], + "3580": [[20622,20627]], + "3581": [[20622,20627]], + "3582": [[20622,20627]], + "3583": [[20622,20627]], + "3584": [[20622,20627]], + "3585": [[20622,20627]], + "3586": [[20629,20634]], + "3587": [[20629,20634]], + "3588": [[20629,20634]], + "3589": [[20629,20634]], + "3590": [[20629,20634]], + "3591": [[20629,20634]], + "3592": [[20629,20634]], + "3593": [[20629,20634]], + "3594": [[20629,20634]], + "3595": [[20629,20634]], + "3596": [[20612,20614]], + "3597": [[20610,20612]], + "3598": [[20619,20621]], + "3599": [[20627,20629]], + "3600": [[20633,20635]], + "3611": [[20657,20757]], + "3612": [[20635,20641]], + "3613": [[20635,20641]], + "3614": [[20635,20641]], + "3615": [[20635,20641]], + "3616": [[20635,20641]], + "3617": [[20635,20641]], + "3618": [[20635,20641]], + "3619": [[20635,20641]], + "3620": [[20635,20641]], + "3621": [[20635,20641]], + "3622": [[20635,20641]], + "3623": [[20635,20641]], + "3624": [[20635,20641]], + "3627": [[20643,20648]], + "3628": [[20643,20648]], + "3629": [[20643,20648]], + "3630": [[20643,20648]], + "3631": [[20643,20648]], + "3632": [[20643,20648]], + "3633": [[20643,20648]], + "3634": [[20643,20648]], + "3635": [[20643,20648]], + "3636": [[20643,20648]], + "3637": [[20643,20648]], + "3638": [[20643,20648]], + "3639": [[20650,20655]], + "3640": [[20650,20655]], + "3641": [[20650,20655]], + "3642": [[20650,20655]], + "3643": [[20650,20655]], + "3644": [[20650,20655]], + "3645": [[20650,20655]], + "3646": [[20650,20655]], + "3647": [[20650,20655]], + "3648": [[20650,20655]], + "3649": [[20650,20655]], + "3650": [[20650,20655]], + "3651": [[20650,20655]], + "3652": [[20650,20655]], + "3653": [[20650,20655]], + "3654": [[20657,20662]], + "3655": [[20657,20662]], + "3656": [[20657,20662]], + "3657": [[20657,20662]], + "3658": [[20657,20662]], + "3659": [[20657,20662]], + "3660": [[20657,20662]], + "3661": [[20657,20662]], + "3662": [[20657,20662]], + "3663": [[20657,20662]], + "3664": [[20657,20662]], + "3665": [[20657,20662]], + "3666": [[20657,20662]], + "3667": [[20657,20662]], + "3668": [[20657,20662]], + "3669": [[20657,20662]], + "3670": [[20657,20662]], + "3671": [[20657,20662]], + "3672": [[20657,20662]], + "3673": [[20664,20669]], + "3674": [[20664,20669]], + "3675": [[20664,20669]], + "3676": [[20664,20669]], + "3677": [[20664,20669]], + "3678": [[20664,20669]], + "3679": [[20664,20669]], + "3680": [[20664,20669]], + "3681": [[20664,20669]], + "3682": [[20664,20669]], + "3683": [[20664,20669]], + "3684": [[20664,20669]], + "3685": [[20664,20669]], + "3686": [[20664,20669]], + "3687": [[20664,20669]], + "3688": [[20664,20669]], + "3689": [[20664,20669]], + "3690": [[20664,20669]], + "3691": [[20638,20640]], + "3692": [[20648,20650]], + "3693": [[20658,20660]], + "3694": [[20668,20670]], + "3705": [[20670,20676]], + "3706": [[20670,20676]], + "3707": [[20670,20676]], + "3708": [[20670,20676]], + "3709": [[20670,20676]], + "3710": [[20670,20676]], + "3711": [[20670,20676]], + "3712": [[20670,20676]], + "3713": [[20670,20676]], + "3714": [[20670,20676]], + "3715": [[20670,20676]], + "3716": [[20670,20676]], + "3717": [[20670,20676]], + "3718": [[20670,20676]], + "3719": [[20670,20676]], + "3720": [[20683,20685]], + "3731": [[20698,20738]], + "3732": [[20698,20738]], + "3733": [[20698,20738]], + "3734": [[20698,20738]], + "3735": [[20698,20738]], + "3736": [[20698,20738]], + "3737": [[20698,20738]], + "3738": [[20698,20738]], + "3739": [[20698,20738]], + "3740": [[20698,20738]], + "3741": [[20698,20738]], + "3742": [[20698,20738]], + "3743": [[20698,20738]], + "3744": [[20698,20738]], + "3745": [[20698,20738]], + "3746": [[20698,20738]], + "3747": [[20704,20706]], + "3760": [[20726,20736]], + "3761": [[20726,20736]], + "3762": [[20726,20736]], + "3763": [[20726,20736]], + "3764": [[20726,20736]], + "3765": [[20726,20736]], + "3766": [[20734,20743]], + "3767": [[20734,20743]], + "3768": [[20734,20743]], + "3769": [[20734,20743]], + "3770": [[20734,20743]], + "3771": [[20734,20743]], + "3772": [[20741,20750]], + "3773": [[20741,20750]], + "3774": [[20741,20750]], + "3775": [[20741,20750]], + "3776": [[20741,20750]], + "3777": [[20741,20750]], + "3778": [[20748,20757]], + "3779": [[20748,20757]], + "3780": [[20748,20757]], + "3781": [[20748,20757]], + "3782": [[20748,20757]], + "3783": [[20748,20757]], + "3784": [[20755,20764]], + "3785": [[20755,20764]], + "3786": [[20755,20764]], + "3787": [[20755,20764]], + "3788": [[20755,20764]], + "3789": [[20755,20764]], + "3790": [[20726,20769]], + "3791": [[20726,20769]], + "3792": [[20726,20769]], + "3793": [[20726,20769]], + "3794": [[20726,20769]], + "3795": [[20726,20769]], + "3796": [[20726,20769]], + "3797": [[20726,20769]], + "3798": [[20726,20769]], + "3799": [[20726,20769]], + "3800": [[20726,20769]], + "3801": [[20726,20769]], + "3802": [[20726,20769]], + "3803": [[20726,20789]], + "3804": [[20726,20769]], + "3805": [[20726,20769]], + "3806": [[20726,20769]], + "3807": [[20726,20769]], + "3808": [[20726,20769]], + "3809": [[20726,20769]], + "3810": [[20726,20769]], + "3811": [[20726,20769]], + "3812": [[20726,20769]], + "3813": [[20726,20769]], + "3814": [[20726,20769]], + "3815": [[20726,20769]], + "3816": [[20726,20769]], + "3817": [[20726,20769]], + "3818": [[20726,20769]], + "3819": [[20726,20769]], + "3820": [[20738,20740]], + "3821": [[20747,20749]], + "3822": [[20753,20755]], + "3823": [[20757,20759]] + } +} diff --git a/lib/sales.js b/lib/sales.js new file mode 100644 index 0000000..61d573d --- /dev/null +++ b/lib/sales.js @@ -0,0 +1,103 @@ +"use strict"; + +const history = require("./sale-dates.json"); + +// when shop items are on sale. the client decides that by itself: a shop +// drops whatever its def's availabilityStartTime..availabilityEndTime does +// not cover today (GenericListXtCommManager.filterIitems), tags what +// started in the last ten days as new and counts down to the end. so the +// defs are what to change, and they are re-stamped here before a client +// gets them. +// +// the official game rewrote an item's window each time the item came back, +// and lib/sale-dates.json has every window found in the builds the CDN +// still serves (tools/sale-history.js). here each window comes round again +// every year on the same dates: an item whose window, moved to this year, +// covers today is stamped with it; any other gets the next one coming, and +// stays hidden until then. items with no window in the file are left as +// their def has them. + +const DAY = 86400; +// sold for most of a year at a stretch: not seasonal, so always in stock. +const ALWAYS_DAYS = 330; + +// [start, end] in seconds for the def to carry at `now`, or null to leave it. +const windowFor = (windows, now) => { + if (!windows || windows.length === 0) { + return null; + } + if (windows.some(([startDay, endDay]) => endDay - startDay >= ALWAYS_DAYS)) { + return [0, 0]; + } + const year = new Date(now * 1000).getUTCFullYear(); + let current = null; + let next = null; + for (const [startDay, endDay] of windows) { + const first = new Date(startDay * DAY * 1000); + for (const candidate of [year - 1, year, year + 1]) { + const start = Date.UTC(candidate, first.getUTCMonth(), first.getUTCDate()) / 1000; + const end = start + (endDay - startDay) * DAY; + if (start <= now && now <= end) { + current = !current || end > current[1] ? [start, end] : current; + } + else if (start > now) { + next = !next || start < next[0] ? [start, end] : next; + } + } + } + return current || next; +}; + +// A testing switch (the admin panel's Debug page): with it on, nothing has +// sale dates at all, so every item shows wherever it is listed. kept in memory; a restart turns it off. +let everythingOnSale = false; + +// whether a seasonal item is in its season at `now`: it has sale dates, none +// of them makes it a year-round one, and one of them, moved to this year, +// covers today. (With the switch above on, any seasonal item is.) +const inSeason = (kind, id, now = Date.now() / 1000) => { + const windows = (history[kind] || {})[String(id)]; + if (!windows || windows.length === 0 || windows.some(([startDay, endDay]) => endDay - startDay >= ALWAYS_DAYS)) { + return false; + } + const [start, end] = windowFor(windows, now); + return everythingOnSale || (start <= now && now <= end); +}; + +// re-stamps the rows of a defPack (`kind`: clothing, denItems or diamond) in +// place. returns how many are on sale at `now` thanks to it. +const stamp = (kind, pack, now = Date.now() / 1000) => { + const windows = history[kind] || {}; + let onSale = 0; + for (const def of Object.values(pack)) { + const window = everythingOnSale ? [0, 0] : windowFor(windows[String(def.id)], now); + if (window) { + def.availabilityStartTime = String(window[0]); + def.availabilityEndTime = String(window[1]); + onSale += window[0] <= now && (window[1] === 0 || now <= window[1]) ? 1 : 0; + } + } + return onSale; +}; + +const always = pack => { + for (const def of Object.values(pack)) { + def.availabilityStartTime = "0"; + def.availabilityEndTime = "0"; + } +}; + +// the day the stamps were made for; a new day needs new ones. +const today = (now = Date.now() / 1000) => Math.floor(now / DAY); + +module.exports = { + stamp, + always, + today, + windowFor, + inSeason, + everythingOnSale: () => everythingOnSale, + setEverythingOnSale(on) { + everythingOnSale = on === true; + }, +}; diff --git a/lib/sfs.js b/lib/sfs.js new file mode 100644 index 0000000..c6c9dcf --- /dev/null +++ b/lib/sfs.js @@ -0,0 +1,279 @@ +"use strict"; + +const crypto = require("crypto"); +const fs = require("fs"); +const net = require("net"); +const tls = require("tls"); +const config = require("../config.js"); +const limits = require("./limits.js"); + +// SmartFoxServer 1.x wire protocol as spoken by the client's SmartFoxClient: +// messages are UTF-8, terminated by a NUL byte, and come in three flavours +// told apart by their first character: +// .. system (XML) +// %xt%%%%%...% extension (raw) +// {"t":"xt","b":{...}} extension (JSON) + +const POLICY = ''; +const MAX_MESSAGE = 64 * 1024; +const RATE_WINDOW_MS = 10000; +const MAX_BACKLOG = 4 * 1024 * 1024; +const MAX_ERRORS_PER_WINDOW = 20; +// the Create Account screens are done in a few minutes; a guest connection +// does not get to stay for as long as it keeps sending something. +const SIGNUP_LIFETIME_MS = 5 * 60000; + +// the login message carries the account's login token; keep it out of the log. +const forLog = message => message.replace(/()/, "$1(hidden)$2"); + +const connections = new Map(); // remote address -> open sockets + +let nextUserId = 1; + +class Session { + constructor(socket) { + this.socket = socket; + this.id = nextUserId++; + this.key = null; + this.account = null; + this.room = null; + this.pos = null; + this.address = socket.remoteAddress || ""; + this.remote = `${this.address}:${socket.remotePort}`; + } + + get name() { + return this.account ? this.account.username : `#${this.id}`; + } + + write(message) { + if (this.socket.writable) { + if (config.logPackets) { + console.log(`[game] -> ${this.name} ${message}`); + } + this.socket.write(message + "\0"); + // A client that stopped reading must not pile up messages here forever. + if (this.socket.writableLength > MAX_BACKLOG) { + this.socket.destroy(); + } + } + } + + sendSys(action, roomId, body = "") { + this.write(`${body}`); + } + + // raw extension message. the client reads params starting at index 2 of + // [cmd, roomId, ...params]. + // "%" separates fields and NUL ends the message, so neither may appear + // inside one: a player-chosen string could otherwise forge fields. + sendXt(cmd, roomId, ...params) { + this.write(`%xt%${[cmd, roomId, ...params].map(param => String(param).replace(/[%\0]/g, "")).join("%")}%`); + } + + sendXtJson(roomId, obj) { + this.write(JSON.stringify({t: "xt", b: {r: roomId, o: obj}})); + } + + close() { + this.socket.destroy(); + } +} + +const parseSys = message => { + const body = /([\s\S]*)<\/body>/.exec(message); + if (!body) { + return null; + } + const cdata = tag => { + const match = new RegExp(`<${tag}>`).exec(body[3]); + return match ? match[1] : null; + }; + return {action: body[1], roomId: Number(body[2]), raw: body[3], cdata}; +}; + +// handlers: {sys(session, msg), xt(session, cmd, roomId, params), close(session)} +const start = handlers => new Promise((resolve, reject) => { + const dispatch = (session, message) => { + if (config.logPackets) { + console.log(`[game] <- ${session.name} ${forLog(message)}`); + } + if (message.startsWith("${session.key}`); + return; + default: + handlers.sys(session, msg); + return; + } + } + if (message[0] === "%") { + // %xt%o%rj%1%a%b% -> ["", "xt", "o", "rj", "1", "a", "b", ""] + const parts = message.split("%"); + if (parts[1] === "xt" && parts.length >= 6) { + handlers.xt(session, parts[3], Number(parts[4]), parts.slice(5, -1)); + } + return; + } + if (message[0] === "{") { + const body = JSON.parse(message).b || {}; + const params = Array.isArray(body.p) ? body.p : Object.values(Object(body.p)); + handlers.xt(session, String(body.c), Number(body.r), params.map(String)); + } + }; + + const onConnection = socket => { + const address = limits.key(socket.remoteAddress); + const open = connections.get(address) || 0; + const total = [...connections.values()].reduce((sum, count) => sum + count, 0); + socket.on("error", () => {}); + if (open >= config.maxConnectionsPerAddress || total >= config.maxConnections) { + socket.destroy(); + return; + } + connections.set(address, open + 1); + + const session = new Session(socket); + let buffer = Buffer.alloc(0); + let windowStart = Date.now(); + let messagesInWindow = 0; + let bytesInWindow = 0; + let errorsInWindow = 0; + socket.setNoDelay(true); + console.log(`[game] ${session.remote} connected as #${session.id}`); + + // whoever connects has to log in (or start signing up) promptly, and + // nobody may sit silent for long: the client sends keep-alives. + const loginTimer = setTimeout(() => { + if (!session.account && !session.signingUp) { + socket.destroy(); + } + }, config.loginTimeoutMs); + const signupTimer = setTimeout(() => { + if (!session.account) { + socket.destroy(); + } + }, SIGNUP_LIFETIME_MS); + socket.setTimeout(config.idleTimeoutMs, () => socket.destroy()); + + socket.on("data", chunk => { + if (Date.now() - windowStart > RATE_WINDOW_MS) { + windowStart = Date.now(); + messagesInWindow = 0; + bytesInWindow = 0; + errorsInWindow = 0; + } + bytesInWindow += chunk.length; + if (bytesInWindow > config.maxBytesPerTenSeconds) { + console.log(`[game] ${session.name} disconnected for flooding`); + socket.destroy(); + return; + } + buffer = Buffer.concat([buffer, chunk]); + let end; + while ((end = buffer.indexOf(0)) !== -1) { + if (end > MAX_MESSAGE) { + socket.destroy(); + return; + } + if (++messagesInWindow > config.maxMessagesPerTenSeconds) { + console.log(`[game] ${session.name} disconnected for flooding`); + socket.destroy(); + return; + } + const message = buffer.toString("utf8", 0, end); + buffer = buffer.subarray(end + 1); + try { + dispatch(session, message); + } + catch (err) { + // one line a failure, and an end to them: a client that sends + // nonsense in a loop is not to fill the log. + const where = String(err.stack || "").split("\n")[1] || ""; + console.log(`[game] error handling message from ${session.name}: ${err.message}${where ? ` (${where.trim()})` : ""}`); + if (++errorsInWindow > MAX_ERRORS_PER_WINDOW) { + console.log(`[game] ${session.name} disconnected: too many messages that could not be handled`); + socket.destroy(); + return; + } + } + if (socket.destroyed) { + return; + } + } + if (buffer.length > MAX_MESSAGE) { + socket.destroy(); + } + }); + socket.on("close", () => { + clearTimeout(loginTimer); + clearTimeout(signupTimer); + const left = connections.get(address) - 1; + if (left > 0) { + connections.set(address, left); + } + else { + connections.delete(address); + } + console.log(`[game] ${session.name} disconnected`); + // nothing thrown while a player is seen off may take the server down. + try { + handlers.close(session); + } + catch (err) { + console.log(`[game] error while ${session.name} left: ${err.stack}`); + } + }); + }; + + const server = config.tls + ? tls.createServer({cert: fs.readFileSync(config.tls.certFile), key: fs.readFileSync(config.tls.keyFile), + handshakeTimeout: config.tlsHandshakeTimeoutMs}, onConnection) + : net.createServer(onConnection); + server.on("tlsClientError", () => {}); + server.maxConnections = config.maxConnections * 2; + if (config.tls) { + // connections that have not finished their TLS greeting are counted + // too: the limit above is only reached once they have. + const greeting = new Map(); // address -> connections not yet through it + server.on("connection", raw => { + const address = limits.key(raw.remoteAddress); + const count = (greeting.get(address) || 0) + 1; + if (count > config.maxConnectionsPerAddress * 2) { + raw.destroy(); + return; + } + greeting.set(address, count); + const done = () => { + const left = greeting.get(address) - 1; + if (left > 0) { + greeting.set(address, left); + } + else { + greeting.delete(address); + } + }; + raw.once("close", done); + }); + } + server.once("error", reject); + server.listen(config.gamePort, config.gameBindAddress, () => { + console.log(`[game] listening on ${config.gameBindAddress}:${config.gamePort}${config.tls ? " (TLS)" : ""}`); + resolve(server); + }); +}); + +module.exports = {start}; diff --git a/lib/shop-stock.json b/lib/shop-stock.json new file mode 100644 index 0000000..0ed749e --- /dev/null +++ b/lib/shop-stock.json @@ -0,0 +1,111 @@ +{"source":"AJ Classic Wiki (animaljam.fandom.com), read by tools/shop-stock.py","lists":{ +"5":{"shop":"Shiveer Shoppe","now":{"clothing":[828,345,156,1110,1761,1762,1763,1091,274,709,1111,1100,356],"den":[]},"former":{"clothing":[233,142,152,135,251,1273,263,1378,1113,1431,1433,1271,154,838,1750,714,1682,892,543,1350,718,1318,1065,528,527,1970,1064,1325,269,703,1292,3827,140,713,1377,234,232,780,3111,2120,478,3631,3770,3304,4295,1323,3756,3754,3873,1767,1985,3277,536,4511,4147,3364,3426,1776,2760,231,3907,2010,3215,3182,1911,3808,4231,881,64,2500,2147,489,490,1759,237,4150,4130,4084,4197,3376,2040,3124,392,4026,3826,3852,3463,3444,2734,3196,3027,2133,2746,1937,4267,479,2629,4484,1059,4416,3689,217,2169,3144,1733,534,1082,2646,3128,3292,3094,3351,3517,4293,3478,3519,2810,3236,3198,3600,3254,2897,3004,3561,2975,3953,4048,1864,4594,4508,3618,2631,572,2717,533,236,4244,225,871,219,221,220,1099,1055,1092,1671,707,250,1272,4273,1977,333,334,228,245,1291,876],"den":[]}}, +"9":{"shop":"Mystery Emporium","now":{"clothing":[],"den":[1065,621,442,970,445,443,480,1201,441,809,479,447,538,1360,444,750,1587,1591,1593]},"former":{"clothing":[],"den":[391,717,64,708,392,56,60,403,440,89,645,755,50,91,742,389,397,59,400,528,390,358,164,628,484,1086]}}, +"11":{"shop":"Jam Mart Clothing","now":{"clothing":[1296,706,142,1578,468,1262,560,559,1264,1045,134,944,1226,932,153,1154,937,738,906,141,260,265,154,1577,834,936,278,157,982,418,159,1249,621,1227,1000,145,830,935,1430,586,632,811,151,573,144,809,1086,137,240,796,1297,1307,1673,268,661,578,577,58,1557,931,765,163,126,1261,164,1037,1558,1129,810,133,792,469,1252,1508,758,999,829,1250,147,125,253,519,1533,60,587,779,1579,1237,1534,417,1251,122,136,165,629,708,1240,743,1540,812,754,22,753,662,1228],"den":[]},"former":{"clothing":[1286,149,233,152,135,981,287,426,4271,1929,828,251,238,1287,652,59,1003,1004,1248,1005,3011,425,925,63,1650,837,759,1273,670,1044,127,289,435,766,822,692,790,1614,128,3016,1446,123,1168,2220,2211,2219,2217,2218,2216,2215,2213,2214,2209,2210,2212,1155,1115,262,264,912,263,1376,1378,1128,729,911,1113,470,1667,546,224,719,905,702,701,500,3877,3911,2032,2035,2029,2036,2033,2037,2034,2027,2030,2031,2038,2028,552,1431,1432,1433,821,820,150,160,169,690,266,663,664,653,835,1271,486,760,1672,1683,1690,684,1493,601,1052,823,838,1247,4272,620,313,1440,1535,1263,1443,598,215,3008,482,612,212,213,441,613,209,214,974,614,3258,783,210,3259,211,1098,1750,1748,1749,1752,1751,1316,714,473,1728,1730,1729,3014,847,1288,647,1181,1494,3009,491,1939,1938,249,259,242,243,357,257,892,889,256,543,1097,255,1106,258,718,4247,1104,1096,1105,1285,488,1061,1967,161,329,1036,1326,1318,1085,852,930,3013,1317,1065,246,1958,1686,1083,528,872,1062,1968,1681,1063,1680,1957,1060,1725,1724,1687,1688,1678,527,1970,1064,1325,1084,1679,3015,849,870,247,267,456,453,269,1292,3912,800,1241,547,162,1298,720,65,261,725,3012,129,1764,2390,2391,2393,2392,2388,2394,2398,2399,2389,2395,2396,2397,2400,2401,2387,983,2475,2474,2472,2471,2473,2457,50,146,481,1509,131,495,836,402,487,3010,1726,130,156,140,998,1001,877,132,1219,1220,1218,713,762,395,1289,2452,2448,235,2447,2449,398,628,2450,2451,2446,2445,1127,254,241,869,1669,1760,139,1377,1114,1393,646,234,232,2077,1438,1923,1256,2119,592,1612,522,475,476,1245,1343,611,545,3110,644,626,1791,624,625,2278,521,1268,848,825,1896,1556,2252,585,745,1654,1235,2072,2071,3029,4487,723,636,1613,1023,1919,2251,1990,1555,445,1464,699,1897,575,1165,1210,1080,1321,1425,1356,3771,3755,1424,1294,2808,1975,3872,1986,1374,497,1768,918,2193,1125,1373,826,908,633,986,540,2274,561,832,716,864,239,1491,2275,1024,1236,971,1567,2761,1586,3214,1225,763,593,756,1054,447,2553,2554,797,231,695,2555,2287,2277,2285,3692,3632,2284,2106,2628,2286,2266,2267,2268,2265,3906,928,539,1830,1445,775,1721,1792,544,727,1922,1774,804,1576,4335,412,1215,571,1833,1950,1414,4292,929,138,226,2241,2240,2025,2424,2425,4024,979,776,777,3956,2901,2183,2188,2331,2330,715,2329,2731,3796,1568,1777,2295,1314,711,379,2222,2238,2221,1677,64,1391,4047,2499,2497,2501,2498,1492,2811,2972,1239,3112,3363,4148,875,907,909,883,1349,1758,1982,904,1348,1984,903,1980,400,1357,2189,2187,1026,1742,1157,1046,237,2296,3127,460,919,1133,955,1415,1978,1734,4083,4085,1811,1664,2645,867,3377,1322,2298,4199,1676,696,697,2149,2167,1306,1238,471,542,541,535,844,1108,843,746,1936,704,467,910,1988,557,1050,4232,2340,3853,2745,4246,3464,2339,2747,2338,3465,728,2144,1025,2117,405,406,327,508,1267,1039,1610,1335,764,227,1184,637,1973,1722,556,682,1775,1731,2105,2103,2104,1049,1538,833,2132,1611,1290,1392,399,1053,1337,3238,882,3183,752,422,1283,1653,3289,650,1081,2191,2192,1153,673,1047,1879,1180,531,446,1095,3199,1526,1444,924,645,1259,1840,778,1663,218,3690,217,675,674,1918,4131,1527,1585,1126,741,956,1908,1437,651,2297,1341,2170,694,1675,2718,509,1814,1089,1109,1094,705,700,230,393,786,4133,2276,3031,3096,3306,3349,841,2009,3477,2200,2348,2350,2332,2224,2405,2341,2347,3856,1989,3518,1134,2198,1998,2404,2402,2197,2001,1997,2194,2403,2196,2195,2762,3480,2199,2351,2423,2349,3197,2422,1012,1862,413,551,498,722,1831,1912,3620,2239,2453,2039,2456,2480,2261,2259,2260,2481,2455,3275,2257,3253,2256,3001,3954,2026,2250,3237,2479,2478,2454,2249,1340,799,755,1909,1794,996,1147,386,380,951,2182,855,4510,1652,846,1813,934,1426,2011,681,1284,23,941,1575,222,3291,3616,933,2299,2317,2315,532,2318,2316,3145,229,236,387,4417,770,950,942,1013,4269,3442,3824,1971,1058,225,1510,627,248,871,721,840,946,891,62,945,943,433,219,221,1649,216,220,3005,724,3007,671,648,831,24,166,1091,1055,1092,710,850,707,873,1668,874,250,1670,774,2427,2426,789,757,744,501,665,1033,597,1781,1765,1818,1796,1810,1817,939,938,1439,1429,1778,1441,3876,1808,1809,1779,3219,1797,1816,4270,3218,1795,1780,290,252,1272,693,401,520,3369,1793,761,529,1270,1112,1648,21,1442,842,244,1308,574,143,223,3006,1974,484,4058,4053,4051,4064,4050,4055,4054,4066,4067,4052,4057,4056,4059,4060,4065,4061,4063,4062,1665,333,334,1666,485,502,228,148,767,245,1291,499,839],"den":[]}}, +"12":{"shop":"Jam Mart Furniture","music":false,"now":{"clothing":[],"den":[424,4995,1547,3427,1624,1213,542,1538,3191,1,1232,1471,4071,4988,118,338,372,2846,637,4114,4624,2362,382,2356,3100,2781,1549,4532,4535,4534,4539,4544,4545,4542,4533,4536,4537,4543,949,4997,3098,1212,1044,373,4656,1048,1043,1046,1047,4996,348,4991,1172,2352,3342,4986,2785,1437,330,381,2782,4998,773,641,1234,3104,1523,2834,4994,4993,547,4999,2361,3101,612,499,3194,4992,189,4622,131,1857,1853,1854,1990,1864,1956,1954,1963,1861,1973,1970,1953,1617,2349,2682,2683,2679,2678,2681,1100,1101,4623,4957,4620,295,367,1595,36,418,369,771,4958,2783,383,4990,1235,4987,776,3103,1139,1536,2192,4119,4118,363,3102,416,415,398,2847,3172,1616,371,2505,2789,1557,152,158,1615,2348,2600,2553,3099,1169,3560,439,423,3189,775,4090,3171,3197,2363,357,1602,2,1590,1592,1594,365]},"former":{"clothing":[],"den":[2484,4648,2427,2422,2421,2424,2431,2430,2426,2420,2423,2428,2429,2425,2865,1135,4694,4696,4695,4771,1575,1768,1770,1769,1760,391,4616,3203,3602,3605,1307,611,4952,4951,8,1821,3894,2412,3431,3434,2719,13,4646,4066,717,16,1103,3225,4182,4724,4590,4686,399,2801,402,15,4091,4104,565,4098,4097,2677,2296,1402,19,3886,3740,292,362,366,24,435,4709,3970,3969,3968,3972,3971,4522,1734,4086,4836,2471,3879,345,2298,1766,3599,1533,2739,2742,2747,2744,2741,2745,2749,2746,2748,2750,2743,2740,380,489,733,411,2455,3946,3945,2452,2434,3949,715,1938,3948,1362,3944,3947,3952,1368,4084,430,3324,2339,394,4117,4115,1303,436,1528,4538,4644,4645,2398,2397,2399,1442,1443,846,1441,848,1447,1985,847,4940,4945,4942,4941,4939,4938,4783,1015,346,2480,181,527,526,1237,4657,1556,1539,3629,2494,1497,1948,1677,4691,2774,37,3694,3689,3684,3685,3688,3692,3686,3683,3687,3693,3691,3690,736,4844,4839,4838,4837,2552,3749,2117,1532,3748,2551,2116,3450,1306,1765,1749,4948,488,812,4563,4561,4560,4564,4559,1483,52,478,1792,4067,4651,4653,4650,903,4652,4083,485,4586,2358,1230,3063,3186,3185,3061,3062,4907,3592,1689,1718,1719,1643,1691,1685,1686,1648,531,732,1788,392,4469,3311,3883,4281,4714,2866,4723,1584,4316,51,3739,3733,3731,3730,3729,3735,3737,3728,3727,3736,3732,3734,3889,3624,3623,3675,3669,3666,3674,3672,3670,3673,3676,3665,3667,3671,3668,56,559,2837,494,935,3745,2702,360,2602,349,1525,1229,1095,2717,4594,355,3232,3236,4593,3234,3233,3231,3235,1057,3007,3990,3006,2998,4832,2396,739,902,842,3507,1901,3504,819,2418,1486,405,4183,4184,3741,3747,1236,3742,3746,388,387,934,403,3887,3437,1524,4069,1312,427,3328,3327,4464,4113,4466,1045,2512,4592,1843,4845,4775,4465,1708,1605,4383,3325,4584,1836,4647,404,4726,4039,2921,4867,4110,1411,2044,3174,428,3463,3464,3460,2593,1837,738,3461,3459,1699,1480,2278,2272,2275,2269,2274,2277,2281,2273,2282,2271,2280,2283,65,1173,1764,1640,3521,1540,3627,2489,1499,1495,4712,1541,3631,2493,1501,4710,419,463,1577,2780,2773,562,395,4585,737,4180,4591,2821,2736,425,1083,2772,1566,4690,3835,3836,3841,3840,4688,3870,3834,2232,2229,793,794,2465,434,68,3511,3513,2470,3508,1962,1416,1606,3008,1940,790,3004,1417,1415,1423,1418,2469,3509,563,1438,1413,2909,2295,4774,586,1729,904,1713,4103,1709,1707,1714,1706,1711,3600,1700,1710,817,4108,820,1404,1826,4107,2461,4105,3935,2676,3885,4275,4280,1450,1365,1840,2453,4736,4732,5243,3451,3452,1935,429,1161,5245,1839,2887,5244,1937,1818,4735,4733,1841,2911,350,4587,1280,3146,1529,2345,1527,3454,2411,3428,1152,2401,3429,3453,3962,2820,2819,1446,4835,1531,432,433,431,1939,1542,3626,2488,1496,4312,4311,4776,4309,4310,1227,4386,4384,4387,4385,4389,4388,3032,4458,4456,4457,4459,4001,454,3996,3034,3518,3517,4858,3033,3998,4004,3035,4454,4451,4449,4452,4450,4455,3031,2510,3999,4000,1789,1791,1790,440,3880,83,3744,1058,4460,3890,2417,3376,1153,2867,2864,1810,3300,3295,3305,3304,3301,3302,3296,3297,3294,3299,3298,3303,4291,2786,2787,486,4649,2915,1091,3127,3129,3133,3128,2456,4687,1484,361,4643,1537,2680,4960,4950,4954,4955,4953,1580,1731,2344,753,2354,2404,1481,1596,354,130,2733,2732,2734,2737,2735,2738,2462,4617,4618,3750,1904,1914,1916,1911,1905,1906,3523,1923,1924,1925,3714,3716,3708,3710,1907,3712,3709,3715,3717,3713,1928,3718,3707,1910,3711,4181,3226,3223,3218,3224,3220,1687,4596,744,1932,456,646,1543,3628,2491,1500,1134,3961,3963,3965,3967,3964,4864,4093,1429,4138,1412,2886,4655,1834,1349,818,2779,1520,695,1809,4041,4043,2047,4040,4042,2049,2045,4038,2048,2046,1445,493,1314,4467,2730,2720,2728,2721,2723,2724,2727,2722,2731,2729,2726,2479,4367,841,4065,50,39,370,364,1233,91,2776,2778,4589,2525,2545,2529,2408,2410,2546,2532,2530,2547,2548,2597,2527,2409,2528,2526,2531,1727,1738,1739,1726,1728,1735,1733,1730,1736,413,335,4613,4614,1474,2912,1936,4812,4808,4810,4813,4809,1601,1934,1488,422,455,4877,4085,845,97,1763,464,412,1614,1613,3895,2850,1870,4727,4728,3456,2402,1579,1238,1468,1645,3772,1545,1650,1276,1190,1277,1226,3610,3608,3616,3611,3614,1224,55,1225,3130,3132,3124,3131,114,629,462,4731,751,2910,4671,4672,4670,115,417,351,4063,1431,1960,734,1801,731,1081,1082,1761,4392,4734,1696,1214,1693,1694,1690,1692,1720,1717,1688,1695,1697,1929,1865,1874,3635,3743,1926,1927,1646,1958,3634,1866,3633,1959,1889,1931,545,1891,1930,3893,4713,389,397,396,933,3198,1530,3604,647,2852,620,2511,4869,2011,4870,2014,3043,4874,4868,2019,490,3975,4070,5048,1746,1678,2503,2501,2502,1544,3630,2490,1498,1440,937,936,1410,4364,459,457,1398,4274,3877,4276,400,840,4721,1844,564,1281,4290,458,155,4092,4279,839,1878,1877,5049,5054,5053,5050,5051,1886,1805,1807,1804,1883,1420,888,1888,1831,1397,1881,1882,1890,4782,1399,4361,2419,1838,721,5052,816,426,3934,2449,4729,4363,4773,889,2387,1802,4973,4956,4972,4970,4961,4971,1800,1794,1793,1803,1799,147,2340,2802,2799,401,1712,587,1933,3878,3832,1569,3833,1568,4692,1565,3839,1572,2849,2347,1581,1585,1573,3831,3837,1574,3838,2848,4917,4530,4918,4919,4531,4529,4916,4915,4914,4060,4061,4051,3594,4052,3589,4059,4055,4062,4057,4056,4520,4886,1546,4524,4525,4528,4527,4526,4523,2777,1304,4082,1283,1011,1611,1012,3601,3607,1166,414,3606,1239,352,1080,774,4010,1448,390,4894,4893,4887,4888,4889,4892,4890,4891,530,226,358,27,1394,1284,1618,359,3632,438,421,1305,437,2920,5215,5214,5218,5216,5217,3609,3651,3617,3612,3615,81,1475,4072,1588,1589,1231,2468,2357,1620,1621,1619,1285,4615,1241,2890,2891,2892,1363,2716,353,1092,1094,1093,1102,2644,4725,4286,3891,477,1598,4562,4884,1600,3449,3973,1964,347,1487,1513,1511,1512,1515,1705,235,5109,1750,1526,1240,1079,374,1586,1282,4366,1828,1830,1829,1827,4365,3882,3950,1607,1597,1762,772,344,420,1851,1228,3175,3168,1096,386,2914,2207,2208,368,4362,3]}}, +"50":{"shop":"Bahari Bargains","now":{"clothing":[296,305,1593,302,293,454,303,299,588,295,329,335,438,298,361,432,464,947,304,291,311,404,423,424,465,672,431,308,301,455,292,1617,347,403,437,306,583,312,309],"den":[]},"former":{"clothing":[505,340,339,377,381,378,382,504,4525,310,1221,1223,1222,337,328,359,358,901,483,3957,331,336,294,360,300,494,503,288,297,307,324,550,4371,4266,325,2014,461,3619,712,2008,680,972,4229,3424,4025,1983,2190,330,3521,615,1841,362,1863,1483,2171,791,326,927,448,3598,1265,771,3910,1834,472,845,562,824,466,2089,2088,576,2223,3560,1021,1547,3823,352,363,346,321,322,496,351,1815,323],"den":[]}}, +"51":{"shop":"Sunken Treasures","now":{"clothing":[],"den":[680,756,705,682,683,880,940,879,745,891,877,727,876,1014,1897,757,878,760,1013,905,1460,892,687,688,1608,1609,741,893,689,1287,1197,3209,3212,3208,3211,3215,1061,1055,1112,890,1873,926,874,873,686,1477,1175,1174,1004,849,828,1869,703,1503,1505,1507,1502,1506,1535,1504,1604,690,711,1461,1482,709,1286,1508,1198,1603]},"former":{"clothing":[],"den":[726,875,681,1056,844,684,827,1146,740,1144,1903,710,685,923,924,790,1060,1147,1142,791,691,925,1143,712,759,938,939,1159,752,1479,941,920]}}, +"56":{"shop":"Music Shop","music":true,"now":{"clothing":[],"den":[697,698,805,699,865,614,1246,914,702,2577,701,648,829,700,5563]},"former":{"clothing":[],"den":[615,616,693]}}, +"59":{"shop":"Epic Wonders","now":{"clothing":[1735,803,1135,1542,462,3344,1002,414,463,350,507,353,795,663,664,760,477,1299,768,623,397,348,428,537,530,349,449,1543,415,1832,4512,1560,827,683,677,678,679,427,622,1043,631,630,649,574],"den":[1177,956,728,1473,795,1157,1150,1170,2051,2041,2040,2054,2066,2052,1463,2067,1151,2276,850,1041,735,5607,3561,3293,851,4179,843,2315,2316,1217,1313,2193,730,921,1476]},"former":{"clothing":[1286,4234,4279,837,4251,4250,4248,4252,4249,1375,905,355,784,4280,785,354,821,4296,726,1930,819,1969,1672,1736,492,1035,1034,4233,4029,2545,2525,2549,2534,2532,506,2540,2542,2546,2550,2535,2541,2530,2523,2547,2528,2526,2529,2522,450,2533,2544,2543,2527,2548,4275,890,1320,1319,573,1087,878,1723,1324,2079,4274,1673,481,1001,4336,4421,493,2078,2077,2080,2075,2076,2082,2074,2081,538,1315,3772,3216,4049,4370,4419,4418,2145,2012,1185,1743,3427,3425,1505,3855,3305,1101,1158,3217,1812,3113,2973,1880,2148,1102,1949,1506,1921,616,2720,3181,3146,4509,3809,2007,880,1996,2748,2898,2899,4245,742,4294,4149,3126,3125,698,2630,3599,4198,3375,3378,2168,1972,3825,3184,2118,3520,1539,3634,3278,4134,1164,4485,4486,3256,3293,3688,3352,2647,1979,1732,2552,1920,2763,4268,3875,2733,3366,3002,3290,2146,1305,1090,3617,1910,4230,3443,4201,1293,396,4372,4488,1615,676,831,1651,873,874,529,1270,1269,1228,1166,474],"den":[1178,1207,2792,1040,725,1576,3951,4116,4689,2477,4100,4282,1084,1264,1085,1222,1223,1263,1243,1242,1087,4089,2922,1208,922,3591,1209,4778,1522,2209,2270,5659,3455,2554,3505,4101,1176,4464,4466,4006,4842,4465,3960,4081,2447,1156,2448,1097,3876,3514,4841,852,803,1158,4211,4292,4106,3997,2030,2788,2675,1455,1457,1458,1435,1459,1456,2718,4112,1210,1215,1008,1132,3884,1009,5658,5660,1098,3184,4811,4817,802,4213,4212,4210,4333,5291,5761,5056,5467,731,1211,3635,3633,1216,5661,2353,804,2805,936,4777,1819,3936,2449,1845,729,4283,1137,4058,4053,4886,2359,1218,3933,1219,3992,2191,3503,4780]}}, +"61":{"shop":"Jamaaliday Shop","music":false,"now":{"clothing":[1690,1062,1681,1725,1724,1678,1956,1084,1679],"den":[717,733,1350,739,3954,2460,2433,1836,428,3463,3464,1837,737,2435,1348,3956,3957,3955,2909,3935,2885,2883,429,1364,1366,744,751,734,3934,1933,3953,754,1367]},"former":{"clothing":[1312,851,692,1067,1052,1328,1329,1330,1327,1331,872,1063,1957,527,247,1959,693,2408,2409,2411,2406,2407,2410,245,1960],"den":[3801,2434,1362,736,4751,3799,427,3960,3800,3959,3958,4744,3462,738,3461,425,1365,4745,2437,3807,2438,3768,3767,1935,432,431,3806,2770,3798,1349,1934,3805,3802,3804,4746,4753,3803,4754,426,1363]}}, +"63":{"shop":"Sol Arcade Shop","now":{"clothing":[],"den":[832,708,831,1088,777,561,543,1133,1059,613,560,645,743,491,789,755,528,492,1155,544,713,628,529]},"former":{"clothing":[],"den":[742]}}, +"67":{"shop":"Dinner Shop","now":{"clothing":[],"den":[781,780,489,488,490,487,2745,2747,2749,2741,2746,2750,2748,2740,2744,2743,2742,2739]},"former":{"clothing":[],"den":[]}}, +"68":{"shop":"Friendship Shop","now":{"clothing":[],"den":[4847,3513,3511,4839,4844,4838,4837,4846,4848,4849,4390,4394,4393,3516,3515,434,68,435,2467,374,364]},"former":{"clothing":[],"den":[]}}, +"70":{"shop":"Heatwave Shop","now":{"clothing":[],"den":[564,563,562,15,530,565]},"former":{"clothing":[],"den":[]}}, +"71":{"shop":"Leap Year Accessories","now":{"clothing":[3445,3446,3447,3448,3449,3450],"den":[]},"former":{"clothing":[],"den":[]}}, +"72":{"shop":"Leap Year Den Items","now":{"clothing":[],"den":[5299,5298,5297,5296,5295,5294,5293,5292]},"former":{"clothing":[],"den":[]}}, +"74":{"shop":"Lucky Shop","now":{"clothing":[],"den":[4873,4871,4875,4872,3519,3522,3036,848,1442,454,847,846,866]},"former":{"clothing":[],"den":[]}}, +"81":{"shop":"Wolves Only Shop","now":{"clothing":[],"den":[882,883,884,881,885,886]},"former":{"clothing":[],"den":[]}}, +"82":{"shop":"April Fools' Shop","now":{"clothing":[1427,922,1156,740,923,1428,921,920],"den":[4893,4892,4891,4889,4887,4894,4888,4890,4878,4865,4863,4866,4471,4470,4482,4461,4463,3595,3600,3597,3598,2031,2038,2033,2035,2039,3596,912,909,907,910,908,911]},"former":{"clothing":[],"den":[]}}, +"83":{"shop":"Horses Only Shop","now":{"clothing":[384,383,385,143,149,160],"den":[901,900,899,898,897,896,919]},"former":{"clothing":[],"den":[]}}, +"84":{"shop":"Horses Only Shop","music":false,"now":{"clothing":[384,383,385,143,149,160],"den":[901,900,899,898,897,896,919]},"former":{"clothing":[],"den":[]}}, +"85":{"shop":"Pet Den Item Shop","now":{"clothing":[],"den":[582,917,581,918,916,631,943,942,2355,955,1494,4095,4094,952,950]},"former":{"clothing":[],"den":[946,945,944,953,610,712,954,951]}}, +"87":{"shop":"Atlantis Shop","now":{"clothing":[388,389,391,390],"den":[930,931,929,928,927,932]},"former":{"clothing":[],"den":[]}}, +"88":{"shop":"Atlantis Shop","now":{"clothing":[388,389,391,390],"den":[930,931,929,928,927,932]},"former":{"clothing":[],"den":[]}}, +"90":{"shop":"Horses Only Shop","music":true,"now":{"clothing":[384,383,385,143,149,160],"den":[901,900,899,898,897,896,919]},"former":{"clothing":[],"den":[]}}, +"92":{"shop":"Spooky Shop","now":{"clothing":[1031,1030,1029,1038,1027,251],"den":[3877,3337,3341,2853,2855,3887,3883,401,402,2351,1141,394,395,3839,693]},"former":{"clothing":[],"den":[]}}, +"93":{"shop":"Spooky Shop","music":false,"now":{"clothing":[1031,1030,1029,1038,1027,251],"den":[3877,3337,3341,2853,2855,3887,3883,401,402,2351,1141,394,395,3839,693]},"former":{"clothing":[],"den":[]}}, +"94":{"shop":"Spooky Shop","music":true,"now":{"clothing":[1031,1030,1029,1038,1027,251],"den":[3877,3337,3341,2853,2855,3887,3883,401,402,2351,1141,394,395,3839,693]},"former":{"clothing":[],"den":[]}}, +"95":{"shop":"Cruise Ship Shop","now":{"clothing":[],"den":[4882,4881,4880,4879,965,963,966,964,962,961,960]},"former":{"clothing":[],"den":[]}}, +"96":{"shop":"Cruise Ship Shop","now":{"clothing":[],"den":[4882,4881,4880,4879,965,963,966,964,962,961,960]},"former":{"clothing":[],"den":[]}}, +"99":{"shop":"Bunnies Only Shop","music":false,"now":{"clothing":[],"den":[975,976,977,978,979,980,1005]},"former":{"clothing":[],"den":[]}}, +"100":{"shop":"Bunnies Only Shop","music":true,"now":{"clothing":[],"den":[975,976,977,978,979,980,1005]},"former":{"clothing":[],"den":[]}}, +"104":{"shop":"Penguins Only Shop","music":false,"now":{"clothing":[],"den":[1016,1017,1018,1019,1020,1021,1039]},"former":{"clothing":[],"den":[]}}, +"106":{"shop":"Penguins Only Shop","music":true,"now":{"clothing":[],"den":[1016,1017,1018,1019,1020,1021,1039]},"former":{"clothing":[],"den":[]}}, +"107":{"shop":"Freedom Shop","now":{"clothing":[1530,978,976,1528,977,973,1529,1531,975,1217,1216,1532],"den":[2175,1052,5585,2186,3237,2176,2179,2181,1051,3238,2183,2178,2182]},"former":{"clothing":[612,439,441,440,613,781,974,614,783,444,443,442,782],"den":[1054,1049,2180,2185,1050,2177,2184,1053]}}, +"108":{"shop":"Freedom Shop","now":{"clothing":[1530,978,976,1528,977,973,1529,1531,975,1217,1216,1532],"den":[2175,1052,5585,2186,3237,2176,2179,2181,1051,3238,2183,2178,2182]},"former":{"clothing":[612,439,441,440,613,781,974,614,783,444,443,442,782],"den":[1054,1049,2180,2185,1050,2177,2184,1053]}}, +"111":{"shop":"Pets Only Shop","music":false,"now":{"clothing":[],"den":[580,579,630,1078,955,952,950,942,943,631,916,918,917,582,581,1090,946,945,944,953,610,954,951]},"former":{"clothing":[],"den":[]}}, +"112":{"shop":"Pets Only Shop","music":true,"now":{"clothing":[],"den":[580,579,630,1078,955,952,950,942,943,631,916,918,917,582,581,1090,946,945,944,953,610,954,951]},"former":{"clothing":[],"den":[]}}, +"113":{"shop":"Treetop Gardens","now":{"clothing":[],"den":[1552,13,1636,2309,1578,2305,9,2310,2115,1525,2311,1509,1510,2321,2322,2306,1551,1131,1553,2096,5608,2308,27,3562]},"former":{"clothing":[],"den":[2302,391,2303,2284,2285,5662,5663,2412,5665,5664,2304,16,1583,5434,1582,4086,250,1893,1894,436,2325,2324,2090,1447,5673,5674,5676,1145,1912,1913,2095,1154,392,4314,4845,2194,2195,2435,5671,5672,5675,5669,5670,1415,460,481,2170,2171,3454,2411,1630,3430,3428,1152,2555,2401,3429,3453,4835,2018,2020,432,433,431,1130,4386,4384,4387,4385,4389,4388,3525,5435,2326,2328,5666,5668,5508,2529,2530,2597,2528,482,2912,1488,845,97,1908,1909,1870,2402,2042,2043,2074,1960,5432,389,2019,5430,5429,3064,5506,1546,2089,774,390,1992,1994,5431,5433,86,5507,1102,1512,1519,1602,5538,5428,5667]}}, +"116":{"shop":"Monkeys Only Shop","music":false,"now":{"clothing":[],"den":[1107,1099,1108,1105,1104,1106,1111]},"former":{"clothing":[],"den":[]}}, +"117":{"shop":"Monkeys Only Shop","music":true,"now":{"clothing":[],"den":[1107,1099,1108,1105,1104,1106,1111]},"former":{"clothing":[],"den":[]}}, +"118":{"shop":"AJ Birthday Shop","music":false,"now":{"clothing":[1020,1019,1018,1017,1016,1015],"den":[3358,3357,3089,3079,3020,3018,3022,2707,2633,2626,2623,2336,2158,2004,1816,1758,1753,1755,1754,1301,1752,1759,1756,1757,1302,1114,1115,3354,1116,1117,3353,3356,3355,1118,1119,1120,1121,1122,1123,1124,1125,1127,1126,3875,3874,5001,5177,5392,5616,5893,2827,2825,2826,2823,2822,2824,1128]},"former":{"clothing":[],"den":[]}}, +"119":{"shop":"AJ Birthday Shop","music":true,"now":{"clothing":[1020,1019,1018,1017,1016,1015],"den":[3358,3357,3089,3079,3020,3018,3022,2707,2633,2626,2623,2336,2158,2004,1816,1758,1753,1755,1754,1301,1752,1759,1756,1757,1302,1114,1115,3354,1116,1117,3353,3356,3355,1118,1119,1120,1121,1122,1123,1124,1125,1127,1126,3875,3874,5001,5177,5392,5616,5893,2827,2825,2826,2823,2822,2824,1128]},"former":{"clothing":[],"den":[]}}, +"122":{"shop":"Haunted Forest Shop","now":{"clothing":[1042,1028,1041,1040,500,499],"den":[3344,3338,2854,2342,2338,399,400,2346,1570,693]},"former":{"clothing":[],"den":[]}}, +"123":{"shop":"Haunted Forest Shop","music":false,"now":{"clothing":[1042,1028,1041,1040,500,499],"den":[3344,3338,2854,2342,2338,399,400,2346,1570,693]},"former":{"clothing":[],"den":[]}}, +"124":{"shop":"Haunted Forest Shop","music":true,"now":{"clothing":[1042,1028,1041,1040,500,499],"den":[3344,3338,2854,2342,2338,399,400,2346,1570,693]},"former":{"clothing":[],"den":[]}}, +"138":{"shop":"Jamaaliday Shop","music":true,"now":{"clothing":[1690,1062,1681,1725,1724,1678,1956,1084,1679],"den":[717,733,1350,739,3954,2460,2433,1836,428,3463,3464,1837,737,2435,1348,3956,3957,3955,2909,3935,2885,2883,429,1364,1366,744,751,734,3934,1933,3953,754,1367]},"former":{"clothing":[1312,851,692,1067,1052,1328,1329,1330,1327,1331,872,1063,1957,527,247,1959,693,2408,2409,2411,2406,2407,2410,245,1960],"den":[3801,2434,1362,736,4751,3799,427,3960,3800,3959,3958,4744,3462,738,3461,425,1365,4745,2437,3807,2438,3768,3767,1935,432,431,3806,2770,3798,1349,1934,3805,3802,3804,4746,4753,3803,4754,426,1363]}}, +"143":{"shop":"New Year's Shop","now":{"clothing":[4202,4203,4204,4205,4206,4207,4208,4209,879,1727,482,401,257,290,254],"den":[5710,2478,2481,2482,3490,5035,3489,3488,615,616,754,693]},"former":{"clothing":[],"den":[]}}, +"144":{"shop":"New Year's Shop","music":false,"now":{"clothing":[4202,4203,4204,4205,4206,4207,4208,4209,879,1727,482,401,257,290,254],"den":[5710,2478,2481,2482,3490,5035,3489,3488,615,616,754,693]},"former":{"clothing":[],"den":[]}}, +"145":{"shop":"New Year's Shop","music":true,"now":{"clothing":[4202,4203,4204,4205,4206,4207,4208,4209,879,1727,482,401,257,290,254],"den":[5710,2478,2481,2482,3490,5035,3489,3488,615,616,754,693]},"former":{"clothing":[],"den":[]}}, +"150":{"shop":"Paradise Shop","now":{"clothing":[],"den":[1199,1191,1192,1194,1196,1193,1195]},"former":{"clothing":[],"den":[]}}, +"161":{"shop":"Jam Session Shop","now":{"clothing":[590,591,589,579,582,580],"den":[2658,2657,2655,2653,2648,2647,2646,1266,1265,1260,1257,1258,1259,1246]},"former":{"clothing":[],"den":[]}}, +"163":{"shop":"Jam Session Shop","music":true,"now":{"clothing":[590,591,589,579,582,580],"den":[2658,2657,2655,2653,2648,2647,2646,1266,1265,1260,1257,1258,1259,1246]},"former":{"clothing":[],"den":[]}}, +"164":{"shop":"Jam Session Shop","music":false,"now":{"clothing":[590,591,589,579,582,580],"den":[2658,2657,2655,2653,2648,2647,2646,1266,1265,1260,1257,1258,1259,1246]},"former":{"clothing":[],"den":[]}}, +"167":{"shop":"Diamond Shop","music":false,"now":{"clothing":[],"den":[3485,3613,1279,2576,649,5561,2565,5562,4423,4403,4404,4405,4406,4511,4509,3400,4499,4487,4505,4508,4498,4488,4504,4489,4502,4493,4496,4483,4491,4486,4503,4501,4490,4495,4500,4497,4494,4506,4485,4507,4484,4492,3159,3153,4407,4408,4409,4410,4411,4412,4413,4476,4480,4481,4478,4479,4477,5593,5594,4422,4420,4421,4418,4414,4415,4416,4417,4419,895,3140,2947,66,2279,3993,1278,3042,5654,5655,1673,4159,4512,4510,3620,948,3409,3370,3360,3366,3364,3359,3363,3365,3361,742,4425,4431,4429,4427,4426,4430,4428,4441,4442,4443,4438,4437,4439,4440,4151,1610,5301,4150,4432,4435,4436,4433,4424,4154,4156,1478,2610,2247,1683,2250,3659,3060,3662,1921,2224,2645,1679,2641,3661,2863,1919,2225,2611,1346,2851,1680,2442,2245,2226,3051,2246,2443,2441,1681,2445,2249,1682,1917,3053,2444,1918,3660,1922,1920,3059,3058,2248,1684,3052,1623,650,4157,4153,4152,4473,4472,4474,4475]},"former":{"clothing":[],"den":[4603,4608,4606,4607,4206,5075,4636,3314,4265,2839,2842,2841,2840,3407,3408,2843,3271,4947,4946,4949,3788,3783,3790,3787,3784,4360,2514,3764,5656,5124,5113,5122,4641,4369,4632,5552,3830,4574,4582,4576,3794,3782,5078,4827,4822,4823,4834,4833,4830,4829,4824,4828,4825,4831,4826,5405,4226,4197,4194,4195,4186,4188,4189,4190,4185,4193,4187,4191,5883,5879,5885,5877,5881,5878,5880,5886,5882,4680,4675,4674,4676,4685,4677,4684,4683,4682,4679,4681,4678,4376,3792,3740,5328,704,4896,3822,3820,3821,3819,3227,5376,5789,5781,5785,5790,5784,5787,5780,5782,5786,5788,5783,4232,1070,5072,3229,3288,4239,3930,4137,3041,2110,2118,3040,2120,3329,5119,5120,5409,5174,3848,5331,5337,5558,2606,4601,4572,3849,2812,3319,4148,4149,3813,5140,3629,5556,5559,5555,4217,3169,1872,4270,3694,3689,3684,3685,3688,3692,3313,3686,3683,3687,3693,3691,3690,5540,5543,5546,5545,5547,5544,5541,5542,4372,4128,3749,3748,4131,5184,5179,5180,5181,5182,5183,5199,5201,5210,5202,5203,5205,5204,5200,5206,5207,5208,5209,5211,5212,4379,5058,5059,5062,5063,5057,5066,5067,5065,5064,5061,5060,4166,4165,4167,4639,4640,4935,3121,4233,4579,4637,5085,3844,4578,4299,4271,4269,3763,3816,5068,3811,5135,4267,4171,4172,4170,4168,4164,3845,3165,3167,3818,4301,4302,4300,4303,3739,3733,3731,3730,3729,3735,3737,3728,3727,3736,3732,3734,5101,3281,3624,3623,3675,3669,3666,3674,3672,3670,3673,3676,3665,3667,3671,3668,2312,2314,2313,5229,5230,5220,4224,4263,4264,4266,3745,4331,4136,5114,5553,5310,5551,4219,3282,4050,4044,4075,4048,4078,4077,4076,4045,4079,4080,4047,3268,2790,2791,5307,5175,3541,5315,4018,4008,4013,4024,4012,4015,4007,4009,4014,4017,4011,3544,3540,3542,3543,5103,4334,2871,2872,2873,4333,2870,5407,5125,5126,5127,5128,5129,5130,5131,5132,5133,5134,4237,4236,4235,5311,5312,5305,3741,3747,5306,3742,5309,3746,3352,3347,3350,3348,3346,3351,3349,4658,2616,1273,3809,5136,4192,3326,1249,3726,3094,3379,1359,4638,5408,1773,2629,3385,4049,3927,2619,1641,1300,3028,1268,2161,2343,3650,5843,3823,1747,2002,3796,2713,1811,5410,4906,4897,3725,4642,5406,3797,3085,3077,1274,3107,3030,3828,4298,3923,3929,3925,3921,3924,3926,3920,1160,3922,3847,3861,3867,3858,3864,3863,3860,3868,3857,3865,3859,3869,5487,5489,5488,5486,5485,5492,5490,5491,4268,3627,3309,3310,3308,5564,5565,3631,4577,3931,3125,3779,3269,3862,866,3619,3835,3836,3841,3840,3870,3834,2475,5316,5317,4231,2651,2649,2650,3778,3647,3652,3646,3648,3649,5335,4339,4335,4338,4337,4330,5069,4934,5144,5143,4926,4929,5142,4933,4598,4602,4597,3176,4631,1449,5381,3312,5219,1915,3766,3846,4133,3721,5145,5146,5147,5148,5149,5150,5151,5152,5153,5154,5155,5156,5030,5019,5008,5032,5023,5016,5013,5014,5026,5021,5025,5004,5002,5033,5006,5015,5010,5028,5022,5018,5020,5017,5012,5007,5027,5034,5003,5005,5024,5011,5009,5029,5031,4209,4208,4207,4203,4200,4205,4201,4202,4204,5343,5341,5342,5338,5344,5347,5340,5339,5345,5346,3166,3780,4635,3318,3977,3988,3982,3979,3981,3987,3983,3985,3978,3986,3976,3980,4373,4370,4368,4708,4707,5326,3287,4218,4223,3817,4581,4604,4381,4229,4228,5100,2500,2499,2495,4580,1270,5185,5187,5196,5188,5189,5191,5190,5186,5192,5193,5194,5195,5197,5198,4132,5550,3626,4936,5117,3793,3795,3317,4850,2083,4852,4854,4856,4859,4851,4862,4861,4857,4860,4853,4855,4032,4026,4029,4030,4028,4037,4031,4027,4035,4033,4034,4036,4382,4135,3744,4134,5118,3932,5592,5591,5587,5589,5590,5588,4216,4222,4221,4220,2786,2787,2788,5350,5352,5353,5354,3789,4759,4768,4764,4760,4763,4767,4762,4769,4761,4765,4766,4770,5844,5845,5846,5847,5848,5849,5850,5851,5852,5853,4937,3170,3785,3786,4633,3316,5384,3190,3781,4073,4088,4074,4019,4087,3722,3278,4199,63,5833,5834,5835,5836,5837,5838,5839,5840,5841,5842,3720,3719,4214,4296,4295,4294,4125,5557,3750,3714,3716,3708,3710,2718,3712,3709,3715,3717,3713,3718,3707,3711,3221,3219,3217,5089,5083,5086,5084,5091,5092,5090,5082,5093,5087,5081,5088,5116,3628,5123,3164,5377,4548,4605,3814,5137,5643,5638,5639,3106,3618,5077,5640,5642,3114,1534,5637,5641,5076,3228,3290,4169,3284,3184,5573,5574,5575,5577,5580,5570,5579,5572,5578,5576,5571,5569,4262,5169,5170,5171,3761,2415,2414,2416,2413,3279,3274,3187,4930,4932,4928,3824,5318,5314,3037,3277,5791,1272,4903,4905,4904,4898,4901,4902,1269,3289,5104,4895,4899,4900,5303,5157,5163,5159,5164,5160,5165,5161,5166,5162,5167,5158,5168,4575,4599,4375,3230,4127,4982,4985,4978,4975,4977,4983,4981,4980,4984,4979,4974,4976,731,4703,4698,4697,4700,4704,4699,4706,4705,4702,4701,5070,5102,5357,5121,5080,3275,3283,3635,3743,3634,3633,5079,3315,5351,5356,5349,5375,5176,5172,5173,5382,5378,5379,5380,5383,5568,5566,5567,5097,5098,5095,5094,5099,5096,3276,3273,4931,4927,4158,3723,4155,5554,3630,2803,5074,4225,5334,1271,5333,5336,3760,5325,5320,5322,5324,5332,4240,4600,2566,3272,4667,4668,4669,4659,4666,4662,4664,4660,4663,4661,4665,5854,3843,3188,3832,5400,5396,5399,5401,5398,5397,3833,3839,3765,3831,3837,3838,3762,2146,3122,3105,3111,3110,3109,3108,5829,5828,5330,4571,4378,4358,3280,4353,5744,5746,4351,5745,5742,4354,4355,5743,5740,5741,4352,4349,4356,4350,4357,4293,5071,4371,4336,3812,5141,5321,5115,5313,4380,3196,3270,4238,4215,5355,3632,4634,5830,5831,5827,5826,5651,3724,3791,5549,3267,5073,4573,5308,3126,4129,4332,1884,4198,4546,4547,4557,4554,4553,4556,4551,4552,4550,4555,4549,5323,4130,4241,4234,3826,3829,3825,3827,5112,5108,5106,5105,5109,5107,5110,5111,3808,3810,3323,4800,4802,4798,4797,4807,4806,4805,4799,4796,4804,4803,4801,4377,3842,5138,5139,5304,3285,5327,4359,5747,5749,5748,5751,5750,4329,3286,5329,5548,3173,4297,5221,5222,5223,5224,5225,5226,5227,5228]}}, +"168":{"shop":"Diamond Shop","now":{"clothing":[1352,1353,1354,1351,1355,1573,735,734,736,733,737,608,607,606,609,610,772,567,584,568,773,569],"den":[]},"former":{"clothing":[2968,2969,2970,2967,2971,1875,2722,2723,2724,3280,3281,3279,3283,3285,3286,3287,3284,3288,3353,3355,3023,3024,3025,3022,3026,2325,2324,2322,4081,3628,3626,2918,2919,2920,2917,2921,4013,4011,4014,2769,2770,2771,2874,2875,2872,4408,3933,4385,3931,3932,4378,4330,4329,3834,4239,4240,4241,4238,4242,1333,1067,2844,2842,2843,1370,1371,1368,1372,3246,3244,3506,3359,3360,3361,3358,3362,4095,2923,2924,2925,2922,2926,2963,2964,2965,2962,2966,2302,2303,2304,1893,815,816,817,814,818,2794,2795,2796,2793,2797,376,3523,3525,3526,3153,3155,3178,3180,2958,2959,2960,2957,2961,3763,2639,2641,2642,2562,2563,2564,2561,2565,1395,1396,1397,1394,1398,1524,1525,1520,885,1738,886,1739,887,1740,884,1737,3429,3430,3428,3432,888,1741,3803,3804,3805,3802,3806,2713,2714,2715,2712,2716,1328,1329,1330,1327,1331,2804,2805,2806,2803,2807,2538,3847,3848,3846,3849,2516,2517,2513,2515,2518,3606,3604,3842,3843,3844,3841,3845,3938,3936,3937,3308,3309,3310,3307,3311,3313,3314,3315,3312,3316,2879,2880,2877,2493,1916,2558,2559,2556,1917,686,687,1891,2301,2913,2914,2915,2912,2916,688,685,689,2708,2709,2711,2242,3745,3743,3747,2246,4158,4365,2283,2281,3623,3625,4322,4321,4360,1828,1829,3434,3435,3436,3433,3437,3261,3262,3260,3264,3266,3267,3268,3265,3269,2741,2742,2743,2740,2744,2336,3451,3752,4071,2903,2904,2905,2902,2906,3033,3034,3035,3032,3036,3928,3926,3927,3457,3458,3459,3456,3460,2979,2799,2800,2801,2798,2802,3039,3037,4403,958,1783,959,1784,960,1785,957,1782,961,1786,3863,3865,3866,3867,3864,3868,914,915,916,913,917,1149,1150,1151,1148,1152,2869,2870,2867,2434,2431,2436,2430,3497,3496,3499,1301,2736,2084,2085,2086,2087,1303,2488,2490,2491,1304,4034,4035,4036,4033,4037,3569,3570,3568,3572,4326,4325,3018,3019,3017,3021,3921,3474,3472,3473,2751,2752,2753,2750,2754,3564,3565,3566,3563,3567,3177,3170,3838,1385,3490,3491,3492,3489,3493,2004,3487,2839,2837,2838,2820,4481,2467,2468,2469,4413,2002,2470,2466,1497,1825,3105,2619,2620,2621,2618,2622,2634,2635,2633,2637,2849,2847,2848,2006,1892,2312,2310,4387,4388,4386,4389,1925,640,641,642,639,643,4074,4075,4077],"den":[]}}, +"173":{"shop":"Diamond Shop","music":true,"now":{"clothing":[],"den":[3485,3442,3433,3613,1279,2576,3436,649,5561,2565,3563,3564,5562,3565,3483,3447,4423,3566,3759,4403,4404,4405,4406,3567,4511,3587,3484,3588,3568,4509,3400,3439,4499,4487,4505,4508,4498,4488,4504,4489,4502,4493,4496,4483,4491,4486,4503,4501,4490,4495,4500,4497,4494,4506,4485,4507,4484,4492,3159,3486,3569,3153,4407,4408,4409,4410,4411,4412,4413,4476,4480,4481,4478,4479,4477,5593,5594,4422,4420,4421,4418,4414,4415,4416,4417,4419,3570,895,3571,3572,3445,3482,3573,3140,3481,3702,2947,66,2279,3574,3993,1278,3042,5654,5655,1673,4159,3575,3487,3576,3444,4512,3441,4510,3620,948,3409,3577,3578,3370,3360,3366,3364,3359,3363,3365,3361,3701,3579,3581,742,4425,4431,4429,4427,4426,4430,4428,4441,4442,4443,4438,4437,4439,4440,3758,4151,3582,3440,3583,3584,3446,1610,5301,3435,4150,4432,4435,4436,4433,4424,4154,4156,1478,2610,2247,1683,2250,3659,3060,3662,1921,2224,2645,1679,2641,3661,2863,1919,2225,2611,1346,2851,1680,2442,2245,2226,3051,2246,2443,2441,1681,2445,2249,1682,1917,3053,2444,1918,3660,1922,1920,3059,3058,2248,1684,3052,1623,3443,3586,650,4157,4153,4152,3438,4473,4472,4474,4475]},"former":{"clothing":[],"den":[4603,4608,4606,4607,4206,5075,4636,3314,4265,2839,2842,2841,2840,3407,3408,2843,3271,4947,4946,4949,3788,3783,3790,3787,3784,4360,2514,3764,5656,5124,5113,5122,4641,4369,4632,5552,3830,4574,4582,4576,3794,3782,5078,4827,4822,4823,4834,4833,4830,4829,4824,4828,4825,4831,4826,5405,4226,4197,4194,4195,4186,4188,4189,4190,4185,4193,4187,4191,5883,5879,5885,5877,5881,5878,5880,5886,5882,4680,4675,4674,4676,4685,4677,4684,4683,4682,4679,4681,4678,4376,3792,3740,5328,704,4896,3822,3820,3821,3819,3227,5376,5789,5781,5785,5790,5784,5787,5780,5782,5786,5788,5783,4232,1070,5072,3229,3288,4239,3930,4137,3041,2110,2118,3040,2120,3329,5119,5120,5409,5174,3848,5331,5337,5558,2606,4601,4572,3849,2812,3319,4148,4149,3813,5140,3629,5556,5559,5555,4217,3169,1872,4270,3694,3689,3684,3685,3688,3692,3313,3686,3683,3687,3693,3691,3690,5540,5543,5546,5545,5547,5544,5541,5542,4372,4128,3749,3748,4131,5184,5179,5180,5181,5182,5183,5199,5201,5210,5202,5203,5205,5204,5200,5206,5207,5208,5209,5211,5212,4379,5058,5059,5062,5063,5057,5066,5067,5065,5064,5061,5060,4166,4165,4167,4639,4640,4935,3121,4233,4579,4637,5085,3844,4578,4299,4271,4269,3763,3816,5068,3811,5135,4267,4171,4172,4170,4168,4164,3845,3165,3167,3818,4301,4302,4300,4303,3739,3733,3731,3730,3729,3735,3737,3728,3727,3736,3732,3734,5101,3281,3624,3623,3675,3669,3666,3674,3672,3670,3673,3676,3665,3667,3671,3668,2312,2314,2313,5229,5230,5220,4224,4263,4264,4266,3745,4331,4136,5114,5553,5310,5551,4219,3282,4050,4044,4075,4048,4078,4077,4076,4045,4079,4080,4047,3268,2790,2791,5307,5175,3541,5315,4018,4008,4013,4024,4012,4015,4007,4009,4014,4017,4011,3544,3540,3542,3543,5103,4334,2871,2872,2873,4333,2870,5407,5125,5126,5127,5128,5129,5130,5131,5132,5133,5134,4237,4236,4235,5311,5312,5305,3741,3747,5306,3742,5309,3746,3352,3347,3350,3348,3346,3351,3349,4658,2616,1273,3809,5136,4192,3326,1249,3726,3094,3379,1359,4638,5408,1773,2629,3385,4049,3927,2619,1641,1300,3028,1268,2161,2343,3650,5843,3823,1747,2002,3796,2713,1811,5410,4906,4897,3725,4642,5406,3797,3085,3077,1274,3107,3030,3828,4298,3923,3929,3925,3921,3924,3926,3920,1160,3922,3847,3861,3867,3858,3864,3863,3860,3868,3857,3865,3859,3869,5487,5489,5488,5486,5485,5492,5490,5491,4268,3627,3309,3310,3308,5564,5565,3631,4577,3931,3125,3779,3269,3862,866,3619,3835,3836,3841,3840,3870,3834,2475,5316,5317,4231,2651,2649,2650,3778,3647,3652,3646,3648,3649,5335,4339,4335,4338,4337,4330,5069,4934,5144,5143,4926,4929,5142,4933,4598,4602,4597,3176,4631,1449,5381,3312,5219,1915,3766,3846,4133,3721,5145,5146,5147,5148,5149,5150,5151,5152,5153,5154,5155,5156,5030,5019,5008,5032,5023,5016,5013,5014,5026,5021,5025,5004,5002,5033,5006,5015,5010,5028,5022,5018,5020,5017,5012,5007,5027,5034,5003,5005,5024,5011,5009,5029,5031,4209,4208,4207,4203,4200,4205,4201,4202,4204,5343,5341,5342,5338,5344,5347,5340,5339,5345,5346,3166,3780,4635,3318,3977,3988,3982,3979,3981,3987,3983,3985,3978,3986,3976,3980,4373,4370,4368,4708,4707,5326,3287,4218,4223,3817,4581,4604,4381,4229,4228,5100,2500,2499,2495,4580,1270,5185,5187,5196,5188,5189,5191,5190,5186,5192,5193,5194,5195,5197,5198,4132,5550,3626,4936,5117,3793,3795,3317,4850,2083,4852,4854,4856,4859,4851,4862,4861,4857,4860,4853,4855,4032,4026,4029,4030,4028,4037,4031,4027,4035,4033,4034,4036,4382,4135,3744,4134,5118,3932,5592,5591,5587,5589,5590,5588,4216,4222,4221,4220,2786,2787,2788,5350,5352,5353,5354,3789,4759,4768,4764,4760,4763,4767,4762,4769,4761,4765,4766,4770,5844,5845,5846,5847,5848,5849,5850,5851,5852,5853,4937,3170,3785,3786,4633,3316,5384,3190,3781,4073,4088,4074,4019,4087,3722,3278,4199,63,5833,5834,5835,5836,5837,5838,5839,5840,5841,5842,3720,3719,4214,4296,4295,4294,4125,5557,3750,3714,3716,3708,3710,2718,3712,3709,3715,3717,3713,3718,3707,3711,3221,3219,3217,5089,5083,5086,5084,5091,5092,5090,5082,5093,5087,5081,5088,5116,3628,5123,3164,5377,4548,4605,3814,5137,5643,5638,5639,3106,3618,5077,5640,5642,3114,1534,5637,5641,5076,3228,3290,4169,3284,3184,5573,5574,5575,5577,5580,5570,5579,5572,5578,5576,5571,5569,4262,5169,5170,5171,3761,2415,2414,2416,2413,3279,3274,3187,4930,4932,4928,3824,5318,5314,3037,3277,5791,1272,4903,4905,4904,4898,4901,4902,1269,3289,5104,4895,4899,4900,5303,5157,5163,5159,5164,5160,5165,5161,5166,5162,5167,5158,5168,4575,4599,4375,3230,4127,4982,4985,4978,4975,4977,4983,4981,4980,4984,4979,4974,4976,731,4703,4698,4697,4700,4704,4699,4706,4705,4702,4701,5070,5102,5357,5121,5080,3275,3283,3635,3743,3634,3633,5079,3315,5351,5356,5349,5375,5176,5172,5173,5382,5378,5379,5380,5383,5568,5566,5567,5097,5098,5095,5094,5099,5096,3276,3273,4931,4927,4158,3723,4155,5554,3630,2803,5074,4225,5334,1271,5333,5336,3760,5325,5320,5322,5324,5332,4240,4600,2566,3272,4667,4668,4669,4659,4666,4662,4664,4660,4663,4661,4665,5854,3843,3188,3832,5400,5396,5399,5401,5398,5397,3833,3839,3765,3831,3837,3838,3762,2146,3122,3105,3111,3110,3109,3108,5829,5828,5330,4571,4378,4358,3280,4353,5744,5746,4351,5745,5742,4354,4355,5743,5740,5741,4352,4349,4356,4350,4357,4293,5071,4371,4336,3812,5141,5321,5115,5313,4380,3196,3270,4238,4215,5355,3632,4634,5830,5831,5827,5826,5651,3724,3791,5549,3267,5073,4573,5308,3126,4129,4332,1884,4198,4546,4547,4557,4554,4553,4556,4551,4552,4550,4555,4549,5323,4130,4241,4234,3826,3829,3825,3827,5112,5108,5106,5105,5109,5107,5110,5111,3808,3810,3323,4800,4802,4798,4797,4807,4806,4805,4799,4796,4804,4803,4801,4377,3842,5138,5139,5304,3285,5327,4359,5747,5749,5748,5751,5750,4329,3286,5329,5548,3173,4297,5221,5222,5223,5224,5225,5226,5227,5228]}}, +"177":{"shop":"Outback Imports","now":{"clothing":[],"den":[2297,2680,1559,1558,1444,1453,1514,47,48,49,53,1631,1562,1560,164,2299]},"former":{"clothing":[],"den":[3431,399,5635,1771,1968,1972,1570,736,2114,44,4068,2999,739,4781,403,1971,1965,404,1969,3959,3958,3463,3464,3462,3461,45,425,1566,2859,2858,2860,2856,2857,2862,1941,1943,1961,1944,1967,1942,1966,3000,2473,2474,2472,2464,2466,1365,46,1446,4005,2867,3523,1349,1520,4038,2548,4883,4002,933,2869,5707,5708,3989,1565,1572,1585,1574,4054,3590,2201,2213,2198,2203,2202,2197,2211,2212,2205,2206,2204,2210,54,4779,3005,3001,3002,1363,2644,4840,5793]}}, +"178":{"shop":"Hospital Shop","now":{"clothing":[658,655,659,657,654,656],"den":[]},"former":{"clothing":[660,980,1246,2644,985],"den":[]}}, +"179":{"shop":"Adventure Shop","now":{"clothing":[],"den":[1316,1318,1317,1321,1320,1319]},"former":{"clothing":[],"den":[]}}, +"184":{"shop":"Museum Shop","now":{"clothing":[127,128,123,552,129,131,1117],"den":[]},"former":{"clothing":[224,439,441,440,781,444,443,442,782,495,132,398,3028,3753,3365,997,4200,3874,4369,3276,3773,4028,3097,4291,3562,3257,2732,3807,4046,3379,2719,4082,2643,2974,3854,3195,798,1014,2749,2900,3691,4132,3479,3466,3633,3350,3030,3095,3003,3955,3601,3440,4243,840,220,839],"den":[]}}, +"191":{"shop":"Play-As-Your-Pet Shop","music":false,"now":{"clothing":[],"den":[1339,1334,1341,1338,1347,1336,1337,1340,1355,1333,1342,1332,1335]},"former":{"clothing":[],"den":[]}}, +"192":{"shop":"Play-As-Your-Pet Shop","music":false,"now":{"clothing":[],"den":[1339,1334,1341,1338,1347,1336,1337,1340,1355,1333,1342,1332,1335]},"former":{"clothing":[],"den":[]}}, +"193":{"shop":"Play-As-Your-Pet Shop","music":true,"now":{"clothing":[],"den":[1339,1334,1341,1338,1347,1336,1337,1340,1355,1333,1342,1332,1335]},"former":{"clothing":[],"den":[]}}, +"212":{"shop":"Royal Ridge","now":{"clothing":[],"den":[1548,1465,1466,1467,1464,1469,1470]},"former":{"clothing":[],"den":[]}}, +"216":{"shop":"April Fools' Shop","now":{"clothing":[1427,922,1156,740,923,1428,921,920],"den":[4893,4892,4891,4889,4887,4894,4888,4890,4878,4865,4863,4866,4471,4470,4482,4461,4463,3595,3600,3597,3598,2031,2038,2033,2035,2039,3596,912,909,907,910,908,911]},"former":{"clothing":[],"den":[]}}, +"234":{"shop":"Jam Mart Furniture (New Jammer)","now":{"clothing":[],"den":[338,131,295,647,152,357]},"former":{"clothing":[],"den":[]}}, +"238":{"shop":"Beta Shop","now":{"clothing":[],"den":[1674,1670,5618,1672,4925,4924,4921,4920,4922,1651,4923,1652,1675,5621,1659,5617,1667,5623,1660,1668,5619,1661,19,21,5631,5626,5630,5632,5624,5628,5627,5625,5629]},"former":{"clothing":[],"den":[3242,3247,3252,3253,1671,3254,3245,3243,3246,3251,3248,3255,3244]}}, +"250":{"shop":"Marine Marvels","now":{"clothing":[],"den":[1796,1798,1795,1797]},"former":{"clothing":[],"den":[]}}, +"271":{"shop":"Bounce House Shop","now":{"clothing":[],"den":[2578,1863,1862,1860,1859,1858,1856]},"former":{"clothing":[],"den":[]}}, +"323":{"shop":"Topiary Shop","now":{"clothing":[],"den":[2617,1432,642,1251,3913,3091,3373,714,1361,3904,1433,707,2630,3381,1066,971,2613,676,748,1642,1434,675,2941,1428,2155,2332,633,3391,1716,1997,608,808,1452,2711,1812,1200,3914,677,3903,3387,3082,4141,2945,1427,607,2943,643]},"former":{"clothing":[],"den":[]}}, +"324":{"shop":"Cloud Shop","now":{"clothing":[962,963,964,965,966,967],"den":[2008,2001,1996,2007,1999,2009,1986,1987,1988,1989,1991,1993]},"former":{"clothing":[],"den":[]}}, +"325":{"shop":"Cloud Shop","now":{"clothing":[962,963,964,965,966,967],"den":[2008,2001,1996,2007,1999,2009,1986,1987,1988,1989,1991,1993]},"former":{"clothing":[],"den":[]}}, +"345":{"shop":"Schoolhouse Shop","now":{"clothing":[],"den":[2795,2796,2797,2798,2150,2149,2148,2145,2139,2142,2140,2141,2147]},"former":{"clothing":[],"den":[]}}, +"346":{"shop":"AJ Birthday Shop","now":{"clothing":[1020,1019,1018,1017,1016,1015],"den":[3358,3357,3089,3079,3020,3018,3022,2707,2633,2626,2623,2336,2158,2004,1816,1758,1753,1755,1754,1301,1752,1759,1756,1757,1302,1114,1115,3354,1116,1117,3353,3356,3355,1118,1119,1120,1121,1122,1123,1124,1125,1127,1126,3875,3874,5001,5177,5392,5616,5893,2827,2825,2826,2823,2822,2824,1128]},"former":{"clothing":[],"den":[]}}, +"362":{"shop":"Theater Shop","now":{"clothing":[],"den":[2128,2136,2129,2138,2135,2130,2131,2134,2137,2127,2132,2133]},"former":{"clothing":[],"den":[]}}, +"374":{"shop":"Astronomy Shop","now":{"clothing":[],"den":[2379,2386,2385,2390,2382,2392,2388,2380,2391,2383,2384]},"former":{"clothing":[],"den":[2387]}}, +"396":{"shop":"??? (Basement of Secrets)","now":{"clothing":[],"den":[2544,2543,2542]},"former":{"clothing":[],"den":[]}}, +"399":{"shop":"Chinese New Year Shop and others","now":{"clothing":[],"den":[2520,2522,2519,2521,2524,2523,3512,3551,3501,3502,3498,3500,5278,5279,5284,5282,5280,5281,5283,5764,5763,5765,5769,5766,5767,5768,2992,2988,2997,2993,2994,4786,4794,4787,4795,4784,4793,4792,2730,2720,2728,2721,2723,2724,2727,2722,2729,2726,5038,5039,5047,5036,5040,5042,5045,4317,4326,4320,4327,4319,4325,4324,2957,2958,2962,2963,2979,2976,5469,5470,5475,5473,5471,5472,5474,1660,1051,497,2178,2357,607,763]},"former":{"clothing":[],"den":[]}}, +"400":{"shop":"Candy Shop","now":{"clothing":[],"den":[2560,2567,2568,2557,2558,2561,2559,2569,2556,2563,2564,2562]},"former":{"clothing":[],"den":[]}}, +"415":{"shop":"Diamond Shop","now":{"clothing":[1352,1353,1354,1351,1355,1570,1572,1574,1571,1573,1554,1511,4531,4529,4532,4530,4533,273,570,1537,856,735,734,736,733,737,608,607,606,609,610,1232,1230,1231,1233,1234,1495,772,567,584,568,773,569,1485,1541],"den":[]},"former":{"clothing":[2968,2969,2970,2967,2971,2262,2263,2264,1876,1878,1877,1875,566,2722,2723,2724,2725,2721,3280,3281,3282,3279,3283,3285,3286,3287,3284,3288,1515,1519,3423,3420,3419,3422,2254,2253,2255,3421,2417,2418,2420,2419,2421,2947,2951,2950,2949,2948,3356,3353,3354,3355,3357,3023,3024,3025,3022,3026,2185,2184,1895,2227,2237,2228,2226,2225,2229,2231,2236,2230,563,2126,2325,2326,2324,2322,2328,4079,4081,4078,4080,3628,3630,3627,3626,3629,2992,2993,2991,2994,2995,2918,2919,2920,2917,2921,2101,4015,2176,2179,1948,4013,4012,4011,4014,4018,2173,4022,2174,4016,4021,2177,1361,4019,1362,4020,2175,2172,4017,2178,2180,2181,4023,2769,2770,2771,2768,2772,2997,2998,2996,2999,3000,2874,2875,2872,2873,2876,3541,3539,3540,3538,3537,4409,4408,4406,4407,4410,3896,3898,2940,2937,2938,2941,2939,3899,3897,3900,3935,4383,3933,4376,4379,4385,4381,4384,3931,4377,4380,3932,3934,4378,4382,2020,4330,4331,4329,4332,3831,3834,3833,3835,3832,4239,4240,4241,4238,4242,2138,2021,4259,4257,4256,4258,4260,1904,1066,1334,1333,1067,1088,1906,3971,3972,3974,3973,3975,2930,2927,2928,2931,2929,2846,2844,2842,2843,2845,3820,3821,3818,3822,3819,3220,3221,3223,3222,3224,1370,1371,1368,1369,1372,4348,4345,4347,4346,4349,3981,3982,3984,3983,3985,3246,3244,3247,3245,3248,3507,3505,3516,3515,3512,3509,3511,3514,3508,3510,3871,3506,3513,3359,3360,3361,3358,3362,4448,4446,4425,4450,4432,4437,4454,4440,4427,4457,4449,4435,4456,4451,4447,4426,4438,4452,4431,4443,4455,4441,4433,4444,4439,4453,4460,4429,4445,4458,4461,4434,4459,4436,4430,4428,4442,3869,3870,4095,4097,4098,4094,4096,4498,4497,4500,4501,4499,1822,1823,1824,1821,1820,2728,2726,2727,2730,2729,1462,1309,1310,2923,2924,2925,2922,2926,2439,1884,2018,1882,2440,2963,2964,2965,2962,2966,2860,2858,2857,2861,2859,3191,3192,3190,3194,3193,2952,2956,2955,2954,2953,3134,3140,2300,3143,3137,2302,3142,3135,3141,3136,3138,2303,2304,3139,1893,2791,2789,2792,2790,2788,815,816,817,814,818,1852,1512,1516,1496,270,1498,2829,2830,2831,2828,2827,4004,4001,4003,4002,4005,1563,1566,1562,1565,1564,2794,2795,2796,2793,2797,2125,2773,2774,2777,2775,2776,376,2444,565,2159,4009,4006,4008,4007,4010,2141,3117,3116,3114,3118,3115,2865,2863,2862,2866,2864,1935,1934,3294,3295,3297,3296,3298,3523,3524,3522,3525,3529,3528,3531,3530,3526,3527,2015,3153,3155,3152,3179,3156,3154,3172,3178,3176,3180,2958,2959,2960,2957,2961,1339,902,1550,1804,1551,1805,1549,1803,1552,1806,1553,1807,3763,3760,3761,3764,3762,2639,2641,2642,2638,2640,2824,2825,2826,2823,2822,2562,2563,2564,2561,2565,1860,1858,1857,1861,1859,2626,2624,2623,2627,2625,1395,1396,1397,1394,2019,1398,1993,1992,1991,1994,1995,3207,3206,3208,3204,3205,4286,4282,4284,4283,4285,3212,3210,3211,3209,3213,2441,1524,1525,1520,1521,1523,1522,885,1738,1347,886,1739,887,1740,884,1737,1746,1744,1745,1747,3429,3430,3431,3428,3432,888,1741,2156,2155,3803,3804,3805,3802,3806,2153,3800,3797,3799,3798,3801,2713,2714,2715,2712,2716,2443,4092,4093,4091,4089,4090,3417,3415,3416,3418,3414,3612,3610,3613,3609,3611,1328,1329,1330,1327,1331,3976,3977,3979,3978,3980,2804,2805,2806,2803,2807,2512,2524,2538,2505,3847,3848,3846,3849,2502,2539,2942,2946,2945,2504,2511,3850,2520,3851,2551,2531,3765,3766,3767,3768,3769,2510,2507,2508,2509,2536,2516,2517,2514,2513,2515,2518,2537,2521,2506,3606,3607,3604,3605,3608,2503,3842,3843,3844,3841,3845,2519,2944,2943,1546,1544,1545,3940,3938,3936,2935,2932,2933,2936,2934,3937,3939,3989,3988,3986,3987,3990,3308,3309,3310,3307,3311,3313,3314,3315,3312,3316,2879,2880,2877,2878,2881,2100,2493,2494,2492,2495,2496,1914,1916,1913,2558,2557,2559,2556,2560,1917,1915,1243,2143,2139,2122,2130,2129,2127,3889,3886,3887,3890,3888,686,687,1891,2301,2913,2914,2915,2912,2916,688,685,2158,1868,1865,1866,1869,1867,2442,689,2708,2709,2710,2707,2711,2243,2244,2245,2242,2247,3745,3746,3744,3743,3747,2246,2248,3370,3373,3371,3121,3122,3119,3120,3123,3374,878,3372,4155,4157,4158,4159,4156,1962,2093,3554,3547,3548,3551,3549,3550,3553,3552,3556,3555,4366,4363,4364,4365,4367,2283,2280,2281,2279,2282,2123,3624,3622,3623,3625,3621,271,1849,4322,4323,4321,4324,1931,1961,4361,4358,4359,4360,4362,1887,1890,1826,1828,1829,3883,3882,3884,3881,3885,1885,3434,3435,3436,3433,3437,3261,3262,3263,3260,3264,3266,3267,3268,3265,3269,3816,3813,3814,3817,3815,3453,2335,3455,2333,3187,3188,3185,3186,3189,2741,2742,2743,2740,2744,2336,2334,3452,3451,3454,2337,3748,3751,3749,3752,3750,1946,1359,1360,2855,2853,2852,2856,2854,2987,2988,2986,2989,2990,1463,2271,2786,2784,2269,2787,2272,2270,2785,2273,2783,1850,4070,4069,4068,4071,4072,3536,3534,3535,3533,3532,3965,3961,3964,3962,3963,272,1281,2437,2903,2904,2905,2902,2906,1604,1656,1659,1660,2134,3033,3034,3035,3032,3036,2140,3930,3928,3926,3927,3929,2186,4287,4288,4290,1835,1836,1838,1837,1839,1536,4314,4311,4313,4315,4316,4312,4317,4320,4318,4319,2814,2813,2812,2815,2816,3457,3458,3459,3456,3460,2016,2977,2979,2976,2980,2978,2799,2800,2801,2798,2802,3038,1460,1434,3039,3040,3037,3041,4163,4162,4160,4161,4164,1903,3228,3226,3229,3225,3227,4404,4403,4401,4402,2882,2883,2885,2884,2886,2096,2023,1282,1159,1169,1332,1244,1093,1436,1182,1229,1447,1209,1295,1459,1260,281,1183,1124,1048,3577,3573,3576,3574,3575,1905,2352,2353,2355,2356,2354,2234,2983,2982,2981,2984,2985,984,4145,4142,4143,4146,4144,4137,4140,4139,4138,4141,2892,2893,2895,2894,2896,1907,2128,1448,958,1783,959,1784,960,1785,957,1782,1365,1366,961,1786,3862,3859,3860,3861,3863,3865,3866,3867,3864,3868,914,915,916,913,917,1853,1258,1418,1417,1149,1150,1151,1148,1152,1416,1419,4368,1421,2013,1420,1855,1856,1854,3441,2869,2870,2867,2868,2871,2887,2888,2890,2889,2891,2434,2435,2428,2431,2436,2429,2430,2432,2433,4354,4357,4355,4353,4356,4351,4350,4352,4340,4342,4343,4341,4344,2233,2232,1163,1160,1161,2235,1162,3302,3300,3299,3301,3303,1883,3503,3497,3498,3496,3499,3502,3495,3500,3504,3494,3501,2005,3546,3544,3545,3543,3542,1301,2736,2737,2735,2738,2739,2084,2085,2083,2086,2087,1300,1302,2414,2415,2416,2413,2412,1303,2488,2489,2487,2490,2491,2157,1304,4034,4035,4036,4033,4037,3569,3570,3571,3568,3572,4041,4038,4039,4042,4040,2094,2097,2095,4326,4327,4325,4328,3018,3019,3020,3017,3021,4495,4494,4492,4493,4496,1886,3992,3922,3995,3925,3251,3252,3991,3921,3923,3249,3250,3924,4474,4477,4475,4478,4476,3916,3917,3918,3920,3919,3969,3968,3966,3967,3970,4306,4309,4307,4308,4310,4304,4301,4303,4302,4305,3476,3474,3469,3472,2757,2756,2755,2758,2759,3470,3467,3468,3471,3473,3475,2142,2751,2752,2753,2750,2754,3564,3565,3566,3563,3567,1336,1499,2022,2151,2152,2154,2150,1889,1363,1364,3901,3903,3904,3902,3905,3164,3160,3150,3163,3175,3157,3177,3158,3166,3174,3167,3173,3168,3149,3159,3148,3151,3147,3171,3162,3169,3165,3161,3170,3586,3587,3582,3583,3590,3591,3578,3579,3596,3597,3584,3585,3580,3581,3588,3589,3592,3593,3594,3595,634,1212,1514,1518,1450,635,1213,1449,1607,3639,3638,3641,3637,1605,1608,3640,1606,1609,1383,1387,3838,3839,3837,3840,3836,1382,1381,1385,3490,3491,1379,3241,3240,3242,3492,3239,3489,3243,3493,1389,1380,2004,1386,1390,1422,1423,1384,1388,3484,3487,3486,3488,3485,4227,4226,4224,4225,4228,1827,4265,4263,2343,4264,4261,2345,4262,2346,2344,2342,2841,2839,2837,2838,2840,1657,1658,564,666,667,2258,2124,2817,2819,2820,2821,2818,2017,4481,4482,4479,4480,4483,2467,2468,2463,2469,2464,2461,2462,2465,1502,1500,4414,4413,4411,2002,4412,1501,4415,1504,2781,2779,2782,2780,2778,2470,1503,2466,1888,2099,2131,2024,3999,3996,3998,3997,4000,1661,1662,2003,1497,1825,3107,3105,3106,3108,3109,2907,2908,2910,2911,2909,2098,2102,2619,2620,2621,2618,2622,1947,1881,2634,2635,2636,2633,2637,1461,2851,2849,2847,2848,2850,2205,2201,2207,2208,2206,2204,2203,2202,2006,1892,1894,2834,2835,2836,2833,2832,3891,3893,3894,3892,3895,1489,1486,1487,1490,1488,1167,2311,2312,2310,2314,2313,4464,4465,4462,4463,4387,4388,4386,4389,4468,4469,4466,4467,1925,1926,1927,1924,1928,3271,3274,3270,3273,2438,3272,3103,3100,3101,3104,3102,640,641,642,639,643,2135,2137,2136,1513,1517,1933,1932,1851,4074,4076,4075,4073,4077],"den":[]}}, +"420":{"shop":"Studio Corner","now":{"clothing":[],"den":[5509,1904,1914,1916,1911,1905,1906,1923,1924,1925,4957,1907,1928,1910,5510,4958,5609,5611]},"former":{"clothing":[],"den":[2924,3069,2718,3070,2923,3184,3012,5821,3071]}}, +"423":{"shop":"Epic Wonders","now":{"clothing":[],"den":[1177,956,728,1473,795,1157,1150,1170,2051,2041,2040,2054,2066,2052,1463,2067,1151,2276,850,1041,735,5607,3561,3293,851,4179,843,2315,2316,1217,1313,2193,730,921,1476]},"former":{"clothing":[],"den":[1178,1207,2792,1040,725,1576,3951,4116,4689,2477,4100,4282,1084,1264,1085,1222,1223,1263,1243,1242,1087,4089,2922,1208,922,3591,1209,4778,1522,2209,2270,5659,3455,2554,3505,4101,1176,4464,4466,4006,4842,4465,3960,4081,2447,1156,2448,1097,3876,3514,4841,852,803,1158,4211,4292,4106,3997,2030,2788,2675,1455,1457,1458,1435,1459,1456,2718,4112,1210,1215,1008,1132,3884,1009,5658,5660,1098,3184,4811,4817,802,4213,4212,4210,4333,5291,5761,5056,5467,731,1211,3635,3633,1216,5661,2353,804,2805,936,4777,1819,3936,2449,1845,729,4283,1137,4058,4053,4886,2359,1218,3933,1219,3992,2191,3503,4780]}}, +"584":{"shop":"??? (Epic Dens)","now":{"clothing":[],"den":[2643,2771,2400,2916,1351,2487,2407,1472,1489,3064,1599,2698,2711,3152,2360,3199,3215,3200,3203,3204,3206,3207,609,3376,2802,3411,1622,2337,3457,3477,3497,3506,1452,3510,3520,3524,3593,2809,3625,3622,3621,2642,2687,2406,2405,2927,2928,2933,2934,2935,2936,2794,2800,3888,3892,2485,3937,1637,1980,3991,3974,3995,4003,4046,4055,4061,4064,4099,4102,4109,4111,4124,4122,4121,4123,4120,4126,1852,4277,4284,4285,4288,4307,4315,4313,4391,4395,4448,4453,4462,4468,4521,4537,4558,4583,4588,4594,4612,4619,4621,4654,4693,4711,4730,4772,4843,4876,4885,4913,4944,4989,1947,2024,1975,2023,1974,2109,3291,2119,2116,5055,2751,2113,3261,1957,2106,2092,5178,3336,5213,3458,1571,5290,5300,5302,5319,5348,5370,5385,5393,5403,5404,5436,5468,5484,5493,2389,3147,2098,5581,5596,1042,5652,5677,5709,5760,5762,5794,5822,5824,2056,5873,5876,5925]},"former":{"clothing":[],"den":[]}}, +"589":{"shop":"Topiary Shop (Lit)","now":{"clothing":[],"den":[2618,1653,1380,1654,3916,3092,3374,1378,1383,3905,1655,1388,2631,3382,1376,1379,2614,1386,1644,1656,1387,2942,1658,2157,2333,1390,3392,1732,1998,1385,1384,2712,1813,1389,3915,1377,3906,1375,3388,3083,2946,1657,1381,2944,1382]},"former":{"clothing":[],"den":[]}}, +"625":{"shop":"Ocean Diamond Shop","now":{"clothing":[],"den":[3139,3144,3142,3138,3141,3143,3210,3214,3054,3056,3057,3055]},"former":{"clothing":[],"den":[]}}, +"626":{"shop":"Ocean Diamond Shop","now":{"clothing":[1455,1453,1456,1454],"den":[]},"former":{"clothing":[1945,3949,3948,3942,3941,3951,3952,3950,3943,3946,3947,3945,3944,1452,1451,4129,3993,3994],"den":[]}}, +"666":{"shop":"Forgotten Relics","now":{"clothing":[1590,1591,1592,1587,1588,1589,474],"den":[]},"former":{"clothing":[1959,1960],"den":[]}}, +"676":{"shop":"Alpha Headquarters","now":{"clothing":[1639,1640,1641,1638,1642],"den":[]},"former":{"clothing":[4506,2062,2063,2064,2061,2065,2381,2377,1712,1713,1714,1711,1715,2379,2378,2380],"den":[]}}, +"677":{"shop":"Alpha Headquarters","now":{"clothing":[1620,1621,1618,1622,1619],"den":[]},"former":{"clothing":[4505,2042,2043,2044,2041,2045,2366,2364,1692,1693,1694,1691,1695,2365,2363,2362],"den":[]}}, +"678":{"shop":"Alpha Headquarters","now":{"clothing":[1624,1625,1626,1623,1627],"den":[]},"former":{"clothing":[4507,2047,2048,2049,2046,2050,2357,2360,1697,1698,1699,1696,1700,2361,2359,2358],"den":[]}}, +"679":{"shop":"Alpha Headquarters","now":{"clothing":[1634,1635,1636,1633,1637],"den":[]},"former":{"clothing":[4504,2057,2058,2059,2056,2060,2375,2376,1707,1708,1709,1706,1710,2373,2372,2374],"den":[]}}, +"680":{"shop":"Alpha Headquarters","now":{"clothing":[1629,1630,1631,1628,1632],"den":[]},"former":{"clothing":[4502,2052,2053,2054,2051,2055,2369,2370,1702,1703,1704,1701,1705,2367,2371,2368],"den":[]}}, +"681":{"shop":"Alpha Headquarters","now":{"clothing":[1644,1645,1646,1643,1647],"den":[]},"former":{"clothing":[4503,2067,2068,2069,2066,2070,2382,2385,1717,1718,1719,1716,1720,2386,2384,2383],"den":[]}}, +"684":{"shop":"Diamond Shop","now":{"clothing":[],"den":[3440,3445,3447,3436,3433,3442,3439,3444,3441,3446,3435,3443,3438,3481,3482,3483,3484,3486,3487,3563,3564,3565,3566,3587,3588,3568,3569,3570,3571,3572,3573,3574,3584,3576,3577,3578,3586,3581,3579,3701,3702,3759,3758]},"former":{"clothing":[],"den":[]}}, +"687":{"shop":"Ancient Antiquities","now":{"clothing":[],"den":[3555,3556,3558,3557,3554,3559]},"former":{"clothing":[],"den":[4559,4562]}}, +"688":{"shop":"Ancient Armory","now":{"clothing":[1770,1771,1772,1769,1773,1899,1900,1901,1898,1902],"den":[]},"former":{"clothing":[],"den":[]}}, +"689":{"shop":"Diamond Shop","now":{"clothing":[],"den":[3567,3575,3582,3583]},"former":{"clothing":[],"den":[]}}, +"709":{"shop":"Giant Gift Pile (Shop)","now":{"clothing":[4165,4166,4167,4168,4169,4170,4171,4172,4173,4174,4175,4176,4177,4178,4179,4180,4181,4182,4183,4184,4185,4186,4187,4188,4189,4190,4191,4192,4193,4194,4195,4196],"den":[]},"former":{"clothing":[],"den":[]}}, +"713":{"shop":"Ancient Treasures","now":{"clothing":[],"den":[3850,3855,3851,3852,3854,3853]},"former":{"clothing":[],"den":[]}}, +"778":{"shop":"Eco Shop","now":{"clothing":[],"den":[4626,4625,4627,4629,4540,4541,4630]},"former":{"clothing":[],"den":[]}}, +"790":{"shop":"Spooky Shop (Phantom Vortex)","now":{"clothing":[3323,3324,3325,3322,3326,3328,3329,3330,3327,3331,3674,3675,3676,3673,3677,2566,2567,2568,2569,2570,2571,4100,4102,2578,2572,4104,2573,2574,2575,4101,2576,2577,4103,4099,3651,3650,2579,2580,2581,2582,2583,2584,2585,2586,2587,2588,2589,2590,2591,3046,3054,3052,3044,3045,3053,3043,3042,3050,3049,3047,3048,3051,3699,3700,3701,3698,3702,3724,3725,3726,3723,3727,2592,2593,2594,2595,2596,2597,2598,2599,2600,2601,2602,2603,2604,4117,4118,3070,4121,3074,4122,3079,3078,3069,4119,3071,3068,4120,3080,3073,3076,3075,3077,3072,4128,4107,2617,2605,2606,2607,2608,2609,2610,2611,4105,2612,2613,3653,3654,3655,3652,3656,2614,4110,4106,4109,4108,2615,2616,3704,3705,3706,3703,3707,3729,3730,3731,3728,3732,3308,3309,3310,3307,3311,3313,3314,3315,3312,3316,3061,3062,3063,3060,3064,3319,3320,3317,3318,3321,3333,3334,3336,3332,3335,3339,3340,3342,3338,3341,3694,3695,3696,3693,3697,3719,3720,3721,3718,3722,3067,3065,3066,3681,4116,4115,3679,3682,4114,4111,3680,3678,4113,4112,3709,3710,3711,3708,3712,3734,3735,3736,3733,3737,3670,3668,3669,3671,3672,3714,3715,3716,3713,3717,3739,3740,3741,3738,3742,3084,3649,3082,3085,3659,3647,3090,3091,3337,3089,3092,3661,3660,3658,3083,3081,3644,3643,3645,3642,3646,3657,3648,3662,3087,3088,3343,3086,3093,4124,4125,4126,4123,4127,3664,3665,3666,3663,3667,4539,4538,4537,4534,4535,4536,4542,4543,4540,4541,4544,4545,3059,3058,3057,3055,3056],"den":[]},"former":{"clothing":[],"den":[]}}, +"801":{"shop":"Jambassador Plushie Shop","now":{"clothing":[],"den":[5231,5422,5239,5424,5494,5466,4261,5235,5413,4259,5496,5456,5497,5457,4252,5419,4254,4257,4247,5415,5242,5411,4249,5498,5458,5237,5426,4255,4258,4245,5499,5459,5500,5460,5233,5416,5501,5464,5238,5417,5505,5461,5502,5465,5503,5462,5241,5420,4248,4250,5236,5423,4251,5232,5425,4260,5234,5427,4242,5412,5504,5463,4253,4244,5421,4243,5240,5414,4256,4246,5418]},"former":{"clothing":[],"den":[5495,5455]}}, +"803":{"shop":"Hall of Animals","now":{"clothing":[],"den":[782,668,662,656,836,548,500,622,787,501,1625,574,549,600,588,595,1626,551,505,1627,507,597,589,569,1628,552,515,516,1629,553,566,556,523,573,798,525,503,524,517,518,521,509,511,510,502,504,522,513,514,512,508,520,519,550,554,555,557,558,567,568,570,571,572,575,576,577,590,591,592,593,598,599,594,596,604,601,602,605,603,623,627,626,625,624,655,654,652,651,653,657,658,659,660,661,663,664,665,666,667,669,670,671,672,673,706,783,784,785,786,788,796,797,799,800,801,833,834,835,837,838]},"former":{"clothing":[],"den":[]}}, +"805":{"shop":"Hall of Animals","now":{"clothing":[],"den":[2608,1419,1247,3912,3090,3372,1358,3901,1421,2628,3383,2607,1638,1422,3023,1430,2238,2377,3393,1748,2006,2714,1855,3911,3902,3389,3080,4145,3025,1420,3024]},"former":{"clothing":[],"den":[]}}, +"806":{"shop":"Hall of Animals","now":{"clothing":[],"den":[1065,2156,1439,2621,2003,1815,1639,1436,1796,2706,621,442,3088,1798,970,3872,3078,2335,2625,445,443,480,1737,1450,3019,3017,1451,3380,1201,441,3021,809,3371,1250,479,447,2632,538,1360,444,750,3873,1795,1454,1797]},"former":{"clothing":[],"den":[]}}, +"807":{"shop":"Hall of Animals","now":{"clothing":[],"den":[2616,1273,1249,3726,3094,3379,1359,3907,1773,2629,3385,2619,1641,1300,3028,1268,2161,2343,1747,2002,2713,1811,3725,3908,3085,4144,3077,1274,3030]},"former":{"clothing":[],"den":[]}}, +"816":{"shop":"Phantom Emporium (Shop)","now":{"clothing":[3588,1658,3589,1657,1659,1660,1462,3590,3591,3595,3594,1516,1512,789,1449,1310,1309,1550,1552,1553,1551,1549,3592,3593,4603,4604,4605,4606],"den":[2840,2842,3408,3407,945,944,946,2110,2120,3040,3041,1236,1241,1237,1238,1239,1240,3324,1524,3328,3327,3325,1529,3329,3326,3323]},"former":{"clothing":[],"den":[]}}, +"817":{"shop":"Hall of Animals","now":{"clothing":[],"den":[4,5,6,7,10,11,12,14,17,18,20,22,23,25,28,26,29,30,31,5644,5645,5646,5647,5648,5649,5650,5657,5697,5698,5699,5700,5701,5702,5703,5704,5705,5706]},"former":{"clothing":[],"den":[]}}, +"818":{"shop":"Phantom Emporium (Shop)","now":{"clothing":[3588,1658,3589,1657,1659,1660,1462,3590,3591,3595,3594,1516,1512,789,1449,1310,1309,1550,1552,1553,1551,1549,3592,3593,4603,4604,4605,4606],"den":[2840,2842,3408,3407,945,944,946,2110,2120,3040,3041,1236,1241,1237,1238,1239,1240,3324,1524,3328,3327,3325,1529,3329,3326,3323]},"former":{"clothing":[],"den":[]}}, +"819":{"shop":"Phantom Emporium (Shop)","now":{"clothing":[3588,1658,3589,1657,1659,1660,1462,3590,3591,3595,3594,1516,1512,789,1449,1310,1309,1550,1552,1553,1551,1549,3592,3593,4603,4604,4605,4606],"den":[2840,2842,3408,3407,945,944,946,2110,2120,3040,3041,1236,1241,1237,1238,1239,1240,3324,1524,3328,3327,3325,1529,3329,3326,3323]},"former":{"clothing":[],"den":[]}}}} diff --git a/lib/shopstock.js b/lib/shopstock.js new file mode 100644 index 0000000..a46daca --- /dev/null +++ b/lib/shopstock.js @@ -0,0 +1,103 @@ +"use strict"; + +const defpacks = require("./defpacks.js"); +const sales = require("./sales.js"); +const {DIAMOND_TYPES} = require("./player.js"); +const wiki = require("./shop-stock.json"); + +// what stands on each shop's shelves. no file of the game says: the official +// server sent a shop's list when it was opened. lib/shop-stock.json has it +// from the AJ Classic Wiki, per generic list (tools/shop-stock.py makes the +// file and says which shop was taken for which list, and where that was a +// guess): "now", what the wiki has on sale there, and "former", what was +// sold there once. A shop stocks all of the first, and of the second what +// is in its season today (lib/sales.js): a shop's seasonal things come back +// to it each year, and what left for good stays away. + +const DEF_ITEM = 1000; +const DEF_DEN_ITEM = 1030; +const DEF_DIAMOND = 1054; +const DEF_COMBINED_LIST = 1060; + +// "kind:refId" -> diamond def id, for what a diamond shop sells. +let diamondIds = null; +const diamondId = (type, refId) => { + if (!diamondIds) { + diamondIds = new Map(); + for (const id of defpacks.diamondIds()) { + const def = defpacks.diamondDef(id); + // an item with two defs keeps the later one. + diamondIds.set(`${def.type}:${def.refId}`, id); + } + } + return diamondIds.get(`${type}:${refId}`); +}; + +const KINDS = { + clothing: {salesKind: "clothing", sold: () => defpacks.clothingIds(), diamondType: DIAMOND_TYPES.clothing}, + den: {salesKind: "denItems", sold: () => defpacks.denItemIds(), diamondType: DIAMOND_TYPES.denItem}, +}; + +// the ids of one kind a list stocks. with `asDiamonds` they are diamond def +// ids, and what has no diamond price is left out. +const shelf = (stock, kind, asDiamonds) => { + const {salesKind, sold, diamondType} = KINDS[kind]; + const sellable = new Set(sold()); + const music = kind === "den" && stock.music !== undefined ? new Set(defpacks.musicIds()) : null; + const fits = id => sellable.has(id) && (!music || music.has(id) === stock.music); + const ids = []; + for (const [items, onlySeasonal] of [[stock.now[kind], false], [stock.former[kind], true]]) { + for (const id of items.filter(fits)) { + const entry = asDiamonds ? diamondId(diamondType, id) : id; + if (entry !== undefined && (!onlySeasonal || sales.inSeason(asDiamonds ? "diamond" : salesKind, entry))) { + ids.push(entry); + } + } + } + return ids; +}; + +const make = (listId, type) => { + const stock = wiki.lists[listId]; + if (!stock) { + return null; + } + if (type === DEF_ITEM) { + return {entries: shelf(stock, "clothing", false)}; + } + if (type === DEF_DEN_ITEM) { + return {entries: shelf(stock, "den", false)}; + } + if (type === DEF_DIAMOND) { + return {entries: [...shelf(stock, "clothing", true), ...shelf(stock, "den", true)]}; + } + if (type === DEF_COMBINED_LIST) { + // [kinds, count per kind, entries of each kind in turn] + // (ItemXtCommManager.setupShopItemObject). + const parts = [[DEF_ITEM, shelf(stock, "clothing", false)], [DEF_DEN_ITEM, shelf(stock, "den", false)]] + .filter(([, ids]) => ids.length > 0); + const count = parts.reduce((sum, [, ids]) => sum + ids.length, 0); + return count === 0 ? null : { + count, + entries: [parts.map(([kind]) => kind).join(","), parts.map(([, ids]) => ids.length).join(","), ...parts.flatMap(([, ids]) => ids)], + }; + } + return null; +}; + +// what the wiki has for this list, as the entries of a `gl` reply (and their +// count, where that is not their number); null when it has nothing, and the +// shop is stocked some other way. made once a day, as the seasons are. +const made = new Map(); // list id -> {day, allOnSale, stock} +const list = (listId, type) => { + const key = Number(listId); + const kept = made.get(key); + if (kept && kept.day === sales.today() && kept.allOnSale === sales.everythingOnSale()) { + return kept.stock; + } + const stock = make(key, type); + made.set(key, {day: sales.today(), allOnSale: sales.everythingOnSale(), stock: stock && stock.entries.length > 0 ? stock : null}); + return made.get(key).stock; +}; + +module.exports = {list}; diff --git a/lib/signup.js b/lib/signup.js new file mode 100644 index 0000000..e5df46b --- /dev/null +++ b/lib/signup.js @@ -0,0 +1,109 @@ +"use strict"; + +const crypto = require("crypto"); +const accounts = require("./accounts.js"); +const bans = require("./bans.js"); +const config = require("../config.js"); +const limits = require("./limits.js"); +const {isUint} = require("./player.js"); + +// the client's own "Create Account" screens (createAccountFlow.CreateAccount). +// they log in to a guest zone with no credentials, check the chosen names +// with "la" and create the account with "lc". + +const SIGNUP_ZONE = "sbiAccountZone"; + +// status codes CreateAccountGui.showLoginCreateResultMsg understands. +const OK = 1; +const FAILED = -1; +const USERNAME_TAKEN = -3; +const USERNAME_INVALID = -4; +const PASSWORD_INVALID = -5; + +const STATUS = { + username_taken: USERNAME_TAKEN, + invalid_username: USERNAME_INVALID, + invalid_password: PASSWORD_INVALID, + name_not_allowed: USERNAME_INVALID, +}; +// names asked about on one guest connection: the screens ask once or twice. +const MAX_NAME_CHECKS = 40; + +// "la" check types +const CHECK_AVATAR_NAME = "1"; + +// SBCrypto.encrypt: AES-256-CBC under SHA-256 of the session's random key, +// sent as base64 of the IV followed by the ciphertext. +const decryptPassword = (encoded, sessionKey) => { + try { + const raw = Buffer.from(encoded, "base64"); + const key = crypto.createHash("sha256").update(sessionKey, "utf8").digest(); + const decipher = crypto.createDecipheriv("aes-256-cbc", key, raw.subarray(0, 16)); + return Buffer.concat([decipher.update(raw.subarray(16)), decipher.final()]).toString("utf8"); + } + catch (err) { + return null; + } +}; + +const handlers = { + // CreateAccountXtCommManager.sendLoginAvailableRequest: [checkType, name, + // nameId1, nameId2, nameId3, language, deployVersion]. any animal name built + // from the pickers is fine; usernames must be valid and free. + la(session, roomId, [checkType, name]) { + session.nameChecks = (session.nameChecks || 0) + 1; + if (session.nameChecks > MAX_NAME_CHECKS) { + session.close(); + return; + } + const problem = checkType === CHECK_AVATAR_NAME ? null : accounts.usernameProblem(String(name).trim()); + session.sendXt("la", -1, problem ? STATUS[problem] : OK); + }, + + // CreateAccountXtCommManager.sendLoginCreateRequest: [username, + // encryptedPassword, birthday, gender, sgParams, nameId1, nameId2, nameId3, + // avatarType, language, country, deployVersion]. the reply + // (CreateAccount.handleLoginCreate) is [status, accountId]. + lc(session, roomId, [username, encryptedPassword, , , , name1, name2, name3, avatarType]) { + const password = session.key ? decryptPassword(String(encryptedPassword), session.key) : null; + if (password === null) { + session.sendXt("lc", -1, FAILED, 0); + return; + } + // checked before the sign-up limit so a mistyped form does not use it up. + const problem = accounts.usernameProblem(String(username).trim()); + if (problem) { + session.sendXt("lc", -1, STATUS[problem], 0); + return; + } + // the game's own sign-up screens cannot show the terms, so on a public + // server an account is made on the sign-up page or in the client. + if (config.isPublic) { + session.sendXt("lc", -1, FAILED, 0); + return; + } + if (bans.addressBan(session.address)) { + console.log("[signup] refused a sign-up from a banned address"); + session.sendXt("lc", -1, FAILED, 0); + return; + } + if (!limits.registrationAllowed(session.address, limits.isTrustedLocal(session.address))) { + console.log(`[signup] too many sign-ups from ${session.address}`); + session.sendXt("lc", -1, FAILED, 0); + return; + } + const avatarName = [name1, name2, name3].every(isUint) ? `${name1}|${name2}|${name3}` : undefined; + const result = accounts.register(username, password, {type: avatarType, name: avatarName}); + if (result.error) { + session.sendXt("lc", -1, STATUS[result.error], 0); + return; + } + session.sendXt("lc", -1, OK, result.account.id); + }, + + // the first animal's look, sent alongside "lc"; the account already has it + // and the client expects no reply. + ln() {}, +}; + +module.exports = {handlers, SIGNUP_ZONE}; diff --git a/lib/staff.js b/lib/staff.js new file mode 100644 index 0000000..5094518 --- /dev/null +++ b/lib/staff.js @@ -0,0 +1,97 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const bans = require("./bans.js"); +const manage = require("./manage.js"); +const support = require("./support.js"); +const world = require("./world.js"); + +// what the admin panel (lib/panel.js) and the moderator panel +// (lib/modpanel.js) both do. `by` is who is doing it, for the record: +// "admin", or a moderator's username. + +const disciplined = () => accounts.all() + .map(account => { + const ban = world.moderation.banOf(account); + return { + username: account.username, + banned: ban ? ban.seconds : 0, + reason: ban ? ban.reason : "", + by: ban ? ban.by : "", + since: ban ? ban.since : null, + silenced: world.moderation.silenceRemaining(account), + }; + }) + .filter(entry => entry.banned !== 0 || entry.silenced !== 0) + .sort((a, b) => a.username.localeCompare(b.username)); + +const ADDRESS_ERRORS = { + not_an_address: "Not an IP address.", + own_address: "That is this machine's own address: with a proxy or a tunnel in front, everyone's.", + already: "Already banned.", + too_many: "Too many banned addresses.", +}; + +// bans an address for good and puts out whoever plays from it. +// returns {ban, out} or {error: text}. +const banAddress = (address, reason, by) => { + const result = bans.banAddress(address, reason, by); + return result.error ? {error: ADDRESS_ERRORS[result.error]} : {ban: result.ban, out: world.disconnectAddress(result.ban.address)}; +}; + +// appeals with what each is against, as it stands now. +const appealsFor = handled => bans.appeals(handled).map(appeal => { + const account = accounts.byId(appeal.accountId); + const ban = account ? world.moderation.banOf(account) : null; + const address = appeal.addressKey ? bans.addressBan(appeal.addressKey) : null; + return {...appeal, username: account ? account.username : appeal.username, gone: !account, + ban: ban && {seconds: ban.seconds, reason: ban.reason}, address: address && {key: address.key, reason: address.reason}}; +}); + +// an appeal answered: approved lifts the account's ban, and the ban on the +// address it was written from when it was about that. +const answerAppeal = (accountId, approved, reply, by) => { + const appeal = bans.waitingAppeal(accountId); + if (!appeal) { + return {error: "No such appeal waiting."}; + } + bans.answerAppeal(appeal.accountId, approved, reply, by); + const account = accounts.byId(appeal.accountId); + if (!approved) { + return {ok: `${appeal.username} stays banned.`, username: appeal.username}; + } + if (account) { + world.moderation.actions.unban(account, by); + } + if (appeal.addressKey) { + bans.unbanAddress(appeal.addressKey, by); + } + return {ok: `${appeal.username} is no longer banned.`, username: appeal.username}; +}; + +// A player's request for another username, approved or denied. the player +// picked the name under the sign-up rules; they are checked again, since it +// may have been taken while it waited. +const answerNameRequest = (id, approve) => { + const request = support.nameRequestById(id); + const account = request && accounts.byId(request.accountId); + if (!request) { + return {error: "No such request waiting."}; + } + if (!approve || !account) { + support.answerNameRequest(request.id, false); + return {ok: account ? `${account.username} keeps their name.` : "That account is gone; the request was closed.", username: account ? account.username : ""}; + } + world.disconnect(account); + manage.forget(account); + const oldName = account.username; + const problem = accounts.rename(account, request.newName); + if (problem) { + return {error: problem === "username_taken" ? "That username has been taken since. Deny the request." + : "That name does not pass the sign-up rules."}; + } + support.answerNameRequest(request.id, true); + return {ok: `${oldName} is now called ${account.username}. They log in with the new name and the same password.`, username: account.username}; +}; + +module.exports = {disciplined, banAddress, appealsFor, answerAppeal, answerNameRequest}; diff --git a/lib/stubs.js b/lib/stubs.js new file mode 100644 index 0000000..9859b3a --- /dev/null +++ b/lib/stubs.js @@ -0,0 +1,12 @@ +"use strict"; + +// features this server does not have, answered with the "nothing here" reply +// each one's client code expects, so that the client carries on instead of +// waiting on a spinner. each entry names the client method that reads it. + +module.exports = { + // ReferAFriendXtCommManager.referralHasAssociateResponse: 0 = no referrer. + refh(session) { + session.sendXt("refh", -1, 0); + }, +}; diff --git a/lib/support.js b/lib/support.js new file mode 100644 index 0000000..3c26fe0 --- /dev/null +++ b/lib/support.js @@ -0,0 +1,156 @@ +"use strict"; + +const accounts = require("./accounts.js"); + +// what players send from the account page (/account, lib/manage.js) for +// whoever runs the server to answer in the admin panel: requests for a new +// username, and feedback and bug reports. + +const SCHEMA = ` + CREATE TABLE IF NOT EXISTS name_requests ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + created_at INTEGER NOT NULL, + account_id INTEGER NOT NULL, + old_name TEXT NOT NULL, + new_name TEXT NOT NULL, + reason TEXT NOT NULL, + status TEXT NOT NULL DEFAULT 'waiting', + handled_at INTEGER + ); + CREATE TABLE IF NOT EXISTS feedback ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + created_at INTEGER NOT NULL, + account_id INTEGER NOT NULL, + username TEXT NOT NULL, + kind TEXT NOT NULL, + text TEXT NOT NULL, + handled_at INTEGER + ); +`; + +const WAITING = "waiting"; +const APPROVED = "approved"; +const DENIED = "denied"; +const WITHDRAWN = "withdrawn"; +const KINDS = ["feedback", "bug"]; +const MAX_REASON = 300; +const MAX_TEXT = 4000; +const MAX_OPEN_FEEDBACK = 5000; // waiting to be read; further ones are refused +const FEEDBACK_PER_DAY = 10; // per account +const DAY_SECONDS = 86400; + +const now = () => Math.floor(Date.now() / 1000); +const db = () => accounts.database(); +const clean = (text, max) => String(text === undefined ? "" : text).replace(/[\u0000-\u0008\u000b-\u001f\u007f]/g, " ").trim().slice(0, max); + +const load = () => db().exec(SCHEMA); + +const nameRow = row => ({ + id: row.id, + createdAt: row.created_at, + accountId: row.account_id, + oldName: row.old_name, + newName: row.new_name, + reason: row.reason, + status: row.status, + handledAt: row.handled_at, +}); + +const waitingNameRequest = account => { + const row = db().prepare("SELECT * FROM name_requests WHERE account_id = ? AND status = ? ORDER BY id DESC LIMIT 1").get(account.id, WAITING); + return row ? nameRow(row) : null; +}; + +const nameRequestsOf = account => + db().prepare("SELECT * FROM name_requests WHERE account_id = ? ORDER BY id DESC LIMIT 10").all(account.id).map(nameRow); + +// asks for a new username. one request waits at a time: a new one replaces +// it. returns {request} or {error: "invalid_username" | "username_taken" | "same_name"}. +const requestName = (account, newName, reason) => { + newName = typeof newName === "string" ? newName.trim() : ""; + if (newName === account.username) { + return {error: "same_name"}; + } + // changing only the capitals of one's own name is not "taken". + const problem = newName.toLowerCase() === account.username.toLowerCase() ? null : accounts.usernameProblem(newName); + if (problem) { + return {error: problem}; + } + db().prepare("UPDATE name_requests SET status = ?, handled_at = ? WHERE account_id = ? AND status = ?").run(WITHDRAWN, now(), account.id, WAITING); + db().prepare("INSERT INTO name_requests (created_at, account_id, old_name, new_name, reason) VALUES (?, ?, ?, ?, ?)") + .run(now(), account.id, account.username, newName, clean(reason, MAX_REASON)); + console.log(`[support] "${account.username}" asked to be called "${newName}"`); + return {request: waitingNameRequest(account)}; +}; + +const withdrawNameRequest = account => + db().prepare("UPDATE name_requests SET status = ?, handled_at = ? WHERE account_id = ? AND status = ?").run(WITHDRAWN, now(), account.id, WAITING).changes > 0; + +// requests waiting, oldest first; or with `handled`, the latest answered. +const nameRequests = (handled = false) => db() + .prepare(handled + ? "SELECT * FROM name_requests WHERE status IN (?, ?) ORDER BY handled_at DESC LIMIT 200" + : "SELECT * FROM name_requests WHERE status = ? ORDER BY id LIMIT 500") + .all(...(handled ? [APPROVED, DENIED] : [WAITING])).map(nameRow); + +const nameRequestById = id => { + const row = db().prepare("SELECT * FROM name_requests WHERE id = ? AND status = ?").get(Number(id), WAITING); + return row ? nameRow(row) : null; +}; + +const answerNameRequest = (id, approved) => + db().prepare("UPDATE name_requests SET status = ?, handled_at = ? WHERE id = ? AND status = ?") + .run(approved ? APPROVED : DENIED, now(), Number(id), WAITING).changes > 0; + +const feedbackRow = row => ({ + id: row.id, + createdAt: row.created_at, + username: row.username, + kind: row.kind, + text: row.text, + handledAt: row.handled_at, +}); + +const openFeedbackCount = () => db().prepare("SELECT COUNT(*) AS count FROM feedback WHERE handled_at IS NULL").get().count; + +// returns {ok: true} or {error: "empty" | "unknown_kind" | "too_many"}. +const sendFeedback = (account, kind, text) => { + const body = clean(text, MAX_TEXT); + if (!KINDS.includes(kind)) { + return {error: "unknown_kind"}; + } + if (!body) { + return {error: "empty"}; + } + const today = db().prepare("SELECT COUNT(*) AS count FROM feedback WHERE account_id = ? AND created_at > ?").get(account.id, now() - DAY_SECONDS).count; + if (today >= FEEDBACK_PER_DAY || openFeedbackCount() >= MAX_OPEN_FEEDBACK) { + return {error: "too_many"}; + } + db().prepare("INSERT INTO feedback (created_at, account_id, username, kind, text) VALUES (?, ?, ?, ?, ?)").run(now(), account.id, account.username, kind, body); + console.log(`[support] ${kind === "bug" ? "bug report" : "feedback"} from "${account.username}"`); + return {ok: true}; +}; + +const feedbackOf = account => + db().prepare("SELECT * FROM feedback WHERE account_id = ? ORDER BY id DESC LIMIT 20").all(account.id).map(feedbackRow); + +const feedback = (handled = false) => db() + .prepare(handled + ? "SELECT * FROM feedback WHERE handled_at IS NOT NULL ORDER BY handled_at DESC LIMIT 200" + : "SELECT * FROM feedback WHERE handled_at IS NULL ORDER BY id LIMIT 500") + .all().map(feedbackRow); + +const markFeedbackRead = id => db().prepare("UPDATE feedback SET handled_at = ? WHERE id = ? AND handled_at IS NULL").run(now(), Number(id)).changes > 0; + +// an account being deleted: what it sent goes with it. +const forget = account => { + db().prepare("DELETE FROM feedback WHERE account_id = ?").run(account.id); + db().prepare("DELETE FROM name_requests WHERE account_id = ?").run(account.id); +}; + +const openCount = () => openFeedbackCount() + db().prepare("SELECT COUNT(*) AS count FROM name_requests WHERE status = ?").get(WAITING).count; + +module.exports = { + load, requestName, withdrawNameRequest, waitingNameRequest, nameRequestsOf, nameRequests, nameRequestById, answerNameRequest, + forget, sendFeedback, feedbackOf, feedback, markFeedbackRead, openCount, MAX_REASON, MAX_TEXT, KINDS, +}; diff --git a/lib/totp.js b/lib/totp.js new file mode 100644 index 0000000..cea8367 --- /dev/null +++ b/lib/totp.js @@ -0,0 +1,204 @@ +"use strict"; + +const crypto = require("crypto"); + +// two-step sign-in: a six-digit code from an authenticator app, asked for +// after the password by the client's sign-in (lib/http.js) and the account +// page's (lib/manage.js). A player turns it on and off on the account page. +// time-based one-time passwords as every authenticator app makes them +// (RFC 6238: HMAC-SHA1, six digits, a new one every 30 seconds). +// +// on an account: +// totp null, or {secret (base32), since, lastStep, recovery: [SHA-256 +// of a code, ...]} once it is on. lastStep is the time step of +// the last code taken: a code works once. +// totpSetup {secret, at} while it is being turned on: the secret was +// shown and no code from it has been given yet. +// devices [{hash, at, via}]: devices that need not give a code for +// DEVICE_DAYS after one sign-in with a code. each holds a +// random token; only its hash is kept here. +// +// A recovery code stands in for a code from the app, once: for a player +// whose phone is gone. they are shown when two-step sign-in is turned on and +// never again. the admin can turn it off for an account from the panel. +// +// the secret has to be kept as it is, since every code is worked out from +// it: whoever can read the database can make codes. it never leaves the +// server after it was shown at setup. + +const STEP_SECONDS = 30; +const DIGITS = 6; +const WINDOW = 1; // steps either side of now that are taken: clocks differ +const SETUP_MINUTES = 15; +const RECOVERY_CODES = 8; +const DEVICE_DAYS = 30; +const MAX_DEVICES = 10; +const DEVICE_TOKEN_HEX = 48; +const ISSUER = "Burrow"; + +const BASE32 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; + +const base32Encode = bytes => { + let bits = ""; + for (const byte of bytes) { + bits += byte.toString(2).padStart(8, "0"); + } + let out = ""; + for (let index = 0; index < bits.length; index += 5) { + out += BASE32[parseInt(bits.slice(index, index + 5).padEnd(5, "0"), 2)]; + } + return out; +}; + +const base32Decode = text => { + let bits = ""; + for (const char of text) { + bits += BASE32.indexOf(char).toString(2).padStart(5, "0"); + } + const bytes = []; + for (let index = 0; index + 8 <= bits.length; index += 8) { + bytes.push(parseInt(bits.slice(index, index + 8), 2)); + } + return Buffer.from(bytes); +}; + +const now = () => Math.floor(Date.now() / 1000); +const sha256 = text => crypto.createHash("sha256").update(text).digest("hex"); + +const sameText = (one, other) => { + const a = Buffer.from(String(one)); + const b = Buffer.from(String(other)); + return a.length === b.length && crypto.timingSafeEqual(a, b); +}; + +// the code for one time step (RFC 4226, with the step as the counter). +const codeAt = (secret, step) => { + const counter = Buffer.alloc(8); + counter.writeBigUInt64BE(BigInt(step)); + const mac = crypto.createHmac("sha1", base32Decode(secret)).update(counter).digest(); + const offset = mac[mac.length - 1] & 0x0F; + return String((mac.readUInt32BE(offset) & 0x7FFFFFFF) % 10 ** DIGITS).padStart(DIGITS, "0"); +}; + +// the time step a code belongs to if it is one the secret gives now, a +// step early or a step late, and later than `after`; or null. +const stepOf = (secret, code, after = 0, at = now()) => { + const current = Math.floor(at / STEP_SECONDS); + let found = null; + // every candidate is compared, so that the time taken says nothing. + for (let step = current - WINDOW; step <= current + WINDOW; step++) { + if (sameText(codeAt(secret, step), code) && step > after) { + found = step; + } + } + return found; +}; + +const isOn = account => Boolean(account.totp); + +// what an authenticator app takes, typed in or as a QR code. +const uri = (username, secret) => { + const label = encodeURIComponent(`${ISSUER}:${String(username).slice(0, 30)}`); + return `otpauth://totp/${label}?secret=${secret}&issuer=${encodeURIComponent(ISSUER)}`; +}; + +// begins turning it on: a new secret, to be confirmed with a code. +const begin = account => { + account.totpSetup = {secret: base32Encode(crypto.randomBytes(20)), at: now()}; + return {secret: account.totpSetup.secret, uri: uri(account.username, account.totpSetup.secret)}; +}; + +const RECOVERY_ALPHABET = "abcdefghjkmnpqrstuvwxyz23456789"; // no l, i, o, 0 or 1 +// sixteen characters (about 79 bits): only its plain hash is kept, which is +// safe for a code this long and was thin for the ten of earlier setups +// (those still work until used). +const RECOVERY_LENGTH = 16; +const OLD_RECOVERY_LENGTH = 10; +const recoveryCode = () => { + let code = ""; + while (code.length < RECOVERY_LENGTH) { + const byte = crypto.randomBytes(1)[0]; + if (byte < RECOVERY_ALPHABET.length * 8) { // 248: no letter is likelier than another + code += RECOVERY_ALPHABET[byte % RECOVERY_ALPHABET.length]; + } + } + return code.match(/.{4}/g).join("-"); +}; +// as typed: capitals, spaces and the dash do not matter. +const recoveryKey = text => String(text).toLowerCase().replace(/[^a-z0-9]/g, ""); + +// turns it on if `code` is one the secret shown at setup gives. returns the +// recovery codes, to be shown once, or null. +const confirm = (account, code) => { + const setup = account.totpSetup; + if (!setup || now() - setup.at > SETUP_MINUTES * 60) { + account.totpSetup = null; + return null; + } + const step = stepOf(setup.secret, String(code).replace(/\s/g, "")); + if (step === null) { + return null; + } + const codes = Array.from({length: RECOVERY_CODES}, recoveryCode); + account.totp = {secret: setup.secret, since: now(), lastStep: step, recovery: codes.map(one => sha256(recoveryKey(one)))}; + account.totpSetup = null; + account.devices = []; + return codes; +}; + +// is `code` good for the account, as a code from the app or a recovery +// code? either is used up by this. returns "code", "recovery" or null. +const verify = (account, code) => { + if (!account.totp || typeof code !== "string" || code.length > 60) { + return null; + } + const digits = code.replace(/\s/g, ""); + if (/^\d{6}$/.test(digits)) { + const step = stepOf(account.totp.secret, digits, account.totp.lastStep); + if (step !== null) { + account.totp.lastStep = step; + return "code"; + } + return null; + } + const index = account.totp.recovery.indexOf(sha256(recoveryKey(code))); + if (index !== -1 && [RECOVERY_LENGTH, OLD_RECOVERY_LENGTH].includes(recoveryKey(code).length)) { + account.totp.recovery.splice(index, 1); + return "recovery"; + } + return null; +}; + +const turnOff = account => { + account.totp = null; + account.totpSetup = null; + account.devices = []; +}; + +const freshDevices = account => account.devices.filter(device => now() - device.at < DEVICE_DAYS * 86400); + +// A token for the device that just signed in with a code. `via` says where +// ("launcher" or "web"). +const trustDevice = (account, via) => { + const token = crypto.randomBytes(DEVICE_TOKEN_HEX / 2).toString("hex"); + account.devices = [{hash: sha256(token), at: now(), via}, ...freshDevices(account)].slice(0, MAX_DEVICES); + return token; +}; + +const deviceTrusted = (account, token) => { + if (typeof token !== "string" || token.length !== DEVICE_TOKEN_HEX) { + return false; + } + account.devices = freshDevices(account); + const hash = sha256(token); + return account.devices.some(device => device.hash === hash); +}; + +const forgetDevices = account => { + account.devices = []; +}; + +module.exports = { + DEVICE_DAYS, isOn, begin, confirm, verify, turnOff, trustDevice, deviceTrusted, forgetDevices, freshDevices, + codeAt, stepOf, uri, base32Encode, base32Decode, +}; diff --git a/lib/trades.js b/lib/trades.js new file mode 100644 index 0000000..012b46d --- /dev/null +++ b/lib/trades.js @@ -0,0 +1,434 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const defpacks = require("./defpacks.js"); +const masterpieces = require("./masterpieces.js"); +const {MAX_ITEMS, MAX_DEN_ITEMS} = require("./player.js"); + +// trading (client side: TradeXtCommManager, TradeManager). A player keeps a +// trade list of items on offer. someone else asks for one of them, offering +// items of their own; the owner accepts or declines; then both confirm and +// the items change hands. + +// TradeItem.itemType +const TYPE_CLOTHING = 0; +const TYPE_DEN_ITEM = 1; +const TYPE_PET = 3; + +const MAX_TRADE_ITEMS = 50; +const MAX_PETS = 1000; // as in lib/pets.js + +// "ti" request steps (first parameter from the client) +const STEP_OFFER = "0"; +const STEP_ANSWER = "1"; +const STEP_CANCEL = "2"; +const STEP_CONFIRM = "3"; + +// "ti" reply statuses (TradeManager.onTradeItemsResponse) +const TRADE_REQUESTED = 0; // to the owner: here is an offer +const TRADE_PROGRESS = 1; // followed by 0 = please confirm, 1 = done +const TRADE_DECLINED = 2; +const TRADE_ITEM_GONE = 3; +const TRADE_UNAVAILABLE = 4; +const TRADE_CLOSED = 6; // just close the trade windows + +const AWAITING_CONFIRMATION = 0; +const COMPLETED = 1; + +// item kinds inside a completed trade (TradeManager.displayTradeDone) +const DONE_CLOTHING = 0; +const DONE_DEN_ITEM = 1; +const DONE_PET = 2; + +const USERNAME_SHOWN = 1; +const MAX_OFFERED = 50; // the patched client lets this many be offered (gui.TradeManager) +const TRADES_KEPT = 50; // per account, for its page +const MAX_WAITING_OFFERS = 50; // offers left on one account +const MAX_OFFERS_MADE = 20; // by one account, still waiting + +module.exports = ({findOnline, blocks}) => { + // TradeManager.onTradeListReceived: [username, clothingCount, (defId, + // invIdx, color)..., denItemCount, (defId, invIdx, version, approved, + // imageId, creatorDbId, creatorUuid)..., petCount, (speciesId, invIdx, + // createdTs, lBits, uBits, eBits, name, personality, toy, food)...] + const sendTradeList = (to, account) => { + const listed = type => account.tradeList.filter(entry => entry.type === type).map(entry => entry.inv); + const clothing = account.items.filter(item => listed(TYPE_CLOTHING).includes(item.inv)); + const denItems = account.denItems.filter(item => listed(TYPE_DEN_ITEM).includes(item.inv) && masterpieces.itemApproved(item)); + const pets = account.pets.filter(pet => listed(TYPE_PET).includes(pet.inv)); + to.sendXt("tl", -1, account.username, + clothing.length, ...clothing.flatMap(item => [item.def, item.inv, item.color]), + denItems.length, ...denItems.flatMap(item => [item.def, item.inv, item.version, "true", ...masterpieces.itemFields(item)]), + pets.length, ...pets.flatMap(pet => [pet.lBits & 0xFF, pet.inv, pet.createdAt, pet.lBits, pet.uBits, pet.eBits, pet.name, 0, 0, 0])); + }; + + const owns = (account, type, inv) => { + const collection = type === TYPE_CLOTHING ? account.items : type === TYPE_DEN_ITEM ? account.denItems : type === TYPE_PET ? account.pets : []; + return collection.some(entry => entry.inv === inv); + }; + + const collectionOf = (account, type) => + (type === TYPE_CLOTHING ? account.items : type === TYPE_DEN_ITEM ? account.denItems : type === TYPE_PET ? account.pets : []); + + // A masterpiece still waiting for review is nobody's to trade. + const find = (account, type, inv) => collectionOf(account, type) + .find(entry => entry.inv === inv && (type !== TYPE_DEN_ITEM || masterpieces.itemApproved(entry))); + + // the field layouts differ between the offer the owner is shown (no + // inventory ids for clothing and den items) and the completed trade. + const offerFields = (type, entry) => { + if (type === TYPE_CLOTHING) { + return [entry.def, entry.color]; + } + if (type === TYPE_DEN_ITEM) { + return [entry.def, entry.version, "true", ...masterpieces.itemFields(entry)]; + } + return [entry.createdAt, entry.lBits & 0xFF, entry.inv, entry.lBits, entry.uBits, entry.eBits, 0, 0, 0, entry.name]; + }; + + const doneFields = (type, entry) => { + if (type === TYPE_CLOTHING) { + return [DONE_CLOTHING, entry.def, entry.inv, entry.color]; + } + if (type === TYPE_DEN_ITEM) { + return [DONE_DEN_ITEM, entry.def, entry.inv, entry.version, "true", ...masterpieces.itemFields(entry)]; + } + return [DONE_PET, entry.createdAt, entry.inv, entry.lBits & 0xFF, entry.lBits, entry.uBits, entry.eBits, 0, 0, 0, entry.name]; + }; + + const doneType = type => (type === TYPE_CLOTHING ? DONE_CLOTHING : type === TYPE_DEN_ITEM ? DONE_DEN_ITEM : DONE_PET); + + // the code the owner's client uses to check it has room: clothing 0-2 and + // den items 3-5 by environment (land, ocean, both), pets 6. + const wantedCode = (type, entry) => { + if (type === TYPE_PET) { + return 6; + } + const def = type === TYPE_CLOTHING ? defpacks.itemDef(entry.def) : defpacks.denItemDef(entry.def); + const environment = {0: 0, 1: 1, 3: 2}[def ? Number(def.enviroType) : 0] || 0; + return type === TYPE_CLOTHING ? environment : 3 + environment; + }; + + // what a traded thing is called, for the trade history. + const nameOf = (type, entry) => { + if (type === TYPE_PET) { + return defpacks.string((defpacks.petDef(entry.lBits & 0xFF) || {}).titleStrId) || "Pet"; + } + const def = type === TYPE_CLOTHING ? defpacks.itemDef(entry.def) : defpacks.denItemDef(entry.def); + return (def && defpacks.string(type === TYPE_CLOTHING ? def.titleStrId : def.nameStrId)) || (def && def.abbrName) || `Item ${entry.def}`; + }; + const note = (account, other, got, gave) => { + account.tradeHistory = [{at: Math.floor(Date.now() / 1000), with: other.username, got, gave}, ...account.tradeHistory].slice(0, TRADES_KEPT); + }; + + // would `account` have room for what it gets, once what it gives is gone? + const LIMITS = new Map([[TYPE_CLOTHING, MAX_ITEMS], [TYPE_DEN_ITEM, MAX_DEN_ITEMS], [TYPE_PET, MAX_PETS]]); + const fits = (account, gets, gives) => [...LIMITS].every(([type, max]) => { + const coming = gets.filter(item => item.type === type).length; + return coming === 0 || collectionOf(account, type).length + coming - gives.filter(item => item.type === type).length <= max; + }); + + // ends the trade `session` is part of, telling the other side with `status`. + const abandon = (session, status) => { + const {trade} = session; + if (!trade) { + return; + } + const other = trade.requester === session ? trade.owner : trade.requester; + trade.requester.trade = trade.owner.trade = null; + other.sendXt("ti", -1, status, session.account.username, USERNAME_SHOWN); + }; + + // moves one entry between accounts. it gets a fresh inventory id, and + // leaves the giver's trade list, animals and den. + const transfer = (from, to, type, entry) => { + const collection = collectionOf(from, type); + collection.splice(collection.indexOf(entry), 1); + from.tradeList = from.tradeList.filter(listed => !(listed.type === type && listed.inv === entry.inv)); + if (type === TYPE_PET) { + for (const avatar of from.avatars) { + avatar.petInvId = avatar.petInvId === entry.inv ? 0 : avatar.petInvId; + } + } + const moved = {...entry, inv: to.nextInv++}; + if (type === TYPE_CLOTHING) { + moved.on = []; + } + else if (type === TYPE_DEN_ITEM) { + Object.assign(moved, {placed: false, x: 0, y: 0, flip: 0}); + delete moved.mannequin; // a mannequin changes hands bare + } + collectionOf(to, type).push(moved); + return moved; + }; + + // TradeXtCommManager.sendTradeItemsRequest: [0, ownerName, wantedType, + // wantedInvIdx, clothingCount, denCount, extraDenCount, petCount, + // ...clothingInvIdx, ...denInvIdx, ...petInvIdx] + const offer = (session, params) => { + const owner = findOnline(params[1]); + const refuse = status => session.sendXt("ti", -1, status, owner ? owner.account.username : params[1], USERNAME_SHOWN); + const numbers = params.slice(2).map(Number); + // nor is there any trading between two players when one has blocked the other. + if (!owner || owner === session || owner.trade || session.trade || !numbers.every(Number.isInteger) + || blocks.either(owner.account, session.account) + || !accounts.featureOn(owner.account, "trading") || !accounts.featureOn(session.account, "trading")) { + refuse(TRADE_UNAVAILABLE); + return; + } + const [wantedType, wantedInv, clothingCount, denCount, extraDenCount, petCount, ...invs] = numbers; + // checked before anything is counted through: these numbers are the client's. + const total = clothingCount + denCount + extraDenCount + petCount; + if (![clothingCount, denCount, extraDenCount, petCount].every(count => count >= 0 && count <= MAX_OFFERED) + || total > MAX_OFFERED || invs.length !== total) { + refuse(TRADE_UNAVAILABLE); + return; + } + const wanted = find(owner.account, wantedType, wantedInv); + if (!wanted || !owner.account.tradeList.some(listed => listed.type === wantedType && listed.inv === wantedInv)) { + refuse(TRADE_ITEM_GONE); + return; + } + const counts = [[TYPE_CLOTHING, clothingCount], [TYPE_DEN_ITEM, denCount + extraDenCount], [TYPE_PET, petCount]]; + const offered = []; + let index = 0; + for (const [type, count] of counts) { + for (let i = 0; i < count; i++) { + const entry = find(session.account, type, invs[index++]); + if (entry && !offered.some(item => item.entry === entry)) { + offered.push({type, entry}); + } + } + } + if (offered.length !== total) { + refuse(TRADE_UNAVAILABLE); + return; + } + session.trade = owner.trade = {requester: session, owner, wantedType, wanted, offered, accepted: false, confirmed: new Set()}; + // TradeManager.displayTradeRequested: [0, requesterName, moderatedFlag, + // wantedCode, wantedInvIdx, clothingCount, denCount, petCount, ...items] + const ofType = type => offered.filter(item => item.type === type); + owner.sendXt("ti", -1, TRADE_REQUESTED, session.account.username, USERNAME_SHOWN, + wantedCode(wantedType, wanted), wanted.inv, + ofType(TYPE_CLOTHING).length, ofType(TYPE_DEN_ITEM).length, ofType(TYPE_PET).length, + ...[TYPE_CLOTHING, TYPE_DEN_ITEM, TYPE_PET].flatMap(type => ofType(type).flatMap(item => offerFields(type, item.entry)))); + }; + + // TradeXtCommManager.sendTradeItemAcceptOrReject: 1 accept, 0 decline, 2 busy + const answer = (session, choice) => { + const {trade} = session; + if (!trade || trade.owner !== session || trade.accepted) { + return; + } + if (choice !== "1") { + abandon(session, choice === "2" ? TRADE_UNAVAILABLE : TRADE_DECLINED); + return; + } + trade.accepted = true; + trade.requester.sendXt("ti", -1, TRADE_PROGRESS, AWAITING_CONFIRMATION); + trade.owner.sendXt("ti", -1, TRADE_PROGRESS, AWAITING_CONFIRMATION); + }; + + // both sides must confirm; then the items change hands and each side is + // told what it received and lost (TradeManager.displayTradeDone: + // [1, 1, receivedCount, ...received, lostCount, (kind, invIdx)...]). + const confirm = (session, yes) => { + const {trade} = session; + if (!trade || !trade.accepted) { + return; + } + if (!yes) { + abandon(session, TRADE_DECLINED); + return; + } + trade.confirmed.add(session); + if (trade.confirmed.size < 2) { + return; + } + const {requester, owner, wantedType, wanted, offered} = trade; + requester.trade = owner.trade = null; + // either side may have recycled or re-traded something while deciding. + const stillThere = collectionOf(owner.account, wantedType).includes(wanted) + && offered.every(item => collectionOf(requester.account, item.type).includes(item.entry)) + && fits(requester.account, [{type: wantedType}], offered) && fits(owner.account, offered, [{type: wantedType}]); + if (!stillThere) { + requester.sendXt("ti", -1, TRADE_ITEM_GONE, owner.account.username, USERNAME_SHOWN); + owner.sendXt("ti", -1, TRADE_ITEM_GONE, requester.account.username, USERNAME_SHOWN); + return; + } + const toRequester = transfer(owner.account, requester.account, wantedType, wanted); + const toOwner = offered.map(item => ({type: item.type, entry: transfer(requester.account, owner.account, item.type, item.entry)})); + // for each side's account page: what went which way. + const wantedName = [nameOf(wantedType, toRequester)]; + const offeredNames = toOwner.map(item => nameOf(item.type, item.entry)); + note(requester.account, owner.account, wantedName, offeredNames); + note(owner.account, requester.account, offeredNames, wantedName); + accounts.save(); + requester.sendXt("ti", -1, TRADE_PROGRESS, COMPLETED, 1, ...doneFields(wantedType, toRequester), + offered.length, ...offered.flatMap(item => [doneType(item.type), item.entry.inv])); + owner.sendXt("ti", -1, TRADE_PROGRESS, COMPLETED, toOwner.length, ...toOwner.flatMap(item => doneFields(item.type, item.entry)), + 1, doneType(wantedType), wanted.inv); + }; + + // A player who disconnects mid-trade leaves the other side's windows open. + const forget = session => abandon(session, TRADE_CLOSED); + + const handlers = { + // [username] + tl(session, roomId, [username]) { + const account = accounts.byName(username); + if (account) { + sendTradeList(session, account); + } + }, + + // TradeXtCommManager.sendTradeSetRequest: [removeCount, (type, invIdx)..., + // addCount, (type, invIdx)...] + ts(session, roomId, params) { + const {account} = session; + const numbers = params.map(Number); + if (!numbers.every(Number.isInteger)) { + return; + } + const removeCount = numbers[0]; + const removals = numbers.slice(1, 1 + removeCount * 2); + const addCount = numbers[1 + removeCount * 2]; + const additions = numbers.slice(2 + removeCount * 2, 2 + (removeCount + addCount) * 2); + for (let i = 0; i + 1 < removals.length; i += 2) { + account.tradeList = account.tradeList.filter(entry => !(entry.type === removals[i] && entry.inv === removals[i + 1])); + } + for (let i = 0; i + 1 < additions.length; i += 2) { + const [type, inv] = [additions[i], additions[i + 1]]; + if (account.tradeList.length < MAX_TRADE_ITEMS && owns(account, type, inv) + && !account.tradeList.some(entry => entry.type === type && entry.inv === inv)) { + account.tradeList.push({type, inv}); + } + } + accounts.save(); + sendTradeList(session, account); + }, + + // ["1"/"0"]: busy flag while the trade window is open; nothing to answer. + tb() {}, + + ti(session, roomId, params) { + switch (params[0]) { + case STEP_OFFER: + offer(session, params); + break; + case STEP_ANSWER: + answer(session, params[1]); + break; + case STEP_CANCEL: + abandon(session, TRADE_CLOSED); + break; + case STEP_CONFIRM: + confirm(session, params[1] === "1"); + break; + } + }, + }; + + // ---- offers left for someone who is not there (the account page) + // + // an offer asks for one thing on another player's trade list and gives + // clothing or den items of one's own for it, as a trade in the game does, + // but waits on the other account until its owner answers on their page. + // it is account.tradeOffers of whoever is asked: {id, fromId, at, wanted: + // {type, inv}, offered: [{type, inv}]}, `fromId` the account id of who + // made it (an id, never a name: a name can pass to somebody else). + + const describe = (account, {type, inv}) => { + const entry = find(account, type, inv); + return entry ? {type, inv, name: nameOf(type, entry)} : null; + }; + + const offers = { + // what `account` could give: its clothing and den items, by name. + owned: account => [TYPE_CLOTHING, TYPE_DEN_ITEM].flatMap(type => collectionOf(account, type) + .filter(entry => type !== TYPE_DEN_ITEM || (masterpieces.itemApproved(entry) && !entry.placed)) + .map(entry => ({type, inv: entry.inv, name: nameOf(type, entry)}))) + .sort((one, other) => one.name.localeCompare(other.name)), + + // what `account` has up for trade (pets aside: they are not offered here). + listed: account => account.tradeList.filter(entry => entry.type !== TYPE_PET).map(entry => describe(account, entry)).filter(Boolean), + + // offers waiting on `account`, and the ones it made that still wait. + incoming: account => account.tradeOffers.map(offer => { + const from = accounts.byId(offer.fromId); + return from && {id: offer.id, from: from.username, at: offer.at, wanted: describe(account, offer.wanted), + offered: offer.offered.map(item => describe(from, item)).filter(Boolean)}; + }).filter(offer => offer && offer.wanted), + outgoing: account => accounts.all().flatMap(other => other.tradeOffers.filter(offer => offer.fromId === account.id) + .map(offer => ({id: offer.id, to: other.username, at: offer.at, wanted: describe(other, offer.wanted), + offered: offer.offered.map(item => describe(account, item)).filter(Boolean)}))).filter(offer => offer.wanted), + + // returns null, or why not: "unavailable" | "not_listed" | "nothing" | "not_yours" | "too_many". + make(from, to, wanted, offered) { + if (!to || to === from || blocks.either(from, to) || !accounts.featureOn(from, "trading") || !accounts.featureOn(to, "trading")) { + return "unavailable"; + } + const want = {type: Number(wanted && wanted.type), inv: Number(wanted && wanted.inv)}; + if (want.type === TYPE_PET || !find(to, want.type, want.inv) || !to.tradeList.some(listed => listed.type === want.type && listed.inv === want.inv)) { + return "not_listed"; + } + const give = (Array.isArray(offered) ? offered : []).map(item => ({type: Number(item && item.type), inv: Number(item && item.inv)})); + if (give.length === 0 || give.length > MAX_OFFERED) { + return "nothing"; + } + if (new Set(give.map(item => `${item.type}:${item.inv}`)).size !== give.length + || !give.every(item => [TYPE_CLOTHING, TYPE_DEN_ITEM].includes(item.type) && find(from, item.type, item.inv))) { + return "not_yours"; + } + if (to.tradeOffers.length >= MAX_WAITING_OFFERS || offers.outgoing(from).length >= MAX_OFFERS_MADE) { + return "too_many"; + } + to.tradeOffers.push({id: to.nextInv++, fromId: from.id, at: Math.floor(Date.now() / 1000), wanted: want, offered: give}); + accounts.save(); + return null; + }, + + // the asked account says yes or no. returns null, "no_offer", or "gone" + // when something in it has left one of the inventories since (the offer + // is dropped then). + answer(account, id, accept, refresh) { + const offer = account.tradeOffers.find(candidate => candidate.id === Number(id)); + if (!offer) { + return "no_offer"; + } + account.tradeOffers = account.tradeOffers.filter(candidate => candidate !== offer); + const from = accounts.byId(offer.fromId); + const wanted = find(account, offer.wanted.type, offer.wanted.inv); + const given = from ? offer.offered.map(item => ({type: item.type, entry: find(from, item.type, item.inv)})) : []; + if (accept && (!from || !wanted || given.some(item => !item.entry) || blocks.either(from, account) + || !fits(from, [offer.wanted], given) || !fits(account, given, [offer.wanted]))) { + accounts.save(); + return "gone"; + } + if (accept) { + const wantedName = [nameOf(offer.wanted.type, wanted)]; + const givenNames = given.map(item => nameOf(item.type, item.entry)); + transfer(account, from, offer.wanted.type, wanted); + given.forEach(item => transfer(from, account, item.type, item.entry)); + note(from, account, wantedName, givenNames); + note(account, from, givenNames, wantedName); + // whoever is in the game sees their inventories change. + [account, from].forEach(refresh); + } + accounts.save(); + return null; + }, + + withdraw(from, toName, id) { + const to = accounts.byName(toName); + const before = to ? to.tradeOffers.length : 0; + if (to) { + to.tradeOffers = to.tradeOffers.filter(offer => !(offer.id === Number(id) && offer.fromId === from.id)); + accounts.save(); + } + return Boolean(to) && to.tradeOffers.length < before; + }, + }; + + return {handlers, forget, offers}; +}; diff --git a/lib/wall-art.json b/lib/wall-art.json new file mode 100644 index 0000000..4634eb1 --- /dev/null +++ b/lib/wall-art.json @@ -0,0 +1,53 @@ +{ + "wallpapers": [ + {"media": 4011, "button": 4000}, + {"media": 4012, "button": 4001}, + {"media": 4013, "button": 4002}, + {"media": 4014, "button": 4003}, + {"media": 4015, "button": 4004}, + {"media": 4016, "button": 4005}, + {"media": 4017, "button": 4006}, + {"media": 4018, "button": 4007}, + {"media": 4019, "button": 4008}, + {"media": 4020, "button": 4009}, + {"media": 4021, "button": 4010}, + {"media": 3941, "button": 3950}, + {"media": 3942, "button": 3951}, + {"media": 3943, "button": 3952}, + {"media": 3944, "button": 3954}, + {"media": 3945, "button": 3955}, + {"media": 3946, "button": 3956}, + {"media": 3947, "button": 3957}, + {"media": 3948, "button": 3958}, + {"media": 3949, "button": 3953}, + {"media": 3959, "button": 3962}, + {"media": 3960, "button": 3961}, + {"media": 3993, "button": 3984}, + {"media": 3994, "button": 3985}, + {"media": 3995, "button": 3986}, + {"media": 3996, "button": 3987}, + {"media": 3997, "button": 3988}, + {"media": 3998, "button": 3989}, + {"media": 3999, "button": 3990}, + {"media": 4023, "button": 4031}, + {"media": 4024, "button": 4032}, + {"media": 4025, "button": 4033}, + {"media": 4026, "button": 4034}, + {"media": 4027, "button": 4035}, + {"media": 4028, "button": 4036}, + {"media": 4029, "button": 4037}, + {"media": 4030, "button": 4038}, + {"media": 4040, "button": 4039}, + {"media": 6453, "button": 6460}, + {"media": 6454, "button": 6461}, + {"media": 6455, "button": 6462}, + {"media": 6456, "button": 6463}, + {"media": 6457, "button": 6464}, + {"media": 6459, "button": 6465}, + {"media": 3991, "button": 4003}, + {"media": 3992, "button": 4005}, + {"media": 6452, "button": 4000}, + {"media": 6458, "button": 4009} + ], + "stickers": [6265,6266,6267,6268,6269,6270,6271,6281,6282,6283,6284,6285,6286,6287,6288,6289,6290,6291,6292,6293,6294,6295,6296,6297,6298,6299,6300,6301,6302,6303,6304,6305,6306] +} diff --git a/lib/walls.js b/lib/walls.js new file mode 100644 index 0000000..d0707fb --- /dev/null +++ b/lib/walls.js @@ -0,0 +1,354 @@ +"use strict"; + +const crypto = require("crypto"); +const fs = require("fs"); +const path = require("path"); +const accounts = require("./accounts.js"); +const masterpieces = require("./masterpieces.js"); +const limits = require("./limits.js"); +const {isUint} = require("./player.js"); +const {isSilenced} = require("./moderation.js"); + +// Jammer Walls (client side: PlayerWallManager, PlayerWallGui, +// PlayerWallXtCommManager): a page per player where they and their visitors +// leave short messages, decorated by its owner. +// +// the client does this in two parts. over the game socket it asks for a +// token for one player's wall ("wt"); with that token it then talks JSON +// over HTTP to the address in the playerWallHost flashvar (POST /wall here): +// CHK "has it changed?", GET, PUT a message, DEL one, and a few more. +// +// A wall is account.wall: {privacy, posts, params, visits, hidden, modified, +// readAt}; a new account's empty one is made in lib/accounts.js. + +// who may open a wall (BuddyCard.onPlayerWallPrivacyGet), as for dens. +const NOBODY = 0; +const BUDDIES = 1; +const EVERYONE = 2; + +// PlayerWallManager.handleTokenResponse +const TOKEN_OK = 1; +const WALL_LOCKED = -1; +const BUDDIES_ONLY = -2; +const UNAVAILABLE = 0; + +const TOKEN_MINUTES = 60; +const MAX_TOKENS = 20000; +const MAX_WALLS_OPEN = 20; // walls one player holds a token for at a time +const MAX_POSTS = 100; +const MAX_MESSAGE = 200; // the client's own box stops at 70 +const MAX_PARAMS_JSON = 8000; +const MAX_HIDDEN = 500; +const USERNAME_SHOWN = 1; +// what an owner may set about their wall (PlayerWallGui.checkForWallParameterChanges): +// background, stickers, masterpieces, the photo booth picture, status line. +const OWNER_PARAMS = ["bg", "stk", "mp", "pb", "tag", "langId"]; + +// generic lists the wall window asks for: the wallpapers' buttons in the +// "customize" popup, the wallpapers themselves (a wall's "bg" parameter is a +// place in this list, 19 until its owner picks another), and stickers. +// like the Jam-A-Gram cards these lists only existed on the official +// servers; lib/wall-art.json holds what tools/find-art.py found on the +// CDN. without the wallpaper list a wall never appears at all. +const LIST_WALLPAPER_BUTTONS = 313; +const LIST_WALLPAPERS = 314; +const LIST_STICKERS = 646; +const RESOURCE_WALL_LIKES = "jammerwall"; +const RESOURCE_MASTERPIECE_LIKES = "masterpiece"; +const art = JSON.parse(fs.readFileSync(path.join(__dirname, "wall-art.json"), "utf8")); + +const postsPerTenMinutes = limits.limiter(60, 600000); + +const clean = text => String(text).replace(/[\u0000-\u001f\u007f]/g, " ").trim().slice(0, MAX_MESSAGE); +// A wall parameter is read by every visitor's game: a number or a short +// text, or a short list of those or of small flat objects of those (the +// stickers and paintings on a wall). nothing nested deeper, nothing long. +const MAX_PARAM_TEXT = 300; +const MAX_PARAM_ENTRIES = 60; +const scalar = value => value === null || typeof value === "boolean" || (typeof value === "number" && Number.isFinite(value)) + || (typeof value === "string" && value.length <= MAX_PARAM_TEXT); +const flat = value => scalar(value) || (typeof value === "object" && !Array.isArray(value) + && Object.keys(value).length <= 12 && Object.values(value).every(scalar)); +const plainParam = value => flat(value) || (Array.isArray(value) && value.length <= MAX_PARAM_ENTRIES && value.every(flat)); +const whole = value => (Number.isInteger(Number(value)) ? Number(value) : 0); + +module.exports = ({blocks}) => { + const tokens = new Map(); // token -> {viewer: account id, owner: account id, expires} + + const mayOpen = (owner, viewer) => { + if (owner === viewer) { + return TOKEN_OK; + } + if (owner.wall.privacy === NOBODY || blocks.either(owner, viewer) || !accounts.featureOn(owner, "wall") || !accounts.featureOn(viewer, "wall")) { + return WALL_LOCKED; + } + if (owner.wall.privacy === BUDDIES && !owner.buddies.includes(viewer.username.toLowerCase())) { + return BUDDIES_ONLY; + } + return TOKEN_OK; + }; + + // one token for a viewer and a wall, given again while it is good, and + // tokens for no more than MAX_WALLS_OPEN walls a viewer: asking in a loop + // gets the same few back and pushes nobody else's out. + const issue = (viewer, owner) => { + const mine = []; + for (const [token, entry] of tokens) { + if (entry.expires < Date.now()) { + tokens.delete(token); + } + else if (entry.viewer === viewer.id) { + mine.push([token, entry]); + } + } + const same = mine.find(([, entry]) => entry.owner === owner.id); + if (same) { + same[1].expires = Date.now() + TOKEN_MINUTES * 60000; + return same[0]; + } + for (const [token] of mine.sort((one, other) => one[1].expires - other[1].expires).slice(0, Math.max(0, mine.length - MAX_WALLS_OPEN + 1))) { + tokens.delete(token); + } + if (tokens.size >= MAX_TOKENS) { + tokens.delete(tokens.keys().next().value); + } + const token = crypto.randomBytes(18).toString("hex"); + tokens.set(token, {viewer: viewer.id, owner: owner.id, expires: Date.now() + TOKEN_MINUTES * 60000}); + return token; + }; + + // {viewer, owner} accounts for a token still good, else null. + const resolve = token => { + const entry = typeof token === "string" ? tokens.get(token) : null; + if (!entry || entry.expires < Date.now()) { + return null; + } + const viewer = accounts.byId(entry.viewer); + const owner = accounts.byId(entry.owner); + return viewer && owner && mayOpen(owner, viewer) === TOKEN_OK ? {viewer, owner} : null; + }; + + // PlayerWallXtCommManager.getResponse: r = posts, n = notifications (replies + // to the viewer elsewhere; not kept here), p = the wall's parameters with + // the visit count and the time its owner last read it, t = last change. + const getReply = (owner, viewer) => { + const {wall} = owner; + const hidden = new Set(wall.hidden); + const reply = { + s: true, + r: wall.posts.filter(post => !hidden.has(post.x)), + n: [], + p: {...wall.params, visits: wall.visits, rdt: wall.readAt}, + t: wall.modified, + }; + if (viewer === owner) { + wall.readAt = Date.now(); + } + return reply; + }; + + const put = (owner, viewer, body) => { + const colours = Array.isArray(body.ac) ? body.ac.slice(0, 3).map(String) : []; + const message = clean(body.m === undefined ? "" : body.m); + if (!message || isSilenced(viewer) || !colours.every(isUint) || !postsPerTenMinutes.allow(viewer.id)) { + // PlayerWallGui.onMessageSent: cs -1 = "could not be posted" + return {PUT: {s: false, cs: -1}}; + } + const post = { + x: crypto.randomBytes(8).toString("hex"), + m: message, + uid: viewer.id, + un: viewer.username, + um: USERNAME_SHOWN, + u: viewer.uuid, + s: whole(body.s), // pattern behind the message + c: whole(body.c), // its colour + t: Date.now(), + ai: whole(body.ai), // the poster's animal, for the little portrait + ac: colours.map(Number), + ae: whole(body.ae), + ap: whole(body.ap), + l: whole(body.l), + aci: whole(body.aci), + }; + if (typeof body.pp === "string" && owner.wall.posts.some(other => other.x === body.pp)) { + post.pp = body.pp; // a reply to that post + } + owner.wall.posts.push(post); + owner.wall.posts = owner.wall.posts.slice(-MAX_POSTS); + owner.wall.modified = post.t; + accounts.save(); + return {PUT: {s: true}, x: post.x, t: post.t, GET: getReply(owner, viewer)}; + }; + + // POST /wall: one JSON command, one JSON answer. + const http = body => { + const cmd = String(body && body.cmd); + const who = resolve(body && body.t); + if (!who) { + // any command but PUT reads "e" at the top; PUT reads it inside PUT. + return cmd === "PUT" ? {PUT: {s: false, e: "token"}} : {s: false, e: "token"}; + } + const {owner, viewer} = who; + const {wall} = owner; + const mine = owner === viewer; + switch (cmd) { + case "CHK": + return {s: true, t: wall.modified}; + case "GET": + return getReply(owner, viewer); + case "PUT": + return put(owner, viewer, body); + case "DEL": { + // the owner may remove anything; anyone may remove what they wrote. + const post = wall.posts.find(candidate => candidate.x === body.x); + if (!post || !(mine || post.uid === viewer.id)) { + return {s: false}; + } + wall.posts = wall.posts.filter(candidate => candidate !== post && candidate.pp !== post.x); + wall.modified = Date.now(); + accounts.save(); + return {s: true}; + } + case "GMB": // posts the owner chose to hide + return {s: true, r: mine ? wall.hidden : []}; + case "AMB": + if (!mine || typeof body.x !== "string" || !wall.posts.some(post => post.x === body.x)) { + return {s: false}; + } + wall.hidden = [...new Set([...wall.hidden, body.x])].slice(-MAX_HIDDEN); + accounts.save(); + return {s: true}; + case "CLW": + if (!mine) { + return {s: false}; + } + wall.posts = []; + wall.hidden = []; + wall.modified = Date.now(); + accounts.save(); + return {s: true}; + case "RMP": // masterpieces taken off the wall; there are none + case "ACK": // notifications marked as read; there are none + return {s: true}; + default: + return {s: false, e: "unavailable"}; + } + }; + + const byUuid = uuid => accounts.all().find(account => account.uuid === uuid) || null; + const likes = owner => owner.wall.likes || []; + + const handlers = { + // the wall's like button (ResourceArrayXtCommManager): ["jammerwall", + // ownerUuid, myUuid, ...] -> [success, likedByMe, likes]. + crg(session, roomId, [resource, ownerUuid]) { + if (resource === RESOURCE_MASTERPIECE_LIKES) { + // A masterpiece's likes: the second field is the painting's id. + const painting = masterpieces.get(ownerUuid); + session.sendXt("crg", -1, painting ? 1 : 0, painting && painting.likes.includes(session.account.id) ? 1 : 0, painting ? painting.likes.length : 0); + return; + } + const owner = resource === RESOURCE_WALL_LIKES ? byUuid(ownerUuid) : null; + session.sendXt("crg", -1, owner ? 1 : 0, owner && likes(owner).includes(session.account.id) ? 1 : 0, owner ? likes(owner).length : 0); + }, + + // the same, pressed: -> [success]. one like a player, and not one's own wall. + crp(session, roomId, [resource, ownerUuid]) { + if (resource === RESOURCE_MASTERPIECE_LIKES) { + session.sendXt("crp", -1, masterpieces.like(ownerUuid, session.account) ? 1 : 0); + return; + } + const owner = resource === RESOURCE_WALL_LIKES ? byUuid(ownerUuid) : null; + const allowed = Boolean(owner) && owner !== session.account && !likes(owner).includes(session.account.id) + && mayOpen(owner, session.account) === TOKEN_OK; + if (allowed) { + owner.wall.likes = [...likes(owner), session.account.id]; + accounts.save(); + } + session.sendXt("crp", -1, allowed ? 1 : 0); + }, + + // [username] -> [status, token, mayRead, mayWrite, username] + wt(session, roomId, [username]) { + const owner = accounts.byName(username); + const status = owner ? mayOpen(owner, session.account) : UNAVAILABLE; + if (status !== TOKEN_OK) { + session.sendXt("wt", -1, status); + return; + } + session.sendXt("wt", -1, TOKEN_OK, issue(session.account, owner), 1, 1, owner.username); + }, + + // [setting]: who may open my wall -> [success] + wss(session, roomId, [setting]) { + const value = Number(setting); + const valid = [NOBODY, BUDDIES, EVERYONE].includes(value); + if (valid) { + session.account.wall.privacy = value; + accounts.save(); + } + session.sendXt("wss", -1, valid ? 1 : 0); + }, + + // [username] -> that player's setting + wsg(session, roomId, [username]) { + const owner = accounts.byName(username); + session.sendXt("wsg", -1, owner ? owner.wall.privacy : NOBODY); + }, + + // [JSON of the parameters that changed] -> [success] + wps(session, roomId, params) { + const {wall} = session.account; + let changes; + try { + // "%" cannot travel inside a field, so nothing was split apart. + changes = JSON.parse(params.join("%")); + } + catch (err) { + changes = null; + } + const merged = changes && typeof changes === "object" && !Array.isArray(changes) ? {...wall.params} : null; + for (const key of merged ? OWNER_PARAMS : []) { + if (changes[key] !== undefined) { + if (!plainParam(changes[key])) { + session.sendXt("wps", -1, 0); + return; + } + merged[key] = changes[key]; + } + } + if (!merged || JSON.stringify(merged).length > MAX_PARAMS_JSON) { + session.sendXt("wps", -1, 0); + return; + } + wall.params = merged; + wall.modified = Date.now(); + accounts.save(); + session.sendXt("wps", -1, 1); + }, + + // [username]: "I looked at that wall" -> [success] + wci(session, roomId, [username]) { + const owner = accounts.byName(username); + if (owner && owner !== session.account && mayOpen(owner, session.account) === TOKEN_OK) { + owner.wall.visits++; + accounts.save(); + } + session.sendXt("wci", -1, owner ? 1 : 0); + }, + }; + + // GenericListXtCommManager.handleMediaResponse: (mediaId, name) pairs; + // null when `listId` is not one of the wall window's lists. + const list = listId => { + const ids = { + [LIST_WALLPAPER_BUTTONS]: art.wallpapers.map(wallpaper => wallpaper.button), + [LIST_WALLPAPERS]: art.wallpapers.map(wallpaper => wallpaper.media), + [LIST_STICKERS]: art.stickers, + }[Number(listId)]; + return ids ? ids.flatMap(id => [id, 0]) : null; + }; + + return {handlers, http, list}; +}; diff --git a/lib/world.js b/lib/world.js new file mode 100644 index 0000000..120913a --- /dev/null +++ b/lib/world.js @@ -0,0 +1,1518 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const achievements = require("./achievements.js"); +const adopt = require("./adopt.js"); +const config = require("../config.js"); +const colours = require("./colours.js"); +const commandModule = require("./commands.js"); +const limits = require("./limits.js"); +const masterpieces = require("./masterpieces.js"); +const defpacks = require("./defpacks.js"); +const avatarHandlers = require("./avatars.js"); +const badges = require("./badges.js"); +const bans = require("./bans.js"); +const chatlog = require("./chatlog.js"); +const buddyModule = require("./buddies.js"); +const dens = require("./dens.js"); +const disguises = require("./disguises.js"); +const ecardModule = require("./ecards.js"); +const epicDens = require("./epicdens.js"); +const itemHandlers = require("./items.js"); +const minigameModule = require("./minigames.js"); +const adventureModule = require("./adventures.js"); +const moderationModule = require("./moderation.js"); +const partyModule = require("./parties.js"); +const petModule = require("./pets.js"); +const reports = require("./reports.js"); +const roomInfo = require("./roominfo.js"); +const shopStock = require("./shopstock.js"); +const signup = require("./signup.js"); +const tradeHandlers = require("./trades.js"); +const stubHandlers = require("./stubs.js"); +const wallModule = require("./walls.js"); +const worldItems = require("./worlditems.js"); +const {CURRENCIES, DIAMOND_TYPES, activeAvatar, avatarById, activePet, equippedBits, wornItems, lastSeenField} = require("./player.js"); + +// game logic behind the socket. field orders below mirror the client's +// parsers; the class that reads each message is named next to it. + +const GENERIC_LIST_AVATARS = 64; +const GENERIC_LIST_NEWSPAPER = 627; +const USER_VAR_NEWSPAPER_READ = 455; +const USER_VAR_GEM_BONUS = 214; +// not one of the game's: the patched client's "hide blocked players" setting +// (gui.MySettings), kept with the user vars so it reaches the client at login. +const USER_VAR_HIDE_BLOCKED = 9001; +// "Graphics" in the game's settings menu: 1 Default (smooth graphics off), +// 2 Smooth, unset for the server's default (config.smooth). +const USER_VAR_GRAPHICS = 9003; +const GENERIC_LIST_WORLD_ITEMS = 583; +const DEF_PET_FOOD = 1062; +const DEF_PET_TOY = 1063; +// the two exchange counters: gems for tickets (114), diamonds for gems (169). +const CURRENCY_GEMS = 0; +const CURRENCY_DIAMONDS = 3; +const EXCHANGE_LIST_PAID_WITH = new Map([[114, CURRENCY_GEMS], [169, CURRENCY_DIAMONDS]]); +// the phrase menus ("safe chat": SafeChatManager) of the chat bar (47), +// Jam-A-Grams and reports (66), the photo booth (158), adventures (170) and +// Jammer Walls (333). an entry is the id of a localization string holding +// one menu, a phrase to a line; when the first line ends in "..." the rest +// complete it. which menus each list had is not in any file; these are the +// game's own menu strings, sorted by what they are evidently for. the lists +// must not be empty: the Jam-A-Gram window reads the first phrase of 66. +const range = (first, last) => Array.from({length: last - first + 1}, (_, i) => first + i); +const DEF_NAMEBAR_BADGE = 1049; +const GENERIC_LIST_GAMES = 341; // GameJoinPopup: game def ids +const SAFE_CHAT_LISTS = new Map([ + [47, [36, 22, 23, 24, 25, 33, 26, 30, 29, 31, 32, 34, 35, 28]], + [66, [1759, 1760, 1769, 1758, 1761, 1762, 1763, 1764, 1765, 1768, 1767, 1770, 1771, 3126, 1766]], + [158, [36, 26, 33]], + [170, [...range(3549, 3556), ...range(3585, 3592)]], + [333, [27, 36, 25, 33, 26, 28]], +]); +// the client shows a cut-down party list to accounts less than a day old +// (PartyPopup) and a "refer a friend" button to ones older than three +// (BuddyList). neither is wanted, so every account says it is two days old. +const ACCOUNT_AGE_SHOWN_SECONDS = 2 * 86400; +const MOTD_SETTING = "motd"; +const MAX_ANNOUNCEMENT = 300; +const RECENT_CHAT_LINES = 15; +// bit flags for tutorials already seen: the den editor's and den shop's +// talking prompts (379) and the trade list help boxes (129). every bit is kept +// set so none of them ever shows. for these two the client sends the number +// of the bit to set, not a new value (UserVarCache.isBitSet). +const USER_VAR_DEN_TUTORIAL = 379; +const USER_VAR_TRADE_TUTORIAL = 129; +const TUTORIALS_ALL_SEEN = 65535; +const BIT_FLAG_VARS = [USER_VAR_DEN_TUTORIAL, USER_VAR_TRADE_TUTORIAL]; +const GEM_BONUS_NEVER_DUE = 65535; +// pets the pet picker must not offer (PetCreator.onNotViewablePetDefsLoaded); none here. +const GENERIC_LIST_HIDDEN_PETS = 574; +// word lists for the animal (first, second, third word) and pet (first, +// second) name pickers. entries are localization string ids; the id ranges +// were read off the English localization defPack, where each list sits in one +// alphabetical block. +const NAME_LISTS = new Map([ + [200, [15136, 15223]], + [202, [15224, 15298]], + [203, [15299, 15385]], + [205, [15386, 15427]], + [206, [15428, 15475]], +]); +const DEF_ITEM = 1000; +const DEF_PET = 1046; +const DEF_DEN_ITEM = 1030; +const DEF_COMBINED_LIST = 1060; +const DEF_DEN_ROOM = 1040; +const DEF_CURRENCY_EXCHANGE = 1051; +const DEF_DIAMOND = 1054; +const SHOP_LIST_TYPES = [DEF_ITEM, DEF_DEN_ITEM, DEF_DEN_ROOM, DEF_COMBINED_LIST, DEF_CURRENCY_EXCHANGE, DEF_DIAMOND]; +// diamond lists the client reads at login to learn which animals and pets +// cost diamonds. they stay empty: animals and pets are free here. +const DIAMOND_ANIMAL_AND_PET_LISTS = [166, 214, 293]; +// the Diamond Shop's two den displays ("one" and "two" in its room file). +// taken for the dens sold for diamonds: nothing else in the room is. +const DIAMOND_DEN_LIST = 196; +const LANG_ENG = 0; +const IDLE_ANIM_LAND = 14; +const IDLE_ANIM_OCEAN = 29; +const MAX_PATH_POINTS = 12; +const TYPED_NAME = /^[A-Za-z0-9][A-Za-z0-9 '.-]{0,19}$/; // an animal's or pet's name typed by its owner +const MAX_BLOCKED = 1000; // from the account page; the game's own button has no limit +const TYPED_CHAT_TYPES = ["0", "9"]; +const MAX_CHAT_EXTRA = 100; // the field after a chat line's type +const MAX_USER_VARS = 2000; +const MAX_FILTER_WORDS = 100; // a player's own words for their chat filter +const MAX_FILTER_WORD = 30; +const LOGIN_BANNED = -15; // MainFrame.MSG_ID_LOGIN_BANNED + +const THEME_PATH_PREFIX = "theme_"; // lib/http.js looks for this +const chatLines = limits.limiter(config.chatLinesPerWindow, config.chatWindowMs); +const online = new Map(); // lowercased username -> session +const rooms = new Map(); // "path.name#shard" -> room +let nextRoomId = 100; + +const others = session => session.room ? [...session.room.sessions].filter(s => s !== session) : []; + +// blocking. A player who blocked another never gets their chat, cannot be +// visited, written to or joined by them; with their "hide blocked players" +// setting on, they do not get that player's animal drawn at all. +const nameKey = account => account.username.toLowerCase(); +const blocks = { + has: (blocker, target) => blocker.blocked.includes(nameKey(target)), + either: (a, b) => a.blocked.includes(nameKey(b)) || b.blocked.includes(nameKey(a)), +}; +const sees = (viewer, subject) => !(viewer.account.hideBlocked && blocks.has(viewer.account, subject.account)); +// everyone else in the room who should hear about this player's animal. +const watchers = session => others(session).filter(other => sees(other, session)); + +const decodeEntities = text => text + .replace(/</g, "<") + .replace(/>/g, ">") + .replace(/'/g, "'") + .replace(/"/g, '"') + .replace(/&/g, "&"); + +// GamePlay.onWorldLogIn +const loginParams = session => { + const {account} = session; + const params = { + userId: session.id, + userName: account.username, + dbUserId: account.id, + uuid: account.uuid, + accountType: account.accountType, + accountTypeChanged: false, + avName: activeAvatar(account).name, + perUserAvId: activeAvatar(account).perUserAvId, + activeDenRoomInvId: account.activeDen, + activePetInvId: activeAvatar(account).petInvId, + createdAt: Math.floor(Date.now() / 1000) - ACCOUNT_AGE_SHOWN_SECONDS, + numLogins: account.numLogins, + sessionId: session.id, + jamaaDate: Math.floor(Date.now() / 86400000), + // bit 0: tutorial finished, and what most name tag badges ask for. bit 2 + // unlocks the one badge that asks for more (defPack 1049, + // pendingFlagsBit). bit 4 would force the "fast pass" avatar flow. + // bit 1 is the "extended inventory" (more den items placed, bigger + // inventories); the patched client counts to 5,000 of each either way + // (shop.ShopManager). + // from bit 8 up: the name tag badges the admin gave this account + // (lib/badges.js). + pendingFlags: 7 | badges.loginFlags(account), + dailyGiftIndex: -1, + hasOnlineBuddies: buddies.hasOnlineBuddies(account), + // one bit per kind of interaction (Utility.canBuddy, canTrade, canGift, + // canChat, ...); everything is allowed. + interactions: 1023, + isGuide: account.isGuide, + isModerator: account.isModerator, + userNameModerated: 1, + sgChatType: 1, + sgChatTypeNonDegraded: 1, + denPrivacySettings: account.denPrivacy, + playerWallSettings: account.wall.privacy, + // not 0: PlayerWallManager only opens walls for accounts with them on. + webWallStatus: 1, + eCardPrivacySettings: account.ecardPrivacy, + // not empty: with neither address set, every fifth login opens a + // "parent's email" window (GuiManager.showAjEmailBtn). accounts here + // have no email. + email: "-", + pendingEmail: "", + lastBroadcastMessage: "", + numAJHQGiftCards: 0, + numAJHQBulkGiftCards: 0, + numRedemptionCards: ecards.redemptions(account), + numUnreadECards: ecards.unread(account), + numDaysLeftOnSubscription: account.membershipDays, + subscriptionSourceType: 0, + recyclePercentage: 0.3, + usableAdoptAPetDefs: adopt.loginList(account), + newspaperDefs: [], + }; + for (const name of CURRENCIES) { + account.currency[name] = Math.max(account.currency[name] || 0, config.minimumCurrency); + params[`${name}Count`] = account.currency[name]; + } + return params; +}; + +const loginFailed = (session, statusId, message) => { + session.sendXtJson(-1, {_cmd: "login", status: "0", statusId, message, params: {}}); +}; + +// SmartFoxClient.login: nick is "username%sessionId%language%deployVersion% +// platform%platformVersion%os%df" and pword is the auth token. +const login = (session, msg) => { + if (new RegExp(``).test(msg.raw)) { + // guest login for the Create Account screens (SysHandler.handleLoginOk). + session.signingUp = true; + session.sendSys("logOK", 0, ``); + return; + } + // one login to a socket: a second would leave the first account looking online. + if (session.account) { + session.close(); + return; + } + const username = (msg.cdata("nick") || "").split("%")[0]; + const account = accounts.byToken(msg.cdata("pword")); + if (!account || account.username.toLowerCase() !== username.toLowerCase()) { + console.log(`[world] login rejected for "${username}"`); + loginFailed(session, 0, "Invalid login"); + return; + } + if (moderation.banRemaining(account) !== 0) { + console.log(`[world] login rejected for banned account "${account.username}"`); + loginFailed(session, LOGIN_BANNED, "Banned"); + return; + } + // A banned address (lib/bans.js). the client is told at /authenticate, + // with the reason; this is for a game that got here another way. + if (bans.addressBan(session.address)) { + console.log(`[world] login rejected for "${account.username}" from a banned address`); + loginFailed(session, LOGIN_BANNED, "Banned"); + return; + } + // its username was rejected (lib/moderation.js): a new one first, which + // the client or the account page asks for. + if (account.nameRejected) { + console.log(`[world] login rejected for "${account.username}": the name was rejected`); + loginFailed(session, 0, "Username rejected"); + return; + } + // locked by its owner on the account page (lib/manage.js). + if (account.locked) { + console.log(`[world] login rejected for locked account "${account.username}"`); + loginFailed(session, 0, "Account locked"); + return; + } + const key = account.username.toLowerCase(); + const existing = online.get(key); + if (existing && existing !== session) { + existing.close(); + leaveWorld(existing); + } + session.account = account; + account.numLogins++; + accounts.recordLogin(account, "game", session.address); + account.lastLogin = Math.floor(Date.now() / 1000); + session.recentChat = []; + session.greeted = false; + session.arrived = false; // not yet put in a first room + if (account.randomTheme) { + const names = Object.keys(config.themes); + account.theme = names[Math.floor(Math.random() * names.length)]; + } + account.pets.forEach(pets.giveCharacter); + adopt.dailyFind(account); + // before the session is findable, so that nothing is sent ahead of the + // login reply. + achievements.refresh(account); + accounts.save(); + online.set(key, session); + console.log(`[world] ${account.username} logged in as sfs user ${session.id}`); + session.sendXtJson(-1, {_cmd: "login", status: "1", params: loginParams(session)}); + // every custom colour, before anything that might be drawn with one + // (XtReplyDemuxer -> PaletteHelper.handleCustomColors in the patched SWF). + for (const chunk of colours.chunks()) { + session.sendXt("xcc", -1, chunk.length, ...chunk.flat()); + } + sendFilter(session); + buddies.announce(account); +}; + +// ItemXtCommManager.itemListResponse ("0": everything the player owns, five +// fields per item) / itemsInUseResponse ("1": what one animal is wearing, +// three fields per item). both start with the animal's eyes and pattern. +const sendItemList = (to, target, full, perUserAvId) => { + const {account} = target; + const avatar = avatarById(account, perUserAvId); + const items = full + ? account.items.flatMap(item => [item.def, item.inv, item.color, equippedBits(item), 0]) + : wornItems(account, avatar).flatMap(item => [item.def, item.inv, item.color]); + const count = full ? account.items.length : wornItems(account, avatar).length; + to.sendXt("il", -1, full ? "0" : "1", 0, avatar.perUserAvId, account.username, avatar.eyes, avatar.pattern, count, ...items); +}; + +// lBits, uBits, eBits, name, createdTs, personality, favourite toy, favourite food +const petFields = pet => pet + ? [pet.lBits, pet.uBits, pet.eBits, pet.name, pet.createdAt, pet.personality || 0, pet.toy || 0, pet.food || 0] + : [0, 0, 0, "", 0, 0, 0, 0]; + +// AvatarXtCommManager.avatarDataResponse +const sendAvatarData = (to, target, perUserAvId) => { + const {account} = target; + const avatar = avatarById(account, perUserAvId); + const enviroType = target.room ? target.room.enviroType : 0; + const head = [ + account.username, account.uuid, + account.nameBarData, + enviroType, + 1, // userNameModeratedFlag + parties.timeLeft(account), // timeLeftHostingCustomParty + lastSeenField(account, Boolean(findOnline(account.username))), // daysSinceLastLogin: see lib/player.js + avatar.perUserAvId, avatar.type, avatar.customAvId, + ...avatar.colors, + avatar.name, + avatar.questLevel || 0, // the admin sets it: setQuestLevel + ]; + const tail = to === target + // avInvId, landPetInvId, oceanPetInvId, attackBase, attackMax, defenseBase, defenseMax, healthBase + ? [avatar.avInvId, avatar.petInvId, avatar.petInvId, 0, 0, 0, 0, 100] + // pet lBits, uBits, eBits, name + : petFields(activePet(account)).slice(0, 4); + to.sendXt("ad", -1, ...head, ...tail); +}; + +// AvatarManager.avatarCreateResponse: puts `target` on `to`'s screen. +const sendAvatarCreate = (to, target) => { + const {account, room} = target; + const avatar = activeAvatar(account); + const pet = activePet(account); + to.sendXt("ac", room.id, + target.id, target.pos.x, target.pos.y, + room.enviroType === 0 ? IDLE_ANIM_LAND : IDLE_ANIM_OCEAN, + account.username, account.uuid, + avatar.perUserAvId, avatar.name, avatar.type, avatar.customAvId, + ...avatar.colors, + avatar.questLevel || 0, + 1, // userNameModeratedFlag + lastSeenField(account, Boolean(findOnline(account.username))), // daysSinceLastLogin: see lib/player.js + // optional-field flags: bit 0 accountType, bit 1 nameBarData, bit 2 pet + pet ? 7 : 3, + account.accountType, + account.nameBarData, + ...(pet ? petFields(pet) : [])); + sendItemList(to, target, false); + disguises.show(to, target); +}; + +// redraws `session`'s animal for everyone else in the room, for changes the +// protocol has no dedicated broadcast for (colours). +const refreshForOthers = session => { + if (!session.pos) { + return; + } + for (const other of watchers(session)) { + other.sendXt("ar", session.room.id, session.id); + sendAvatarCreate(other, session); + } +}; + +const denRoomsForSale = () => defpacks.denRoomIds().filter(id => defpacks.denRoomName(id)); + +// the Summer Carnival's three shops sell what is priced in tickets, and +// nobody else does: clothing, den items, and the plushie stand. +const CURRENCY_TYPE_TICKETS = "1"; +const TICKET_SHOPS = new Map([[101, "clothing"], [165, "denItems"], [102, "plushies"]]); +let stock = null; +const sortStock = () => { + if (!stock) { + const forTickets = def => def.currencyType === CURRENCY_TYPE_TICKETS; + const clothing = defpacks.clothingIds(); + const denItems = defpacks.denItemIds().filter(id => !defpacks.unsoldDenItemIds().includes(id)); + const ticketDenItems = denItems.filter(id => forTickets(defpacks.denItemDef(id))); + const isPlushie = id => /plush/i.test(defpacks.denItemDef(id).abbrName); + stock = { + clothing: clothing.filter(id => forTickets(defpacks.itemDef(id))), + denItems: ticketDenItems.filter(id => !isPlushie(id)), + plushies: ticketDenItems.filter(isPlushie), + }; + } + return stock; +}; +// two out-of-the-way shops keep what was never in one: the shop in the +// Chamber of Knowledge's base (reached from a hidden spot on the world map) +// has the den items, the one in the Zios archives the clothing. see +// oddDenItemIds in lib/defpacks.js. +const ODDITY_SHOPS = new Map([[396, () => defpacks.oddDenItemIds()], [666, () => defpacks.oddClothingIds()]]); +const ticketStock = kind => sortStock()[kind]; +// the den shops of the lands (Coral Canyons, Deep Blue) and the one inside +// a den: lists that mix kinds, selling den rooms. +const DEN_SHOP_LISTS = [213, 375, 384]; + +// AchievementXtCommManager.getUserVarsResponse: [count, (varId, type, value)...] +const sendUserVars = session => { + const vars = session.account.userVars; + // there is no newspaper on this server; a "last read" time stops the + // client opening an empty one at every login (NewspaperManager). + if (vars[USER_VAR_NEWSPAPER_READ] === undefined) { + vars[USER_VAR_NEWSPAPER_READ] = Math.floor(Date.now() / 1000); + } + // likewise the daily gem-bonus wheel: GuiManager.guiStartupChecks spins it + // when the low 16 bits of this var (the day it was last spun) are before + // today's jamaaDate. the far-future day keeps it shut. + vars[USER_VAR_GEM_BONUS] = GEM_BONUS_NEVER_DUE; + vars[USER_VAR_DEN_TUTORIAL] = TUTORIALS_ALL_SEEN; + vars[USER_VAR_TRADE_TUTORIAL] = TUTORIALS_ALL_SEEN; + vars[USER_VAR_HIDE_BLOCKED] = session.account.hideBlocked ? 1 : 0; + const entries = Object.entries(vars); + // smooth graphics off by default: told to the client as "Graphics: + // default", and kept nowhere, so the default can change back. + if (!config.smooth && !(Number(vars[USER_VAR_GRAPHICS]) > 0)) { + entries.push([String(USER_VAR_GRAPHICS), 1]); + } + session.sendXt("zg", -1, entries.length, ...entries.flatMap(([id, value]) => [id, 0, value])); +}; + +const findOnline = username => online.get(String(username).toLowerCase()); + +// the account's chat filter, for its game to apply: [chosen, level, mode, own words]. +const sendFilter = session => { + const {filter} = session.account; + session.sendXt("xfl", -1, filter.chosen ? 1 : 0, filter.level, filter.mode, filter.words); +}; + +// the player called `username` as the senders above take one: their session +// when they are playing, else just their account. A player's card can be +// opened for anybody (the buddy list, the player search), and it asks for +// their animals and what those wear whether or not they are in the game. +const findPlayer = username => { + const account = accounts.byName(username); + return findOnline(username) || (account ? {account, room: null} : null); +}; + +const handlers = { + // KeepAlive: no reply expected. + ka() {}, + + // the chat filter's window in the patched client (AJClient.saveChatFilter): + // [level, mode, the player's own words with commas between]. kept with + // the account and sent back, which is what takes effect in their game. + // the filtering is all theirs: nothing here reads chat for it. + xfl(session, roomId, [level, mode, ...words]) { + const own = words.join(",").split(/[\s,]+/).map(word => word.replace(/[^\p{L}\p{N}@$*'-]/gu, "").slice(0, MAX_FILTER_WORD)) + .filter(Boolean).slice(0, MAX_FILTER_WORDS); + session.account.filter = {level: [0, 1, 2].includes(Number(level)) ? Number(level) : 0, mode: Number(mode) === 1 ? 1 : 0, + words: [...new Set(own)].join(","), chosen: true}; + accounts.save(); + sendFilter(session); + }, + + // the patched client's hex colour picker (gui.ColorTable): [rgb1, rgb2, + // rgb3, rgb4], the four colours of one layer. everyone online is told the + // entry's id, the asker included, who then uses it as that layer's colour. + // A colour somebody made before is anybody's to use; a new one counts + // against the day's allowance of whoever asks (config.customColoursPerDay). + xcc(session, roomId, params) { + const {account} = session; + const today = Math.floor(Date.now() / 86400000); + const made = account.coloursMade && account.coloursMade.day === today ? account.coloursMade.count : 0; + const entry = colours.allocate(params.slice(0, 4).map(Number), made < config.customColoursPerDay); + if (!entry) { + return; + } + if (entry.full) { + tell(session, "No more new colours today. Colours made before can still be used."); + return; + } + if (entry.created) { + account.coloursMade = {day: today, count: made + 1}; + accounts.save(); + } + for (const recipient of entry.created ? online.values() : [session]) { + recipient.sendXt("xcc", -1, 1, entry.id, ...entry.rgbs); + } + }, + + // AvatarXtCommManager.avatarListResponse. the animal in use is listed first. + al(session, roomId, [username]) { + const target = findPlayer(username); + if (!target) { + session.sendXt("al", -1, username, 0); + return; + } + const {account} = target; + const active = activeAvatar(account); + const avatars = [active, ...account.avatars.filter(avatar => avatar !== active)]; + if (target === session) { + // 0xFFFFFFFF marks every avatar slot as available (AvatarSwitch.availSlotFlags). + session.sendXt("al", -1, account.username, 4294967295, account.uuid, avatars.length, + ...avatars.flatMap(avatar => [avatar.perUserAvId, avatar.avInvId, avatar.name, avatar.type, avatar.customAvId])); + } + else { + session.sendXt("al", -1, account.username, avatars.length, ...avatars.map(avatar => avatar.perUserAvId)); + } + }, + + // [username, perUserAvId, "0" no items | "1" full item list | "2" items in use] + ad(session, roomId, [username, perUserAvId, itemFlag]) { + const target = findPlayer(username); + if (!target) { + return; + } + sendAvatarData(session, target, perUserAvId); + if (itemFlag === "1" || itemFlag === "2") { + sendItemList(session, target, itemFlag === "1" && target === session, perUserAvId); + } + }, + + // [username, perUserAvId, "1" full list | "0" items in use] + il(session, roomId, [username, perUserAvId, full]) { + const target = findPlayer(username); + if (target) { + sendItemList(session, target, full === "1" && target === session, perUserAvId); + } + }, + + // AvatarManager.processQueuedPositions / updateAvatar: + // [count, x1, y1, ..., animAndFlip, teleport] + au(session, roomId, params) { + if (!session.room) { + return; + } + const count = Number(params[0]); + const coords = params.slice(1, 1 + count * 2).map(Number); + if (!Number.isInteger(count) || count < 1 || count > MAX_PATH_POINTS + || coords.length !== count * 2 || !coords.every(Number.isInteger)) { + return; + } + const teleport = params[params.length - 1] === "1" ? 1 : 0; + const firstUpdate = !session.pos; + session.pos = {x: coords[coords.length - 2], y: coords[coords.length - 1]}; + if (!session.greeted) { + // the first room has loaded: the client can show a popup now. + session.greeted = true; + const motd = accounts.setting(MOTD_SETTING); + if (motd) { + tell(session, motd); + } + buddies.greet(session); + minigames.greet(session); + // never asked what chat they want filtered: the window is put to + // them, this once (the patched client's "xfa"). + if (!session.account.filter.chosen) { + session.sendXt("xfa", -1, 1); + } + } + if (firstUpdate) { + // the player's own animal is on their screen now: its disguise, if any. + disguises.show(session, session); + } + for (const other of watchers(session)) { + if (firstUpdate) { + // nobody could see this avatar until it reported where it spawned. + sendAvatarCreate(other, session); + } + else { + // AvatarManager.avatarUpdateResponse + other.sendXt("au", session.room.id, 1, session.id, count, ...coords, teleport); + } + } + }, + + // GenericListXtCommManager.handleNewData: [listId, entryType, 4 unused + // fields, count, ...entries]. the entry type comes from the list-type + // defPack. list contents live on the official servers, so apart from the two + // kinds that can be rebuilt from defPacks every list is answered empty; that + // still releases whatever the client had waiting on it. + gl(session, roomId, [listId]) { + if (Number(listId) === GENERIC_LIST_NEWSPAPER) { + // the client decides whether to pop the newspaper open when this list + // arrives, from the "last read" user var, so its saved vars must get + // there first. it never asks for them; the server pushes them. + sendUserVars(session); + } + const type = defpacks.listType(listId); + if (type === undefined) { + unhandled("gl", [listId]); + return; + } + let entries = []; + let count; + if (Number(listId) === GENERIC_LIST_AVATARS) { + entries = defpacks.avatarTypes(); + } + else if (defpacks.patternList(listId)) { + entries = defpacks.patternList(listId); + } + else if (parties.list(listId)) { + // the hosted-party window: party rooms, its three name wheels, music. + entries = parties.list(listId); + } + else if (ecards.list(listId)) { + // Jam-A-Gram cards or stamps, as (mediaId, name) pairs. + entries = ecards.list(listId); + count = entries.length / 2; + } + else if (Number(listId) === pets.PERSONALITY_LIST) { + entries = pets.personalityList(); + } + else if (type === DEF_PET_FOOD || type === DEF_PET_TOY) { + // what a kind of pet may favour, as (defId, name string id) pairs. + entries = pets.favouritesList(type, listId); + count = entries.length / 2; + } + else if (type === DEF_CURRENCY_EXCHANGE) { + const paidWith = EXCHANGE_LIST_PAID_WITH.get(Number(listId)); + entries = defpacks.exchangeDefs().filter(def => paidWith === undefined || def.costType === paidWith).map(def => def.id); + } + else if (Number(listId) === GENERIC_LIST_WORLD_ITEMS) { + entries = worldItems.usable(session.account); + } + else if (type === DEF_NAMEBAR_BADGE) { + // every badge, in id order: a name tag names its badge by its place + // in this list (NameBar.setBadgeIcon). + entries = defpacks.badgeIds(); + } + else if (Number(listId) === GENERIC_LIST_GAMES) { + entries = minigames.library(); + } + else if (adventures.list(listId)) { + entries = adventures.list(listId); + } + else if (masterpieces.frameList(listId)) { + // the frames a painting can be given, as (mediaId, name) pairs. + entries = masterpieces.frameList(listId); + count = entries.length / 2; + } + else if (SAFE_CHAT_LISTS.has(Number(listId))) { + entries = SAFE_CHAT_LISTS.get(Number(listId)); + } + else if (walls.list(listId)) { + // wallpapers and stickers, as (mediaId, name) pairs. + entries = walls.list(listId); + count = entries.length / 2; + } + else if (NAME_LISTS.has(Number(listId))) { + const [first, last] = NAME_LISTS.get(Number(listId)); + entries = Array.from({length: last - first + 1}, (_, i) => first + i); + } + else if (TICKET_SHOPS.has(Number(listId))) { + entries = ticketStock(TICKET_SHOPS.get(Number(listId))); + } + else if (ODDITY_SHOPS.has(Number(listId))) { + // what the shop really sold comes first. + const real = shopStock.list(listId, type); + entries = [...new Set([...(real ? real.entries : []), ...ODDITY_SHOPS.get(Number(listId))()])]; + } + else if (Number(listId) === DIAMOND_DEN_LIST) { + entries = defpacks.diamondIds().filter(id => { + const def = defpacks.diamondDef(id); + return def.type === DIAMOND_TYPES.denRoom && denRoomsForSale().includes(Number(def.refId)); + }); + } + else if (shopStock.list(listId, type)) { + // A shop whose shelves the AJ Classic Wiki records: lib/shopstock.js. + ({entries, count} = shopStock.list(listId, type)); + } + else if (type === DEF_DEN_ROOM) { + // every den shop sells every den room. + entries = denRoomsForSale(); + } + else if (type === DEF_COMBINED_LIST) { + // A shop mixing kinds of item: [kinds, count per kind, entries of + // each kind in turn] (ItemXtCommManager.setupShopItemObject). the den + // shops get every den room. any other is a shop nothing is known of, + // and gets one kind with nothing in it: a reply with no kinds at all + // would leave the shop on its loading spinner for good. + const rooms = DEN_SHOP_LISTS.includes(Number(listId)) ? denRoomsForSale() : []; + count = Math.max(rooms.length, 1); + entries = rooms.length > 0 ? [DEF_DEN_ROOM, rooms.length, ...rooms] : [DEF_DEN_ITEM, 0]; + } + // A clothing, den item or diamond shop that gets here is one no record + // was found of. its shelves are empty: the owner would have that + // rather than things it never sold. + else if (type === DEF_PET && Number(listId) !== GENERIC_LIST_HIDDEN_PETS) { + // GenericListXtCommManager.handlePetResponse: (petDefId, available) pairs + count = defpacks.petIds().length; + entries = defpacks.petIds().flatMap(id => [id, 1]); + } + // for shops the first unused field is the title's string id; left empty + // it keeps the shop window's own title (Shop.gotItemListCallback). + const title = SHOP_LIST_TYPES.includes(type) ? (session.room ? roomInfo.shopTitle(session.room.base, listId) : "") : 0; + session.sendXt("gl", -1, listId, type, title, 0, 0, 0, count === undefined ? entries.length : count, ...entries); + }, + + // DenXtCommManager.requestDenJoinFull: ["den", confirmLanguage, ?] + dj(session, roomId, [roomName]) { + joinDen(session, String(roomName)); + }, + + // AchievementXtCommManager.requestSetUserVar: [varId, value, ?]. the reply + // (setUserVarResponse) is [varId, value, newAchievementCount]. + zs(session, roomId, [id, value]) { + if (!/^\d{1,4}$/.test(id) || !Number.isFinite(Number(value))) { + return; + } + const {account} = session; + const vars = account.userVars; + // the game's own vars and this server's are all below 10,000, and there + // are a few hundred of them: an account does not get to keep more. + if (vars[id] === undefined && Object.keys(vars).length >= MAX_USER_VARS) { + return; + } + if (Number(id) === USER_VAR_HIDE_BLOCKED) { + setHideBlocked(session, Number(value) === 1); + } + else if (BIT_FLAG_VARS.includes(Number(id))) { + vars[id] = TUTORIALS_ALL_SEEN; + } + else if (achievements.counts(id)) { + // A var that achievements count in: the games report "one more" as 1 + // and a best score as the score, and the official server knew which + // each var was. here 1 adds one and anything else only ever raises it. + const current = Number(vars[id]) || 0; + vars[id] = Number(value) === 1 ? current + 1 : Math.max(current, Number(value)); + } + else if (!achievements.SERVER_VARS.has(Number(id))) { + // the counters the server keeps itself are not the client's to set. + vars[id] = Number(value); + } + if (vars[id] === undefined) { + vars[id] = 0; + } + const earned = achievements.award(account, id); + accounts.save(); + achievements.sendVar(session, id, earned); + }, + + zg(session) { + sendUserVars(session); + }, + + // ReportAPlayer -> FacilitatorXtCommManager: [username, reasonId]. the + // reply (facilitatorReportAPlayerResponse) is [success]. + fr(session, roomId, [username, reason]) { + session.sendXt("fr", -1, fileReport(session, username, reason) ? 1 : 0); + }, + + // the same about a wall post or a Jam-A-Gram: [username, reasonId, what + // (7 wall post, 8 Jam-A-Gram), the post or message]. + fra(session, roomId, [username, reason, what, ...data]) { + const about = `${what === "7" ? "Jammer Wall post" : "Jam-A-Gram"}: ${data.join("%")}`; + session.sendXt("fra", -1, fileReport(session, username, reason, "", about) ? 1 : 0); + }, + + // the patched report window (gui.ReportAPlayer), just before its "fr" or + // "fra": [username, reasonId, what the reporter typed]. + xrd(session, roomId, [username, reason, ...text]) { + fileReport(session, username, reason, text.join("%")); + }, + + // the answer to a yes-or-no box this server put up (ask, below): [id, "1" yes | "0" no]. + xyn(session, roomId, [id, answer]) { + const asked = session.asked; + session.asked = null; + if (asked && asked.id === Number(id) && answer === "1") { + asked.run(); + } + }, + + // A new name typed over an animal's or a pet's in the patched switcher + // windows (gui.AvatarSwitcher, gui.PetInventory): ["a", perUserAvId, name] + // or ["p", petInvIdx, name]. the reply is [kind, id, "1" | "0", name as it + // now is]. A typed name is shown as it is; the game's own are word ids. + xrn(session, roomId, [kind, id, ...words]) { + const {account} = session; + const wanted = words.join(" ").trim(); + const thing = kind === "a" ? account.avatars.find(avatar => avatar.perUserAvId === Number(id)) + : kind === "p" ? account.pets.find(pet => pet.inv === Number(id)) : null; + // typed words others read: not while silenced. + const ok = Boolean(thing) && TYPED_NAME.test(wanted) && !moderation.isSilenced(account); + if (ok) { + thing.name = wanted; + accounts.save(); + if (kind === "a" && thing === activeAvatar(account)) { + sendAvatarData(session, session, thing.perUserAvId); + } + if (thing === activeAvatar(account) || thing === activePet(account)) { + refreshForOthers(session); + } + } + session.sendXt("xrn", -1, kind, id, ok ? 1 : 0, thing ? thing.name : ""); + }, + + // the patched player card (buddy.BuddyCard) asks whether the player it + // shows is banned: [username]. the reply starts [username, seconds of ban + // left | -1 permanent | 0 not banned], and the card draws a red "Banned" + // label from it. + xbn(session, roomId, [username]) { + const account = accounts.byName(String(username)); + if (account) { + // ... then when the account was made, for the card's "Joined" label, + // their Discord username and their badges ("id|label,id|label"), for + // the icons after the name, and their bio, for the Bio tab + // (lib/badges.js). + session.sendXt("xbn", -1, account.username, moderation.banRemaining(account), account.createdAt, + account.discord, badges.cardField(account), account.bio); + } + }, + + // VolumeSelector.handleRoomCountResponse: the head-count shown on each land + // of the world map, as [count, (roomName, players)...]. + rc(session) { + // the lands and their shops, as the map shows them: not dens, parties, + // or anybody's adventure, whose names are nobody else's business. + const counts = [...rooms.values()].filter(room => !room.denOwner && room.roomType === 0).flatMap(room => [room.name, room.sessions.size]); + session.sendXt("rc", -1, counts.length / 2, ...counts); + }, + + // RoomXtCommManager.sendRoomJoinRequestFull: [nameOrId, confirmLanguage, invisible, joinType] + rj(session, roomId, [roomName]) { + joinRoom(session, String(roomName)); + }, +}; + +const findBySfsId = id => [...online.values()].find(session => session.id === id); + +// an "Animal Jam HQ" popup, also kept in the chat history +// (UserCommXtCommManager.userCommAdminMessageResponse). the text travels +// where a room id usually does; the 1 marks a system message. +const tell = (session, text) => session.sendXt("ua", String(text).slice(0, MAX_ANNOUNCEMENT), 1); + +// puts a yes-or-no box in front of the player ("xyn", shown by the patched +// client) and runs `run` if they say yes. one question waits at a time. +let nextQuestion = 1; +const ask = (session, text, run) => { + session.asked = {id: nextQuestion++, run}; + session.sendXt("xyn", -1, session.asked.id, String(text).replace(/%/g, " percent")); +}; + +// files a report by this player; false when it was not taken. +const fileReport = (session, username, reason, detail = "", about = "") => { + // A secret valentine is reported under the name the game showed for it. + const target = username === ecards.SECRET_NAME ? ecards.secretSender(session.account) : accounts.byName(username); + if (!target || target === session.account) { + return false; + } + const targetSession = findOnline(target.username); + const said = targetSession ? targetSession.recentChat.join("\n") : ""; + return reports.file({ + reporter: session.account.username, + target: target.username, + reason: Number(reason), + detail, + context: [about, said].filter(Boolean).join("\n"), + room: session.room ? session.room.name : "", + }); +}; + +// what the modules below may use of this one. `others` here is everyone who +// should see the player's animal change; dens get everyone in the room. +const context = { + others: watchers, + watchers, + findOnline, + findBySfsId, + sendItemList, + sendAvatarCreate, + refreshForOthers, + petFields, + blocks, + players: () => [...online.values()], + enterRoom: (...args) => enterRoom(...args), + setHideBlocked: (...args) => setHideBlocked(...args), + onBlocked: (...args) => onBlocked(...args), + onUnblocked: (...args) => onUnblocked(...args), + partyTimeLeft: account => parties.timeLeft(account), + tell: (...args) => tell(...args), + leaveRoom: (...args) => leaveRoom(...args), + ask: (...args) => ask(...args), + travel: (session, base) => joinRoom(session, `${base}#${config.shards[0].id}`), + joinRoom: (...args) => joinRoom(...args), + reloadRoom: session => reloadRoom(session), + buyAgain: session => handlers[session.lastPurchase.cmd](session, session.lastPurchase.roomId, session.lastPurchase.params), +}; +const pets = petModule(context); +const parties = partyModule(context); +const ecards = ecardModule(context); +const walls = wallModule(context); +const commands = commandModule(context); +const minigames = minigameModule(context); +const adventures = adventureModule(context); +const buddies = buddyModule(context); +const moderation = moderationModule(context); +const trades = tradeHandlers(context); +achievements.setFinder(findOnline); +Object.assign(handlers, avatarHandlers(context), itemHandlers(context), pets.handlers, dens.handlers({...context, others}), + buddies.handlers, moderation.handlers, trades.handlers, achievements.handlers, adopt.handlers, worldItems.handlers, + parties.handlers, ecards.handlers, walls.handlers, minigames.handlers, adventures.handlers, stubHandlers); + +const leaveRoom = session => { + const {room} = session; + if (!room) { + return; + } + room.sessions.delete(session); + session.room = null; + session.pos = null; + for (const other of room.sessions) { + // AvatarManager.avatarRemoveResponse + if (sees(other, session)) { + other.sendXt("ar", room.id, session.id); + } + } + if (room.sessions.size === 0) { + rooms.delete(room.name); + } +}; + +const leaveWorld = session => { + minigames.leave(session); + trades.forget(session); + leaveRoom(session); + if (session.account && online.get(session.account.username.toLowerCase()) === session) { + online.delete(session.account.username.toLowerCase()); + session.account.lastSeen = Math.floor(Date.now() / 1000); + accounts.save(); + buddies.announce(session.account); + } +}; + +// A room that has another version of itself on the CDN which nothing leads +// to shows that version in the months config.roomSwaps gives it. it stays +// the same room to everyone (same name, same doors in); only the file the +// clients draw is the other one. +const swappedRoom = (base, month = new Date().getUTCMonth() + 1) => { + const swap = config.roomSwaps.find(candidate => candidate.room === base && candidate.months.includes(month)); + return swap && defpacks.roomDef(swap.shown) ? swap.shown : base; +}; + +// the room as this player should see it: the same room, loaded from the +// build that has the look they picked, and as another room file of that +// build where the theme names one. the client turns the path +// into a file request, which lib/http.js answers from that build. dens keep +// their one look. +const roomAsSeenBy = (session, room) => { + if (room.denOwner) { + return room; + } + // A room may have been given a look of its own ("!theme here"). + const chosen = Object.hasOwn(session.account.roomThemes, room.base) ? session.account.roomThemes[room.base] : session.account.theme; + const theme = Object.hasOwn(config.themes, chosen) ? config.themes[chosen] : null; + const themed = theme && theme.rooms && theme.rooms[room.base]; + const base = themed && defpacks.roomDef(themed) ? themed : swappedRoom(room.base); + return theme ? {...room, base: `${THEME_PATH_PREFIX}${theme.build}.${base}`} : {...room, base}; +}; + +// has the player's client load the room they stand in again, in whatever +// look it should have for them now. +const reloadRoom = session => { + if (session.room && !session.room.denOwner) { + dens.sendRoomProperties(session, roomAsSeenBy(session, session.room)); + for (const other of others(session)) { + if (other.pos && sees(session, other)) { + sendAvatarCreate(session, other); + } + } + } +}; + +// changes a player's seasonal theme ("" for none) and, if they are standing +// in a room, has their client load it again. false for an unknown theme. +const setTheme = (account, theme) => { + if (theme !== "" && !Object.hasOwn(config.themes, theme)) { + return false; + } + account.theme = theme; + accounts.save(); + const session = findOnline(account.username); + if (session) { + reloadRoom(session); + } + return true; +}; + +// RoomXtCommManager.roomJoinResponse failure branch +const joinFailed = (session, reason) => { + console.log(`[world] ${session.name} could not join: ${reason}`); + session.sendXt("rj", -1, 0, reason); +}; + +// moves the session into the room called `name`, creating it from `base` +// (a "path.name" from the room defPack) when nobody is in it yet. `props` +// are what sets a den or a party room apart from a land: roomType, +// secondaryDefId, denOwner, partyHost, customMusicDef. the client is told to +// change rooms whether or not it asked to, which is also how a player is +// sent somewhere (out of a den they were blocked from, say). +// who came into whose den, for the owner's account page: the latest +// visits, one line per visitor. +const DEN_VISITS_KEPT = 50; +const noteDenVisit = (owner, visitor) => { + owner.denVisits = [{at: Math.floor(Date.now() / 1000), name: visitor.username}, + ...owner.denVisits.filter(visit => visit.name !== visitor.username)].slice(0, DEN_VISITS_KEPT); +}; + +const enterRoom = (session, name, base, displayName, shardId, props = {}) => { + const def = defpacks.roomDef(base); + let room = rooms.get(name); + if (room && room === session.room) { + return; + } + if (room && room.sessions.size >= config.maxUsersPerRoom) { + joinFailed(session, "This room is currently full"); + return; + } + minigames.leave(session); // walking into a room is how a full-screen game is left + leaveRoom(session); + if (!room) { + room = {id: nextRoomId++, name, base, defId: Number(def.id), enviroType: Number(def.type), roomType: 0, secondaryDefId: 0, + customMusicDef: 0, displayName, sessions: new Set(), ...props}; + rooms.set(name, room); + } + room.sessions.add(session); + session.room = room; + if (props.denOwner && props.denOwner !== session.account) { + noteDenVisit(props.denOwner, session.account); + } + roomInfo.ensure(base); + const avatar = activeAvatar(session.account); + pets.walked(session.account); + + // RoomXtCommManager.roomJoinResponse + session.sendXt("rj", -1, 1, + room.name, room.id, + room.sessions.size, config.maxUsersPerRoom, + 0, 0, // spectators, maxSpectators + ...(room.joinFlags || [0, 0, 0, 0, 0]), // isPrivate, isGame, isLimbo, isTemp, isSubRoom (an adventure's room sets them) + // the name shown in the corner of the screen, then the id of a + // localization string to show in its place (GuiManager.setRoomNameDisplay); + // 0 for "use the name". + room.displayName, room.nameStringId || 0, + avatar.perUserAvId, + avatar.petInvId, + LANG_ENG, + room.customMusicDef, + shardId); + dens.sendRoomProperties(session, roomAsSeenBy(session, room)); + + for (const other of others(session)) { + if (other.pos && sees(session, other)) { + sendAvatarCreate(session, other); + } + } + return room; +}; + +const sendHome = session => { + const shard = config.shards[0]; + enterRoom(session, `${config.startupRoom}#${shard.id}`, config.startupRoom, roomInfo.name(config.startupRoom), shard.id); +}; + +const emptyRoom = name => { + const room = rooms.get(name); + for (const session of room ? [...room.sessions] : []) { + sendHome(session); + } +}; + +// the player's "hide blocked players" setting: with it on, animals of +// players they blocked are not drawn for them. those in the room now come +// or go at once. +const setHideBlocked = (session, hide) => { + const {account} = session; + if (account.hideBlocked === hide) { + return; + } + const blocked = others(session).filter(other => other.pos && blocks.has(account, other.account)); + if (hide) { + for (const other of blocked) { + session.sendXt("ar", session.room.id, other.id); + } + } + account.hideBlocked = hide; + account.userVars[USER_VAR_HIDE_BLOCKED] = hide ? 1 : 0; + accounts.save(); + if (!hide) { + for (const other of blocked) { + sendAvatarCreate(session, other); + } + } +}; + +// `session`'s player has just blocked `target`: out of their den or party +// goes the blocked player, and out of sight if that is how they have it set. +const onBlocked = (session, target) => { + const targetSession = findOnline(target.username); + if (!targetSession || !targetSession.room) { + return; + } + const {room} = targetSession; + if (room.denOwner === session.account || room.partyHost === session.account) { + if (room.denOwner) { + // DenXtCommManager.denPrivacyKickResponse: the client then explains + // why it finds itself somewhere else. + targetSession.sendXt("dpk", -1); + } + sendHome(targetSession); + } + else if (room === session.room && targetSession.pos && session.account.hideBlocked) { + session.sendXt("ar", room.id, targetSession.id); + } +}; + +const onUnblocked = (session, target) => { + const targetSession = findOnline(target.username); + if (targetSession && targetSession.pos && targetSession.room === session.room && session.account.hideBlocked) { + sendAvatarCreate(session, targetSession); + } +}; + +const joinRoom = (session, requested) => { + // "jamaa_township.room_main#-1": path, then shard (-1 = pick one for me). + let [base, shardText] = requested.split("@")[0].split("#"); + // A party's room, which is where a buddy's "go to" can lead. + if (parties.joinByRoomName(session, base)) { + return; + } + // coming back from a full-screen game the client asks for the room it + // was in by name, a den included (RoomManagerWorld.minigameJoinRoom). + if (/^den/i.test(base) && accounts.byName(base.slice(3))) { + joinDen(session, base); + return; + } + base = base.toLowerCase(); + // the game always asks for the same room first. A player who chose to + // start in their den is put there instead (the game goes wherever the + // reply says; a starting room in the flashvars it does not honour). + if (!session.arrived) { + session.arrived = true; + const {startInDen, startRoom, username} = session.account; + const den = startInDen ? username : /^den/i.test(startRoom || "") ? startRoom.slice(3) : null; + if (den !== null && accounts.byName(den)) { + joinDen(session, `den${den}`); + return; + } + // any other name asked for that is a room here; else the usual one. + const asked = (startRoom || "").split("#")[0].toLowerCase(); + if (!startInDen && defpacks.roomDef(asked) && !asked.startsWith("den")) { + base = asked; + } + } + if (!defpacks.roomDef(base) || base.startsWith("den")) { + joinFailed(session, `Room "${requested}" is not supported by this server`); + return; + } + const shard = config.shards.find(s => s.id === Number(shardText)) || config.shards[0]; + enterRoom(session, `${base}#${shard.id}`, base, roomInfo.name(base), shard.id); +}; + +// dens are rooms named "den"; the client takes the owner from the name +// and compares it to its own username, so the stored casing is used. +const joinDen = (session, requested) => { + const owner = accounts.byName(requested.slice(3)); + // A row of the world map's Epic Dens list: a showcase den, which is a + // room like any other (lib/epicdens.js). A player of that name comes first. + const showcase = owner ? null : epicDens.byName(requested.slice(3)); + if (showcase) { + const shard = config.shards[0].id; + enterRoom(session, `${showcase.base}#${shard}`, showcase.base, showcase.name, shard); + return; + } + if (!requested.toLowerCase().startsWith("den") || !owner) { + joinFailed(session, `Den "${requested}" does not exist`); + return; + } + if (!dens.canEnter(owner, session.account) || blocks.has(owner, session.account)) { + joinFailed(session, "This den is locked"); + return; + } + // "'s Den" is what the client looks for to put a den's name in its + // own words (GuiManager.setRoomNameDisplay). + // ... unless the owner named the den themselves ("!den name"). + const denName = owner.denNames[owner.activeDen]; + const room = enterRoom(session, `den${owner.username}`, dens.denRoom(owner).base, denName ? `${owner.username}'s ${denName}` : `${owner.username}'s Den`, config.shards[0].id, + {...dens.denRoom(owner), denOwner: owner}); + if (room) { + dens.sendDenState(session, room); + } +}; + +const seenUnhandled = new Set(); +const unhandled = (cmd, params) => { + const key = cmd === "gl" ? `gl ${params[0]}` : cmd; + if (!seenUnhandled.has(key) && seenUnhandled.size < 500) { + seenUnhandled.add(key); + console.log(`[world] no handler for xt "${key}" (params: ${JSON.stringify(params).slice(0, 200)}) - the client gets no reply`); + } +}; + +// hosted parties end on the clock, not on anyone's request. +setInterval(() => { + try { + parties.expire(emptyRoom); + } + catch (err) { + console.error(`[world] ending parties failed: ${err.stack}`); + } +}, 60000).unref(); + +module.exports = { + sys(session, msg) { + if (msg.action === "login") { + login(session, msg); + return; + } + if (!session.account) { + return; + } + switch (msg.action) { + case "pubMsg": { + // UserCommXtCommManager sends "%[%]" and reads it + // back in userCommChatResponse as [sfsUserId, text, type, extra]. + if (session.room && session.room.id === msg.roomId) { + // at most text, type and one extra field, and no essays. + const fields = decodeEntities(msg.cdata("txt") || "").split("%").slice(0, 3); + if (fields[0].length > config.maxChatLength || (fields[2] || "").length > MAX_CHAT_EXTRA) { + return; + } + // the type as the client will read it (int(), which makes 0 of + // "00", of "abc" and of nothing at all): a whole number, written + // one way, or the line is dropped. otherwise typed chat could be + // sent as "00" and pass for something else here. + if (!/^\d{1,2}$/.test(fields[1] || "")) { + return; + } + fields[1] = String(Number(fields[1])); + // typed chat shows as "..." over the sender until the server sends + // it back (UserCommXtCommManager.sendChatMessage); everything else + // the sender has already shown themselves. + const echo = TYPED_CHAT_TYPES.includes(fields[1]); + // silenced, or chat switched off on the account page: the line + // goes nowhere. + if (echo && (moderation.isSilenced(session.account) || !accounts.featureOn(session.account, "chat"))) { + session.sendXt("uc", session.room.id, session.id, -1, 5); + return; + } + // A few lines in a few seconds, and no more: the bubble waiting + // for this one is cleared, as for a silenced player. + if (echo && !limits.isTrustedLocal(session.address) && !chatLines.allow(session.account.id)) { + session.sendXt("uc", session.room.id, session.id, -1, 5); + return; + } + if (echo) { + // "!help" and the like (lib/commands.js). A command's line is + // still echoed to its sender, whose chat bubble waits for it. + const said = commands.run(session, fields[0]); + if (said === null) { + session.sendXt("uc", session.room.id, session.id, ...fields); + return; + } + fields[0] = said; + session.recentChat.push(`${new Date().toISOString().slice(11, 19)} ${said}`); + session.recentChat = session.recentChat.slice(-RECENT_CHAT_LINES); + chatlog.record(session.account, session.room.name, said); + } + // nobody hears a player they have blocked, and with chat switched + // off nobody's typed lines arrive at all. + for (const recipient of echo ? session.room.sessions : others(session)) { + if (recipient === session || (!blocks.has(recipient.account, session.account) && (!echo || accounts.featureOn(recipient.account, "chat")))) { + recipient.sendXt("uc", session.room.id, session.id, ...fields); + } + } + } + return; + } + case "logout": + session.close(); + return; + default: + console.log(`[world] unhandled sys "${msg.action}" from ${session.name}`); + } + }, + + xt(session, cmd, roomId, params) { + if (!session.account) { + if (session.signingUp && Object.hasOwn(signup.handlers, cmd)) { + signup.handlers[cmd](session, roomId, params); + } + return; + } + if (Object.hasOwn(handlers, cmd)) { + // clothing and den item purchases, for "!again". + if (cmd === "ib" || cmd === "db") { + session.lastPurchase = {cmd, roomId, params}; + } + handlers[cmd](session, roomId, params); + } + else { + unhandled(cmd, params); + } + }, + + close: leaveWorld, + + findOnline, + sendItemList, + setTheme, + // offers left on the account page (lib/trades.js); `refresh` shows a + // playing account its inventories as they are now. + tradeOffers: trades.offers, + refreshInventories(account) { + const session = findOnline(account.username); + if (session) { + sendItemList(session, session, true); + dens.sendDenItems(session); + } + }, + // runs a chat command for an account that is playing, as if typed. false + // when it is not in the game. + runCommand(account, text) { + const session = findOnline(account.username); + if (!session || !session.room) { + return false; + } + commands.run(session, text); + return true; + }, + // blocks or unblocks `target` for `account` from outside the game (the + // account page). false when there was nothing to change. + setBlocked(account, target, block) { + const key = target.username.toLowerCase(); + if (account.blocked.includes(key) === block || (block && account.blocked.length >= MAX_BLOCKED)) { + return false; + } + account.blocked = block ? [...account.blocked, key] : account.blocked.filter(name => name !== key); + accounts.save(); + const session = findOnline(account.username); + if (session) { + (block ? onBlocked : onUnblocked)(session, target); + buddies.handlers.bl(session); // their game's own lists, brought up to date + } + return true; + }, + moderation, + walls, + ecards, + // called when the admin changed an account's badges: a name tag showing + // one it no longer holds goes back to the first badge, for everyone who + // sees it. + checkNameTag(account) { + if (badges.mayWear(account, defpacks.badgeIds()[account.nameBarData >> 8 & 0xFF])) { + return; + } + account.nameBarData &= ~0xFF00; + accounts.save(); + const session = findOnline(account.username); + if (session && session.room) { + // AvatarXtCommManager "an": [sfsUserId, nameBarData] + for (const viewer of session.room.sessions) { + viewer.sendXt("an", session.room.id, session.id, account.nameBarData); + } + } + }, + // the adventure level of the animal an account is using, set from the + // admin panel. clients in the room hear of it through an `ad` they did + // not ask for; a name tag draws the new level when it is next made. + setQuestLevel(account, level) { + const avatar = activeAvatar(account); + avatar.questLevel = level; + avatar.questXp = adventureModule.levelXp(level); + accounts.save(); + const session = findOnline(account.username); + if (session && session.room) { + for (const viewer of session.room.sessions) { + sendAvatarData(viewer, session, avatar.perUserAvId); + } + } + }, + motd: () => accounts.setting(MOTD_SETTING) || "", + setMotd(text) { + accounts.setSetting(MOTD_SETTING, String(text).trim().slice(0, MAX_ANNOUNCEMENT)); + }, + // shows a message to everyone playing, or to everyone in one room. returns + // how many players got it. + announce(text, roomName = null) { + const audience = [...online.values()].filter(session => session.pos && (!roomName || (session.room && session.room.name === roomName))); + for (const session of audience) { + tell(session, text); + } + return audience.length; + }, + // an "Animal Jam HQ" popup for one player; false when they are not playing. + tellAccount(account, text) { + const session = findOnline(account.username); + if (session && session.pos) { + tell(session, text); + } + return Boolean(session && session.pos); + }, + rooms: () => [...rooms.values()].map(room => ({name: room.name, title: commands.roomTitle(room), players: room.sessions.size})), + + // the panel's Masterpieces page. A painting waiting for review is an + // item its maker cannot use yet; approving it tells them so, by a + // Jam-A-Gram from Animal Jam HQ and at once if they are playing. + approveMasterpiece(id) { + const maker = masterpieces.creatorOf(id); + if (!masterpieces.approve(id)) { + return false; + } + if (maker) { + ecards.noteFromHq(maker, "Your Masterpiece has been approved! It is with your den items."); + const session = findOnline(maker.username); + if (session) { + dens.sendDenItems(session); + } + } + return true; + }, + // takes a painting away for good, from whoever has it by now: one that + // was not approved, or one that should not have been. its maker gets a + // Masterpiece Token to frame another with, and word of it. + removeMasterpiece(id) { + const painting = masterpieces.get(id); + const maker = masterpieces.creatorOf(id); + if (!painting) { + return false; + } + const changed = new Set(maker ? [maker] : []); + const shownIn = []; + for (const account of accounts.all()) { + const held = account.denItems.filter(item => item.image === painting.id); + if (held.length === 0) { + continue; + } + changed.add(account); + if (held.some(item => item.placed)) { + shownIn.push(rooms.get(`den${account.username}`)); + } + account.denItems = account.denItems.filter(item => item.image !== painting.id); + account.tradeList = account.tradeList.filter(listed => !(listed.type === 1 && held.some(item => item.inv === listed.inv))); + } + masterpieces.forget(painting.id); + if (maker) { + dens.giveDenItem(maker, masterpieces.TOKEN_DEN_ITEM); + ecards.noteFromHq(maker, "Your Masterpiece was not approved. Here is a Masterpiece Token to frame another one with."); + } + for (const account of changed) { + const session = findOnline(account.username); + if (session) { + dens.sendDenItems(session); + } + } + for (const room of shownIn.filter(Boolean)) { + for (const visitor of room.sessions) { + dens.sendDenState(visitor, room, false); + } + } + accounts.save(); + return true; + }, + + // the panel's Debug page: puts a playing account into any room of the room + // list, as that room and nothing more (a den's file without its owner, a + // party's without the party). returns what is wrong, or null. + teleport(account, path) { + const session = findOnline(account.username); + const base = String(path).replace(/\//g, ".").toLowerCase(); + if (!session || !session.room) { + return "They are not in the game right now"; + } + if (!defpacks.roomDef(base)) { + return "There is no such room"; + } + minigames.leave(session); + const shard = config.shards[0].id; + enterRoom(session, `${base}#${shard}`, base, roomInfo.name(base), shard); + return null; + }, + // an address was just banned (lib/bans.js): whoever plays from it is told + // as for a ban of their own, and put out. returns how many. + disconnectAddress(address) { + const there = [...online.values()].filter(session => limits.key(session.address) === limits.key(address)); + for (const session of there) { + session.sendXt("fd", -1, "fb", 1, moderation.PERMANENT); + session.close(); + } + return there.length; + }, + // takes the account out of the world at once (not when its socket gets + // round to closing), so the caller can go on to rename or delete it. + disconnect(account) { + parties.forget(account, emptyRoom); + const session = findOnline(account.username); + if (session) { + leaveWorld(session); + session.close(); + } + }, + players: () => [...online.values()].map(session => ({ + username: session.account.username, + room: session.room ? session.room.name : null, + address: session.address, + })), +}; diff --git a/lib/worlditems.js b/lib/worlditems.js new file mode 100644 index 0000000..c61a744 --- /dev/null +++ b/lib/worlditems.js @@ -0,0 +1,75 @@ +"use strict"; + +const accounts = require("./accounts.js"); +const achievements = require("./achievements.js"); +const defpacks = require("./defpacks.js"); +const dens = require("./dens.js"); +const {CURRENCIES, hasRoom, addClothing, sendClothingAdded} = require("./player.js"); + +// gifts lying about in the lands (client side: WorldItemsManager): a room +// has up to three spots, a world-item def says which spot it sits in, what +// it gives and which bit of a user var records that the player took it. +// the real game put a few out at a time. here each spot shows the first +// gift the player has not taken yet, so all of them come round in turn. + +// WorldItemDef.giftType +const GIFT_DEN_ITEM = "0"; +const GIFT_GEMS = "1"; +const GIFT_DIAMONDS = "2"; +const GIFT_CLOTHING = "3"; +const CURRENCY_OF = {[GIFT_GEMS]: 0, [GIFT_DIAMONDS]: 3}; +const NO_CURRENCY = -1; + +const taken = (account, def) => ((Number(account.userVars[def.userVarRefId]) || 0) >>> Number(def.uvIndex)) & 1; + +// the defs on show for this player, one per spot: generic list 583. +const usable = account => { + const bySpot = new Map(); + for (const id of defpacks.worldItemIds()) { + const def = defpacks.worldItemDef(id); + if (!bySpot.has(def.position) && !taken(account, def)) { + bySpot.set(def.position, id); + } + } + return [...bySpot.values()]; +}; + +const handlers = { + // WorldItemsXtCommManager.sendAcceptGift: [defId, denItemVersion, + // clothingColourIndex]. the reply (WorldItemsManager.onGiftResponse) is + // [success, new currency amount or -1]. + wig(session, roomId, [defId, version, colorIndex]) { + const {account} = session; + const def = defpacks.worldItemDef(defId); + if (!def || !usable(account).includes(Number(def.id)) + || (def.giftType === GIFT_DEN_ITEM && !hasRoom(account, "denItems")) || (def.giftType === GIFT_CLOTHING && !hasRoom(account, "items"))) { + session.sendXt("wig", -1, 0, NO_CURRENCY); + return; + } + let amount = NO_CURRENCY; + if (def.giftType === GIFT_DEN_ITEM && defpacks.denItemDef(def.giftRefId)) { + dens.giveDenItem(account, def.giftRefId, version); + dens.sendDenItems(session); + } + else if (def.giftType === GIFT_CLOTHING && defpacks.itemDef(def.giftRefId)) { + const colors = String(defpacks.itemDef(def.giftRefId).colors).split(","); + sendClothingAdded(session, addClothing(account, def.giftRefId, colors[Number(colorIndex)] || colors[0])); + } + else if (Object.hasOwn(CURRENCY_OF, def.giftType)) { + const currency = CURRENCIES[CURRENCY_OF[def.giftType]]; + account.currency[currency] = (account.currency[currency] || 0) + Number(def.amount); + achievements.currencyChanged(account, currency, Number(def.amount)); + amount = account.currency[currency]; + } + else { + session.sendXt("wig", -1, 0, NO_CURRENCY); + return; + } + // the client reads the bit straight from its copy of the user var. + achievements.set(account, def.userVarRefId, ((Number(account.userVars[def.userVarRefId]) || 0) | (1 << Number(def.uvIndex))) >>> 0); + accounts.save(); + session.sendXt("wig", -1, 1, amount); + }, +}; + +module.exports = {handlers, usable}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..cbe55fa --- /dev/null +++ b/package.json @@ -0,0 +1,14 @@ +{ + "name": "aj-classic-private-server", + "version": "0.1.0", + "private": true, + "description": "Local server for the AJ Classic desktop client", + "main": "server.js", + "scripts": { + "start": "node server.js", + "test": "node test/smoke.js" + }, + "engines": { + "node": ">=22.5" + } +} diff --git a/public/account.html b/public/account.html new file mode 100644 index 0000000..c15eb80 --- /dev/null +++ b/public/account.html @@ -0,0 +1,1301 @@ + + + + + + Your account + + + + +
+ + + +

Burrow is an unofficial fan project, not affiliated with WildWorks or Animal Jam. Terms · Privacy

+
+ + + + + diff --git a/public/admin.html b/public/admin.html new file mode 100644 index 0000000..22916b6 --- /dev/null +++ b/public/admin.html @@ -0,0 +1,1502 @@ + + + + + + Server admin + + + + +
+ +

Server admin

+

+
+ + + + + +
+

+
+ + + + + + diff --git a/public/badges/artist.png b/public/badges/artist.png new file mode 100644 index 0000000000000000000000000000000000000000..27af64cf5870dc1f21e71765b7d5655129b70a68 GIT binary patch literal 1335 zcmV-71<3k|P)=f;?!*no!bynMPNACnmL{P%H|Lz23!MzQx?jAZXm-U z7>6h!Bu+GuEM^WfbT)yBqQ%V+Mz#Ul+OEG|+v7Vg_2u>U-q-i5l`P)mlXdUjbME)N z-ru)rY5%9RG+U0z#AD{M@pSPF@BqO;G|v_-Yq}kTTX;@U#3}`CE&s*aw(^YW5Kb}{ z^=V4Bcr&AUz^9AugCE!BfU}_lMw*raw7(VuKEpgLgJl_kpl@@s-g-M(;o-tNp|36v z#+z3_9jGuN?+ zS{5~+7D*6Rxd6mb=R)mM5NKX%IKkEmh>Q#XnZk~*m^P?IIx5L6%!ER1&!t1aw#0Z^ z%IV^-_9wJOO_Criv;f3a<@wdw;NShC;e?&NapEHr!w|5qOlXUmq^nq3=M@W#ZYu(R zli5&0{bzxe0!M2V*`p?6L^4r_&SS-Qfp6DhL*aTlsN#cP?@{FkwNZ!E=q^df=&pPO zd>_1E7{SgxRPmvU->LS6+9UzkqycpOn{laT9(WrU8bYvhH&uLi_=+Zfs7(?;moxxz z^1AwVE_inq>&Ab0Ekt~t_)g0|^Vuz$e4;k#q$UkO%$VHqye@qE%fZ*ShALi|vyN@l zDfO&G=7Pqi@+wA922I)#V>a7=UNnvzqW8tY!)qI_>X0nte-29DsF!dKwo) zWb8UqeE7OkD5J?Y0V@Ep6A#wS19!uGRe0WC1l(`k%mDnS8ddwGf!bJ|SR6+C-U0X!*qlM|Sro70iI~O;0f4uJp+U;P38`wbue_lHJgdTgsm*GGY9!Y$}|S z9YE;XWf`E2sgrDBaY@9IKpM zI1_HwJr)NUK*Z|;-!})SW%Ys@6d$Y54z|v(oDH{Xvtn@VuLAFxR`7iGE==rN9+z(v zShuQ!E!NTErOHgWS@UR0!8$b^Ez%Bm?axeuUo9DMbN$090qep#b=?)vj@Nrv%z_*1 z9!e@$hwkHbxeJaji_>AKdJf!J^Pr)iPxNir1&7=f6MntD%kPEJ)pHC1eGyH@m@B44 zmwX@P-vQk(-wgwmvthJ4LltO)w&)|NmwZaES&tM={4(=x#*q}KQ)+AKlZpC(m&a%R!RC>g4O^4002ovPDHLkV1mC)fyDp- literal 0 HcmV?d00001 diff --git a/public/badges/booster.png b/public/badges/booster.png new file mode 100644 index 0000000000000000000000000000000000000000..08ae351765f2e2101ff92f4279ffd4c7acbf95b0 GIT binary patch literal 2483 zcmV;k2~75hP)#C(d0758R~&kdKxP7^8(E!%>H%Wn^wSh? z25_LEzwtw<`Xm8pF-2#H*XhXT#d3dy_6w3;hvA5JJ74mWxv7hfxeh0V5!+!o| z_*>ku-^Ik#{a9ZqYyiw=Yh$ZeAff@ZR9HR$uve%!LzjUkO;2E{VJR}wGsN0twUv$qqSyOv7c$D^dngr3{9@bB zp^}(w)H`*M8x?WE`mH{=PdLRrh@h0mm8GFC}4ru?BAs%N;sWtMlGGpfwzVu4wn(+lwa+bv0Nm$eID^>_1ors0&A@L4Gg zza81^p-UGw#N;XD?6q9QEKIp=V)?PN&O+}FtZ&i)am z&g_gF)URg`Lex?}rGe%rx{$1+Z3g!DM%nL~o3hydJQ%}^OORQ|U1Qe5Kb&xXAwDg& zUOI)T*-36Q1)EY?0L@0r5kl}1^VzgwElevaML91oR3PKmSuwn4D5Ne{qwr0x>K=L3 z2Di=4QYbneX8$w;|A&vwW$8h4U(@e{01mYiLN+jWp03>rL#`pULM4#d zlml5#EbnDH84BMF2QC}XuMQ*N48+7kU@`#5p-Dhch$b>_pRnWX)pOhdPsA|F~Q^@;hs<1Q?QY$JRJRJ*|KM~av#PQ(X`JDd)a@mnl~W{=Ha;fgEi=}*l~;dIC8U>3!-hQ3BqOb~A|Z9%?1 zKV=YS?$$%|q&6fcDTp^^K^P|sU%KE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xFV0jS}SCMS0rSr2V zBFXdm)}V3E=hI98GArDOO|_&>t&#*mT|zv$9h-y34OZv%V1*m8$r5nN6KD_xP3x1W z|J7VeaPN47h7W&9qpsruaE(5zyogPfK!ZF1>Em@S<0b0b`m!d54!lS1?RlDV?^j>Y zq{=WtA7ol~-~_jxZ^S15sL2zM1lP7~)I>ikX9xti?mXxxAJ|)_8oWFS=A?hJV7W__LT8`nk~bYTNq zT!YJ~U#$eBm$)S*iLT^i7($O@ivV1kZM?k^AU3U+SSq8Z*CbH)hICVKSH5dH0oa)J zgV?mnsPrLov4wS4R+=ij-+tp4NPop%0cM+)9eil{cPSVBPSvTzr;(3RC#$z=@E-F| zpl@F}_3kM)od9fL>z4rYq2(X3X-y>*leyO97pcRZVhU!PS$@Q%Iho_9({;bddth`j>k>j?_I)gkMm>02|yP% zumuOW0{KHsx(gb9N%>=33|(Sni$_OJCV5YMH~k?S8x{H>o9Ji{eD|4-$OBtx>@!Z0 zhX-N_xTNG4^&iZeLv3qU(?vG+M0D>gpxbWu^w+bgk=nEE)AFM2ilF?a5ljXhQ6IM8 z5F5DRL+%qXAQq#Gdd0TN;YE>jVci-Dm$TA^Ab{Te6$+V%uEKoswVw409(|Ch*?>#r zg%7z5F&N%fQQO$6k6l9lB(0KgrL=@DWu_|n)BwG~qhAZabs&9k@_O)XYGX@lYw^_b zrSx~=${7WG2DP=Qwz*q9_d)t4K8DV-Px(v$zTnf+S%KR2`pM`hYFoV`tbh;8+v|D< z9ETPzpg$Ah=-kTXAq6-O`5!k0f54%4#DvFNx8xc6>xKA`09@RV3C$5xphLco9)5_9 zKl>y#$3;`?ie;t%8`y#)tcQF?k6CNjr~cSekJAtAZk}4Yn9e>Qs{r~SgHDZdS`hwY o)>(7VJuCjzU{?LJ$NkX$1u@$ERok;bdjJ3c07*qoM6N<$f-^DH_5c6? literal 0 HcmV?d00001 diff --git a/public/badges/contributor.png b/public/badges/contributor.png new file mode 100644 index 0000000000000000000000000000000000000000..7e10c2b6d93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9(y!G#NHZf!D!?p&%V@Co0V zU2w=0?nyS@(Q#;+d%h&TkS9T zlwPwwo)bnPC6P3PK_*^g?>$)9`do*+l%vuF9B7Voox2dNJniH(1&w~L99t3;4Vnir{2yBR^?>S z$2EC$W}BCOY=2$~$U!bR1ckIa_HBgC4;lr$*)!f z_03OYQvdb}8vd}#QGgTNf_o#&&LCjXE9GIdpcbXA-{u zq=Eh%zf5RX&UEX2stvi|Km#YZMVjzp9F<~C%=DnjCF#@`ED<7N{;wNX>B9ady-&3v z7aZV<6k(sM`&d~ksi4H{x^B3l4CBGoCKI86RrK0@#V;n^#EV;+JjG z1t3R7%ji{Dz_G^V(&%mR%8x)=j*3>?0>1J+u7t~dhb)^%tg24j0**E;Q^N74BD(qe zXk7D%L9D8dSpn=O4sBdaU%Zm9gk!I-rW?PR7lCt#QRRm>vzwR=qdUFx=<}B!wS}Rs z0R3$kT5*g%yS(sbHjJ_dnZL+QM_$UcjccPrtN4>C5Ds9u^*hc`WJ8`nn9 z845V(2q(OmO(mixbD`>mbf`W@3O&Jc>fKSxaQ)XytNF1R6tW{X;HMeTRQ(vdZ%~}?OA_+ zQUEPz+S)4+EwB4m&7$2E_azk2u)Vw_(X90}dzv%1Z?VbOGIcr1hb zg)^yT%`9s3+#3b-;T&QRo78RADYMZ%C4Oo!rGD&jJG6fRQ`Eg#bpYCW00000NkvXX Hu0mjfTOVnv literal 0 HcmV?d00001 diff --git a/public/badges/friend.png b/public/badges/friend.png new file mode 100644 index 0000000000000000000000000000000000000000..1f8dba30df23a2ea27f7d0504fbf4684be41b4b7 GIT binary patch literal 1398 zcmV-+1&R8JP)oh~>!!eVcUe@DzJQiKDeZQ*+wJ2x-(+_(GrjlD>{HTsk}uoYd(L;h zGkfoyJNGs%?SD&4dtgVIMS@L2i3GcZ9tosFPq?il>}$Cngy%}AXNWZm#OD4Nce_x+ zcpSp@7!Pw=k}clG=^pfGK@B}$<)AGmyJ$!A2o-oq1AK=z_`sJ_2)J#@y6cttgjpX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ta)GBCYUug)CN7-bHkGlViC=ZgB2Sr6 zm$w~wVrC?p=F~Z7$Gh~LG;ny?+S@^AZ{CpEJLuCbTYOi=f+lwLIhc+yiRjKYxt%@>*b;;?DWDFaw>qE-llRaL}1{3Ab6xaM zRZ&Dio2IrFwKjL7lauKF{aN&&v=)g3XbWvxIxEoHUZ0zlK?^Dlh8477d3!z70mrPJ z?~%PYmmVn37Ya0?E$o0J)De^I%_O>KUpm>#@`L~_XbL}Kn(B}*dg~UNlewGb9LnAc~?`OV=Y2iPV;^i$@Z5-55=a z60agf@Q8@5F|LUst-5WDS{se2u9{8adi^@zvW~OE%zJNk->woI_+Xj$-goT2dGn4< zN_uxCCAAy7!KT2jz^R}@L7f89p)OqJ4A-^24aRd695gU13bf666W?~80)Gs~_3(!| zZSgj5H|ZYK?TZo`ccrPjb=djkPpwZ!jT%7Br*o zPWlJ-GiNPj{rn`MfTsSzwlY+z4Tt1cQ)XFfR9JudX$aA_hqf++U8L)%<9v@fl`XQD@LXJFR#G`J{q;< zJ`*KXEz$#klcx)B+LxL(fLieBrvJF`oRc2_oFdvWeIG{!#kmyLv8;T$VQyflEXa-ppQP>Qo{n zb31*!{$DO~%NnHx0GEg+yqQfUA|`WvS6`!n1-H2FOQx)f&oB#|kGrz>DajK4M$t z{pn?tzN*eL90wYy>iX*`H$LNDG+gi?yscuivDJP4N$S1wdQ_OTqdtUa+e6#Z#+KRE zV(Oww>h*1HLIKUFwib;xciWG5(gzFAQqOPxP6(g{&6v&#jJDUi&OJ^auJ|jifJV&Q z>#PHgj?;Ei>e4?bZMjb>zzJ??2OO*;Cj7izW*?)}W!IztT)HkJ=ZJ}S$k$=gX6p3S zuhey6HFaNl)e_JKZNU-OLq5@C*7q`sC}rj$>O7}{y5v?;w9MS l=x!5#HE2_R_IMkv{{dCem92K1Y&ie`002ovPDHLkV1gU$MHv79 literal 0 HcmV?d00001 diff --git a/public/badges/owner.png b/public/badges/owner.png new file mode 100644 index 0000000000000000000000000000000000000000..27a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gc zs1DU7AEqAi={;s$kX(nX_u7$@(uqx}SFyu-Cjz=g_sE89<9f_GX%4z4#a|63)t^0H ah4LRpYo4#W>A6?{00001%&#EP)1~dxV+O(^# zT2VSo%%T-iu7u>$fCC*aayW1nleM+C@)oSGs!!!AN3h}XXBpC@c3SLsRe z9chjzkQ2F?z7ZeJlMfJo#lD}s74JnA;9!cdh4tFh-j^ z%L-OEhCy$z5W#<8r+bCA8l`kOcs4m=+ zVR80MyJ74i;LE-~BDYbjVF6Qn-Y|rJbUe5ti_vEKK&@dceBc`tFLIjUHZEZI>xOVu zw(xzSf0(BBRm)?A4LT8eM5X_yn21!9^fnPvA!aQ+E)+ICL2bTiR@g0ohDv5YzjBT zdfh)gBNYZaAS)EHu$$$BHrYg`EG0g;Zyk;AC^e0#;(BQjxUXkJtQ9V3lPx6z7IOoe z@@ahgA=8+`$RZIc6)$3}a6prEF{fQl|L}MQIky#C!er42Q$@fBzE<-?lXN+){h(=B zxt5$;4_d}#;c@agobrzxVS`U7xuHq-gGT#Fd3o(l`Zuk}GMqch$kW{uJXDH%u!WKn zS`0ragFfo-Tth>tc{H|pe@JkB^v$hFN?eDU2O6No>_>gTw#w-TlWFYv!jLh6AyOcm z9ME8TTZP-$`Y|DcMpN^b1mL!`u_fDD?0#Z5jXswbQ-Cw1twnBgw{FE6x{{Phj%RXX z0&sydtg`}cd;QYt?c_*)C8_{N*xT!R2OOs!*hqs<@1>EA`yvYDMDBVv!@NhkRy_S({fT(YFt! z($A~5(H{xBXy~cz0N@^M@PThkk6D+^LHDxwsll@PvB&Mu{sSLu(j9XwXx9J$002ov JPDHLkV1oX>syF}u literal 0 HcmV?d00001 diff --git a/public/badges/tester.png b/public/badges/tester.png new file mode 100644 index 0000000000000000000000000000000000000000..1df17f463e124b2f43620940c439efca9c5d620e GIT binary patch literal 1307 zcmV+$1?2jPP)2QB5;ua4X*Ol5HqfrW=_DwixaJVdLMRs_uluO^L{(;y*bv|o{gRJInU>LUd}o1 zdC$2~QU8~ysHLkPa!5#)kR`z*!6$)K@CDkk01<^ zbUq#JSWI=7Q%wPV&=(vGBYC#{Hv;0Dl?hTaM$@ii3+Tt5WwroZ;8dAt7B(Rf#Hq)6 zM)ng_(Y1t5UV7VBfD_z|xe+JwJ=q@2#)`IT$7!Lc=CCV-ywCzDU*GOCtj0 zLQc!WNj+ir)+SQbuS+5di&SiA( zuiGI8P=_`VZfH}!)RYF~h661LLb&>89rrDaHc@`1R;GdC<`*oZzI(myRsu01Idlya zoq668N?I3^f9RU70mLBIY93t!`@PRuLf7>oGFlL8H4o2#Jc(TuvuR&byeX8QTS;aM z`k2iFZM;b=FQeNIPNN?h=bOUyfwTM}bN6>@yRv&2LyFZ2eaz;8Hr_HSzsQ`qF;wu= zvxedA$C->h zCAXt5IE?0lHr`euXfx-koJsCePwV1xe~sqThd^cgzQ%-*7;qTL1x?(|oO(O`Nq!9F zH_XvQdB>^{G1qQ+>2OO5HTu2|szWT$=kH=qXsJyvA2e~d)9MeJch--ly!u(1xPA9( zh>)tzHFEpV{Q<)(61ep8L6hbOjrx=Fvw~R4t&3x#_JWfsq^Gx<3QjHHwrdsi;pKxC z-A_vOM}12ABjl=@PP=PoguvYpZ|Vu_6>x!*l?xi6#pp+U(6P$LUq;jSC#N&faB+)m z2EfJ30}Y0cRaggGneIunt7aM#USEza;PE53se>)v(c%}yG34@0jVO@Q($OO8a2I26 zbMa*Qw)&}v0J&7-zS-&tb|NsS^1=`04KO@ zyWr5eVoFJWm^S2%qi;^c+5&Ka)AlPSy-U6o>l~Ev-D9-1bRzAjm~0B@gTCMh>m{Gj zYu2=lqiF5UXmYwAr_YPW)Ar+&f`B@-AqKG#y=EOT7u_S`rv@YH#~u$t`3Ilt!=@6h Rpu_+G002ovPDHLkV1h>Ib#wp# literal 0 HcmV?d00001 diff --git a/public/ban-icon.png b/public/ban-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..afb28521b74ff04736692a78b6d0748e56d1f2cf GIT binary patch literal 3999 zcmZ`+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JMH!q<}cTLQo} Lbk!?Wt-}5T!uS!} literal 0 HcmV?d00001 diff --git a/public/bio-icon.png b/public/bio-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..9c10f28d67f07c111264e386467e0e9ed5df9282 GIT binary patch literal 10255 zcmV+qDDc;bP)sIBxERguO?$pS z{_}|fkwlarl}Rpd{O0if=6*QS+zRdAQp)F~tY0q$6%@1P$qe7|Jpw!4VZQge>yD6LWFW{ye z%^K=jIAz?9Td6mv61E)2p_Nwab~$h$PkS zAd+ph*MaJS#Z9Zd6aNBkLclN0dTf76 zLej$&E;w}XZHbqLPK8ulx8xGIHX948)ds7Lh0$Wd#!KIzz)-?NW&o)~ymI%imsT=N z!yx|)xCsDr94CHp>bURIQ`5)t)p5{BeK7s*2?+D?gttloVrw16RW0-C*$!9$&4OiF zd=k9}d4@vjkdeDpYW4Cj4xL_2AK+&B7qFWHRo7)pW<0Vl^+w7g4!ByG4|)d;qqdag zILIYp^a~3{D<2Pt8Ah`pm=0#mVFT{Dm?Wj(+A`TSLP+We0J zyl%;~pt#t?D80_`ENf$#uDv>sUG?#|Ke;mqjlE{kv?m0r;ro=-(m`jEe_NZ7_w)d(`B=Emk7MEI1p7ZK-=?v<$%uly1Fh1qPOlT2dc0)zd>Z`%9of9o57#(w_ttcMRJ zC!`9J>mAw#qh>9GCxNR_LaS6jtyEHDc{AoZ684{f&0rKHn%LyN!G2InBra;1ceEU^ z1?c2&EQ?(k`@q`GuT&!b+3MHs{=Iwm+Un}V-x~1bk=+9Tc}zux$=?ygcXW2hke+YO zU;V}M#saMEKC*D|()69DQj;_KIYiPcqz%T*ehnTfH3h3xDxp>=sM^&Tjr2!vG9l~u zCFo<*oYD-Sy{8623b~8q@+#WtRr7EO_W z`ieKpic06&IF1kIavT_uh)ORhZQ6yNSij@Pdzu>XOS2w6nUat?$ni{%fDk+|cQv#s zB{WI}JQV!DMAZs#4MylpCKxRiSaOS@JA9G0*I}DOlyZd131k));z?5#&8ust>gJ&z zFFTC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UHvBgu0m4C0DE|QEZzG3$+vF1{zg>rrvY}fm3)(Eg-$m?Us|!&YI6Zi77bV%+O}_x zdqUeiDO?)aB(SJcE8{^@`n z{rS)Mdo&dW>o{YDafQul4R-}eV$Eue2B9Ir82i9O=-0n54H44(W;cTjO+0Rusv`^j z+dkid!@nFBw&{q);&MNK?@=4~{(7c4pIu+we;L4zhVI!jUi`~f*@KNb(?XNkazDp$ zm5v%9D?nsG!@^pjN6+3EIB)<$$RdK2UwF9Vh2yYp{d!!wbVZ%`hk`EW*lFE0LR<>&%_fs(({4qK7~E;r9j~zu$C?bJp~i z2JC2NR8*Ac)*nYZmg`FUOJ(xeW|O%ezwftd;g4D%>YJ!^FHcYS`T8IvBotw7+9EJ8 z00Dk}@bUA7L@MKB$c`U-RaI4fO(uZUf92{`tY5z#77M@ag$!gskpIER!JQ{PJ^!O- zJ>0AzFT&pfaMcdojNa|N?3InfWg=#rzP#cA8_Oyg2FlvZF~7)9GAa4plEkK~)Eanr zdP1w!K&4dC5UNxrg-WI7f0s&W`j5JXWWwC+Ec|@vkn3hMYe10S;!S&hZSvKihQO@p z+P@{>svUWH)Zk!+g6UOST-HGrr=Lkvb^ zAOl8TDVNK>7~-(=RX?l#3=Tei-f>;Jbi8-rn$7&TZ~X8^sDMM{}1j| V0+z1(3c&yX002ovPDHLkV1gX96>k6l literal 0 HcmV?d00001 diff --git a/public/captcha.html b/public/captcha.html new file mode 100644 index 0000000..5aac8db --- /dev/null +++ b/public/captcha.html @@ -0,0 +1,62 @@ + + + + + + Burrow + + + + +
+

Checking…

+ + + + diff --git a/public/captcha.js b/public/captcha.js new file mode 100644 index 0000000..d05b1c0 --- /dev/null +++ b/public/captcha.js @@ -0,0 +1,83 @@ +"use strict"; + +// cloudflare turnstile on this server's pages (lib/captcha.js). the server +// writes its site key in below, or "" when it asks for no captcha. +// +// const check = captcha.mount(element, "login") shows the widget in +// `element`, as a page loads; await check.answer() before a request (it +// waits while the player is still solving it; undefined when the server +// asks for none, "" when the captcha could not load or run: say +// captcha.FAILED then), and check.reset() after it: an answer is good once. +window.captcha = (() => { + const siteKey = "{{siteKey}}"; + let loading = null; + + const load = () => { + loading = loading || new Promise((resolve, reject) => { + const script = document.createElement("script"); + script.src = "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit"; + script.onload = () => resolve(window.turnstile); + script.onerror = () => { + loading = null; + reject(new Error("the captcha did not load")); + }; + document.head.append(script); + }); + return loading; + }; + + // `options`: {appearance} ("interaction-only" by default: seen only when + // cloudflare wants a click), {onAnswer(token)}. + const mount = (element, action, options = {}) => { + let widget = null; + let answer = null; // a token, "" when none could be had, null while waiting + let waiting = []; + const settle = value => { + answer = value; + if (value && options.onAnswer) { + options.onAnswer(value); + } + for (const resolve of waiting) { + resolve(value); + } + waiting = []; + }; + if (siteKey) { + load().then(turnstile => { + widget = turnstile.render(element, { + sitekey: siteKey, + action, + theme: "dark", + appearance: options.appearance || "interaction-only", + callback: settle, + "expired-callback": () => { + answer = null; + }, + // its code is cloudflare's (110200: this site's name is not on the widget) + "error-callback": code => { + console.log(`captcha error ${code}`); + settle(""); + }, + }); + }, () => settle("")); + } + return { + on: Boolean(siteKey), + answer: () => { + if (!siteKey) { + return Promise.resolve(undefined); + } + return answer !== null ? Promise.resolve(answer) : new Promise(resolve => waiting.push(resolve)); + }, + // (a widget that never loaded keeps its "" so nothing waits on it) + reset: () => { + if (widget !== null) { + answer = null; + window.turnstile.reset(widget); + } + }, + }; + }; + + return {on: Boolean(siteKey), mount, FAILED: "Captcha could not load. Reload the page."}; +})(); diff --git a/public/commands.html b/public/commands.html new file mode 100644 index 0000000..57b5915 --- /dev/null +++ b/public/commands.html @@ -0,0 +1,259 @@ + + + + + + Chat commands + + + + +
+
+ +

Chat commands

+ Your account +
+
+

Getting around

+ + + +
!go PLACEGo to a land or room.
!go listPlaces you can go.
+
+ +
+

Other players

+ + + + + + +
!onlineWho is online.
!where BUDDYWhere a buddy is.
!w BUDDY MESSAGEWhisper to a buddy.
!hideblocked onHide blocked players.
!hideblocked offShow them again.
+
+ +
+

Outfits

+ + + + + + + +
!outfit save NAMESave your outfit.
!outfit wear NAMEWear a saved outfit.
!outfit listYour saved outfits.
!outfit delete NAMEDelete an outfit.
!outfit offTake everything off.
!outfit undoUndo the last change.
+
+ +
+

Dens

+ + + + + + + + + + +
!den save NAMESave your den layout.
!den load NAMELoad a saved layout.
!den listYour saved layouts.
!den delete NAMEDelete a layout.
!den copyCopy the den you are in.
!den undoUndo Clear Den.
!den name NAMEName your den.
!den name offRemove the name.
!music allGet every music track.
+
+ +
+

Themes

+ + + + + + +
!theme listAll themes.
!theme here NAMETheme this room.
!theme here offRemove it.
!theme random onA random theme each login.
!theme random offStop that.
+
+ +
+

Other

+ + + + + + +
!again NBuy your last purchase N more times.
!mail clearDelete read Jam-A-Grams.
!become NAMELook like an alpha.
!become listWho you can become.
!become offBack to your animal.
+
+ +
+ + + + diff --git a/public/filter/level1.txt b/public/filter/level1.txt new file mode 100644 index 0000000..e161909 --- /dev/null +++ b/public/filter/level1.txt @@ -0,0 +1,51 @@ +# threats +kys +kill yourself +kill urself +go kill yourself +go die +hang yourself +neck yourself +i will rape you +ill rape you +rape you +rape +i hope you die +hope you die +slit your wrists + +# slurs +nigger* +nigga* +nigg +niglet* +chink* +gook* +spic +spics +wetback* +beaner* +kike* +coon +coons +paki +pakis +raghead* +towelhead* +sandnigger* +jigaboo* +porchmonkey* +faggot* +fag +fags +fagg* +dyke +dykes +tranny +trannies +troon* +shemale* +retard +retards +retarded +mongoloid* diff --git a/public/filter/level2.txt b/public/filter/level2.txt new file mode 100644 index 0000000..529fded --- /dev/null +++ b/public/filter/level2.txt @@ -0,0 +1,35 @@ +# list from level1.txt also applies + +fuck* +fuk +fuking +fck +fcking +motherfuck* +mf +stfu +gtfo +shit* +bullshit* +bitch* +biatch* +cunt* +cock +cocks +cocksucker* +dick +dicks +dickhead* +pussy +pussies +asshole* +arsehole* +bastard* +whore* +slut* +twat* +wanker* +jackass* +dumbass* +douche* +bollocks diff --git a/public/fonts/CCDigitalDelivery-Bold.otf b/public/fonts/CCDigitalDelivery-Bold.otf new file mode 100644 index 0000000000000000000000000000000000000000..ec30f35075e60a1d52d76b8e13fce4287479e97f GIT binary patch literal 38764 zcmeFYcUT)o*Ec)@?5q`sICkVDyU8wg5t`r zxK@|;5ddaH05DS(!43-j`N$8qVA(Ld)|8t+(J~hW~(AEm;*#a9n7ye*7TkF)z;4QnG zusp?XaJr{wWzXn006;k)1vWN|ZHB=NfY=P%sNl2u*`4tzSPTAy#Q?FjrEhi_0JLud z4*Ox9>7TRLQ5Ptq17%~oV#*C{hBEy82mp*Ow2|5};mu)MqPgI~zxi*4x%8-L`U=?k zJPmt?;ylZ@1&e^|^Ryk950am!XMnjN_j!6I%&&T$egPZ-$DXGVfG}o3JuvKMK@RDR zSDvRCU?D^IJPilL=zN~G1qT@e&(n5bxy_8{=^5Z1n>EkVGyfz11yE(<_B9C!{ahR@};J{-i zuz5n5xpU{P$nZ#h5N8*g6Def#l6J&$LU#r6qGRKNIGY{*N3jE4zImG0|6bp1xAO_wYfFt075Ln8C?P(e`T^0&fPPgL#4!r+YuXGC@Y?}Zt9uPuG z*W3yJc1?4Rgsp>Mn_aMk19RvaJjihe?3)AY?t-N}5DlN=rt58n{r#U?JN&ynUH_kP z{h!;d_;)+^X*m+0M6qzZ4qy$Gn%2&m|LD&dO2~#%(PMiy%CPBH4scAdFozHIN|*d^ zx~AKNz#9Mb9|l|S{-X{3%!TE2FSL$BVf~orx^RGZ{&apMw2=U&{^^AaThUJ;uyz8J z_`hp!`i+Lu#Psh?NMYK}lYUd+T(Ahtw3(g_-~$)t*uZ={SZ5}90U%%&V8Z!%Hh2lx zgO|Y^I4jJB)AOr<1>f=4!0X@*fWkTDP4E`L0RhEc02YF`!8_nxI8Q7F?|~&?DOd)U zgB4J$Rnv-G3*HCozz1MG*Z?*{x7!Rp1RsHq!4^2*Y=bViW7Jnb3eKAQhy6bRYp)AR9F(ta-ak% zk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i?&eaa2GHfs3Ndk8ZO4PAUASJ=tq|&{p-vbvH zw6JVjkZPN${t|wHg-{hNxFjayGodNhK!MA{GIbCmYtTH|y3Ajx(Sg$kMc;{VLE+tSny?aREfso8JI| zh1HMO?}TM@gOuJ$>kM|Vv9F$0j~+OW!hhT6Z&qfpPwtzoQW6as1K+~RwNwAhUog3^gSdFxe9~3ZgR4n^opoj+E7pt{49bvr-&c$f_?j{Ocbe z&A#}1);{|@>oCv;W0kXRTRH1ym5*bKR!Q<$a$#}Nb>=MW8ukU|KS~ehL~B^Z-B8AV z8S0O$i|*5x0B9b>SZ%FMWsa#z%<6Qy^<>Lf=n4x^DSItKcs*DFSXMsV2@Z%UR_Eg& zG6k|stTK1M%=2bF4r)$MZXfw8i#;ql-P1=5u@tUOKK3*%X1N11Wl0nrtE>gJ4YZ(G zWii?E6tVW$s*pyTsg?B^GxXU)7QUyO%Vhzj5PnbogNghDV#%+VB`g;bce6^5ZgR11 Hx#j-@psKLj literal 0 HcmV?d00001 diff --git a/public/fonts/CCDigitalDelivery-Regular.otf b/public/fonts/CCDigitalDelivery-Regular.otf new file mode 100644 index 0000000000000000000000000000000000000000..6b123e0ca94a3801773e062b266b549de09889ad GIT binary patch literal 33460 zcmeFYcUW7;wl_RN7`7!_PHf9bwxTUuaEW_2u7I&IZgfoVy%zzZ7a>$o7ac_Jy%!tX zxc43x;)3In=HwhFImw8#lfyeAIrp4er_N1AQ&}L*uBwOwR&r!`rC6 zz;JA4ra#*L$iD{w(SdScV6cj!1hW8UFlHb@zombCQ=WrO;P0pz%%Y-c4S-=b0Nv)m z! zEE@o0M9v@eRInJF__J*IZ+&Kg`GEIlz0tqb8v}bF`LiAa7$CLzaP*j46O>{s^d~8g-A2%p)ory(cq{&Rz1e5rngrN8&RJnh@ zRai(E*Dum4C^9T5C_cp@C?qk`FW$;8J|ZU8FLI~J|LC!EW+j)P_=K>SXp@cWHf-29 zQ)3qy}QhLqH;`^FzO_X7Y#`n)SVRqFMj%bLe~h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>U{#=jZk0-5pFn3rSoehuC#+c*j`&cu(g`KS;TbO`q}6eC#bipTv{_J`xY~fS zjZFE{B)qiQQ)M}f9zZO|97lvlcaqi{%MHa0cz=ejg0|8@Jlp;w)72M+J86gl1iJFa z+6Ndb7j#j1n~vu_vx5XAjYsy9$c&pOSIfE=#YSRa3?Vc7#jOmDW*uXCLY0ZakG0Ow111qJ(!uqwu;tAquGR4xO zY*B_G@!(2H4wYO&6*UQfOyv(`>TBp5S^z}ft=-GjiCJFF>8;d`xhY5oKj4(3w4F+LcnR%6uUki)?8N}xxKR&N_m@}0?xB3 zah{>ZzGLM4a~Wr*MSY?PQ6FMv?$8>u%sQ>=Gra8RyW~Oq|74NKZUsc;J`CQa(;t!n zTwhZO?;>*&!hz%jb7wVR?j-%m+#v(jsNqJ^uRxs}ze}bPf3*=$%ZR@+-d2#`p<|$v z%qR3|2!FGd3_$<8v>PxmG+zQ-{C5dlyqxUJ0lbTt5sXmd(23L-X!K$#AWM{0({Ox= zcsn^R{synF2gXAC)yhw&(Q~x64z;xvC>2>95o$`)1|ZznJ1yKu7VZLoZr^?-VKcvaIaX=Fd_hseS1SX-n63N}Z(JE`Qs1cNCN{*ehxhR>RM8RX^WeVI%y8!Z^B zI#M%IIb1smkbiJQvmk5Iq`@>PVyg5C)&H@gFYyU)m5E + + + + Game Client + + + + + + + diff --git a/public/home.html b/public/home.html new file mode 100644 index 0000000..2208491 --- /dev/null +++ b/public/home.html @@ -0,0 +1,420 @@ + + + + + + Burrow + + + + + + +

+ +
+ + + +
+ +
+

Burrow

+ +
+

an AJ Classic private server

+ +
+ Discord + GitHub +
+

+
+
+ +
+
+
+
+

Everything unlocked

+
+
    +
  • Item giver

    any item in custom colours

  • +
  • Membership unlocked

  • +
  • Every animal and pet

    in stores all the time

  • +
  • Restored content

    removed content and concept dens

  • +
  • Themes

    any season or holiday

  • +
  • Alphas

    play as an alpha

  • +
  • Profiles

    bio, badges and better player cards

  • +
  • Chat upgraded

    fewer limits, whispers

  • +
  • Custom names

    for animals and pets

  • +
  • Bigger inventory

    higher limits

  • +
  • Custom client

    with improvements of its own

  • +
  • QOL improvements

    all over the game

  • +
+
+
+ +
+
+
+
+

Get Burrow

+

Windows, Linux, macOS

+
+
+
+ Soon +
+
+
+
+
+ + + + + + diff --git a/public/logo-square.png b/public/logo-square.png new file mode 100644 index 0000000000000000000000000000000000000000..ffec27f9f66a91592f709012257e8b8349f25e33 GIT binary patch literal 39740 zcmdQ~WmlVB)5YD3TY=&PEn2Kl+$|w^pg6^gTd<-93dM^%1PE3ff)^|96qi!m9bWF| zU%Vf(R#rY-b7ro|o|!%SL}_U#;^R=`AR!^)D=W$AAR!?G{`+8Iy!_%55a)q}l!>Y= zC!^=Rc#wq&A)T2Wn6hQc&1K4+M`HSolGiqC?Peug(mz!>ibZNs|dU z+1t@%)u9)oKR+cNwp)4a`dF`<}t+m=Y%395KKjKhU9@6?E@I4RD ziv0uC|D&(5*3vo)h_4S`$EG%gQuhb1b`KYC=j0gkS4pt_fvN&KY4tO{=HP(n3A8FJqrg}-9*z@29@M2t7P92Xqr)y`5!EQL?)3x(tYn9<_wUIV zYZJ==UVnNBSNw!mBHD$?j*H$aBc}*_cP)h^Gu3_x{g=-Kykja>M^9f+r1uK!-Q~vn zju|711oYARfZUlfAE4B`&jEQZW@Xf|zTF!z&{T3xhowd0z`y6kvd)#egx)u<_#Sd# zUR6J4{30g}Bf+_g$(5H!V)ax-&iS&e!M!m0t~TvrtA3BNNwj{xv*JxxZia)Ae7N{? z({>6?Ys_)Atd^xV_@V$w;fz{X7&sG{1ajfY;i}0+brRL>P)FVRwJ)GY+YHFH25r1o!APxCa zh%@}ek@{hH-O|!Upw6i7vqKGO(x`QUAi#tatZg2&wBX)G&#k6Zg%G4`q1hHJ9~uOuA>W%`yJh3U*pNQhvu_j!&9qkA3nKrsFap zHW_GI|E16u0Zxp!JuV*1If1_M-?xW%CC5gjdDR-BX4B=6r-e#tffPRE(xG{7)Z{+c zZpL?OGvPzimS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u0mjf;#HA7 literal 0 HcmV?d00001 diff --git a/public/mod.html b/public/mod.html new file mode 100644 index 0000000..7a83a51 --- /dev/null +++ b/public/mod.html @@ -0,0 +1,981 @@ + + + + + + Moderators + + + + +
+ +

Moderators

+
+ + + + + + +
+ +
+

+
+ + + + + + + diff --git a/public/privacy.html b/public/privacy.html new file mode 100644 index 0000000..97a76c7 --- /dev/null +++ b/public/privacy.html @@ -0,0 +1,257 @@ + + + + + + Privacy Policy · Burrow + + + + +
+
+ +

Privacy Policy

+ Terms of Service +
+
Burrow is an unofficial fan project. It is not affiliated with, endorsed by or connected to WildWorks, Inc. or Animal Jam. Animal Jam and Animal Jam Classic are trademarks of WildWorks, Inc.
+

Version {{version}}. This policy covers the Burrow server at {{site}}, its website and its client.

+ +
+

1. Who is responsible

+

The controller of your personal data is the operator of Burrow, {{operator}}. Contact for anything in this policy: {{legalEmail}}. General contact: {{adminEmail}}.

+

We do not sell data, show ads, track you across sites or send marketing. We do not collect your real name, email address or date of birth. The only statistics we see are the overall traffic figures described in section 4.

+
+ +
+

2. What we collect and why

+
+ + + + + + + + + + + +
DataWhy
Username, password (stored only as a salted hash), and the date and version of the terms you acceptedTo give you an account
Your game data: animals, items, dens, pets, buddies, block list, trades, achievements, settingsTo run the game for you
What you choose to write or make: bio, Discord username (optional), Jam-A-Grams, wall posts, paintings, feedbackTo show or deliver it as you asked
Typed chat and whispers, with the room and timeModeration: reviewing reports and deciding on bans
IP address at each sign-in, and sign-in timesSecurity: your sign-in history, limiting abuse, address bans
Reports, bans and their reasons, appeals, username rejectionsModeration and preventing ban evasion
2FA secret and trusted-device tokens, if you turn 2FA onTo protect your account
Technical error reports sent by the game clientFixing bugs
+

Creating an account requires the first row only. Everything else comes from playing.

+
+ +
+

3. Who can see it

+
    +
  • Other players see your username, animals, den, bio, Discord username if you add one, badges, when you joined and were last seen, your chat in the room you are in, and whether you are currently banned.
  • +
  • Moderators can also read stored chat and whispers, reports, and ban history. They cannot see your IP address, sign-in history, password or inventory.
  • +
  • The administrator can see everything listed in section 2.
  • +
  • Our hosting provider stores the data on our behalf, in {{hostedIn}}. If that is outside your country, your data is transferred there to provide the service.
  • +
  • Cloudflare carries part of the traffic to this server. See section 4.
  • +
+

We share data with nobody else, unless the law requires it. WildWorks receives nothing from us about you.

+
+ +
+

4. Cloudflare

+

Parts of Burrow are reached through Cloudflare, Inc., which protects the server from attacks and delivers pages faster. When your connection passes through Cloudflare, it processes your IP address and technical details of the request (such as browser type, the page requested and the time), and may set a cookie that is needed for security. Cloudflare operates worldwide, so this can happen outside your country, including in the United States.

+

When you sign in or create an account, a Cloudflare captcha (Turnstile) checks that you are a person. It looks at your IP address and at signals from your browser and device, and only tells us whether the check passed.

+

Cloudflare gives us overall traffic statistics, such as the number of requests and visitors and the countries they come from. These do not identify you and we do not combine them with your account.

+

Cloudflare handles this data under its own policy: cloudflare.com/privacypolicy.

+
+ +
+

5. How long we keep it

+
+ + + + + + + + + + + +
DataKept
Account and game dataUntil you delete your account
Chat and whispers30 days
Sign-in history with IP addressesYour last 40 sign-ins, and none older than 90 days
Error reports and server logsUp to 30 days
Handled reports, feedback and username requests12 months
Ban recordsWhile the account exists, then 12 months
Banned IP addressesUntil the ban is lifted
Backups14 days
+

When you delete your account we delete your game data, chat, appeal, feedback, username requests and paintings straight away. Your username is held for 30 days so nobody can pass as you, and ban records are kept as shown above. Copies in backups disappear within 14 days.

+
+ +
+

6. Your rights

+

Wherever you live, you can use these on your account page:

+
    +
  • Access and portability: "Download your data" gives you a file with everything we hold about your account.
  • +
  • Correction: change your password, bio, Discord username and settings, or request a new username.
  • +
  • Deletion: "Delete account" removes your account for good. This also works while you are banned.
  • +
+

You can also ask us to restrict or stop a use of your data, or ask any question, by writing to {{legalEmail}}. We answer within one month.

+
+ +
+

7. Children

+

Burrow is for people aged 13 and over, or the higher age at which the law of your country lets you agree to the use of your data on your own (up to 16 in parts of Europe). We do not knowingly collect data from anyone younger and we do not offer parental consent. If we learn that an account belongs to someone under that age we delete it. Parents and guardians can ask for this at {{legalEmail}}.

+
+ +
+

8. Cookies and your device

+

The website sets only cookies that are needed to keep you signed in: a session cookie on your account page (12 hours) and, if you choose "Trust this device", a 2FA cookie (30 days). The client keeps your saved sign-in on your own computer if you tick "Remember me". Cloudflare may add a security cookie of its own (section 4). There are no advertising or tracking cookies.

+
+ +
+

9. Security

+

Passwords are stored only as salted hashes, sign-in tokens as hashes, and connections are encrypted when the server address begins with https. No system is perfectly secure. If a breach puts your data at risk we will tell you in the game and on this site.

+
+ +
+

10. Changes

+

If this policy changes, the version at the top changes with it, and significant changes are announced in the game or on this site before they apply.

+
+ + +
+ + diff --git a/public/register.html b/public/register.html new file mode 100644 index 0000000..1572d5d --- /dev/null +++ b/public/register.html @@ -0,0 +1,358 @@ + + + + + + Create an account + + + + +
+ +
+
Step 1 of 2
+

Choose an animal

+
+
+
+
+ + +
+
+ +
+ + + + + +
+
+ +
Burrow is an unofficial fan project, not affiliated with WildWorks or Animal Jam. Terms · Privacy
+ + + + + diff --git a/public/shop.html b/public/shop.html new file mode 100644 index 0000000..20e378c --- /dev/null +++ b/public/shop.html @@ -0,0 +1,305 @@ + + + + + + Item finder + + + + +
+ +

Item finder

+

Search every clothing and den item by name or id and add it to an account for free. In-game shops only stock a slice of the catalogue each.

+ +
+ + + +
+
+ +
+ + + + + +
IdNameKindPrice
+
+
+ + + + diff --git a/public/signup/hero_bunny.svg b/public/signup/hero_bunny.svg new file mode 100644 index 0000000..c14c2c0 --- /dev/null +++ b/public/signup/hero_bunny.svg @@ -0,0 +1 @@ +avatar_hero_bunny \ No newline at end of file diff --git a/public/signup/hero_koala.svg b/public/signup/hero_koala.svg new file mode 100644 index 0000000..a1252a5 --- /dev/null +++ b/public/signup/hero_koala.svg @@ -0,0 +1 @@ +avatar_hero_koala \ No newline at end of file diff --git a/public/signup/hero_monkey.svg b/public/signup/hero_monkey.svg new file mode 100644 index 0000000..87667d8 --- /dev/null +++ b/public/signup/hero_monkey.svg @@ -0,0 +1 @@ +avatar_hero_monkey \ No newline at end of file diff --git a/public/signup/hero_panda.svg b/public/signup/hero_panda.svg new file mode 100644 index 0000000..e2b6f93 --- /dev/null +++ b/public/signup/hero_panda.svg @@ -0,0 +1 @@ +avatar_hero_panda \ No newline at end of file diff --git a/public/signup/hero_penguin.svg b/public/signup/hero_penguin.svg new file mode 100644 index 0000000..64d4dfa --- /dev/null +++ b/public/signup/hero_penguin.svg @@ -0,0 +1 @@ +avatar_hero_penguin \ No newline at end of file diff --git a/public/signup/hero_rhino.svg b/public/signup/hero_rhino.svg new file mode 100644 index 0000000..daabbd5 --- /dev/null +++ b/public/signup/hero_rhino.svg @@ -0,0 +1 @@ +avatar_hero_rino \ No newline at end of file diff --git a/public/signup/hero_seal.svg b/public/signup/hero_seal.svg new file mode 100644 index 0000000..494e39b --- /dev/null +++ b/public/signup/hero_seal.svg @@ -0,0 +1 @@ +avatar_hero_seal \ No newline at end of file diff --git a/public/signup/hero_tiger.svg b/public/signup/hero_tiger.svg new file mode 100644 index 0000000..0da5f57 --- /dev/null +++ b/public/signup/hero_tiger.svg @@ -0,0 +1 @@ +avatar_hero_tiger \ No newline at end of file diff --git a/public/signup/hero_wolf.svg b/public/signup/hero_wolf.svg new file mode 100644 index 0000000..076b47f --- /dev/null +++ b/public/signup/hero_wolf.svg @@ -0,0 +1 @@ +avatar_hero_wolf \ No newline at end of file diff --git a/public/signup/thumb_bunny.svg b/public/signup/thumb_bunny.svg new file mode 100644 index 0000000..c4850ca --- /dev/null +++ b/public/signup/thumb_bunny.svg @@ -0,0 +1 @@ +avatar_thumb_bunny \ No newline at end of file diff --git a/public/signup/thumb_koala.svg b/public/signup/thumb_koala.svg new file mode 100644 index 0000000..c9ab66e --- /dev/null +++ b/public/signup/thumb_koala.svg @@ -0,0 +1 @@ +avatar_thumb_koala \ No newline at end of file diff --git a/public/signup/thumb_monkey.svg b/public/signup/thumb_monkey.svg new file mode 100644 index 0000000..cc8366b --- /dev/null +++ b/public/signup/thumb_monkey.svg @@ -0,0 +1 @@ +avatar_thumb_monkey \ No newline at end of file diff --git a/public/signup/thumb_panda.svg b/public/signup/thumb_panda.svg new file mode 100644 index 0000000..e08e05f --- /dev/null +++ b/public/signup/thumb_panda.svg @@ -0,0 +1 @@ +avatar_thumb_panda \ No newline at end of file diff --git a/public/signup/thumb_penguin.svg b/public/signup/thumb_penguin.svg new file mode 100644 index 0000000..9d6bd9a --- /dev/null +++ b/public/signup/thumb_penguin.svg @@ -0,0 +1 @@ +avatar_thumb_penguin \ No newline at end of file diff --git a/public/signup/thumb_rhino.svg b/public/signup/thumb_rhino.svg new file mode 100644 index 0000000..e7f0304 --- /dev/null +++ b/public/signup/thumb_rhino.svg @@ -0,0 +1 @@ +avatar_thumb_rino \ No newline at end of file diff --git a/public/signup/thumb_seal.svg b/public/signup/thumb_seal.svg new file mode 100644 index 0000000..1d1f3de --- /dev/null +++ b/public/signup/thumb_seal.svg @@ -0,0 +1 @@ +avatar_thumb_seal \ No newline at end of file diff --git a/public/signup/thumb_tiger.svg b/public/signup/thumb_tiger.svg new file mode 100644 index 0000000..232af6f --- /dev/null +++ b/public/signup/thumb_tiger.svg @@ -0,0 +1 @@ +avatar_thumb_tiger \ No newline at end of file diff --git a/public/signup/thumb_wolf.svg b/public/signup/thumb_wolf.svg new file mode 100644 index 0000000..b45f479 --- /dev/null +++ b/public/signup/thumb_wolf.svg @@ -0,0 +1 @@ +avatar_thumb_wolf \ No newline at end of file diff --git a/public/terms.html b/public/terms.html new file mode 100644 index 0000000..50a73a6 --- /dev/null +++ b/public/terms.html @@ -0,0 +1,240 @@ + + + + + + Terms of Service · Burrow + + + + +
+
+ +

Terms of Service

+ Privacy Policy +
+
Burrow is an unofficial fan project. It is not affiliated with, endorsed by or connected to WildWorks, Inc. or Animal Jam. Animal Jam and Animal Jam Classic are trademarks of WildWorks, Inc.
+

Version {{version}}. These terms apply to the Burrow server at {{site}}, its website and its client.

+ +
+

1. Who we are

+

Burrow is a private, non-commercial game server run by {{operator}} ("we"). It is a hobby project, offered free of charge. We are not WildWorks and have no relationship with them. If you want the official game, it is at animaljam.com.

+

General contact: {{adminEmail}}. Legal and privacy contact: {{legalEmail}}.

+
+ +
+

2. Who may play

+
    +
  • You must be at least 13 years old.
  • +
  • If the law where you live sets a higher age for agreeing to the use of your personal data on your own (up to 16 in parts of Europe), you must be at least that age.
  • +
  • Burrow is not directed at children and has no way to collect a parent's consent. If you are under the age above, do not create an account.
  • +
+

By creating an account you confirm that you meet these requirements and that you agree to these terms and to the Privacy Policy. We delete accounts that we learn belong to someone under the required age.

+
+ +
+

3. Your account

+
    +
  • You are responsible for your password and for what is done with your account. Use a password you do not use anywhere else.
  • +
  • We do not collect an email address, so we cannot send you a password reset. Turn on 2FA and keep your recovery codes.
  • +
  • You can delete your account at any time on your account page.
  • +
+
+ +
+

4. Rules

+

Burrow gives players more freedom than the original game, including free chat. In return you agree not to:

+
    +
  • harass, threaten or bully anyone, or post hateful or sexual content;
  • +
  • share anyone's personal information, including your own contact details where it puts you at risk;
  • +
  • scam other players;
  • +
  • put another player in danger in any way, in the game or outside it;
  • +
  • pretend to be staff, use a name or content meant to offend, or get around a ban;
  • +
  • attack, overload or probe the server, use exploits, or interfere with other players' use of it;
  • +
  • use Burrow for anything unlawful.
  • +
+
+ +
+

5. Moderation

+
    +
  • Chat and whispers are stored for a limited time so that moderators can review reports. See the Privacy Policy.
  • +
  • Moderators and the administrator may silence or ban an account, reject a username, remove content, or ban an address, with or without notice, when these terms are broken or the server needs protecting.
  • +
  • Putting another player in danger leads to the account being closed.
  • +
  • We may also suspend or close any account at our discretion, for any reason, including reasons not listed in these terms.
  • +
  • If you are banned you are told the reason and can appeal once on your account page.
  • +
+
+ +
+

6. Your content

+

What you write or make in the game (chat, bio, Jam-A-Grams, wall posts, paintings, den layouts) stays yours. You allow us to store it and show it to other players as the game requires, for as long as it is on the server. Do not post anything you have no right to share.

+
+ +
+

7. The game and its content

+

The game client, artwork, music, characters and names belong to WildWorks, Inc. or their respective owners. Burrow claims no ownership of them and grants you no rights in them. Items, currency and anything else you hold in the game have no monetary value and can be changed, reset or removed at any time.

+

Takedown procedure: WildWorks, Inc. or its authorized representatives may request the removal of content, or of Burrow as a whole, by writing to {{legalEmail}}. Upon verification of authority, the request will be carried out promptly.

+
+ +
+

8. No guarantees

+

Burrow is provided as it is, without any warranty. It may be unavailable, lose data, change or shut down permanently at any time and without notice. To the extent the law allows, we are not liable for any loss arising from your use of it. Nothing in these terms limits rights that the law does not allow to be limited.

+
+ +
+

9. Ending and changes

+
    +
  • You may stop using Burrow and delete your account at any time. We may suspend or close an account as set out in section 5.
  • +
  • We may update these terms. The version and date at the top will change, and significant changes will be announced in the game or on this site before they apply. If you do not agree, stop using Burrow and delete your account.
  • +
  • These terms are governed by the law of the European Union member state where the operator is based, without affecting the consumer protections of the country where you live.
  • +
+
+ + +
+ + diff --git a/server.js b/server.js new file mode 100644 index 0000000..396cb27 --- /dev/null +++ b/server.js @@ -0,0 +1,80 @@ +"use strict"; + +require("./lib/log.js"); // first, so everything printed reaches the admin panel's log view + +const fs = require("fs"); +const accounts = require("./lib/accounts.js"); +const bans = require("./lib/bans.js"); +const chatlog = require("./lib/chatlog.js"); +const modlog = require("./lib/modlog.js"); +const retention = require("./lib/retention.js"); +const colours = require("./lib/colours.js"); +const config = require("./config.js"); +const defpacks = require("./lib/defpacks.js"); +const http = require("./lib/http.js"); +const masterpieces = require("./lib/masterpieces.js"); +const panel = require("./lib/panel.js"); +const reports = require("./lib/reports.js"); +const roomInfo = require("./lib/roominfo.js"); +const support = require("./lib/support.js"); +const sfs = require("./lib/sfs.js"); +const world = require("./lib/world.js"); + +// files this server makes are its own to read: accounts, logs, the cache. +process.umask(0o077); + +const main = async () => { + if (config.problems.length) { + throw new Error(config.problems.join("; ")); + } + if (!fs.existsSync(config.clientSwf)) { + throw new Error(`Client SWF not found at ${config.clientSwf} (set AJ_CLIENT_SWF)`); + } + await defpacks.init(); + await roomInfo.preload(); + accounts.load(); + fs.chmodSync(config.dataDir, 0o700); + accounts.startBackups(); + colours.load(); + reports.load(); + support.load(); + bans.load(); + chatlog.load(); + modlog.load(); + masterpieces.load(); + retention.load(); + panel.load(); + await http.start(); + await sfs.start(world); + console.log(`[server] ready at ${config.baseUrl}`); +}; + +// stopped on purpose: what is waiting to be written is written first. +const stop = code => { + try { + accounts.flush(); + } + catch (err) { + console.error(`[server] could not save while stopping: ${err.message}`); + } + process.exit(code); +}; +process.on("SIGTERM", () => stop(0)); +process.on("SIGINT", () => stop(0)); +// the last resort. message handlers, timers and goodbyes each catch their +// own errors; what gets here was thrown somewhere nobody thought of, and the +// server's state can no longer be vouched for. it is written down, what can +// be saved is saved, and the process ends for whatever started it (systemd, +// with Restart=always) to start it again. +process.on("uncaughtException", err => { + console.error(`[server] uncaught error, stopping: ${err && err.stack ? err.stack : err}`); + stop(1); +}); +process.on("unhandledRejection", err => { + console.error(`[server] unhandled rejection: ${err && err.stack ? err.stack : err}`); +}); + +main().catch(err => { + console.error(`[server] failed to start: ${err.message}`); + process.exit(1); +}); diff --git a/test/account.js b/test/account.js new file mode 100644 index 0000000..77a28d7 --- /dev/null +++ b/test/account.js @@ -0,0 +1,231 @@ +"use strict"; + +// end-to-end check of the sign-up page's rules and the account page +// (/account, lib/manage.js): signing in, password, username requests, +// feedback, the lock, the switches for parts of the game, login history, +// and the admin panel's side of it. simulated players, a real server. + +const assert = require("assert"); +const art = require("../lib/ecard-art.json"); +const harness = require("./harness.js"); + +const HTTP_PORT = 18084; +const GAME_PORT = 19343; +const BASE = `http://127.0.0.1:${HTTP_PORT}`; +const TOWNSHIP = "jamaa_township.room_main#1"; +const {postJson} = harness; + +const authenticate = (username, password) => postJson(`${BASE}/authenticate`, {username, password}); + +const arrive = async (username, password) => { + const auth = await (await authenticate(username, password)).json(); + const client = new harness.GameClient(GAME_PORT); + await client.connect(); + const login = await client.logIn(username, auth.auth_token); + assert.strictEqual(login.status, "1"); + client.xt("rj", 1, TOWNSHIP, 1, 0, 0); + const roomId = (await client.untilXt("rj"))[4]; + await client.untilXt("rp"); + client.xt("au", roomId, 1, 400, 400, 14, 1); + return {client, roomId, token: auth.auth_token}; +}; + +// A request to one of the two cookie-guarded pages' APIs. +const page = prefix => async (pathname, body, cookie, headers = {}) => { + const response = await fetch(`${BASE}/${prefix}/api/${pathname}`, { + method: body === undefined ? "GET" : "POST", + headers: {"Content-Type": "application/json", ...(cookie ? {Cookie: cookie} : {}), ...headers}, + body: body === undefined ? undefined : JSON.stringify(body), + }); + return {status: response.status, data: await response.json(), cookie: (response.headers.get("set-cookie") || "").split(";")[0]}; +}; +const mine = page("account"); +const panel = page("admin"); + +const run = async () => { + const register = (username, avatarType) => fetch(`${BASE}/api/register`, {method: "POST", headers: {"Content-Type": "application/json"}, + body: JSON.stringify({username, password: "Password01", avatarType, agreed: true})}); + assert.strictEqual((await register("Ann", 4)).status, 200); + assert.strictEqual((await register("Ben", 24)).status, 200); + // what a client shows beside its login form. + const status = await (await fetch(`${BASE}/api/status`)).json(); + assert.ok(status.online === 0 && status.uptimeSeconds >= 0); + + // --- the page and who may use it + assert.match(await (await fetch(`${BASE}/account`)).text(), /Your account/); + assert.strictEqual((await mine("me")).status, 401); + assert.strictEqual((await mine("login", {username: "Ann", password: "wrong"})).status, 401); + assert.strictEqual((await mine("login", {username: "Nobody", password: "Password01"})).status, 401); + const signedIn = await mine("login", {username: "ann", password: "Password01"}); + assert.strictEqual(signedIn.status, 200); + assert.match(signedIn.cookie, /^ajc_account=[0-9a-f]{48}$/); + const ann = signedIn.cookie; + assert.strictEqual((await mine("act", {action: "lock", locked: true}, ann, {Origin: "http://evil.example"})).status, 403); + let me = (await mine("me", undefined, ann)).data; + assert.deepStrictEqual([me.username, me.animalType, me.locked, me.features.chat], ["Ann", 4, false, true]); // the wolf she picked + // the wrong password and the sign-in are both in her history, newest first. + assert.deepStrictEqual(me.history.map(login => [login.via, login.ok]), [["web", true], ["web", false]]); + + // --- parts of the game switched off + const {client: a, roomId} = await arrive("Ann", "Password01"); + const {client: b} = await arrive("Ben", "Password01"); + await a.untilXt("ac"); + const set = async (feature, on) => assert.strictEqual((await mine("act", {action: "feature", feature, on}, ann)).status, 200); + assert.strictEqual((await mine("act", {action: "feature", feature: "flying", on: false}, ann)).status, 400); + + await set("buddies", false); + b.xt("ba", roomId, "Ann"); + assert.deepStrictEqual((await b.untilXt("ba")).slice(2, 4), ["3", "Ann"]); // not accepting requests + a.xt("ba", roomId, "Ben"); + assert.strictEqual((await a.untilXt("ba"))[2], "3"); + await set("buddies", true); + b.xt("ba", roomId, "Ann"); + assert.strictEqual((await a.untilXt("ba"))[3], "Ben"); // it arrives now + + await set("chat", false); + a.send(``); + assert.deepStrictEqual((await a.untilXt("uc")).slice(3), ["-1", "5"]); // her line goes nowhere + b.send(``); + assert.strictEqual((await b.untilXt("uc"))[3], "anyone"); + await set("chat", true); + b.send(``); + assert.strictEqual((await a.untilXt("uc"))[3], "again"); // "anyone" never reached her + + await set("trading", false); + b.xt("ti", roomId, 0, "Ann", 0, 1, 0, 0, 0, 0); + assert.deepStrictEqual((await b.untilXt("ti")).slice(2, 4), ["4", "Ann"]); // unavailable, before anything else is looked at + await set("jamagrams", false); + b.xt("es", roomId, "Ann", art.cards[0], art.stamps[0], 0, "hi", 0, 0, 0); + assert.strictEqual((await b.untilXt("es"))[2], "-2"); // not accepting them + await set("jamagrams", true); + b.xt("es", roomId, "Ann", art.cards[0], art.stamps[0], 0, "hi", 0, 0, 0); + assert.strictEqual((await b.untilXt("es"))[2], "1"); + await set("jamagrams", false); + me = (await mine("me", undefined, ann)).data; + assert.deepStrictEqual([me.features.trading, me.features.jamagrams, me.features.buddies, me.online], [false, false, true, true]); + + // --- buddies with a note, the block list, achievements, den visitors + b.xt("bc", roomId, "Ann", 1); // ben says yes to her request from before + a.xt("ba", roomId, "Ben"); + await b.untilXt("ba"); + b.xt("bc", roomId, "Ann", 1); + await a.untilXt("bs"); + assert.strictEqual((await mine("act", {action: "buddyNote", name: "Ben", note: " met at the fountain "}, ann)).status, 200); + assert.strictEqual((await mine("act", {action: "buddyNote", name: "Nobody", note: "x"}, ann)).status, 400); + assert.strictEqual((await mine("act", {action: "block", name: "Nobody"}, ann)).status, 400); + assert.strictEqual((await mine("act", {action: "block", name: "Ben"}, ann)).status, 200); + await a.untilXt("bl"); // her game hears of it: its buddy list, then its block list + assert.deepStrictEqual((await a.untilXt("bl")).slice(2, 5), ["1", "1", "ben"]); + assert.strictEqual((await mine("act", {action: "block", name: "Ben"}, ann)).status, 400); + b.xt("dj", roomId, "denAnn", 1, -1); + await b.untilXt("rj"); // locked out: she blocked him + assert.strictEqual((await mine("act", {action: "unblock", name: "ben"}, ann)).status, 200); + b.xt("dj", roomId, "denAnn", 1, -1); + const inDen = await b.untilXt("rj"); + assert.strictEqual(inDen[3], "denAnn"); + b.xt("rj", inDen[4], TOWNSHIP, 1, 0, 0); + await b.untilXt("rp"); + me = (await mine("me", undefined, ann)).data; + assert.deepStrictEqual(me.buddyList, [{name: "Ben", online: true, note: "met at the fountain"}]); + assert.deepStrictEqual([me.blocked, me.denVisits.map(visit => visit.name), me.trades, me.offers], [[], ["Ben"], [], {incoming: [], outgoing: []}]); + assert.ok(me.achievements.of > 200 && me.achievements.counted.some(counted => counted.name === "Gems Earned" && counted.next > 0)); + + // --- a trade offer left for someone, answered from their page + const giveTo = async (username, query) => { + const found = (await (await fetch(`${BASE}/api/search?q=${query}&kind=clothing`)).json()).results[0]; + await fetch(`${BASE}/api/give`, {method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({username, kind: "clothing", id: found.id, colorIndex: 0})}); + return found.name; + }; + const hatName = await giveTo("Ann", "top+hat"); + const scarfName = await giveTo("Ben", "scarf"); + let benHas = await b.untilXt("il"); + while (benHas[2] !== "2" || benHas[5] !== "Ben") { // past the lists he was sent of Ann's clothes + benHas = await b.untilXt("il"); + } + b.xt("ts", roomId, 0, 1, 0, benHas[9]); // ben puts his scarf up for trade, in the game + await b.untilXt("tl"); + const benPageCookie = (await mine("login", {username: "Ben", password: "Password01"})).cookie; + const tradable = (await mine("tradable?of=ben", undefined, ann)).data; + assert.deepStrictEqual([tradable.found, tradable.theirs.map(item => item.name), tradable.mine.map(item => item.name)], [true, [scarfName], [hatName]]); + assert.strictEqual((await mine("act", {action: "offer", to: "Ben", wanted: tradable.theirs[0], offered: []}, ann)).status, 400); + assert.strictEqual((await mine("act", {action: "offer", to: "Ben", wanted: {type: 0, inv: 999999}, offered: tradable.mine}, ann)).status, 400); + assert.strictEqual((await mine("act", {action: "offer", to: "Ben", wanted: tradable.theirs[0], offered: tradable.mine}, ann)).status, 400); // she has trading off + await set("trading", true); + assert.strictEqual((await mine("act", {action: "offer", to: "Ben", wanted: tradable.theirs[0], offered: tradable.mine}, ann)).status, 200); + let benPage = (await mine("me", undefined, benPageCookie)).data; + assert.deepStrictEqual(benPage.offers.incoming.map(offer => [offer.from, offer.wanted.name, offer.offered.map(item => item.name)]), [["Ann", scarfName, [hatName]]]); + assert.strictEqual((await mine("me", undefined, ann)).data.offers.outgoing.length, 1); + assert.strictEqual((await mine("act", {action: "answerOffer", id: benPage.offers.incoming[0].id, accept: true}, benPageCookie)).status, 200); + await a.untilXt("di"); // both are in the game: their inventories are sent afresh + await b.untilXt("di"); + benPage = (await mine("me", undefined, benPageCookie)).data; + assert.deepStrictEqual([benPage.offers.incoming, benPage.trades.map(trade => [trade.with, trade.got, trade.gave])], [[], [["Ann", [hatName], [scarfName]]]]); + assert.deepStrictEqual((await mine("tradable?of=ben", undefined, ann)).data.mine.map(item => item.name), [scarfName]); + + // --- a username request, approved from the admin panel + assert.strictEqual((await mine("act", {action: "requestName", newName: "Ben"}, ann)).status, 400); // taken + assert.strictEqual((await mine("act", {action: "requestName", newName: "Ann"}, ann)).status, 400); // hers already + assert.strictEqual((await mine("act", {action: "requestName", newName: "x"}, ann)).status, 400); + const asked = await mine("act", {action: "requestName", newName: "Annabel", reason: "my real nickname"}, ann); + assert.strictEqual(asked.status, 200); + assert.deepStrictEqual(asked.data.account.nameRequests.map(request => [request.newName, request.status]), [["Annabel", "waiting"]]); + assert.strictEqual((await mine("act", {action: "feedback", kind: "bug", text: " the slide is stuck "}, ann)).status, 200); + assert.strictEqual((await mine("act", {action: "feedback", kind: "bug", text: " "}, ann)).status, 400); + assert.strictEqual((await mine("act", {action: "feedback", kind: "rant", text: "x"}, ann)).status, 400); + + const admin = (await panel("setup", {password: "admin-password-1"})).cookie; + const waiting = (await panel("support?handled=0", undefined, admin)).data; + assert.deepStrictEqual([waiting.open, waiting.names[0].newName, waiting.names[0].reason, waiting.feedback[0].text], + [2, "Annabel", "my real nickname", "the slide is stuck"]); + assert.strictEqual((await panel("overview", undefined, admin)).data.stats.support, 2); + assert.strictEqual((await panel("support", {action: "read", id: waiting.feedback[0].id}, admin)).status, 200); + assert.strictEqual((await panel("support", {action: "approve", id: waiting.names[0].id}, admin)).status, 200); + assert.strictEqual((await panel("support", {action: "approve", id: waiting.names[0].id}, admin)).status, 400); // only once + assert.strictEqual((await mine("me", undefined, ann)).status, 401); // renamed: sign in again, with the new name + assert.strictEqual((await authenticate("Ann", "Password01")).status, 401); + const annabel = (await mine("login", {username: "Annabel", password: "Password01"})).cookie; + me = (await mine("me", undefined, annabel)).data; + assert.deepStrictEqual([me.username, me.nameRequests[0].status, me.feedback[0].handledAt > 0], ["Annabel", "approved", true]); + + // --- the lock: out of the game, and no way back in until it is undone + const {token} = await arrive("Annabel", "Password01"); + assert.strictEqual((await mine("act", {action: "lock", locked: true}, annabel)).status, 200); + assert.strictEqual((await authenticate("Annabel", "Password01")).status, 401); + assert.strictEqual((await postJson(`${BASE}/authenticate`, {refresh_token: token})).status, 401); // the saved sign-in is gone + assert.strictEqual((await panel("accounts", undefined, admin)).data.accounts.find(account => account.username === "Annabel").locked, true); + assert.strictEqual((await mine("login", {username: "Annabel", password: "Password01"})).status, 200); // the page still lets her in + assert.strictEqual((await mine("act", {action: "lock", locked: false}, annabel)).status, 200); + assert.strictEqual((await authenticate("Annabel", "Password01")).status, 200); + + // --- the password: the old one is asked for, and stops working + assert.strictEqual((await mine("act", {action: "password", current: "wrong", password: "Password02"}, annabel)).status, 400); + assert.strictEqual((await mine("act", {action: "password", current: "Password01", password: "short"}, annabel)).status, 400); + assert.strictEqual((await mine("act", {action: "password", current: "Password01", password: "Password02"}, annabel)).status, 200); + assert.strictEqual((await authenticate("Annabel", "Password01")).status, 401); + assert.strictEqual((await authenticate("Annabel", "Password02")).status, 200); + me = (await mine("me", undefined, annabel)).data; + assert.ok(me.history.some(login => login.via === "launcher" && !login.ok) && me.history.some(login => login.via === "game" && login.ok)); + + assert.strictEqual((await mine("logout", {}, annabel)).status, 200); + assert.strictEqual((await mine("me", undefined, annabel)).status, 401); + + // --- deleting one's own account: the password and the name, then it is gone + const {client: b2} = await arrive("Ben", "Password01"); + const ben = (await mine("login", {username: "Ben", password: "Password01"})).cookie; + assert.strictEqual((await mine("act", {action: "delete", current: "wrong", confirm: "Ben"}, ben)).status, 400); + assert.strictEqual((await mine("act", {action: "delete", current: "Password01", confirm: "Annabel"}, ben)).status, 400); + const gone = await mine("act", {action: "delete", current: "Password01", confirm: "ben"}, ben); + assert.deepStrictEqual([gone.status, gone.data.deleted, gone.data.account], [200, true, undefined]); + assert.strictEqual((await mine("me", undefined, ben)).status, 401); + assert.strictEqual((await authenticate("Ben", "Password01")).status, 401); + assert.ok(!(await panel("accounts", undefined, admin)).data.accounts.some(account => account.username === "Ben")); + assert.strictEqual((await register("Ben", 5)).status, 200); // the name is free again + b2.socket.destroy(); + a.socket.destroy(); + b.socket.destroy(); +}; + +harness.withServer("account page test", HTTP_PORT, GAME_PORT, run).catch(err => { + console.error(err); + process.exit(1); +}); diff --git a/test/buddygames.js b/test/buddygames.js new file mode 100644 index 0000000..8f2d679 --- /dev/null +++ b/test/buddygames.js @@ -0,0 +1,311 @@ +"use strict"; + +// end-to-end check of the buddy games: the invitation, and each of the +// eight games played through by two simulated players against a real server. + +const assert = require("assert"); +const harness = require("./harness.js"); + +const HTTP_PORT = 18083; +const GAME_PORT = 19342; +const BASE = `http://127.0.0.1:${HTTP_PORT}`; +const TOWNSHIP = "jamaa_township.room_main#1"; +const {postJson} = harness; +const GAMES = {ticTacToe: 89, fourGems: 90, rockPaperScissors: 91, shellGame: 92, pairs: 93, scooped: 95, bowling: 98, marbles: 101}; + +const arrive = async username => { + const auth = await (await postJson(`${BASE}/authenticate`, {username, password: "Password01"})).json(); + const client = new harness.GameClient(GAME_PORT); + await client.connect(); + const login = await client.logIn(username, auth.auth_token); + assert.strictEqual(login.status, "1"); + client.xt("rj", 1, TOWNSHIP, 1, 0, 0); + const roomId = (await client.untilXt("rj"))[4]; + await client.untilXt("rp"); + client.xt("au", roomId, 1, 400, 400, 14, 1); + return {client, roomId, id: String(login.params.userId), animal: String(login.params.perUserAvId)}; +}; + +const run = async () => { + for (const username of ["Ann", "Ben", "Cat"]) { + const response = await fetch(`${BASE}/api/register`, {method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({username, password: "Password01", avatarType: 1, agreed: true})}); + assert.strictEqual(response.status, 200); + } + const ann = await arrive("Ann"); + const ben = await arrive("Ben"); + const cat = await arrive("Cat"); + const [a, b, c] = [ann.client, ben.client, cat.client]; + // everything about arriving and seeing each other arrive is behind them + // once each has had an answer to something asked afterwards. + for (const [client, me] of [[a, ann], [b, ben], [c, cat]]) { + client.xt("zg", me.roomId); + await client.untilXt("zg"); + } + + // --- a player who arrives is told of the eight games, each for two players and ready to be played against another + const told = a.unaskedGames[0]; + assert.strictEqual(told[2], "8"); + const perGame = (told.length - 3) / 8; + assert.strictEqual(perGame, 19); + const first = told.slice(3, 3 + perGame); + assert.deepStrictEqual([first[0], first[2], first[4], first[5], first[7], first[8], first[12], first[17]], ["89", "PVP_TicTacToe", "2", "2", "0", "5063", "1", "5063"]); + + // --- invitations + // Ann asks Ben; he says no, and she is told. + a.xt("mp", ann.roomId, GAMES.ticTacToe, 0, "Ben"); + assert.deepStrictEqual((await b.nextXt("mp")).slice(2), ["89", "0", "Ann", "1"]); + // while that is open neither can be asked, nor ask, anything else. + c.xt("mp", cat.roomId, GAMES.pairs, 0, "Ann"); + assert.deepStrictEqual((await c.nextXt("mp")).slice(2), ["93", "1"]); + b.xt("mp", ben.roomId, GAMES.ticTacToe, 1); + assert.deepStrictEqual((await a.nextXt("mp")).slice(2), ["89", "1"]); + // asked again, and taken back. + a.xt("mp", ann.roomId, GAMES.ticTacToe, 0, "Ben"); + await b.nextXt("mp"); + a.xt("mp", ann.roomId, GAMES.ticTacToe, 1); + assert.deepStrictEqual((await b.nextXt("mp")).slice(2), ["89", "1"]); + // nobody of that name, a game that is not a buddy game, oneself: all "no". + for (const [game, name] of [[GAMES.ticTacToe, "Nobody"], [4, "Ben"], [GAMES.ticTacToe, "Ann"]]) { + a.xt("mp", ann.roomId, game, 0, name); + assert.strictEqual((await a.nextXt("mp"))[3], "1"); + } + // A buddy game cannot be started alone. + a.xt("mj", ann.roomId, GAMES.ticTacToe, 0, 0, 0); + assert.deepStrictEqual((await a.nextXt("mj")).slice(2), ["as", "0"]); + await a.untilXt("ua"); + + // starts `game` between Ann (who asks) and Ben, up to both saying they + // are ready. returns the game room's id and what the start message added. + const begin = async game => { + a.xt("mp", ann.roomId, game, 0, "Ben"); + await b.untilXt("mp"); + b.xt("mp", ben.roomId, game, 0); + let room; + let extra; + for (const [client, me] of [[a, ann], [b, ben]]) { + const joined = await client.untilXt("rj"); + assert.deepStrictEqual([joined[3].split("_")[0], joined[10], joined[13]], [`game${game}`, "1", "1"]); // a game's room, beside the one they are in + room = joined[4]; + assert.deepStrictEqual((await client.untilXt("mj")).slice(1), [room, ann.id, ben.id]); + const started = await client.nextXt("ms"); + // two players, their ids, then each one's animal and name + assert.deepStrictEqual(started.slice(1, 9), [room, "2", ann.id, ben.id, ann.animal, "Ann", ben.animal, "Ben"]); + extra = started.slice(9); + void me; + } + a.xt("mm", room, game, "ready"); + b.xt("mm", room, game, "ready"); + return {room, extra}; + }; + // what both players are told next, checked to be the same. + const both = async word => { + const [toAnn, toBen] = [await a.nextXt("mm"), await b.nextXt("mm")]; + assert.deepStrictEqual(toAnn, toBen); + assert.strictEqual(toAnn[2], word); + return toAnn.slice(3); + }; + const say = (who, room, game, ...words) => (who === 0 ? a : b).xt("mm", room, game, ...words); + const finish = async room => { + // each game ends itself: "quit", then out of its room. after a game + // that was decided nobody is told the other "left". + for (const client of [a, b]) { + client.xt("rl", room, room); + } + a.xt("zg", ann.roomId); + assert.strictEqual((await a.nextXt("zg"))[0], "zg"); + b.xt("zg", ben.roomId); + assert.strictEqual((await b.nextXt("zg"))[0], "zg"); + }; + + // --- Tic Tac Toe: the top row for whoever starts + { + const {room} = await begin(GAMES.ticTacToe); + const [turn, ...ids] = await both("round"); + assert.deepStrictEqual(ids, [ann.id, ben.id]); + const x = Number(turn); + const o = 1 - x; + say(o, room, GAMES.ticTacToe, "mark", 1, 1); // not their turn + assert.deepStrictEqual((await (o === 0 ? a : b).nextXt("mm")).slice(2), ["invalid", String(x)]); + say(x, room, GAMES.ticTacToe, "mark", 0, 0); + assert.deepStrictEqual(await both("mark"), [String(x), "0", "0", "0", "0", String(o)]); + say(o, room, GAMES.ticTacToe, "mark", 0, 0); // taken + assert.deepStrictEqual((await (o === 0 ? a : b).nextXt("mm")).slice(2), ["invalid", String(o)]); + say(o, room, GAMES.ticTacToe, "time"); // and then they run out of time: the turn passes + assert.deepStrictEqual(await both("invalid"), [String(x)]); + say(x, room, GAMES.ticTacToe, "mark", 1, 0); + await both("mark"); + say(o, room, GAMES.ticTacToe, "mark", 1, 1); + await both("mark"); + say(x, room, GAMES.ticTacToe, "mark", 2, 0); + assert.deepStrictEqual(await both("mark"), [String(x), "2", "0", "1", "0", String(x)]); // won + await finish(room); + } + + // --- Four Gems: four in one column + { + const {room} = await begin(GAMES.fourGems); + const x = Number((await both("round"))[0]); + const o = 1 - x; + for (let move = 0; move < 3; move++) { + say(x, room, GAMES.fourGems, "mark", 3); + assert.deepStrictEqual(await both("mark"), [String(x), "3", "0", "0", String(o)]); + say(o, room, GAMES.fourGems, "mark", 4); + await both("mark"); + } + say(x, room, GAMES.fourGems, "mark", 9); // no such column + assert.strictEqual((await (x === 0 ? a : b).nextXt("mm"))[2], "invalid"); + say(x, room, GAMES.fourGems, "mark", 3); + assert.deepStrictEqual(await both("mark"), [String(x), "3", "1", "0", String(x)]); + await finish(room); + } + + // --- Rock Paper Scissors: a draw, then Ben wins two rounds + { + const game = GAMES.rockPaperScissors; + const {room} = await begin(game); + const round = async (annHand, benHand) => { + assert.deepStrictEqual(await both("round"), [ann.id, ben.id]); + say(0, room, game, "time", annHand); + say(1, room, game, "time", benHand); + const result = await both("mark"); + return result; + }; + assert.deepStrictEqual(await round("rock", "rock"), ["rock", "rock", "0", "0"]); + say(0, room, game, "ready"); + say(1, room, game, "ready"); + assert.deepStrictEqual(await round("rock", "paper"), ["rock", "paper", "0", "1", "1"]); + say(0, room, game, "ready"); + say(1, room, game, "ready"); + assert.deepStrictEqual(await round("nonsense", "scissors"), ["off", "scissors", "1", "1"]); // no hand loses to any + await finish(room); + } + + // --- the Shell Game: the right shell against the wrong one, twice + { + const game = GAMES.shellGame; + const {room} = await begin(game); + for (const over of [false, true]) { + const [first, second, shell] = await both("round"); + assert.deepStrictEqual([first, second], [ann.id, ben.id]); + assert.ok(["1", "2", "3"].includes(shell)); + const wrong = String(Number(shell) % 3 + 1); + say(0, room, game, "time", shell); + say(1, room, game, "time", wrong); + assert.deepStrictEqual(await both("mark"), over ? [shell, wrong, "1", "0"] : [shell, wrong, "0", "1", "0"]); + if (!over) { + say(0, room, game, "ready"); + say(1, room, game, "ready"); + } + } + await finish(room); + } + + // --- Pairs: whoever starts turns up all eight pairs + { + const game = GAMES.pairs; + const {room} = await begin(game); + const [starter, , count, ...cards] = await both("round"); + assert.deepStrictEqual([count, cards.length, [...cards].map(Number).sort((one, two) => one - two).join()], ["16", 16, "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16"]); + const me = starter === ann.id ? 0 : 1; + const them = 1 - me; + const watcher = them === 0 ? a : b; + const at = picture => cards.indexOf(String(picture)); + // A miss first, by the other player's clock running out... no: by two cards that do not match. + say(me, room, game, "c1", at(1)); + assert.deepStrictEqual((await watcher.nextXt("mm")).slice(2), ["c1", String(at(1))]); + say(me, room, game, "c2", at(2)); + assert.deepStrictEqual((await watcher.nextXt("mm")).slice(2), ["c2", String(at(2))]); + assert.deepStrictEqual(await both("results"), ["0", "0"]); + say(them, room, game, "c1", at(3)); // nothing moves until both have watched the result + say(0, room, game, "rp"); + say(1, room, game, "rp"); + await both("nextround"); + say(them, room, game, "time"); // the other player's turn now; they let it run out + await both("time"); + say(0, room, game, "rp"); + say(1, room, game, "rp"); + await both("nextround"); + say(me, room, game, "emote", 3); + assert.deepStrictEqual((await watcher.nextXt("mm")).slice(2), ["emote", "3"]); + for (let picture = 1; picture <= 8; picture++) { + say(me, room, game, "c1", at(picture)); + say(me, room, game, "c2", at(picture + 8)); + await watcher.nextXt("mm"); + await watcher.nextXt("mm"); + if (picture < 8) { + assert.deepStrictEqual(await both("results"), ["0", "1"]); + say(0, room, game, "rp"); + say(1, room, game, "rp"); + await both("nextround"); + } + } + assert.deepStrictEqual(await both("results"), ["1", starter]); + await finish(room); + } + + // --- Scooped: scoops are shown to the other player; the first to finish wins + { + const game = GAMES.scooped; + const {room} = await begin(game); + assert.deepStrictEqual(await both("start"), []); + say(0, room, game, "sc_click", "flavor3"); + assert.deepStrictEqual((await b.nextXt("mm")).slice(2), ["sc_click", "flavor3"]); + say(1, room, game, "sc_done"); + assert.deepStrictEqual(await both("sc_done"), ["1"]); + await finish(room); + } + + // --- Bowling: balls and the wait between them are passed across + { + const game = GAMES.bowling; + const {room} = await begin(game); + const [bowler] = await both("round"); + const thrower = bowler === ann.id ? 0 : 1; + say(thrower, room, game, "ball", "12.5", "-3.25", "410"); + assert.deepStrictEqual((await (thrower === 0 ? b : a).nextXt("mm")).slice(2), ["ball", "12.5", "-3.25", "410"]); + say(0, room, game, "rp"); + say(1, room, game, "rp"); + assert.deepStrictEqual(await both("nextround"), []); + say(thrower, room, game, "time"); + assert.deepStrictEqual(await both("time"), []); + // Ann walks off mid-game: Ben's game is told she left. + a.xt("rl", room, room); + assert.deepStrictEqual((await b.nextXt("ml")).slice(1), [room, ann.id]); + b.xt("rl", room, room); + } + + // --- Marbles: a layout with the start, then aim, shot and end of turn + { + const game = GAMES.marbles; + const {room, extra} = await begin(game); + assert.ok(extra.length === 1 && Number(extra[0]) >= 1 && Number(extra[0]) <= 14); + assert.ok(["0", "1"].includes((await both("start"))[0])); + say(0, room, game, "pos", 300, 200); + assert.deepStrictEqual((await b.nextXt("mm")).slice(2), ["pos", "300", "200"]); + say(0, room, game, "shoot", "301.5", "199", "-40.25", "12"); + assert.deepStrictEqual((await b.nextXt("mm")).slice(2), ["shoot", "301.5", "199", "-40.25", "12"]); + say(0, room, game, "endTurn"); + say(1, room, game, "endTurn"); + assert.deepStrictEqual(await both("endTurn"), []); + say(0, room, game, "shoot", "1%2", "x", "3", "4"); // not numbers: dropped + // the server cannot tell when this game is over (the clients keep the + // score), so the one who stays is told when the other goes. + a.xt("rl", room, room); + assert.deepStrictEqual((await b.nextXt("ml")).slice(1), [room, ann.id]); + b.xt("rl", room, room); + } + + // --- a player who logs off takes their invitation with them + a.xt("mp", ann.roomId, GAMES.marbles, 0, "Ben"); + await b.untilXt("mp"); + a.socket.destroy(); + assert.deepStrictEqual((await b.untilXt("mp")).slice(2), ["101", "1"]); + + b.socket.destroy(); + c.socket.destroy(); +}; + +harness.withServer("buddy games test", HTTP_PORT, GAME_PORT, run).catch(err => { + console.error(err); + process.exit(1); +}); diff --git a/test/features.js b/test/features.js new file mode 100644 index 0000000..65a5b84 --- /dev/null +++ b/test/features.js @@ -0,0 +1,666 @@ +"use strict"; + +// end-to-end check of what smoke.js does not cover: achievements, the +// currency exchange, pets' characters, Adopt-A-Pet, gifts in the lands, +// parties, Jam-A-Grams, Jammer Walls, reports, blocking, chat commands and +// the admin panel's pages for them. three simulated players, a real server. + +const assert = require("assert"); +const harness = require("./harness.js"); + +const HTTP_PORT = 18081; +const GAME_PORT = 19340; +const BASE = `http://127.0.0.1:${HTTP_PORT}`; +const TOWNSHIP = "jamaa_township.room_main#1"; +const {postJson} = harness; + +const say = (client, roomId, text) => + client.send(``); + +// registers nothing: logs an existing account in and walks it into Jamaa +// Township. returns {client, login, roomId}. +const arrive = async (username, password) => { + const auth = await (await postJson(`${BASE}/authenticate`, {username, password})).json(); + const client = new harness.GameClient(GAME_PORT); + await client.connect(); + const login = await client.logIn(username, auth.auth_token); + assert.strictEqual(login.status, "1"); + client.xt("rj", 1, TOWNSHIP, 1, 0, 0); + const roomId = (await client.untilXt("rj"))[4]; + await client.untilXt("rp"); + client.xt("au", roomId, 1, 400, 400, 14, 1); + return {client, login, roomId}; +}; + +// DenXtCommManager.denItemsResponse as [{inv, def, placed}], nine fields an item. +const denItems = fields => { + const items = []; + for (let i = 5; i < fields.length; i += 9) { + items.push({inv: fields[i], def: fields[i + 1], placed: fields[i + 2]}); + } + return items; +}; + +const wall = async body => (await postJson(`${BASE}/wall`, body)).json(); + +const run = async () => { + const registerJson = body => fetch(`${BASE}/api/register`, {method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({avatarType: 1, agreed: true, ...body})}); + for (const username of ["Ann", "Ben", "Cat"]) { + assert.strictEqual((await registerJson({username, password: "Password01"})).status, 200); + } + + // --- the admin panel's message of the day reaches a player once their first room has loaded + const panel = async (pathname, body, cookie) => { + const response = await fetch(`${BASE}/admin/api/${pathname}`, { + method: body === undefined ? "GET" : "POST", + headers: {"Content-Type": "application/json", ...(cookie ? {Cookie: cookie} : {})}, + body: body === undefined ? undefined : JSON.stringify(body), + }); + return {status: response.status, data: await response.json(), cookie: (response.headers.get("set-cookie") || "").split(";")[0]}; + }; + const admin = (await panel("setup", {password: "admin-password-1"})).cookie; + assert.strictEqual((await panel("motd", {text: "Welcome to the test server"}, admin)).status, 200); + assert.strictEqual((await panel("messages", undefined, admin)).data.motd, "Welcome to the test server"); + + const {client: a, login: annLogin, roomId} = await arrive("Ann", "Password01"); + // "ua": the text sits where a room id usually does, then 1 = system message. + assert.deepStrictEqual((await a.untilXt("ua")).slice(1), ["Welcome to the test server", "1"]); + assert.strictEqual((await panel("motd", {text: ""}, admin)).status, 200); + + // every account says it is two days old: a newer one gets a cut-down party list. + assert.ok(Math.abs(Date.now() / 1000 - 2 * 86400 - annLogin.params.createdAt) < 60); + // the phrase menus are not empty (the Jam-A-Gram window reads the first of list 66). + a.xt("gl", roomId, 66); + assert.deepStrictEqual((await a.nextXt("gl")).slice(8, 10), ["15", "1759"]); + // walls are switched on, and each day's first login finds an Adopt-A-Pet. + assert.strictEqual(annLogin.params.webWallStatus, 1); + assert.strictEqual(annLogin.params.usableAdoptAPetDefs.length, 1); + assert.strictEqual(annLogin.params.usableAdoptAPetDefs[0].hasSeen, false); + a.xt("padc", roomId, "Ann"); + assert.deepStrictEqual((await a.nextXt("padc")).slice(2), ["1"]); + a.xt("pad", roomId, "Ann"); + assert.deepStrictEqual((await a.nextXt("pad")).slice(2), ["1", "1", String(annLogin.params.usableAdoptAPetDefs[0].defId), String(annLogin.params.usableAdoptAPetDefs[0].invId)]); + + const {client: b, login: benLogin} = await arrive("Ben", "Password01"); + await a.untilXt("ac"); + await a.nextXt("il"); + + // --- a shop's title is its room's name, as the id of the string that says so + b.xt("rj", roomId, "jamaa_township.clothes_shop#1", 1, 0, 0); + const shopRoom = await b.untilXt("rj"); + assert.strictEqual(shopRoom[14], "Jam Mart Clothing"); + await b.nextXt("rp"); + b.xt("gl", shopRoom[4], 11); // the tables in that room open list 11 + const titled = await b.nextXt("gl"); + assert.deepStrictEqual(titled.slice(3, 5), ["1000", "389"]); // string 389: "Jam Mart Clothing" + b.xt("gl", shopRoom[4], 5); // a shop that is not in this room keeps its own title + assert.strictEqual((await b.nextXt("gl"))[4], ""); + b.xt("rj", shopRoom[4], TOWNSHIP, 1, 0, 0); + await b.untilXt("rj"); + await b.nextXt("rp"); + await b.nextXt("ac"); + await b.nextXt("il"); + b.xt("au", roomId, 1, 420, 400, 14, 1); + await a.untilXt("ar"); + await a.untilXt("ac"); + await a.nextXt("il"); + + // --- minigames: which game is which, a game in a window over the room, gems, a full-screen game + a.xt("mi", roomId, 15, 4, 999999); + const gameInfo = await a.nextXt("mi"); + // 19 fields a game. 15 is the popcorn machine, in a window (type 0). + assert.deepStrictEqual([gameInfo[2], gameInfo.length, gameInfo[3], gameInfo[6], gameInfo[10]], ["3", 3 + 3 * 19, "15", "MicroPopcorn", "0"]); + assert.deepStrictEqual([gameInfo[22], gameInfo[25], gameInfo[29], gameInfo[31]], ["4", "Pachinko", "1", "16"]); // gem Ball: full screen, counts in var 16 + assert.strictEqual(gameInfo[39], "4295"); // its picture in the Games window + // an id nobody knows still gets an entry (a room draws no game signs unless + // it hears about all of them), with a name the client can look up. + assert.strictEqual(gameInfo[41], "999999"); + assert.ok(Number(gameInfo[42]) > 0); + // the HUD's Games window: game def ids, each with a picture, none of the unfinished ones. + a.xt("gl", roomId, 341); + const library = (await a.nextXt("gl")).slice(9); + assert.ok(library.includes("4") && library.includes("94") && !library.includes("62") && library.length > 15); + // phantom Invasion: 10 gems a go, and the prize a win would bring is named up front. + a.xt("mj", roomId, 72, 0, 0, -1); + const invasionRoom = (await a.nextXt("rj"))[4]; + await a.untilXt("ms"); + a.xt("mm", invasionRoom, 72, "cp"); + assert.strictEqual((await a.nextXt("cu"))[2], "0"); // gems + const go = await a.nextXt("mm"); + assert.deepStrictEqual([go[2], go[3], go[5]], ["cp", "1", "1"]); + const [serialNo, prizeDef] = [Number(go[4]), go[6]]; + assert.ok(serialNo > 0 && Number(prizeDef) > 0); + const uidNow = annLogin.params.userId; + a.xt("mm", invasionRoom, 72, "cd", 11 * 5 + (uidNow + 99) * 3 + (serialNo + 49) * 5, (serialNo + uidNow + 11) * 3 + 11 * 3); + assert.ok(denItems(await a.untilXt("di")).some(item => item.def === prizeDef)); // kept: it is in the den inventory + a.xt("rl", invasionRoom, invasionRoom); + a.xt("mj", roomId, 15, 0, 0, -1); + const subRoom = await a.nextXt("rj"); + assert.deepStrictEqual([subRoom[2], subRoom[10], subRoom[12], subRoom[13]], ["1", "1", "1", "1"]); // a game room, temporary, beside the room + const gemSerial = Number((await a.nextXt("mg"))[2]); + await a.nextXt("ma"); + assert.deepStrictEqual((await a.nextXt("mj")).slice(1), [subRoom[4], String(annLogin.params.userId)]); + assert.deepStrictEqual((await a.nextXt("ms")).slice(1), [subRoom[4], "1", String(annLogin.params.userId), String(annLogin.params.dbUserId), "Ann"]); + // 25 gems, signed the way MinigameManager.sendGemAward signs them. + const uid = annLogin.params.userId; + a.xt("mg", subRoom[4], (25 + 29) * 7 + (uid + 99) * 3 + (gemSerial + 49) * 5, (15 + 49) * 3 + (gemSerial + 83) * 5, (gemSerial + uid + 25) * 3 + 25 * 3); + const nextSerial = Number((await a.nextXt("mg"))[2]); + a.xt("mg", subRoom[4], 1, 2, 3); // not signed: no gems + await a.nextXt("mg"); + assert.ok(nextSerial > 0); + a.xt("rl", subRoom[4], subRoom[4]); + a.xt("mj", roomId, 4, 0, 0, -1); // gem Ball takes the room's place + const gameRoom = await a.nextXt("rj"); + assert.deepStrictEqual([gameRoom[10], gameRoom[13]], ["1", "0"]); + await a.nextXt("mg"); + await a.nextXt("ma"); + await a.nextXt("mj"); + await a.nextXt("ms"); + assert.deepStrictEqual((await b.untilXt("ar")).slice(2), [String(annLogin.params.userId)]); // gone from the township meanwhile + a.xt("zs", gameRoom[4], 16, 1, 1); // "one more game played", twice: a counter, not a value + await a.nextXt("zs"); + a.xt("zs", gameRoom[4], 16, 1, 1); + assert.deepStrictEqual((await a.nextXt("zs")).slice(2, 4), ["16", "2"]); + a.xt("mj", gameRoom[4], 62, 0, 0, -1); // a game that needs more than is here yet + assert.deepStrictEqual((await a.nextXt("mj")).slice(2), ["as", "0"]); + assert.match((await a.nextXt("ua"))[1], /not ready/); + a.xt("rj", gameRoom[4], TOWNSHIP, 1, 0, 0); // and back + await a.untilXt("rj"); + await a.nextXt("rp"); + await a.nextXt("ac"); + await a.nextXt("il"); + a.xt("au", roomId, 1, 400, 400, 14, 1); + await b.untilXt("ac"); + await b.nextXt("il"); + + // --- name tags: the colour and badge go with a colour change, reach the room, and stay + a.xt("gl", roomId, 110); + const badges = await a.nextXt("gl"); + assert.deepStrictEqual([badges[3], badges[8], badges[9], badges[70]], ["1049", "75", "1", "62"]); // every badge, in id order: the game's 62 and the thirteen the admin gives + const tag = 6 | 11 << 8; // colour 6, the twelfth badge + a.xt("ap", roomId, 1, 2, 3, tag); + assert.deepStrictEqual((await a.nextXt("ap")).slice(2), ["1"]); + assert.deepStrictEqual((await b.untilXt("an")).slice(2), [String(annLogin.params.userId), String(tag)]); + a.xt("ap", roomId, 1, 2, 3, 6 | 200 << 8); // no such badge: the colours change, the tag stays + await a.nextXt("ap"); + b.xt("ag", roomId, "Ann"); + assert.strictEqual((await b.untilXt("ag"))[10], String(tag)); + + // --- the currency exchange: 1 diamond for 1,000 gems (def 4, at counter 169) + a.xt("gl", roomId, 169); + const exchange = await a.nextXt("gl"); + assert.deepStrictEqual([exchange[3], ...exchange.slice(8)], ["1051", "4", "4", "5", "6", "7"]); + a.xt("ce", roomId, 169, 4); + assert.deepStrictEqual((await a.nextXt("cu")).slice(2), ["0", String(annLogin.params.gemsCount + 1015), "0"]); // 25 won, 10 spent on Phantom Invasion + assert.deepStrictEqual((await a.nextXt("ce")).slice(2), ["1", String(annLogin.params.diamondsCount - 1)]); + // 1,000 gems earned (25 in the game, 1,000 here) is an achievement (def 1); the counter came on its own. + assert.ok(a.varUpdates.some(update => update[2] === "1" && update[3] === "1025" && update[4] === "1" && update[6] === "1")); + a.xt("ce", roomId, 5, 4); // not an exchange counter + assert.deepStrictEqual((await a.nextXt("ce")).slice(2), ["0", "0"]); + + // --- pets have a personality and favourites; mastery has to be earned + a.xt("pc", roomId, 312, 1, 0, 0, 15386, 15428, 0); + const petInv = (await a.nextXt("pc"))[5]; + a.xt("pl", roomId, "Ann"); + const petList = await a.nextXt("pl"); + const [mastery, personality, toy, food] = petList.slice(11, 15).map(Number); + assert.strictEqual(mastery, 0); + assert.ok(personality >= 25865 && personality <= 25932 && toy > 0 && food > 0); + await a.nextXt("pu"); + // the kitten's foods (list 439) are the first ten in the pack, starting with hamburgers. + a.xt("gl", roomId, 439); + const foods = await a.nextXt("gl"); + assert.deepStrictEqual([foods[3], foods[8], foods[9], foods[10]], ["1062", "10", "1", "25933"]); + assert.ok(foods.slice(9).filter((_, i) => i % 2 === 0).includes(String(food))); + a.xt("gl", roomId, 432); + assert.deepStrictEqual((await a.nextXt("gl")).slice(8, 10), ["68", "25865"]); + a.xt("pm", roomId, 1, petInv); + assert.deepStrictEqual((await a.nextXt("pm")).slice(2), ["0"]); + + // --- gifts lying about in the lands: one per spot, the next one after it is taken + a.xt("gl", roomId, 583); + const spots = await a.nextXt("gl"); + assert.deepStrictEqual([spots[3], spots[8]], ["1064", "3"]); + a.xt("wig", roomId, spots[9], 0, 0); + assert.strictEqual((await a.untilXt("wig"))[2], "1"); + a.xt("wig", roomId, spots[9], 0, 0); // only once + assert.strictEqual((await a.untilXt("wig"))[2], "0"); + a.xt("gl", roomId, 583); + const spotsAfter = await a.untilXt("gl"); + assert.ok(spotsAfter[8] === "3" && !spotsAfter.slice(9).includes(spots[9])); + + // --- parties: the game's own, always open + a.xt("sl", roomId); + const partyList = await a.nextXt("sl"); + assert.ok(Number(partyList[3]) > 20 && partyList[5] === "0" && Number(partyList[3]) * 3 === partyList.length - 4); + a.xt("sj", roomId, partyList[4]); + const partyJoin = await a.nextXt("rj"); + assert.deepStrictEqual(partyJoin.slice(2, 4), ["1", `party${partyList[4]}`]); + const partyRoom = await a.nextXt("rp"); + assert.deepStrictEqual([partyRoom[2].split(".")[0], partyRoom[4], partyRoom[5]], ["party", "5", partyList[4]]); + a.xt("sj", partyJoin[4], 4); // bunnies only, and Ann is not one + assert.deepStrictEqual((await a.nextXt("sj")).slice(2), ["0", "NA", "4"]); + + // --- parties put back: the Trading Party in the trading barn, and two rooms no party used + const offered = partyList.slice(4).filter((field, index) => index % 3 === 0); + assert.ok(["6", "52", "53"].every(id => offered.includes(id)) && !offered.includes("3")); + a.xt("sj", partyJoin[4], 6); + assert.deepStrictEqual((await a.nextXt("rj")).slice(3, 4), ["party6"]); + assert.strictEqual((await a.nextXt("rp"))[2], "party.venue_pl_barn_trading"); + + // --- the Summer Carnival: gone from the official room list, back in ours; its games pay in tickets + assert.ok(partyList.slice(4).filter((field, index) => index % 3 === 0).includes("18")); + a.xt("sj", partyJoin[4], 18); + const carnival = await a.nextXt("rj"); + assert.deepStrictEqual(carnival.slice(2, 4), ["1", "party18"]); + assert.strictEqual((await a.nextXt("rp"))[2], "party.venue_carnival"); + // its shops sell what is priced in tickets: 76 pieces of clothing at the first. + a.xt("gl", carnival[4], 101); + const ticketClothes = await a.nextXt("gl"); + assert.deepStrictEqual([ticketClothes[3], ticketClothes[8]], ["1000", "76"]); + a.xt("mi", carnival[4], 68, 96); + const booths = await a.nextXt("mi"); + assert.deepStrictEqual([booths[6], booths[25]], ["Skeeball", "DunkAPhantom"]); + a.xt("mj", carnival[4], 68, 0, 0, -1); + const booth = (await a.nextXt("rj"))[4]; + await a.untilXt("ms"); + // "pz" and "pg" each bring a serial number, hidden as (n + 5) * 3 - 7. + const shown = async word => { + const message = await a.nextXt("mm"); + assert.strictEqual(message[2], word); + return message; + }; + const serial1 = (Number((await shown("pz"))[3]) + 7) / 3 - 5; + a.xt("mm", booth, 68, "pg"); + assert.strictEqual((await a.nextXt("cu"))[2], "0"); // 5 gems a go + const paid = await shown("pg"); + assert.strictEqual(paid[3], "1"); + const serial2 = (Number(paid[4]) + 7) / 3 - 5; + const points = 250; // at 10 points a ticket + a.xt("mm", booth, 68, "gr", (points + 29) * 7 + (serial1 + 49) * 5, (points + 49) * 3 + (serial2 + 83) * 5, (serial1 + points) * 3 + points * 3); + assert.deepStrictEqual((await a.nextXt("cu")).slice(2, 4), ["1", String(annLogin.params.ticketsCount + 25)]); + assert.strictEqual((await shown("gr"))[3], "25"); + a.xt("mm", booth, 68, "gr", 1, 2, 3); // the same go again, and unsigned: nothing + assert.strictEqual((await shown("gr"))[3], "0"); + a.xt("rj", booth, "party18", 1, 0, 0); // back out of the game + assert.strictEqual((await a.untilXt("rj"))[3], "party18"); + await a.nextXt("rp"); + + // --- sale dates: a window comes round each year (lib/sales.js) + const sales = require("../lib/sales.js"); + const day = (year, month, date) => Date.UTC(year, month - 1, date) / 86400000; + const at = (year, month, date) => Date.UTC(year, month - 1, date, 12) / 1000; + const october = [[day(2023, 10, 1), day(2023, 11, 11)], [day(2024, 10, 5), day(2024, 11, 11)]]; + assert.deepStrictEqual(sales.windowFor(october, at(2030, 10, 20)), [at(2030, 10, 1) - 43200, at(2030, 11, 11) - 43200]); // on sale now + assert.deepStrictEqual(sales.windowFor(october, at(2030, 3, 1))[0], at(2030, 10, 1) - 43200); // waiting for the next one + assert.deepStrictEqual(sales.windowFor([[day(2018, 1, 1), day(2019, 2, 1)]], at(2030, 3, 1)), [0, 0]); // sold all year round: always + assert.strictEqual(sales.windowFor(undefined, at(2030, 3, 1)), null); + + // --- a party of Ann's own: the lists its window needs, then hosting it + a.xt("gl", partyJoin[4], 370); + const hostable = await a.nextXt("gl"); + assert.ok(hostable[3] === "1047" && Number(hostable[8]) >= 5); + a.xt("gl", partyJoin[4], 401); + const music = await a.nextXt("gl"); + assert.ok(music[3] === "1030" && Number(music[8]) > 10); + a.xt("gl", partyJoin[4], 386); + assert.deepStrictEqual((await a.nextXt("gl")).slice(8, 10), ["26", "24135"]); + a.xt("scp", partyJoin[4], hostable[9], 24135, 24162, 1, music[9]); // 1 is not a name + assert.deepStrictEqual((await a.nextXt("scp")).slice(2), ["0", "INV"]); + a.xt("scp", partyJoin[4], hostable[9], 24135, 24162, 24186, music[9]); + assert.deepStrictEqual((await a.nextXt("cu")).slice(2, 4), ["3", String(annLogin.params.diamondsCount - 2)]); + const hosting = await a.nextXt("scp"); + assert.deepStrictEqual(hosting.slice(2, 4), ["1", "1"]); + assert.ok(Number(hosting[4]) > 7000); + const own = await a.nextXt("rj"); + // the party's name is three string ids; its music is in the join message. + assert.deepStrictEqual([own[3], own[14], own[19]], ["ppartyAnn", "24135|24162|24186", music[9]]); + await a.nextXt("rp"); + assert.strictEqual((await a.nextXt("sjp"))[2], "1"); + a.xt("au", own[4], 1, 400, 400, 14, 1); + a.xt("scp", own[4], hostable[9], 24135, 24162, 24186, music[9]); + assert.deepStrictEqual((await a.nextXt("scp")).slice(2), ["0", "EXISTS"]); + + b.xt("slp", 1, 0, 200); + const hostedList = await b.untilXt("slp"); + assert.deepStrictEqual(hostedList.slice(2, 3).concat(hostedList.slice(6, 11)), ["1", "1", annLogin.params.uuid, "24135|24162|24186", "127.0.0.1", hostable[9]]); + b.xt("sphp", 1, annLogin.params.uuid); + assert.ok(Number((await b.nextXt("sphp"))[2]) > 7000); + b.xt("spn", 1, annLogin.params.uuid); + assert.deepStrictEqual((await b.nextXt("spn")).slice(2), ["1", annLogin.params.uuid, "127.0.0.1"]); + b.xt("sjp", 1, annLogin.params.uuid); + assert.deepStrictEqual((await b.nextXt("rj")).slice(2, 4), ["1", "ppartyAnn"]); + await b.nextXt("rp"); + await b.nextXt("ac"); // Ann, already there + await b.nextXt("il"); + assert.strictEqual((await b.nextXt("sjp"))[2], "1"); + b.xt("au", own[4], 1, 420, 420, 14, 1); + await a.untilXt("ac"); + await a.nextXt("il"); + + // --- chat commands: answered in a popup, never shown to the room + say(a, own[4], "!online"); + assert.deepStrictEqual((await a.nextXt("xtl")).slice(2), ["2 playing: Ann, Ben"]); // a plain message box + assert.strictEqual((await a.nextXt("uc"))[3], "!online"); // the sender's own bubble + say(a, own[4], "!!! wow"); + assert.strictEqual((await b.untilXt("uc"))[3], "!!! wow"); // not a command: just chat + await a.nextXt("uc"); + say(a, own[4], "!roll"); + assert.match((await b.nextXt("uc"))[3], /^\(rolls a dice: [1-6]\)$/); + await a.nextXt("uc"); + + // --- outfits: what the animal wears, saved and put back on + a.xt("gl", own[4], 5); + const shop = await a.nextXt("gl"); + a.xt("ib", own[4], 5, 1, shop[9], 0, 0, -1, ""); + const hat = (await a.nextXt("il"))[9]; + await a.nextXt("ib"); + a.xt("iu", own[4], 1, 0, hat); + await a.nextXt("iu"); + await a.nextXt("il"); + await b.untilXt("il"); + say(a, own[4], "!outfit save hat"); + assert.strictEqual((await a.nextXt("xtl"))[2], "Outfit hat saved (1 items)."); + await a.nextXt("uc"); + a.xt("iu", own[4], 0, 1, hat); + await a.nextXt("iu"); + const off = await a.nextXt("il"); // her own game hears it too + assert.deepStrictEqual([off[2], off[7], off[8], off[9]], ["3", "0", "1", hat]); + assert.strictEqual((await b.nextXt("il"))[8], "0"); // ben sees it come off + say(a, own[4], "!outfit wear hat"); + // "3": what is worn changed, [.., onCount, offCount, (inv, def)...] + const worn = await a.nextXt("il"); + assert.deepStrictEqual([worn[2], worn[7], worn[8], worn[9]], ["3", "1", "0", hat]); + assert.strictEqual((await a.nextXt("xtl"))[2], "Wearing hat."); + await a.nextXt("uc"); + assert.deepStrictEqual((await b.nextXt("il")).slice(8, 10), ["1", shop[9]]); // and back on + + // --- Jam-A-Grams: a card, a stamp, typed words and the hat as a gift + a.xt("gl", own[4], 10); + const cards = await a.nextXt("gl"); + assert.ok(cards[3] === "1033" && Number(cards[8]) > 100 && cards[9] === "1"); + a.xt("gl", own[4], 44); + const stamps = await a.nextXt("gl"); + a.xt("es", own[4], "Ben", cards[9], 9999, 2, "hello", 0, 0, 0); // no such stamp + assert.deepStrictEqual((await a.nextXt("es")).slice(2), ["0"]); + a.xt("es", own[4], "Ben", cards[9], stamps[9], 2, "A hat for you!", 1, hat, 0); + // the hat leaves Ann's inventory with the card. + const sent = await a.nextXt("il"); + assert.deepStrictEqual([sent[2], sent[7], sent[8], sent[9]], ["2", "0", "1", hat]); + assert.deepStrictEqual((await a.nextXt("es")).slice(2), ["1"]); + const pushed = await b.untilXt("ep"); + assert.deepStrictEqual(pushed.slice(3, 10), ["Ann", cards[9], stamps[9], "0", "A hat for you!", "1", shop[9]]); + b.xt("el", own[4], 0); + const inbox = await b.nextXt("el"); + assert.deepStrictEqual([inbox[2], inbox.length], ["1", 3 + 17]); + b.xt("er", own[4], pushed[2]); + assert.deepStrictEqual((await b.nextXt("er")).slice(2), [pushed[2], "1"]); + b.xt("eg", own[4], pushed[2], 1); + assert.deepStrictEqual((await b.nextXt("il")).slice(2, 3).concat((await b.nextXt("eg")).slice(2)), ["2", pushed[2], "1"]); + b.xt("eg", own[4], pushed[2], 1); // the gift is taken only once + assert.deepStrictEqual((await b.nextXt("eg")).slice(2), [pushed[2], "0"]); + b.xt("ed", own[4], pushed[2]); + assert.deepStrictEqual((await b.nextXt("ed")).slice(2), ["1", "1", pushed[2]]); + b.xt("ei", own[4], 2); // ben takes Jam-A-Grams from nobody now + assert.deepStrictEqual((await b.nextXt("ei")).slice(2), ["1"]); + a.xt("es", own[4], "Ben", cards[9], stamps[9], 2, "again", 0, 0, 0); + assert.deepStrictEqual((await a.nextXt("es")).slice(2), ["-2"]); + b.xt("ei", own[4], 0); + await b.nextXt("ei"); + + // A secret valentine: the receiver is not told who sent it, the server knows. + a.xt("es", own[4], "Ben", cards[9], stamps[9], 2, "GUESS WHO", 0, 0, 1); + assert.deepStrictEqual((await a.nextXt("es")).slice(2), ["1"]); + const valentine = await b.nextXt("ep"); + assert.deepStrictEqual([valentine[3], valentine[7], valentine[18]], ["", "GUESS WHO", "1"]); // no name; special type 1 + b.xt("fr", own[4], "Secret Valentine", 14); // reported under the name the game shows + assert.deepStrictEqual((await b.nextXt("fr")).slice(2), ["1"]); + const aboutValentine = (await panel("reports", undefined, admin)).data.reports; + assert.deepStrictEqual([aboutValentine[0].reporter, aboutValentine[0].target, aboutValentine[0].reason], ["Ben", "Ann", "Inappropriate Jam-A-Gram"]); + await panel("report", {id: aboutValentine[0].id}, admin); + b.xt("ed", own[4], valentine[2]); + await b.nextXt("ed"); + + // --- Jammer Walls: the wallpapers a wall cannot be drawn without, and their buttons + a.xt("gl", own[4], 314); + const wallpapers = await a.nextXt("gl"); + a.xt("gl", own[4], 313); + const wallpaperButtons = await a.nextXt("gl"); + assert.ok(wallpapers[3] === "1033" && Number(wallpapers[8]) > 19 && wallpapers[8] === wallpaperButtons[8]); // 19: a new wall's wallpaper + a.xt("gl", own[4], 646); + assert.ok(Number((await a.nextXt("gl"))[8]) > 10); + a.xt("dmi", own[4], "Ben"); // masterpieces hung on the wall: none, but it waits to hear + assert.deepStrictEqual((await a.nextXt("dmi")).slice(2), ["0"]); + a.xt("crg", own[4], "jammerwall", benLogin.params.uuid, annLogin.params.uuid, "report"); + assert.deepStrictEqual((await a.nextXt("crg")).slice(2), ["1", "0", "0"]); // found, not liked by me, no likes + a.xt("crp", own[4], "jammerwall", benLogin.params.uuid, annLogin.params.uuid); + assert.deepStrictEqual((await a.nextXt("crp")).slice(2), ["1"]); + a.xt("crp", own[4], "jammerwall", benLogin.params.uuid, annLogin.params.uuid); // one like each + assert.deepStrictEqual((await a.nextXt("crp")).slice(2), ["0"]); + b.xt("crg", own[4], "jammerwall", benLogin.params.uuid, benLogin.params.uuid, "report"); + assert.deepStrictEqual((await b.nextXt("crg")).slice(2), ["1", "0", "1"]); + + // --- Jammer Walls: a token over the socket, then JSON over HTTP + a.xt("wsg", own[4], "Ben"); + assert.deepStrictEqual((await a.nextXt("wsg")).slice(2), ["2"]); // open to everyone + a.xt("wt", own[4], "Ben"); + const token = await a.nextXt("wt"); + assert.deepStrictEqual([token[2], token[4], token[5], token[6]], ["1", "1", "1", "Ben"]); + assert.deepStrictEqual(await wall({cmd: "GET", t: "nonsense"}), {s: false, e: "token"}); + const before = await wall({cmd: "GET", t: token[3]}); + assert.deepStrictEqual([before.s, before.r, before.p.bg, before.p.visits], [true, [], "19", 0]); + const put = await wall({cmd: "PUT", t: token[3], m: "Nice wall, Ben!", s: 2, c: 3, ai: 1, ac: [1, 2, 3], ae: 4, ap: 5, l: 0, aci: -1, sid: 999}); + assert.strictEqual(put.PUT.s, true); + assert.deepStrictEqual([put.GET.r.length, put.GET.r[0].m, put.GET.r[0].un, put.GET.r[0].uid, put.GET.r[0].x], [1, "Nice wall, Ben!", "Ann", annLogin.params.dbUserId, put.x]); + assert.strictEqual((await wall({cmd: "CHK", t: token[3]})).t, put.t); + a.xt("wci", own[4], "Ben"); + assert.deepStrictEqual((await a.nextXt("wci")).slice(2), ["1"]); + b.xt("wt", own[4], "Ben"); + const ownToken = (await b.nextXt("wt"))[3]; + b.xt("wps", own[4], JSON.stringify({bg: "7", tag: "hello there", visits: 5000})); + assert.deepStrictEqual((await b.nextXt("wps")).slice(2), ["1"]); + const mine = await wall({cmd: "GET", t: ownToken}); + assert.deepStrictEqual([mine.p.bg, mine.p.tag, mine.p.visits, mine.r.length], ["7", "hello there", 1, 1]); // visits are not the owner's to set + assert.deepStrictEqual(await wall({cmd: "CLW", t: token[3]}), {s: false}); // only the owner clears a wall + assert.deepStrictEqual(await wall({cmd: "DEL", t: ownToken, x: put.x}), {s: true}); + assert.strictEqual((await wall({cmd: "GET", t: ownToken})).r.length, 0); + b.xt("wss", own[4], 0); // locked + assert.deepStrictEqual((await b.nextXt("wss")).slice(2), ["1"]); + assert.deepStrictEqual(await wall({cmd: "GET", t: token[3]}), {s: false, e: "token"}); + a.xt("wt", own[4], "Ben"); + assert.deepStrictEqual((await a.nextXt("wt")).slice(2), ["-1"]); + b.xt("wss", own[4], 2); + await b.nextXt("wss"); + + // --- reports: the reason, what was typed, and what the reported player had been saying + say(b, own[4], "something rude"); + await b.nextXt("uc"); + await a.untilXt("uc"); + a.xt("xrd", own[4], "Ben", 2, "He keeps saying rude things in my party"); + a.xt("fr", own[4], "Ben", 2); + assert.deepStrictEqual((await a.nextXt("fr")).slice(2), ["1"]); + const waiting = (await panel("reports", undefined, admin)).data; + assert.strictEqual(waiting.open, 1); + assert.strictEqual(waiting.reports.length, 1); + assert.deepStrictEqual([waiting.reports[0].reporter, waiting.reports[0].target, waiting.reports[0].reason, waiting.reports[0].detail, waiting.reports[0].room], + ["Ann", "Ben", "Bad words", "He keeps saying rude things in my party", "ppartyAnn"]); + assert.match(waiting.reports[0].context, /something rude/); + assert.strictEqual((await panel("overview", undefined, admin)).data.stats.reports, 1); + assert.strictEqual((await panel("report", {id: waiting.reports[0].id}, admin)).status, 200); + assert.strictEqual((await panel("reports", undefined, admin)).data.open, 0); + assert.strictEqual((await panel("reports?handled=1", undefined, admin)).data.reports.length, 2); // this one and the valentine + + // --- blocking: no chat from them, out of my party and my den, and out of sight if I say so + a.xt("bb", own[4], "Ben"); + assert.deepStrictEqual((await a.nextXt("bb")).slice(2), ["Ben", "1"]); + // ben is sent back to the township: a room change he did not ask for. + const sentHome = await b.untilXt("rj"); + assert.deepStrictEqual(sentHome.slice(2, 4), ["1", TOWNSHIP]); + const home = sentHome[4]; // the township emptied meanwhile, so it is a new room + await b.nextXt("rp"); + assert.deepStrictEqual((await a.nextXt("ar")).slice(2), [String(benLogin.params.userId)]); + b.xt("au", home, 1, 300, 300, 14, 1); + b.xt("sjp", home, annLogin.params.uuid); + assert.deepStrictEqual((await b.nextXt("sjp")).slice(2), ["0", "BLK"]); + b.xt("slp", home, 0, 200); + assert.deepStrictEqual((await b.nextXt("slp")).slice(2, 4), ["1", "0"]); // nor is it listed for him + b.xt("dj", home, "denAnn", 1, -1); + assert.strictEqual((await b.nextXt("rj"))[2], "0"); + b.xt("wt", home, "Ann"); + assert.deepStrictEqual((await b.nextXt("wt")).slice(2), ["-1"]); + + a.xt("rj", own[4], TOWNSHIP, 1, 0, 0); + await a.untilXt("rj"); + await a.nextXt("rp"); + await a.nextXt("ac"); // ben is drawn: blocked, but not hidden yet + await a.nextXt("il"); + a.xt("au", home, 1, 500, 500, 14, 1); + await b.untilXt("ac"); + await b.nextXt("il"); + say(b, home, "can you hear me"); + await b.nextXt("uc"); + say(a, home, "hello"); + assert.strictEqual((await a.nextXt("uc"))[3], "hello"); // ben's line never came + assert.strictEqual((await b.nextXt("uc"))[3], "hello"); // though he still hears Ann + say(a, home, "!hideblocked on"); + assert.deepStrictEqual((await a.nextXt("ar")).slice(2), [String(benLogin.params.userId)]); + assert.strictEqual((await a.nextXt("xtl"))[2], "Players you have blocked are now hidden from you."); + await a.nextXt("uc"); + b.xt("au", home, 2, 310, 310, 320, 320, 14, 0); // ben walks about: nothing for Ann + a.xt("zg", home); + const vars = await a.nextXt("zg"); + assert.strictEqual(vars[vars.indexOf("9001", 3) + 2], "1"); + a.xt("zs", home, 9001, 0, 1); // the settings window's switch, off again + assert.deepStrictEqual((await a.nextXt("ac")).slice(2, 3), [String(benLogin.params.userId)]); + await a.nextXt("il"); + assert.deepStrictEqual((await a.nextXt("zs")).slice(2), ["9001", "0", "0"]); + a.xt("bu", home, "Ben"); + assert.deepStrictEqual((await a.nextXt("bu")).slice(2), ["Ben", "1"]); + + // blocking someone standing in my den puts them outside, with the game's own notice. + b.xt("dj", home, "denAnn", 1, -1); + const denId = (await b.untilXt("rj"))[4]; + await b.nextXt("rp"); + await b.nextXt("ds"); + a.xt("bb", home, "Ben"); + await a.untilXt("bb"); + await b.nextXt("dpk"); + assert.deepStrictEqual((await b.nextXt("rj")).slice(2, 4), ["1", TOWNSHIP]); + await b.nextXt("rp"); + a.xt("bu", home, "Ben"); + await a.untilXt("bu"); + + // --- den layouts: save, clear, load; and copying a den one stands in + a.xt("dj", home, "denAnn", 1, -1); + const annDen = (await a.untilXt("rj"))[4]; + await a.nextXt("rp"); + await a.nextXt("ds"); + a.xt("au", annDen, 1, 200, 200, 14, 1); + a.xt("gl", annDen, 9); + const denShop = await a.nextXt("gl"); + a.xt("db", annDen, 0, 9, denShop[9], 0, 0, 0, 0, ""); + await a.nextXt("db"); + const chair = denItems(await a.nextXt("di")).find(item => item.def === denShop[9]).inv; + a.xt("ds", annDen, 1, 0, chair, 1, 120, 340, 1, "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + await a.nextXt("dss"); + say(a, annDen, "!den save cosy"); + assert.strictEqual((await a.nextXt("xtl"))[2], "Den layout cosy saved (1 items)."); + await a.nextXt("uc"); + a.xt("de", annDen); + await a.nextXt("de"); + await a.nextXt("di"); + say(a, annDen, "!den load cosy"); + assert.deepStrictEqual(denItems(await a.nextXt("di")).find(item => item.inv === chair), {inv: chair, def: denShop[9], placed: "1"}); // placed again + assert.deepStrictEqual((await a.nextXt("ds")).slice(2, 10), ["1", "0", "0", chair, denShop[9], "1", "120", "340"]); + assert.strictEqual((await a.nextXt("xtl"))[2], "Den layout cosy loaded."); + await a.nextXt("uc"); + + b.xt("dj", home, "denAnn", 1, -1); + await b.untilXt("rj"); + await b.nextXt("rp"); + await b.nextXt("ac"); // Ann, at home + await b.nextXt("il"); + await b.nextXt("ds"); + say(b, annDen, "!den copy"); + const copied = denItems(await b.nextXt("di")); // ben had no such chair: he has one now, placed + assert.deepStrictEqual(copied.map(item => [item.def, item.placed]), [[denShop[9], "1"]]); + assert.strictEqual((await b.nextXt("xtl"))[2], "Your den now looks like this one."); + await b.nextXt("uc"); + + // --- the panel: announcements, gifts, what an account owns, the ban list + const announced = await panel("announce", {text: "Party at Ann's den"}, admin); + assert.deepStrictEqual(announced.data, {ok: "Shown to 1 player."}); // Ann has walked about; Ben has not moved in the den yet + assert.strictEqual((await a.untilXt("ua"))[1], "Party at Ann's den"); + const rooms = (await panel("messages", undefined, admin)).data.rooms; + assert.deepStrictEqual(rooms.find(room => room.name === "denAnn"), {name: "denAnn", title: "Ann's Den", players: 2}); + assert.strictEqual((await panel("announce", {text: "nobody there", room: "no.such#1"}, admin)).data.ok, "Shown to 0 players."); + + // gifts come as Jam-A-Grams from Animal Jam HQ. diamonds: the client is + // told a code was redeemed, asks for its cards and opens a gift popup. + assert.strictEqual((await panel("account", {username: "Ben", action: "gift", kind: "diamonds", amount: 7, text: "7 for you"}, admin)).status, 200); + assert.deepStrictEqual((await b.untilXt("grc")).slice(2), ["1", "", "0"]); + b.xt("el", annDen, 0); // the inbox does not list it + assert.strictEqual((await b.nextXt("el"))[2], "0"); + b.xt("el", annDen, 1); // the popups' request does + const popupCards = await b.nextXt("el"); + // sender, message (not starting with a number), type 9 = diamonds, amount, sender type 2 = opens as a popup + assert.deepStrictEqual([popupCards[2], popupCards[4], popupCards[8], popupCards[9], popupCards[10], popupCards[16]], + ["1", "Burrow HQ", "Gift: 7 for you", "9", "7", "2"]); + b.xt("eg", annDen, popupCards[3], 1); + assert.deepStrictEqual((await b.nextXt("cu")).slice(2), ["3", String(benLogin.params.diamondsCount + 7), "0"]); + assert.deepStrictEqual((await b.nextXt("eg")).slice(2), [popupCards[3], "1"]); + b.xt("el", annDen, 1); + assert.strictEqual((await b.nextXt("el"))[2], "0"); // answered, so gone + // an item waits in the inbox, from "the voice": the name is string 15964, "Animal Jam HQ". + assert.strictEqual((await panel("account", {username: "Ben", action: "gift", kind: "den", id: Number(denShop[9])}, admin)).status, 200); + const hqCard = await b.nextXt("ep"); + assert.deepStrictEqual([hqCard[3], hqCard[7], hqCard[8], hqCard[9], hqCard[15]], ["15964", "A gift for you!", "3", denShop[9], "1"]); + b.xt("eg", annDen, hqCard[2], 1); + assert.strictEqual((await b.nextXt("di"))[3], "2"); + assert.deepStrictEqual((await b.nextXt("eg")).slice(2), [hqCard[2], "1"]); + assert.strictEqual((await panel("account", {username: "Ben", action: "gift", kind: "den", id: 99999999}, admin)).status, 400); + assert.strictEqual((await panel("account", {username: "Ben", action: "gift", kind: "tickets", amount: 3}, admin)).status, 200); // no card for tickets + assert.deepStrictEqual((await b.nextXt("cu")).slice(2, 3), ["1"]); + assert.strictEqual((await panel("account", {username: "Ben", action: "gift", kind: "achievement", id: 99}, admin)).status, 200); + assert.strictEqual((await panel("account", {username: "Ben", action: "gift", kind: "achievement", id: 99}, admin)).status, 400); // already has it + assert.match((await panel("account", {username: "Cat", action: "gift", kind: "adopt", id: "all"}, admin)).data.ok, /^Cat has \d+ more/); + + const owned = (await panel("owned?username=Ben", undefined, admin)).data; + assert.deepStrictEqual([owned.animals.length, owned.denItemsTotal, owned.denItems[0].count, owned.clothingTotal, owned.currency.diamonds], + [1, 2, 2, 1, benLogin.params.diamondsCount + 7]); + assert.ok(owned.achievements >= 1 && owned.clothing[0].name.length > 0); + + assert.deepStrictEqual((await panel("bans", undefined, admin)).data.accounts, []); + await panel("account", {username: "Cat", action: "ban", hours: 0}, admin); + await panel("account", {username: "Ben", action: "silence", hours: 1}, admin); + const disciplined = (await panel("bans", undefined, admin)).data.accounts; + assert.deepStrictEqual(disciplined.map(entry => [entry.username, entry.banned, entry.silenced > 1700]), [["Ben", 0, true], ["Cat", -1, false]]); + + // --- the panel's Debug page: into a room nothing leads to, and sale dates off + const debug = (await panel("debug", undefined, admin)).data; + assert.ok(debug.players.includes("Ann") && debug.rooms.length > 400 && debug.everythingOnSale === false); + assert.match(debug.rooms.find(room => room.path === "epic_dens/room_solarcade2").note, /Epic Dens/); + assert.strictEqual((await panel("debug", {action: "teleport", username: "Ann", room: "epic_dens/room_solarcade2"}, admin)).status, 200); + assert.strictEqual((await a.untilXt("rj"))[3].split("#")[0], "epic_dens.room_solarcade2"); + assert.strictEqual((await panel("debug", {action: "teleport", username: "Ann", room: "no/such_room"}, admin)).status, 400); + assert.strictEqual((await panel("debug", {action: "teleport", username: "Cat", room: "jamaa_township/room_main"}, admin)).status, 400); // not playing + // den items out of season have dates in the pack clients get; with the switch on, none do. + const zlib = require("zlib"); + const amf3 = require("../lib/amf3.js"); + const cdn = require("../lib/cdn.js"); + const dated = async pack => Object.values(amf3.decode(zlib.inflateRawSync(Buffer.from( + await (await fetch(`${BASE}/${cdn.hashedPath(`defPacks/${pack}`)}`)).arrayBuffer())))).filter(def => Number(def.availabilityEndTime) > 0).length; + assert.ok(await dated(1030) > 0); + assert.strictEqual((await panel("debug", {action: "everythingOnSale", on: true}, admin)).status, 200); + assert.strictEqual(await dated(1030), 0); + await panel("debug", {action: "everythingOnSale", on: false}, admin); + assert.ok(await dated(1030) > 0); + + a.socket.destroy(); + b.socket.destroy(); +}; + +harness.withServer("feature test", HTTP_PORT, GAME_PORT, run).catch(err => { + console.error(err); + process.exit(1); +}); diff --git a/test/harness.js b/test/harness.js new file mode 100644 index 0000000..7323600 --- /dev/null +++ b/test/harness.js @@ -0,0 +1,173 @@ +"use strict"; + +// what the end-to-end tests share: a game client that speaks the SWF's +// socket protocol, and a real server process on ports and a database of its +// own that is thrown away afterwards. + +const assert = require("assert"); +const {spawn} = require("child_process"); +const fs = require("fs"); +const net = require("net"); +const os = require("os"); +const path = require("path"); + +class GameClient { + constructor(gamePort) { + this.gamePort = gamePort; + this.queue = []; + this.varUpdates = []; + this.askedForGames = 0; + this.unaskedGames = []; + this.waiters = []; + this.buffer = Buffer.alloc(0); + } + + connect() { + return new Promise((resolve, reject) => { + this.socket = net.connect(this.gamePort, "127.0.0.1", resolve); + this.socket.once("error", reject); + this.socket.on("data", chunk => { + this.buffer = Buffer.concat([this.buffer, chunk]); + let end; + while ((end = this.buffer.indexOf(0)) !== -1) { + this.queue.push(this.buffer.toString("utf8", 0, end)); + if (process.env.AJ_TEST_TRACE) { + console.log(`<- ${this.queue[this.queue.length - 1].slice(0, 300)}`); + } + this.buffer = this.buffer.subarray(end + 1); + } + this.flush(); + }); + }); + } + + flush() { + while (this.queue.length && this.waiters.length) { + this.waiters.shift()(this.queue.shift()); + } + } + + send(message) { + if (process.env.AJ_TEST_TRACE) { + console.log(`-> ${message.slice(0, 300)}`); + } + this.socket.write(message + "\0"); + } + + xt(cmd, roomId, ...params) { + if (cmd === "mi") { + this.askedForGames++; + } + this.send(`%xt%o%${[cmd, roomId, ...params].join("%")}%`); + } + + // the server describes the buddy games to a player who has just arrived + // without being asked ("mi"). is this message that, rather than the + // answer to a request of ours? + unasked(fields) { + if (fields[0] !== "mi") { + return false; + } + if (this.askedForGames === 0) { + this.unaskedGames.push(fields); + return true; + } + this.askedForGames--; + return false; + } + + next() { + // made here, not in the timer, so that its stack says which line waited. + const timedOut = new Error("timed out waiting for a server message"); + return new Promise((resolve, reject) => { + const timer = setTimeout(() => reject(timedOut), 5000); + this.waiters.push(message => { + clearTimeout(timer); + resolve(message); + }); + this.flush(); + }); + } + + // next raw extension message as [cmd, roomId, ...params]. user var + // updates ("zs") turn up between other messages whenever a counter the + // server keeps moves; they are set aside in `this.varUpdates` unless asked + // for, and the unasked list of buddy games in `this.unaskedGames`. + async nextXt(cmd) { + for (;;) { + const fields = (await this.next()).split("%").slice(2, -1); + if (fields[0] === "zs" && cmd !== "zs") { + this.varUpdates.push(fields); + continue; + } + if (this.unasked(fields)) { + continue; + } + assert.strictEqual(fields[0], cmd); + return fields; + } + } + + // skips other messages until the next raw extension message for `cmd`. + async untilXt(cmd) { + for (;;) { + const fields = (await this.next()).split("%").slice(2, -1); + if (this.unasked(fields)) { + continue; + } + if (fields[0] === cmd) { + return fields; + } + } + } + + async logIn(username, token) { + this.send(""); + assert.match(await this.next(), /action='apiOK'/); + this.send(""); + assert.match(await this.next(), /[0-9a-f]+<\/k>/); + const nick = `${username}%%0%1830%electron%1.5.7%win%df`; + this.send(``); + return JSON.parse(await this.next()).b.o; + } +} + +const postJson = (url, body) => fetch(url, { + method: "POST", + headers: {"Content-Type": "application/json", "Origin": "null"}, + body: JSON.stringify(body), +}); + +// starts a server on the given ports with an empty database, runs `run` +// against it, and prints `name` passed or the server's output on failure. +const withServer = async (name, httpPort, gamePort, run) => { + const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), "aj-test-")); + const server = spawn(process.execPath, [path.join(__dirname, "..", "server.js")], { + env: {...process.env, AJ_HTTP_PORT: httpPort, AJ_GAME_PORT: gamePort, AJ_DATA_DIR: dataDir, AJ_QUIET: "1"}, + stdio: ["ignore", "pipe", "inherit"], + }); + let output = ""; + try { + await new Promise((resolve, reject) => { + server.stdout.on("data", chunk => { + output += chunk; + if (output.includes("[server] ready")) { + resolve(); + } + }); + server.once("exit", code => reject(new Error(`server exited early (${code})\n${output}`))); + }); + await run(); + console.log(`${name} passed`); + } + catch (err) { + console.error(output); + throw err; + } + finally { + server.kill(); + fs.rmSync(dataDir, {recursive: true, force: true}); + } +}; + +module.exports = {GameClient, postJson, withServer}; diff --git a/test/qol.js b/test/qol.js new file mode 100644 index 0000000..51545d2 --- /dev/null +++ b/test/qol.js @@ -0,0 +1,206 @@ +"use strict"; + +// end-to-end check of the small comforts added on 2026-10-11: bigger +// limits, the newer chat commands, whispers, names typed over, looks per +// room, eggs that hatch at once. simulated players, a real server. + +const assert = require("assert"); +const harness = require("./harness.js"); + +const HTTP_PORT = 18085; +const GAME_PORT = 19344; +const BASE = `http://127.0.0.1:${HTTP_PORT}`; +const TOWNSHIP = "jamaa_township.room_main#1"; +const {postJson} = harness; + +const say = (client, roomId, text) => + client.send(``); +// what a command's message box said. +const told = async client => (await client.untilXt("xtl"))[2]; + +// logs in and asks for the township, as the game always does first. +// returns where the server put them. +const arrive = async username => { + const auth = await (await postJson(`${BASE}/authenticate`, {username, password: "Password01"})).json(); + const client = new harness.GameClient(GAME_PORT); + await client.connect(); + const login = await client.logIn(username, auth.auth_token); + assert.strictEqual(login.status, "1"); + client.xt("rj", 1, TOWNSHIP, 1, 0, 0); + const joined = await client.untilXt("rj"); + const file = (await client.untilXt("rp"))[2]; + client.xt("au", joined[4], 1, 400, 400, 14, 1); + return {client, login, roomId: joined[4], room: joined[3], file}; +}; + +const run = async () => { + for (const username of ["Ann", "Ben"]) { + const response = await fetch(`${BASE}/api/register`, {method: "POST", headers: {"Content-Type": "application/json"}, + body: JSON.stringify({username, password: "Password01", avatarType: 1, agreed: true})}); + assert.strictEqual(response.status, 200); + } + let {client: a, login, roomId, room} = await arrive("Ann"); + const {client: b, roomId: benRoom} = await arrive("Ben"); + await a.untilXt("ac"); + assert.strictEqual(room, TOWNSHIP); + assert.strictEqual(login.params.pendingFlags & 2, 2); // the client's bigger inventories + + // --- !go: by short name, by a room's own name, and not to nowhere + say(a, roomId, "!go nowhere"); + assert.match(await told(a), /no place called nowhere/); + say(a, roomId, "!go list"); + assert.match(await told(a), /township.*sarepia/); + say(a, roomId, "!go sarepia"); + let moved = await a.untilXt("rj"); + assert.strictEqual(moved[3], "sarepia.room_main#1"); + assert.strictEqual((await a.untilXt("rp"))[2], "sarepia.room_main"); + roomId = moved[4]; + + // --- a look for this room only, and for no other + say(a, roomId, "!theme here fall2022"); + assert.strictEqual((await a.untilXt("rp"))[2], "theme_1636.sarepia.room_main"); + say(a, roomId, "!theme here easter"); + assert.match(await told(a), /Use: !theme/); + say(a, roomId, "!go sarepia.flag_shop"); + moved = await a.untilXt("rj"); + assert.strictEqual((await a.untilXt("rp"))[2], "sarepia.flag_shop"); + say(a, moved[4], "!go sarepia"); + moved = await a.untilXt("rj"); + assert.strictEqual((await a.untilXt("rp"))[2], "theme_1636.sarepia.room_main"); // remembered + roomId = moved[4]; + say(a, roomId, "!theme here off"); + assert.strictEqual((await a.untilXt("rp"))[2], "sarepia.room_main"); + + // --- whispers: buddies only; a popup from afar, a bubble for two in one room + say(a, roomId, "!w Ben Psst, over HERE"); + assert.match(await told(a), /not one of your buddies/); + a.xt("ba", roomId, "Ben"); + await b.untilXt("ba"); + b.xt("bc", benRoom, "Ann", 1); + await a.untilXt("bs"); + say(a, roomId, "!w Ben Psst, over HERE"); + assert.deepStrictEqual((await b.untilXt("xw")).slice(2), ["0", "Ann", "Psst, over HERE"]); // from afar: a box; capitals kept + assert.match(await told(a), /Whispered to Ben/); + say(b, benRoom, "!go sarepia"); + const benMoved = await b.untilXt("rj"); + await b.untilXt("rp"); + b.xt("au", benMoved[4], 1, 300, 300, 14, 1); + await a.untilXt("ac"); + say(b, benMoved[4], "!w ann hello"); + assert.deepStrictEqual((await a.untilXt("xw")).slice(2), ["1"]); // in one room: the next bubble is a green one + assert.deepStrictEqual((await a.nextXt("uc")).slice(3), ["hello", "0"]); + + // --- names typed over in the switcher windows: an animal's, a pet's + a.xt("xrn", roomId, "a", 1, "Sir Fluffy Paws"); + assert.strictEqual((await a.untilXt("ad"))[15], "Sir Fluffy Paws"); + assert.deepStrictEqual((await a.untilXt("xrn")).slice(2), ["a", "1", "1", "Sir Fluffy Paws"]); + a.xt("xrn", roomId, "a", 1, ""); + assert.deepStrictEqual((await a.untilXt("xrn")).slice(2), ["a", "1", "0", "Sir Fluffy Paws"]); + a.xt("xrn", roomId, "p", 999, "Biscuit"); + assert.deepStrictEqual((await a.untilXt("xrn")).slice(2, 5), ["p", "999", "0"]); + say(a, roomId, "!name Nope"); // no longer a command: just something said + assert.strictEqual((await a.untilXt("uc"))[3], "!name Nope"); + + // --- clothes: everything off and back + const give = async query => { + const found = (await (await fetch(`${BASE}/api/search?q=${query}&kind=clothing`)).json()).results[0]; + assert.strictEqual((await fetch(`${BASE}/api/give`, {method: "POST", headers: {"Content-Type": "application/json"}, + body: JSON.stringify({username: "Ann", kind: "clothing", id: found.id, colorIndex: 0})})).status, 200); + return (await a.untilXt("il"))[9]; // its inventory id + }; + const hat = await give("top+hat"); + const scarf = await give("scarf"); + a.xt("iu", roomId, 2, 0, hat, scarf); + await a.untilXt("iu"); + await a.untilXt("il"); + say(a, roomId, "!outfit off"); + let changed = await a.untilXt("il"); + assert.deepStrictEqual([changed[2], changed[7], changed[8]], ["3", "0", "2"]); + assert.match(await told(a), /Everything is off/); + say(a, roomId, "!outfit undo"); + changed = await a.untilXt("il"); + assert.deepStrictEqual([changed[2], changed[7], changed[8]], ["3", "2", "0"]); + assert.match(await told(a), /Back to what you wore before/); + say(a, roomId, "!again"); + assert.match(await told(a), /Buy something in a shop first/); + // A purchase, then more of it: only after a yes to the question. + a.xt("gl", roomId, 5); + const shop = await a.untilXt("gl"); + a.xt("ib", roomId, 5, 1, shop[9], 0, 0, -1, ""); + await a.untilXt("ib"); + const owned = async () => { + a.xt("il", roomId, "Ann", 1, 1); + let list = await a.untilXt("il"); + while (list[2] !== "0") { + list = await a.untilXt("il"); + } + return Number(list[8]); + }; + const before = await owned(); + say(a, roomId, "!again 101"); + assert.match(await told(a), /from 1 to 100/); + say(a, roomId, "!again 3"); + const question = await a.untilXt("xyn"); + assert.match(question[3], /Buy 3 more/); + a.xt("xyn", roomId, question[2], 0); // no + assert.strictEqual(await owned(), before); + say(a, roomId, "!again 3"); + a.xt("xyn", roomId, (await a.untilXt("xyn"))[2], 1); // yes + assert.strictEqual(await owned(), before + 3); + say(a, roomId, "!help"); // gone: the list is at /commands + assert.strictEqual((await a.untilXt("uc"))[3], "!help"); + assert.match(await (await fetch(`${BASE}/commands`)).text(), /!outfit save NAME/); + + // --- den undo, mail, music + say(a, roomId, "!den undo"); + assert.match(await told(a), /nothing to put back/); + say(a, roomId, "!den name Beach House"); + assert.match(await told(a), /now called Beach House/); + b.xt("dj", benMoved[4], "denAnn", 1, -1); + assert.strictEqual((await b.untilXt("rj"))[14], "Ann's Beach House"); + b.xt("rj", 1, "sarepia.room_main#1", 1, 0, 0); + await b.untilXt("rp"); + say(a, roomId, "!mail clear"); + assert.match(await told(a), /0 read Jam-A-Grams deleted/); + say(a, roomId, "!music all"); + const tracks = await a.untilXt("di"); + assert.match(await told(a), /66 music tracks added/); + assert.ok(Number(tracks[3]) >= 66); + say(a, roomId, "!music all"); + await a.untilXt("di"); + assert.match(await told(a), /every music track already/); + + // --- an egg is hatched as soon as it is bought (three days by the game's clock) + const eggDef = require("../lib/defpacks.js"); + await eggDef.init(); + const egg = eggDef.petIds().find(id => eggDef.petDef(id).isEgg === "1"); + a.xt("pc", roomId, 312, egg, 0, 0, 1, 2, 0); + const made = await a.untilXt("pc"); + assert.strictEqual(made[2], "1"); + assert.ok(Number(made[10]) <= Date.now() / 1000 - 259200); + + // --- she starts in the township as ever, in a look picked at random if she asked for one + say(a, roomId, "!theme random on"); + assert.match(await told(a), /picked at random/); + a.socket.destroy(); + await new Promise(resolve => setTimeout(resolve, 200)); + const again = await arrive("Ann"); + assert.match(again.file, /^theme_\d+\.jamaa_township\.room_main/); + again.client.socket.destroy(); + await new Promise(resolve => setTimeout(resolve, 200)); + + // --- "start in your own den" (asked for at sign-in): the game asks for the township and is put in the den + const denAuth = await (await postJson(`${BASE}/authenticate`, {username: "Ann", password: "Password01", login_choices: {startInDen: true}})).json(); + const home = new harness.GameClient(GAME_PORT); + await home.connect(); + await home.logIn("Ann", denAuth.auth_token); + home.xt("rj", 1, TOWNSHIP, 1, 0, 0); + assert.strictEqual((await home.untilXt("rj"))[3], "denAnn"); + home.socket.destroy(); + b.socket.destroy(); +}; + +harness.withServer("comforts test", HTTP_PORT, GAME_PORT, run).catch(err => { + console.error(err); + process.exit(1); +}); diff --git a/test/restored.js b/test/restored.js new file mode 100644 index 0000000..8292727 --- /dev/null +++ b/test/restored.js @@ -0,0 +1,328 @@ +"use strict"; + +// end-to-end check of what was brought back from the game's files: showcase +// dens, animals and dens out of season, added dens and parties, the shops +// of odd items, rooms shown as another version of themselves. simulated +// players, a real server. + +const assert = require("assert"); +const zlib = require("zlib"); +const amf3 = require("../lib/amf3.js"); +const cdn = require("../lib/cdn.js"); +const harness = require("./harness.js"); + +const HTTP_PORT = 18082; +const GAME_PORT = 19341; +const BASE = `http://127.0.0.1:${HTTP_PORT}`; +const TOWNSHIP = "jamaa_township.room_main#1"; +const {postJson} = harness; + +const arrive = async (username, password) => { + const auth = await (await postJson(`${BASE}/authenticate`, {username, password})).json(); + const client = new harness.GameClient(GAME_PORT); + await client.connect(); + const login = await client.logIn(username, auth.auth_token); + assert.strictEqual(login.status, "1"); + client.xt("rj", 1, TOWNSHIP, 1, 0, 0); + const roomId = (await client.untilXt("rj"))[4]; + await client.untilXt("rp"); + client.xt("au", roomId, 1, 400, 400, 14, 1); + return {client, login, roomId}; +}; + +// A defPack as clients get it from this server, as its rows. +const pack = async id => Object.values(amf3.decode(zlib.inflateRawSync(Buffer.from( + await (await fetch(`${BASE}/${cdn.hashedPath(`defPacks/${id}`)}`)).arrayBuffer())))); +const byId = (rows, id) => rows.find(row => String(row.id) === String(id)); + +const run = async () => { + const registerJson = body => fetch(`${BASE}/api/register`, {method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({avatarType: 1, agreed: true, ...body})}); + for (const username of ["Ann", "Ben"]) { + assert.strictEqual((await registerJson({username, password: "Password01"})).status, 200); + } + const {client: a, roomId} = await arrive("Ann", "Password01"); + + // --- Epic Dens: twenty names; asking for the den of one leads into its room + a.xt("dh", roomId); + const epic = await a.nextXt("dh"); + assert.strictEqual(epic[2], "20"); + assert.strictEqual(new Set(epic.slice(3)).size, 20); + a.xt("dj", roomId, `den${epic[3]}`, 1, -1); + const showcase = await a.untilXt("rj"); + assert.match(showcase[3], /^epic_dens\.room_\w+#1$/); + assert.strictEqual(showcase[14], epic[3]); // the name in the corner of the screen + assert.match((await a.nextXt("rp"))[2], /^epic_dens\.room_/); + // the AJHQ button is party 36: one more showcase den, not one of the twenty. + a.xt("sj", showcase[4], 36); + const featured = await a.untilXt("rj"); + assert.match(featured[3], /^party36_\d+$/); + assert.ok(!epic.slice(3).includes(featured[14])); + assert.match((await a.nextXt("rp"))[2], /^epic_dens\.room_/); + assert.strictEqual(byId(await pack(1047), 36).titleStrId, "8700"); // "Epic Dens" + + // --- nothing is out of season among animals, pets and dens + for (const id of [1003, 1046, 1040]) { + assert.deepStrictEqual((await pack(id)).filter(def => Number(def.availabilityStartTime) > 0 || Number(def.availabilityEndTime) > 0), []); + } + + // --- the four draft dens: in the pack, named, and for sale + const dens = await pack(1040); + assert.deepStrictEqual([62, 63, 64, 65].map(id => byId(dens, id).roomDefId), ["130", "187", "186", "441"]); + const strings = amf3.decode(zlib.inflateRawSync(Buffer.from(await (await fetch(`${BASE}/${cdn.hashedPath("defPacks/10230")}`)).arrayBuffer()))); + assert.strictEqual(strings[byId(dens, 62).titleStrRef], "Castle (2010 draft)"); + assert.strictEqual(strings[157], "Small House"); // and the game's own are as they were + // the den switcher asks for the slot it wants filled, and the den's id is that slot. + a.xt("db", featured[4], -1, 0, 65, 3, 0); + assert.strictEqual((await a.untilXt("db"))[2], "1"); + const owned = await a.nextXt("dl"); + assert.deepStrictEqual(owned.slice(2), ["2", "0", owned[4], "3", "65"]); + a.xt("db", featured[4], -1, 0, 62, 3, 0); // a slot already taken: the first free one instead + await a.untilXt("db"); + assert.deepStrictEqual((await a.nextXt("dl")).slice(7), ["1", "62"]); + a.xt("dc", featured[4], 3); + await a.nextXt("dc"); + a.xt("dj", featured[4], "denAnn", 1, -1); + await a.untilXt("rj"); + assert.strictEqual((await a.nextXt("rp"))[2], "player_den.room_main_epicpalace"); + + // --- four more parties, in the rooms nothing used + a.xt("sl", roomId); + const parties = await a.untilXt("sl"); + for (const id of ["54", "55", "56", "57"]) { + assert.ok(parties.includes(id)); + } + a.xt("sj", roomId, 56); + await a.untilXt("rj"); + assert.strictEqual((await a.nextXt("rp"))[2], "party.venue_pl_res_bakery"); + + // --- the shops of odd items: Beta furniture in the chamber base, the Founders' Hat in the archives + const denItems = await pack(1030); + a.xt("gl", roomId, 396); + const oddDenItems = (await a.nextXt("gl")).slice(9); + assert.ok(oddDenItems.length > 200); + // what the shop really sold comes first (lib/shopstock.js), then the Beta set. + assert.strictEqual(byId(denItems, oddDenItems[0]).abbrName, "ChamberLamp"); + assert.match(byId(denItems, oddDenItems.find(id => !/^Chamber/.test(byId(denItems, id).abbrName))).abbrName, /^Beta/); + assert.ok(oddDenItems.some(id => /^Beta/.test(byId(denItems, id).abbrName))); + assert.ok(oddDenItems.includes("3123")); // TestCloud + assert.ok(oddDenItems.every(id => /^Chamber/.test(byId(denItems, id).abbrName) || byId(denItems, id).availabilityEndTime === "0")); + a.xt("gl", roomId, 666); + assert.ok((await a.nextXt("gl")).slice(9).includes("215")); + + // --- extra den music: den items like the official tracks, their audio cut out of the game's files, in no shop + const track = byId(denItems, 6001); + assert.deepStrictEqual([track.abbrName, track.typeCat, track.sortCat, strings[track.nameStrId]], ["XtraNarration", "4", "4", "Narration"]); + assert.ok(byId(denItems, 6011)); + const mp3 = Buffer.from(await (await fetch(`${BASE}/${cdn.hashedPath("audio/XtraUnnamed.mp3")}`)).arrayBuffer()); + assert.ok(mp3.length > 3000 && mp3[0] === 0xFF && (mp3[1] & 0xE0) === 0xE0); // an MP3 frame + for (const shop of [12, 51, 63, 85, 396]) { + a.xt("gl", roomId, shop); + assert.ok(!(await a.nextXt("gl")).slice(9).some(id => Number(id) >= 6001 && Number(id) <= 6011)); + } + a.xt("gl", roomId, 401); // nor among the tracks a hosted party can play + assert.ok(!(await a.nextXt("gl")).slice(9).includes("6001")); + + // --- a room shown as its other version: same room, another file + const month = new Date().getUTCMonth() + 1; + a.xt("rj", roomId, "appondale.room_museum#1", 1, 0, 0); + assert.strictEqual((await a.untilXt("rj"))[3], "appondale.room_museum#1"); + assert.strictEqual((await a.nextXt("rp"))[2], month % 2 === 0 ? "appondale.room_museum_ant" : "appondale.room_museum"); + + // --- mannequins: a den item that wears clothing of its owner's + a.xt("ib", roomId, 666, 1, 215, 0, 0); // the Founders' Hat, a head item + const hat = (await a.untilXt("il"))[9]; + await a.untilXt("ib"); + a.xt("db", roomId, 0, 12, 3433, 0, 0); // arctic Wolf Mannequin + assert.strictEqual((await a.untilXt("db"))[2], "1"); + // the owner's list: eight fields, the ten of a mannequin (all 0 = bare, the animal's own colours), one more. + const listed = await a.nextXt("di"); + assert.deepStrictEqual(listed.slice(5), [listed[5], "3433", "0", "0", "true", "", "-1", "", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"]); + const mannequin = listed[5]; + a.xt("dj", roomId, "denAnn", 1, -1); + const den = (await a.untilXt("rj"))[4]; + await a.untilXt("ds"); + // placed, coloured, wearing the hat. the hat offered as a tail piece is not taken. + a.xt("ds", den, 1, 0, mannequin, 1, 300, 400, 0, "off", 111, 222, 0, 333, 0, hat, 0, 0, 0, hat); + assert.deepStrictEqual((await a.nextXt("dss")).slice(2), [mannequin]); + a.xt("di", den); + assert.deepStrictEqual((await a.nextXt("di")).slice(13, 24), ["111", "222", "0", "333", "0", "0", "0", "0", "0", hat, "0"]); + // A visitor is told what the hat is: its def and colour, then its id. + const {client: b, roomId: benRoom} = await arrive("Ben", "Password01"); + b.xt("dj", benRoom, "denAnn", 1, -1); + const seen = await b.untilXt("ds"); + assert.deepStrictEqual(seen.slice(5), [mannequin, "3433", "1", "300", "400", "0", "0", "", "", "-1", "", + "111", "222", "0", "333", "0", "0", "0", "0", "0", "215", "392491620", hat, "0"]); + // --- playing as an alpha: the client is told which character stands in for the animal + const say = (client, room, text) => client.send(``); + a.xt("au", den, 1, 300, 300, 14, 1); // Ann has walked in: others see her + await b.untilXt("ac"); + say(a, den, "!become liza"); + const disguised = await a.untilXt("dph"); + assert.deepStrictEqual(disguised.slice(2), ["1", disguised[3], "1", "21"]); + // ben has her animal put on his screen afresh, and the disguise after it. + assert.strictEqual((await b.untilXt("ac"))[2], disguised[3]); + assert.deepStrictEqual((await b.untilXt("dph")).slice(2), ["1", disguised[3], "1", "21"]); + assert.match((await a.untilXt("xtl"))[2], /^Done/); + say(a, den, "!become nobody"); + assert.match((await a.untilXt("xtl"))[2], /no character called nobody/); + say(a, den, "!become off"); + assert.deepStrictEqual((await a.untilXt("dph")).slice(2), ["1", disguised[3], "0", "2"]); + await b.untilXt("ac"); + + // the hat recycled: the mannequin is bare again. + a.xt("ir", den, hat); + await a.untilXt("ir"); + await a.nextXt("il"); + a.xt("di", den); + assert.strictEqual((await a.nextXt("di"))[22], "0"); + + // --- a player who is not in the game: their card still shows who they are + assert.strictEqual((await registerJson({username: "Cat", password: "Password01"})).status, 200); + const {client: c, roomId: catRoom} = await arrive("Cat", "Password01"); + c.xt("pc", catRoom, 312, 1, 0, 0, 15386, 15428, 0); // a pet, so there is one to list + await c.untilXt("pc"); + c.socket.destroy(); + await new Promise(resolve => setTimeout(resolve, 200)); + b.xt("ag", benRoom, "cat", 1); + const card = await b.untilXt("ag"); + assert.deepStrictEqual(card.slice(2, 5), ["Cat", card[3], "0"]); // found, offline + b.xt("al", benRoom, "Cat"); + const animals = await b.nextXt("al"); + assert.deepStrictEqual(animals.slice(2, 4), ["Cat", "1"]); + b.xt("ad", benRoom, "Cat", animals[4], 2); + const animal = await b.nextXt("ad"); + assert.deepStrictEqual([animal[2], animal[9]], ["Cat", animals[4]]); + assert.deepStrictEqual((await b.nextXt("il")).slice(2, 6), ["1", "0", animals[4], "Cat"]); // what it wears + b.xt("pl", benRoom, "Cat"); + assert.deepStrictEqual((await b.nextXt("pl")).slice(2, 5), ["1", "Cat", "1"]); + // A buddy request and a Jam-A-Gram for them wait until they are back. + b.xt("ba", benRoom, "Cat"); + assert.deepStrictEqual((await b.nextXt("ba")).slice(2), ["1", "Cat", "1"]); // sent + b.xt("gl", benRoom, 10); + const cards = (await b.nextXt("gl")).slice(9); + b.xt("gl", benRoom, 44); + const stamps = (await b.nextXt("gl")).slice(9); + b.xt("es", benRoom, "Cat", cards[0], stamps[0], 0, "see you soon", 0, 0, 0); + assert.strictEqual((await b.untilXt("es"))[2], "1"); + const {client: c2, login: catLogin, roomId: catRoom2} = await arrive("Cat", "Password01"); + assert.strictEqual(catLogin.params.numUnreadECards, 1); + assert.deepStrictEqual((await c2.untilXt("ba")).slice(2), ["0", "Ben", "1"]); // asked, now that Cat is here + c2.xt("bc", catRoom2, "Ben", 1); + assert.deepStrictEqual((await c2.untilXt("bs")).slice(3, 4), ["Ben"]); + assert.deepStrictEqual((await b.untilXt("bs")).slice(3, 4), ["Cat"]); + + // --- masterpieces: painted, posted, framed, reviewed, hung + const panel = async (pathname, body, cookie) => { + const response = await fetch(`${BASE}/admin/api/${pathname}`, { + method: body === undefined ? "GET" : "POST", + headers: {"Content-Type": "application/json", ...(cookie ? {Cookie: cookie} : {})}, + body: body === undefined ? undefined : JSON.stringify(body), + }); + const picture = (response.headers.get("content-type") || "").startsWith("image/"); + return {status: response.status, data: picture ? Buffer.from(await response.arrayBuffer()) : await response.json(), + cookie: (response.headers.get("set-cookie") || "").split(";")[0]}; + }; + const admin = (await panel("setup", {password: "admin-password-1"})).cookie; + const post = (token, picture) => { + const form = new FormData(); + form.append("authToken", token); + form.append("image", new Blob([picture], {type: "image/jpeg"}), "ArtStudioImage"); + return fetch(`${BASE}/game/mp`, {method: "POST", body: form}).then(response => response.json()); + }; + // the least a JPEG can be and pass for one: a header segment, a frame + // header (100 by 100), the start of the picture data, some of it, the end. + const jpeg = Buffer.concat([Buffer.from([0xFF, 0xD8, 0xFF, 0xE0, 0, 16]), Buffer.alloc(14), + Buffer.from([0xFF, 0xC0, 0, 11, 8, 0, 100, 0, 100, 1, 1, 0x11, 0]), Buffer.from([0xFF, 0xDA, 0, 8, 1, 1, 0, 0, 63, 0]), + Buffer.alloc(400, 7), Buffer.from([0xFF, 0xD9])]); + // the frames: 24 of them, each with a name. + a.xt("gl", den, 424); + const frames = await a.untilXt("gl"); + assert.deepStrictEqual([frames[8], frames[9], frames[10]], ["24", "4813", "25174"]); + // the easel asks for a token; the painting is posted with it, once. + // the easel's popup needs Pixel Painting described along with Painting. + a.xt("mi", den, 51); + const described = await a.untilXt("mi"); + assert.deepStrictEqual([described[2], described[3], described[3 + 19]], ["2", "51", "139"]); + a.xt("mj", den, 51, 0, 0, 0); + const easel = (await a.untilXt("mj"))[1]; + a.xt("mm", easel, 51, "gmtkn", 0, 1); + const tokenReply = await a.untilXt("mm"); + assert.deepStrictEqual([tokenReply[2], tokenReply[3], tokenReply[7]], ["tkn", "1", "1"]); + assert.deepStrictEqual(await post("not-a-token", jpeg), {success: false}); + const posted = await post(tokenReply[5], jpeg); + assert.strictEqual(posted.success, true); + assert.deepStrictEqual(await post(tokenReply[5], jpeg), {success: false}); + assert.deepStrictEqual(Buffer.from(await (await fetch(`${BASE}/masterpieces/${posted.uuid}`)).arrayBuffer()), jpeg); + // framed (frame 2) for two diamonds: an item, not approved, that will not go on a wall. + a.xt("db", den, 0, 0, 221, 2, 1, 1, 0, posted.uuid); + const bought = await a.untilXt("db"); + assert.strictEqual(bought[2], "1"); + const painting = bought[6]; + const framed = await a.nextXt("di"); + const at = framed.indexOf(painting, 5); + assert.deepStrictEqual(framed.slice(at, at + 9), [painting, "2725", "0", "2", "false", posted.uuid, String(framed[at + 6]), framed[at + 7], "0"]); + assert.match(framed[at + 7], /^[0-9a-f-]{36}$/); // Ann's uuid: she made it + a.xt("ds", den, 1, 0, painting, 1, 500, 300, 0, "off", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + assert.deepStrictEqual((await a.untilXt("dss")).slice(2), []); + // ben cannot frame Ann's painting. + b.xt("db", benRoom, 0, 0, 221, 0, 1, 1, 0, posted.uuid); + assert.strictEqual((await b.untilXt("db"))[2], "0"); + // the panel has it waiting, with the picture; approving tells Ann. + const waiting = (await panel("masterpieces", undefined, admin)).data; + assert.deepStrictEqual([waiting.review, waiting.waiting.map(entry => [entry.id, entry.creator]), waiting.approved], [true, [[posted.uuid, "Ann"]], []]); + assert.deepStrictEqual((await panel(`masterpiece?id=${posted.uuid}`, undefined, admin)).data, jpeg); + assert.strictEqual((await panel(`masterpiece?id=${posted.uuid}`)).status, 401); + assert.strictEqual((await panel("masterpiece", {id: posted.uuid, action: "approve"}, admin)).status, 200); + assert.match((await a.untilXt("ep"))[7], /approved/); + const approved = await a.nextXt("di"); + assert.strictEqual(approved[approved.indexOf(painting, 5) + 4], "true"); + // hung, once Ann is home from the easel: a visitor is told which painting and whose. + a.xt("dj", den, "denAnn", 1, -1); + await a.untilXt("ds"); + a.xt("ds", den, 1, 0, painting, 1, 500, 300, 0, "off", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + assert.deepStrictEqual((await a.untilXt("dss")).slice(2), [painting]); + const hung = await b.untilXt("ds"); + const spot = hung.indexOf(painting, 5); + assert.deepStrictEqual(hung.slice(spot, spot + 11), [painting, "2725", "1", "500", "300", "2", "0", "", posted.uuid, framed[at + 6], framed[at + 7]]); + b.xt("dmc", benRoom, "Ann", posted.uuid); + assert.deepStrictEqual((await b.nextXt("dmc")).slice(2), ["Ann"]); + b.xt("dmi", benRoom, "Ann"); + assert.deepStrictEqual((await b.nextXt("dmi")).slice(2, 8), ["1", "2725", painting, "2", "true", posted.uuid]); + // A like from Ben counts once; Ann cannot like her own. + b.xt("crp", benRoom, "masterpiece", posted.uuid, "x", "", "2,x,1"); + assert.strictEqual((await b.nextXt("crp"))[2], "1"); + b.xt("crp", benRoom, "masterpiece", posted.uuid, "x", "", "2,x,1"); + assert.strictEqual((await b.nextXt("crp"))[2], "0"); + a.xt("crg", den, "masterpiece", posted.uuid, "x", ""); + assert.deepStrictEqual((await a.untilXt("crg")).slice(2), ["1", "0", "1"]); + // it hangs in the Masterpiece Gallery party, which is told so with the room. + b.xt("sm", benRoom); + assert.deepStrictEqual(JSON.parse((await b.nextXt("sm"))[2]).pool.map(entry => [entry.resourceId, entry.userName, entry.frameId]), [[posted.uuid, "Ann", 2]]); + b.xt("sj", benRoom, 47); + await b.untilXt("rj"); + assert.strictEqual(JSON.parse((await b.nextXt("rp"))[8]).pool[0].resourceId, posted.uuid); + // removed from the panel: gone from Ann's den and things, a token in its place. + assert.strictEqual((await panel("masterpiece", {id: posted.uuid, action: "remove"}, admin)).status, 200); + const after = await a.untilXt("di"); + assert.ok(!after.includes(posted.uuid) && after.includes("2947")); + assert.strictEqual((await fetch(`${BASE}/masterpieces/${posted.uuid}`)).status, 404); + // with review off, a painting framed with that token is approved on the spot. + assert.strictEqual((await panel("masterpiece", {action: "review", on: false}, admin)).status, 200); + a.xt("mj", den, 51, 0, 0, 0); + const easelAgain = (await a.untilXt("mj"))[1]; + a.xt("mm", easelAgain, 51, "gmtkn", 0, 1); + const second = await post((await a.untilXt("mm"))[5], jpeg); + a.xt("db", den, 0, 0, 221, 0, 1, 1, 1, second.uuid); + assert.strictEqual((await a.untilXt("db"))[2], "1"); + const last = await a.nextXt("di"); + assert.ok(!last.includes("2947") && last[last.indexOf(second.uuid) - 1] === "true"); + + a.socket.destroy(); + b.socket.destroy(); + c2.socket.destroy(); +}; + +harness.withServer("restored features test", HTTP_PORT, GAME_PORT, run).catch(err => { + console.error(err); + process.exit(1); +}); diff --git a/test/smoke.js b/test/smoke.js new file mode 100644 index 0000000..aee19c0 --- /dev/null +++ b/test/smoke.js @@ -0,0 +1,658 @@ +"use strict"; + +// end-to-end check against a real server process: plays the launcher's HTTP +// calls and then two game clients speaking the SWF's socket protocol. + +const assert = require("assert"); +const crypto = require("crypto"); +const harness = require("./harness.js"); + +const HTTP_PORT = 18080; +const GAME_PORT = 19339; +const BASE = `http://127.0.0.1:${HTTP_PORT}`; + +class GameClient extends harness.GameClient { + constructor() { + super(GAME_PORT); + } +} + +const {postJson} = harness; + +const run = async () => { + // --- launcher HTTP flow + const flashVars = await (await fetch(`${BASE}/flashvars`)).json(); + assert.strictEqual(flashVars.smartfoxPort, String(GAME_PORT)); + assert.ok(flashVars.content && flashVars.website && flashVars.blueboxServer && flashVars.blueboxPort); + + // --- registration: the web form's API, and no accounts made by logging in + assert.match(await (await fetch(`${BASE}/register`)).text(), /Create an account/); + const registerJson = body => fetch(`${BASE}/api/register`, {method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({avatarType: 1, agreed: true, ...body})}); + assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "Alice", password: "Password01"})).status, 401); + assert.strictEqual((await registerJson({username: "Alice", password: "Password01"})).status, 200); + assert.deepStrictEqual(await (await registerJson({username: "alice", password: "Password01"})).json(), {error: "username_taken"}); + assert.deepStrictEqual(await (await registerJson({username: "a!", password: "Password01"})).json(), {error: "invalid_username"}); + assert.deepStrictEqual(await (await registerJson({username: "Shorty", password: "pw"})).json(), {error: "invalid_password"}); + // no default animal: whoever signs up picks one of the nine on the page. + assert.deepStrictEqual(await (await registerJson({username: "Noanimal", password: "Password01", avatarType: undefined})).json(), {error: "choose_animal"}); + assert.deepStrictEqual(await (await registerJson({username: "Noanimal", password: "Password01", avatarType: 2})).json(), {error: "choose_animal"}); + assert.match(await (await fetch(`${BASE}/register`)).text(), /Choose an animal/); + assert.strictEqual((await fetch(`${BASE}/signup/thumb_wolf.svg`)).headers.get("content-type"), "image/svg+xml"); + assert.strictEqual((await fetch(`${BASE}/signup/..%2Faccount.html`)).status, 404); + for (const [username, password] of [["Bob", "Password02"], ["Carol", "Password03"], ["foo", "Password04"]]) { + assert.strictEqual((await registerJson({username, password})).status, 200); + } + + let res = await postJson(`${BASE}/authenticate`, {username: "Alice", password: "Password01", domain: "flash", df: "x"}); + assert.strictEqual(res.status, 200); + assert.strictEqual(res.headers.get("access-control-allow-origin"), "null"); + const alice = await res.json(); + assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "alice", password: "wrong"})).status, 401); + assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "constructor", password: "Password01"})).status, 401); + assert.strictEqual((await postJson(`${BASE}/authenticate`, {refresh_token: alice.refresh_token})).status, 200); + const bob = await (await postJson(`${BASE}/authenticate`, {username: "Bob", password: "Password02"})).json(); + + res = await fetch(`${BASE}/player?domain=flash&client_version=1830`, {headers: {Authorization: `Bearer ${alice.auth_token}`}}); + assert.strictEqual((await res.json()).screen_name, "Alice"); + assert.strictEqual((await fetch(`${BASE}/player`, {headers: {Authorization: "Bearer nope"}})).status, 401); + + assert.match(await (await fetch(`${BASE}/gameClient/game/index.html`)).text(), /flashVarsReady/); + const swf = Buffer.from(await (await fetch(flashVars.clientURL)).arrayBuffer()); + assert.ok(["CWS", "ZWS", "FWS"].includes(swf.toString("latin1", 0, 3))); + assert.strictEqual((await fetch(`${BASE}/../../etc/passwd`)).status, 404); + assert.strictEqual((await fetch(`${BASE}/%2e%2e/%2e%2e/config.js`)).status, 404); + + // --- socket policy request (Flash asks before opening the real connection) + const policy = new GameClient(); + await policy.connect(); + policy.send(""); + assert.match(await policy.next(), /cross-domain-policy/); + + // --- the client's Create Account screens: guest zone, name check, create + const guest = new GameClient(); + await guest.connect(); + guest.send(""); + await guest.next(); + guest.send(""); + const guestKey = /([0-9a-f]+)<\/k>/.exec(await guest.next())[1]; + guest.send(""); + assert.match(await guest.next(), /action='logOK'/); + guest.xt("la", 1, 0, "Alice", 0, 0, 0, 0, 1830); + assert.deepStrictEqual((await guest.nextXt("la")).slice(2), ["-3"]); + guest.xt("la", 1, 0, "Dave", 0, 0, 0, 0, 1830); + assert.deepStrictEqual((await guest.nextXt("la")).slice(2), ["1"]); + const iv = crypto.randomBytes(16); + const cipher = crypto.createCipheriv("aes-256-cbc", crypto.createHash("sha256").update(guestKey).digest(), iv); + const encrypted = Buffer.concat([iv, cipher.update("DavePass01"), cipher.final()]).toString("base64"); + guest.xt("lc", 1, "Dave", encrypted, "2000-01-01", 0, "", 15136, 15224, 15299, 4, 0, "US", 1830); + assert.deepStrictEqual((await guest.nextXt("lc")).slice(2, 3), ["1"]); + guest.socket.destroy(); + assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "Dave", password: "DavePass01"})).status, 200); + + // --- first player: login and world entry + const a = new GameClient(); + await a.connect(); + const bad = new GameClient(); + await bad.connect(); + assert.strictEqual((await bad.logIn("Alice", "bogus")).status, "0"); + bad.socket.destroy(); + + const login = await a.logIn("Alice", alice.auth_token); + assert.strictEqual(login._cmd, "login"); + assert.strictEqual(login.status, "1"); + assert.strictEqual(login.params.userName, "Alice"); + assert.strictEqual(login.params.gemsCount, 10000000); + assert.strictEqual(login.params.pendingFlags & 1, 1); + const aliceId = login.params.userId; + + a.xt("al", 1, "Alice"); + const al = await a.nextXt("al"); + assert.deepStrictEqual(al.slice(2, 4), ["Alice", "4294967295"]); + assert.strictEqual(al[5], "1"); + + a.xt("gl", 1, 64); + const gl = await a.nextXt("gl"); + assert.deepStrictEqual(gl.slice(2, 4), ["64", "1003"]); + assert.strictEqual(Number(gl[8]), gl.length - 9); + + a.xt("rj", 1, "jamaa_township.room_main#-1", 1, 0, 0); + const rj = await a.nextXt("rj"); + assert.deepStrictEqual(rj.slice(2, 4), ["1", "jamaa_township.room_main#1"]); + // the name for the corner of the screen, and 0 for "no string id in its place". + assert.deepStrictEqual(rj.slice(14, 16), ["Jamaa Township", "0"]); + const roomId = rj[4]; + const rp = await a.nextXt("rp"); + assert.deepStrictEqual(rp.slice(1, 4), [roomId, "jamaa_township.room_main", "0"]); + + a.xt("ad", roomId, "Alice", 1, 1); + const ad = await a.nextXt("ad"); + assert.strictEqual(ad[2], "Alice"); + assert.strictEqual(ad.length, 2 + 15 + 8); + assert.deepStrictEqual((await a.nextXt("il")).slice(2, 6), ["0", "0", "1", "Alice"]); + a.xt("au", roomId, 1, 500, 400, 14, 1); + + a.xt("rj", roomId, "no_such.room#1", 1, 0, 0); + assert.strictEqual((await a.nextXt("rj"))[2], "0"); + + // --- second player sees the first, and vice versa + const b = new GameClient(); + await b.connect(); + const bobId = (await b.logIn("Bob", bob.auth_token)).params.userId; + b.xt("rj", 1, "jamaa_township.room_main#1", 1, 0, 0); + assert.strictEqual((await b.nextXt("rj"))[4], roomId); + await b.nextXt("rp"); + const ac = await b.nextXt("ac"); + assert.deepStrictEqual(ac.slice(1, 7), [roomId, String(aliceId), "500", "400", "14", "Alice"]); + await b.nextXt("il"); + + b.xt("au", roomId, 1, 100, 200, 14, 1); + assert.deepStrictEqual((await a.nextXt("ac")).slice(2, 5), [String(bobId), "100", "200"]); + await a.nextXt("il"); + + b.xt("au", roomId, 2, 110, 210, 120, 220, 14, 0); + assert.deepStrictEqual((await a.nextXt("au")).slice(2), ["1", String(bobId), "2", "110", "210", "120", "220", "0"]); + b.xt("au", roomId, 999, 1, 1, 14, 0); // malformed: ignored + + b.send(``); + assert.deepStrictEqual((await a.nextXt("uc")).slice(1), [roomId, String(bobId), "hi & bye", "0"]); + assert.deepStrictEqual((await b.nextXt("uc")).slice(1), [roomId, String(bobId), "hi & bye", "0"]); + b.send(``); // emote: not echoed + assert.deepStrictEqual((await a.nextXt("uc")).slice(3), ["7", "2"]); + + // --- player cards + a.xt("ag", roomId, "bob", 1); + const card = await a.nextXt("ag"); + assert.deepStrictEqual([card[2], card[4], card[21]], ["Bob", "1", String(bobId)]); + a.xt("ags", roomId, bobId, 0); + assert.strictEqual((await a.nextXt("ag"))[2], "Bob"); + a.xt("ag", roomId, "nobody", 1); + assert.deepStrictEqual((await a.nextXt("ag")).slice(2), ["nobody", "", "3"]); + a.xt("sphp", roomId, "x"); + assert.deepStrictEqual((await a.nextXt("sphp")).slice(2), ["-1"]); + + // --- buddies: request, accept, list, location, block, remove + b.xt("ba", roomId, "alice"); + assert.deepStrictEqual((await a.nextXt("ba")).slice(2), ["0", "Bob", "1"]); + assert.deepStrictEqual((await b.nextXt("ba")).slice(2), ["1", "Alice", "1"]); + a.xt("bc", roomId, "Bob", 1); + const aliceSees = await a.nextXt("bs"); + assert.deepStrictEqual([aliceSees[3], aliceSees[6], aliceSees[8]], ["Bob", "1", "0"]); + const bobSees = await b.nextXt("bs"); + assert.deepStrictEqual([bobSees[3], bobSees[6], bobSees[8]], ["Alice", "1", "1"]); // 1 = accepted your request + a.xt("bl", roomId); + assert.deepStrictEqual((await a.nextXt("bl")).slice(2, 5).concat((await a.nextXt("bl")).slice(2)), ["0", "1", "Bob", "1", "0"]); + assert.deepStrictEqual((await a.nextXt("xls")).slice(2), ["0"]); // when offline buddies were last seen: none are offline + a.xt("br", roomId, "Bob"); + assert.deepStrictEqual((await a.nextXt("br")).slice(2), ["jamaa_township.room_main#1", "Jamaa Township", "0", "0"]); // last 0: "go to" allowed + a.xt("bb", roomId, "Bob"); + assert.deepStrictEqual((await a.nextXt("bb")).slice(2), ["Bob", "1"]); + b.xt("bi", roomId, "Alice"); + assert.deepStrictEqual((await b.nextXt("bi")).slice(2), ["Alice", "1"]); + a.xt("bu", roomId, "Bob"); + assert.deepStrictEqual((await a.nextXt("bu")).slice(2), ["Bob", "1"]); + a.xt("bd", roomId, "Bob"); + assert.deepStrictEqual((await a.nextXt("bd")).slice(2), ["Bob"]); + assert.deepStrictEqual((await b.nextXt("bd")).slice(2), ["Alice"]); + + b.socket.destroy(); + assert.deepStrictEqual((await a.nextXt("ar")).slice(1), [roomId, String(bobId)]); + + // --- lists, user vars and the den + a.xt("gl", roomId, 741); + assert.deepStrictEqual((await a.nextXt("gl")).slice(2, 4), ["741", "1000"]); + a.xt("zs", roomId, 66, 1, 1); + // var 66 at 1 is what the "Welcome to the Club" achievement (def 134) asks for. + const clubVar = await a.nextXt("zs"); + assert.deepStrictEqual([...clubVar.slice(2, 5), clubVar[6]], ["66", "1", "1", "134"]); + a.xt("za", roomId, "Alice", -1); + const aliceAchievements = await a.nextXt("za"); + assert.strictEqual(aliceAchievements[2], "Alice"); + // 134, and "Buddy Added" (def 90) from making friends with Bob above. + assert.deepStrictEqual(aliceAchievements.slice(4).filter((_, i) => i % 2 === 1).sort(), ["134", "90"]); + // A counter the server keeps is not the client's to set. + a.xt("zs", roomId, 1, 999999, 1); + assert.deepStrictEqual((await a.nextXt("zs")).slice(2), ["1", "0", "0"]); + a.xt("gl", roomId, 627); + const pushedVars = await a.nextXt("zg"); + // 129 and 379: every tutorial marked as seen. 214: the daily wheel never due. + const varsById = {}; + for (let i = 3; i < pushedVars.length; i += 3) { + varsById[pushedVars[i]] = pushedVars[i + 2]; + } + assert.strictEqual(Number(pushedVars[2]), Object.keys(varsById).length); + // 40: buddies added, counted by the server. 9001: "hide blocked players", off. + assert.deepStrictEqual([varsById[66], varsById[129], varsById[214], varsById[379], varsById[40], varsById[9001]], ["1", "65535", "65535", "65535", "1", "0"]); + assert.strictEqual((await a.nextXt("gl"))[2], "627"); + a.xt("dl", roomId); + assert.deepStrictEqual((await a.nextXt("dl")).slice(2), ["1", "0", "1"]); + a.xt("dj", roomId, "denNobody", 1, -1); + assert.strictEqual((await a.nextXt("rj"))[2], "0"); + a.xt("dj", roomId, "denalice", 1, -1); + const denJoin = await a.nextXt("rj"); + assert.deepStrictEqual([denJoin[2], denJoin[3], denJoin[14], denJoin[15]], ["1", "denAlice", "Alice's Den", "0"]); + assert.match((await a.nextXt("rp"))[2], /^player_den\./); + assert.deepStrictEqual((await a.nextXt("ds")).slice(2), ["0", "0", "1"]); + + // --- shops, clothing, animals and pets (Carol watches from the same den) + const carol = await (await postJson(`${BASE}/authenticate`, {username: "Carol", password: "Password03"})).json(); + const c = new GameClient(); + await c.connect(); + await c.logIn("Carol", carol.auth_token); + c.xt("dj", 1, "denAlice", 1, -1); + const denId = (await c.nextXt("rj"))[4]; + await c.nextXt("rp"); + await c.nextXt("ds"); + a.xt("au", denId, 1, 300, 300, 14, 1); + c.xt("au", denId, 1, 310, 310, 14, 1); + await a.nextXt("ac"); + await a.nextXt("il"); + await c.nextXt("ac"); + await c.nextXt("il"); + + a.xt("gl", denId, 200); + const names = await a.nextXt("gl"); + assert.deepStrictEqual(names.slice(3, 4).concat(names.slice(8, 10)), ["1023", "88", "15136"]); + + // the den shop inside a den is a "combined" list: kinds, counts, entries. + a.xt("gl", denId, 384); + const denRoomShop = await a.nextXt("gl"); + assert.deepStrictEqual(denRoomShop.slice(3, 5).concat(denRoomShop[9]), ["1060", "", "1040"]); + assert.ok(Number(denRoomShop[8]) > 50 && denRoomShop[8] === denRoomShop[10] && Number(denRoomShop[10]) === denRoomShop.length - 11); + + a.xt("gl", denId, 5); + const shop = await a.nextXt("gl"); + assert.strictEqual(shop[3], "1000"); + assert.ok(Number(shop[8]) > 5 && Number(shop[8]) < 200 && Number(shop[8]) === shop.length - 9); + const itemDef = shop[9]; + + a.xt("ib", denId, 5, 1, itemDef, 0, 0, -1, ""); + const added = await a.nextXt("il"); + assert.deepStrictEqual(added.slice(2, 6).concat(added.slice(7)), ["2", "0", "1", "Alice", "1", "0", added[9], itemDef]); + const itemInv = added[9]; + const bought = await a.nextXt("ib"); + assert.deepStrictEqual(bought.slice(2, 4), ["1", "5"]); + assert.ok(Number(bought[4]) <= 10000000); + a.xt("ib", denId, 5, 1, 1, 0, 0, -1, ""); // a body part, not clothing + assert.strictEqual((await a.nextXt("ib"))[2], "0"); + + a.xt("iu", denId, 1, 0, itemInv); + assert.strictEqual((await a.nextXt("iu"))[2], "1"); + // her own game redraws her animal from this, not from the reply. + assert.deepStrictEqual((await a.nextXt("il")).slice(2), ["3", "1", "1", "Alice", "0", "1", "0", itemInv, itemDef]); + const worn = await c.nextXt("il"); + assert.deepStrictEqual(worn.slice(2, 6).concat(worn.slice(8, 11)), ["1", "0", "1", "Alice", "1", itemDef, itemInv]); + a.xt("il", denId, "Alice", 1, 1); + const full = await a.nextXt("il"); + assert.deepStrictEqual(full.slice(8), ["1", itemDef, itemInv, full[11], "2", "0"]); // "2" = bit 1 = avInvId 1 + + // --- trade list: put the item up, see it, a trade request is declined + a.xt("ts", denId, 0, 1, 0, itemInv); + assert.deepStrictEqual((await a.nextXt("tl")).slice(2, 7), ["Alice", "1", itemDef, itemInv, full[11]]); + c.xt("tl", denId, "alice"); + assert.deepStrictEqual((await c.untilXt("tl")).slice(2, 5), ["Alice", "1", itemDef]); + + // --- a trade: Carol offers an item of hers for Alice's listed one + c.xt("ib", denId, 5, 1, shop[10], 0, 0, -1, ""); + const carolItemInv = (await c.untilXt("il"))[9]; + await c.nextXt("ib"); + c.xt("ti", denId, 0, "Alice", 0, 999999, 1, 0, 0, 0, carolItemInv); // not an item Alice has + assert.deepStrictEqual((await c.nextXt("ti")).slice(2), ["3", "Alice", "1"]); + c.xt("ti", denId, 0, "Alice", 0, itemInv, 1, 0, 0, 0, carolItemInv); + const request = await a.nextXt("ti"); + assert.deepStrictEqual(request.slice(2, 10), ["0", "Carol", "1", request[5], itemInv, "1", "0", "0"]); + assert.strictEqual(request[10], shop[10]); + a.xt("ti", denId, 1, 0); // declined + assert.deepStrictEqual((await c.nextXt("ti")).slice(2), ["2", "Alice", "1"]); + c.xt("ti", denId, 0, "Alice", 0, itemInv, 1, 0, 0, 0, carolItemInv); + await a.nextXt("ti"); + a.xt("ti", denId, 1, 1); // accepted + assert.deepStrictEqual((await a.nextXt("ti")).slice(2), ["1", "0"]); + assert.deepStrictEqual((await c.nextXt("ti")).slice(2), ["1", "0"]); + a.xt("ti", denId, 3, 1); + c.xt("ti", denId, 3, 1); + const carolGot = await c.nextXt("ti"); + assert.deepStrictEqual(carolGot.slice(2, 7).concat(carolGot.slice(9)), ["1", "1", "1", "0", itemDef, "1", "0", carolItemInv]); + const aliceGot = await a.nextXt("ti"); + assert.deepStrictEqual(aliceGot.slice(2, 7).concat(aliceGot.slice(9)), ["1", "1", "1", "0", shop[10], "1", "0", itemInv]); + a.xt("tl", denId, "Alice"); + assert.deepStrictEqual((await a.nextXt("tl")).slice(2, 4), ["Alice", "0"]); // the traded item left the list + const tradedInv = aliceGot[7]; + + a.xt("ap", denId, 1, 2, 3, 0); + assert.strictEqual((await a.nextXt("ap"))[2], "1"); + await c.nextXt("ar"); + assert.deepStrictEqual((await c.nextXt("ac")).slice(12, 15), ["1", "2", "3"]); + await c.nextXt("il"); + + a.xt("aa", denId, 15136, 15224, 15299, 4, -1, 0, 0); + const aa = await a.nextXt("aa"); + assert.strictEqual(aa[2], "1"); + a.xt("as", denId, aa[3]); + const switched = await a.nextXt("as"); + assert.deepStrictEqual(switched.slice(2, 4).concat(switched.slice(4, 8)), ["1", String(aliceId), aa[3], aa[4], "-1", "4"]); + assert.strictEqual(switched[11], "15136|15224|15299"); + assert.strictEqual((await c.nextXt("as")).length, switched.length + 7); + a.xt("al", denId, "Alice"); + assert.deepStrictEqual((await a.nextXt("al")).slice(5, 7), ["2", aa[3]]); + a.xt("ak", denId, aa[3]); // cannot remove the animal in use + assert.strictEqual((await a.nextXt("ak"))[2], "0"); + + a.xt("gl", denId, 312); + const petShop = await a.nextXt("gl"); + assert.strictEqual(petShop[3], "1046"); + assert.strictEqual(Number(petShop[8]) * 2, petShop.length - 9); + a.xt("gl", denId, 574); + assert.strictEqual((await a.nextXt("gl"))[8], "0"); + a.xt("pc", denId, 312, petShop[9], 0, 0, 15386, 15428, 0); + const pet = await a.nextXt("pc"); + assert.deepStrictEqual(pet.slice(2, 3).concat(pet.slice(6, 10)), ["1", petShop[9], "0", "0", "15386|15428"]); + a.xt("ps", denId, pet[5]); + assert.deepStrictEqual((await a.nextXt("ps")).slice(2), ["1", String(aliceId), pet[5]]); + assert.deepStrictEqual((await c.nextXt("ps")).slice(2, 8), ["1", String(aliceId), petShop[9], "0", "0", "15386|15428"]); + a.xt("pl", denId, "Alice"); + assert.deepStrictEqual((await a.nextXt("pl")).slice(2, 6), ["1", "Alice", "1", pet[5]]); + assert.match((await a.nextXt("pu"))[2], /^4294967295(,4294967295)*$/); + + // --- den items: buy, place (Carol sees it), recycle + a.xt("gl", denId, 9); + const denShop = await a.nextXt("gl"); + assert.strictEqual(denShop[3], "1030"); + assert.ok(Number(denShop[8]) > 5 && Number(denShop[8]) < 200); // the Mystery Emporium's shelf (lib/shopstock.js) + a.xt("db", denId, 0, 9, denShop[9], 0, 0, 0, 0, ""); + assert.deepStrictEqual((await a.nextXt("db")).slice(2, 3), ["1"]); + const denItems = await a.nextXt("di"); + assert.deepStrictEqual(denItems.slice(2, 5).concat(denItems.slice(6, 8)), ["0", "1", "0", denShop[9], "0"]); + const denInv = denItems[5]; + a.xt("ds", denId, 1, 0, denInv, 1, 250, 260, 1, "off", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + assert.deepStrictEqual((await a.nextXt("dss")).slice(2), [denInv]); + assert.deepStrictEqual((await c.nextXt("ds")).slice(2, 12), ["1", "0", "0", denInv, denShop[9], "1", "250", "260", "0", "1"]); + a.xt("dp", denId, 1, "Carol"); + assert.deepStrictEqual((await a.nextXt("dp")).slice(2), ["Carol", "2"]); // 2 = open to everyone + + // --- den rooms: buy a second den and switch to it (the visitor follows); lock the den + a.xt("gl", denId, 13); + const denRooms = await a.nextXt("gl"); + assert.strictEqual(denRooms[3], "1040"); + const newDenDef = denRooms.slice(9).find(id => id !== "1"); + a.xt("db", denId, -1, 13, newDenDef, 0, 0); + assert.deepStrictEqual((await a.nextXt("db")).slice(2, 3), ["1"]); + const denList = await a.nextXt("dl"); + assert.deepStrictEqual([denList[2], denList[3], denList[4], denList[6]], ["2", "0", "1", newDenDef]); + a.xt("dc", denId, denList[5]); + assert.deepStrictEqual((await a.nextXt("dc")).slice(2, 3), [newDenDef]); + const moved = await c.nextXt("rp"); + assert.deepStrictEqual([moved[4], moved[5]], ["2", newDenDef]); // room type 2 = den, then the den type + assert.deepStrictEqual((await c.nextXt("ds")).slice(2, 3), ["0"]); // the furniture stayed in the first den + assert.deepStrictEqual((await a.nextXt("ds")).slice(2, 3), ["0"]); + a.xt("dc", denId, 0); + await a.nextXt("dc"); + await c.nextXt("rp"); + assert.deepStrictEqual((await c.nextXt("ds")).slice(2, 3), ["1"]); + await a.nextXt("ds"); + a.xt("dp", denId, 0, 0); + { + const stranger = new GameClient(); + await stranger.connect(); + await stranger.logIn("Dave", (await (await postJson(`${BASE}/authenticate`, {username: "Dave", password: "DavePass01"})).json()).auth_token); + stranger.xt("dj", 1, "denAlice", 1, -1); + assert.strictEqual((await stranger.nextXt("rj"))[2], "0"); + stranger.socket.destroy(); + } + a.xt("dp", denId, 0, 2); + a.xt("dr", denId, 0, denInv); + assert.deepStrictEqual((await a.nextXt("dr")).slice(2, 3).concat((await c.nextXt("ds")).slice(2, 3)), ["1", "0"]); + await a.nextXt("di"); // what the recycling window waits for + + a.xt("ir", denId, tradedInv); + const recycled = await a.nextXt("ir"); + assert.deepStrictEqual([recycled[2], recycled[4]], ["1", tradedInv]); + // the recycling window waits for the list to change before it closes. + const gone = await a.nextXt("il"); + assert.deepStrictEqual([gone[2], gone[5], ...gone.slice(7)], ["2", "Alice", "0", "1", tradedInv]); + + // --- item finder: search by name and id, give to a connected player + assert.match(await (await fetch(`${BASE}/shop`)).text(), /Item finder/); + const found = await (await fetch(`${BASE}/api/search?q=top+hat&kind=clothing`)).json(); + assert.ok(found.total > 0 && found.results.every(item => /top/i.test(item.name) && /hat/i.test(item.name))); + const hat = found.results[0]; + assert.strictEqual((await (await fetch(`${BASE}/api/search?q=${hat.id}`)).json()).results[0].id, hat.id); + assert.ok((await (await fetch(`${BASE}/api/accounts`)).json()).some(entry => entry.username === "Alice" && entry.online)); + assert.strictEqual((await fetch(`${BASE}/api/accounts`, {headers: {Origin: "https://example.com"}})).status, 403); + const giveJson = body => fetch(`${BASE}/api/give`, {method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify(body)}); + assert.strictEqual((await giveJson({username: "Alice", kind: "clothing", id: hat.id, colorIndex: 0})).status, 200); + const pushed = await a.nextXt("il"); + assert.deepStrictEqual([pushed[2], pushed[10]], ["2", String(hat.id)]); + assert.strictEqual((await giveJson({username: "Alice", kind: "clothing", id: 1})).status, 400); + assert.strictEqual((await giveJson({username: "Nobody", kind: "den", id: 6})).status, 404); + assert.strictEqual((await giveJson({username: "Alice", kind: "den", id: 6})).status, 200); + assert.deepStrictEqual((await a.nextXt("di")).slice(3, 4), ["1"]); + + // --- no game account has admin powers: "foo" is an ordinary player now + const foo = await (await postJson(`${BASE}/authenticate`, {username: "foo", password: "Password04"})).json(); + const f = new GameClient(); + await f.connect(); + const fooLogin = await f.logIn("foo", foo.auth_token); + assert.strictEqual(fooLogin.params.accountType, 2); + f.xt("rj", 1, "jamaa_township.room_main#1", 1, 0, 0); + const fooRoom = (await f.nextXt("rj"))[4]; + await f.nextXt("rp"); + f.send(``); + assert.deepStrictEqual((await f.nextXt("uc")).slice(3), ["!gems alice 5", "0"]); // just chat + f.xt("fb", fooRoom, "Carol", 7200, 0, ""); + assert.deepStrictEqual((await f.nextXt("fb")).slice(2), ["0"]); + f.xt("fk", fooRoom, "Alice", ""); + assert.deepStrictEqual((await f.nextXt("fk")).slice(2), ["0"]); + + // --- the admin panel: first-time password, then everything behind it + const panel = async (pathname, body, cookie, headers = {}) => { + const response = await fetch(`${BASE}/admin/api/${pathname}`, { + method: body === undefined ? "GET" : "POST", + headers: {"Content-Type": "application/json", ...(cookie ? {Cookie: cookie} : {}), ...headers}, + body: body === undefined ? undefined : JSON.stringify(body), + }); + return {status: response.status, data: await response.json(), cookie: (response.headers.get("set-cookie") || "").split(";")[0]}; + }; + assert.match(await (await fetch(`${BASE}/admin`)).text(), /Server admin/); + assert.deepStrictEqual((await panel("state")).data, {needsSetup: true, needsSetupCode: false, signedIn: false}); + assert.strictEqual((await panel("overview")).status, 401); + assert.strictEqual((await panel("login", {password: "anything"})).status, 401); + assert.strictEqual((await panel("setup", {password: "short"})).status, 400); + const setup = await panel("setup", {password: "admin-password-1"}); + assert.strictEqual(setup.status, 200); + assert.match(setup.cookie, /^ajc_admin=[0-9a-f]{48}$/); + assert.strictEqual((await panel("setup", {password: "another-password"})).status, 409); // only once + assert.strictEqual((await panel("login", {password: "wrong-password"})).status, 401); + const admin = (await panel("login", {password: "admin-password-1"})).cookie; + assert.strictEqual((await panel("state", undefined, admin)).data.signedIn, true); + assert.strictEqual((await panel("account", {username: "Alice", action: "kick"}, admin, {Origin: "http://evil.example"})).status, 403); + + const seen = (await panel("overview", undefined, admin)).data; + assert.ok(seen.stats.online >= 3 && seen.stats.accounts >= 5 && seen.players.some(player => player.username === "foo")); + const listed = (await panel("accounts", undefined, admin)).data.accounts; + assert.strictEqual(listed.find(account => account.username === "Alice").online, true); + assert.ok((await panel("logs?filter=%5Badmin%5D", undefined, admin)).data.lines.some(line => line.text.includes("admin password chosen"))); + + assert.strictEqual((await panel("account", {username: "Nobody", action: "kick"}, admin)).status, 404); + assert.strictEqual((await panel("account", {username: "Alice", action: "gems", amount: -5}, admin)).status, 200); + assert.deepStrictEqual((await a.untilXt("cu")).slice(2, 3), ["0"]); + assert.strictEqual((await panel("account", {username: "Alice", action: "message", text: "hello from the panel"}, admin)).status, 200); + + assert.deepStrictEqual((await a.untilXt("fd")).slice(2, 4), ["fp", "hello from the panel"]); + + // --- last seen: a card carries the time its player left, -2 while they + // are online, and the panel can set it for testing + const cardOf = async name => { + a.xt("ag", denId, name, 0); + return Number((await a.untilXt("ag"))[7]); + }; + assert.strictEqual(await cardOf("Alice"), -2); + assert.ok(Math.abs(await cardOf("Dave") - Date.now() / 1000) < 600); // he left moments ago + const threeDaysAgo = Math.floor(Date.now() / 1000) - 3 * 86400; + assert.strictEqual((await panel("account", {username: "Dave", action: "lastSeen", when: threeDaysAgo}, admin)).status, 200); + assert.strictEqual(await cardOf("Dave"), threeDaysAgo); + assert.strictEqual((await panel("account", {username: "Dave", action: "lastSeen", when: threeDaysAgo + 30 * 86400}, admin)).status, 400); // not the future + + assert.strictEqual((await panel("account", {username: "Carol", action: "ban", hours: 2}, admin)).status, 200); + assert.deepStrictEqual((await c.untilXt("fd")).slice(2), ["fb", "1", "7200"]); + // A player card asks whether its player is banned, for its red label. + a.xt("xbn", denId, "carol"); + const banned = await a.untilXt("xbn"); + assert.ok(banned[2] === "Carol" && Number(banned[3]) > 7190 && Number(banned[3]) <= 7200); + a.xt("xbn", denId, "Alice"); + const notBanned = await a.untilXt("xbn"); + assert.deepStrictEqual(notBanned.slice(2, 4), ["Alice", "0"]); + assert.ok(Number(notBanned[4]) > 1700000000); // and when she joined + assert.deepStrictEqual(notBanned.slice(5), ["", "early|Early Member", ""]); // no Discord username; the badge of the first hundred accounts; no bio (lib/badges.js) + assert.strictEqual((await fetch(`${BASE}/ban-icon.png`)).headers.get("content-type"), "image/png"); + const carolAgain = new GameClient(); + await carolAgain.connect(); + const refused = await carolAgain.logIn("Carol", carol.auth_token); + assert.deepStrictEqual([refused.status, refused.statusId], ["0", -15]); + carolAgain.socket.destroy(); + assert.ok((await panel("accounts", undefined, admin)).data.accounts.find(account => account.username === "Carol").banned > 7000); + + // A new username: buddies follow it, the player is disconnected, and the + // same password works under the new name. + assert.deepStrictEqual((await panel("account", {username: "Bob", action: "rename", newName: "alice"}, admin)).data, {error: "That username is taken."}); + for (const unusable of ["", " ", "50% off", "tab\there", "x".repeat(101)]) { + assert.strictEqual((await panel("account", {username: "Bob", action: "rename", newName: unusable}, admin)).status, 400); + } + // names sign-up would refuse are fine from the panel, and can log in. + for (const odd of ["x", "~*Bob*~ <3", "Ünïcødé 名前", "a name well past twenty characters"]) { + assert.strictEqual((await panel("account", {username: "Bob", action: "rename", newName: odd}, admin)).status, 200); + assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: odd, password: "Password02"})).status, 200); + assert.strictEqual((await panel("account", {username: odd, action: "rename", newName: "Bob"}, admin)).status, 200); + } + assert.strictEqual((await registerJson({username: "x", password: "Password09"})).status, 400); // sign-up rules unchanged + const renamed = await panel("account", {username: "Bob", action: "rename", newName: "Robert"}, admin); + assert.deepStrictEqual([renamed.status, renamed.data.username], [200, "Robert"]); + assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "Bob", password: "Password02"})).status, 401); + assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "robert", password: "Password02"})).status, 200); + assert.ok(!(await panel("accounts", undefined, admin)).data.accounts.some(account => account.username === "Bob")); + assert.strictEqual((await panel("account", {username: "Robert", action: "rename", newName: "ROBERT"}, admin)).status, 200); + assert.strictEqual((await panel("account", {username: "robert", action: "rename", newName: "Bob"}, admin)).status, 200); + + // A new password for a player: the old one and old tokens stop working. + assert.strictEqual((await panel("account", {username: "foo", action: "password", password: "short"}, admin)).status, 400); + assert.strictEqual((await panel("account", {username: "foo", action: "password", password: "New-password-4"}, admin)).status, 200); + assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "foo", password: "Password04"})).status, 401); + assert.strictEqual((await postJson(`${BASE}/authenticate`, {refresh_token: foo.refresh_token})).status, 401); + assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "foo", password: "New-password-4"})).status, 200); + assert.strictEqual((await panel("account", {username: "foo", action: "delete"}, admin)).status, 200); + assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "foo", password: "New-password-4"})).status, 401); + + // changing the admin password signs every other session out. + assert.strictEqual((await panel("password", {current: "nope", password: "admin-password-2"}, admin)).status, 403); + const changed = await panel("password", {current: "admin-password-1", password: "admin-password-2"}, admin); + assert.strictEqual(changed.status, 200); + assert.strictEqual((await panel("overview", undefined, admin)).status, 401); + assert.strictEqual((await panel("overview", undefined, changed.cookie)).status, 200); + assert.strictEqual((await panel("logout", {}, changed.cookie)).status, 200); + assert.strictEqual((await panel("overview", undefined, changed.cookie)).status, 401); + + // --- diamonds + // Items priced in diamonds are bought by their diamond def id: 76 is a + // clothing item, 3457 a den item and 3436 a den room. + a.xt("gl", denId, 415); // the Diamond Shop's clothing + const diamondShop = await a.untilXt("gl"); + assert.deepStrictEqual(diamondShop.slice(3, 5), ["1054", ""]); + assert.ok(Number(diamondShop[8]) > 20 && Number(diamondShop[8]) === diamondShop.length - 9); + a.xt("gl", denId, 293); + assert.deepStrictEqual((await a.untilXt("gl")).slice(3, 9), ["1054", "", "0", "0", "0", "0"]); + // A shop nothing is known of has empty shelves, whatever its kind. + for (const [unknownShop, kind] of [[390, "1030"], [338, "1000"], [796, "1054"]]) { + a.xt("gl", denId, unknownShop); + assert.deepStrictEqual((await a.untilXt("gl")).slice(3, 9), [kind, "", "0", "0", "0", "0"]); + } + a.xt("gl", denId, 794); + assert.deepStrictEqual((await a.untilXt("gl")).slice(8), ["1", "1030", "0"]); + a.xt("ib", denId, 11, 1, 76, 0, 1, -1, ""); + assert.strictEqual((await a.untilXt("il"))[10], "584"); + assert.deepStrictEqual((await a.untilXt("ib")).slice(2), ["1", "11", "9999999", "3"]); + a.xt("db", denId, 0, 234, 3457, 0, 1, 0, 0, ""); + assert.deepStrictEqual((await a.untilXt("db")).slice(2), ["1", "9999998", "0", "3", "0"]); + assert.ok((await a.untilXt("di")).includes("5755")); + a.xt("db", denId, -1, 384, 3436, 1, 1); + assert.deepStrictEqual((await a.untilXt("db")).slice(2), ["1", "9999991", "0", "3", "0"]); + assert.strictEqual((await a.untilXt("dl")).at(-1), "58"); + a.xt("ib", denId, 11, 1, 3436, 0, 1, -1, ""); // a den room's diamond def is not clothing + assert.strictEqual((await a.untilXt("ib"))[2], "0"); + + // --- tutorials stay switched off, seasonal themes, custom colour ids + a.xt("zs", denId, 379, 2, 1); // the client names the bit it wants set + assert.deepStrictEqual((await a.untilXt("zs")).slice(2), ["379", "65535", "0"]); + a.xt("rj", denId, "sarepia.room_main#1", 1, 0, 0); + await a.untilXt("rj"); + assert.strictEqual((await a.untilXt("rp"))[2], "sarepia.room_main"); + const themeJson = theme => fetch(`${BASE}/api/theme`, {method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({username: "Alice", theme})}); + assert.strictEqual((await themeJson("easter")).status, 400); + assert.strictEqual((await themeJson("jamaalidays")).status, 200); + // reloaded where she stands, from the December build's files. + assert.strictEqual((await a.untilXt("rp"))[2], "theme_1810.sarepia.room_main"); + // an older design is a build too, or another room file of one. + assert.strictEqual((await themeJson("fall2022")).status, 200); + assert.strictEqual((await a.untilXt("rp"))[2], "theme_1636.sarepia.room_main"); + assert.strictEqual((await themeJson("freedom2021")).status, 200); + assert.strictEqual((await a.untilXt("rp"))[2], "theme_1824.sarepia.room_main_freedom"); + assert.strictEqual((await themeJson("friendship2018")).status, 200); + assert.strictEqual((await a.untilXt("rp"))[2], "theme_1815.sarepia.room_main"); // not one of its rooms + const roomFile = name => `roomDefs/${name}sarepia/${crypto.createHash("md5").update("placeholder").digest("hex")}`; + assert.strictEqual((await fetch(`${BASE}/1830/${roomFile("theme_9999/")}`)).status, 404); + assert.strictEqual((await themeJson("")).status, 200); + assert.strictEqual((await giveJson({username: "Alice", kind: "clothing", id: hat.id, color: "123456789"})).status, 200); + await a.untilXt("il"); + a.xt("il", denId, "Alice", 1, 1); + assert.ok((await a.untilXt("il")).includes("123456789")); + assert.strictEqual((await giveJson({username: "Alice", kind: "clothing", id: hat.id, color: "-5"})).status, 400); + + // --- the item defs clients get: ocean eyes (314) allowed on every animal + const {decode} = require("../lib/amf3.js"); + const zlib = require("zlib"); + const itemDefsPath = require("../lib/cdn.js").hashedPath("defPacks/1000"); + const servedDefs = decode(zlib.inflateRawSync(Buffer.from(await (await fetch(`${BASE}/${itemDefsPath}?v=4`)).arrayBuffer()))); + const servedById = Object.fromEntries(Object.values(servedDefs).map(def => [def.id, def])); + assert.strictEqual(servedById[314].avatarUseFlags, "9007199254740991"); + // ... and every piece of clothing wearable by every animal. + assert.ok(Object.values(servedDefs).filter(def => def.type === "1").every(def => def.avatarUseFlags === "9007199254740991")); + assert.strictEqual(servedById[316].avatarUseFlags, "12453376"); // an ocean pattern: untouched + assert.strictEqual(Object.keys(servedDefs).length, 4497); + a.xt("iu", denId, 1, 0, -314); + assert.strictEqual((await a.untilXt("iu"))[2], "1"); + + // --- the custom client's login choices: honoured for that session only + assert.strictEqual((await (await fetch(`${BASE}/flashvars`)).json()).loginChoices, true); + const chosen = await (await postJson(`${BASE}/authenticate`, {username: "Carol", password: "Password03", + login_choices: {accountType: 0, isGuide: true, membershipDays: 12, isModerator: "yes"}})).json(); + // (Carol is banned from the game by now, so only the web side is checked.) + assert.strictEqual((await (await fetch(`${BASE}/player`, {headers: {Authorization: `Bearer ${chosen.auth_token}`}})).json()).game_account_type, 0); + a.xt("ag", denId, "Carol", 0); + assert.deepStrictEqual((await a.untilXt("ag")).slice(5, 7), ["0", "1"]); // account type, guide + await postJson(`${BASE}/authenticate`, {username: "Carol", password: "Password03"}); // and back to normal + a.xt("ag", denId, "Carol", 0); + assert.deepStrictEqual((await a.untilXt("ag")).slice(5, 7), ["2", "0"]); + + // --- custom colours: an id for four RGB values, announced to everyone + a.xt("xcc", denId, 0xff8800, 0x123456, 0, 0xffffff); + const colour = await a.untilXt("xcc"); + assert.deepStrictEqual(colour.slice(2), ["1", String(0xFD000000), "16746496", "1193046", "0", "16777215"]); + a.xt("xcc", denId, 0xff8800, 0x123456, 0, 0xffffff); // the same colours again + assert.strictEqual((await a.untilXt("xcc"))[3], String(0xFD000000)); + a.xt("xcc", denId, 0x1000000, 0, 0, 0); // not a colour + a.xt("ap", denId, 0xFD000000, 0, 0); + assert.strictEqual((await a.untilXt("ap"))[2], "1"); + const late = new GameClient(); + await late.connect(); + const dev = await (await postJson(`${BASE}/authenticate`, {username: "Alice", password: "Password01", login_choices: {accountType: 4, membershipDays: 7}})).json(); + const devLogin = await late.logIn("Alice", dev.auth_token); + assert.deepStrictEqual([devLogin.params.accountType, devLogin.params.numDaysLeftOnSubscription, devLogin.params.isGuide, devLogin.params.isModerator], [4, 7, false, false]); + assert.deepStrictEqual((await late.untilXt("xcc")).slice(2, 4), ["1", String(0xFD000000)]); // the table at login + late.socket.destroy(); + + c.socket.destroy(); + policy.socket.destroy(); +}; + +harness.withServer("smoke test", HTTP_PORT, GAME_PORT, run).catch(err => { + console.error(err); + process.exit(1); +}); diff --git a/tools/build-client.sh b/tools/build-client.sh new file mode 100755 index 0000000..2fb5d56 --- /dev/null +++ b/tools/build-client.sh @@ -0,0 +1,64 @@ +#!/bin/sh +# rebuilds swf/ajclient.swf: the untouched client (swf/ajclient.before-finder.swf) +# with every class in swf-src/ compiled over its original, by JPEXS (tools/ffdec, +# needs Java). the result is the same bytes every time. +# +# tools/build-client.sh [output.swf] (default: swf/ajclient.swf) +# +# A class added to swf-src/ needs a line below: its full name, then its file. +# +# one thing is not a whole class: gui.EmoticonUtility's static initialiser, +# as P-code, with our emote added to its lists (tools/make-emote.py). the +# decompiler gets two of that class's functions wrong, so the class cannot +# be compiled from its source. 4839 is that method body's place in the +# untouched client. +set -e +cd "$(dirname "$(readlink -f "$0")")/.." +out=${1:-swf/ajclient.swf} +set -- \ + AJClient AJClient.as \ + GlobalErrorCatch GlobalErrorCatch.as \ + XtReplyDemuxer XtReplyDemuxer.as \ + loader.MediaHelper MediaHelper.as \ + com.sbi.graphics.PaletteHelper PaletteHelper.as \ + gui.ColorTable ColorTable.as \ + gui.MySettings MySettings.as \ + gui.itemWindows.ItemWindowToggle ItemWindowToggle.as \ + gui.ReportAPlayer ReportAPlayer.as \ + gui.ECardCreation ECardCreation.as \ + gui.GuiManager GuiManager.as \ + gui.PlayerSearch PlayerSearch.as \ + avatar.NPCView NPCView.as \ + gui.ChatHistory ChatHistory.as \ + gui.PredictiveTextManager PredictiveTextManager.as \ + avatar.UserCommXtCommManager UserCommXtCommManager.as \ + buddy.BuddyCard BuddyCard.as \ + gui.itemWindows.ItemWindowPets ItemWindowPets.as \ + gui.itemWindows.ItemWindowAvtPetSml ItemWindowAvtPetSml.as \ + gui.itemWindows.ItemWindowBuddyList ItemWindowBuddyList.as \ + shop.Shop Shop.as \ + shop.ShopManager ShopManager.as \ + avatar.Avatar Avatar.as \ + gui.ChatBalloon ChatBalloon.as \ + room.RoomManagerView RoomManagerView.as \ + gui.itemWindows.ItemWindowOriginal ItemWindowOriginal.as \ + gui.itemWindows.ItemWindowAnimal ItemWindowAnimal.as \ + gui.DenAndClothesItemSelect DenAndClothesItemSelect.as \ + gui.RecycleItems RecycleItems.as \ + gui.AvatarEditor AvatarEditor.as \ + gui.PetInventory PetInventory.as \ + gui.DenEditor DenEditor.as \ + gui.TradeManager TradeManager.as \ + avatar.AvatarWorldView AvatarWorldView.as \ + room.RoomManagerWorld RoomManagerWorld.as \ + gskinner.motion.GTween GTween.as \ + playerWall.PostMessage PostMessage.as +args="" +while [ $# -gt 0 ]; do + args="$args $1 swf-src/$2" + shift 2 +done +# shellcheck disable=SC2086 +java -jar tools/ffdec/ffdec-cli.jar -replace swf/ajclient.before-finder.swf "$out" \ + gui.EmoticonUtility swf-src/EmoticonUtility.cinit.pcode 4839 $args | grep -v "^Replac\|EXPERIMENTAL" || true +ls -l "$out" diff --git a/tools/client-test.js b/tools/client-test.js new file mode 100644 index 0000000..6fc297b --- /dev/null +++ b/tools/client-test.js @@ -0,0 +1,27 @@ +// drives the custom client (~/aj-private-client) through a real login and +// saves a screenshot of the game view. it opens a window on the desktop. +// +// AJ_USER=name AJ_PASS=password [WAIT=55000] node tools/client-test.js shot.png +// +// extra arguments go to Electron. uses the Chrome DevTools Protocol. +const {spawn} = require("child_process"); const os = require("os"); const fs = require("fs"); +const PORT = 9336; const extra = process.argv.slice(3); const shotPath = process.argv[2]; +const child = spawn(os.homedir() + "/aj-private-client/run.sh", [`--remote-debugging-port=${PORT}`, "--enable-logging", ...extra], {stdio: ["ignore", "pipe", "pipe"]}); +let log = ""; child.stdout.on("data", d => log += d); child.stderr.on("data", d => log += d); +const sleep = ms => new Promise(r => setTimeout(r, ms)); +const connect = async target => { const ws = new WebSocket(target.webSocketDebuggerUrl); await new Promise((res, rej) => { ws.onopen = res; ws.onerror = rej; }); let id = 0; const pending = new Map(); ws.onmessage = m => { const d = JSON.parse(m.data); if (d.id && pending.has(d.id)) { pending.get(d.id)(d); pending.delete(d.id); } }; return (method, params = {}) => new Promise(res => { const i = ++id; pending.set(i, res); ws.send(JSON.stringify({id: i, method, params})); }); }; +const targets = async () => (await fetch(`http://127.0.0.1:${PORT}/json`)).json(); +const evalIn = async (send, expr) => { const r = await send("Runtime.evaluate", {expression: expr, awaitPromise: true, returnByValue: true}); return r.result.exceptionDetails ? "EXC" : r.result.result.value; }; +(async () => { + let list = []; for (let i = 0; i < 40; i++) { try { list = await targets(); if (list.some(t => t.url.includes("index.html"))) break; } catch (e) {} await sleep(300); } + const host = await connect(list.find(t => t.url.includes("index.html"))); + await sleep(800); + await evalIn(host, `document.getElementById('username').value=${JSON.stringify(process.env.AJ_USER)}; document.getElementById('password').value=${JSON.stringify(process.env.AJ_PASS)}; document.getElementById('log-in').click()`); + await sleep(Number(process.env.WAIT || 12000)); + console.log("game visible:", await evalIn(host, "!document.getElementById('game').hidden"), "status:", await evalIn(host, "document.getElementById('status').textContent")); + const g = (await targets()).find(x => x.type === "webview"); + if (g && shotPath !== "-") { const guest = await connect(g); const sh = await guest("Page.captureScreenshot", {format: "png"}); if (sh.result && sh.result.data) fs.writeFileSync(shotPath, Buffer.from(sh.result.data, "base64")); } + child.kill(); await sleep(300); + console.log(log.split("\n").filter(l => /ERROR|plugin|Plugin|flash|Flash|sandbox/i.test(l) && !/GetVSync|Security Warning/.test(l)).slice(0, 12).join("\n").slice(0, 1800)); + process.exit(0); +})().catch(e => { console.log("FAILED", e.message); child.kill(); process.exit(1); }); diff --git a/tools/find-art.py b/tools/find-art.py new file mode 100644 index 0000000..959add1 --- /dev/null +++ b/tools/find-art.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python3 +"""Finds artwork among the CDN's media files that the game used to be told +about by lists on the official servers: Jam-A-Gram cards, Jammer Wall +wallpapers and wall stickers. Prints the media ids of each. + + python3 tools/find-art.py [firstId] [lastId] (default 1 to 9500) + +A media file is a SWF, zlib ("CWS") or LZMA ("ZWS") compressed. What tells +them apart is the names of the clips inside: + + card a "msgTxt" text field and a "stamp" clip (ecard.ECardImageBase) + wallpaper a "postStatus" clip (playerWall.PlayerWallGui.onWallDecorItemLoaded) + sticker the ones found carry "sticker" in a symbol name + +That overshoots a little (a few windows of the game have the same names +inside), so the results were looked at, one picture each, before going into +lib/ecard-art.json and lib/wall-art.json. Two things had to be done by eye +altogether: stamps are plain pictures with nothing to tell them by (ids +10-23 are what sits next to the first cards), and each wallpaper's button in +the wall's "customize" popup is a separate file, usually numbered right after +or right before its batch of wallpapers. + +It downloads every file in the range (about 250 MB) without keeping any. +""" +import concurrent.futures +import hashlib +import lzma +import struct +import sys +import urllib.request +import zlib + +CONTENT = "https://ajcontent.akamaized.net/" +DEPLOY_VERSION = "1830" + + +def hashed(name): + """LoaderCache.hashItV2, as in lib/cdn.js.""" + salted = "W3 7r4Ck h4X0r3rs" + name + out = "" + for index, char in enumerate(salted): + out = out + char if index % 2 == 0 else char + out + return hashlib.md5(out.encode()).hexdigest() + + +def inflate(data): + if data[:3] == b"CWS": + return zlib.decompress(data[8:]) + if data[:3] == b"ZWS": + # ZWS: "ZWS", version, uncompressed length, compressed length, LZMA + # properties, data. the .lzma format wants properties, length, data. + size = struct.unpack(" 1 else 1 + last = int(sys.argv[2]) if len(sys.argv) > 2 else 9500 + results = {"card": [], "wallpaper": [], "sticker": []} + with concurrent.futures.ThreadPoolExecutor(16) as pool: + for media_id, found in pool.map(kinds, range(first, last + 1)): + for kind in found: + results[kind].append(media_id) + for kind, ids in results.items(): + print(kind, ids) + + +if __name__ == "__main__": + main() diff --git a/tools/hud/dump.py b/tools/hud/dump.py new file mode 100644 index 0000000..5c77d68 --- /dev/null +++ b/tools/hud/dump.py @@ -0,0 +1,85 @@ +import sys, pickle, os +import xml.etree.ElementTree as ET +here=os.path.dirname(os.path.abspath(__file__)) +pk=os.path.join(here,"hud.pickle") +if os.path.exists(pk): + D=pickle.load(open(pk,"rb")) +else: + root=ET.parse(os.path.join(here,"hud.xml")).getroot() + tags=root.find("tags") + D={"sprites":{}, "shapes":{}, "texts":{}, "names":{}} + def rect(e): + return tuple(int(e.get(k))/20 for k in ("Xmin","Ymin","Xmax","Ymax")) + for it in tags: + t=it.get("type") + if t=="SymbolClassTag": + ids=[int(x.text) for x in it.find("tags")] + names=[x.text for x in it.find("names")] + for i,n in zip(ids,names): D["names"][n]=i + elif t=="DefineSpriteTag": + sid=int(it.get("spriteId")) + frames=[]; cur={}; labels={} + disp={} + fi=0 + for st in it.find("subTags"): + tt=st.get("type") + if tt in ("PlaceObject2Tag","PlaceObject3Tag"): + depth=int(st.get("depth")) + prev=disp.get(depth,{}) + o=dict(prev) + if st.get("placeFlagHasCharacter")=="true": o["cid"]=int(st.get("characterId")) + if st.get("placeFlagHasName")=="true": o["name"]=st.get("name") + m=st.find("matrix") + if st.get("placeFlagHasMatrix")=="true" and m is not None: + o["x"]=int(m.get("translateX"))/20; o["y"]=int(m.get("translateY"))/20 + o["sx"]=float(m.get("scaleX")) if m.get("hasScale")=="true" else 1.0 + o["sy"]=float(m.get("scaleY")) if m.get("hasScale")=="true" else 1.0 + disp[depth]=o + elif tt=="RemoveObject2Tag": + disp.pop(int(st.get("depth")),None) + elif tt=="FrameLabelTag": + labels[st.get("name")]=fi + elif tt=="ShowFrameTag": + frames.append({d:dict(o) for d,o in disp.items()}); fi+=1 + D["sprites"][sid]={"frames":frames,"labels":labels} + elif t and t.startswith("DefineShape"): + D["shapes"][int(it.get("shapeId"))]=rect(it.find("shapeBounds")) + elif t=="DefineEditTextTag": + D["texts"][int(it.get("characterID"))]=(rect(it.find("bounds")), it.get("variableName"), it.get("initialText"), it.get("fontHeight")) + pickle.dump(D,open(pk,"wb")) +def bounds(cid, frame=0, seen=()): + if cid in D["shapes"]: return D["shapes"][cid] + if cid in D["texts"]: return D["texts"][cid][0] + sp=D["sprites"].get(cid) + if not sp or not sp["frames"] or cid in seen: return None + b=None + for o in sp["frames"][min(frame,len(sp["frames"])-1)].values(): + if "cid" not in o: continue + cb=bounds(o["cid"],0,seen+(cid,)) + if not cb: continue + x=o.get("x",0); y=o.get("y",0); sx=o.get("sx",1); sy=o.get("sy",1) + xs=sorted([x+cb[0]*sx,x+cb[2]*sx]); ys=sorted([y+cb[1]*sy,y+cb[3]*sy]) + r=(xs[0],ys[0],xs[1],ys[1]) + b=r if b is None else (min(b[0],r[0]),min(b[1],r[1]),max(b[2],r[2]),max(b[3],r[3])) + return b +def fmt(b): return "?" if not b else "[%.0f,%.0f %.0fx%.0f]"%(b[0],b[1],b[2]-b[0],b[3]-b[1]) +def dump(cid, depth, maxd, frame=0, ind=""): + sp=D["sprites"].get(cid) + if not sp: return + if sp["labels"]: print(ind+" labels:", ",".join(f"{k}@{v}" for k,v in list(sp["labels"].items())[:30]), "frames", len(sp["frames"])) + for d,o in sorted(sp["frames"][min(frame,len(sp["frames"])-1)].items()): + c=o.get("cid"); kind="sprite" if c in D["sprites"] else "text" if c in D["texts"] else "shape" + extra="" + if kind=="text": extra=" text=%r h=%s"%(D["texts"][c][2], D["texts"][c][3]) + print(f'{ind} d{d} {o.get("name","-")} ({kind} {c}) at {o.get("x",0):.0f},{o.get("y",0):.0f} scale {o.get("sx",1):.2f},{o.get("sy",1):.2f} bounds {fmt(bounds(c))}{extra}') + if kind=="sprite" and depth2 else 2; frame=sys.argv[3] if len(sys.argv)>3 else "0" + if name=="--list": + for n in sorted(D["names"]): + if maxd==0 or sys.argv[3].lower() in n.lower(): print(n, D["names"][n], fmt(bounds(D["names"][n]))) + sys.exit() + cid=D["names"][name]; sp=D["sprites"][cid] + f=sp["labels"].get(frame, int(frame) if frame.isdigit() else 0) + print(name,"id",cid,"bounds",fmt(bounds(cid,f)),"frame",f) + dump(cid,0,maxd,f) diff --git a/tools/hud/transplant-nametag.py b/tools/hud/transplant-nametag.py new file mode 100644 index 0000000..b3e9b63 --- /dev/null +++ b/tools/hud/transplant-nametag.py @@ -0,0 +1,168 @@ +"""transplant-nametag.py old.xml now.xml out.xml + +Puts the name tags of the March 2014 HUDAssets.swf into today's. Both files +are given as the XML `ffdec-cli -swf2xml` writes; the result goes back +through `-xml2swf`. Everything is found by symbol and instance name, so it +does not depend on either file's character ids. + +What changes, and only this: + + member tag The 2014 left cap and bar ("e" and "n" of memberNameBar, a + clip each with one hand-drawn frame per colour) are copied + in under new ids and added as a child named "old" on top of + what today's "e" and "m" already hold. Nothing of today's is + taken out: avatar.NameBar reaches into those two for a child + called "mouse", and no login survives its absence. The old + clips carry the same offsets inside as today's parts, so + they go in at 0,0. swf-src/hud/memberNameBar.as shows the + right frame and hides today's drawing. + picker The ten samples in the animal editor (namebar_Cont): + the "up" and "mouse" drawings inside each one's "mouse" clip + are swapped for the 2014 ones, which sit at the same places. + free tag Its drawing has not changed since 2014, pixel for pixel; the + name on it was in the regular weight then and is bold now. + The text field goes back to the regular font. +""" +import re +import sys +import xml.etree.ElementTree as ET + +old_path, now_path, out_path = sys.argv[1:4] +COLOURS = ["black", "blue", "brown", "gold", "green", "pink", "purple", "red", "teal", "white"] +OLD_DEPTH = 40 # above the parts already in today's cap and bar +ID_ATTRS = ("spriteId", "shapeId", "characterId", "characterID", "bitmapId", "fontId", "buttonId") + + +def read(path): + """-> (definitions by character id, character id by symbol name)""" + tags = ET.parse(path).getroot().find("tags") + defs, names = {}, {} + for item in tags: + kind = item.get("type", "") + if kind == "SymbolClassTag": + ids = [entry.text for entry in item.find("tags")] + for cid, name in zip(ids, (entry.text for entry in item.find("names"))): + names[name] = cid + elif kind.startswith("Define"): + for attr in ("spriteId", "shapeId", "characterID", "buttonId", "fontId"): + if item.get(attr): + defs.setdefault(item.get(attr), item) + return defs, names + + +def child(defs, sprite_id, name): + """Character id of the child called `name` on a sprite's first frame.""" + for tag in defs[sprite_id].find("subTags"): + if tag.get("type") == "ShowFrameTag": + break + if tag.get("name") == name and tag.get("characterId"): + return tag.get("characterId") + raise SystemExit(f"sprite {sprite_id} has no child called {name}") + + +old, old_names = read(old_path) +now, now_names = read(now_path) + +wanted = {} +old_tag, now_tag = old_names["memberNameBar"], now_names["memberNameBar"] +add_old = { # today's sprite -> the 2014 clip it gets as "old" + child(now, now_tag, "e"): child(old, old_tag, "e"), + child(now, now_tag, "m"): child(old, old_tag, "n"), +} +retarget = {} # (today's sprite, child name) -> the 2014 character to place there +for colour in COLOURS: + symbol = f"namebar_{colour}Cont" + old_states = child(old, old_names[symbol], "mouse") + now_states = child(now, now_names[symbol], "mouse") + for state in ("up", "mouse"): + retarget[(now_states, state)] = child(old, old_states, state) +for cid in list(add_old.values()) + list(retarget.values()): + wanted[cid] = True + + +def references(element): + found = set() + for sub in element.iter(): + if sub is element: + continue + for attr in ("characterId", "bitmapId", "fontId"): + value = sub.get(attr) + if value and value != "65535": + found.add(value) + return found + + +order, seen = [], set() + + +def visit(cid): + if cid in seen: + return + if cid not in old: + raise SystemExit(f"the 2014 file has no definition for character {cid}") + seen.add(cid) + for ref in sorted(references(old[cid]), key=int): + visit(ref) + order.append(cid) # what a thing is made of comes before it + + +for cid in wanted: + visit(cid) +kinds = {} +for cid in order: + kinds[old[cid].get("type")] = kinds.get(old[cid].get("type"), 0) + 1 +print("copying", len(order), "definitions:", kinds) + +text = open(now_path, encoding="utf8").read() +highest = max(int(value) for value in re.findall(r'(?:spriteId|shapeId|characterID|buttonId|fontId|characterId)="(\d+)"', text) if int(value) < 60000) +new_id = {cid: str(highest + 1 + index) for index, cid in enumerate(order)} +chunks = [] +for cid in order: + element = old[cid] + for sub in element.iter(): + for attr in ID_ATTRS: + if sub.get(attr) in new_id: + sub.set(attr, new_id[sub.get(attr)]) + chunks.append(ET.tostring(element, encoding="unicode").strip()) + + +def sprite_span(source, sprite_id): + """(start, end) of a sprite's definition in the XML text.""" + start = re.search(r'[ \t]*]*spriteId="%s"[^>]*>' % sprite_id, source) + assert start, f"sprite {sprite_id} not found in today's file" + indent = re.match(r'[ \t]*', start.group(0)).group(0) + closing = "\n" + indent + "" + return start.start(), source.index(closing, start.end()) + len(closing) + + +free_text = child(now, child(now, now_names["FreeNameBar"], "c"), "txt") +field = re.search(r']*characterID="%s"[^>]*>' % free_text, text) +assert field and 'fontClass="CCDigitalDeliveryBold"' in field.group(0) +plain = field.group(0).replace('fontClass="CCDigitalDeliveryBold"', 'fontClass="CCDigitalDeliveryRegular"').replace("<b>", "").replace("</b>", "") +text = text[:field.start()] + plain + text[field.end():] + +for (sprite_id, name), old_cid in retarget.items(): + start, end = sprite_span(text, sprite_id) + sprite = text[start:end] + pattern = re.compile(r'(]*?)characterId="\d+"([^>]*?name="%s")' % name) + sprite, count = pattern.subn(lambda match: f'{match.group(1)}characterId="{new_id[old_cid]}"{match.group(2)}', sprite) + assert count == 1, (sprite_id, name, count) + text = text[:start] + sprite + text[end:] + +for sprite_id, old_cid in add_old.items(): + start, end = sprite_span(text, sprite_id) + show = text.index('' + '\n ') % (new_id[old_cid], OLD_DEPTH) + text = text[:show] + place + text[show:] + +first = min(sprite_span(text, sprite_id)[0] for sprite_id in list(add_old) + [key[0] for key in retarget]) +indent = re.match(r'[ \t]*', text[first:]).group(0) +text = text[:first] + "".join(indent + chunk + "\n" for chunk in chunks) + text[first:] +open(out_path, "w", encoding="utf8").write(text) +print("written", out_path) diff --git a/tools/make-badges.py b/tools/make-badges.py new file mode 100644 index 0000000..aa81153 --- /dev/null +++ b/tools/make-badges.py @@ -0,0 +1,362 @@ +#!/usr/bin/env python3 +"""Makes the pictures of the badges the admin gives (lib/badges.js), both +forms of each from one outline: + + swf/badges/.swf the name tag badge: the outline alone, in grey, + which the name tag tints with its own colour + public/badges/.png the badge on player cards: the outline in white on + a round disc of the badge's colour + + python3 tools/make-badges.py + +Needs Java, for tools/ffdec, and nothing else. The workdir gets the files +in between and sheet.png, every badge at a size to look at. + +A name tag badge is a small media file: an unseen square to point at +("iconBA") and one shape. This takes the game's star badge (media 700, +from cache/), swaps the star's outline for another and names the symbol +after it. + +An outline is a list of closed paths of straight edges, drawn below in any +units with y downwards; each is a solid piece or a hole in one. Paths must +not cross or overlap each other. +""" +import hashlib +import math +import os +import re +import struct +import subprocess +import sys +import zlib + +HERE = os.path.dirname(os.path.abspath(__file__)) +ROOT = os.path.dirname(HERE) +FFDEC = os.path.join(HERE, "ffdec", "ffdec-cli.jar") +DEPLOY_VERSION = "1830" +STAR = "700" +TAG_HALF = 6.0 # how far a name tag badge reaches from its middle, in pixels: 80% of the star's 7.5 +CARD_SIZE = 48 # the card's picture, drawn at a third of this +CARD_HALF = 12.5 # how far the outline reaches from the middle of that + + +def hashed(name): + """LoaderCache.hashItV2, as in lib/cdn.js.""" + salted = "W3 7r4Ck h4X0r3rs" + name + out = "" + for index, char in enumerate(salted): + out = out + char if index % 2 == 0 else char + out + return hashlib.md5(out.encode()).hexdigest() + + +def arc(cx, cy, radius, start, end, steps): + """Points along a circle, angles in degrees, y downwards.""" + return [(cx + radius * math.cos(math.radians(start + (end - start) * step / steps)), + cy + radius * math.sin(math.radians(start + (end - start) * step / steps))) for step in range(steps + 1)] + + +def circle(cx, cy, radius, steps=16): + return arc(cx, cy, radius, 0, 360, steps)[:-1] + + +def curve(start, control, end, steps): + """Points along a quadratic curve, without its start.""" + points = [] + for step in range(1, steps + 1): + t = step / steps + points.append(tuple((1 - t) ** 2 * a + 2 * (1 - t) * t * b + t ** 2 * c for a, b, c in zip(start, control, end))) + return points + + +def mirrored(points): + return [(-x, y) for x, y in reversed(points)] + + +def turned(points, degrees): + turn = math.radians(degrees) + return [(x * math.cos(turn) - y * math.sin(turn), x * math.sin(turn) + y * math.cos(turn)) for x, y in points] + + +def bar(x1, y1, x2, y2, width): + """A straight stroke from one point to another.""" + length = math.hypot(x2 - x1, y2 - y1) + nx, ny = -(y2 - y1) / length * width / 2, (x2 - x1) / length * width / 2 + return [(x1 + nx, y1 + ny), (x2 + nx, y2 + ny), (x2 - nx, y2 - ny), (x1 - nx, y1 - ny)] + + +# each returns [(points, is_hole), ...]. + +def crown(): + return [([(-6.4, 5.6), (-7.5, -3.6), (-3.4, 0.2), (0, -6), (3.4, 0.2), (7.5, -3.6), (6.4, 5.6)], False)] + + +def shield(): + right = [(0, -7.2), (6.2, -5), (6.2, 0.5)] + curve((6.2, 0.5), (6, 5), (0, 7.4), 6) + return [(right + [(-x, y) for x, y in reversed(right[1:-1])], False)] + + +def wrench(): + # an open-ended spanner standing upright, then turned: a round head + # with a slot in the top, and a handle with a round end. + head, slot, grip = 4.3, 1.7, 1.75 + reach = math.degrees(math.asin(slot / head)) # where the slot's sides meet the head's edge + join = math.degrees(math.asin(grip / head)) + points = [(-slot, -4.2)] + points += arc(0, -4, head, 270 - reach, 90 + join, 10) + points += arc(0, 7.2, grip, 180, 0, 6) + points += arc(0, -4, head, 90 - join, -90 + reach, 10) + points += [(slot, -4.2)] + return [(turned(points, 45), False)] + + +def brackets(): + # "" + left = [(-3.4, -5.4), (-8.4, 0), (-3.4, 5.4), (-3.4, 2.6), (-5.8, 0), (-3.4, -2.6)] + return [(left, False), (mirrored(left), False), ([(0.5, -6.4), (2.3, -6.4), (-0.5, 6.4), (-2.3, 6.4)], False)] + + +def brush(): + handle = [(-1.2, -9), (1.2, -9), (1.5, 0.4), (2.1, 0.4), (2.1, 3), (-2.1, 3), (-2.1, 0.4), (-1.5, 0.4)] + tip = [(-2.1, 3.9), (2.1, 3.9)] + curve((2.1, 3.9), (3, 7), (0, 9.4), 5) + curve((0, 9.4), (-3, 7), (-2.1, 3.9), 5)[:-1] + return [(turned(handle, 40), False), (turned(tip, 40), False)] + + +def question(): + cx, cy, outer, inner = 0, -3.4, 4.6, 2.2 + hook = arc(cx, cy, outer, 180, 405, 14) + [(1.2, 1.2), (1.2, 3.2), (-1.2, 3.2), (-1.2, 0.2)] + arc(cx, cy, inner, 405, 180, 12) + return [(hook, False), (circle(0, 6.3, 1.5, 10), False)] + + +def bug(): + body = [(x, 1.2 + y) for x, y in zip([4.2 * math.cos(math.radians(a)) for a in range(0, 360, 20)], + [5.4 * math.sin(math.radians(a)) for a in range(0, 360, 20)])] + head = arc(0, -4.9, 2.7, 180, 360, 8) + legs = [bar(4.9, -0.8, 7.9, -2.8, 1.4), bar(5.2, 1.6, 8.3, 1.6, 1.4), bar(4.9, 4, 7.9, 6, 1.4)] + feelers = [bar(1.4, -7.8, 3.2, -9.6, 1.2)] + pieces = [body, head] + legs + [mirrored(leg) for leg in legs] + feelers + [mirrored(feeler) for feeler in feelers] + return [(piece, False) for piece in pieces] + + +def trophy(): + right = [(0, -7), (4.6, -7), (4.6, -3.4)] + curve((4.6, -3.4), (4.4, 1.2), (1.2, 2.4), 5) + [(1.2, 4.4), (3.8, 4.4), (3.8, 7), (0, 7)] + cup = right + [(-x, y) for x, y in reversed(right[1:-1])] + handle = arc(5.5, -4.2, 2.6, -90, 90, 8) + arc(5.5, -4.2, 1.3, 90, -90, 6) + return [(cup, False), (handle, False), (mirrored(handle), False)] + + +def flask(): + glass = [(-2.6, -7.6), (2.6, -7.6), (2.6, -6.2), (1.7, -6.2), (1.7, -1.8), (6.4, 5.8), (5.4, 7.6), (-5.4, 7.6), (-6.4, 5.8), + (-1.7, -1.8), (-1.7, -6.2), (-2.6, -6.2)] + return [(glass, False), (circle(1.2, 3.4, 1.4, 10), True), (circle(-2, 5.2, 0.9, 8), True)] + + +def smiley(): + smile = arc(0, -0.6, 5.2, 20, 160, 10) + arc(0, -0.6, 3.6, 160, 20, 8) + return [(circle(0, 0, 7.5, 28), False), (circle(-2.7, -2.4, 1.25, 10), True), (circle(2.7, -2.4, 1.25, 10), True), (smile, True)] + + +def heart_points(scale, dy=0.0): + right = [(0, -3.2)] + curve((0, -3.2), (1.2, -6.8), (4.4, -6.6), 5) + curve((4.4, -6.6), (7.8, -6.2), (7.4, -2.2), 5) \ + + curve((7.4, -2.2), (6.8, 2.4), (0, 7.2), 7) + points = right + [(-x, y) for x, y in reversed(right[1:-1])] + return [(x * scale, y * scale + dy) for x, y in points] + + +def heart(): + # an outlined heart: the game has a solid one among its own badges. + return [(heart_points(1), False), (heart_points(0.5, -0.2), True)] + + +def tick(): + return [([(-7.4, 0.6), (-4.8, -2.2), (-2, 0.8), (5, -6.4), (7.6, -3.8), (-2, 6.2)], False)] + + +def sprout(): + stem = [(-0.8, 2.3), (0.8, 2.3), (0.8, 8), (-0.8, 8)] + small = [(-0.4, 1.7)] + curve((-0.4, 1.7), (-1.4, -4.4), (-7.4, -3.6), 7) + curve((-7.4, -3.6), (-6.6, 1.9), (-0.4, 1.7), 7)[:-1] + large = [(0.4, 1.7)] + curve((0.4, 1.7), (7.6, 1.6), (7.8, -7.6), 8) + curve((7.8, -7.6), (0, -7.4), (0.4, 1.7), 8)[:-1] + return [(stem, False), (small, False), (large, False)] + + +# id, outline, and the card disc's colours: top, bottom, rim. +BADGES = [ + ("owner", crown, "#ffd95a", "#f0a11c", "#96600a"), + ("moderator", shield, "#5cb2ff", "#1f6fd6", "#12458a"), + ("contributor", wrench, "#6fd878", "#2f9e3a", "#19621f"), + ("developer", brackets, "#8a9ab0", "#4d5b70", "#283241"), + ("artist", brush, "#ffa066", "#ea6524", "#8f3a10"), + ("helper", question, "#5fd9cf", "#1fa398", "#0f615a"), + ("bughunter", bug, "#f77873", "#d03b36", "#7f1c19"), + ("eventwinner", trophy, "#d9a273", "#9c5f2a", "#5e3613"), + ("tester", flask, "#c6e45e", "#8fb81f", "#55700d"), + ("friend", smiley, "#7fd6ff", "#2ba6e0", "#136a94"), + ("supporter", heart, "#ff8fa8", "#e8476d", "#93203c"), + ("partner", tick, "#b28cff", "#7a4fe0", "#44288f"), + ("early", sprout, "#58b874", "#1f7a3d", "#0f4a22"), +] + + +def fitted(paths, half): + """Centred, and reaching `half` from the middle.""" + xs = [x for points, _ in paths for x, _ in points] + ys = [y for points, _ in paths for _, y in points] + cx, cy = (min(xs) + max(xs)) / 2, (min(ys) + max(ys)) / 2 + scale = half / max(max(xs) - cx, max(ys) - cy) + return [([((x - cx) * scale, (y - cy) * scale) for x, y in points], hole) for points, hole in paths] + + +def area(points): + return sum(x1 * y2 - x2 * y1 for (x1, y1), (x2, y2) in zip(points, points[1:] + points[:1])) + + +def records(paths, clockwise): + """The outline as SWF shape records, in twips. A solid piece goes round + the way the star does and a hole the other way, which puts the fill on + the same side of every edge.""" + out, xs, ys = [], [], [] + for points, hole in fitted(paths, TAG_HALF): + twips = [(round(x * 20), round(y * 20)) for x, y in points] + if (area(twips) > 0) != (clockwise != hole): + twips.reverse() + out.append('' % twips[0]) + for (x1, y1), (x2, y2) in zip(twips, twips[1:] + twips[:1]): + if (x1, y1) != (x2, y2): + out.append('' + % (x2 - x1, y2 - y1)) + xs += [x for x, _ in twips] + ys += [y for _, y in twips] + out.append('') + bounds = '' % (max(xs), min(xs), max(ys), min(ys)) + return bounds, "\n".join(out) + + +def star_points(shape): + """The star's own outline, to learn which way round it goes.""" + move = re.search(r'moveDeltaX="(-?\d+)" moveDeltaY="(-?\d+)"', shape) + x, y = int(move.group(1)), int(move.group(2)) + points = [(x, y)] + for edge in re.findall(r']*>', shape): + dx, dy = re.search(r'deltaX="(-?\d+)"', edge), re.search(r'deltaY="(-?\d+)"', edge) + x, y = x + (int(dx.group(1)) if dx else 0), y + (int(dy.group(1)) if dy else 0) + points.append((x, y)) + return points[:-1] + + +def inside(paths, x, y): + """Is the point in the outline? An odd number of crossings is in, which + makes a hole of a path inside another.""" + crossings = 0 + for points, _ in paths: + for (x1, y1), (x2, y2) in zip(points, points[1:] + points[:1]): + if (y1 > y) != (y2 > y) and x < x1 + (y - y1) * (x2 - x1) / (y2 - y1): + crossings += 1 + return crossings % 2 == 1 + + +def rgb(colour): + return tuple(int(colour[i:i + 2], 16) for i in (1, 3, 5)) + + +def card_pixels(paths, top, bottom, rim): + """CARD_SIZE square of (r, g, b, a): a disc shaded from `top` to + `bottom` with a `rim`, the outline in white on it. Sixteen samples to a + pixel.""" + paths = fitted(paths, CARD_HALF) + top, bottom, rim = rgb(top), rgb(bottom), rgb(rim) + middle, fill_radius, rim_radius = CARD_SIZE / 2, 20.0, 23.0 + rows = [] + for py in range(CARD_SIZE): + row = [] + for px in range(CARD_SIZE): + total = [0.0, 0.0, 0.0, 0.0] + for sy in range(4): + for sx in range(4): + x, y = px + (sx + 0.5) / 4 - middle, py + (sy + 0.5) / 4 - middle + distance = math.hypot(x, y) + if distance > rim_radius: + continue + if distance > fill_radius: + colour = rim + elif inside(paths, x, y): + colour = (255, 255, 255) + else: + shade = (y + fill_radius) / (2 * fill_radius) + colour = tuple(a + (b - a) * shade for a, b in zip(top, bottom)) + for channel in range(3): + total[channel] += colour[channel] + total[3] += 1 + row.append(tuple(round(total[c] / total[3]) if total[3] else 0 for c in range(3)) + (round(total[3] / 16 * 255),)) + rows.append(row) + return rows + + +def png(rows): + raw = b"".join(b"\x00" + bytes(value for pixel in row for value in pixel) for row in rows) + + def chunk(kind, data): + return struct.pack(">I", len(data)) + kind + data + struct.pack(">I", zlib.crc32(kind + data)) + return b"\x89PNG\r\n\x1a\n" + chunk(b"IHDR", struct.pack(">IIBBBBB", len(rows[0]), len(rows), 8, 6, 0, 0, 0)) \ + + chunk(b"IDAT", zlib.compress(raw, 9)) + chunk(b"IEND", b"") + + +def sheet(cards, outlines): + """Every badge to look at: the card picture, the same at the size the + card draws it, and the name tag outline on a tag-like colour.""" + cell, small = CARD_SIZE + 4, CARD_SIZE // 3 + backgrounds = [(119, 119, 119), (233, 228, 212), (43, 43, 51), (242, 201, 76)] + rows = [[backgrounds[(y // cell) % 4] + (255,) for _ in range(cell * len(cards))] for y in range(cell * 4)] + + def put(x0, y0, pixels): + for dy, row in enumerate(pixels): + for dx, (r, g, b, a) in enumerate(row): + under = rows[y0 + dy][x0 + dx] + rows[y0 + dy][x0 + dx] = tuple(round((c * a + u * (255 - a)) / 255) for c, u in zip((r, g, b), under)) + (255,) + for index, (card, paths) in enumerate(zip(cards, outlines)): + put(index * cell + 2, 2, card) + shrunk = [[tuple(round(sum(card[y * 3 + j][x * 3 + i][c] * card[y * 3 + j][x * 3 + i][3] for j in range(3) for i in range(3)) + / max(1, sum(card[y * 3 + j][x * 3 + i][3] for j in range(3) for i in range(3)))) for c in range(3)) + + (round(sum(card[y * 3 + j][x * 3 + i][3] for j in range(3) for i in range(3)) / 9),) + for x in range(small)] for y in range(small)] + put(index * cell + 2 + small, cell + small, shrunk) + put(index * cell + 2 + small, cell * 3 + small, shrunk) + # the name tag outline, three times its size, in a light tint. + big = fitted(paths, TAG_HALF * 3) + tag = [[(250, 240, 200, 255 if inside(big, x + 0.5 - cell / 2, y + 0.5 - cell / 2) else 0) for x in range(cell)] for y in range(cell)] + put(index * cell, cell * 2, tag) + return rows + + +def main(): + work = sys.argv[1] + os.makedirs(work, exist_ok=True) + os.makedirs(os.path.join(ROOT, "swf", "badges"), exist_ok=True) + os.makedirs(os.path.join(ROOT, "public", "badges"), exist_ok=True) + star_xml = os.path.join(work, "star.xml") + subprocess.run(["java", "-jar", FFDEC, "-swf2xml", os.path.join(ROOT, "cache", DEPLOY_VERSION, "media", hashed(STAR)), star_xml], + check=True, stdout=subprocess.DEVNULL) + xml = open(star_xml, encoding="utf-8").read() + # the second shape is the star; the first is the square behind it. + shape = re.search(r']*shapeId="3">.*?\s* 0 + cards, outlines = [], [] + for name, outline, top, bottom, rim in BADGES: + paths = outline() + bounds, edges = records(paths, clockwise) + changed = re.sub(r']*/>', bounds, shape, count=1) + changed = re.sub(r'.*?', "\n" + edges + "\n", changed, count=1, flags=re.S) + made = xml.replace(shape, changed).replace("iconStar", "icon" + name.capitalize()) + made_xml = os.path.join(work, name + ".xml") + open(made_xml, "w", encoding="utf-8").write(made) + out = os.path.join(ROOT, "swf", "badges", name + ".swf") + subprocess.run(["java", "-jar", FFDEC, "-xml2swf", made_xml, out], check=True, stdout=subprocess.DEVNULL) + card = card_pixels(paths, top, bottom, rim) + open(os.path.join(ROOT, "public", "badges", name + ".png"), "wb").write(png(card)) + cards.append(card) + outlines.append(paths) + print(name, os.path.getsize(out), "bytes") + open(os.path.join(work, "sheet.png"), "wb").write(png(sheet(cards, outlines))) + + +if __name__ == "__main__": + main() diff --git a/tools/make-bio-tab.py b/tools/make-bio-tab.py new file mode 100644 index 0000000..bc383c1 --- /dev/null +++ b/tools/make-bio-tab.py @@ -0,0 +1,162 @@ +#!/usr/bin/env python3 +"""Makes swf/biotab.swf, the artwork of the Bio tab on player cards. + + python3 tools/make-bio-tab.py + +The card (media 4620, from cache/) has two tabs that slide out of its left +side: the buddy games' at the top and the trade list's at the bottom. Each +is a brown frame with an ear on its left edge, and a blue button on the +ear. The Bio tab goes between them, so it needs a frame with its ear in +the middle, and a button with no picture on it (the card code puts +public/bio-icon.png there). This makes both from the card's own artwork +and leaves everything else in the file as it is, so that the card code can +load the result as it loads the card and take the tab out of it, button +class and all: + + - the games tab's frame is drawn again with the ear EAR_DOWN pixels + lower, and its top left corner rounded as its bottom left one is; + - the trade list's button loses its arrows: each of its four pictures is + a stack of layers, the arrows being the last six; + - the games tab gets that button in place of its own, on the ear. + +Needs Java, for tools/ffdec. +""" +import hashlib +import os +import re +import subprocess +import sys + +HERE = os.path.dirname(os.path.abspath(__file__)) +ROOT = os.path.dirname(HERE) +FFDEC = os.path.join(HERE, "ffdec", "ffdec-cli.jar") +DEPLOY_VERSION = "1830" +CARD = "4620" + +FRAME_SHAPE = 366 # the games tab's frame +GAMES_TAB = 372 +GAMES_BUTTON = 294 +TRADE_BUTTON = 312 +# the trade button's pictures, and how many layers of each are the button itself. +BUTTON_LAYERS = {307: 4, 309: 4, 305: 3, 303: 3} # up, mouse over, down, grey +EAR_DOWN = 66 # the games tab's ear is at the top; this far down is midway to the trade list's + + +def hashed(name): + """LoaderCache.hashItV2, as in lib/cdn.js.""" + salted = "W3 7r4Ck h4X0r3rs" + name + out = "" + for index, char in enumerate(salted): + out = out + char if index % 2 == 0 else char + out + return hashlib.md5(out.encode()).hexdigest() + + +def frame_path(inset, d): + """The frame's outline, `inset` pixels in from its edge, as ("M" | "L", + x, y) and ("Q", control x, control y, x, y). The numbers are the + original's, the ear's with `d` added.""" + if inset: + left, ear_left, top, bottom, right = -78, -130.9, -97.5, 97.5, 131 + ear_top, ear_bottom = -84.8 + d, -27.9 + d + ear = [("Q", -119.8, ear_top, -125.4, -79.2 + d), ("Q", ear_left, -73.7 + d, ear_left, -65.8 + d), ("L", ear_left, -46.9 + d), + ("Q", ear_left, -39.0 + d, -125.4, -33.4 + d), ("Q", -119.8, ear_bottom, -112, ear_bottom)] + corner = [("Q", left, 88.8, -73.5, 93.1), ("Q", -69.2, bottom, -63, bottom)] + else: + left, ear_left, top, bottom, right = -80, -132.9, -99.5, 99.5, 133 + ear_top, ear_bottom = -86.8 + d, -25.9 + d + ear = [("Q", -120.7, ear_top, -126.8, -80.7 + d), ("Q", ear_left, -74.5 + d, ear_left, -65.8 + d), ("L", ear_left, -46.9 + d), + ("Q", ear_left, -38.1 + d, -126.8, -32.0 + d), ("Q", -120.7, ear_bottom, -112, ear_bottom)] + corner = [("Q", left, 89.5, -75, 94.5), ("Q", -70, bottom, -63, bottom)] + # the top left corner, which the original's ear ran into: the bottom one, upside down. + (_, c1x, c1y, m1x, m1y), (_, c2x, c2y, _, _) = corner + top_corner = [("Q", c2x, -c2y, m1x, -m1y), ("Q", c1x, -c1y, left, -82.5)] + return [("M", left, ear_top), ("L", -112, ear_top)] + ear + [("L", left, ear_bottom), ("L", left, 82.5)] + corner \ + + [("L", right, bottom), ("L", right, top), ("L", -63, top)] + top_corner + [("L", left, ear_top)] + + +def backwards(path): + points = [(step[-2], step[-1]) for step in path] + out = [("M",) + points[-1]] + for index in range(len(path) - 1, 0, -1): + step = path[index] + out.append(step[:-2] + points[index - 1]) + return out + + +def path_records(path, first): + """SWF shape records for a path, in twips. `first` is put into the + record that moves to its start.""" + out, x, y = [], 0, 0 + twips = lambda value: round(value * 20) + for step in path: + if step[0] == "M": + x, y = twips(step[1]), twips(step[2]) + out.append('' % (first, x, y)) + elif step[0] == "L": + nx, ny = twips(step[1]), twips(step[2]) + if (nx, ny) != (x, y): + out.append('' + % (nx - x, ny - y)) + x, y = nx, ny + else: + cx, cy, nx, ny = (twips(value) for value in step[1:]) + out.append('' + % (nx - cx, ny - cy, cx - x, cy - y)) + x, y = nx, ny + return out + + +def shape_tag(xml, shape_id): + return re.search(r']*shapeId="%d">.*?\s*' % shape_id, xml, re.S).group(0) + + +def new_frame(xml): + """The frame as two layers, as the original has it: the brown inside, + then the dark rim around it (the outline, with the inside as a hole).""" + tag = shape_tag(xml, FRAME_SHAPE) + # the record between the layers, which carries the second layer's colour. + new_styles = re.search(r']*stateNewStyles="true">.*?\s*', tag, re.S).group(0) + fill, keep = 'fillStyle0="1" stateFillStyle0="true" stateFillStyle1="false"', 'stateFillStyle0="false" stateFillStyle1="false"' + inner, outer = frame_path(2, EAR_DOWN), frame_path(0, EAR_DOWN) + records = path_records(inner, fill) + [new_styles] + path_records(outer, fill) + path_records(backwards(inner), keep) \ + + [''] + return xml.replace(tag, re.sub(r'.*', "\n" + "\n".join(records) + "\n", + tag, count=1, flags=re.S)) + + +def without_picture(xml, shape_id, layers): + """A button picture with only its first `layers` layers.""" + tag = shape_tag(xml, shape_id) + starts = [match.start() for match in re.finditer(r']*stateNewStyles="true"', tag)] + cut = starts[layers - 1] # the record that begins the layer after the last one kept + end = tag.rindex(']*spriteId="%d">.*?' % GAMES_TAB, xml, re.S).group(0) + place = re.search(r']*name="gameTabBtn"[^>]*>\s*]*/>' % GAMES_BUTTON, tab).group(0) + moved = place.replace('characterId="%d"' % GAMES_BUTTON, 'characterId="%d"' % TRADE_BUTTON) + y = int(re.search(r'translateY="(-?\d+)"', place).group(1)) + moved = moved.replace('translateY="%d"' % y, 'translateY="%d"' % (y + EAR_DOWN * 20)) + xml = xml.replace(tab, tab.replace(place, moved)) + made_xml = os.path.join(work, "biotab.xml") + open(made_xml, "w", encoding="utf-8").write(xml) + out = os.path.join(ROOT, "swf", "biotab.swf") + subprocess.run(["java", "-jar", FFDEC, "-xml2swf", made_xml, out], check=True, stdout=subprocess.DEVNULL) + print(out, os.path.getsize(out), "bytes") + + +if __name__ == "__main__": + main() diff --git a/tools/make-emote.py b/tools/make-emote.py new file mode 100644 index 0000000..cbada02 --- /dev/null +++ b/tools/make-emote.py @@ -0,0 +1,309 @@ +"""make-emote.py [name] [--black-background] + +Adds an emote of our own to swf/HUDAssets.swf, from a picture: the classes +"" (the emote over an animal's head and in a chat bubble) and +"_sml" (the small one in the emote picker and in chat lines), each a +clip holding the picture, the size and place the game's own emotes have. +The default name is emo_temp, the face with a thermometer. + +The game makes an emote by its class name (gui.EmoticonUtility), so the +name also has to be in that class's lists: swf-src/EmoticonUtility.cinit.pcode, +which tools/build-client.sh puts into the client. + +Running it again replaces what an earlier run added. The picture must be an +8-bit RGBA PNG, not interlaced; --black-background is for one that came on +black where it should be see-through. Needs nothing but Python. +""" +import lzma +import struct +import sys +import zlib +from pathlib import Path + +ROOT = Path(__file__).resolve().parent.parent +HUD = ROOT / "swf" / "HUDAssets.swf" + +# character ids of ours, far above the file's own (which end near 4,000): +# picture, the two shapes, the two clips. +FIRST_ID = 60001 +ABC_NAME = b"ours_emote" +# the game's emotes are drawn about their middle: the large ones 35 by 38 +# pixels (emo_sick's shape is 706 by 763 twips), the small ones 19 by 20. +LARGE_WIDTH = 706 +SMALL_WIDTH = 373 +SHRINK = 2 # the picture is kept at half its size, which is still four times the large emote + + +def read_png(path): + data = path.read_bytes() + if data[:8] != b"\x89PNG\r\n\x1a\n": + sys.exit("not a PNG") + pos, idat, head = 8, b"", None + while pos < len(data): + length, kind = struct.unpack(">I4s", data[pos:pos + 8]) + body = data[pos + 8:pos + 8 + length] + if kind == b"IHDR": + head = struct.unpack(">IIBBBBB", body) + elif kind == b"IDAT": + idat += body + pos += 12 + length + width, height, depth, colour, _, _, interlace = head + if (depth, colour, interlace) != (8, 6, 0): + sys.exit("the picture must be 8-bit RGBA and not interlaced") + raw = zlib.decompress(idat) + stride = width * 4 + rows, previous = [], bytearray(stride) + for y in range(height): + kind = raw[y * (stride + 1)] + line = bytearray(raw[y * (stride + 1) + 1:(y + 1) * (stride + 1)]) + for i in range(stride): + left = line[i - 4] if i >= 4 else 0 + up = previous[i] + corner = previous[i - 4] if i >= 4 else 0 + if kind == 1: + line[i] = (line[i] + left) & 255 + elif kind == 2: + line[i] = (line[i] + up) & 255 + elif kind == 3: + line[i] = (line[i] + (left + up) // 2) & 255 + elif kind == 4: + estimate = left + up - corner + nearest = min((abs(estimate - left), 0, left), (abs(estimate - up), 1, up), (abs(estimate - corner), 2, corner))[2] + line[i] = (line[i] + nearest) & 255 + rows.append(line) + previous = line + return width, height, rows + + +def without_background(width, height, rows, darkest=28): + """Makes the black around the drawing see-through: every pixel that + dark which can be reached from the picture's edge. Black inside the + drawing (eyes, a mouth) is not reached and stays.""" + dark = lambda x, y: max(rows[y][x * 4:x * 4 + 3]) <= darkest and rows[y][x * 4 + 3] != 0 + todo = [(x, y) for x in range(width) for y in (0, height - 1)] + [(x, y) for y in range(height) for x in (0, width - 1)] + while todo: + x, y = todo.pop() + if 0 <= x < width and 0 <= y < height and dark(x, y): + rows[y][x * 4 + 3] = 0 + todo += [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)] + return width, height, rows + + +def shrunk(width, height, rows, by): + """The picture at 1/by of its size, as SWF wants it: ARGB with the + colours already multiplied by the alpha.""" + out_width, out_height = width // by, height // by + out = bytearray() + for y in range(out_height): + for x in range(out_width): + red = green = blue = alpha = 0 + for dy in range(by): + line = rows[y * by + dy] + for dx in range(by): + i = (x * by + dx) * 4 + a = line[i + 3] + red += line[i] * a + green += line[i + 1] * a + blue += line[i + 2] * a + alpha += a + count = by * by + out += bytes((alpha // count, red // (255 * count), green // (255 * count), blue // (255 * count))) + return out_width, out_height, bytes(out) + + +class Bits: + def __init__(self): + self.bits = [] + + def unsigned(self, value, count): + self.bits += [(value >> (count - 1 - i)) & 1 for i in range(count)] + + def signed(self, value, count): + self.unsigned(value & ((1 << count) - 1), count) + + def bytes(self): + bits = self.bits + [0] * (-len(self.bits) % 8) + return bytes(sum(bit << (7 - i) for i, bit in enumerate(bits[n:n + 8])) for n in range(0, len(bits), 8)) + + +def needed(*values): + """Bits for the widest of these signed numbers.""" + return max(max(abs(value) for value in values).bit_length() + 1, 2) + + +def rect(x1, x2, y1, y2): + bits = Bits() + count = needed(x1, x2, y1, y2) + bits.unsigned(count, 5) + for value in (x1, x2, y1, y2): + bits.signed(value, count) + return bits.bytes() + + +def tag(code, body): + if len(body) < 63 and code not in (2, 36, 39): + return struct.pack("> 3) + 7) // 8 + 4 + tags, pos = [], header + while pos < len(body): + short = struct.unpack_from("> 6, body[pos:start + length], body[start:start + length])) + pos = start + length + return body[:header], tags + + +def main(): + if not [word for word in sys.argv[1:] if not word.startswith("--")]: + sys.exit(__doc__) + words = [word for word in sys.argv[1:] if not word.startswith("--")] + name = words[1] if len(words) > 1 else "emo_temp" + picture = read_png(Path(words[0])) + if "--black-background" in sys.argv: + picture = without_background(*picture) + width, height, pixels = shrunk(*picture, SHRINK) + bitmap, large_shape, small_shape, large, small = range(FIRST_ID, FIRST_ID + 5) + ours = [ + tag(36, struct.pack(" +# +# the database is copied with SQLite's own VACUUM INTO, so it is whole and +# small whether or not the server is running. tools/ is left out but for +# what the running server may be asked to use. +set -e +cd "$(dirname "$(readlink -f "$0")")/.." +out=${1:?usage: tools/pack-for-vps.sh } +[ -e "$out" ] && { echo "$out is already there" >&2; exit 1; } +mkdir -p "$out/data" "$out/tools" +cp -r server.js config.js package.json lib public swf client-updates "$out/" +cp tools/reset-admin-password.js "$out/tools/" +cp -r cache "$out/cache" +node -e ' +const {DatabaseSync} = require("node:sqlite"); +const db = new DatabaseSync(process.argv[1]); +db.exec("PRAGMA busy_timeout = 5000"); +db.prepare("VACUUM INTO ?").run(process.argv[2]); +' data/game.sqlite "$out/data/game.sqlite" +[ -d data/masterpieces ] && cp -r data/masterpieces "$out/data/masterpieces" +chmod -R go-rwx "$out/data" +find "$out" -type d -exec chmod u+rwx {} + +find "$out" -type f -exec chmod u+rw,a-x {} + +echo "Packed into $out:" +du -sh "$out"/* | sed 's/^/ /' diff --git a/tools/publish-public.sh b/tools/publish-public.sh new file mode 100644 index 0000000..48132aa --- /dev/null +++ b/tools/publish-public.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +# copies this repository as it stands at its last commit, minus what stays +# private, into the public one and pushes it: +# +# tools/publish-public.sh [--no-push] +# +# no markdown file of any kind goes public. the public repository has a +# history of its own: nothing of this one's +# history goes there, so a file that was ever committed here and is private +# never shows up in an old public commit. its .gitignore names the private +# paths too, so they are not added there by hand either. +set -euo pipefail + +name=burrow-server +remote=git@github.com:burrow-dev/$name.git +# what stays private: the game's own client and SWFs, the client decompiled, +# the client updates (release files), and the working notes +private=(swf swf-src client-updates HANDOFF.md DISCOVERIES.md GOING-PUBLIC.md) + +here=$(cd "$(dirname "$0")/.." && pwd) +public=${BURROW_PUBLIC_DIR:-$HOME/burrow-public/$name} +push=1 +[ "${1:-}" = "--no-push" ] && push=0 + +cd "$here" +if [ -n "$(git status --porcelain --untracked-files=no)" ]; then + echo "commit first: the public copy is made from the last commit" >&2 + exit 1 +fi +source=$(git rev-parse --short HEAD) +ssh_command=$(git config --get core.sshCommand || true) + +if [ ! -d "$public/.git" ]; then + mkdir -p "$public" + git -C "$public" init -q -b main + git -C "$public" remote add origin "$remote" +fi +git -C "$public" config user.name "$(git config user.name)" +git -C "$public" config user.email "$(git config user.email)" +[ -n "$ssh_command" ] && git -C "$public" config core.sshCommand "$ssh_command" + +work=$(mktemp -d) +trap 'rm -rf "$work"' EXIT +git archive HEAD | tar -x -C "$work" +for path in "${private[@]}"; do + rm -rf "${work:?}/$path" +done +# no markdown file goes public, of any kind (the owner's rule) +find "$work" -name '*.md' -delete + +# a last look before anything leaves: none of the game's code or SWFs +leaked=$(find "$work" \( -name '*.swf' -o -name '*.as' -o -name '*.pem' -o -name '*.md' \) -print) +if [ -n "$leaked" ]; then + echo "refused: these would have gone public:" >&2 + echo "$leaked" >&2 + exit 1 +fi + +{ + cat "$work/.gitignore" + printf '\n# kept in the private repository, never here\n' + printf '*.md\n' + for path in "${private[@]}"; do + printf '/%s\n' "$path" + done +} > "$work/.gitignore.public" +mv "$work/.gitignore.public" "$work/.gitignore" + +# the public tree becomes exactly this +find "$public" -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} + +cp -a "$work/." "$public/" +cd "$public" +git add -A +if git diff --cached --quiet; then + echo "the public copy is already up to date" + exit 0 +fi +git commit -q -m "Brought up to date with the private repository ($source)" +echo "committed in $public: $(git log -1 --format='%h %s')" +if [ "$push" = 1 ]; then + git push -q -u origin main + echo "pushed to $remote" +fi diff --git a/tools/reset-admin-password.js b/tools/reset-admin-password.js new file mode 100644 index 0000000..028053b --- /dev/null +++ b/tools/reset-admin-password.js @@ -0,0 +1,15 @@ +"use strict"; + +// forgets the admin panel's password, so the panel asks for a new one the +// next time it is opened. restart the server afterwards: from another machine +// the panel will want the setup code it prints at start. +// +// node tools/reset-admin-password.js + +const path = require("path"); +const {DatabaseSync} = require("node:sqlite"); +const config = require("../config.js"); + +const db = new DatabaseSync(path.join(config.dataDir, "game.sqlite")); +const result = db.prepare("DELETE FROM settings WHERE key = 'admin_password'").run(); +console.log(result.changes ? "The admin password is forgotten. Restart the server, then open /admin." : "There was no admin password."); diff --git a/tools/room-assets.js b/tools/room-assets.js new file mode 100644 index 0000000..2620896 --- /dev/null +++ b/tools/room-assets.js @@ -0,0 +1,49 @@ +"use strict"; + +// writes out the files a room file carries inside it. +// +// node tools/room-assets.js ... +// node tools/room-assets.js /tmp/scenes pvp_tictactoe/room_main +// +// A room file (roomDefs/.xroom: zlib, then AMF3) holds its artwork as +// SWFs in `assets`, each with a name and its bytes (`ba`); its layers say +// which asset each one shows. A minigame's scene is such a room, and the +// SWF on its "theGame" layer has code of its own: half the rules of each +// buddy game are in there (lib/buddygames.js). to read it: +// +// java -jar tools/ffdec/ffdec-cli.jar -export script + +const fs = require("fs"); +const path = require("path"); +const zlib = require("zlib"); +const amf3 = require("../lib/amf3.js"); +const cdn = require("../lib/cdn.js"); + +(async () => { + const [outDir, ...rooms] = process.argv.slice(2); + if (!outDir || rooms.length === 0) { + console.log("usage: node tools/room-assets.js ..."); + process.exit(1); + } + for (const room of rooms) { + const body = await cdn.get(cdn.hashedPath(`roomDefs/${room}.xroom`)); + if (!body) { + console.log(`${room}: no such room file`); + continue; + } + const decoded = amf3.decode(zlib.inflateSync(body)); + const dir = path.join(outDir, room.replace(/\//g, "_")); + fs.mkdirSync(dir, {recursive: true}); + for (const asset of decoded.assets) { + const name = String(asset.name).replace(/[\\/: ]/g, "_"); + if (Buffer.isBuffer(asset.ba)) { + fs.writeFileSync(path.join(dir, name), asset.ba); + } + console.log(`${room}: ${name} ${Buffer.isBuffer(asset.ba) ? `${asset.ba.length} bytes` : "(no bytes)"}`); + } + for (const layer of decoded.actors.ActorLayer || []) { + console.log(`${room}: layer "${layer.name}" shows ${layer.assetName || layer.asset || "?"}`); + } + } + process.exit(0); +})(); diff --git a/tools/room-history.js b/tools/room-history.js new file mode 100644 index 0000000..e278111 --- /dev/null +++ b/tools/room-history.js @@ -0,0 +1,131 @@ +"use strict"; + +// lists every version of the lands' room files the CDN still has: for each +// room, which builds share a version, the big pictures inside it, and when +// its newest artwork was saved. this is how the older designs in the Theme +// list were found (DISCOVERIES.md, "Older designs of the lands"). +// +// node tools/room-history.js +// +// downloads about 1.9 GB and keeps the 400 MB that is distinct, in +// /files, so a second run only reads. A build is dated by the +// newest sale start in its item pack, which is a few weeks ahead of it. + +const crypto = require("crypto"); +const fs = require("fs"); +const path = require("path"); +const zlib = require("zlib"); +const amf3 = require("../lib/amf3.js"); +const cdn = require("../lib/cdn.js"); +const config = require("../config.js"); + +const OLDEST_BUILD = 1600; +const LANDS = /^(appondale|aussie|balloosh|bahari_bay|canyon_path|coral_canyons|coralpets|crystal_sands|jamaa_township|lost_temple_of_zios|mountains_of_shivveer|oceans|pirate_ship|sarepia|r?holidays_and_celebrations)\//; +const BIG_PICTURE = 60000; // bytes; smaller JPEGs are patches and signs +const WORKERS = 12; + +const tail = assetPath => cdn.hashedPath(assetPath).split("/").slice(1).join("/"); + +const download = async (build, assetPath) => { + const url = new URL(`${build}/${tail(assetPath)}`, config.upstreamContent); + url.searchParams.set("v", config.upstreamBuildVersion); + for (let attempt = 0; attempt < 4; attempt++) { + try { + const res = await fetch(url, {headers: {"User-Agent": "Mozilla/5.0"}}); + if (res.status === 404 || res.status === 403) { + return null; + } + if (res.ok) { + return Buffer.from(await res.arrayBuffer()); + } + } + catch (err) { + // tried again below + } + } + throw new Error(`could not fetch ${assetPath} of build ${build}`); +}; + +const day = time => new Date(time).toISOString().slice(0, 10); + +(async () => { + const workDir = process.argv[2]; + if (!workDir) { + console.log("usage: node tools/room-history.js "); + process.exit(1); + } + const filesDir = path.join(workDir, "files"); + const indexFile = path.join(workDir, "index.json"); + fs.mkdirSync(filesDir, {recursive: true}); + + // {builds: {build: newest sale start}, rooms: {room: {build: hash of its file}}} + let index = fs.existsSync(indexFile) ? JSON.parse(fs.readFileSync(indexFile)) : null; + if (!index) { + index = {builds: {}, rooms: {}}; + const jobs = []; + const candidates = Array.from({length: Number(config.deployVersion) - OLDEST_BUILD + 1}, (unused, at) => OLDEST_BUILD + at); + await Promise.all(candidates.map(async build => { + const rooms = await download(build, "defPacks/1011"); + if (!rooms) { + return; + } + const items = Object.values(amf3.decode(zlib.inflateRawSync(await download(build, "defPacks/1000")))); + index.builds[build] = day(1000 * Math.max(...items.map(def => Number(def.availabilityStartTime) || 0))); + for (const def of Object.values(amf3.decode(zlib.inflateRawSync(rooms)))) { + if (def && LANDS.test(def.pathName)) { + jobs.push([build, String(def.pathName)]); + } + } + })); + console.log(`${Object.keys(index.builds).length} builds, ${jobs.length} room files`); + const worker = async () => { + while (jobs.length > 0) { + const [build, room] = jobs.pop(); + const body = await download(build, `roomDefs/${room}.xroom`); + const hash = body ? crypto.createHash("sha1").update(body).digest("hex").slice(0, 12) : null; + if (body && !fs.existsSync(path.join(filesDir, hash))) { + fs.writeFileSync(path.join(filesDir, hash), body); + } + (index.rooms[room] = index.rooms[room] || {})[build] = hash; + } + }; + await Promise.all(Array.from({length: WORKERS}, worker)); + fs.writeFileSync(indexFile, JSON.stringify(index)); + } + + console.log("Builds, by the newest sale start in each:"); + console.log(Object.entries(index.builds).map(([build, date]) => ` ${build} ${date}`).join("\n")); + const described = new Map(); + const describe = hash => { + if (!described.has(hash)) { + const room = amf3.decode(zlib.inflateSync(fs.readFileSync(path.join(filesDir, hash)))); + const pictures = room.assets.filter(asset => /\.jpe?g$/i.test(asset.name) && Buffer.isBuffer(asset.ba) && asset.ba.length > BIG_PICTURE) + .map(asset => String(asset.name).split("\\").slice(-2).join("/")).sort(); + const newest = Math.max(0, ...room.assets.map(asset => Number(new Date(asset.timeStamp)) || 0)); + described.set(hash, {pictures: pictures.join(" + ") || "(no big picture)", newest: newest ? day(newest) : "?", assets: room.assets.length}); + } + return described.get(hash); + }; + for (const room of Object.keys(index.rooms).sort()) { + // versions with the same big pictures are one line: they differ in + // decorations, which change monthly. + const looks = new Map(); + for (const build of Object.keys(index.rooms[room]).sort()) { + const hash = index.rooms[room][build]; + if (hash) { + const {pictures, newest, assets} = describe(hash); + const look = looks.get(pictures) || looks.set(pictures, {builds: [], newest, assets: new Set()}).get(pictures); + look.builds.push(build); + look.newest = newest > look.newest ? newest : look.newest; + look.assets.add(assets); + } + } + console.log(`\n${room}`); + for (const [pictures, look] of looks) { + console.log(` ${pictures}\n builds ${look.builds.join(" ")}; ${Math.min(...look.assets)}-${Math.max(...look.assets)} assets; newest artwork ${look.newest}`); + } + } +})().catch(err => { + console.error(err); + process.exit(1); +}); diff --git a/tools/room-info.js b/tools/room-info.js new file mode 100644 index 0000000..ec43a54 --- /dev/null +++ b/tools/room-info.js @@ -0,0 +1,11 @@ +const path=require("path");const SRV=process.argv[2]; +const cdn=require(path.join(SRV,"lib/cdn.js")),zlib=require("zlib"),amf=require(path.join(SRV,"lib/amf3.js")); +(async()=>{for(const p of process.argv.slice(3)){const b=await cdn.get(cdn.hashedPath("roomDefs/"+p+".xroom"));if(!b){console.log("==",p,"MISSING");continue}const o=amf.decode(zlib.inflateSync(b)); +const ts=o.assets.map(a=>Number(a.timeStamp)).filter(Boolean).sort((a,b)=>a-b);const d=t=>new Date(t>1e12?t:t*1000).toISOString().slice(0,10); +console.log("==",p,"assets",o.assets.length,"newest asset",ts.length?d(ts[ts.length-1]):"?", "oldest",ts.length?d(ts[0]):"?"); +const L=o.actors.ActorLayer||[]; +if(process.env.KEYS){console.log(" layer keys:",Object.keys(L[0]).join(","));console.log(" settings:",JSON.stringify(o.actors.ActorSettings[0],(k,v)=>Buffer.isBuffer(v)?"bytes":v).slice(0,900))} +const names=[...new Set([...o.assets.map(a=>a.name),...L.map(l=>l.name)])].filter(n=>/hallow|spook|pumpk|phantom|night|snow|winter|jamaalid|xmas|christ|holiday|friend|heart|valent|summer|beach|freedom|firework|lucky|clover|feast|leaf|spring|egg|birthday|season/i.test(String(n))); +console.log(" seasonal-looking names:",names.join(", ").slice(0,700)||"(none)"); +if(process.env.ALL)console.log(" all layers:",L.map(l=>l.name).join(", ").slice(0,3000)); +}})().catch(e=>console.log("ERR",e.stack)); diff --git a/tools/sale-history.js b/tools/sale-history.js new file mode 100644 index 0000000..e6adff5 --- /dev/null +++ b/tools/sale-history.js @@ -0,0 +1,88 @@ +"use strict"; + +// collects when each item was on sale, from every build of the defPacks the +// CDN still serves, into lib/sale-dates.json (see lib/sales.js for what +// reads it). +// +// node tools/sale-history.js +// +// an item's def carries one sale window, availabilityStartTime to +// availabilityEndTime, and the official game rewrote it whenever the item +// came back: Halloween items have a window each October, and so on. any one +// build only has the latest. old builds stay on the CDN under their own +// number (35 of them between 1636 and 1830 when this was written), so +// reading them all gives each item's windows over about four years. +// +// downloads about 10 MB and keeps none of it. + +const fs = require("fs"); +const path = require("path"); +const zlib = require("zlib"); +const amf3 = require("../lib/amf3.js"); +const cdn = require("../lib/cdn.js"); +const config = require("../config.js"); + +const PACKS = {clothing: 1000, denItems: 1030, diamond: 1054}; +const OLDEST_BUILD = 1600; +const DAY = 86400; +const OUT = path.join(__dirname, "..", "lib", "sale-dates.json"); + +const fetchPack = async (build, id) => { + const tail = cdn.hashedPath(`defPacks/${id}`).split("/").slice(1).join("/"); + const url = new URL(`${build}/${tail}`, config.upstreamContent); + url.searchParams.set("v", config.upstreamBuildVersion); + for (let attempt = 0; attempt < 3; attempt++) { + try { + const res = await fetch(url, {headers: {"User-Agent": "Mozilla/5.0"}}); + if (res.status === 404 || res.status === 403) { + return null; + } + if (res.ok) { + return Object.values(amf3.decode(zlib.inflateRawSync(Buffer.from(await res.arrayBuffer())))); + } + } + catch (err) { + // tried again below + } + } + throw new Error(`could not fetch defPack ${id} of build ${build}`); +}; + +(async () => { + const candidates = []; + for (let build = OLDEST_BUILD; build <= Number(config.deployVersion); build++) { + candidates.push(build); + } + const found = await Promise.all(candidates.map(async build => (await fetchPack(build, PACKS.clothing) ? build : null))); + const builds = found.filter(Boolean); + console.log(`${builds.length} builds on the CDN: ${builds[0]} to ${builds[builds.length - 1]}`); + + const out = {builds: [builds[0], builds[builds.length - 1]]}; + for (const [name, id] of Object.entries(PACKS)) { + const windows = new Map(); // def id -> Set of "startDay,endDay" + for (const build of builds) { + for (const def of await fetchPack(build, id) || []) { + const start = Number(def.availabilityStartTime) || 0; + const end = Number(def.availabilityEndTime) || 0; + // only a window with both ends says "this is when it is sold". + if (start > 0 && end > start) { + const key = String(def.id); + windows.set(key, (windows.get(key) || new Set()).add(`${Math.floor(start / DAY)},${Math.ceil(end / DAY)}`)); + } + } + } + out[name] = Object.fromEntries([...windows].sort((one, other) => Number(one[0]) - Number(other[0])) + .map(([key, set]) => [key, [...set].map(window => window.split(",").map(Number)).sort((one, other) => one[0] - other[0])])); + const counts = Object.values(out[name]).map(list => list.length); + console.log(`${name}: ${counts.length} items with sale windows, ${counts.reduce((sum, count) => sum + count, 0)} windows`); + } + // one item a line: the file is committed, and this keeps its diffs readable. + const body = Object.entries(out).map(([name, value]) => (Array.isArray(value) + ? ` ${JSON.stringify(name)}: ${JSON.stringify(value)}` + : ` ${JSON.stringify(name)}: {\n${Object.entries(value).map(([id, list]) => ` ${JSON.stringify(id)}: ${JSON.stringify(list)}`).join(",\n")}\n }`)); + fs.writeFileSync(OUT, `{\n${body.join(",\n")}\n}\n`); + console.log(`wrote ${OUT} (${fs.statSync(OUT).size} bytes)`); +})().catch(err => { + console.error(err.message); + process.exit(1); +}); diff --git a/tools/shop-stock.py b/tools/shop-stock.py new file mode 100644 index 0000000..6b39688 --- /dev/null +++ b/tools/shop-stock.py @@ -0,0 +1,321 @@ +#!/usr/bin/env python3 +"""Builds lib/shop-stock.json: what each shop sells, from the AJ Classic Wiki. + + python3 tools/shop-stock.py [] + +The game's files say which shop list stands in which room and nothing about +what is on its shelves: the official server sent that. The wiki +(animaljam.fandom.com) has it. Every item page there carries the game's own +def id (the sort key of "Clothing by ID" / "Den Items by ID"), the category +of each shop selling it now ("Jam Mart Clothing") and of each that used to +("Formerly Jam Mart Clothing"). Shops that are gone, the party shops mostly, +list their items on the shop's own page instead. + +LISTS below says which wiki shop is which generic list. Where that is a guess +it says so. keeps what was downloaded (wiki.json, pages.json); +delete them to fetch the wiki again. + +Written out per list: "now" (on the shelf according to the wiki) and +"former" (sold there once). lib/shopstock.js stocks all of "now" and those +of "former" that have sale dates, which bring them back in their season. +""" +import json +import os +import re +import sys +import time +import urllib.parse +import urllib.request + +API = "https://animaljam.fandom.com/api.php" +OUT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "lib", "shop-stock.json") + + +def api(**params): + params["format"] = "json" + url = API + "?" + urllib.parse.urlencode(params) + for attempt in range(4): + try: + request = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0 (shop research)"}) + return json.load(urllib.request.urlopen(request, timeout=60)) + except Exception: + time.sleep(2 + attempt * 3) + raise SystemExit("failed: " + url) + + +def members(category, sortkey=False): + found, more = [], {} + while True: + reply = api(action="query", list="categorymembers", cmtitle="Category:" + category, cmlimit="500", + cmprop="title|sortkeyprefix" if sortkey else "title", **more) + found += reply["query"]["categorymembers"] + if "continue" not in reply: + return found + more = {"cmcontinue": reply["continue"]["cmcontinue"]} + time.sleep(0.2) + + +def download(workdir): + wiki_path, pages_path = os.path.join(workdir, "wiki.json"), os.path.join(workdir, "pages.json") + if not os.path.exists(wiki_path): + wiki = {"ids": {}, "shops": {}} + for kind, category in (("clothing", "Clothing by ID"), ("den", "Den Items by ID")): + wiki["ids"][kind] = {row["title"]: row["sortkeyprefix"] for row in members(category, True)} + for shop in [row["title"] for row in members("Shops")]: + if not shop.startswith("Category:"): + wiki["shops"][shop] = {"now": [row["title"] for row in members(shop)], + "former": [row["title"] for row in members("Formerly " + shop)]} + time.sleep(0.2) + json.dump(wiki, open(wiki_path, "w")) + wiki = json.load(open(wiki_path)) + if not os.path.exists(pages_path): + pages = {} + for shop in wiki["shops"]: + reply = api(action="parse", page=shop, prop="wikitext", redirects="1") + pages[shop] = reply.get("parse", {}).get("wikitext", {}).get("*", "") + time.sleep(0.15) + json.dump(pages, open(pages_path, "w")) + return wiki, json.load(open(pages_path)) + + +# sections of a shop page that talk about items without listing the shelf. +NOT_THE_SHELF = re.compile(r"trivia|gallery|history|appearance|glitch|previously|formerly|see also", re.I) + + +def sections(text): + """[(heading path, body)] of a page, the lead included under "".""" + parts = re.split(r"^(=+)\s*(.*?)\s*=+\s*$", text, flags=re.M) + found, path = [("", parts[0])], [] + for at in range(1, len(parts), 3): + level, name = len(parts[at]), parts[at + 1] + path = [step for step in path if step[0] < level] + [(level, name)] + found.append((" / ".join(step[1] for step in path), parts[at + 2])) + return [(head, body) for head, body in found if not NOT_THE_SHELF.search(head)] + + +def latest_tab(body): + """Of a tabbed list by year, the first tab: the latest years.""" + body = re.sub(r"\{\{Tabber\s*\|[^|]*\|(\{\{[^{}]*\}\}).*?(?=\n==|\Z)", r"\1", body, flags=re.S) + return re.sub(r"\s*\|-\|[^=\n]*=(.*?)(?:\|-\|.*?)?", r"\1", body, flags=re.S) + + +def names(body): + """Item names in a stretch of wikitext: item tables and links.""" + found = [] + for table in re.finditer(r"\{\{(?:ItemTable|CollectionTable)\s*\|([^{}]*)\}\}", body): + for cell in re.split(r"[|,;]", table.group(1)): + found.append(cell.split("::")[0].strip()) + found += [link.group(1).strip() for link in re.finditer(r"\[\[([^\]|#]+)", body)] + return found + + +# what a list takes from the wiki: (shop, where, heading, name). +# where "category": the shop's item category, now and formerly; +# "page": the items listed on the shop's page. +# heading with "page", only sections whose heading path matches. +# name only items whose name matches (a leading "!" for "does not"). +def category(shop, name=None): + return (shop, "category", None, name) + + +def page(shop, heading=None, name=None): + return (shop, "page", heading, name) + + +NEW_YEARS = ["Chinese New Year Shop"] + ["Year of the %s Shop" % animal for animal in ( + "Dog", "Dragon", "Horse", "Ox", "Pig", "Rabbit", "Rat", "Rooster", "Snake", "Tiger")] +PARTY_MUSIC = r"music" + +# generic list id -> what it sells. "music": True keeps only music tracks, +# False keeps them out (a party's furniture stand next to its jukebox). +# "kinds" names the one kind a diamond list sells, which can hold both. +LISTS = { + # the lands. 11, 50, 12, 51, 56, 85 and 234 are named in the client + # (GenericListXtCommManager); the rest follow from the room each list + # stands in. + 11: {"from": [category("Jam Mart Clothing")]}, + 12: {"from": [category("Jam Mart Furniture")], "music": False}, + 234: {"from": [category("Jam Mart Furniture (New Jammer)")]}, + 56: {"from": [category("Music Shop")], "music": True}, + 5: {"from": [category("Shiveer Shoppe")]}, + 9: {"from": [category("Mystery Emporium")]}, + 113: {"from": [category("Treetop Gardens")]}, + 323: {"from": [category("Topiary Shop")]}, + 589: {"from": [category("Topiary Shop (Lit)")]}, + 778: {"from": [category("Eco Shop")]}, + 362: {"from": [category("Theater Shop")]}, + 184: {"from": [category("Museum Shop")]}, + 85: {"from": [category("Pet Den Item Shop")]}, + 50: {"from": [category("Bahari Bargains")]}, + 51: {"from": [category("Sunken Treasures")]}, + 626: {"from": [category("Ocean Diamond Shop")], "kinds": ["clothing"]}, # the clam in Bahari Bargains: clothing + 625: {"from": [category("Ocean Diamond Shop")], "kinds": ["den"]}, # the shelf in Sunken Treasures: den items + 250: {"from": [category("Marine Marvels")]}, + 212: {"from": [page("Royal Ridge")]}, # "airshop": the one only flying animals reach + 59: {"from": [category("Epic Wonders")]}, + 423: {"from": [category("Epic Wonders")], "kinds": ["den"]}, # the lower orb + 420: {"from": [category("Studio Corner")]}, + 63: {"from": [category("Sol Arcade Shop")]}, + 374: {"from": [category("Astronomy Shop")]}, + 177: {"from": [category("Outback Imports")]}, + 178: {"from": [category("Hospital Shop")]}, + 179: {"from": [category("Adventure Shop")]}, + 687: {"from": [category("Ancient Antiquities")]}, + # guessed which of the temple's two windows is which, by the order the + # shops opened in (the armory first). + 688: {"from": [category("Ancient Armory")]}, + 713: {"from": [category("Ancient Treasures")]}, + 801: {"from": [category("Jambassador Plushie Shop")]}, + 790: {"from": [category("Spooky Shop (Phantom Vortex)")]}, + 584: {"from": [page(r"??? (Epic Dens)")]}, + # the two shops this server filled with what was never sold anywhere + # (ODDITY_SHOPS in lib/world.js) get their real shelves in front of that. + 396: {"from": [page(r"??? (Basement of Secrets)")]}, + 666: {"from": [category("Forgotten Relics")]}, + + # the Diamond Shop. guessed: 415 as the clothing window (the newer list; + # the two were one window until 2016), 167 as the den items, 168 + # ("armor") as the armour among the clothing. + 415: {"from": [category("Diamond Shop")], "kinds": ["clothing"]}, + 168: {"from": [category("Diamond Shop", r"armou?r|helmet|gauntlet|amulet|sword|shield")], "kinds": ["clothing"]}, + 167: {"from": [category("Diamond Shop", r"!mannequin")], "kinds": ["den"], "music": False}, + 173: {"from": [category("Diamond Shop")], "kinds": ["den"], "music": True}, + 684: {"from": [page("Diamond Shop", r"^Mannequins")]}, + 689: {"from": [page("Diamond Shop", r"^Deep Blue")]}, + # alpha Headquarters: six stands, one alpha's armour each. guessed which + # stand is whose (the stands are numbered 1 to 6 in the room file, the + # alphas taken in the wiki's order). + 677: {"from": [category("Alpha Headquarters", r"peck")]}, + 678: {"from": [category("Alpha Headquarters", r"greely")]}, + 676: {"from": [category("Alpha Headquarters", r"gilbert")]}, + 680: {"from": [category("Alpha Headquarters", r"liza")]}, + 679: {"from": [category("Alpha Headquarters", r"graham")]}, + 681: {"from": [category("Alpha Headquarters", r"cosmo")]}, + # hall of Animals. the plushies and the coins are named in the room + # file; which of the three tables has banners, statues and flags is + # guessed. + 805: {"from": [page("Hall of Animals", r"Animal Banners")]}, + 806: {"from": [page("Hall of Animals", r"Alpha Statues")]}, + 803: {"from": [page("Hall of Animals", r"Flags")]}, + 807: {"from": [page("Hall of Animals", r"Giant Animal Plushies")]}, + 817: {"from": [page("Hall of Animals", r"Animal Coins")]}, + + # parties. + 61: {"from": [category("Jamaaliday Shop")], "music": False}, + 138: {"from": [category("Jamaaliday Shop")], "music": True}, + 709: {"from": [page("Giant Gift Pile (Shop)")]}, + 67: {"from": [page("Dinner Shop")]}, + 68: {"from": [page("Friendship Shop")]}, + 70: {"from": [page("Heatwave Shop")]}, + 71: {"from": [page("Leap Year Accessories")]}, + 72: {"from": [page("Leap Year Den Items")]}, + 74: {"from": [page("Lucky Shop")]}, + 81: {"from": [page("Wolves Only Shop")]}, + 83: {"from": [page("Horses Only Shop")]}, + 84: {"from": [page("Horses Only Shop")], "music": False}, + 90: {"from": [page("Horses Only Shop")], "music": True}, + 82: {"from": [page("April Fools' Shop")]}, + 216: {"from": [page("April Fools' Shop")]}, + 87: {"from": [page("Atlantis Shop")]}, + 88: {"from": [page("Atlantis Shop")]}, + 92: {"from": [page("Spooky Shop")]}, + 93: {"from": [page("Spooky Shop")], "music": False}, + 94: {"from": [page("Spooky Shop")], "music": True}, + 95: {"from": [page("Cruise Ship Shop")]}, + 96: {"from": [page("Cruise Ship Shop")]}, + 99: {"from": [page("Bunnies Only Shop")], "music": False}, + 100: {"from": [page("Bunnies Only Shop")], "music": True}, + 104: {"from": [page("Penguins Only Shop")], "music": False}, + 106: {"from": [page("Penguins Only Shop")], "music": True}, + 107: {"from": [category("Freedom Shop")]}, + 108: {"from": [category("Freedom Shop")]}, + 111: {"from": [page("Pets Only Shop")], "music": False}, + 112: {"from": [page("Pets Only Shop")], "music": True}, + 116: {"from": [page("Monkeys Only Shop")], "music": False}, + 117: {"from": [page("Monkeys Only Shop")], "music": True}, + 118: {"from": [page("AJ Birthday Shop")], "music": False}, + 119: {"from": [page("AJ Birthday Shop")], "music": True}, + 346: {"from": [page("AJ Birthday Shop")]}, + 122: {"from": [page("Haunted Forest Shop")]}, + 123: {"from": [page("Haunted Forest Shop")], "music": False}, + 124: {"from": [page("Haunted Forest Shop")], "music": True}, + 143: {"from": [page("New Year's Shop")]}, + 144: {"from": [page("New Year's Shop")], "music": False}, + 145: {"from": [page("New Year's Shop")], "music": True}, + 161: {"from": [page("Jam Session Shop")]}, + 164: {"from": [page("Jam Session Shop")], "music": False}, + 163: {"from": [page("Jam Session Shop")], "music": True}, + 191: {"from": [category("Play-As-Your-Pet Shop")], "music": False}, + 192: {"from": [category("Play-As-Your-Pet Shop")], "music": False}, + 193: {"from": [category("Play-As-Your-Pet Shop")], "music": True}, + 238: {"from": [category("Beta Shop")]}, + 271: {"from": [page("Bounce House Shop")]}, + 324: {"from": [page("Cloud Shop")]}, + 325: {"from": [page("Cloud Shop")]}, + 345: {"from": [page("Schoolhouse Shop")]}, + 150: {"from": [page("Paradise Shop")]}, + 400: {"from": [category("Candy Shop")]}, + # one party room for every year's animal: all their shops together. + 399: {"from": [category(shop) for shop in NEW_YEARS]}, + # the Phantom Emporium's three rooms. + 816: {"from": [page("Phantom Emporium (Shop)")]}, + 818: {"from": [page("Phantom Emporium (Shop)")]}, + 819: {"from": [page("Phantom Emporium (Shop)")]}, +} + + +def main(workdir, out_path=OUT): + wiki, pages = download(workdir) + ids = {} + for kind in ("clothing", "den"): + for title, def_id in wiki["ids"][kind].items(): + if def_id.isdigit(): + ids.setdefault(title.lower(), []).append((kind, int(def_id))) + unknown = set() + + def matching(pattern, text): + if not pattern: + return True + if pattern.startswith("!"): + return not re.search(pattern[1:], text, re.I) + return bool(re.search(pattern, text, re.I)) + + def take(titles, name): + return [item for title in titles if matching(name, title) for item in ids.get(title.lower(), [])] + + lists = {} + for list_id, spec in sorted(LISTS.items()): + now, former, shops = [], [], [] + for shop, where, heading, name in spec["from"]: + shops.append(shop) + if where == "category": + now += take(wiki["shops"][shop]["now"], name) + former += take(wiki["shops"][shop]["former"], name) + else: + for head, body in sections(pages[shop]): + if matching(heading, head): + found = names(latest_tab(body)) + unknown.update(n for n in found if n and n.lower() not in ids and len(n) < 40) + now += take(found, name) + entry = {"shop": " + ".join(shops) if len(shops) < 3 else shops[0] + " and others"} + if "music" in spec: + entry["music"] = spec["music"] + for label, items in (("now", now), ("former", [item for item in former if item not in now])): + unique = list(dict.fromkeys(items)) + entry[label] = {kind: [def_id for item_kind, def_id in unique if item_kind == kind and kind in spec.get("kinds", (kind,))] + for kind in ("clothing", "den")} + lists[str(list_id)] = entry + print("%4d %-34s now %3d clothing %3d den former %4d" % ( + list_id, entry["shop"][:34], len(entry["now"]["clothing"]), len(entry["now"]["den"]), + len(entry["former"]["clothing"]) + len(entry["former"]["den"]))) + out = {"source": "AJ Classic Wiki (animaljam.fandom.com), read by tools/shop-stock.py", "lists": lists} + with open(out_path, "w") as handle: + handle.write(json.dumps(out, separators=(",", ":")).replace('"lists":{', '"lists":{\n').replace('}},"', '}},\n"') + "\n") + print("\nnames on shop pages that are no item page (links to other pages, mostly):") + print(", ".join(sorted(unknown))) + + +if __name__ == "__main__": + if len(sys.argv) not in (2, 3): + raise SystemExit(__doc__) + main(*sys.argv[1:])