mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-18 17:27:50 -05:00
Compare commits
32
Commits
6645bf66b3
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e117ff26f | ||
|
|
29c0eff454 | ||
|
|
f72e346c03 | ||
|
|
4355994253 | ||
|
|
c7efda7030 | ||
|
|
7de41ceed5 | ||
|
|
15f321fb00 | ||
|
|
6c273554d7 | ||
|
|
22fb7f0fa5 | ||
|
|
e9097a9a4f | ||
|
|
7cfef493fa | ||
|
|
44af83f1c5 | ||
|
|
b22708a4ba | ||
|
|
494f252c5b | ||
|
|
6b707fbc1d | ||
|
|
b45fd195df | ||
|
|
e2454447d9 | ||
|
|
0da5daabc9 | ||
|
|
3b53c8dab8 | ||
|
|
83c2fc3b0b | ||
|
|
c1a85f9b5d | ||
|
|
d44612bd08 | ||
|
|
9156c6e392 | ||
|
|
3930d2dabe | ||
|
|
9985ae7625 | ||
|
|
3139384ef3 | ||
|
|
e67fbe95e1 | ||
|
|
3423df10f8 | ||
|
|
8839f86e6c | ||
|
|
92ebb4d07c | ||
|
|
974f68490e | ||
|
|
43f2717b44 |
No files matched your search
@@ -5,6 +5,7 @@
|
||||
"cdn.jsdelivr.net",
|
||||
"challenges.cloudflare.com",
|
||||
"discord.com",
|
||||
"duckduckgo.com",
|
||||
"play.burrow.moe",
|
||||
"player.vimeo.com",
|
||||
"vision.googleapis.com",
|
||||
|
||||
@@ -101,6 +101,10 @@ module.exports = {
|
||||
// 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,
|
||||
// A stalled CAPTCHA provider must not consume all of the VPS's outbound
|
||||
// sockets. This only limits simultaneous verification requests; normal
|
||||
// players use one, and a rejected request can safely be retried.
|
||||
maxConcurrentCaptchaChecks: Math.max(1, Math.min(100, Number(env.AJ_CAPTCHA_MAX_CONCURRENT) || 24)),
|
||||
|
||||
// Account-recovery mail is delivered to this HTTPS webhook. It receives
|
||||
// {to, subject, text}; point it at the transactional-mail provider or
|
||||
@@ -168,7 +172,9 @@ module.exports = {
|
||||
// 49 and 50: its link to a colour picker.
|
||||
// 61: the Owner, Moderator, Developer and Verified name tag badges seen by everyone.
|
||||
// 62: "Custom pictures" in the settings menu, to hide players' item pictures.
|
||||
buildVersion: env.AJ_BUILD_VERSION || "82",
|
||||
// 83: den items tinted (the tint in their version, DenItemHelper.applyTint).
|
||||
// 84: fixes from the owner's list of bugs (bugs.txt, 2026-10-23).
|
||||
buildVersion: env.AJ_BUILD_VERSION || "92",
|
||||
// what the official CDN is asked for; not ours to change.
|
||||
upstreamBuildVersion: "3",
|
||||
|
||||
@@ -201,7 +207,7 @@ module.exports = {
|
||||
// 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-21",
|
||||
termsVersion: "2026-10-24",
|
||||
legalEmail: env.AJ_LEGAL_EMAIL || "[email protected]",
|
||||
adminEmail: env.AJ_ADMIN_EMAIL || "[email protected]",
|
||||
operator: env.AJ_OPERATOR || "an individual based in the European Union",
|
||||
@@ -310,6 +316,9 @@ module.exports = {
|
||||
// world N after the Nth name of its own list (551 Aldan, 552 Congo...,
|
||||
// generic list 16), so the names here are only for the panels and logs.
|
||||
// AJ_WORLDS: how many (the tests' is one).
|
||||
// the admin panel can change how many while the server runs (lib/world.js
|
||||
// setWorldCount), which then outlasts a restart.
|
||||
worldNames: ["Aldan", "Congo", "Draa", "Grande", "Kama", "Nile", "Pecos", "Ramu", "Tigris", "Zambezi"],
|
||||
shards: ["Aldan", "Congo", "Draa", "Grande", "Kama", "Nile", "Pecos", "Ramu", "Tigris", "Zambezi"]
|
||||
.slice(0, Math.min(10, Math.max(1, Number(env.AJ_WORLDS) || 2))).map((name, i) => ({id: i + 1, name})),
|
||||
maxUsersPerRoom: 40,
|
||||
@@ -376,6 +385,13 @@ module.exports = {
|
||||
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
|
||||
roomActionsPerWindow: 6, // emotes, actions and the like one player may send a room ...
|
||||
roomActionWindowMs: 3000, // ... in this long (the rest reach nobody)
|
||||
// eco den items (lib/eco.js): credits an hour for each point of eco power
|
||||
// placed in a den, and what an account is given the first time it looks
|
||||
// (an Eco Solar Panel's price)
|
||||
ecoCreditsPerPointHour: 1,
|
||||
ecoStartCredits: 1500,
|
||||
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
|
||||
|
||||
+33
-1
@@ -61,6 +61,7 @@ const USER_VAR_SETTINGS = 363; // the settings menu's switches, a bit each (gui.
|
||||
// the chat filter an account starts with: level 1 slurs and threats, mode 1
|
||||
// the whole message left out (see account.filter below).
|
||||
const DEFAULT_FILTER = {level: 1, mode: 1, words: ""};
|
||||
const chatStyles = require("./chatstyles.js");
|
||||
const MAX_PASSWORD_LENGTH = 100;
|
||||
const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
// parts of the game a player can switch off for their own account, each
|
||||
@@ -250,6 +251,9 @@ const normalize = account => {
|
||||
// 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;
|
||||
// Personal chat appearance. The renderer receives it with each spoken line
|
||||
// (lib/world.js), never as a client-controlled packet field.
|
||||
account.chatStyle = chatStyles.normalize(account.chatStyle);
|
||||
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 Discord gave it (lib/discord.js)
|
||||
@@ -737,6 +741,34 @@ const register = (username, password, avatar = {}) => {
|
||||
return {account};
|
||||
};
|
||||
|
||||
// Public sign-ups can arrive in a burst. scryptSync is fine for the local,
|
||||
// legacy Create Account socket but it would freeze all players while each web
|
||||
// registration is derived. Keep the same validation and database insert on
|
||||
// the main thread, but derive its password on libuv's worker pool. Check the
|
||||
// username again after awaiting: another request may have claimed it first.
|
||||
const registerAsync = async (username, password, avatar = {}) => {
|
||||
username = typeof username === "string" ? username.trim() : username;
|
||||
let error = usernameProblem(username) || passwordProblem(password, username) || (defpacks.avatarDef(avatar.type) ? null : "choose_animal");
|
||||
if (error) {
|
||||
return {error};
|
||||
}
|
||||
const salt = crypto.randomBytes(16).toString("hex");
|
||||
const hash = await hashPasswordAsync(password, salt);
|
||||
error = usernameProblem(username) || passwordProblem(password, username) || (defpacks.avatarDef(avatar.type) ? null : "choose_animal");
|
||||
if (error) {
|
||||
return {error};
|
||||
}
|
||||
const type = Number(avatar.type);
|
||||
const account = insert(username, salt, hash, now(), {
|
||||
avatars: [newAvatar({perUserAvId: 1, avInvId: 1}, avatar.name || username, type, -1)],
|
||||
activeAvatar: 1,
|
||||
badges: byId.size < EARLY_MEMBERS ? [EARLY_BADGE] : [],
|
||||
recoveryEmail: typeof avatar.email === "string" && EMAIL_PATTERN.test(avatar.email.trim()) ? avatar.email.trim().toLowerCase() : "",
|
||||
});
|
||||
console.log(`[accounts] registered "${logText(username)}" (id ${logText(account.id)})`);
|
||||
return {account};
|
||||
};
|
||||
|
||||
const authenticate = (username, password) => {
|
||||
// "name" and "name " are the same account.
|
||||
const account = typeof username === "string" ? touch(byKey.get(username.trim().toLowerCase())) : null;
|
||||
@@ -954,4 +986,4 @@ const all = () => [...byId.values()];
|
||||
|
||||
const database = () => db;
|
||||
|
||||
module.exports = {FEATURES, featureOn, recordLogin, revokeTokens, load, save, flush, hold, release, startBackups, database, setLoginChoices, setPassword, rename, remove, setting, setSetting, hashPassword, register, usernameProblem, authenticate, authenticateAsync, issueToken, byToken, byName, nameOf, byId: accountById, newAvatar, freeAvatarSlot, all};
|
||||
module.exports = {FEATURES, featureOn, recordLogin, revokeTokens, load, save, flush, hold, release, startBackups, database, setLoginChoices, setPassword, rename, remove, setting, setSetting, hashPassword, register, registerAsync, usernameProblem, authenticate, authenticateAsync, issueToken, byToken, byName, nameOf, byId: accountById, newAvatar, freeAvatarSlot, all};
|
||||
+140
-4
@@ -2,6 +2,8 @@
|
||||
|
||||
const accounts = require("./accounts.js");
|
||||
const bans = require("./bans.js");
|
||||
const cdn = require("./cdn.js");
|
||||
const colours = require("./colours.js");
|
||||
const captcha = require("./captcha.js");
|
||||
const defpacks = require("./defpacks.js");
|
||||
const devices = require("./devices.js");
|
||||
@@ -10,6 +12,7 @@ const roles = require("./roles.js");
|
||||
const dens = require("./dens.js");
|
||||
const itemControl = require("./itemcontrol.js");
|
||||
const customItems = require("./customitems.js");
|
||||
const itemArt = require("./itemart.js");
|
||||
const limits = require("./limits.js");
|
||||
const world = require("./world.js");
|
||||
const {addClothing, sendClothingAdded, isUint} = require("./player.js");
|
||||
@@ -71,6 +74,24 @@ const search = (params, favourites = null, seesLocked = false, askerId = null) =
|
||||
};
|
||||
};
|
||||
|
||||
// the variants each den item's art has (tools/den-variants.sh):
|
||||
// {versions: [...], colours?: [[hex, ...] per variant]}, or null.
|
||||
let denVariants = null;
|
||||
const variantsOf = id => {
|
||||
if (!denVariants) {
|
||||
try {
|
||||
denVariants = require("./den-variants.json");
|
||||
}
|
||||
catch (err) {
|
||||
denVariants = {};
|
||||
}
|
||||
}
|
||||
return denVariants[Number(id)] || null;
|
||||
};
|
||||
const SPECIAL_MANNEQUIN = "4";
|
||||
const MAX_TINT_SLOT = 0x7FFFFF; // what fits above a den item's variant (8 bits) in its version, kept positive
|
||||
const MAX_PRESETS = 40;
|
||||
|
||||
// one to four "#RRGGBB", spaces or commas between. the # is wanted: six
|
||||
// digits alone are a colour id
|
||||
const HEX_COLOURS = /^#[0-9a-f]{6}([\s,]+#[0-9a-f]{6}){0,3}$/i;
|
||||
@@ -89,6 +110,7 @@ const give = (body, seesLocked = false) => {
|
||||
return {status: 403, body: {error: "That item is locked out of the item finder."}};
|
||||
}
|
||||
const session = world.findOnline(account.username);
|
||||
const given = {}; // what the item was given as: its colour, or its version
|
||||
if (body.kind === "clothing") {
|
||||
const def = defpacks.itemDef(body.id);
|
||||
const colors = def ? String(def.colors).split(",") : [];
|
||||
@@ -119,6 +141,9 @@ const give = (body, seesLocked = false) => {
|
||||
if (custom && !isUint(custom)) {
|
||||
return {status: 400, body: {error: "Colour: an id, or #RRGGBB"}};
|
||||
}
|
||||
if (custom && !colours.known(Number(custom))) {
|
||||
return {status: 400, body: {error: "No such custom colour"}};
|
||||
}
|
||||
const color = custom || 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"}};
|
||||
@@ -127,6 +152,7 @@ const give = (body, seesLocked = false) => {
|
||||
if (!item) {
|
||||
return {status: 409, body: {error: "That inventory is full"}};
|
||||
}
|
||||
given.color = Number(color);
|
||||
accounts.save(account);
|
||||
if (session) {
|
||||
sendClothingAdded(session, item);
|
||||
@@ -136,12 +162,48 @@ const give = (body, seesLocked = false) => {
|
||||
if (!defpacks.denItemIds().includes(Number(body.id))) {
|
||||
return {status: 400, body: {error: "No such den item"}};
|
||||
}
|
||||
if (!dens.giveDenItem(account, body.id)) {
|
||||
// `version`: one of the variants its art has (above), 0 by default.
|
||||
// `tint` ("#RRGGBB") and `tintStrength` (1-100, 100 by default): the
|
||||
// whole item in shades of that colour, which the patched client draws
|
||||
// (DenItemHelper.applyTint). the tint is a custom colour entry
|
||||
// (lib/colours.js, [rgb, strength, 0, 0]), and 1 + its number goes in
|
||||
// the version above the variant's 8 bits, so it goes wherever the item
|
||||
// goes: dens, trades, gifts.
|
||||
const variants = variantsOf(body.id);
|
||||
const variant = body.version === undefined || body.version === "" ? 0 : Number(body.version);
|
||||
if (!Number.isInteger(variant) || (variant !== 0 && !(variants && variants.versions.includes(variant)))) {
|
||||
return {status: 400, body: {error: "That item has no such variant"}};
|
||||
}
|
||||
let version = variant;
|
||||
const tint = typeof body.tint === "string" ? body.tint.trim() : "";
|
||||
if (tint) {
|
||||
const strength = body.tintStrength === undefined || body.tintStrength === "" ? 100 : Number(body.tintStrength);
|
||||
if (!/^#[0-9a-f]{6}$/i.test(tint) || !Number.isInteger(strength) || strength < 1 || strength > 100) {
|
||||
return {status: 400, body: {error: "Tint: #RRGGBB, strength 1 to 100"}};
|
||||
}
|
||||
if ((defpacks.denItemDef(body.id) || {}).specialType === SPECIAL_MANNEQUIN) {
|
||||
return {status: 400, body: {error: "Mannequins cannot be tinted"}};
|
||||
}
|
||||
const entry = world.makeColour(account, [parseInt(tint.slice(1), 16), strength, 0, 0], session);
|
||||
if (!entry) {
|
||||
return {status: 400, body: {error: "Bad colour"}};
|
||||
}
|
||||
if (entry.full) {
|
||||
return {status: 429, body: {error: "No more new colours today. Colours made before can still be used."}};
|
||||
}
|
||||
const slot = entry.id - colours.CUSTOM_BASE + 1;
|
||||
if (slot > MAX_TINT_SLOT) {
|
||||
return {status: 503, body: {error: "No more tints can be made"}};
|
||||
}
|
||||
version |= slot << 8;
|
||||
}
|
||||
if (!dens.giveDenItem(account, body.id, version)) {
|
||||
return {status: 409, body: {error: "That inventory is full"}};
|
||||
}
|
||||
if (session) {
|
||||
dens.sendDenItems(session);
|
||||
}
|
||||
given.version = version;
|
||||
}
|
||||
else {
|
||||
return {status: 400, body: {error: "Unknown item kind"}};
|
||||
@@ -152,7 +214,81 @@ const give = (body, seesLocked = false) => {
|
||||
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(account);
|
||||
return {status: 200, body: {ok: true, online: Boolean(session)}};
|
||||
return {status: 200, body: {ok: true, online: Boolean(session), ...given}};
|
||||
};
|
||||
|
||||
// the game's 256 colours (the CDN's paletteData; PaletteHelper.setGamePalette),
|
||||
// as "rrggbb", once read. null while the file cannot be had.
|
||||
let palette = null;
|
||||
const loadPalette = async () => {
|
||||
if (!palette) {
|
||||
const file = await cdn.get(cdn.hashedPath("paletteData"));
|
||||
if (file && file.length >= 4 && file.readInt32BE(0) === 1024) {
|
||||
palette = Array.from({length: 256}, (unused, index) => (file.readUInt32BE(4 + index * 4) & 0xFFFFFF).toString(16).padStart(6, "0"));
|
||||
}
|
||||
}
|
||||
return palette;
|
||||
};
|
||||
// a packed colour's four, as "rrggbb" (a custom colour's own, or the
|
||||
// palette's at each of its four bytes, colour 1 the top one).
|
||||
const coloursOf = id => {
|
||||
const custom = colours.rgbsOf(id);
|
||||
if (custom) {
|
||||
return custom.map(rgb => rgb.toString(16).padStart(6, "0"));
|
||||
}
|
||||
return palette ? [24, 16, 8, 0].map(shift => palette[(id >>> shift) & 0xFF]) : null;
|
||||
};
|
||||
|
||||
// the web item giver (/account/items, lib/manage.js): a search as the
|
||||
// in-game one, with what each item may be given as: a clothing item's own
|
||||
// colours, a den item's variants and whether it takes a tint.
|
||||
const searchFor = async (account, params) => {
|
||||
await loadPalette();
|
||||
const found = search(params, account.finderGiven, roles.can(account, "items.create"), account.id);
|
||||
return {...found, results: found.results.map(result => {
|
||||
// a custom item's own picture, which the game shows in place of its art
|
||||
const custom = customItems.get(result.kind, result.id);
|
||||
const entry = {...result, art: custom ? itemArt.urlOf(custom, "/account/api/itemart") : null};
|
||||
if (entry.kind === "clothing") {
|
||||
const def = defpacks.itemDef(entry.id);
|
||||
const ids = def ? String(def.colors).split(",").map(Number).filter(Number.isInteger).slice(0, MAX_PRESETS) : [];
|
||||
return {...entry, presets: ids.map(id => ({id: id >>> 0, colours: coloursOf(id >>> 0)}))};
|
||||
}
|
||||
const variants = variantsOf(entry.id);
|
||||
return {...entry, variants: variants ? variants.versions : [], variantColours: variants && variants.colours ? variants.colours : null,
|
||||
tintable: (defpacks.denItemDef(entry.id) || {}).specialType !== SPECIAL_MANNEQUIN};
|
||||
})};
|
||||
};
|
||||
|
||||
// ... and its colour boxes, which turn colours to the game's numbers and
|
||||
// back as they are typed: with `id`, a custom colour's four ("rrggbb"); with
|
||||
// `rgbs` (four "rrggbb", commas between), the custom colour already made of
|
||||
// those four, or null (Give would make it); with neither, the game's 256.
|
||||
const colourLookup = async params => {
|
||||
if (params.has("id")) {
|
||||
const text = params.get("id");
|
||||
const id = /^-?\d{1,10}$/.test(text) && Number(text) >= -0x80000000 && Number(text) <= 0xFFFFFFFF ? Number(text) >>> 0 : null;
|
||||
const rgbs = id === null ? null : colours.rgbsOf(id);
|
||||
return rgbs ? {status: 200, body: {id, colours: rgbs.map(rgb => rgb.toString(16).padStart(6, "0"))}}
|
||||
: {status: 404, body: {error: "No such custom colour"}};
|
||||
}
|
||||
if (params.has("rgbs")) {
|
||||
const rgbs = params.get("rgbs").split(",").map(hex => (/^[0-9a-f]{6}$/i.test(hex) ? parseInt(hex, 16) : NaN));
|
||||
const entry = colours.allocate(rgbs, false);
|
||||
if (!entry) {
|
||||
return {status: 400, body: {error: "Four colours: rrggbb,rrggbb,rrggbb,rrggbb"}};
|
||||
}
|
||||
return {status: 200, body: {id: entry.full ? null : entry.id}};
|
||||
}
|
||||
return {status: 200, body: {palette: await loadPalette()}};
|
||||
};
|
||||
|
||||
// ... and its Give, for the account signed in on that page.
|
||||
const giveAs = (account, body) => {
|
||||
if (!givesPerMinute.allow(account.id)) {
|
||||
return {status: 429, body: {error: "Too many at once. Try again in a minute."}};
|
||||
}
|
||||
return give({...body, username: account.username}, roles.can(account, "items.create"));
|
||||
};
|
||||
|
||||
const FORBIDDEN = {status: 403, body: {error: "forbidden"}};
|
||||
@@ -282,7 +418,7 @@ const handle = async (route, params, body, from) => {
|
||||
if (!STARTER_ANIMALS.includes(avatarType)) {
|
||||
return {status: 400, body: {error: "choose_animal"}};
|
||||
}
|
||||
const result = accounts.register(username, password, {type: avatarType, email});
|
||||
const result = await accounts.registerAsync(username, password, {type: avatarType, email});
|
||||
if (result.account) {
|
||||
result.account.agreed = {version: config.termsVersion, at: Math.floor(Date.now() / 1000)};
|
||||
accounts.save(result.account);
|
||||
@@ -296,4 +432,4 @@ const handle = async (route, params, body, from) => {
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {handle, search};
|
||||
module.exports = {handle, search, searchFor, colourLookup, giveAs};
|
||||
@@ -537,9 +537,12 @@ module.exports = {
|
||||
for (const number of [2, 3, 4]) {
|
||||
set(q, `cork_${number}${pick("abc")}`, 1, 1, 0);
|
||||
}
|
||||
for (const number of [1, 2, 3, 4]) {
|
||||
// the last key's other places lie off where an animal can walk:
|
||||
// players had to jump to it. it lies where the recording had it.
|
||||
for (const number of [1, 2, 3]) {
|
||||
set(q, `bunny_key_${number}${pick("abcdef")}`, 1, 1, 0);
|
||||
}
|
||||
set(q, "bunny_key_4c", 1, 1, 0);
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
+15
-1
@@ -307,7 +307,21 @@ class Amf3Writer {
|
||||
this.value(element);
|
||||
}
|
||||
}
|
||||
else if (typeof value === "object" && !Buffer.isBuffer(value)) {
|
||||
else if (value instanceof Date) {
|
||||
// A date (a room file's timestamps): its milliseconds, written in place.
|
||||
this.byte(0x08);
|
||||
this.u29(1);
|
||||
this.room(8);
|
||||
this.pos = this.buf.writeDoubleBE(value.getTime(), this.pos);
|
||||
}
|
||||
else if (Buffer.isBuffer(value)) {
|
||||
// A ByteArray (a room file's pictures and shapes).
|
||||
this.byte(0x0c);
|
||||
this.u29((value.length << 1) | 1);
|
||||
this.room(value.length);
|
||||
this.pos += value.copy(this.buf, this.pos);
|
||||
}
|
||||
else if (typeof value === "object") {
|
||||
// A dynamic object of no class, with its traits written in place.
|
||||
this.byte(0x0a);
|
||||
this.byte(0x0b);
|
||||
|
||||
@@ -97,6 +97,12 @@ module.exports = ({others, findOnline, findBySfsId, refreshForOthers, petFields}
|
||||
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);
|
||||
// Nothing more goes to the switching player here. The client swaps the
|
||||
// animals during the transform animation (AvatarSwitch "hideAvatar"),
|
||||
// copying the in-world avatar into the switcher slot first and asking
|
||||
// for "ad" itself when it needs to. An unasked "ad"/"il" lands on the
|
||||
// in-world avatar before that copy, so the old animal vanished from the
|
||||
// switcher and the new one showed twice.
|
||||
if (session.pos) {
|
||||
for (const other of others(session)) {
|
||||
other.sendXt("as", messageRoom, ...common, ...petFields(activePet(account)), avatar.questLevel || 0);
|
||||
|
||||
+13
-1
@@ -26,10 +26,12 @@ const MAX_ANSWER_LENGTH = 2048;
|
||||
const PASS_MS = 600000;
|
||||
const PASS_USES = 5;
|
||||
const MAX_PASSES = 10000;
|
||||
const MAX_VERIFYING = config.maxConcurrentCaptchaChecks;
|
||||
|
||||
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");
|
||||
let verifying = 0;
|
||||
|
||||
// for the pages: what each answer means
|
||||
const MESSAGES = {
|
||||
@@ -70,6 +72,13 @@ const verify = async (answer, from, action) => {
|
||||
if (typeof answer !== "string" || !answer || answer.length > MAX_ANSWER_LENGTH) {
|
||||
return "captcha_required";
|
||||
}
|
||||
// A burst of valid-looking tokens should not turn an upstream Turnstile
|
||||
// slowdown into thousands of open fetches on this VPS. Refuse quickly;
|
||||
// the browser can reset its widget and retry after the short outage.
|
||||
if (verifying >= MAX_VERIFYING) {
|
||||
return "captcha_unavailable";
|
||||
}
|
||||
verifying++;
|
||||
const form = new URLSearchParams({secret: config.turnstile.secret, response: answer});
|
||||
if (!limits.isLoopback(from.address)) {
|
||||
form.set("remoteip", from.address);
|
||||
@@ -83,6 +92,9 @@ const verify = async (answer, from, action) => {
|
||||
console.log(`[captcha] cloudflare did not answer: ${logText(err.message)}`);
|
||||
return "captcha_unavailable";
|
||||
}
|
||||
finally {
|
||||
verifying--;
|
||||
}
|
||||
// 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)) {
|
||||
@@ -107,7 +119,7 @@ const check = async (body, from, action, account) => {
|
||||
// a page's security policy: public/captcha.js always (the page calls it even
|
||||
// when off), and the widget too when it is on.
|
||||
const policy = csp => (on
|
||||
? `${csp.replace("script-src ", `script-src 'self' ${ORIGIN} `)}; frame-src ${ORIGIN}`
|
||||
? `${csp.replace("script-src ", `script-src 'self' ${ORIGIN} `).replace("connect-src ", `connect-src 'self' ${ORIGIN} `)}; frame-src ${ORIGIN}`
|
||||
: csp.replace("script-src ", "script-src 'self' "));
|
||||
|
||||
// a page with public/captcha.js asked for under a name that changes with the
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
"use strict";
|
||||
|
||||
// The style travels with a chat line, rather than with an avatar-create
|
||||
// packet, so a new choice takes effect immediately and is seen by everybody
|
||||
// who sees that line. Keep it small and entirely server-generated: clients
|
||||
// never get to choose the fields sent to other players.
|
||||
const DEFAULT = Object.freeze({background: "ffffff", accent: "dfe8ff", text: "445559", border: "9aabb0", opacity: 75,
|
||||
animation: "none", speed: 100, gradient: "linear", angle: 45, strength: 100, outline: 1,
|
||||
stops: "ffffff:0;dfe8ff:100"});
|
||||
const ANIMATIONS = new Set(["none", "pulse", "shimmer", "flow", "rainbow"]);
|
||||
const GRADIENTS = new Set(["solid", "linear", "radial"]);
|
||||
const COLOR = /^[0-9a-f]{6}$/i;
|
||||
|
||||
const color = (value, fallback) => typeof value === "string" && COLOR.test(value) ? value.toLowerCase() : fallback;
|
||||
const number = (value, fallback, low, high) => Number.isInteger(value) && value >= low && value <= high ? value : fallback;
|
||||
const direction = value => {
|
||||
const angle = number(value, DEFAULT.angle, 0, 315);
|
||||
return angle % 45 === 0 ? angle : DEFAULT.angle;
|
||||
};
|
||||
|
||||
const stops = (value, background, accent) => {
|
||||
if (typeof value === "string") {
|
||||
const parsed = value.split(";").map(stop => {
|
||||
const match = /^([0-9a-f]{6}):(100|[1-9]?\d)$/i.exec(stop);
|
||||
return match ? {color: match[1].toLowerCase(), position: Number(match[2])} : null;
|
||||
});
|
||||
if (parsed.length >= 2 && parsed.length <= 5 && parsed.every(Boolean)
|
||||
&& parsed[0].position === 0 && parsed.at(-1).position === 100
|
||||
&& parsed.every((stop, index) => index === 0 || stop.position > parsed[index - 1].position)) {
|
||||
return parsed.map(stop => `${stop.color}:${stop.position}`).join(";");
|
||||
}
|
||||
}
|
||||
return `${background}:0;${accent}:100`;
|
||||
};
|
||||
|
||||
const normalize = value => {
|
||||
const source = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
||||
let background = color(source.background, DEFAULT.background);
|
||||
let accent = color(source.accent, DEFAULT.accent);
|
||||
const gradientStops = stops(source.stops, background, accent);
|
||||
const stopParts = gradientStops.split(";");
|
||||
background = stopParts[0].slice(0, 6);
|
||||
accent = stopParts.at(-1).slice(0, 6);
|
||||
return {
|
||||
background,
|
||||
accent,
|
||||
text: color(source.text, DEFAULT.text),
|
||||
border: color(source.border, DEFAULT.border),
|
||||
opacity: number(source.opacity, DEFAULT.opacity, 25, 100),
|
||||
animation: ANIMATIONS.has(source.animation) ? source.animation : DEFAULT.animation,
|
||||
speed: number(source.speed, DEFAULT.speed, 40, 300),
|
||||
gradient: GRADIENTS.has(source.gradient) ? source.gradient : DEFAULT.gradient,
|
||||
angle: direction(source.angle),
|
||||
strength: number(source.strength, DEFAULT.strength, 0, 100),
|
||||
outline: number(source.outline, DEFAULT.outline, 0, 4),
|
||||
stops: gradientStops,
|
||||
};
|
||||
};
|
||||
|
||||
const same = (one, two) => Object.keys(DEFAULT).every(key => one[key] === two[key]);
|
||||
|
||||
// `normalize` is intentionally forgiving when old account data is loaded.
|
||||
// Incoming editor requests are not: every field must already be canonical.
|
||||
const valid = value => Boolean(value) && typeof value === "object" && !Array.isArray(value)
|
||||
&& Object.keys(DEFAULT).every(key => value[key] === normalize(value)[key]);
|
||||
|
||||
const fields = value => {
|
||||
const style = normalize(value);
|
||||
return [style.background, style.accent, style.text, style.border, style.opacity, style.animation, style.speed,
|
||||
style.gradient, style.angle, style.strength, style.outline, style.stops];
|
||||
};
|
||||
|
||||
// Twelve comma-separated, URL-safe fields; empty means the original game bubble.
|
||||
const packet = value => {
|
||||
const style = normalize(value);
|
||||
return same(style, DEFAULT) ? "" : fields(style).join(",");
|
||||
};
|
||||
|
||||
module.exports = {DEFAULT, normalize, valid, fields, packet};
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
"use strict";
|
||||
|
||||
const accounts = require("./accounts.js");
|
||||
const defpacks = require("./defpacks.js");
|
||||
|
||||
// codes players type into the game's "Redeem Code" window
|
||||
// (gameRedemption.CodeRedemptionPopup, "grc" in lib/world.js), made in the
|
||||
// admin panel. a code gives one thing: a clothing item (in a colour), a den
|
||||
// item, gems or diamonds, as a gift from Burrow HQ (lib/ecards.js
|
||||
// sendFromHq). each account may use a code once; a code may also have an
|
||||
// end to how many times it is used in all, and is then spent.
|
||||
|
||||
const SCHEMA = `
|
||||
CREATE TABLE IF NOT EXISTS redeem_codes (
|
||||
code TEXT PRIMARY KEY,
|
||||
kind TEXT NOT NULL,
|
||||
item INTEGER NOT NULL DEFAULT 0,
|
||||
amount INTEGER NOT NULL DEFAULT 0,
|
||||
color INTEGER,
|
||||
uses INTEGER NOT NULL DEFAULT 0,
|
||||
used INTEGER NOT NULL DEFAULT 0,
|
||||
created_at INTEGER NOT NULL
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS redeem_uses (
|
||||
code TEXT NOT NULL,
|
||||
account_id INTEGER NOT NULL,
|
||||
at INTEGER NOT NULL,
|
||||
PRIMARY KEY (code, account_id)
|
||||
);
|
||||
`;
|
||||
|
||||
const KINDS = ["clothing", "den", "gems", "diamonds"];
|
||||
const CODE = /^[A-Z0-9-]{3,32}$/; // what the game's box lets be typed (and in capitals)
|
||||
const MAX_AMOUNT = 10000000;
|
||||
const MAX_USES = 1000000;
|
||||
|
||||
let made = false;
|
||||
const db = () => {
|
||||
const database = accounts.database();
|
||||
if (!made) {
|
||||
database.exec(SCHEMA);
|
||||
made = true;
|
||||
}
|
||||
return database;
|
||||
};
|
||||
const now = () => Math.floor(Date.now() / 1000);
|
||||
const normal = code => String(code || "").trim().toUpperCase();
|
||||
|
||||
const row = entry => ({code: entry.code, kind: entry.kind, item: entry.item, amount: entry.amount, color: entry.color,
|
||||
uses: entry.uses, used: entry.used, createdAt: entry.created_at});
|
||||
|
||||
const list = () => db().prepare("SELECT * FROM redeem_codes ORDER BY created_at DESC").all().map(row);
|
||||
|
||||
// {code, kind, item, amount, color, uses}: returns {ok} or {error}.
|
||||
const create = fields => {
|
||||
const code = normal(fields.code);
|
||||
const kind = String(fields.kind || "");
|
||||
const uses = Number(fields.uses) || 0;
|
||||
if (!CODE.test(code)) {
|
||||
return {error: "A code is 3 to 32 letters, digits and dashes."};
|
||||
}
|
||||
if (!KINDS.includes(kind)) {
|
||||
return {error: "A code gives clothing, a den item, gems or diamonds."};
|
||||
}
|
||||
if (!Number.isInteger(uses) || uses < 0 || uses > MAX_USES) {
|
||||
return {error: "Uses: 0 for any number, or how many in all."};
|
||||
}
|
||||
let item = 0;
|
||||
let amount = 0;
|
||||
let color = null;
|
||||
if (kind === "clothing") {
|
||||
item = Number(fields.item);
|
||||
const def = defpacks.itemDef(item);
|
||||
if (!def || !defpacks.clothingIds().includes(item)) {
|
||||
return {error: "No clothing item with that id."};
|
||||
}
|
||||
const own = String(def.colors).split(",").map(Number);
|
||||
const chosen = fields.color === undefined || String(fields.color).trim() === "" ? own[0] : Number(fields.color);
|
||||
if (!Number.isInteger(chosen) || chosen < -0x80000000 || chosen > 0xFFFFFFFF) {
|
||||
return {error: "A colour as the game writes it (a whole number), or none for the item's own."};
|
||||
}
|
||||
color = chosen >>> 0;
|
||||
}
|
||||
else if (kind === "den") {
|
||||
item = Number(fields.item);
|
||||
if (!defpacks.denItemIds().includes(item)) {
|
||||
return {error: "No den item with that id."};
|
||||
}
|
||||
}
|
||||
else {
|
||||
amount = Number(fields.amount);
|
||||
if (!Number.isInteger(amount) || amount < 1 || amount > MAX_AMOUNT) {
|
||||
return {error: "An amount from 1 to 10,000,000."};
|
||||
}
|
||||
}
|
||||
if (db().prepare("SELECT 1 FROM redeem_codes WHERE code = ?").get(code)) {
|
||||
return {error: "That code is taken."};
|
||||
}
|
||||
db().prepare("INSERT INTO redeem_codes (code, kind, item, amount, color, uses, used, created_at) VALUES (?, ?, ?, ?, ?, ?, 0, ?)")
|
||||
.run(code, kind, item, amount, color, uses, now());
|
||||
return {ok: `${code} made.`};
|
||||
};
|
||||
|
||||
const remove = code => db().prepare("DELETE FROM redeem_codes WHERE code = ?").run(normal(code)).changes > 0;
|
||||
|
||||
// a code typed in the game, for `account`: {gift} for lib/ecards.js
|
||||
// sendFromHq, or {error: "unknown" | "used" | "spent"}. the use is noted.
|
||||
const redeem = (account, typed) => {
|
||||
const code = normal(typed);
|
||||
const entry = CODE.test(code) ? db().prepare("SELECT * FROM redeem_codes WHERE code = ?").get(code) : null;
|
||||
if (!entry) {
|
||||
return {error: "unknown"};
|
||||
}
|
||||
if (db().prepare("SELECT 1 FROM redeem_uses WHERE code = ? AND account_id = ?").get(code, account.id)) {
|
||||
return {error: "used"};
|
||||
}
|
||||
if (entry.uses > 0 && entry.used >= entry.uses) {
|
||||
return {error: "spent"};
|
||||
}
|
||||
db().prepare("INSERT INTO redeem_uses (code, account_id, at) VALUES (?, ?, ?)").run(code, account.id, now());
|
||||
db().prepare("UPDATE redeem_codes SET used = used + 1 WHERE code = ?").run(code);
|
||||
const gift = entry.kind === "clothing" ? {kind: "clothing", id: entry.item, color: entry.color}
|
||||
: entry.kind === "den" ? {kind: "den", id: entry.item} : {kind: entry.kind, amount: entry.amount};
|
||||
return {gift, code};
|
||||
};
|
||||
|
||||
// a use taken back, when the gift could not be sent after all
|
||||
const unredeem = (account, code) => {
|
||||
if (db().prepare("DELETE FROM redeem_uses WHERE code = ? AND account_id = ?").run(code, account.id).changes > 0) {
|
||||
db().prepare("UPDATE redeem_codes SET used = MAX(used - 1, 0) WHERE code = ?").run(code);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {list, create, remove, redeem, unredeem, KINDS};
|
||||
+4
-1
@@ -71,4 +71,7 @@ const chunks = (size = 200) => {
|
||||
// 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};
|
||||
// the four RGB values of an entry, or null.
|
||||
const rgbsOf = id => entries.get(id) || null;
|
||||
|
||||
module.exports = {CUSTOM_BASE, load, allocate, chunks, known, rgbsOf, count: () => entries.size};
|
||||
+44
-4
@@ -44,8 +44,9 @@ const DEF_WORLD_ITEMS = 1064;
|
||||
const DEF_NPC = 1025;
|
||||
const DEF_NAMEBAR_BADGE = 1049;
|
||||
const DEF_EMOTICON = 1036;
|
||||
const DEF_NEWSPAPER = 1065; // the Jamaa Journal's pages (newspaper.NewspaperManager)
|
||||
|
||||
const OFFERED_SPECIAL_TYPES = ["0", "4"]; // den items: plain, mannequin
|
||||
const OFFERED_SPECIAL_TYPES = ["0", "4", "6", "7"]; // den items: plain, mannequin, eco producer and consumer (lib/eco.js)
|
||||
const DEN_ITEM_MASTERPIECE = 2725;
|
||||
|
||||
const packs = new Map();
|
||||
@@ -181,6 +182,13 @@ const ADDED_STRINGS = {
|
||||
9000004: "Crystal Palace (concept)",
|
||||
// the buddy game the client's files call "fourGem"; no string says so.
|
||||
9000005: "Four Gems",
|
||||
// a shop's title when its room gives it none (lib/world.js SHOP_KIND_TITLES)
|
||||
9000010: "Clothing Shop",
|
||||
9000011: "Den Shop",
|
||||
9000012: "Den Rooms",
|
||||
9000013: "Shop",
|
||||
9000014: "Exchange",
|
||||
9000015: "Diamond Shop",
|
||||
};
|
||||
|
||||
// the game under this server's name. its text says "Animal Jam", "Animal
|
||||
@@ -239,6 +247,31 @@ const withCustomRows = id => pack => {
|
||||
return pack;
|
||||
};
|
||||
|
||||
// colours of clothing items from a dump of a beta-era inventory (art id,
|
||||
// then the colour as 4 bytes, little-endian), added after each item's own
|
||||
// so the colours already given keep their place. the shop shows a list's
|
||||
// first 8 only, so these are had from the item givers.
|
||||
const DUMP_COLOURS = new Map([
|
||||
[231, [0x6929C069]], // Rare Eyeball Hat (Beta EyeBall; tried in the game)
|
||||
[224, [0x67520169]], // Creature Mask (Beta Creature Mask)
|
||||
[136, [0x2C083069, 0x55153131]], // Tiara (Beta Tiara, Milky Tiara)
|
||||
[135, [0x83550505]], // Arctic Hood (Beta Hood)
|
||||
[169, [0x937FF63B]], // Elf Helmet (Beta Elf)
|
||||
[714, [0x00000069]], // Furry Hat (Real Magenta Furry Hat)
|
||||
[649, [0x2E2D1906]], // Turquoise Ring (1st Glitched Ring)
|
||||
]);
|
||||
|
||||
const withDumpColours = pack => {
|
||||
for (const def of Object.values(pack)) {
|
||||
const added = def && DUMP_COLOURS.get(Number(def.id));
|
||||
if (added) {
|
||||
const colours = String(def.colors).split(",").filter(Boolean);
|
||||
def.colors = [...colours, ...added.map(String).filter(colour => !colours.includes(colour))].join(",");
|
||||
}
|
||||
}
|
||||
return pack;
|
||||
};
|
||||
|
||||
const withAddedStrings = pack => Object.assign(withLineBreaks(withOurName(Object.assign(pack, ADDED_STRINGS, extraMusic.strings()))), customStrings);
|
||||
|
||||
// the extra music tracks (lib/extramusic.js), as den items like the
|
||||
@@ -301,7 +334,7 @@ const SHARED_CHANGES = new Map([
|
||||
[DEF_PARTY, withRestoredParties],
|
||||
[DEF_DEN_ROOM, withoutPrices(DEF_DEN_ROOM, withAddedDens)],
|
||||
[DEF_DEN_ITEM, withoutPrices(DEF_DEN_ITEM, pack => withCustomRows(DEF_DEN_ITEM)(withExtraMusic(pack)))],
|
||||
[DEF_ITEM, withoutPrices(DEF_ITEM, withCustomRows(DEF_ITEM))],
|
||||
[DEF_ITEM, withoutPrices(DEF_ITEM, pack => withCustomRows(DEF_ITEM)(withDumpColours(pack)))],
|
||||
[DEF_DIAMOND, withoutPrices(DEF_DIAMOND)],
|
||||
[DEF_PET, withoutPrices(DEF_PET)],
|
||||
[DEF_LOCALIZATION_EN, withAddedStrings],
|
||||
@@ -455,6 +488,7 @@ let npcDefs = new Map(); // the characters of the adventures, see lib/disguises.
|
||||
// An avatar attachment is named by its emoticon definition id on the wire,
|
||||
// while AvatarWorldView needs the media id stored by that definition.
|
||||
let emoticonMediaIds = new Map();
|
||||
let journalPages = []; // the Jamaa Journal's pages: {id, page (media id), start (seconds)}
|
||||
|
||||
// A pack whose feature can be done without: missing (offline and never
|
||||
// cached) just leaves that feature empty.
|
||||
@@ -484,8 +518,9 @@ const init = async () => {
|
||||
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.
|
||||
// stock, ...). of those mannequins (4) are modelled, in lib/dens.js, and
|
||||
// the eco items (6, 7) in lib/eco.js, so those and plain den items 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);
|
||||
@@ -522,6 +557,8 @@ const init = async () => {
|
||||
petToyDefs = await loadOptional(DEF_PET_TOY);
|
||||
npcDefs = new Map((await loadOptional(DEF_NPC)).map(def => [Number(def.id), def]));
|
||||
emoticonMediaIds = new Map((await loadOptional(DEF_EMOTICON)).map(def => [Number(def.id), Number(def.mediaRef)]));
|
||||
journalPages = (await loadOptional(DEF_NEWSPAPER)).map(def => ({id: Number(def.id), page: Number(def.pageMediaRefId),
|
||||
start: Number(def.availabilityStartTime) || 0})).filter(page => page.page > 0);
|
||||
partyDefs = new Map((await loadOptional(DEF_PARTY)).map(def => {
|
||||
const room = roomPathsById.get(Number(def.roomDefId));
|
||||
return [Number(def.id), {
|
||||
@@ -633,6 +670,9 @@ module.exports = {
|
||||
badgeIds: () => badgeIds,
|
||||
npcDef: id => npcDefs.get(Number(id)),
|
||||
emoticonMediaId: id => emoticonMediaIds.get(Number(id)) || 0,
|
||||
// the media ids of the newest Jamaa Journal pages out by `now` (seconds), newest first
|
||||
newestJournalPages: (count, now = Date.now() / 1000) => journalPages.filter(page => page.start <= now)
|
||||
.sort((one, other) => other.start - one.start || other.id - one.id).slice(0, count).map(page => page.page),
|
||||
oddDenItemIds: () => oddDenItemIds,
|
||||
// den items that exist to be given by id and are in no shop.
|
||||
unsoldDenItemIds: () => extraMusic.ids,
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{"1":{"versions":[0,1,2,3,4,5,6,7],"colours":[["56c3d8","1078ff","4acaff","4876ba"],["8f48ff","3d00a7","5e1dff","5d0089"],["ff99f0","e150ff","ff6bf7","ff3dba"],["ac0912","ea004f","c40000","a10000"],["ff732b","dd3c4d","ff742d","e84138"],["f3ff86","d0ee19","e6ff3b","dfff05"],["63ff66","007917","23b700","035000"],["63565d","201219","551f4c","2f151f"]]},"9":{"versions":[0,1]},"13":{"versions":[0,1,2,3]},"19":{"versions":[0,1,2,3,4,5,6,7,8,9],"colours":[["7cbbff","2388ff","b9fffc","6bc1ff"],["be5bff","9348ff","42195b","ac43ff"],["e689c2","e45dad","fbfbfb","ea65c4"],["c8a0cd","cc434c","887e8e","ff4b4b"],["efcd34","e57712","ffffff","7bfff2"],["fff81a","fff81a","835c40","ff6bb3"],["4cbf00","43910b","ade53b","57de00"],["9e9e9e","5c5c7f","727c72","ffbf15"],["9e1616","3a3a3a","0f0f0f","ff1d1d"],["644b18","503000","e0b61f","7b4100"]]},"21":{"versions":[0,1,2]},"27":{"versions":[0,1,2,3]},"36":{"versions":[0,1,2,3,4,5,6,7,8,9],"colours":[["2b5eff","ffd646","56b8ff","b7ecff"],["ee58ff","5e0096","ffcf84","e3bcff"],["ff50d8","fbfbfb","ffbc1d","ffffef"],["ff3418","050505","ff9e53","ffffff"],["ff7323","ffa640","ffe42d","c7fcff"],["f8ff12","150f00","f3ff1a","050500"],["4caf00","adff3b","fff87e","c4ffe2"],["969696","ffdb5b","e0e5ff","809ca2"],["3d3d3d","830004","fafafa","0d0d0d"],["644b18","2b0c00","b9ab00","314800"]]},"37":{"versions":[0,1,3,4,5,6,7],"colours":[["a1daff","7bbfe8","b7eaff","4893ff"],["ceafff","a550ff","5d00b7","9c50ff"],["ff9999","990000","e95353","e11515"],["ffca94","f4a500","d07200","e37d48"],["dbe700","ecd743","ffff02","fff20a"],["afffa4","0a9100","75ff5e","30ff0d"],["727272","909090","f6f6f6","dedede"]]},"45":{"versions":[0,1,2,3,4,5,6,7]},"48":{"versions":[0,1,2,3,4,5,6,7]},"49":{"versions":[0,1,2,3,4,5,6,7]},"53":{"versions":[0,1,2,3,4,5,6,7]},"54":{"versions":[0,1,2,3,4,5,6,7]},"56":{"versions":[0,1,2,3,4,5,6,7,8,9],"colours":[["3e89d0","0d3673","b17400"],["9361ff","42195b","ff8ce4"],["f771a8","ff33a9","ffffff"],["d24743","ae3d59","434343"],["cf6227","e78100","ffe63d"],["ffea30","ff6d1a","bc7900"],["bde745","ff9400","dfaa00"],["969696","525252","ffffff"],["303030","f1f1f1","7d7d7d"],["91602d","ffe463","acb43e"]]},"83":{"versions":[0,1,2,3,4,5,6,7,8,9],"colours":[["c7f3ff","408aff","6bdaff"],["c976ff","5e0096","dcd4ff"],["ff89f3","ff4cac","f5d7ff"],["e43437","ffffff","ffffff"],["fd7500","ffcd63","fffbea"],["ffff3d","150f00","e2fff4"],["4caf00","adff3b","ffffff"],["969696","6b7c6b","dedede"],["212121","6b4496","030303"],["713700","ffffff","fffff2"]]},"91":{"versions":[0,1,2,3,4,5,6,7,8,9],"colours":[["3d5977","c47821","bc8000","ab6412"],["906fa5","705091","af8957","56486c"],["e5768c","f1f1da","e9b3c7","e2c1ce"],["bd483e","373736","7f5437","30312e"],["c37138","3a3539","c75524","474446"],["b46d00","ffe042","787878","525252"],["6b7e48","433422","a16951","58462c"],["8ca0a6","7b8f90","cc9d5d","dcdaa6"],["434342","4b4641","2b3331","212121"],["8a6341","78502a","dbab64","c3b39a"]]},"131":{"versions":[0,1,2,3,4,5]},"147":{"versions":[0,1,2,3,4,5,6,7],"colours":[["7bb8f7","fffedc","dcfcff","ffffff"],["9b4eff","ffeff5","eacaff","aa69ff"],["ff9efa","f33de9","ffd2fb","ca00c4"],["d20000","636363","e62525","616161"],["ef8454","e0ffdf","efe4ce","ffffff"],["fff802","af6f2b","faff58","1ecf00"],["3dc43d","7b7800","35ee45","31cc00"],["505050","ffffff","686868","494949"]]},"152":{"versions":[0,1,2,3,4,5,6,7],"colours":[["7bb8f7","ade0e6","e0db00"],["af37d7","3b0038","f0e579"],["e825e1","ff99f7","cfcfcf"],["d20000","ffacac","eddc6b"],["ff732b","ffda76","cecece"],["ede80a","a2a700","d1d1d1"],["3dc43d","afffa4","ffd938"],["484848","757575","fffaa4"]]},"226":{"versions":[0,1,2,3,4,5,6,7],"colours":[["060043","c4dbff","0015b4","3548ff"],["f5f5f5","42195b","8d00f2","ae74eb"],["ff71e3","ffeaf1","d400c9","ff3dba"],["ac0912","fffee7","fbffa7","ea0000"],["ede3a0","d8822e","fbdf9e","be4e33"],["fff812","639ac6","949400","dfd300"],["fffbca","008903","faffbc","008e3e"],["ffffff","505050","ffffff","343434"]]},"295":{"versions":[0,1,2,3,4,5,6,7],"colours":[["3458dd","4696ff"],["9a47d8","b875ff"],["ff8193","ffc4c6"],["ff2d2d","ff9c9c"],["f57a00","ffd47b"],["e7e700","ffffbb"],["05af00","daffa3"],["7d7d7d","d5d5d5"]]},"348":{"versions":[0,1,2,3,4,5,6,7,8,9],"colours":[["4589ff","fffbac","4086ff","7bc744"],["a640ff","fff986","6300c2","cbe26a"],["ffffff","00b999","ff35e5","bc910e"],["01000a","ff3333","bf0000","ffffff"],["ff7a00","d6d6af","ffffff","3a5000"],["fff800","73e3e0","f7f000","b1ea8c"],["4caf00","adff3b","7dd700","c4ffe2"],["727272","bebebe","e0e5ff","a6a6a6"],["404040","3d3d3d","828282","5e0000"],["644b18","d6c72b","664d00","506a16"]]},"350":{"versions":[0,1,2,3,4,5,6,7,8,9],"colours":[["48c5ff","ffff18","5bff35","0dff1e"],["a846ff","ff650d","ffff33","43f1ff"],["ff73d9","ff30c2","ffffff","00f2eb"],["ff2d2d","828282","ffe925","fdea00"],["e76a00","35f700","ffed10","fff930"],["ffff00","4bfaff","23f700","13ff02"],["76ff20","21ea00","ff7210","ffff02"],["ffffff","cfecff","0affff","fff928"],["717171","3c3c3c","00fdf6","02fff2"],["92663a","ffcfLine truncated
|
||||
+14
-4
@@ -8,6 +8,7 @@ const defpacks = require("./defpacks.js");
|
||||
const wearRules = require("./wearrules.js");
|
||||
const epicDens = require("./epicdens.js");
|
||||
const masterpieces = require("./masterpieces.js");
|
||||
const eco = require("./eco.js");
|
||||
const {CURRENCIES, MAX_DEN_ITEMS, hasRoom, activeAvatar, resolvePurchase, isUint} = require("./player.js");
|
||||
|
||||
// den items: owning, placing and recycling furniture (client side:
|
||||
@@ -119,9 +120,14 @@ const petsInDen = account => account.pets.filter(pet => pet.inDen && pet.inDen.d
|
||||
// it is not placed there. 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.
|
||||
// an item whose def is gone (a custom item deleted) is left out of both: the
|
||||
// client skipped it without reading all its fields, and read every item after
|
||||
// it wrong, placed ones as not placed and the den's floor and wallpaper lost.
|
||||
const known = item => Boolean(defpacks.denItemDef(item.def));
|
||||
|
||||
const sendDenItems = session => {
|
||||
const {account} = session;
|
||||
const {denItems} = account;
|
||||
const denItems = account.denItems.filter(known);
|
||||
const pets = petsInDen(account);
|
||||
session.sendXt("di", -1, account.activeDen, denItems.length, pets.length,
|
||||
...denItems.flatMap(item => {
|
||||
@@ -134,13 +140,13 @@ const sendDenItems = session => {
|
||||
|
||||
// DenXtCommManager.denStateResponse: [itemCount, petCount, forceReload,
|
||||
// (invIdx, defId, placed, x, y, version, flipped, userNameLink, imageId,
|
||||
// creatorDbId, creatorUuid, [mannequin], ?)..., (invIdx, lBits, uBits, eBits,
|
||||
// creatorDbId, creatorUuid, [mannequin], eco state)..., (invIdx, lBits, uBits, eBits,
|
||||
// category, x, y, flipped, createdTs, personality, toy, food, name)...].
|
||||
// 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 owner = room.denOwner;
|
||||
const placed = itemsInDen(owner).filter(item => masterpieces.itemApproved(item));
|
||||
const placed = itemsInDen(owner).filter(item => known(item) && masterpieces.itemApproved(item));
|
||||
const pets = petsInDen(owner);
|
||||
session.sendXt("ds", room.id, placed.length, pets.length, forceReload ? 1 : 0,
|
||||
...placed.flatMap(item => {
|
||||
@@ -149,7 +155,7 @@ const sendDenState = (session, room, forceReload = true) => {
|
||||
// object as category 1 made wall/floor items enter the wrong display
|
||||
// layer when a den was reloaded or another player visited.
|
||||
return [item.inv, item.def, spot.cat || 1, spot.x, spot.y, item.version, spot.flip, "", ...masterpieces.itemFields(item),
|
||||
...mannequinShownFields(owner, item), 0];
|
||||
...mannequinShownFields(owner, item), eco.consumerState(owner, item)];
|
||||
}),
|
||||
...pets.flatMap(pet => [pet.inv, pet.lBits, pet.uBits, pet.eBits, PET_CATEGORY, pet.inDen.x, pet.inDen.y, pet.inDen.flip,
|
||||
pet.createdAt, pet.personality || 0, pet.toy || 0, pet.food || 0, pet.name]));
|
||||
@@ -380,6 +386,10 @@ const handlers = ({others, findOnline}) => {
|
||||
session.sendXt("dss", -1);
|
||||
return;
|
||||
}
|
||||
// the eco credits earned at the den's rate until now (lib/eco.js)
|
||||
if (account.eco) {
|
||||
eco.accrue(account);
|
||||
}
|
||||
const applied = [];
|
||||
const byInv = new Map(account.denItems.map(candidate => [candidate.inv, candidate]));
|
||||
const mannequins = account.denItems.filter(candidate => candidate.mannequin);
|
||||
|
||||
+55
-40
@@ -19,11 +19,13 @@ const config = require("../config.js");
|
||||
// again with a secret of this server's (data/device-key), so what is kept
|
||||
// is of no use anywhere else.
|
||||
//
|
||||
// any one of them is a match: someone who edits /etc/machine-id or deletes
|
||||
// MachineGuid still has the same disks and the client's own id. the network
|
||||
// card's address alone (MAC_KIND) is a weak match: it is easily changed and
|
||||
// sometimes shared, so it bans nothing; it is written down for the
|
||||
// moderators instead. values every cheap board or VM has ("To be filled by
|
||||
// two computers are taken for one when they share at least MIN_MATCHING of
|
||||
// these (owner, 2026-10-23: one or two in common was too often someone
|
||||
// else's), for a ban and for an alt alike: someone who edits
|
||||
// /etc/machine-id or deletes MachineGuid still has the same board, disks
|
||||
// and the client's own id. the network card's address (MAC_KIND) does not
|
||||
// count towards them: it is easily changed and sometimes shared, so it bans
|
||||
// nothing; it is written down for the moderators instead. values every cheap board or VM has ("To be filled by
|
||||
// O.E.M.", all zeros) are left out here, so that no ban falls on everyone
|
||||
// who has one. what the client noticed was wrong (the system id missing, or
|
||||
// not shaped as it always is) comes as notes, and is written down too.
|
||||
@@ -56,6 +58,7 @@ const SCHEMA = `
|
||||
const KINDS = ["os", "board", "disk", "install", "mac"];
|
||||
const STRONG = ["os", "board", "disk", "install"];
|
||||
const MAC_KIND = "mac";
|
||||
const MIN_MATCHING = 3; // ids but a network card's two computers share to be taken for one
|
||||
const LISTS = ["disk", "mac"]; // sent as lists; the rest one each
|
||||
const MAX_IN_LIST = 8;
|
||||
const MAX_KEPT = 60; // ids an account keeps, the latest
|
||||
@@ -106,6 +109,7 @@ const idsOf = account => {
|
||||
return account.hwids;
|
||||
};
|
||||
const tag = entry => `${entry.kind}:${entry.id}`;
|
||||
const isStrong = id => STRONG.includes(id.split(":")[0]);
|
||||
|
||||
const banRow = row => ({id: row.id, ids: JSON.parse(row.ids), reason: row.reason, by: row.by, createdAt: row.created_at,
|
||||
accountId: row.account_id, username: row.username});
|
||||
@@ -161,27 +165,29 @@ const read = device => {
|
||||
return ids.some(entry => STRONG.includes(entry.kind)) ? {ids, notes} : null;
|
||||
};
|
||||
|
||||
// the ban that keeps this computer out, or null. a network card's address
|
||||
// alone keeps nobody out (see the top).
|
||||
const banOf = device => {
|
||||
for (const entry of device.ids) {
|
||||
if (STRONG.includes(entry.kind) && banned.has(tag(entry))) {
|
||||
return banned.get(tag(entry));
|
||||
// the ban that has at least MIN_MATCHING of these "kind:id" in it, or
|
||||
// null. network cards' addresses are not counted (see the top).
|
||||
const banMatching = ids => {
|
||||
const strong = new Set(ids.filter(isStrong));
|
||||
const looked = new Set();
|
||||
for (const id of strong) {
|
||||
const ban = banned.get(id);
|
||||
if (ban && !looked.has(ban.id)) {
|
||||
looked.add(ban.id);
|
||||
if (ban.ids.filter(one => strong.has(one)).length >= MIN_MATCHING) {
|
||||
return ban;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
// the ban that keeps this computer out, or null.
|
||||
const banOf = device => banMatching(device.ids.map(tag));
|
||||
|
||||
// the ban on any computer the account signed in from lately, or null: for
|
||||
// the client asking why its game was stopped.
|
||||
const banOfAccount = account => {
|
||||
for (const entry of idsOf(account)) {
|
||||
if (STRONG.includes(entry.kind) && entry.last > now() - DAYS_KEPT * 86400 && banned.has(tag(entry))) {
|
||||
return banned.get(tag(entry));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
const banOfAccount = account => banMatching(idsOf(account).filter(entry => entry.last > now() - DAYS_KEPT * 86400).map(tag));
|
||||
|
||||
const alert = (account, kind, detail) => {
|
||||
const last = db().prepare("SELECT at FROM device_alerts WHERE account_id = ? AND kind = ? ORDER BY id DESC LIMIT 1").get(account.id, kind);
|
||||
@@ -223,38 +229,47 @@ const seen = (account, device, isBanned) => {
|
||||
if (nearBan) {
|
||||
alert(account, "near_ban", `same network card as a hardware ban (${banned.get(tag(nearBan)).username || "no account"})`);
|
||||
}
|
||||
const sharers = new Set();
|
||||
const shared = new Map(); // account id -> ids in common
|
||||
for (const entry of device.ids.filter(one => STRONG.includes(one.kind))) {
|
||||
for (const id of holders.get(tag(entry)) || []) {
|
||||
const other = id === account.id ? null : accounts.byId(id);
|
||||
if (other && isBanned(other)) {
|
||||
sharers.add(other.username);
|
||||
if (id !== account.id) {
|
||||
shared.set(id, (shared.get(id) || 0) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
const sharers = new Set();
|
||||
for (const [id, count] of shared) {
|
||||
const other = count >= MIN_MATCHING ? accounts.byId(id) : null;
|
||||
if (other && isBanned(other)) {
|
||||
sharers.add(other.username);
|
||||
}
|
||||
}
|
||||
if (sharers.size) {
|
||||
alert(account, "shares_banned", `same hardware as banned ${[...sharers].slice(0, 5).join(", ")}`);
|
||||
}
|
||||
};
|
||||
|
||||
// the other accounts that used any of this one's computers: [{username,
|
||||
// kinds: [kind], weak: true when only a network card}], most in common first.
|
||||
// the other accounts that used one of this one's computers, sharing at
|
||||
// least MIN_MATCHING of its ids: [{username, kinds: [kind]}], most in
|
||||
// common first.
|
||||
const alts = account => {
|
||||
const found = new Map(); // account id -> Set of kinds
|
||||
const found = new Map(); // account id -> {kinds: Set, strong: ids in common but network cards}
|
||||
for (const entry of idsOf(account)) {
|
||||
for (const id of holders.get(tag(entry)) || []) {
|
||||
if (id !== account.id) {
|
||||
if (!found.has(id)) {
|
||||
found.set(id, new Set());
|
||||
found.set(id, {kinds: new Set(), strong: 0});
|
||||
}
|
||||
found.get(id).add(entry.kind);
|
||||
found.get(id).kinds.add(entry.kind);
|
||||
found.get(id).strong += STRONG.includes(entry.kind) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return [...found].map(([id, kinds]) => ({account: accounts.byId(id), kinds: [...kinds]}))
|
||||
return [...found].filter(([, shared]) => shared.strong >= MIN_MATCHING)
|
||||
.map(([id, shared]) => ({account: accounts.byId(id), kinds: [...shared.kinds], strong: shared.strong}))
|
||||
.filter(entry => entry.account)
|
||||
.map(entry => ({username: entry.account.username, kinds: entry.kinds, weak: entry.kinds.every(kind => kind === MAC_KIND)}))
|
||||
.sort((one, other) => Number(one.weak) - Number(other.weak) || other.kinds.length - one.kinds.length || one.username.localeCompare(other.username));
|
||||
.sort((one, other) => other.strong - one.strong || other.kinds.length - one.kinds.length || one.account.username.localeCompare(other.account.username))
|
||||
.map(entry => ({username: entry.account.username, kinds: entry.kinds}));
|
||||
};
|
||||
|
||||
// how many computers' worth of ids an account has, for the panels.
|
||||
@@ -265,10 +280,10 @@ const knownFor = account => ({ids: idsOf(account).length, lastAt: idsOf(account)
|
||||
// one of them.
|
||||
const banAccount = (account, reason, by) => {
|
||||
const ids = [...new Set(idsOf(account).filter(entry => entry.last > now() - DAYS_KEPT * 86400).map(tag))];
|
||||
if (!ids.some(id => STRONG.includes(id.split(":")[0]))) {
|
||||
return {error: "No hardware IDs known for them."};
|
||||
if (ids.filter(isStrong).length < MIN_MATCHING) {
|
||||
return {error: `Fewer than ${MIN_MATCHING} hardware IDs known for them.`};
|
||||
}
|
||||
if (ids.filter(id => STRONG.includes(id.split(":")[0])).every(id => banned.has(id))) {
|
||||
if (ids.filter(isStrong).every(id => banned.has(id))) {
|
||||
return {error: "Their hardware is banned already."};
|
||||
}
|
||||
const text = clean(reason, MAX_REASON) || NO_REASON;
|
||||
@@ -281,16 +296,16 @@ const banAccount = (account, reason, by) => {
|
||||
return {ban};
|
||||
};
|
||||
|
||||
// the accounts playing from one of a ban's computers, by their latest ids.
|
||||
// the accounts playing from one of a ban's computers, by their latest ids:
|
||||
// those with at least MIN_MATCHING of its ids.
|
||||
const accountsUnder = ban => {
|
||||
const ids = new Set(ban.ids.filter(id => STRONG.includes(id.split(":")[0])));
|
||||
const found = new Set();
|
||||
for (const id of ids) {
|
||||
const found = new Map(); // account id -> ids in common
|
||||
for (const id of new Set(ban.ids.filter(isStrong))) {
|
||||
for (const accountId of holders.get(id) || []) {
|
||||
found.add(accountId);
|
||||
found.set(accountId, (found.get(accountId) || 0) + 1);
|
||||
}
|
||||
}
|
||||
return [...found].map(id => accounts.byId(id)).filter(Boolean);
|
||||
return [...found].filter(([, count]) => count >= MIN_MATCHING).map(([id]) => accounts.byId(id)).filter(Boolean);
|
||||
};
|
||||
|
||||
const unban = id => {
|
||||
|
||||
+110
-26
@@ -42,6 +42,7 @@ const EPHEMERAL = 1 << 6;
|
||||
const STATUS_MESSAGE_SETTING = "discordBotStatusMessage";
|
||||
const STATUS_TITLE_SETTING = "discordBotStatusTitle";
|
||||
const STATUS_NOTE_SETTING = "discordBotStatusNote";
|
||||
const STATUS_BANNER_SETTING = "discordBotStatusBanner";
|
||||
const STATUS_EVERY_MS = 5 * 60000;
|
||||
const REPORT_BUTTON_PREFIX = "burrow:report:";
|
||||
const MAX_GITHUB_WEBHOOK_BYTES = 512 * 1024;
|
||||
@@ -71,18 +72,36 @@ let lastRaidAlertAt = 0;
|
||||
const safe = (value, max = 1000) => String(value === undefined || value === null ? "" : value)
|
||||
.replace(/@/g, "@\u200b").replace(/`/g, "'").replace(/[\u0000-\u001f\u007f]/g, " ").trim().slice(0, max);
|
||||
|
||||
// Discord fetches the banner itself, so only absolute http(s) URLs work.
|
||||
// Blank means the card has no banner; null means the URL was rejected.
|
||||
const bannerUrl = value => {
|
||||
const text = String(value || "").trim();
|
||||
if (!text) return "";
|
||||
try {
|
||||
const url = new URL(text);
|
||||
return /^https?:$/.test(url.protocol) && text.length <= 500 ? url.toString() : null;
|
||||
}
|
||||
catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const statusSettings = () => ({
|
||||
title: safe(accounts.setting(STATUS_TITLE_SETTING) || "Burrow status", 80) || "Burrow status",
|
||||
note: safe(accounts.setting(STATUS_NOTE_SETTING) || "", 500),
|
||||
banner: bannerUrl(accounts.setting(STATUS_BANNER_SETTING)) || "",
|
||||
});
|
||||
|
||||
const setStatusSettings = ({title, note}) => {
|
||||
const setStatusSettings = ({title, note, banner}) => {
|
||||
const next = {
|
||||
title: safe(title || "Burrow status", 80) || "Burrow status",
|
||||
note: safe(note || "", 500),
|
||||
banner: bannerUrl(banner),
|
||||
};
|
||||
if (next.banner === null) return {error: "Banner must be an http(s) image URL of 500 characters or fewer, or blank for none."};
|
||||
accounts.setSetting(STATUS_TITLE_SETTING, next.title);
|
||||
accounts.setSetting(STATUS_NOTE_SETTING, next.note);
|
||||
accounts.setSetting(STATUS_BANNER_SETTING, next.banner);
|
||||
return next;
|
||||
};
|
||||
|
||||
@@ -223,6 +242,33 @@ const success = (title, sections, ephemeral = true) => card({title, sections, to
|
||||
const warning = (message, ephemeral = true) => card({title: "Burrow", sections: [message], tone: 0xfee75c, ephemeral});
|
||||
const failure = (message, ephemeral = true) => card({title: "Burrow", sections: [message], tone: 0xed4245, ephemeral});
|
||||
|
||||
// Staff audit streams use the same compact Components V2 pattern as SRP-Bot:
|
||||
// a brief summary, structured fields, and a durable log timestamp.
|
||||
const logCard = ({title, description = "", fields = [], tone = 0x5865f2}) => {
|
||||
const shown = fields.filter(field => field && field.name && field.value !== undefined && field.value !== null).slice(0, 12);
|
||||
const components = [{type: 10, content: [
|
||||
`## ${safe(title, 160)}`,
|
||||
description ? safe(description, 900) : "",
|
||||
].filter(Boolean).join("\n")}];
|
||||
|
||||
if (shown.length) {
|
||||
components.push({type: 14, divider: true, spacing: 1});
|
||||
components.push({type: 10, content: shown
|
||||
.map(field => `• **${safe(field.name, 80)}:** ${safe(field.value, 500)}`)
|
||||
.join("\n")
|
||||
.slice(0, 1800)});
|
||||
}
|
||||
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
components.push({type: 14, divider: false, spacing: 1});
|
||||
components.push({type: 10, content: `_Logged <t:${now}:F> (<t:${now}:R>)_`});
|
||||
return {
|
||||
flags: COMPONENTS_V2,
|
||||
allowedMentions: {parse: []},
|
||||
components: [{type: 17, accent_color: tone, components}],
|
||||
};
|
||||
};
|
||||
|
||||
const commandDefinitions = () => [
|
||||
new SlashCommandBuilder().setName("burrow").setDescription("View Burrow server and player information")
|
||||
.addSubcommand(command => command.setName("status").setDescription("Show the live Burrow server status"))
|
||||
@@ -276,7 +322,9 @@ const commandDefinitions = () => [
|
||||
.addSubcommand(command => command.setName("close").setDescription("Close this support ticket")),
|
||||
].map(command => command.toJSON());
|
||||
|
||||
const actorFor = interaction => modpanel.discordBot.actor(interaction.user.id);
|
||||
// a command or button counts for a staff member signed in to the panel with
|
||||
// their 2FA code (modpanel.discordBot.commandActor): Discord alone is not them.
|
||||
const actorFor = interaction => modpanel.discordBot.commandActor(interaction.user.id);
|
||||
|
||||
const reportButton = report => new ActionRowBuilder().addComponents(
|
||||
new ButtonBuilder().setCustomId(`${REPORT_BUTTON_PREFIX}${report.id}:handled`).setLabel("Mark handled").setStyle(ButtonStyle.Success),
|
||||
@@ -302,12 +350,33 @@ const playerCard = player => success(`Player: ${player.username}`, [
|
||||
|
||||
const statusCard = status => {
|
||||
const settings = statusSettings();
|
||||
return card({title: settings.title, tone: 0x5865f2, sections: [
|
||||
settings.note ? `**Status message**\n${settings.note}` : "",
|
||||
`**Online**\n${status.players} players in ${status.rooms} room${status.rooms === 1 ? "" : "s"}`,
|
||||
`**Moderation queue**\n${status.reports} open report${status.reports === 1 ? "" : "s"}`,
|
||||
`**Server**\nUptime: <t:${Math.floor(Date.now() / 1000 - status.uptimeSeconds)}:R>\nMemory: ${status.memoryMb} MB`,
|
||||
]});
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
const startedAt = now - status.uptimeSeconds;
|
||||
const rooms = `${status.rooms} room${status.rooms === 1 ? "" : "s"}`;
|
||||
const playUrl = new URL("gameClient/game/index.html", config.siteUrl).toString();
|
||||
|
||||
// This is intentionally public-only: moderation reports and queue depth are
|
||||
// staff data and do not belong in a community-facing server-status post.
|
||||
return {
|
||||
flags: COMPONENTS_V2,
|
||||
allowedMentions: {parse: []},
|
||||
components: [{
|
||||
type: 17,
|
||||
accent_color: 0x7c5ce7,
|
||||
components: [
|
||||
{type: 10, content: `## ${safe(settings.title, 80)}`},
|
||||
{type: 14, divider: true, spacing: 1},
|
||||
{type: 10, content: ["### STATUS", "🟢 **Online**", settings.note ? `\n${safe(settings.note, 500)}` : ""].filter(Boolean).join("\n")},
|
||||
{type: 14, divider: true, spacing: 1},
|
||||
{type: 10, content: `### PLAYERS\n\`${status.players} online\` • \`${rooms}\``},
|
||||
{type: 14, divider: true, spacing: 1},
|
||||
{type: 10, content: `### UPTIME\nStarted <t:${startedAt}:R> • ${status.memoryMb} MB memory`},
|
||||
...settings.banner ? [{type: 12, items: [{media: {url: settings.banner}}]}] : [],
|
||||
{type: 1, components: [{type: 2, style: 5, label: "Play Burrow", url: playUrl}]},
|
||||
{type: 10, content: `_Last updated <t:${now}:R>_`},
|
||||
],
|
||||
}],
|
||||
};
|
||||
};
|
||||
|
||||
const staffCard = staff => success("Burrow staff", staff.length
|
||||
@@ -476,7 +545,7 @@ const handleTicket = async interaction => {
|
||||
return;
|
||||
}
|
||||
const owner = ticketOwner(interaction.channel);
|
||||
const staff = actorFor(interaction);
|
||||
const staff = modpanel.discordBot.actor(interaction.user.id);
|
||||
if (!owner || (owner !== interaction.user.id && !staff)) {
|
||||
await interaction.editReply(failure("Only the ticket opener or linked Burrow staff can close this ticket."));
|
||||
return;
|
||||
@@ -528,7 +597,9 @@ const postCard = async (channelId, payload, label) => {
|
||||
const publishStatus = async () => {
|
||||
const channel = await channelFor(config.discord.statusChannelId);
|
||||
if (!channel) return {error: "The public status channel is not configured or the Discord bot is not connected."};
|
||||
const payload = statusCard({players: 0, rooms: 0, reports: reports.openCount(), uptimeSeconds: Math.floor(process.uptime()), memoryMb: Math.round(process.memoryUsage().rss / 1048576)});
|
||||
const players = world.players();
|
||||
const payload = statusCard({players: players.length, rooms: new Set(players.map(player => player.room).filter(Boolean)).size,
|
||||
reports: reports.openCount(), uptimeSeconds: Math.floor(process.uptime()), memoryMb: Math.round(process.memoryUsage().rss / 1048576)});
|
||||
// The public status card needs no staff actor; it exposes only aggregate
|
||||
// counts. Store its message id in the server database so restarts edit it.
|
||||
const saved = accounts.setting(STATUS_MESSAGE_SETTING);
|
||||
@@ -555,41 +626,54 @@ const notifyReport = async report => {
|
||||
|
||||
const notifyGameActivity = async entry => {
|
||||
const minutes = Math.max(1, Math.ceil((entry.playedSeconds || 0) / 60));
|
||||
const played = entry.type === "logout" ? `\nSession: ${minutes} minute${minutes === 1 ? "" : "s"}` : "";
|
||||
await postCard(config.discord.gameLogsChannelId, card({
|
||||
title: "In-game player activity",
|
||||
tone: entry.type === "login" ? 0x57f287 : 0x5865f2,
|
||||
sections: [`**${safe(entry.username, 40)}** ${entry.type === "login" ? "signed in" : "signed out"}.${played}`],
|
||||
const signedIn = entry.type === "login";
|
||||
await postCard(config.discord.gameLogsChannelId, logCard({
|
||||
title: "In-game activity",
|
||||
description: signedIn ? "A player signed in." : "A player signed out.",
|
||||
tone: signedIn ? 0x57f287 : 0x5865f2,
|
||||
fields: [
|
||||
{name: "Player", value: entry.username},
|
||||
{name: "Event", value: signedIn ? "Signed in" : "Signed out"},
|
||||
...(!signedIn ? [{name: "Session", value: `${minutes} minute${minutes === 1 ? "" : "s"}`}] : []),
|
||||
],
|
||||
}), "game activity log");
|
||||
};
|
||||
|
||||
const notifyModeration = async entry => {
|
||||
await postCard(config.discord.moderationLogsChannelId, card({
|
||||
await postCard(config.discord.moderationLogsChannelId, logCard({
|
||||
title: "Moderation audit",
|
||||
description: "A Burrow staff action was recorded.",
|
||||
tone: 0xfee75c,
|
||||
sections: [
|
||||
`**${safe(entry.by, 50)}** — ${safe(entry.action, 120)}`,
|
||||
entry.target ? `Player: **${safe(entry.target, 50)}**` : "",
|
||||
entry.detail ? `Details: ${safe(entry.detail, 500)}` : "",
|
||||
fields: [
|
||||
{name: "Staff", value: entry.by},
|
||||
{name: "Action", value: entry.action},
|
||||
...(entry.target ? [{name: "Player", value: entry.target}] : []),
|
||||
...(entry.detail ? [{name: "Details", value: entry.detail}] : []),
|
||||
],
|
||||
}), "moderation log");
|
||||
};
|
||||
|
||||
const notifyBot = async (interaction, action) => {
|
||||
const actor = modpanel.discordBot.actor(interaction.user.id);
|
||||
await postCard(config.discord.botLogsChannelId, card({
|
||||
await postCard(config.discord.botLogsChannelId, logCard({
|
||||
title: "Discord bot audit",
|
||||
description: "A Discord command or control was used.",
|
||||
tone: actor ? 0x5865f2 : 0xed4245,
|
||||
sections: [
|
||||
`Discord user: **${safe(interaction.user.username, 80)}** (\`${safe(interaction.user.id, 30)}\`)`,
|
||||
`Action: ${safe(action, 160)}`,
|
||||
actor ? `Linked staff account: **${safe(actor.username, 40)}**` : "No active linked Burrow staff account.",
|
||||
fields: [
|
||||
{name: "Discord user", value: `${interaction.user.username} (${interaction.user.id})`},
|
||||
{name: "Action", value: action},
|
||||
{name: "Linked staff account", value: actor ? actor.username : "No active linked Burrow staff account."},
|
||||
],
|
||||
}), "Discord bot audit log");
|
||||
};
|
||||
|
||||
const securityIncident = async (title, sections, detail = "") => {
|
||||
await postCard(config.discord.moderationLogsChannelId, card({title, tone: 0xed4245, sections}), "Discord security log");
|
||||
await postCard(config.discord.moderationLogsChannelId, logCard({
|
||||
title,
|
||||
description: "Discord security activity detected.",
|
||||
tone: 0xed4245,
|
||||
fields: [{name: "Details", value: sections.filter(Boolean).join("\n")}],
|
||||
}), "Discord security log");
|
||||
modlog.record("discord security", title.toLowerCase(), "", detail);
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +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]
|
||||
"stamps": [13,11,2889,2896,1602,2886,1604,12,2877,2885,1603,2894,10,2899,2891,2876,376,2878,2879,2880,2881,2882,2884,2888,2898,2887,2890,377,2892,2893,2895,2900,378,2901,2902]
|
||||
}
|
||||
+51
-13
@@ -17,9 +17,12 @@ const {CURRENCIES, hasRoom, addClothing, sendClothingAdded, sendClothingRemoved}
|
||||
// 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
|
||||
// which cards and stamps exist was a list on the official servers. the cards
|
||||
// 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).
|
||||
// artwork (tools/find-art.py found what is in lib/ecard-art.json); the
|
||||
// stamps are the official list itself, as a recording of the official game
|
||||
// has it (lib/official-lists.json, list 44): the ones guessed before were
|
||||
// partly not stamps at all, and showed nothing.
|
||||
|
||||
// ECard.type: what, if anything, comes with the card
|
||||
const TYPE_PLAIN = 0;
|
||||
@@ -51,10 +54,15 @@ const INBOX_FULL = -1;
|
||||
const NOT_ACCEPTING = -2;
|
||||
const FAILED = 0;
|
||||
|
||||
// who may send to a player (ECardInbox's settings popup).
|
||||
// who may send to a player, as kept (account.ecardPrivacy).
|
||||
const FROM_EVERYONE = 0;
|
||||
const FROM_BUDDIES = 1;
|
||||
const FROM_NOBODY = 2;
|
||||
// ECardInbox's settings popup sends the place of the option picked, and its
|
||||
// artwork has Nobody first and Everyone last: the other way round from the
|
||||
// above. turned over both ways between the two (buddies is in the middle).
|
||||
const SETTING_COUNT = 3;
|
||||
const turnedOver = value => SETTING_COUNT - 1 - value;
|
||||
|
||||
const LIST_CARDS = 10;
|
||||
const LIST_STAMPS = 44;
|
||||
@@ -69,8 +77,23 @@ 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 gift the game can show and take: its item still exists (a custom item
|
||||
// may have been deleted since), or an amount that makes sense. any other
|
||||
// left the gift windows stuck; it is treated as no gift at all.
|
||||
const MAX_GIFT_AMOUNT = 10000000;
|
||||
const giftUsable = gift => {
|
||||
if (gift.type === TYPE_CLOTHING) {
|
||||
return Boolean(defpacks.itemDef(gift.def)) && Number.isFinite(Number(gift.color));
|
||||
}
|
||||
if (gift.type === TYPE_DEN_ITEM) {
|
||||
return Boolean(defpacks.denItemDef(gift.def));
|
||||
}
|
||||
const amount = Number(gift.def);
|
||||
return Object.hasOwn(CURRENCY_OF, gift.type) && Number.isInteger(amount) && amount > 0 && amount <= MAX_GIFT_AMOUNT;
|
||||
};
|
||||
|
||||
// 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));
|
||||
const isRedemption = card => Boolean(card.hq && card.gift && giftUsable(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.
|
||||
@@ -90,9 +113,10 @@ module.exports = ({findOnline, blocks}) => {
|
||||
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;
|
||||
const gift = card.gift && giftUsable(card.gift) ? card.gift : null;
|
||||
return [
|
||||
card.id, name, card.card, card.stamp, card.read ? 1 : 0, card.msg, card.gift ? card.gift.type : TYPE_PLAIN,
|
||||
card.gift ? giftId(card.gift) : 0, card.gift ? card.gift.color : 0, card.gift ? card.gift.name : 0,
|
||||
card.id, name, card.card, card.stamp, card.read ? 1 : 0, card.msg, gift ? gift.type : TYPE_PLAIN,
|
||||
gift ? giftId(gift) : 0, gift ? gift.color : 0, gift ? gift.name : 0,
|
||||
card.hq || card.secret ? MEMBER : sender ? sender.accountType : 0,
|
||||
0, // name bar data
|
||||
0, // secondary type
|
||||
@@ -102,7 +126,7 @@ module.exports = ({findOnline, blocks}) => {
|
||||
// patched client (ECardInbox) can show a custom item as itself (its
|
||||
// own picture and name) and not as the art it was made from. (the
|
||||
// "|" keeps the game from taking it for an HQ gift's own message.)
|
||||
card.gift && card.gift.type === TYPE_CLOTHING ? `item|${card.gift.def}` : "",
|
||||
gift && gift.type === TYPE_CLOTHING ? `item|${gift.def}` : "",
|
||||
card.secret ? SECRET_VALENTINE : 0,
|
||||
];
|
||||
};
|
||||
@@ -155,7 +179,11 @@ module.exports = ({findOnline, blocks}) => {
|
||||
}
|
||||
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};
|
||||
const amount = Number(gift.amount);
|
||||
if (!Number.isInteger(amount) || amount < 1 || amount > MAX_GIFT_AMOUNT) {
|
||||
return "An amount from 1 to 10,000,000";
|
||||
}
|
||||
attached = {type: gift.kind === "gems" ? TYPE_GEMS : TYPE_DIAMONDS, def: amount, color: 0, name: amount};
|
||||
}
|
||||
// the gift popup takes a message that starts with a number for the id of
|
||||
// a localization string (StartupPopups.setupGiftPopup).
|
||||
@@ -218,8 +246,8 @@ module.exports = ({findOnline, blocks}) => {
|
||||
}
|
||||
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);
|
||||
account.currency[currency] = (account.currency[currency] || 0) + Number(gift.def);
|
||||
achievements.currencyChanged(account, currency, Number(gift.def));
|
||||
// ItemXtCommManager.currencyUpdateResponse: [currencyType, newAmount, reason]
|
||||
session.sendXt("cu", -1, CURRENCY_OF[gift.type], account.currency[currency], 0);
|
||||
}
|
||||
@@ -251,7 +279,8 @@ module.exports = ({findOnline, blocks}) => {
|
||||
// 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)) {
|
||||
// The client also skips its per-recipient cap for moderators.
|
||||
|| (!account.isModerator && !sendsPerTenMinutes.allow(account.id))) {
|
||||
reply(FAILED);
|
||||
return;
|
||||
}
|
||||
@@ -324,6 +353,13 @@ module.exports = ({findOnline, blocks}) => {
|
||||
return;
|
||||
}
|
||||
const {gift} = card;
|
||||
// a gift that cannot be had (above): gone, and the window let go
|
||||
if (!giftUsable(gift)) {
|
||||
card.gift = null;
|
||||
accounts.save(session.account);
|
||||
session.sendXt("eg", -1, msgId, 1);
|
||||
return;
|
||||
}
|
||||
// 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")))) {
|
||||
@@ -344,7 +380,7 @@ module.exports = ({findOnline, blocks}) => {
|
||||
|
||||
// [setting] -> eCardIsolationHandler: [success]
|
||||
ei(session, roomId, [setting]) {
|
||||
const value = Number(setting);
|
||||
const value = turnedOver(Number(setting));
|
||||
const valid = [FROM_EVERYONE, FROM_BUDDIES, FROM_NOBODY].includes(value);
|
||||
if (valid) {
|
||||
session.account.ecardPrivacy = value;
|
||||
@@ -373,5 +409,7 @@ module.exports = ({findOnline, blocks}) => {
|
||||
return card ? senderOf(card) : null;
|
||||
};
|
||||
|
||||
return {handlers, list, unread, redemptions, sendFromHq, noteFromHq, secretSender, SECRET_NAME: "Secret Valentine"};
|
||||
// the setting as the inbox's settings popup shows it (above)
|
||||
const privacyShown = account => turnedOver(account.ecardPrivacy || FROM_EVERYONE);
|
||||
return {handlers, list, unread, redemptions, privacyShown, sendFromHq, noteFromHq, secretSender, SECRET_NAME: "Secret Valentine"};
|
||||
};
|
||||
+227
@@ -0,0 +1,227 @@
|
||||
"use strict";
|
||||
|
||||
const accounts = require("./accounts.js");
|
||||
const achievements = require("./achievements.js");
|
||||
const config = require("../config.js");
|
||||
const defpacks = require("./defpacks.js");
|
||||
|
||||
// the eco den items: producers (special type 6, the Eco Solar Panel and
|
||||
// Eco Wind Turbine) and consumers (7, the eco lamps and fan), sold for eco
|
||||
// credits in the Eco Shop (list 778). client side: gui.EcoScorePopup (a
|
||||
// producer clicked), gui.EcoPointsPopup (a consumer clicked),
|
||||
// DenItemHolder.updateConsumers. the official server's rules were never
|
||||
// recorded; these are this server's:
|
||||
//
|
||||
// - a den's generation is the eco power of the producers placed in its
|
||||
// owner's den in use; consumers switched on take theirs from it, in
|
||||
// inventory order, and one that no longer fits is "offline" (state 2)
|
||||
// until there is power for it again. its switch stays on.
|
||||
// - generation turns into credits, config.ecoCreditsPerPointHour a point
|
||||
// an hour, waiting to be collected ("Get Your Credits") up to the
|
||||
// meter's full 240. an account's first look (an eco window, or the
|
||||
// Eco Shop) gets it config.ecoStartCredits, enough for its first producer.
|
||||
// - the eco score (generation less use) earns the three eco plaques, one
|
||||
// at a time, through user var 465 (a bit each).
|
||||
|
||||
const SPECIAL_PRODUCER = "6";
|
||||
const SPECIAL_CONSUMER = "7";
|
||||
const WIND_TURBINE = 4541;
|
||||
const SOLAR_PANEL = 4540;
|
||||
const CURRENCY_ECO = 11;
|
||||
const ECO_SHOP_LIST = 778;
|
||||
const MAX_WAITING = 240; // EcoScorePopup.updateCreditProgressMeter: the meter is full at 240
|
||||
const USER_VAR_REWARDS = 465;
|
||||
const REWARDS = [
|
||||
{bit: 0, score: 5, def: 4611}, // Wood Eco Plaque
|
||||
{bit: 1, score: 15, def: 4610}, // Silver Eco Plaque
|
||||
{bit: 2, score: 30, def: 4609}, // Gold Eco Plaque
|
||||
];
|
||||
const HOUR_MS = 3600000;
|
||||
|
||||
const OFF = 0;
|
||||
const ON = 1;
|
||||
const OFFLINE = 2;
|
||||
|
||||
const special = item => {
|
||||
const def = defpacks.denItemDef(item.def);
|
||||
return def ? String(def.specialType) : "";
|
||||
};
|
||||
const power = item => Number((defpacks.denItemDef(item.def) || {}).ecoPower) || 0;
|
||||
const placedInUse = account => account.denItems.filter(item => item.spots && item.spots[account.activeDen]);
|
||||
|
||||
// the den in use as the eco windows see it: {generation, consumption,
|
||||
// turbines, panels, consumers: [item], states: Map(inv -> 0 off, 1 on, 2 offline)}
|
||||
const stateOf = account => {
|
||||
const placed = placedInUse(account);
|
||||
const producers = placed.filter(item => special(item) === SPECIAL_PRODUCER);
|
||||
const consumers = placed.filter(item => special(item) === SPECIAL_CONSUMER).sort((one, other) => one.inv - other.inv);
|
||||
const generation = producers.reduce((sum, item) => sum + power(item), 0);
|
||||
let consumption = 0;
|
||||
const states = new Map();
|
||||
for (const item of consumers) {
|
||||
if (!item.ecoOn) {
|
||||
states.set(item.inv, OFF);
|
||||
}
|
||||
else if (consumption + power(item) <= generation) {
|
||||
consumption += power(item);
|
||||
states.set(item.inv, ON);
|
||||
}
|
||||
else {
|
||||
states.set(item.inv, OFFLINE);
|
||||
}
|
||||
}
|
||||
return {
|
||||
generation,
|
||||
consumption,
|
||||
turbines: producers.filter(item => item.def === WIND_TURBINE).length,
|
||||
panels: producers.filter(item => item.def === SOLAR_PANEL).length,
|
||||
consumers,
|
||||
states,
|
||||
};
|
||||
};
|
||||
|
||||
// a den item's eco field in the den's state (DenStateItem's last): 0 for
|
||||
// all but consumers
|
||||
const consumerState = (account, item) => (special(item) === SPECIAL_CONSUMER ? stateOf(account).states.get(item.inv) || OFF : OFF);
|
||||
|
||||
const perHour = generation => generation * (Number(config.ecoCreditsPerPointHour) || 0);
|
||||
|
||||
// brings the waiting credits up to now, at the rate the den has now. the
|
||||
// caller saves.
|
||||
const accrue = account => {
|
||||
const now = Date.now();
|
||||
if (!account.eco) {
|
||||
account.eco = {waiting: 0, at: now};
|
||||
const start = Math.max(0, Math.floor(Number(config.ecoStartCredits) || 0));
|
||||
account.currency.ecoCredits = (account.currency.ecoCredits || 0) + start;
|
||||
return;
|
||||
}
|
||||
const rate = perHour(stateOf(account).generation);
|
||||
const hours = Math.max(0, now - account.eco.at) / HOUR_MS;
|
||||
account.eco.waiting = Math.min(MAX_WAITING, (Number(account.eco.waiting) || 0) + rate * hours);
|
||||
account.eco.at = now;
|
||||
};
|
||||
|
||||
// seconds until one more whole credit waits, 0 when none will
|
||||
const secondsToNext = account => {
|
||||
const rate = perHour(stateOf(account).generation);
|
||||
if (rate <= 0 || account.eco.waiting >= MAX_WAITING) {
|
||||
return 0;
|
||||
}
|
||||
const short = 1 - (account.eco.waiting % 1);
|
||||
return Math.max(1, Math.ceil(short / rate * 3600));
|
||||
};
|
||||
|
||||
const nextReward = account => {
|
||||
const bits = Number(account.userVars[USER_VAR_REWARDS]) || 0;
|
||||
return REWARDS.find(reward => !(bits & (1 << reward.bit))) || null;
|
||||
};
|
||||
|
||||
module.exports = ({others, ecards}) => {
|
||||
const sendCredits = session => session.sendXt("cu", -1, CURRENCY_ECO, session.account.currency.ecoCredits || 0, 0);
|
||||
|
||||
// the consumers' states to the owner and, when they are in it, everyone
|
||||
// else in the den: DenXtCommManager.denEcoConsumerResponse [consumption,
|
||||
// generation, count, (invIdx, state)...].
|
||||
const sendConsumers = session => {
|
||||
const {account} = session;
|
||||
const state = stateOf(account);
|
||||
const fields = [state.consumption, state.generation, state.consumers.length,
|
||||
...state.consumers.flatMap(item => [item.inv, state.states.get(item.inv)])];
|
||||
session.sendXt("dEc", -1, ...fields);
|
||||
if (session.room && session.room.denOwner === account) {
|
||||
for (const other of others(session)) {
|
||||
other.sendXt("dEc", -1, ...fields);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handlers = {
|
||||
// requestDenEcoCreditRefresh -> EcoStateResponse: [turbines, panels,
|
||||
// consumers, generation, consumption, score required, next reward bit,
|
||||
// credits waiting, seconds to the next].
|
||||
dEf(session) {
|
||||
const {account} = session;
|
||||
const firstLook = !account.eco;
|
||||
accrue(account);
|
||||
accounts.save(account);
|
||||
if (firstLook) {
|
||||
sendCredits(session);
|
||||
}
|
||||
const state = stateOf(account);
|
||||
const reward = nextReward(account);
|
||||
session.sendXt("dEf", -1, state.turbines, state.panels, state.consumers.length, state.generation, state.consumption,
|
||||
reward ? reward.score : REWARDS[REWARDS.length - 1].score, reward ? reward.bit : -1,
|
||||
Math.floor(account.eco.waiting), secondsToNext(account));
|
||||
},
|
||||
|
||||
// requestDenEcoCreditRedeem: the waiting credits collected -> [success,
|
||||
// seconds to the next].
|
||||
dEr(session) {
|
||||
const {account} = session;
|
||||
accrue(account);
|
||||
const credits = Math.floor(account.eco.waiting);
|
||||
if (credits < 1) {
|
||||
accounts.save(account);
|
||||
session.sendXt("dEr", -1, 0, secondsToNext(account));
|
||||
return;
|
||||
}
|
||||
account.eco.waiting -= credits;
|
||||
account.currency.ecoCredits = (account.currency.ecoCredits || 0) + credits;
|
||||
achievements.currencyChanged(account, "ecoCredits", credits);
|
||||
accounts.save(account);
|
||||
sendCredits(session);
|
||||
session.sendXt("dEr", -1, 1, secondsToNext(account));
|
||||
},
|
||||
|
||||
// requestDenEcoConsumer: [invIdx, "1" on | "0" off]
|
||||
dEc(session, roomId, [invIdx, on]) {
|
||||
const {account} = session;
|
||||
const item = account.denItems.find(candidate => candidate.inv === Number(invIdx));
|
||||
if (item && special(item) === SPECIAL_CONSUMER) {
|
||||
accrue(account);
|
||||
item.ecoOn = on === "1";
|
||||
accounts.save(account);
|
||||
}
|
||||
sendConsumers(session);
|
||||
},
|
||||
};
|
||||
|
||||
// user var 465, set by the eco score window's gift: the value is the bit
|
||||
// of the reward asked for. given when it is the next one and the score is
|
||||
// there; the plaque comes as a gift from HQ. true when the var was this.
|
||||
const userVar = (session, id, bit) => {
|
||||
if (Number(id) !== USER_VAR_REWARDS) {
|
||||
return false;
|
||||
}
|
||||
const {account} = session;
|
||||
const reward = nextReward(account);
|
||||
const state = stateOf(account);
|
||||
if (reward && reward.bit === Number(bit) && state.generation - state.consumption >= reward.score
|
||||
&& !ecards.sendFromHq(account, "Eco Reward", {kind: "den", id: reward.def})) {
|
||||
account.userVars[USER_VAR_REWARDS] = (Number(account.userVars[USER_VAR_REWARDS]) || 0) | (1 << reward.bit);
|
||||
accounts.save(account);
|
||||
}
|
||||
if (account.userVars[USER_VAR_REWARDS] === undefined) {
|
||||
account.userVars[USER_VAR_REWARDS] = 0;
|
||||
}
|
||||
achievements.sendVar(session, USER_VAR_REWARDS);
|
||||
return true;
|
||||
};
|
||||
|
||||
// the Eco Shop opened: an account that never had eco credits is given
|
||||
// its first, to buy its first producer with.
|
||||
const shopOpened = session => {
|
||||
if (!session.account.eco) {
|
||||
accrue(session.account);
|
||||
accounts.save(session.account);
|
||||
sendCredits(session);
|
||||
}
|
||||
};
|
||||
|
||||
return {handlers, userVar, shopOpened, SHOP_LIST: ECO_SHOP_LIST};
|
||||
};
|
||||
|
||||
module.exports.accrue = accrue;
|
||||
module.exports.consumerState = consumerState;
|
||||
module.exports.SPECIAL_TYPES = [SPECIAL_PRODUCER, SPECIAL_CONSUMER];
|
||||
+101
-70
@@ -1,84 +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": 1, "swf": "PVP_TicTacToe", "title": "Tic Tac Toe", "type": 0, "vars": [63,0,0], "icon": 5063, "card": 5055, "buddy": true},
|
||||
{"id": 4, "swf": "Pachinko", "title": "Gem Ball", "type": 1, "vars": [16,17,0], "icon": 4295, "card": 58},
|
||||
{"id": 5, "swf": "MiniGame_Memory", "title": "Double Up", "type": 1, "vars": [6,7,0], "icon": 4291, "card": 61},
|
||||
{"id": 6, "swf": "MoatMadness", "title": "Overflow", "type": 1, "vars": [8,9,9], "icon": 4300, "card": 59},
|
||||
{"id": 10, "swf": "ParachuteGlider", "title": "Wind Rider", "type": 1, "vars": [12,13,0], "start": "seedAndCrosshairs", "icon": 4311, "card": 65},
|
||||
{"id": 11, "swf": "Trivia", "title": "Temple of Trivia", "type": 1, "vars": [10,11,0], "icon": 4309, "card": 64, "ready": false},
|
||||
{"id": 12, "swf": "RiverRace", "title": "River Race", "type": 1, "vars": [22,23,0], "start": "seed", "card": 62},
|
||||
{"id": 13, "swf": "PhantomFighter", "title": "Phantom Fighter", "type": 1, "vars": [14,15,0], "icon": 4312, "card": 60},
|
||||
{"id": 14, "swf": "SpiderShooter", "title": "Spider Zapper", "type": 1, "vars": [18,19,0], "start": "seedAndCrosshairs", "icon": 4305, "card": 63},
|
||||
{"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": 18, "swf": "MicroCrane", "title": "The Claw", "type": 0},
|
||||
{"id": 19, "swf": "WindRider", "title": "Sky High", "type": 1, "vars": [26,27,0], "icon": 4304, "card": 78},
|
||||
{"id": 20, "swf": "Twister", "title": "Twister", "type": 1, "vars": [24,25,0], "icon": 4310, "card": 79},
|
||||
{"id": 21, "swf": "FrogFlyer", "title": "Long Shot", "type": 1, "ready": false},
|
||||
{"id": 22, "swf": "DistanceChallenge", "title": "Long Shot", "type": 1, "vars": [20,21,21], "icon": 4298, "card": 80},
|
||||
{"id": 23, "swf": "ArtStudioPrint", "title": "Coloring", "type": 1, "card": 58},
|
||||
{"id": 24, "swf": "ArtStudioColor", "title": "Coloring", "type": 1, "card": 58, "ready": false},
|
||||
{"id": 25, "swf": "ParachuteGliderTest", "title": "Wind Rider", "type": 1, "card": 65, "ready": false},
|
||||
{"id": 26, "swf": "ArtStudioPottery", "title": "Pottery", "type": 1, "card": 58},
|
||||
{"id": 27, "swf": "MicroPhantom", "title": "Phantom Vortex", "type": 0, "card": 69},
|
||||
{"id": 28, "swf": "TowerDefense", "title": "Pest Control", "type": 1, "vars": [130,131,132], "icon": 4301, "card": 456},
|
||||
{"id": 29, "swf": "GemBreaker", "title": "Gem Breaker", "type": 1, "start": "seedAndPlayers", "card": 58},
|
||||
{"id": 30, "swf": "GemBreaker", "title": "Gem Breaker", "type": 1, "vars": [91,32,0], "start": "seedAndPlayers", "icon": 4313, "card": 354},
|
||||
{"id": 31, "swf": "PVP_ConnectFour", "title": "Four Gems", "type": 0, "icon": 5057, "card": 5049, "buddy": true},
|
||||
{"id": 32, "swf": "PVP_RockPaperScissor", "title": "Rock Paper Scissors", "type": 0, "icon": 5060, "card": 5052, "buddy": true},
|
||||
{"id": 34, "swf": "MicroMiraSays", "title": "Mira Says", "type": 1, "vars": [77,76,0], "icon": 4299, "card": 288},
|
||||
{"id": 35, "swf": "FortSmasher", "title": "Fruit Slinger", "type": 1, "vars": [74,75,0], "icon": 4294, "card": 541, "ready": false},
|
||||
{"id": 36, "swf": "MicroHotCocoa", "title": "Hot Cocoa Machine", "type": 0, "vars": [95,0,0]},
|
||||
{"id": 37, "swf": "SuperSort", "title": "Super Sort", "type": 1, "vars": [31,32,37], "icon": 4307, "card": 353},
|
||||
{"id": 38, "swf": "PVP_ShellGame", "title": "Shell Game", "type": 0, "icon": 5062, "card": 5054, "buddy": true},
|
||||
{"id": 39, "swf": "PillBugs", "title": "Pill Bugs", "type": 1, "vars": [277,278,279], "icon": 4303, "card": 1098},
|
||||
{"id": 40, "swf": "BradyChemistrySet", "title": "Brady's Lab", "type": 0, "vars": [115,0,0]},
|
||||
{"id": 41, "swf": "PhantomsTreasure", "title": "Phantom's Treasure", "type": 1, "vars": [281,283,282], "icon": 4302, "card": 1140},
|
||||
{"id": 42, "swf": "FeedingFrenzy", "title": "Eat 'Em Up", "type": 1, "vars": [284,0,0], "icon": 4292, "card": 1170},
|
||||
{"id": 43, "swf": "MicroPetWash", "title": "Pet Wash", "type": 0, "vars": [51,0,0]},
|
||||
{"id": 45, "swf": "PVP_Marbles", "title": "Marbles", "type": 0, "icon": 5058, "card": 5050, "buddy": true},
|
||||
{"id": 46, "swf": "OffTheHook", "title": "Off the Hook", "type": 1, "card": 79, "ready": false},
|
||||
{"id": 47, "swf": "Pinball", "title": "Double Up", "type": 1, "card": 61, "ready": false},
|
||||
{"id": 48, "swf": "FashionShow", "title": "Best Dressed", "type": 1, "vars": [292,293,294], "icon": 4288, "card": 1205, "ready": false},
|
||||
{"id": 49, "swf": "Geography", "title": "Geography", "type": 1, "card": 79, "ready": false},
|
||||
{"id": 51, "swf": "ArtStudioPainting", "title": "Painting", "type": 1, "vars": [78,0,0], "card": 4849},
|
||||
{"id": 52, "swf": "MicroPetSalon", "title": "Pet Stop", "type": 0, "vars": [280,0,0], "card": 1205},
|
||||
{"id": 53, "swf": "PVP_Scooped", "title": "Scooped", "type": 0, "icon": 5061, "card": 5053, "buddy": true},
|
||||
{"id": 54, "swf": "Glide", "title": "Glide", "type": 1, "card": 79, "ready": false},
|
||||
{"id": 55, "swf": "MicroGameInvasion", "title": "Phantom Invasion", "type": 0, "card": 1205},
|
||||
{"id": 56, "swf": "ActivityGeography", "title": "Eat 'Em Up", "type": 1, "card": 1205, "ready": false},
|
||||
{"id": 57, "swf": "MicroCrane", "title": "The Claw", "type": 0},
|
||||
{"id": 58, "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": 60, "swf": "TouchPool", "title": "Touch Pool", "type": 1, "vars": [310,308,309], "icon": 5229, "card": 5228},
|
||||
{"id": 61, "swf": "MicroCrane", "title": "The Claw", "type": 0, "card": 65},
|
||||
{"id": 62, "swf": "HorseRace", "title": "Jamaa Derby", "type": 1, "vars": [327,328,330], "icon": 4297, "card": 1510, "ready": false},
|
||||
{"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], "icon": 4289, "card": 1482, "ready": false},
|
||||
{"id": 67, "swf": "MicroCrane", "title": "The Claw", "type": 0},
|
||||
{"id": 68, "swf": "Skeeball", "title": "Phantom Ball", "type": 0, "tickets": 10},
|
||||
{"id": 69, "swf": "WhackPhantom", "title": "Whack-A-Phantom", "type": 0, "vars": [78,0,0], "tickets": 10, "card": 300},
|
||||
{"id": 70, "swf": "CandyCatcher", "title": "Candy Catch", "type": 0, "tickets": 10, "card": 300},
|
||||
{"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": 72, "swf": "MicroGameInvasion", "title": "Phantom Invasion", "type": 0, "card": 259},
|
||||
{"id": 73, "swf": "ArtPrintPlayPortrait", "title": "Painting", "type": 1, "vars": [78,0,0], "card": 1205},
|
||||
{"id": 74, "swf": "CottonCandy", "title": "Cotton Candy Machine", "type": 0, "vars": [78,0,0]},
|
||||
{"id": 75, "swf": "MicroCrane", "title": "The Claw", "type": 0, "card": 300},
|
||||
{"id": 76, "swf": "ArtPrintPlayPortrait", "title": "Painting", "type": 0},
|
||||
{"id": 77, "swf": "FallingPhantoms", "title": "Falling Phantoms", "type": 1, "vars": [344,345,346], "icon": 4293, "card": 1622, "ready": false},
|
||||
{"id": 78, "swf": "DolphinRace", "title": "Splash and Dash", "type": 1, "vars": [357,358,360], "icon": 4306, "card": 1804, "ready": false},
|
||||
{"id": 80, "swf": "ShootingGallery", "title": "Carnival Darts", "type": 0, "tickets": 100},
|
||||
{"id": 81, "swf": "MicroPetSalon", "title": "Pet Stop", "type": 0, "vars": [57,0,0], "card": 259},
|
||||
{"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, "card": 1713},
|
||||
{"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": 86, "swf": "ArtPrintPlayPortrait", "title": "Painting", "type": 0},
|
||||
{"id": 87, "swf": "ArtPrintPlayPortrait", "title": "Painting", "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": 89, "swf": "ArtStudioPrint", "title": "Coloring", "type": 0},
|
||||
{"id": 90, "swf": "BradyExpeditions", "title": "Brady Expeditions", "type": 1},
|
||||
{"id": 91, "swf": "MicroSmoothie", "title": "Smoothie Machine", "type": 0},
|
||||
{"id": 92, "swf": "ParachuteGlider2", "title": "Wind Rider", "type": 1, "card": 65, "ready": false},
|
||||
{"id": 93, "swf": "QuestParachuteGlider", "title": "Wind Rider", "type": 1, "vars": [12,13,0], "card": 65, "ready": false},
|
||||
{"id": 94, "swf": "EagleFlap", "title": "Swoopy Eagle", "type": 1, "vars": [378,377,0], "icon": 4308, "card": 2647},
|
||||
{"id": 95, "swf": "ArtPrintPlayPortrait", "title": "Painting", "type": 0},
|
||||
{"id": 96, "swf": "DunkAPhantom", "title": "Dunk-A-Phantom", "type": 0, "tickets": 10, "card": 300},
|
||||
{"id": 97, "swf": "SpotOn", "title": "Spot On", "type": 1, "vars": [386,387,388], "icon": 4321, "card": 3561},
|
||||
{"id": 98, "swf": "MicroCrane", "title": "The Claw", "type": 0, "vars": [5,0,0]},
|
||||
{"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": 101, "swf": "PVP_Memory", "title": "Pairs", "type": 0, "icon": 5059, "card": 5051, "buddy": true},
|
||||
{"id": 102, "swf": "TrueFalse", "title": "Best Guess", "type": 1, "vars": [403,0,0], "card": 3748, "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": 104, "swf": "MicroCrane", "title": "The Claw", "type": 0, "card": 300},
|
||||
{"id": 105, "swf": "MicroCrane", "title": "The Claw", "type": 0, "card": 61},
|
||||
{"id": 106, "swf": "MicroCrane", "title": "The Claw", "type": 0, "card": 61},
|
||||
{"id": 107, "swf": "MicroCrane", "title": "The Claw", "type": 0},
|
||||
{"id": 108, "swf": "PVP_Bowling", "title": "Bowling", "type": 0, "icon": 5056, "card": 5048, "buddy": true},
|
||||
{"id": 109, "swf": "MicroCrane", "title": "The Claw", "type": 0},
|
||||
{"id": 110, "swf": "MicroCrane", "title": "The Claw", "type": 0},
|
||||
{"id": 111, "swf": "MicroGoldPanning", "title": "Long Shot", "type": 0, "vars": [415,0,0], "ready": false},
|
||||
{"id": 112, "swf": "MicroOatHarvest", "title": "Slingshot", "type": 0, "vars": [415,0,0], "ready": false},
|
||||
{"id": 113, "swf": "MicroWoodGather", "title": "Slingshot", "type": 0, "vars": [415,0,0], "ready": false},
|
||||
{"id": 114, "swf": "MicroStoneMining", "title": "Slingshot", "type": 0, "vars": [415,0,0], "ready": false},
|
||||
{"id": 115, "swf": "MicroBambooHarvest", "title": "Slingshot", "type": 0, "vars": [415,0,0], "ready": false},
|
||||
{"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": 122, "swf": "ArtPrintPlayPortrait", "title": "Painting", "type": 0},
|
||||
{"id": 123, "swf": "MicroCrane", "title": "The Claw", "type": 0},
|
||||
{"id": 124, "swf": "ArtPrintPlayPortrait", "title": "Painting", "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},
|
||||
@@ -89,9 +123,11 @@
|
||||
{"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": 135, "swf": "ArtPrintPlayPortrait", "title": "Painting", "type": 0},
|
||||
{"id": 136, "swf": "ArtPrintPlayPortrait", "title": "Painting", "type": 0},
|
||||
{"id": 137, "swf": "ArtPrintPlayPortrait", "title": "Painting", "type": 0},
|
||||
{"id": 138, "swf": "FastFoodies", "title": "Fast Foodies", "type": 1, "vars": [445,444,446], "icon": 5727, "card": 5723},
|
||||
{"id": 139, "swf": "ArtStudioGridDrawing", "title": "Pixel Painting", "type": 1, "card": 5958},
|
||||
{"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},
|
||||
@@ -103,16 +139,11 @@
|
||||
{"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": 151, "swf": "ArtStudioGridDrawing", "title": "Pixel Painting", "type": 1, "vars": [78,0,0], "card": 5958},
|
||||
{"id": 152, "swf": "ArtStudioPrint", "title": "Coloring", "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}
|
||||
{"id": 158, "swf": "ArtPrintPlayPortrait", "title": "Painting", "type": 1, "vars": [78,0,0], "card": 1205}
|
||||
]
|
||||
+19
-3
@@ -28,6 +28,7 @@ const extraMusic = require("./extramusic.js");
|
||||
const customMusic = require("./custommusic.js");
|
||||
const itemControl = require("./itemcontrol.js");
|
||||
const masterpieces = require("./masterpieces.js");
|
||||
const themeRooms = require("./themerooms.js");
|
||||
const panel = require("./panel.js");
|
||||
const totp = require("./totp.js");
|
||||
const world = require("./world.js");
|
||||
@@ -1008,6 +1009,10 @@ const handle = async (req, res) => {
|
||||
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 /burrow-status-banner.png": // public banner used by the Discord status card
|
||||
res.setHeader("Cache-Control", "public, max-age=86400");
|
||||
send(res, 200, await fs.promises.readFile(path.join(config.publicDir, "burrow-status-banner.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"]);
|
||||
@@ -1141,7 +1146,15 @@ const handle = async (req, res) => {
|
||||
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");
|
||||
if (picture) {
|
||||
send(res, 200, picture, MIME[".jpg"]);
|
||||
return;
|
||||
}
|
||||
// one that cannot be shown (waiting to be looked at, seen from an
|
||||
// address not its maker's game's, or its file gone) is the Burrow logo:
|
||||
// given nothing, the game waited for it for good, behind its spinner.
|
||||
res.setHeader("Cache-Control", "no-store");
|
||||
send(res, 200, await fs.promises.readFile(path.join(config.publicDir, "logo-square.png")), MIME[".png"]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1179,8 +1192,11 @@ const handle = async (req, res) => {
|
||||
// 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);
|
||||
const currentPath = themed ? `${themed[1]}/roomDefs/${themed[3]}` : relPath;
|
||||
const oldBody = themed && themed[2] !== themed[1] && Object.values(config.themes).some(theme => theme.build === Number(themed[2]))
|
||||
&& await cdn.get(`${themed[2]}/roomDefs/${themed[3]}`, mayFetch);
|
||||
// its shops and other spots as today's room has them (lib/themerooms.js)
|
||||
const body = oldBody ? await themeRooms.fix(relPath, oldBody, () => cdn.get(currentPath, mayFetch)) : await cdn.get(currentPath, mayFetch);
|
||||
if (!body) {
|
||||
// one the CDN does not have is asked for again and again (the same few
|
||||
// hundred, by every client that meets them): its client may keep the
|
||||
|
||||
+2
-2
@@ -22,9 +22,9 @@ const imageModeration = require("./image-moderation.js");
|
||||
// kept as data/itemart/<kind>-<id>.<png|jpg|gif>; its version, a hash, is on
|
||||
// the item (customItems.setArt), so a new picture is a new address.
|
||||
|
||||
const MAX_BYTES = 300 * 1024; // a picture kept
|
||||
const MAX_BYTES = 100 * 1024; // a picture kept: every player who sees the item downloads it
|
||||
const MAX_UPLOAD = 2 * 1024 * 1024; // one sent (a BMP is bigger than the PNG it becomes)
|
||||
const MAX_SIDE = 512;
|
||||
const MAX_SIDE = 256; // drawn fitted to the item anyway (a den item's place is 160)
|
||||
const MIN_SIDE = 8;
|
||||
const DIR = path.join(config.dataDir, "itemart");
|
||||
const PNG_SIGNATURE = Buffer.from([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]);
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
"use strict";
|
||||
|
||||
// pictures of items for the web item giver (public/items.html), from the
|
||||
// game's own files on the CDN:
|
||||
//
|
||||
// - clothing: the icon the game shows in a closet (item.SimpleIcon), a
|
||||
// paletted bitmap the page colours itself as the game does
|
||||
// (LayerBitmap.paintFrame), so any four colours show without asking again.
|
||||
// - den items: their art, a SWF, which public/item-preview.html plays with
|
||||
// Ruffle through public/item-preview.swf (tools/preview-host).
|
||||
//
|
||||
// both are the same for everyone, so no sign-in is asked for them.
|
||||
|
||||
const zlib = require("zlib");
|
||||
const amf3 = require("./amf3.js");
|
||||
const cdn = require("./cdn.js");
|
||||
const customItems = require("./customitems.js");
|
||||
const defpacks = require("./defpacks.js");
|
||||
|
||||
const ICON_AVATAR = 1; // the avatar every closet icon is drawn for (Item.makeSmallIcon)
|
||||
const ICON_LARGE = 25; // SimpleIcon.AN_ICON_L
|
||||
const ICON_SMALL = 26; // SimpleIcon.AN_ICON_S
|
||||
const IMAGE_VERSION = 0x7080900; // what ImageServerURL accepts
|
||||
|
||||
// DenItem.getIconId: which of an item's pictures the den shows, by its sort category.
|
||||
const iconId = sortCat => ([0, 99, 6, 5].includes(sortCat) ? 1 : sortCat === 1 ? 2 : [2, 3, 4].includes(sortCat) ? 3 : sortCat + 1);
|
||||
|
||||
// a custom item is drawn as the game's item it was made from.
|
||||
const baseIdOf = (kind, id) => {
|
||||
const entry = customItems.get(kind, id);
|
||||
return entry ? entry.base : Number(id);
|
||||
};
|
||||
|
||||
// a clothing item's closet icon, large if there is one: {w, h, b} with b the
|
||||
// first frame's run-length bytes, base64 (LayerBitmap.paintFrame reads them).
|
||||
// null when it has none.
|
||||
const clothingIcon = async id => {
|
||||
const def = defpacks.itemDef(id);
|
||||
if (!def || !Number.isInteger(Number(def.layerDefId))) {
|
||||
return null;
|
||||
}
|
||||
for (const size of [ICON_LARGE, ICON_SMALL]) {
|
||||
const file = await cdn.get(cdn.hashedPath(`imageArrays/${((ICON_AVATAR << 24) | (size << 16) | Number(def.layerDefId)) >>> 0}`));
|
||||
try {
|
||||
const image = file && amf3.decode(zlib.inflateSync(file));
|
||||
const frame = image && image.v === IMAGE_VERSION && Array.isArray(image.f) && image.f[0];
|
||||
if (frame && Buffer.isBuffer(frame.b) && frame.w > 0 && frame.h > 0) {
|
||||
return {w: frame.w, h: frame.h, b: frame.b.toString("base64")};
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
// not an icon this can read: the next size, or none.
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
// a den item's art as the SWF it holds, or null.
|
||||
const denArt = async id => {
|
||||
const def = defpacks.denItemDef(id);
|
||||
const baseId = baseIdOf("den", id);
|
||||
const baseDef = defpacks.denItemDef(baseId);
|
||||
if (!def || !baseDef) {
|
||||
return null;
|
||||
}
|
||||
const file = await cdn.get(cdn.hashedPath(`items/${((baseId << 16) | iconId(Number(baseDef.sortCat))) >>> 0}`));
|
||||
try {
|
||||
const wrapped = file && amf3.decode(file);
|
||||
return wrapped && wrapped.ba ? Buffer.from(wrapped.ba) : null;
|
||||
}
|
||||
catch (err) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {clothingIcon, denArt};
|
||||
@@ -19,6 +19,8 @@ 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
|
||||
const CURRENCY_GEMS = 0; // ItemXtCommManager.currencyUpdateResponse's currency type
|
||||
const PHOTO_GEMS = 50; // what the photo booth says a picture costs (string 14789)
|
||||
|
||||
module.exports = ({others, sendItemList}) => {
|
||||
// ItemXtCommManager.itemBuyResponse: [status, shopId, newAmount, currencyType]
|
||||
@@ -141,6 +143,43 @@ module.exports = ({others, sendItemList}) => {
|
||||
session.sendXt("ce", -1, 1, account.currency[paid]);
|
||||
},
|
||||
|
||||
// gui.MuseumDonation: [amount], gems given to the museum's causes. the
|
||||
// reply (currencyDonationResponse) is [1] or [0]; the gems go, and the
|
||||
// account keeps count of what it has given.
|
||||
cd(session, roomId, [amount]) {
|
||||
const {account} = session;
|
||||
const gems = /^\d{1,9}$/.test(String(amount)) ? Number(amount) : 0;
|
||||
if (gems < 1 || (account.currency.gems || 0) < gems) {
|
||||
session.sendXt("cd", -1, 0);
|
||||
return;
|
||||
}
|
||||
account.currency.gems -= gems;
|
||||
account.gemsDonated = (account.gemsDonated || 0) + gems;
|
||||
achievements.currencyChanged(account, "gems", -gems);
|
||||
accounts.save(account);
|
||||
session.sendXt("cu", -1, CURRENCY_GEMS, account.currency.gems, 0);
|
||||
session.sendXt("cd", -1, 1);
|
||||
},
|
||||
|
||||
// the photo booth's picture (gui.PhotoBooth), PHOTO_GEMS gems. "apc"
|
||||
// asks first: [gems after, or -1 for too few]; "apb", once the player
|
||||
// keeps the picture, pays: [gem total]. neither was answered, and the
|
||||
// booth waited behind its spinner for good.
|
||||
apc(session) {
|
||||
const gems = session.account.currency.gems || 0;
|
||||
session.sendXt("apc", -1, gems >= PHOTO_GEMS ? gems - PHOTO_GEMS : -1);
|
||||
},
|
||||
|
||||
apb(session) {
|
||||
const {account} = session;
|
||||
if ((account.currency.gems || 0) >= PHOTO_GEMS) {
|
||||
account.currency.gems -= PHOTO_GEMS;
|
||||
achievements.currencyChanged(account, "gems", -PHOTO_GEMS);
|
||||
accounts.save(account);
|
||||
}
|
||||
session.sendXt("apb", -1, account.currency.gems || 0);
|
||||
},
|
||||
|
||||
// ItemXtCommManager.requestItemRecycle: [invIdx, ...]. the reply
|
||||
// (itemRecycleResponse) is [count, newGemTotal, ...recycledInvIdx], and
|
||||
// the recycling window then waits, behind its spinner, for the item
|
||||
|
||||
+31
-1
@@ -1,5 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
const net = require("net");
|
||||
const config = require("../config.js");
|
||||
|
||||
// small in-memory rate limits for the parts of the server that strangers can
|
||||
@@ -28,6 +29,25 @@ const key = address => {
|
||||
|
||||
const isLoopback = address => LOOPBACK.includes(String(address || "").replace(/^::ffff:/i, ""));
|
||||
|
||||
// the addresses Cloudflare's edge connects from, as it publishes them at
|
||||
// https://www.cloudflare.com/ips/ (they seldom change; add any new range here).
|
||||
const CLOUDFLARE = new net.BlockList();
|
||||
for (const range of ["173.245.48.0/20", "103.21.244.0/22", "103.22.200.0/22", "103.31.4.0/22", "141.101.64.0/18",
|
||||
"108.162.192.0/18", "190.93.240.0/20", "188.114.96.0/20", "197.234.240.0/22", "198.41.128.0/17", "162.158.0.0/15",
|
||||
"104.16.0.0/13", "104.24.0.0/14", "172.64.0.0/13", "131.0.72.0/22"]) {
|
||||
const [prefix, bits] = range.split("/");
|
||||
CLOUDFLARE.addSubnet(prefix, Number(bits), "ipv4");
|
||||
}
|
||||
for (const range of ["2400:cb00::/32", "2606:4700::/32", "2803:f800::/32", "2405:b500::/32", "2405:8100::/32",
|
||||
"2a06:98c0::/29", "2c0f:f248::/32"]) {
|
||||
const [prefix, bits] = range.split("/");
|
||||
CLOUDFLARE.addSubnet(prefix, Number(bits), "ipv6");
|
||||
}
|
||||
const fromCloudflare = address => {
|
||||
const family = net.isIP(address);
|
||||
return family !== 0 && CLOUDFLARE.check(address, family === 4 ? "ipv4" : "ipv6");
|
||||
};
|
||||
|
||||
// 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);
|
||||
@@ -45,7 +65,17 @@ 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;
|
||||
// the last X-Forwarded-For entry is the one the local proxy appended: who
|
||||
// connected to it (the first is whatever the visitor sent, so it is never
|
||||
// used). Behind Cloudflare that is Cloudflare's own edge, which made every
|
||||
// visitor one address (and left remoteip out of the Turnstile check), so
|
||||
// then CF-Connecting-IP is the visitor. Only when that hop is Cloudflare:
|
||||
// anyone who reaches the server directly can send the header too. Neither
|
||||
// header counts unless the local reverse proxy has been trusted.
|
||||
const lastHop = (hops.at(-1) || "").replace(/^::ffff:/i, "");
|
||||
const cloudflareAddress = String(req.headers["cf-connecting-ip"] || "").trim().replace(/^::ffff:/i, "");
|
||||
const reported = net.isIP(cloudflareAddress) && fromCloudflare(lastHop) ? cloudflareAddress : lastHop;
|
||||
const address = config.trustedProxy && isLoopback(own) && reported ? reported.replace(/^::ffff:/i, "").slice(0, 60) : own;
|
||||
const direct = isLoopback(own) && !forwarded;
|
||||
return {address, key: key(address), direct, local: direct && config.trustLocalRequests};
|
||||
};
|
||||
|
||||
+223
-5
@@ -24,6 +24,10 @@ const support = require("./support.js");
|
||||
const totp = require("./totp.js");
|
||||
const recoveryMail = require("./recoverymail.js");
|
||||
const world = require("./world.js");
|
||||
const chatStyles = require("./chatstyles.js");
|
||||
const roles = require("./roles.js");
|
||||
const admin = require("./admin.js");
|
||||
const itemPreview = require("./itempreview.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
|
||||
@@ -50,6 +54,29 @@ const discordCookie = (value, maxAgeSeconds) =>
|
||||
`${DISCORD_COOKIE}=${value}; Path=/account/discord; HttpOnly; SameSite=Lax; Max-Age=${maxAgeSeconds}${config.secureCookies ? "; Secure" : ""}`;
|
||||
const SESSION_HOURS = 12;
|
||||
const TEN_MINUTES_MS = 600000;
|
||||
// "Sign in with the Burrow client": the page starts it, and keeps this
|
||||
// cookie; the link it opens (burrow://account?n=<nonce>) has the client ask
|
||||
// for a ticket with its own login token, which it then opens in the
|
||||
// browser at /account/client. the ticket signs in only the browser that
|
||||
// holds the nonce it was asked for, so a burrow:// link from anywhere else
|
||||
// signs nobody in, and a ticket sent to someone else opens nothing for them.
|
||||
const CLIENT_COOKIE = "ajc_clink";
|
||||
const clientCookie = (value, maxAgeSeconds) =>
|
||||
`${CLIENT_COOKIE}=${value}; Path=/account/client; HttpOnly; SameSite=Lax; Max-Age=${maxAgeSeconds}${config.secureCookies ? "; Secure" : ""}`;
|
||||
const CLIENT_START_MS = 5 * 60 * 1000;
|
||||
const CLIENT_TICKET_MS = 2 * 60 * 1000;
|
||||
const MAX_CLIENT_STARTS = 10000;
|
||||
const clientStarts = new Map(); // SHA-256 of a nonce -> expiry (ms)
|
||||
const clientTickets = new Map(); // SHA-256 of a ticket -> {id: account id, nonce: SHA-256 of its nonce, expiry: ms}
|
||||
const clientStartsByAddress = limits.limiter(20, TEN_MINUTES_MS);
|
||||
const clientTicketsByAccount = limits.limiter(10, TEN_MINUTES_MS);
|
||||
const dropExpired = map => {
|
||||
for (const [hash, entry] of map) {
|
||||
if ((typeof entry === "number" ? entry : entry.expiry) < Date.now()) {
|
||||
map.delete(hash);
|
||||
}
|
||||
}
|
||||
};
|
||||
const MAX_NOTE = 120;
|
||||
const RECOVERY_TOKEN_MS = 30 * 60 * 1000;
|
||||
const recoveryHash = token => crypto.createHash("sha256").update(token).digest("hex");
|
||||
@@ -63,6 +90,20 @@ const failuresByAddress = limits.limiter(config.failedLoginsPerTenMinutes, TEN_M
|
||||
const WRONG_PASSWORDS_ALLOWED = 5;
|
||||
const wrongPasswords = limits.limiter(WRONG_PASSWORDS_ALLOWED, TEN_MINUTES_MS);
|
||||
const recoveryRequests = limits.limiter(5, TEN_MINUTES_MS);
|
||||
// recovery mail sent for one account, from any address: a few an hour.
|
||||
const recoveryMailsPerAccount = limits.limiter(3, 3600000);
|
||||
// a 2FA reset by email waits this long after a password reset by email, so
|
||||
// that someone who has only the mailbox cannot do one after the other.
|
||||
const EMAIL_RESET_GAP_MS = 7 * 24 * 3600000;
|
||||
// why a 2FA reset by email cannot be done for this account now, or null.
|
||||
// it also needs the account's password (recover/complete). staff ask the
|
||||
// admin (lib/panel.js), whose 2FA reset ends their role's use until they
|
||||
// turn it on again: a mailbox must not make someone staff.
|
||||
const twoStepResetProblem = account => roles.roleOf(account)
|
||||
? "Staff accounts cannot remove 2FA by email. Ask the admin."
|
||||
: account.emailPasswordResetAt && Date.now() - account.emailPasswordResetAt < EMAIL_RESET_GAP_MS
|
||||
? "2FA cannot be removed by email within 7 days of a password reset by email."
|
||||
: null;
|
||||
// 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
|
||||
@@ -168,6 +209,7 @@ const profile = (account, from) => {
|
||||
logins: account.numLogins || 0,
|
||||
playtime: account.playtime,
|
||||
playtimePublic: account.playtimePublic,
|
||||
chatStyle: chatStyles.normalize(account.chatStyle),
|
||||
animals: account.avatars.length,
|
||||
animalType: avatar ? avatar.type : null,
|
||||
items: account.items.length,
|
||||
@@ -428,6 +470,17 @@ const act = (account, body, req, from, res) => {
|
||||
account.playtimePublic = body.on === true;
|
||||
accounts.save(account);
|
||||
return {ok: account.playtimePublic ? "Others can see your playtime on your card." : "Your playtime is private."};
|
||||
// A player can choose every colour, opacity, animation and animation
|
||||
// speed. Validation is deliberately here as well as in the page: saved
|
||||
// state is not trusted just because it came from our own browser UI.
|
||||
case "chatStyle": {
|
||||
if (!chatStyles.valid(body.style)) {
|
||||
return {error: "Choose valid chat colours and animation settings."};
|
||||
}
|
||||
account.chatStyle = chatStyles.normalize(body.style);
|
||||
accounts.save(account);
|
||||
return {ok: "Chat style saved. Your next message will use it."};
|
||||
}
|
||||
// their Discord account, for their card in the game: it is linked by
|
||||
// signing in to Discord (GET /account/discord/link), and only taken off
|
||||
// here, with the booster badge it brought.
|
||||
@@ -515,6 +568,16 @@ const PAGE_HEADERS = {
|
||||
+ "form-action 'none'; frame-ancestors 'none'; base-uri 'none'"),
|
||||
};
|
||||
|
||||
// the web item giver shows den items in frames of public/item-preview.html,
|
||||
// which plays them with Ruffle (a Flash player, from jsDelivr).
|
||||
const ITEMS_PAGE_POLICY = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; connect-src 'self'; img-src 'self' data:; font-src 'self'; "
|
||||
+ "frame-src 'self'; form-action 'none'; frame-ancestors 'none'; base-uri 'none'";
|
||||
const RUFFLE = "https://cdn.jsdelivr.net/npm/@ruffle-rs/[email protected]/";
|
||||
const PREVIEW_POLICY = `default-src 'none'; script-src 'unsafe-inline' 'wasm-unsafe-eval' ${RUFFLE}; connect-src 'self' ${RUFFLE}; `
|
||||
+ "style-src 'unsafe-inline'; img-src 'self' data: blob:; media-src 'self' data: blob:; worker-src blob:; "
|
||||
+ "form-action 'none'; frame-ancestors 'self'; base-uri 'none'; sandbox allow-scripts";
|
||||
const artFetches = limits.limiter(600, 600000); // item pictures for the web item giver, per address in ten minutes
|
||||
|
||||
// A request that changes something must come from this server's own page.
|
||||
const sameOrigin = limits.originAllowed;
|
||||
|
||||
@@ -530,6 +593,41 @@ const handle = async (req, res, url, from, web) => {
|
||||
web.send(res, 200, captcha.withScriptVersion(await fs.promises.readFile(path.join(config.publicDir, "account.html"))), "text/html; charset=utf-8");
|
||||
return;
|
||||
}
|
||||
// the item giver on the web (public/items.html), with this page's sign-in.
|
||||
if (route === "GET /account/items") {
|
||||
res.setHeader("Content-Security-Policy", ITEMS_PAGE_POLICY);
|
||||
web.send(res, 200, await fs.promises.readFile(path.join(config.publicDir, "items.html")), "text/html; charset=utf-8");
|
||||
return;
|
||||
}
|
||||
// its den item previews (lib/itempreview.js): a page of their own in a
|
||||
// frame, sandboxed, as they run a Flash player from elsewhere (Ruffle).
|
||||
if (route === "GET /account/item-preview") {
|
||||
res.setHeader("Content-Security-Policy", PREVIEW_POLICY);
|
||||
res.setHeader("X-Frame-Options", "SAMEORIGIN");
|
||||
web.send(res, 200, await fs.promises.readFile(path.join(config.publicDir, "item-preview.html")), "text/html; charset=utf-8");
|
||||
return;
|
||||
}
|
||||
const art = /^GET \/account\/(item-preview\.swf|art\/(clothing|den)\/(\d{1,9}))$/.exec(route);
|
||||
if (art) {
|
||||
// fetched from the preview's sandbox, which has no origin of its own
|
||||
res.setHeader("Access-Control-Allow-Origin", "*");
|
||||
if (art[1] === "item-preview.swf") {
|
||||
web.send(res, 200, await fs.promises.readFile(path.join(config.publicDir, "item-preview.swf")), "application/x-shockwave-flash");
|
||||
return;
|
||||
}
|
||||
if (!artFetches.allow(from.address)) {
|
||||
reply(429, {error: "Too many at once. Try again in a minute."});
|
||||
return;
|
||||
}
|
||||
const found = art[2] === "den" ? await itemPreview.denArt(Number(art[3])) : await itemPreview.clothingIcon(Number(art[3]));
|
||||
if (!found) {
|
||||
reply(404, {error: "No picture."});
|
||||
return;
|
||||
}
|
||||
res.setHeader("Cache-Control", "public, max-age=3600");
|
||||
web.send(res, 200, found, art[2] === "den" ? "application/x-shockwave-flash" : "application/json");
|
||||
return;
|
||||
}
|
||||
if (route === "GET /account/recover") {
|
||||
web.send(res, 200, captcha.withScriptVersion(await fs.promises.readFile(path.join(config.publicDir, "recover.html"))), "text/html; charset=utf-8");
|
||||
return;
|
||||
@@ -551,7 +649,8 @@ const handle = async (req, res, url, from, web) => {
|
||||
const account = accounts.byName(String(body.username || ""));
|
||||
const email = String(body.email || "").trim().toLowerCase();
|
||||
const kind = body.kind === "twoStep" ? "twoStep" : "password";
|
||||
if (account && account.recoveryEmail && account.recoveryEmail === email && recoveryMail.available()) {
|
||||
if (account && account.recoveryEmail && account.recoveryEmail === email && recoveryMail.available()
|
||||
&& recoveryMailsPerAccount.allow(account.id)) {
|
||||
const token = crypto.randomBytes(32).toString("hex");
|
||||
account.recoveryTokens = (account.recoveryTokens || []).filter(entry => entry.expires > Date.now());
|
||||
account.recoveryTokens.push({hash: recoveryHash(token), kind, expires: Date.now() + RECOVERY_TOKEN_MS});
|
||||
@@ -571,7 +670,8 @@ const handle = async (req, res, url, from, web) => {
|
||||
const token = String(body.token || "");
|
||||
const account = [...accounts.all()].find(candidate => (candidate.recoveryTokens || []).some(entry => entry.hash === recoveryHash(token) && entry.expires > Date.now()));
|
||||
const entry = account && account.recoveryTokens.find(candidate => candidate.hash === recoveryHash(token) && candidate.expires > Date.now());
|
||||
reply(entry ? 200 : 400, entry ? {kind: entry.kind} : {error: "This recovery link is invalid or expired."});
|
||||
const refused = entry && entry.kind === "twoStep" ? twoStepResetProblem(account) : null;
|
||||
reply(entry && !refused ? 200 : 400, entry && !refused ? {kind: entry.kind} : {error: refused || "This recovery link is invalid or expired."});
|
||||
return;
|
||||
}
|
||||
case "POST /account/api/recover/complete": {
|
||||
@@ -588,10 +688,28 @@ const handle = async (req, res, url, from, web) => {
|
||||
reply(400, {error: problem === "weak_password" ? "That password is too easy to guess." : "Use 10+ characters with an uppercase letter, lowercase letter and digit."});
|
||||
return;
|
||||
}
|
||||
account.emailPasswordResetAt = Date.now();
|
||||
}
|
||||
else if (totp.isOn(account)) {
|
||||
totp.turnOff(account);
|
||||
accounts.revokeTokens(account);
|
||||
else {
|
||||
const refused = twoStepResetProblem(account);
|
||||
if (refused) {
|
||||
reply(400, {error: refused});
|
||||
return;
|
||||
}
|
||||
// the mailbox and the password: the link alone does not remove 2FA.
|
||||
if (!from.local && failuresByAddress.blocked(from.key)) {
|
||||
reply(429, {error: "Too many attempts. Try later."});
|
||||
return;
|
||||
}
|
||||
if (await accounts.authenticateAsync(account.username, body.password) !== account) {
|
||||
failuresByAddress.record(from.key);
|
||||
reply(401, {error: "Wrong password."});
|
||||
return;
|
||||
}
|
||||
if (totp.isOn(account)) {
|
||||
totp.turnOff(account);
|
||||
accounts.revokeTokens(account);
|
||||
}
|
||||
}
|
||||
account.recoveryTokens = [];
|
||||
accounts.save(account);
|
||||
@@ -659,6 +777,84 @@ const handle = async (req, res, url, from, web) => {
|
||||
reply(200, {ok: true});
|
||||
return;
|
||||
}
|
||||
// "Sign in with the Burrow client" (above), from the page: the nonce for
|
||||
// the burrow:// link, which this browser keeps as a cookie too.
|
||||
case "POST /account/api/client-start": {
|
||||
if (!from.local && !clientStartsByAddress.allow(from.key)) {
|
||||
reply(429, {error: "Too many attempts. Try later."});
|
||||
return;
|
||||
}
|
||||
dropExpired(clientStarts);
|
||||
if (clientStarts.size >= MAX_CLIENT_STARTS) {
|
||||
reply(503, {error: "Try again in a few minutes."});
|
||||
return;
|
||||
}
|
||||
const nonce = crypto.randomBytes(24).toString("hex");
|
||||
clientStarts.set(sha256(nonce), Date.now() + CLIENT_START_MS);
|
||||
res.setHeader("Set-Cookie", clientCookie(nonce, CLIENT_START_MS / 1000));
|
||||
reply(200, {nonce});
|
||||
return;
|
||||
}
|
||||
// ... from the client, with its login token (no Origin: the client's main
|
||||
// process): where to send the browser, which signs in there. a token is
|
||||
// only given after a whole sign-in, 2FA code included (lib/http.js).
|
||||
case "POST /account/api/client-ticket": {
|
||||
const nonce = typeof body.nonce === "string" && /^[0-9a-f]{48}$/.test(body.nonce) ? body.nonce : "";
|
||||
const started = nonce && clientStarts.get(sha256(nonce));
|
||||
if (!started || started < Date.now()) {
|
||||
reply(400, {error: "Start again from the account page."});
|
||||
return;
|
||||
}
|
||||
if (!from.local && failuresByAddress.blocked(from.key)) {
|
||||
reply(429, {error: "Too many attempts. Try later."});
|
||||
return;
|
||||
}
|
||||
const account = accounts.byToken(body.token);
|
||||
if (!account) {
|
||||
failuresByAddress.record(from.key);
|
||||
reply(401, {error: "Log in to Burrow again first."});
|
||||
return;
|
||||
}
|
||||
if (!clientTicketsByAccount.allow(account.id)) {
|
||||
reply(429, {error: "Too many attempts. Try later."});
|
||||
return;
|
||||
}
|
||||
dropExpired(clientTickets);
|
||||
const ticket = crypto.randomBytes(24).toString("hex");
|
||||
clientTickets.set(sha256(ticket), {id: account.id, nonce: sha256(nonce), expiry: Date.now() + CLIENT_TICKET_MS});
|
||||
reply(200, {url: new URL(`/account/client?ticket=${ticket}`, config.siteUrl).href, username: account.username});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// ... and the ticket, opened by the client in the browser: signed in when
|
||||
// this browser started it (its cookie). a ticket is good once, whatever
|
||||
// happens. the page that follows says how it went.
|
||||
if (route === "GET /account/client") {
|
||||
const given = String(url.searchParams.get("ticket") || "");
|
||||
const ticket = /^[0-9a-f]{48}$/.test(given) ? clientTickets.get(sha256(given)) : null;
|
||||
if (ticket) {
|
||||
clientTickets.delete(sha256(given));
|
||||
}
|
||||
const nonce = (new RegExp(`(?:^|;\\s*)${CLIENT_COOKIE}=([0-9a-f]{48})(?:;|$)`).exec(req.headers.cookie || "") || [])[1];
|
||||
const account = ticket && ticket.expiry > Date.now() ? accounts.byId(ticket.id) : null;
|
||||
const result = !account ? "expired" : !nonce || sha256(nonce) !== ticket.nonce ? "elsewhere" : "ok";
|
||||
const cookies = [clientCookie("", 0)];
|
||||
if (result === "ok") {
|
||||
clientStarts.delete(ticket.nonce);
|
||||
accounts.recordLogin(account, "web", from.address);
|
||||
accounts.save(account);
|
||||
signIn(res, account, cookies);
|
||||
}
|
||||
else {
|
||||
res.setHeader("Set-Cookie", cookies);
|
||||
}
|
||||
// a page of this site's own that goes on to the account page, rather than
|
||||
// a redirect: the (SameSite=Strict) cookie then surely goes with it.
|
||||
res.setHeader("Cache-Control", "no-store");
|
||||
web.send(res, 200, `<!doctype html><meta charset="utf-8"><meta http-equiv="refresh" content="0;url=/account?client=${result}"><title>Burrow</title>`,
|
||||
"text/html; charset=utf-8");
|
||||
return;
|
||||
}
|
||||
|
||||
// back from Discord (lib/discord.js): the state and the nonce must be the
|
||||
@@ -705,6 +901,28 @@ const handle = async (req, res, url, from, web) => {
|
||||
case "GET /account/api/me":
|
||||
reply(200, profile(account, from));
|
||||
return;
|
||||
// the item giver (above, and lib/admin.js): for the account signed in
|
||||
// here only, as the in-game one is for the one playing; not while banned.
|
||||
case "GET /account/api/giver":
|
||||
case "GET /account/api/colour":
|
||||
case "POST /account/api/give": {
|
||||
if (banFor(account, from) || account.nameRejected) {
|
||||
reply(403, {error: "Not now."});
|
||||
return;
|
||||
}
|
||||
if (route === "GET /account/api/colour") {
|
||||
const result = await admin.colourLookup(url.searchParams);
|
||||
reply(result.status, result.body);
|
||||
return;
|
||||
}
|
||||
if (req.method === "GET") {
|
||||
reply(200, await admin.searchFor(account, url.searchParams));
|
||||
return;
|
||||
}
|
||||
const result = admin.giveAs(account, body);
|
||||
reply(result.status, result.body);
|
||||
return;
|
||||
}
|
||||
// for the trade offer form: what the player could give, and what
|
||||
// another player has up for trade.
|
||||
case "GET /account/api/tradable": {
|
||||
|
||||
+47
-13
@@ -6,6 +6,7 @@ const defpacks = require("./defpacks.js");
|
||||
const buddyGames = require("./buddygames.js");
|
||||
const masterpieces = require("./masterpieces.js");
|
||||
const dens = require("./dens.js");
|
||||
const customItems = require("./customitems.js");
|
||||
const limits = require("./limits.js");
|
||||
const {activeAvatar, addClothing, sendClothingAdded} = require("./player.js");
|
||||
|
||||
@@ -16,10 +17,14 @@ const {activeAvatar, addClothing, sendClothingAdded} = require("./player.js");
|
||||
// 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:
|
||||
// lib/games.json is that table, as a recording of the official game has it
|
||||
// (its "mi" reply, made with tools/recorder.js): which class each id runs,
|
||||
// in a window or in the room's place, its user vars and its pictures. it
|
||||
// was first put back together from what still names the ids (arcade-machine
|
||||
// den items, the room files, GameCardPopup's names, the achievement defs),
|
||||
// which had some ids wrong: the print kits, the carnival games (run in the
|
||||
// room, not in its place), Brady's lab, and the buddy games, given ids of
|
||||
// other games' as nothing then named theirs. 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
|
||||
@@ -32,16 +37,16 @@ const {activeAvatar, addClothing, sendClothingAdded} = require("./player.js");
|
||||
// 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
|
||||
// card (lib/buddygames.js)
|
||||
// card the game's title picture on its "Play!" popup; a buddy game's
|
||||
// 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 GAME_AFTERGLOW_MS = 15000; // how long a game's room id is still taken after leaving it (leave)
|
||||
const IN_ROOM = 0;
|
||||
const MAX_GEMS_PER_AWARD = 5000;
|
||||
const MAX_MASTERY_PER_AWARD = 100;
|
||||
@@ -83,7 +88,16 @@ const START = {
|
||||
// which player is its own by the id (GemBreakerPlayer.init), and only
|
||||
// that one aims and shoots.
|
||||
seedAndPlayers: game => [serial(), game.players.length, ...game.players.flatMap(player => [player.id, 0])],
|
||||
// Spider Zapper and Wind Rider (SpiderShooterPlayer.init,
|
||||
// ParachuteGliderPlayer.init): each player's sfs id and where it starts.
|
||||
// given only the seed they had no players, none of them their own:
|
||||
// nothing could be shot, and nobody glided.
|
||||
seedAndCrosshairs: game => [serial(), game.players.length,
|
||||
...game.players.flatMap((player, at) => [player.id, CROSSHAIR_X + at * CROSSHAIR_GAP, CROSSHAIR_Y])],
|
||||
};
|
||||
const CROSSHAIR_X = 400;
|
||||
const CROSSHAIR_GAP = 100;
|
||||
const CROSSHAIR_Y = 300;
|
||||
|
||||
// the room games several players play together: "Multiplayer" on the
|
||||
// game's waiting list (MinigameManager.setupWaitListPopup), for players in
|
||||
@@ -121,8 +135,8 @@ module.exports = ({tell, leaveRoom, findOnline, blocks, watchers}) => {
|
||||
game.buddy ? 2 : MULTIPLAYER[game.swf] ? MULTIPLAYER[game.swf].max : 1,
|
||||
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.
|
||||
// the game card: the title picture on the "play" popup, 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
|
||||
@@ -234,6 +248,10 @@ module.exports = ({tell, leaveRoom, findOnline, blocks, watchers}) => {
|
||||
return;
|
||||
}
|
||||
session.game = null;
|
||||
// an in-room game may say it is done just before it hands over what it
|
||||
// made (the Juice Bar's smoothie, the Cocoa Hut's drink: an attachment,
|
||||
// lib/world.js pubMsg), labelled with the game's room
|
||||
session.lastGame = {roomId: game.roomId, until: Date.now() + GAME_AFTERGLOW_MS};
|
||||
if (session.bubbleOffOwed) {
|
||||
bubbleOff(session);
|
||||
}
|
||||
@@ -408,8 +426,12 @@ module.exports = ({tell, leaveRoom, findOnline, blocks, watchers}) => {
|
||||
// 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;
|
||||
// the game's own den items only: a custom item (and a player's own, which
|
||||
// is nobody else's to win) may be missing from the winner's game, whose
|
||||
// prize popup then threw (DenItem.initShopItem) and left the game frozen.
|
||||
const gameOwnDenItemIds = () => defpacks.denItemIds().filter(id => id < customItems.FIRST_ID);
|
||||
const clawPrizes = game => {
|
||||
plushies = plushies || defpacks.denItemIds().filter(id => /plush/i.test(defpacks.denItemDef(id).abbrName));
|
||||
plushies = plushies || gameOwnDenItemIds().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())) : [];
|
||||
@@ -420,7 +442,7 @@ module.exports = ({tell, leaveRoom, findOnline, blocks, watchers}) => {
|
||||
// machines aside.
|
||||
let phantomItems = null;
|
||||
const invasionPrizes = () => {
|
||||
phantomItems = phantomItems || defpacks.denItemIds().filter(id => /phantom/i.test(defpacks.denItemDef(id).abbrName)
|
||||
phantomItems = phantomItems || gameOwnDenItemIds().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);
|
||||
};
|
||||
@@ -550,7 +572,7 @@ module.exports = ({tell, leaveRoom, findOnline, blocks, watchers}) => {
|
||||
WindRider: {
|
||||
go() {},
|
||||
gw(session, game, params, reply) {
|
||||
const ids = defpacks.clothingIds();
|
||||
const ids = defpacks.clothingIds().filter(id => id < customItems.FIRST_ID);
|
||||
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);
|
||||
@@ -588,6 +610,18 @@ module.exports = ({tell, leaveRoom, findOnline, blocks, watchers}) => {
|
||||
},
|
||||
// the touch pool: the same again, with six prizes; which one is in the
|
||||
// first number.
|
||||
// Spider Zapper, after each wave: "wave" [1 if the player shot enough,
|
||||
// else 0] -> "wavesuccess" (the next wave) or "wavefail" (the end), and
|
||||
// "waveend" [spiders shot] -> "waveend" [spiders shot] (its results).
|
||||
// they went unanswered and the game waited after the first wave.
|
||||
SpiderShooter: {
|
||||
wave(session, game, [passed], reply) {
|
||||
reply(passed === "1" ? "wavesuccess" : "wavefail");
|
||||
},
|
||||
waveend(session, game, [shot], reply) {
|
||||
reply("waveend", /^\d{1,4}$/.test(String(shot)) ? Number(shot) : 0);
|
||||
},
|
||||
},
|
||||
TouchPool: {
|
||||
ts(session, game, params, reply) {
|
||||
session.prizeSerial = serial();
|
||||
|
||||
+105
-14
@@ -30,6 +30,7 @@ const sfs = require("./sfs.js");
|
||||
const support = require("./support.js");
|
||||
const totp = require("./totp.js");
|
||||
const world = require("./world.js");
|
||||
const {logText} = require("./logtext.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),
|
||||
@@ -66,7 +67,17 @@ const PROJECT_ROOT = path.resolve(__dirname, "..");
|
||||
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}
|
||||
// SHA-256 of a session token -> {id: account id, expiry: ms, code}. `code`:
|
||||
// a 2FA code was given for it (the password sign-in, and Discord's with a
|
||||
// code after it), which the Discord bot's commands need (discordCommandActor).
|
||||
const sessions = new Map();
|
||||
// a Discord sign-in waiting for its 2FA code: SHA-256 of the token in its
|
||||
// cookie -> {id, expiry, tries}. Discord says who it is; the code says it is
|
||||
// still them, as the password sign-in asks.
|
||||
const pendingDiscord = new Map();
|
||||
const PENDING_COOKIE = "ajc_mod_pending";
|
||||
const PENDING_MINUTES = 5;
|
||||
const PENDING_TRIES = 5;
|
||||
const addressSearched = new Map(); // moderator's account id -> the address they last searched for
|
||||
|
||||
const sha256 = text => crypto.createHash("sha256").update(text).digest("hex");
|
||||
@@ -127,7 +138,12 @@ const cookieHeader = (token, maxAgeSeconds) =>
|
||||
const discordCookie = (value, maxAgeSeconds) =>
|
||||
`${DISCORD_COOKIE}=${value}; Path=/; HttpOnly; SameSite=Lax; Max-Age=${maxAgeSeconds}${config.secureCookies ? "; Secure" : ""}`;
|
||||
|
||||
const beginSession = (account, res, address, detail = "") => {
|
||||
const pendingCookieHeader = (token, maxAgeSeconds) =>
|
||||
`${PENDING_COOKIE}=${token}; Path=/; HttpOnly; SameSite=Strict; Max-Age=${maxAgeSeconds}${config.secureCookies ? "; Secure" : ""}`;
|
||||
const pendingToken = req => (new RegExp(`(?:^|;\\s*)${PENDING_COOKIE}=([0-9a-f]{48})(?:;|$)`).exec(req.headers.cookie || "") || [])[1] || null;
|
||||
|
||||
// `extraCookies` go out with the session's own.
|
||||
const beginSession = (account, res, address, detail = "", code = true, extraCookies = []) => {
|
||||
accounts.recordLogin(account, "mod", address);
|
||||
accounts.save(account);
|
||||
for (const [hash, session] of sessions) {
|
||||
@@ -136,8 +152,8 @@ const beginSession = (account, res, address, detail = "") => {
|
||||
}
|
||||
}
|
||||
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));
|
||||
sessions.set(sha256(token), {id: account.id, expiry: Date.now() + SESSION_HOURS * 3600000, code});
|
||||
res.setHeader("Set-Cookie", [cookieHeader(token, SESSION_HOURS * 3600), ...extraCookies]);
|
||||
modlog.record(account.username, "signed in", "", detail);
|
||||
};
|
||||
|
||||
@@ -159,6 +175,11 @@ const forget = account => {
|
||||
sessions.delete(hash);
|
||||
}
|
||||
}
|
||||
for (const [hash, pending] of pendingDiscord) {
|
||||
if (pending.id === account.id) {
|
||||
pendingDiscord.delete(hash);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const playerRow = (account, playing) => {
|
||||
@@ -433,13 +454,22 @@ const handle = async (req, res, url, from, web) => {
|
||||
result.ok = false;
|
||||
result.error = "denied";
|
||||
}
|
||||
// Discord has said who this is; the panel opens once their 2FA code is
|
||||
// given too (POST /mod/api/discord/code), so a Discord account alone,
|
||||
// taken over or linked by someone else, opens nothing.
|
||||
const cookies = [discordCookie("", 0)];
|
||||
if (result.ok) {
|
||||
beginSession(result.account, res, from.address, "through Discord");
|
||||
console.log(`[mod] ${result.account.username} signed in with Discord from ${from.address}`);
|
||||
for (const [hash, pending] of pendingDiscord) {
|
||||
if (pending.expiry < Date.now()) {
|
||||
pendingDiscord.delete(hash);
|
||||
}
|
||||
}
|
||||
const token = crypto.randomBytes(24).toString("hex");
|
||||
pendingDiscord.set(sha256(token), {id: result.account.id, expiry: Date.now() + PENDING_MINUTES * 60000, tries: 0});
|
||||
cookies.push(pendingCookieHeader(token, PENDING_MINUTES * 60));
|
||||
}
|
||||
const sessionCookie = res.getHeader("Set-Cookie");
|
||||
res.setHeader("Set-Cookie", sessionCookie ? [sessionCookie, discordCookie("", 0)] : discordCookie("", 0));
|
||||
res.writeHead(302, {Location: `/dashboard/staff?discord=${result.ok ? "ok" : result.error}`});
|
||||
res.setHeader("Set-Cookie", cookies);
|
||||
res.writeHead(302, {Location: `/dashboard/staff?discord=${result.ok ? "code" : result.error}`});
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
@@ -503,12 +533,52 @@ const handle = async (req, res, url, from, web) => {
|
||||
}
|
||||
}
|
||||
const token = crypto.randomBytes(24).toString("hex");
|
||||
sessions.set(sha256(token), {id: account.id, expiry: Date.now() + SESSION_HOURS * 3600000});
|
||||
sessions.set(sha256(token), {id: account.id, expiry: Date.now() + SESSION_HOURS * 3600000, code: true});
|
||||
res.setHeader("Set-Cookie", cookieHeader(token, SESSION_HOURS * 3600));
|
||||
modlog.record(account.username, "signed in");
|
||||
reply(200, {ok: true, username: account.username});
|
||||
return;
|
||||
}
|
||||
// the second half of a Discord sign-in (GET /mod/discord/callback): the
|
||||
// account's 2FA code, from the browser Discord sent back here. a few
|
||||
// wrong codes and the sign-in is gone; it must start again at Discord.
|
||||
case "POST /mod/api/discord/code": {
|
||||
if (!from.local && failuresByAddress.blocked(from.key)) {
|
||||
reply(429, {error: "Too many attempts. Try later."});
|
||||
return;
|
||||
}
|
||||
const token = pendingToken(req);
|
||||
const hash = token ? sha256(token) : null;
|
||||
const pending = hash ? pendingDiscord.get(hash) : null;
|
||||
const account = pending && pending.expiry > Date.now() ? accounts.byId(pending.id) : null;
|
||||
if (!account || !mayModerate(account)) {
|
||||
if (hash) {
|
||||
pendingDiscord.delete(hash);
|
||||
}
|
||||
res.setHeader("Set-Cookie", pendingCookieHeader("", 0));
|
||||
reply(401, {error: "The Discord sign-in expired. Sign in with Discord again.", expired: true});
|
||||
return;
|
||||
}
|
||||
if (!totp.verify(account, String(body.code || ""))) {
|
||||
failuresByAddress.record(from.key);
|
||||
accounts.recordLogin(account, "mod", from.address, false);
|
||||
accounts.save(account);
|
||||
pending.tries++;
|
||||
if (pending.tries >= PENDING_TRIES) {
|
||||
pendingDiscord.delete(hash);
|
||||
res.setHeader("Set-Cookie", pendingCookieHeader("", 0));
|
||||
reply(401, {error: "Too many wrong codes. Sign in with Discord again.", expired: true});
|
||||
return;
|
||||
}
|
||||
reply(401, {error: "Wrong code."});
|
||||
return;
|
||||
}
|
||||
pendingDiscord.delete(hash);
|
||||
beginSession(account, res, from.address, "through Discord", true, [pendingCookieHeader("", 0)]);
|
||||
console.log(`[mod] ${logText(account.username)} signed in with Discord and a code from ${logText(from.address)}`);
|
||||
reply(200, {ok: true, username: account.username});
|
||||
return;
|
||||
}
|
||||
// signed in through the game instead: a client the moderator is playing
|
||||
// in hands over the game's login token, so they need not type their
|
||||
// password and a code again. taken only for active staff with 2FA on
|
||||
@@ -547,7 +617,8 @@ const handle = async (req, res, url, from, web) => {
|
||||
}
|
||||
}
|
||||
const cookie = crypto.randomBytes(24).toString("hex");
|
||||
sessions.set(sha256(cookie), {id: account.id, expiry: Date.now() + SESSION_HOURS * 3600000});
|
||||
// no code given here, so not one the Discord bot's commands count
|
||||
sessions.set(sha256(cookie), {id: account.id, expiry: Date.now() + SESSION_HOURS * 3600000, code: false});
|
||||
res.setHeader("Set-Cookie", cookieHeader(cookie, SESSION_HOURS * 3600));
|
||||
modlog.record(account.username, "signed in", "", "through the game");
|
||||
reply(200, {ok: true, username: account.username});
|
||||
@@ -1089,13 +1160,33 @@ const moderators = () => accounts.all().filter(account => roles.roleOf(account))
|
||||
// linked to one Burrow account. From there these methods use the same role,
|
||||
// rank, permission and action checks as POST /mod/api/act, and log every
|
||||
// successful change under the staff member's normal Burrow username.
|
||||
// whose Discord this is: the active staff member it is linked to, or null.
|
||||
// it says who someone is (the bot leaves staff alone), not that they may act.
|
||||
const discordActor = discordId => {
|
||||
const account = accounts.all().find(candidate => candidate.discordId === String(discordId));
|
||||
return mayModerate(account) ? account : null;
|
||||
};
|
||||
|
||||
// who may use the bot's commands: the staff member above, while they are
|
||||
// signed in to the panel with a code (a session above with `code`). a
|
||||
// Discord account alone is not them, and a new password, signing out
|
||||
// everywhere or 2FA turned off end those sessions (forget), and the bot's
|
||||
// use with them.
|
||||
const discordCommandActor = discordId => {
|
||||
const account = discordActor(discordId);
|
||||
if (!account) {
|
||||
return null;
|
||||
}
|
||||
for (const session of sessions.values()) {
|
||||
if (session.id === account.id && session.code && session.expiry > Date.now()) {
|
||||
return account;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const discordError = (actor, permission) => !actor
|
||||
? {error: "Link this Discord account to an active Burrow staff account first."}
|
||||
? {error: "Link this Discord account to your active Burrow staff account, then sign in to the staff dashboard with your 2FA code. Discord commands work while that sign-in lasts (12 hours)."}
|
||||
: !roles.can(actor, permission) ? {error: "Your Burrow role cannot do that."} : null;
|
||||
|
||||
const discordStatus = actor => {
|
||||
@@ -1153,7 +1244,7 @@ const discordHandleReport = (actor, id) => {
|
||||
|
||||
const discordAct = (actor, username, body) => {
|
||||
if (!actor) {
|
||||
return {error: "Link this Discord account to an active Burrow staff account first."};
|
||||
return discordError(null);
|
||||
}
|
||||
const target = accounts.byName(String(username || "").trim());
|
||||
if (!target) {
|
||||
@@ -1166,7 +1257,7 @@ const discordAct = (actor, username, body) => {
|
||||
return result;
|
||||
};
|
||||
|
||||
const discordBot = {actor: discordActor, authorize: discordError, status: discordStatus, player: discordPlayer, reports: discordReports,
|
||||
const discordBot = {actor: discordActor, commandActor: discordCommandActor, authorize: discordError, status: discordStatus, player: discordPlayer, reports: discordReports,
|
||||
staff: discordStaff, announce: discordAnnounce, handleReport: discordHandleReport, act: discordAct};
|
||||
|
||||
module.exports = {handle, forget, moderators, signedInAs, itemRoutes, reviewRoutes, discordBot};
|
||||
@@ -0,0 +1 @@
|
||||
{"10":{"type":1033,"count":141,"entries":["9329","0","9326","0","9332","0","9330","0","9331","0","9327","0","9328","0","9167","0","9170","0","9172","0","9174","0","9175","0","9176","0","9013","0","9014","0","9015","0","9016","0","9017","0","4452","0","2702","0","4451","0","2706","0","4453","0","2762","0","2711","0","2716","0","2715","0","2723","0","2697","0","2717","0","4478","0","1250","0","1251","0","1354","0","1426","0","1627","0","5738","0","346","0","86","0","124","0","118","0","2805","0","2806","0","2807","0","2808","0","2809","0","2810","0","2811","0","2812","0","2813","0","2814","0","2815","0","2816","0","2817","0","2818","0","2819","0","2820","0","2821","0","2822","0","2823","0","2824","0","2825","0","2826","0","2827","0","2828","0","1","0","4547","0","4542","0","4544","0","4549","0","4540","0","4548","0","4538","0","4539","0","4541","0","4543","0","4545","0","4546","0","2708","0","4470","0","356","0","5077","0","5078","0","5079","0","2705","0","4457","0","4465","0","2703","0","2709","0","5092","0","5093","0","5094","0","5095","0","4856","0","2712","0","2713","0","2714","0","4477","0","6130","0","6138","0","4777","0","4778","0","4779","0","4780","0","4855","0","5980","0","5981","0","4435","0","4946","0","4460","0","4461","0","4462","0","2707","0","4454","0","5088","0","5089","0","5090","0","5091","0","4455","0","2700","0","1188","0","2704","0","4459","0","4467","0","4468","0","4469","0","4393","0","5073","0","5074","0","5075","0","5076","0","4410","0","5084","0","5085","0","5086","0","5087","0","4466","0","5080","0","5081","0","5082","0","5083","0"]},"16":{"type":1023,"count":50,"entries":["551","552","553","554","555","556","557","564","558","569","559","1831","573","560","578","561","576","562","563","579","565","1841","568","574","566","1845","567","570","577","575","1830","571","1844","1826","572","1835","1839","1832","1843","1829","1827","1842","1828","1846","1838","1833","1840","1836","1837","1834"]},"44":{"type":1033,"count":35,"entries":["13","0","11","0","2889","0","2896","0","1602","0","2886","0","1604","0","12","0","2877","0","2885","0","1603","0","2894","0","10","0","2899","0","2891","0","2876","0","376","0","2878","0","2879","0","2880","0","2881","0","2882","0","2884","0","2888","0","2898","0","2887","0","2890","0","377","0","2892","0","2893","0","2895","0","2900","0","378","0","2901","0","2902","0"]},"53":{"type":1033,"count":14,"entries":["1389","1603","1545","1600","1595","1601","1265","1604","1470","1599","1232","1790","2279","3726","2015","0","7061","18253","1185","912","1192","1571","1186","913","1187","914","6189","0"],"note":"not recorded: the Journey Book's pages, found among the media files by their jb_title parts, and each land's name"},"54":{"type":1035,"count":160,"entries":["634","7044","32198","32199","10","459","0","635","7045","32200","32201","10","459","1","636","7046","32202","32203","10","459","2","637","7047","32204","32205","10","459","3","638","7048","32206","32207","10","459","4","639","7049","32208","32209","10","459","5","640","7050","32210","32211","10","459","6","641","7051","32212","32213","10","459","7","642","7052","32214","32215","10","459","8","643","7053","32216","32217","10","459","9","606","6667","31309","31310","14","457","0","607","6666","31311","31312","14","457","1","608","6668","31313","31314","14","457","2","609","6670","31303","31304","14","457","3","610","6665","31307","31308","14","457","4","611","6669","31305","31306","14","457","5","578","6180","30096","30097","14","456","11","577","6181","30094","30095","14","456","10","576","6187","30092","30093","14","456","9","575","6186","30090","30091","14","456","8","574","6179","30088","30089","14","456","7","573","6178","30086","30087","14","456","6","572","6177","30084","30085","14","456","5","571","6176","30082","30083","14","456","4","570","6183","30080","30081","14","456","3","569","6182","30078","30079","14","456","2","568","6185","30076","30077","14","456","1","567","6184","30074","30075","14","456","0","140","775","812","848","10","289","0","141","777","814","850","10","289","1","142","780","817","853","10","289","2","143","125","808","844","10","289","3","144","776","813","849","10","289","4","145","772","809","845","10","289","5","146","774","811","847","10","289","6","147","778","815","851","10","289","7","148","781","818","854","10","289","8","149","779","816","852","10","289","9","150","773","810","846","10","289","10","151","815","832","868","10","291","0","152","821","840","876","10","291","1","153","817","834","871","10","291","2","154","824","843","883","10","291","3","155","820","839","875","10","291","4","156","819","838","873","10","291","5","157","818","835","872","10","291","6","158","822","841","879","10","291","7","159","823","842","880","10","291","8","160","816","833","869","10","291","9","161","784","821","857","10","290","0","162","786","823","859","10","290","1","163","813","830","866","10","290","2","164","788","825","861","10","290","3","165","783","820","856","10","Line truncated
|
||||
+109
-10
@@ -32,6 +32,7 @@ const support = require("./support.js");
|
||||
const totp = require("./totp.js");
|
||||
const manage = require("./manage.js");
|
||||
const world = require("./world.js");
|
||||
const codes = require("./codes.js");
|
||||
const {activeAvatar} = require("./player.js");
|
||||
|
||||
// the admin panel at /admin: the only place the server is administered from.
|
||||
@@ -92,6 +93,11 @@ const passwordAcceptable = password =>
|
||||
typeof password === "string" && password.length >= MIN_PASSWORD_LENGTH && password.length <= MAX_PASSWORD_LENGTH;
|
||||
|
||||
const load = () => {
|
||||
// the number of worlds the admin chose last (world.setWorldCount)
|
||||
const worlds = accounts.setting(world.WORLD_COUNT_SETTING);
|
||||
if (worlds !== null) {
|
||||
world.setWorldCount(worlds, false);
|
||||
}
|
||||
if (!hasPassword()) {
|
||||
setupCode = crypto.randomBytes(5).toString("hex");
|
||||
console.log(`[admin] no admin password yet: open ${logText(config.baseUrl)}admin to choose one`
|
||||
@@ -119,7 +125,22 @@ const cookieHeader = (token, maxAgeSeconds) =>
|
||||
const discordCookie = (value, maxAgeSeconds) =>
|
||||
`${DISCORD_COOKIE}=${value}; Path=/; HttpOnly; SameSite=Lax; Max-Age=${maxAgeSeconds}${config.secureCookies ? "; Secure" : ""}`;
|
||||
|
||||
const signIn = res => {
|
||||
// a Discord sign-in waiting for the 2FA code of the account it is linked
|
||||
// to: SHA-256 of the token in its cookie -> {id, expiry, tries}. Discord
|
||||
// alone does not open this panel, as the password alone does not open the
|
||||
// moderator panel.
|
||||
const pendingDiscord = new Map();
|
||||
const PENDING_COOKIE = "ajc_admin_pending";
|
||||
const PENDING_MINUTES = 5;
|
||||
const PENDING_TRIES = 5;
|
||||
const pendingCookieHeader = (token, maxAgeSeconds) =>
|
||||
`${PENDING_COOKIE}=${token}; Path=/; HttpOnly; SameSite=Strict; Max-Age=${maxAgeSeconds}${config.secureCookies ? "; Secure" : ""}`;
|
||||
const pendingToken = req => (new RegExp(`(?:^|;\\s*)${PENDING_COOKIE}=([0-9a-f]{48})(?:;|$)`).exec(req.headers.cookie || "") || [])[1] || null;
|
||||
// may this account still sign in here with Discord?
|
||||
const discordAdmin = account => Boolean(account && account.adminDashboardAccess && account.discordId && totp.isOn(account) && !account.locked);
|
||||
|
||||
// `extraCookies` go out with the session's own.
|
||||
const signIn = (res, extraCookies = []) => {
|
||||
for (const [hash, expiry] of sessions) {
|
||||
if (expiry < Date.now()) {
|
||||
sessions.delete(hash);
|
||||
@@ -127,7 +148,7 @@ const signIn = res => {
|
||||
}
|
||||
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));
|
||||
res.setHeader("Set-Cookie", [cookieHeader(token, SESSION_HOURS * 3600), ...extraCookies]);
|
||||
};
|
||||
|
||||
const signOut = (req, res) => {
|
||||
@@ -299,6 +320,8 @@ const debugState = () => ({
|
||||
}).sort((a, b) => a.path.localeCompare(b.path)),
|
||||
everythingOnSale: sales.everythingOnSale(),
|
||||
theatreBrowser: theatreBrowserOn(),
|
||||
worlds: config.shards.length,
|
||||
maxWorlds: config.worldNames.length,
|
||||
});
|
||||
|
||||
const debugAct = body => {
|
||||
@@ -316,6 +339,11 @@ const debugAct = body => {
|
||||
? "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."};
|
||||
}
|
||||
if (body.action === "worlds") {
|
||||
const count = world.setWorldCount(body.count);
|
||||
return count ? {ok: `${count} ${count === 1 ? "world" : "worlds"}: ${config.shards.map(shard => shard.name).join(", ")}.`}
|
||||
: {error: "A number of worlds, please."};
|
||||
}
|
||||
if (body.action === "theatreBrowser") {
|
||||
accounts.setSetting(THEATRE_BROWSER_SETTING, body.on === true ? "on" : "off");
|
||||
return {ok: body.on === true
|
||||
@@ -692,13 +720,25 @@ const handle = async (req, res, url, from, web) => {
|
||||
const nonce = (new RegExp(`(?:^|;\\s*)${DISCORD_COOKIE}=([0-9a-f]{48})(?:;|$)`).exec(req.headers.cookie || "") || [])[1];
|
||||
const result = url.searchParams.get("error") ? {error: "cancelled"}
|
||||
: await discordLinks.finishAdmin(url.searchParams.get("state"), nonce, url.searchParams.get("code"));
|
||||
if (result.ok) {
|
||||
signIn(res);
|
||||
console.log(`[admin] ${logText(result.account.username)} signed in with Discord from ${logText(from.address)}`);
|
||||
// Discord has said who this is; the panel opens once that account's 2FA
|
||||
// code is given too (POST /admin/api/discord/code).
|
||||
if (result.ok && !discordAdmin(result.account)) {
|
||||
result.ok = false;
|
||||
result.error = totp.isOn(result.account) ? "denied" : "twostep";
|
||||
}
|
||||
const adminCookie = res.getHeader("Set-Cookie");
|
||||
res.setHeader("Set-Cookie", adminCookie ? [adminCookie, discordCookie("", 0)] : discordCookie("", 0));
|
||||
res.writeHead(302, {Location: `/dashboard/admin?discord=${result.ok ? "ok" : result.error}`});
|
||||
const cookies = [discordCookie("", 0)];
|
||||
if (result.ok) {
|
||||
for (const [hash, pending] of pendingDiscord) {
|
||||
if (pending.expiry < Date.now()) {
|
||||
pendingDiscord.delete(hash);
|
||||
}
|
||||
}
|
||||
const token = crypto.randomBytes(24).toString("hex");
|
||||
pendingDiscord.set(sha256(token), {id: result.account.id, expiry: Date.now() + PENDING_MINUTES * 60000, tries: 0});
|
||||
cookies.push(pendingCookieHeader(token, PENDING_MINUTES * 60));
|
||||
}
|
||||
res.setHeader("Set-Cookie", cookies);
|
||||
res.writeHead(302, {Location: `/dashboard/admin?discord=${result.ok ? "code" : result.error}`});
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
@@ -760,6 +800,44 @@ const handle = async (req, res, url, from, web) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// the second half of a Discord sign-in: the linked account's 2FA code.
|
||||
case "POST /admin/api/discord/code": {
|
||||
if (tooManyFailures(from.key)) {
|
||||
reply(429, {error: "Too many attempts. Try again in a few minutes."});
|
||||
return;
|
||||
}
|
||||
const token = pendingToken(req);
|
||||
const hash = token ? sha256(token) : null;
|
||||
const pending = hash ? pendingDiscord.get(hash) : null;
|
||||
const account = pending && pending.expiry > Date.now() ? accounts.byId(pending.id) : null;
|
||||
if (!discordAdmin(account)) {
|
||||
if (hash) {
|
||||
pendingDiscord.delete(hash);
|
||||
}
|
||||
res.setHeader("Set-Cookie", pendingCookieHeader("", 0));
|
||||
reply(401, {error: "The Discord sign-in expired. Sign in with Discord again.", expired: true});
|
||||
return;
|
||||
}
|
||||
if (!totp.verify(account, String(body.code || ""))) {
|
||||
recordFailure(from.key);
|
||||
console.log(`[admin] wrong 2FA code after Discord for ${logText(account.username)} from ${logText(from.address)}`);
|
||||
pending.tries++;
|
||||
if (pending.tries >= PENDING_TRIES) {
|
||||
pendingDiscord.delete(hash);
|
||||
res.setHeader("Set-Cookie", pendingCookieHeader("", 0));
|
||||
reply(401, {error: "Too many wrong codes. Sign in with Discord again.", expired: true});
|
||||
return;
|
||||
}
|
||||
reply(401, {error: "Wrong code."});
|
||||
return;
|
||||
}
|
||||
pendingDiscord.delete(hash);
|
||||
signIn(res, [pendingCookieHeader("", 0)]);
|
||||
console.log(`[admin] ${logText(account.username)} signed in with Discord and a code from ${logText(from.address)}`);
|
||||
reply(200, {ok: true});
|
||||
return;
|
||||
}
|
||||
|
||||
case "POST /admin/api/logout":
|
||||
signOut(req, res);
|
||||
reply(200, {ok: true});
|
||||
@@ -814,8 +892,12 @@ const handle = async (req, res, url, from, web) => {
|
||||
return;
|
||||
|
||||
case "POST /admin/api/discord/status": {
|
||||
const statusCard = discordBot.setStatusSettings({title: body.title, note: body.note});
|
||||
modlog.record("admin", "Discord public status card changed", "", `title: ${statusCard.title}`);
|
||||
const statusCard = discordBot.setStatusSettings({title: body.title, note: body.note, banner: body.banner});
|
||||
if (statusCard.error) {
|
||||
reply(400, {error: statusCard.error});
|
||||
return;
|
||||
}
|
||||
modlog.record("admin", "Discord public status card changed", "", `title: ${statusCard.title}, banner: ${statusCard.banner || "none"}`);
|
||||
reply(200, {ok: "Status-card text saved. Use Publish now to update Discord.", statusCard});
|
||||
return;
|
||||
}
|
||||
@@ -1043,6 +1125,23 @@ const handle = async (req, res, url, from, web) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// codes for the game's Redeem Code window (lib/codes.js), each giving
|
||||
// an item, gems or diamonds
|
||||
case "GET /admin/api/codes":
|
||||
reply(200, {codes: codes.list(), kinds: codes.KINDS});
|
||||
return;
|
||||
|
||||
case "POST /admin/api/codes": {
|
||||
const result = body.action === "remove"
|
||||
? (codes.remove(body.code) ? {ok: "Code deleted."} : {error: "No such code."})
|
||||
: codes.create(body);
|
||||
if (result.ok) {
|
||||
console.log(`[admin] redemption code ${logText(body.action === "remove" ? "deleted" : "made")}: ${logText(String(body.code || "").toUpperCase())}`);
|
||||
}
|
||||
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 || ""));
|
||||
|
||||
+7
-3
@@ -14,8 +14,9 @@ const defpacks = require("./defpacks.js");
|
||||
// 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";
|
||||
// what the room editor left in files nobody named ("default": the museum's
|
||||
// theatre).
|
||||
const UNNAMED = ["display name", "default"];
|
||||
// rooms whose file has no name and whose path does not spell it either.
|
||||
const NAMES = new Map([
|
||||
["jamaa_township.room_diamonds", "Diamond Shop"],
|
||||
@@ -24,6 +25,9 @@ const NAMES = new Map([
|
||||
["aussie.room_main", "Kimbara Outback"],
|
||||
["aussie.room_aushop", "Outback Imports"],
|
||||
["aussie.room_hos", "Medical Center"],
|
||||
["appondale.room_museumtheater", "Museum Theater"],
|
||||
["crystal_sands.room_tiertheater", "Tierney's Theater"],
|
||||
["lost_temple_of_zios.bb_theater", "Temple Theater"],
|
||||
]);
|
||||
const VOLUME_SHOP = 12; // ActorVolume.type: clicking it opens generic list `typeDefId`
|
||||
|
||||
@@ -37,7 +41,7 @@ const parse = 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() : "",
|
||||
name: typeof settings.name === "string" && !UNNAMED.includes(settings.name.trim().toLowerCase()) ? settings.name.trim() : "",
|
||||
shops: new Set(volumes.filter(volume => Number(volume.type) === VOLUME_SHOP).map(volume => Number(volume.typeDefId))),
|
||||
};
|
||||
};
|
||||
|
||||
+4
-4
@@ -141,19 +141,19 @@ const byDevice = query => {
|
||||
|
||||
// other accounts the same person may have: those that used one of its
|
||||
// computers (lib/devices.js), and those that signed in from one of its
|
||||
// addresses in the last 90 days. [{username, devices: [kind], weak,
|
||||
// addresses in the last 90 days. [{username, devices: [kind],
|
||||
// addresses: count, online, banned}], the likeliest first. the addresses
|
||||
// themselves are not given: moderators do not see them.
|
||||
const altsOf = account => {
|
||||
const found = new Map();
|
||||
const entry = username => {
|
||||
if (!found.has(username)) {
|
||||
found.set(username, {username, devices: [], weak: false, addresses: 0});
|
||||
found.set(username, {username, devices: [], addresses: 0});
|
||||
}
|
||||
return found.get(username);
|
||||
};
|
||||
for (const alt of devices.alts(account)) {
|
||||
Object.assign(entry(alt.username), {devices: alt.kinds, weak: alt.weak});
|
||||
Object.assign(entry(alt.username), {devices: alt.kinds});
|
||||
}
|
||||
const mine = new Set(account.logins.filter(login => login.ok && login.address && !limits.isLoopback(login.address)).map(login => login.address));
|
||||
if (mine.size) {
|
||||
@@ -170,7 +170,7 @@ const altsOf = account => {
|
||||
const other = accounts.byName(alt.username);
|
||||
return {...alt, online: Boolean(world.findOnline(alt.username)), banned: other ? world.moderation.banRemaining(other) : 0,
|
||||
deviceBanned: other ? devices.bannedId(other) !== 0 : false};
|
||||
}).sort((one, other) => Number(other.devices.length > 0 && !other.weak) - Number(one.devices.length > 0 && !one.weak)
|
||||
}).sort((one, other) => Number(other.devices.length > 0) - Number(one.devices.length > 0)
|
||||
|| other.devices.length - one.devices.length || other.addresses - one.addresses || one.username.localeCompare(other.username)).slice(0, 100);
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
|
||||
const zlib = require("zlib");
|
||||
const amf3 = require("./amf3.js");
|
||||
|
||||
// a room file of a seasonal theme comes from an older build (lib/http.js,
|
||||
// roomAsSeenBy in lib/world.js), and so do its clickable spots: a shop there
|
||||
// names the generic list it had then, which today's lists may have as
|
||||
// something else or as nothing, so one theme's shops worked and another's
|
||||
// did not. each spot the room has today too (by its name) is given today's
|
||||
// list, kind and message; what only the old room has stays as it was.
|
||||
|
||||
// the volume fields that say what a click does (RoomManagerWorld: type 1 a
|
||||
// minigame by typeDefId, 7 a message, 12 a generic list)
|
||||
const ACTION_FIELDS = ["type", "typeDefId", "message"];
|
||||
const MAX_KEPT = 40; // rooms remembered, made once each (files of up to a few MB)
|
||||
|
||||
const kept = new Map(); // old file's path -> the file with today's spots, or null for "as it was"
|
||||
|
||||
const volumes = room => (room && room.actors && Array.isArray(room.actors.ActorVolume) ? room.actors.ActorVolume : []);
|
||||
|
||||
const withTodaysSpots = (oldBody, currentBody) => {
|
||||
const old = amf3.decode(zlib.inflateSync(oldBody));
|
||||
const today = new Map(volumes(amf3.decode(zlib.inflateSync(currentBody))).filter(volume => volume && volume.name).map(volume => [volume.name, volume]));
|
||||
let changed = false;
|
||||
for (const volume of volumes(old)) {
|
||||
const now = volume && today.get(volume.name);
|
||||
if (now && ACTION_FIELDS.some(field => volume[field] !== now[field])) {
|
||||
for (const field of ACTION_FIELDS) {
|
||||
if (now[field] === undefined) {
|
||||
delete volume[field];
|
||||
}
|
||||
else {
|
||||
volume[field] = now[field];
|
||||
}
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed ? zlib.deflateSync(amf3.encode(old)) : oldBody;
|
||||
};
|
||||
|
||||
// `oldBody` with today's spots, `current` giving today's file (or null);
|
||||
// the old one as it was when that cannot be had or read.
|
||||
const fix = async (key, oldBody, current) => {
|
||||
if (kept.has(key)) {
|
||||
return kept.get(key) || oldBody;
|
||||
}
|
||||
let body = oldBody;
|
||||
try {
|
||||
const currentBody = await current();
|
||||
if (currentBody) {
|
||||
body = withTodaysSpots(oldBody, currentBody);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
console.log(`[themes] ${key}: ${err.message}`);
|
||||
body = oldBody;
|
||||
}
|
||||
if (kept.size >= MAX_KEPT) {
|
||||
kept.delete(kept.keys().next().value);
|
||||
}
|
||||
kept.set(key, body === oldBody ? null : body);
|
||||
return body;
|
||||
};
|
||||
|
||||
module.exports = {fix};
|
||||
+17
-7
@@ -15,7 +15,7 @@ const TYPE_CLOTHING = 0;
|
||||
const TYPE_DEN_ITEM = 1;
|
||||
const TYPE_PET = 3;
|
||||
|
||||
const MAX_TRADE_ITEMS = 50;
|
||||
const MAX_TRADE_ITEMS = 200; // on a trade list (the game sets no end to it; past this the rest were dropped)
|
||||
const MAX_PETS = 1000; // as in lib/pets.js
|
||||
|
||||
// "ti" request steps (first parameter from the client)
|
||||
@@ -53,8 +53,11 @@ module.exports = ({findOnline, blocks}) => {
|
||||
// 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));
|
||||
// one whose def is gone (a custom item deleted) is left out: the client
|
||||
// cannot make an item of it, and the list stopped there.
|
||||
const clothing = account.items.filter(item => listed(TYPE_CLOTHING).includes(item.inv) && defpacks.itemDef(item.def));
|
||||
const denItems = account.denItems.filter(item => listed(TYPE_DEN_ITEM).includes(item.inv) && masterpieces.itemApproved(item)
|
||||
&& defpacks.denItemDef(item.def));
|
||||
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]),
|
||||
@@ -71,8 +74,10 @@ module.exports = ({findOnline, blocks}) => {
|
||||
(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.
|
||||
// nor one whose def is gone.
|
||||
const find = (account, type, inv) => collectionOf(account, type)
|
||||
.find(entry => entry.inv === inv && (type !== TYPE_DEN_ITEM || masterpieces.itemApproved(entry)));
|
||||
.find(entry => entry.inv === inv && (type !== TYPE_DEN_ITEM || masterpieces.itemApproved(entry))
|
||||
&& (type === TYPE_CLOTHING ? Boolean(defpacks.itemDef(entry.def)) : type === TYPE_DEN_ITEM ? Boolean(defpacks.denItemDef(entry.def)) : true));
|
||||
|
||||
// the field layouts differ between the offer the owner is shown (no
|
||||
// inventory ids for clothing and den items) and the completed trade.
|
||||
@@ -129,6 +134,10 @@ module.exports = ({findOnline, blocks}) => {
|
||||
return coming === 0 || collectionOf(account, type).length + coming - gives.filter(item => item.type === type).length <= max;
|
||||
});
|
||||
|
||||
const endTrade = trade => {
|
||||
trade.requester.trade = trade.owner.trade = null;
|
||||
};
|
||||
|
||||
// ends the trade `session` is part of, telling the other side with `status`.
|
||||
const abandon = (session, status) => {
|
||||
const {trade} = session;
|
||||
@@ -136,7 +145,7 @@ module.exports = ({findOnline, blocks}) => {
|
||||
return;
|
||||
}
|
||||
const other = trade.requester === session ? trade.owner : trade.requester;
|
||||
trade.requester.trade = trade.owner.trade = null;
|
||||
endTrade(trade);
|
||||
other.sendXt("ti", -1, status, session.account.username, USERNAME_SHOWN);
|
||||
};
|
||||
|
||||
@@ -250,7 +259,7 @@ module.exports = ({findOnline, blocks}) => {
|
||||
return;
|
||||
}
|
||||
const {requester, owner, wantedType, wanted, offered} = trade;
|
||||
requester.trade = owner.trade = null;
|
||||
endTrade(trade);
|
||||
// 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))
|
||||
@@ -312,7 +321,8 @@ module.exports = ({findOnline, blocks}) => {
|
||||
sendTradeList(session, account);
|
||||
},
|
||||
|
||||
// ["1"/"0"]: busy flag while the trade window is open; nothing to answer.
|
||||
// ["1"/"0"]: busy flag while the trade window is open; nothing to
|
||||
// answer.
|
||||
tb() {},
|
||||
|
||||
ti(session, roomId, params) {
|
||||
|
||||
+3
-2
@@ -77,10 +77,11 @@ const whole = value => (Number.isInteger(Number(value)) ? Number(value) : 0);
|
||||
// the photo booth picture ("pb", PlayerWallGui): one level deeper than the
|
||||
// rest, {avatar: {id, color1.., eyes, pattern}, bgid, pet: {ts, lbits, ..} |
|
||||
// null, items: [{id, color}, ..]}. it was turned away as too deep, and the
|
||||
// owner's whole change with it: the photo never stayed.
|
||||
// owner's whole change with it: the photo never stayed. an animal wearing
|
||||
// nothing has no items list at all (null), which was turned away too.
|
||||
const MAX_PHOTO_ITEMS = 30;
|
||||
const photoParam = value => value === null || (typeof value === "object" && !Array.isArray(value) && Object.keys(value).length <= 6
|
||||
&& Object.entries(value).every(([key, part]) => (key === "items" ? Array.isArray(part) && part.length <= MAX_PHOTO_ITEMS && part.every(flat)
|
||||
&& Object.entries(value).every(([key, part]) => (key === "items" ? part === null || (Array.isArray(part) && part.length <= MAX_PHOTO_ITEMS && part.every(flat))
|
||||
: key === "avatar" || key === "pet" ? part === null || flat(part) : scalar(part))));
|
||||
|
||||
module.exports = ({blocks, findOnline}) => {
|
||||
|
||||
+238
-12
@@ -19,12 +19,16 @@ const badges = require("./badges.js");
|
||||
const bans = require("./bans.js");
|
||||
const devices = require("./devices.js");
|
||||
const chatlog = require("./chatlog.js");
|
||||
const support = require("./support.js");
|
||||
const codes = require("./codes.js");
|
||||
const chatFilter = require("./chatfilter.js");
|
||||
const chatSpam = require("./chatspam.js");
|
||||
const chatStyles = require("./chatstyles.js");
|
||||
const buddyModule = require("./buddies.js");
|
||||
const dens = require("./dens.js");
|
||||
const disguises = require("./disguises.js");
|
||||
const ecardModule = require("./ecards.js");
|
||||
const ecoModule = require("./eco.js");
|
||||
const epicDens = require("./epicdens.js");
|
||||
const itemHandlers = require("./items.js");
|
||||
const minigameModule = require("./minigames.js");
|
||||
@@ -48,6 +52,8 @@ const {CURRENCIES, DIAMOND_TYPES, activeAvatar, avatarById, activePet, equippedB
|
||||
|
||||
const GENERIC_LIST_AVATARS = 64;
|
||||
const GENERIC_LIST_NEWSPAPER = 627;
|
||||
const GENERIC_LIST_WHATS_NEW = 369;
|
||||
const WHATS_NEW_PAGES = 6;
|
||||
// the worlds' names (ServerSelector.getShardName): localization ids, the
|
||||
// game's own river names, world N being the Nth.
|
||||
const GENERIC_LIST_WORLD_NAMES = 16;
|
||||
@@ -127,13 +133,32 @@ const DEF_COMBINED_LIST = 1060;
|
||||
const DEF_DEN_ROOM = 1040;
|
||||
const DEF_CURRENCY_EXCHANGE = 1051;
|
||||
const DEF_DIAMOND = 1054;
|
||||
// generic lists as the official server answered them (gl), recorded with
|
||||
// tools/recorder.js: used where this server has none of its own. one was
|
||||
// not recorded and is made up the same way: the Journey Book's pages (53),
|
||||
// found among the media files (each has a "jb_title_<land>" part) with the
|
||||
// name of each land, which opens the book at the page of the land the
|
||||
// player is in (GuiManager.onJourneyBookMediaListReceived). likewise the
|
||||
// books of the Chamber of Knowledge (EBookChooser, lists 353-356) and their
|
||||
// pages, for the four whose pages could be found.
|
||||
const OFFICIAL_LISTS = require("./official-lists.json");
|
||||
const SHOP_LIST_TYPES = [DEF_ITEM, DEF_DEN_ITEM, DEF_DEN_ROOM, DEF_COMBINED_LIST, DEF_CURRENCY_EXCHANGE, DEF_DIAMOND];
|
||||
// a shop's title when its room gives it none (a shop in a land's main room,
|
||||
// or one opened from elsewhere): what it sells (strings in lib/defpacks.js).
|
||||
// with no title the shop window's banner was blank.
|
||||
// shops opened from a window rather than a room, by their list: the Eco Shop.
|
||||
const SHOP_LIST_TITLES = new Map([[778, 35727]]);
|
||||
const SHOP_KIND_TITLES = new Map([[DEF_ITEM, 9000010], [DEF_DEN_ITEM, 9000011], [DEF_DEN_ROOM, 9000012],
|
||||
[DEF_COMBINED_LIST, 9000013], [DEF_CURRENCY_EXCHANGE, 9000014], [DEF_DIAMOND, 9000015]]);
|
||||
// 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;
|
||||
// the egg the egg stands sell (pet.EggPetGuiManager, list 624): one at
|
||||
// random of these, the diamond shop's eggs. empty, the stand threw.
|
||||
const DIAMOND_EGG_LIST = 624;
|
||||
const LANG_ENG = 0;
|
||||
const IDLE_ANIM_LAND = 14;
|
||||
const IDLE_ANIM_OCEAN = 29;
|
||||
@@ -149,6 +174,9 @@ const TYPED_NAME = /^[A-Za-z0-9][A-Za-z0-9 '.-]{0,19}$/; // an animal's or pet's
|
||||
const nameFiltered = name => !String(name).includes("|") && Boolean(chatFilter.broken(String(name)));
|
||||
const MAX_BLOCKED = 1000; // from the account page; the game's own button has no limit
|
||||
const TYPED_CHAT_TYPES = ["0", "9"];
|
||||
// UserCommXtCommManager's safe chat phrase (1), emote (2), action (3),
|
||||
// attachment (4), slide (6) and pet action (7)
|
||||
const MOMENTARY_TYPES = ["1", "2", "3", "4", "6", "7"];
|
||||
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
|
||||
@@ -162,6 +190,10 @@ const LOGIN_OUTDATED = -12;
|
||||
|
||||
const THEME_PATH_PREFIX = "theme_"; // lib/http.js looks for this
|
||||
const chatLines = limits.limiter(config.chatLinesPerWindow, config.chatWindowMs);
|
||||
const codeTries = limits.limiter(10, 60000); // codes typed, per account a minute
|
||||
// emotes, actions, attachments: each goes to everyone in the room, so a
|
||||
// player pressing one over and over slowed a busy room for all of them.
|
||||
const roomActions = limits.limiter(config.roomActionsPerWindow, config.roomActionWindowMs);
|
||||
const online = new Map(); // lowercased username -> session
|
||||
const rooms = new Map(); // "path.name#shard" -> room
|
||||
const gameActivityListeners = new Set();
|
||||
@@ -214,7 +246,13 @@ const sees = (viewer, subject) => (!subject.invisible || roles.isActiveStaff(vie
|
||||
&& !(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));
|
||||
// the game's feedback windows by type (FeedbackManager.frameLabelForType;
|
||||
// the titles are the feedback defs' own), for the panel to say where a
|
||||
// message came from
|
||||
const FEEDBACK_KINDS = new Map([[1, "Theatre feedback"], [3, "Feedback"], [4, "Jamaa Journal feedback"], [5, "Feedback"],
|
||||
[11, "Theatre feedback"], [18, "Jammer Wall feedback"], [19, "Chat feedback"], [21, "Theatre feedback"], [22, "Theatre feedback"]]);
|
||||
const TYPING_EVERY_MS = 2000; // "typing" passed on at most this often per player (xty)
|
||||
const WORLD_COUNT_SETTING = "worldCount"; // how many worlds the admin chose (setWorldCount)
|
||||
|
||||
// tags ("@name") in chat and on Jammer Walls (xmn): the longest player's
|
||||
// name that the text after an "@" starts with, ending where a word does
|
||||
@@ -289,7 +327,7 @@ const loginParams = session => {
|
||||
playerWallSettings: account.wall.privacy,
|
||||
// not 0: PlayerWallManager only opens walls for accounts with them on.
|
||||
webWallStatus: 1,
|
||||
eCardPrivacySettings: account.ecardPrivacy,
|
||||
eCardPrivacySettings: ecards.privacyShown(account),
|
||||
// not empty: with neither address set, every fifth login opens a
|
||||
// "parent's email" window (GuiManager.showAjEmailBtn). accounts here
|
||||
// have no email.
|
||||
@@ -556,8 +594,10 @@ const sortStock = () => {
|
||||
// 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()]]);
|
||||
// oddDenItemIds in lib/defpacks.js. of the clothing only the Founder's Hat
|
||||
// (oddClothingIds' first): the rest, nameless pieces never finished, made the
|
||||
// Forgotten Archive a heap of broken items.
|
||||
const ODDITY_SHOPS = new Map([[396, () => defpacks.oddDenItemIds()], [666, () => defpacks.oddClothingIds().slice(0, 1)]]);
|
||||
// the items staff have made (lib/customitems.js) are sold there too, first.
|
||||
const CUSTOM_ITEM_SHOPS = new Map([[396, "den"], [666, "clothing"]]);
|
||||
const ticketStock = kind => sortStock()[kind];
|
||||
@@ -627,6 +667,10 @@ const sendFilter = session => {
|
||||
session.sendXt("xfl", -1, filter.chosen ? 1 : 0, filter.level, filter.mode, filter.words);
|
||||
};
|
||||
|
||||
// The in-game editor asks for this on demand too. It receives only canonical
|
||||
// values, so the Flash client never has to guess at a missing account field.
|
||||
const sendChatStyle = session => session.sendXt("xcs", -1, ...chatStyles.fields(session.account.chatStyle));
|
||||
|
||||
// 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
|
||||
@@ -653,6 +697,25 @@ const handlers = {
|
||||
sendFilter(session);
|
||||
},
|
||||
|
||||
// The Settings > Chat Bubble popup. An empty request just reloads the
|
||||
// saved setting; a complete twelve-field request replaces it. Older custom
|
||||
// clients remain accepted and receive a two-stop gradient automatically.
|
||||
xcs(session, roomId, params) {
|
||||
if (params.length === 0) {
|
||||
sendChatStyle(session);
|
||||
return;
|
||||
}
|
||||
if (![7, 10, 11, 12].includes(params.length)) return;
|
||||
const [background, accent, text, border, opacity, animation, speed, gradient = "linear", angle = 45, strength = 100, outline = 1,
|
||||
stops = `${background}:0;${accent}:100`] = params;
|
||||
const style = {background, accent, text, border, opacity: Number(opacity), animation, speed: Number(speed),
|
||||
gradient, angle: Number(angle), strength: Number(strength), outline: Number(outline), stops};
|
||||
if (!chatStyles.valid(style)) return;
|
||||
session.account.chatStyle = style;
|
||||
accounts.save(session.account);
|
||||
sendChatStyle(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.
|
||||
@@ -797,6 +860,9 @@ const handlers = {
|
||||
}
|
||||
let entries = [];
|
||||
let count;
|
||||
if (Number(listId) === eco.SHOP_LIST) {
|
||||
eco.shopOpened(session);
|
||||
}
|
||||
if (Number(listId) === GENERIC_LIST_AVATARS) {
|
||||
entries = defpacks.avatarTypes();
|
||||
}
|
||||
@@ -866,6 +932,12 @@ const handlers = {
|
||||
const real = shopStock.list(listId, type);
|
||||
entries = [...new Set([...defpacks.customShopIds(CUSTOM_ITEM_SHOPS.get(Number(listId))), ...(real ? real.entries : []), ...ODDITY_SHOPS.get(Number(listId))()])];
|
||||
}
|
||||
else if (Number(listId) === DIAMOND_EGG_LIST) {
|
||||
entries = defpacks.diamondIds().filter(id => {
|
||||
const def = defpacks.diamondDef(id);
|
||||
return def.type === DIAMOND_TYPES.pet && (defpacks.petDef(Number(def.refId)) || {}).isEgg === "1";
|
||||
});
|
||||
}
|
||||
else if (Number(listId) === DIAMOND_DEN_LIST) {
|
||||
entries = defpacks.diamondIds().filter(id => {
|
||||
const def = defpacks.diamondDef(id);
|
||||
@@ -898,9 +970,27 @@ const handlers = {
|
||||
count = defpacks.petIds().length;
|
||||
entries = defpacks.petIds().flatMap(id => [id, 1]);
|
||||
}
|
||||
// Jammer Central's "What's New" pictures (gui.BulletinBoard, list 369):
|
||||
// the newest pages of the Jamaa Journal. empty, the window waited on
|
||||
// its spinner.
|
||||
if (Number(listId) === GENERIC_LIST_WHATS_NEW && (count === undefined ? entries.length : count) === 0) {
|
||||
entries = defpacks.newestJournalPages(WHATS_NEW_PAGES).flatMap(id => [id, 0]);
|
||||
count = entries.length / 2;
|
||||
}
|
||||
// what the official server answered, where this one has nothing of its
|
||||
// own (lib/official-lists.json, from recordings of the official game:
|
||||
// the Journey Book's facts and pictures among them)
|
||||
if ((count === undefined ? entries.length : count) === 0 && Object.hasOwn(OFFICIAL_LISTS, String(Number(listId)))) {
|
||||
const official = OFFICIAL_LISTS[String(Number(listId))];
|
||||
if (official.type === type) {
|
||||
entries = official.entries;
|
||||
count = official.count;
|
||||
}
|
||||
}
|
||||
// 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;
|
||||
const title = SHOP_LIST_TYPES.includes(type)
|
||||
? (session.room && roomInfo.shopTitle(session.room.base, listId)) || SHOP_LIST_TITLES.get(Number(listId)) || SHOP_KIND_TITLES.get(type) : 0;
|
||||
session.sendXt("gl", -1, listId, type, title, 0, 0, 0, count === undefined ? entries.length : count, ...entries);
|
||||
},
|
||||
|
||||
@@ -922,6 +1012,10 @@ const handlers = {
|
||||
if (vars[id] === undefined && Object.keys(vars).length >= MAX_USER_VARS) {
|
||||
return;
|
||||
}
|
||||
// the eco plaques (lib/eco.js) are given, not set
|
||||
if (eco.userVar(session, id, value)) {
|
||||
return;
|
||||
}
|
||||
if (Number(id) === USER_VAR_HIDE_BLOCKED) {
|
||||
setHideBlocked(session, Number(value) === 1);
|
||||
}
|
||||
@@ -1039,6 +1133,60 @@ const handlers = {
|
||||
}
|
||||
},
|
||||
|
||||
// the game's feedback windows (the purple Help and Feedback buttons, the
|
||||
// orbs in rooms, the newspaper's and the theatre's: the patched
|
||||
// gui.FeedbackManager): xfb [the window's feedback type, the text]. it
|
||||
// goes to the staff panels' feedback (lib/support.js), named by where it
|
||||
// was written.
|
||||
xfb(session, roomId, [type, ...text]) {
|
||||
const where = FEEDBACK_KINDS.get(Number(type)) || "Feedback";
|
||||
const said = text.join("%").trim();
|
||||
if (!said) {
|
||||
return;
|
||||
}
|
||||
const result = support.sendFeedback(session.account, "feedback", `${where} (in ${session.room ? session.room.displayName : "the game"}): ${said}`);
|
||||
// the window has thanked them already; said only when it did not go
|
||||
if (!result.ok) {
|
||||
tell(session, result.error === "too_many" ? "You have sent a lot of feedback today. Try again tomorrow." : "That feedback could not be sent.");
|
||||
}
|
||||
},
|
||||
|
||||
// the game's Redeem Code window (GameRedemptionXtCommManager.requestRedeemCode):
|
||||
// [code, captcha question, answer], a code made in the admin panel
|
||||
// (lib/codes.js). the reply (CodeRedemptionPopup.onCodeRedeemResponse) is
|
||||
// "1" redeemed: the gift comes as a card from HQ, or for gems and diamonds
|
||||
// as a gift popup, whose card says so itself (lib/ecards.js deliver);
|
||||
// "-4" not now (used already, and an HQ popup says so); else "that code
|
||||
// didn't work". it was not answered at all, and the window spun.
|
||||
grc(session, roomId, [code]) {
|
||||
const {account} = session;
|
||||
if (!codeTries.allow(account.id)) {
|
||||
session.sendXt("grc", -1, "-4", "", 0);
|
||||
return;
|
||||
}
|
||||
const result = codes.redeem(account, code);
|
||||
if (result.error === "used" || result.error === "spent") {
|
||||
tell(session, result.error === "used" ? "You have used that code already." : "That code has been used up.");
|
||||
session.sendXt("grc", -1, "-4", "", 0);
|
||||
return;
|
||||
}
|
||||
if (result.error) {
|
||||
session.sendXt("grc", -1, "0", "", 0);
|
||||
return;
|
||||
}
|
||||
const problem = ecards.sendFromHq(account, `Code ${result.code} redeemed!`, result.gift);
|
||||
if (problem) {
|
||||
codes.unredeem(account, result.code);
|
||||
tell(session, `${problem}. The code can be used once there is room.`);
|
||||
session.sendXt("grc", -1, "-4", "", 0);
|
||||
return;
|
||||
}
|
||||
if (result.gift.kind === "clothing" || result.gift.kind === "den") {
|
||||
session.sendXt("grc", -1, "1", "", 0);
|
||||
tell(session, "Code redeemed! Your gift is in your Jam-A-Grams.");
|
||||
}
|
||||
},
|
||||
|
||||
// the patched client's tags (AJClient.resolveMentions): xmn [id, the text
|
||||
// after each "@", ...] -> "xmn" [.., .., id, then for each text: how many
|
||||
// of its characters are a player's name (0 for none), the name as it is
|
||||
@@ -1124,11 +1272,28 @@ const handlers = {
|
||||
|
||||
// VolumeSelector.handleRoomCountResponse: the head-count shown on each land
|
||||
// of the world map, as [count, (roomName, players)...].
|
||||
// the map's buddy counts (VolumeSelector.handleRoomCountResponse): how
|
||||
// many of the player's buddies are in each land of the player's world.
|
||||
// the map takes a land from the room's name (an ocean's from its room)
|
||||
// and keeps the last number it gets for it, so each land comes once,
|
||||
// its rooms added up. it counted everyone in every room of every world.
|
||||
// dens, parties and adventures are left out, whose names are nobody
|
||||
// else's business.
|
||||
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);
|
||||
const counts = new Map(); // a name the map reads its land from -> buddies there
|
||||
const world = session.worldId || config.shards[0].id;
|
||||
for (const other of online.values()) {
|
||||
const {room} = other;
|
||||
if (other === session || !room || room.denOwner || room.roomType !== 0 || worldOf(room.name) !== world
|
||||
|| !session.account.buddies.includes(other.account.username.toLowerCase()) || !sees(session, other)
|
||||
|| blocks.either(session.account, other.account)) {
|
||||
continue;
|
||||
}
|
||||
const [land, place = ""] = room.base.split(".");
|
||||
const key = land === "oceans" ? `oceans.${place}#${world}` : `${land}.room_main#${world}`;
|
||||
counts.set(key, (counts.get(key) || 0) + 1);
|
||||
}
|
||||
session.sendXt("rc", -1, counts.size, ...[...counts].flat());
|
||||
},
|
||||
|
||||
// RoomXtCommManager.sendRoomJoinRequestFull: [nameOrId, confirmLanguage, invisible, joinType]
|
||||
@@ -1342,6 +1507,7 @@ const pets = petModule(context);
|
||||
const parties = partyModule(context);
|
||||
const ecards = ecardModule(context);
|
||||
const walls = wallModule(context);
|
||||
const eco = ecoModule({others, ecards});
|
||||
const commands = commandModule(context);
|
||||
const minigames = minigameModule(context);
|
||||
const adventures = adventureModule(context);
|
||||
@@ -1351,9 +1517,22 @@ 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,
|
||||
parties.handlers, ecards.handlers, eco.handlers, walls.handlers, minigames.handlers, adventures.handlers, stubHandlers,
|
||||
playerItems.handlers({itemsTaken: (...args) => itemsTaken(...args)}));
|
||||
|
||||
// a den's owner, wherever they are, is told how many are in it: the HUD's
|
||||
// den count, with the doorbell when it goes up (DenXtCommManager.denRoomCount,
|
||||
// GuiManager.updateDenRoomCount: [count, 1 if they are among them, owner]).
|
||||
// someone they cannot see is not counted.
|
||||
const tellDenCount = room => {
|
||||
const owner = room && room.denOwner ? findOnline(room.denOwner.username) : null;
|
||||
if (!owner) {
|
||||
return;
|
||||
}
|
||||
const inside = [...room.sessions].filter(other => other === owner || sees(owner, other));
|
||||
owner.sendXt("drc", -1, inside.length, inside.includes(owner) ? 1 : 0, room.denOwner.username);
|
||||
};
|
||||
|
||||
const leaveRoom = session => {
|
||||
const {room} = session;
|
||||
if (!room) {
|
||||
@@ -1373,6 +1552,7 @@ const leaveRoom = session => {
|
||||
if (room.sessions.size === 0) {
|
||||
rooms.delete(room.name);
|
||||
}
|
||||
tellDenCount(room);
|
||||
};
|
||||
|
||||
// the Bio tab's words: the bio, under the time played when the player
|
||||
@@ -1545,6 +1725,7 @@ const enterRoom = (session, name, base, displayName, shardId, props = {}) => {
|
||||
if (props.denOwner && props.denOwner !== session.account) {
|
||||
noteDenVisit(props.denOwner, session.account);
|
||||
}
|
||||
tellDenCount(room);
|
||||
roomInfo.ensure(base);
|
||||
const avatar = activeAvatar(session.account);
|
||||
pets.walked(session.account);
|
||||
@@ -1802,7 +1983,9 @@ module.exports = {
|
||||
// embedded SWF labels outgoing user messages with the minigame's
|
||||
// temporary sub-room id. Accept that id as well so its attachment
|
||||
// reward can make the normal round trip back to the avatar.
|
||||
if (session.room && (session.room.id === msg.roomId || (session.game && session.game.roomId === Number(msg.roomId)))) {
|
||||
const fromGame = (session.game && session.game.roomId === Number(msg.roomId))
|
||||
|| (session.lastGame && session.lastGame.roomId === Number(msg.roomId) && Date.now() < session.lastGame.until);
|
||||
if (session.room && (session.room.id === msg.roomId || fromGame)) {
|
||||
// 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) {
|
||||
@@ -1864,6 +2047,10 @@ module.exports = {
|
||||
// local client deliberately does not draw it optimistically, unlike
|
||||
// typed chat and normal emotes.
|
||||
const attachmentEcho = fields[1] === "4";
|
||||
// A phrase from the phrase menus is drawn from the echo too (the
|
||||
// patched UserCommXtCommManager.sendAvatarSafeChat), so that it
|
||||
// comes in the sender's chat bubble style, as typed chat does.
|
||||
const phrase = fields[1] === "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"))) {
|
||||
@@ -1876,6 +2063,14 @@ module.exports = {
|
||||
session.sendXt("uc", session.room.id, session.id, -1, 5);
|
||||
return;
|
||||
}
|
||||
// the momentary ones (a phrase, an emote, an action, an attachment,
|
||||
// a slide, a pet's trick), past a few in a few seconds, reach
|
||||
// nobody: the sender has shown their own already. what sets a
|
||||
// state (a colour, see-through, a lasting emote) always goes, or
|
||||
// others would be left seeing the wrong one.
|
||||
if (MOMENTARY_TYPES.includes(fields[1]) && !limits.isTrustedLocal(session.address) && !roomActions.allow(session.account.id)) {
|
||||
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.
|
||||
@@ -1917,12 +2112,18 @@ module.exports = {
|
||||
// nobody hears a player they have blocked, and with chat switched
|
||||
// off nobody's typed lines arrive at all.
|
||||
// an invisible staff member's emotes and the like reach staff only.
|
||||
for (const recipient of (echo || attachmentEcho) ? session.room.sessions : others(session)) {
|
||||
// Typed chat always gets a third (stock "extra") field, followed by
|
||||
// its style. Keeping message and type at their original indexes is
|
||||
// what clears the local "..." bubble; carrying the style on the
|
||||
// same packet prevents it being lost or applied to a later line.
|
||||
const style = echo || phrase ? chatStyles.packet(session.account.chatStyle) : "";
|
||||
for (const recipient of (echo || attachmentEcho || phrase) ? session.room.sessions : others(session)) {
|
||||
if (session.invisible && recipient !== session && !roles.isActiveStaff(recipient.account)) {
|
||||
continue;
|
||||
}
|
||||
if (recipient === session || (!blocks.has(recipient.account, session.account) && (!echo || accounts.featureOn(recipient.account, "chat")))) {
|
||||
recipient.sendXt("uc", session.room.id, session.id, ...fields);
|
||||
recipient.sendXt("uc", session.room.id, session.id,
|
||||
...((echo || phrase) && style ? [fields[0], fields[1], fields[2] || "", style] : fields));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2121,6 +2322,31 @@ module.exports = {
|
||||
return true;
|
||||
},
|
||||
|
||||
// how many worlds there are (the admin panel), from 1 to 10, kept as a
|
||||
// setting. the list is changed where it is (config.shards: everything
|
||||
// reads it from there), so the world picker shows the new ones at once;
|
||||
// whoever is in a world that is gone is moved to the first.
|
||||
WORLD_COUNT_SETTING,
|
||||
setWorldCount(count, keep = true) {
|
||||
const wanted = Math.min(config.worldNames.length, Math.max(1, Math.floor(Number(count))));
|
||||
if (!Number.isFinite(wanted)) {
|
||||
return null;
|
||||
}
|
||||
config.shards.splice(0, config.shards.length, ...config.worldNames.slice(0, wanted).map((name, i) => ({id: i + 1, name})));
|
||||
if (keep) {
|
||||
accounts.setSetting(WORLD_COUNT_SETTING, String(wanted));
|
||||
}
|
||||
for (const session of online.values()) {
|
||||
if (session.worldId > wanted) {
|
||||
session.worldId = config.shards[0].id;
|
||||
if (session.room && worldOf(session.room.name) === 0 && /#\d+$/.test(session.room.name)) {
|
||||
sendHome(session);
|
||||
}
|
||||
}
|
||||
}
|
||||
return wanted;
|
||||
},
|
||||
|
||||
// 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.
|
||||
|
||||
+297
-7
@@ -94,6 +94,8 @@
|
||||
transition: background 0.12s, border-color 0.12s, color 0.12s;
|
||||
}
|
||||
button:hover { background: var(--raised); border-color: #555; }
|
||||
a.button { border: 1px solid var(--line); border-radius: 999px; padding: 7px 16px 8px; white-space: nowrap; text-decoration: none; }
|
||||
a.button:hover { background: var(--raised); border-color: #555; }
|
||||
button:disabled { opacity: 0.45; cursor: default; }
|
||||
button:focus-visible, a:focus-visible, input[type="checkbox"]:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
|
||||
button.primary { font-weight: 700; color: #000; background: var(--text); border-color: var(--text); }
|
||||
@@ -116,7 +118,7 @@
|
||||
line-height: 17px;
|
||||
text-align: center;
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
|
||||
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
|
||||
.wrap { max-width: 760px; margin: 0 auto; }
|
||||
label.check { display: flex; align-items: center; color: var(--text); font-size: 14px; cursor: pointer; }
|
||||
/* dark on white whatever the page: that is what a phone's camera reads. */
|
||||
@@ -175,6 +177,26 @@
|
||||
.ban-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
|
||||
.ban-head img { width: 44px; height: 44px; flex: none; }
|
||||
.ban-head h2 { margin: 0; font-size: 22px; }
|
||||
.chat-style-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
|
||||
.chat-style-grid input[type="color"] { width: 100%; height: 42px; padding: 3px; cursor: pointer; }
|
||||
.gradient-editor { margin: 14px 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
|
||||
.gradient-editor-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
|
||||
.gradient-stops { display: grid; gap: 8px; }
|
||||
.gradient-ramp { height: 22px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 999px; }
|
||||
.gradient-stop { display: grid; grid-template-columns: 50px minmax(100px, 1fr) 72px auto; align-items: center; gap: 8px; }
|
||||
.gradient-stop input[type="color"] { width: 50px; height: 36px; padding: 2px; cursor: pointer; }
|
||||
.gradient-stop input[type="range"] { margin: 0; }
|
||||
.gradient-stop output { color: var(--muted); font-size: 12px; text-align: right; }
|
||||
.chat-preview { min-height: 74px; display: grid; place-items: center; margin-top: 14px; padding: 12px 18px; border: 1px solid var(--line); border-radius: 18px; text-align: center; font-weight: 700; background: linear-gradient(120deg, #fff, #dfe8ff); color: #445559; }
|
||||
.chat-preview.pulse { animation: chatPulse 1.5s ease-in-out infinite alternate; }
|
||||
.chat-preview.shimmer { background-size: 250% 100%; animation: chatShimmer 1.5s linear infinite; }
|
||||
.chat-preview.flow { background-size: 220% 220%; animation: chatFlow 1.5s linear infinite alternate; }
|
||||
.chat-preview.rainbow { animation: chatRainbow 2s linear infinite; }
|
||||
@keyframes chatPulse { to { opacity: .55; } }
|
||||
@keyframes chatShimmer { to { background-position: 100% 0; } }
|
||||
@keyframes chatFlow { to { background-position: 100% 100%; } }
|
||||
@keyframes chatRainbow { to { filter: hue-rotate(360deg); } }
|
||||
@media (max-width: 440px) { .chat-style-grid { grid-template-columns: 1fr; } }
|
||||
#ban-section pre { margin: 0 0 12px; font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
|
||||
#ban-section h3 { margin: 18px 0 0; }
|
||||
</style>
|
||||
@@ -195,7 +217,7 @@
|
||||
<label class="check" style="margin-top:12px"><input id="remember-device" type="checkbox"> Trust this device for 30 days</label>
|
||||
</div>
|
||||
<div class="captcha" id="captcha"></div>
|
||||
<div class="row"><button class="primary" type="submit">Sign in</button></div>
|
||||
<div class="row"><button class="primary" type="submit">Sign in</button><button id="client-sign-in" type="button">Sign in with the Burrow client</button></div>
|
||||
</form>
|
||||
<p class="status" id="gate-status" role="status"></p>
|
||||
<p class="hint" style="margin:10px 0 0">No account yet? <a href="/register">Create one</a> · <a href="/account/recover">Forgot password or 2FA?</a></p>
|
||||
@@ -205,6 +227,7 @@
|
||||
<header>
|
||||
<img class="mark" src="/logo.png" alt="">
|
||||
<h1 id="title"></h1>
|
||||
<a class="button" id="item-giver" href="/account/items">Item giver</a>
|
||||
<button id="sign-out" type="button">Sign out</button>
|
||||
</header>
|
||||
|
||||
@@ -242,7 +265,11 @@
|
||||
|
||||
<section>
|
||||
<h2>Buddies</h2>
|
||||
<div id="buddies"></div>
|
||||
<!-- closed at first: a long list made the page slow to scroll -->
|
||||
<details id="buddies-box" hidden>
|
||||
<summary id="buddies-summary">Buddies</summary>
|
||||
<div id="buddies"></div>
|
||||
</details>
|
||||
<p class="hint" id="no-buddies" hidden>No buddies yet.</p>
|
||||
<p class="status" id="buddy-status" role="status"></p>
|
||||
</section>
|
||||
@@ -293,7 +320,10 @@
|
||||
|
||||
<section>
|
||||
<h2>Den visitors</h2>
|
||||
<div id="visits"></div>
|
||||
<details id="visits-box" hidden>
|
||||
<summary id="visits-summary">Visitors</summary>
|
||||
<div id="visits"></div>
|
||||
</details>
|
||||
<p class="hint" id="no-visits" hidden>No visitors yet.</p>
|
||||
</section>
|
||||
|
||||
@@ -354,6 +384,35 @@
|
||||
<p class="status" id="bio-status" role="status"></p>
|
||||
</section>
|
||||
|
||||
<section id="chat-bubble">
|
||||
<h2>Chat bubble</h2>
|
||||
<p>Choose how your spoken chat bubbles look for everyone using Burrow's current client.</p>
|
||||
<form id="chat-style-form">
|
||||
<div class="gradient-editor">
|
||||
<div class="gradient-editor-head"><b>Gradient colours</b><button id="chat-stop-add" type="button">Add colour</button></div>
|
||||
<div class="gradient-ramp" id="chat-ramp"></div>
|
||||
<div class="gradient-stops" id="chat-stops"></div>
|
||||
</div>
|
||||
<div class="chat-style-grid">
|
||||
<div hidden><input id="chat-background" type="color" value="#ffffff"></div>
|
||||
<div hidden><input id="chat-accent" type="color" value="#dfe8ff"></div>
|
||||
<div><label for="chat-text-colour">Text colour</label><input id="chat-text-colour" type="color" value="#445559"></div>
|
||||
<div><label for="chat-border">Border</label><input id="chat-border" type="color" value="#9aabb0"></div>
|
||||
<div><label for="chat-opacity">Opacity <span class="hint" id="chat-opacity-value"></span></label><input id="chat-opacity" type="range" min="25" max="100" value="75"></div>
|
||||
<div><label for="chat-gradient">Gradient</label><select id="chat-gradient"><option value="linear">Linear</option><option value="radial">Radial</option><option value="solid">Solid</option></select></div>
|
||||
<div><label for="chat-angle">Direction</label><select id="chat-angle"><option value="0">0°</option><option value="45">45°</option><option value="90">90°</option><option value="135">135°</option><option value="180">180°</option><option value="225">225°</option><option value="270">270°</option><option value="315">315°</option></select></div>
|
||||
<div><label for="chat-strength">Gradient strength <span class="hint" id="chat-strength-value"></span></label><input id="chat-strength" type="range" min="0" max="100" value="100"></div>
|
||||
<div><label for="chat-outline">Outline thickness <span class="hint" id="chat-outline-value"></span></label><input id="chat-outline" type="range" min="0" max="4" step="1" value="1"></div>
|
||||
<div><label for="chat-animation">Animation</label><select id="chat-animation"><option value="none">Still</option><option value="pulse">Pulse</option><option value="shimmer">Shimmer</option><option value="flow">Flow</option><option value="rainbow">Rainbow</option></select></div>
|
||||
<div><label for="chat-speed">Animation speed <span class="hint" id="chat-speed-value"></span></label><input id="chat-speed" type="range" min="40" max="300" value="100"></div>
|
||||
</div>
|
||||
<div class="chat-preview" id="chat-preview">Your chat bubble preview</div>
|
||||
<div class="row"><button id="chat-style-swap" type="button">Swap gradient</button><button id="chat-style-random" type="button">Random gradient</button></div>
|
||||
<div class="row"><button class="primary" type="submit">Save chat style</button><button id="chat-style-reset" type="button">Use original bubble</button></div>
|
||||
</form>
|
||||
<p class="status" id="chat-style-status" role="status"></p>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Playtime</h2>
|
||||
<p id="playtime-text"></p>
|
||||
@@ -504,8 +563,12 @@
|
||||
];
|
||||
const VIA = {game: "Game", launcher: "Client", web: "This page", mod: "Moderator panel"};
|
||||
const ANIMALS = {1: "Tiger", 4: "Wolf", 5: "Koala", 6: "Panda", 7: "Monkey", 8: "Bunny", 13: "Rhino", 18: "Seal", 24: "Penguin"};
|
||||
const DEFAULT_CHAT_STYLE = {background: "ffffff", accent: "dfe8ff", text: "445559", border: "9aabb0", opacity: 75,
|
||||
animation: "none", speed: 100, gradient: "linear", angle: 45, strength: 100, outline: 1,
|
||||
stops: "ffffff:0;dfe8ff:100"};
|
||||
|
||||
let account = null;
|
||||
let chatStops = [];
|
||||
let twoStepSetup = null; // {secret, uri} while two-step sign-in is being turned on
|
||||
let twoStepCodes = null; // the recovery codes, until the player says they kept them
|
||||
|
||||
@@ -527,6 +590,126 @@
|
||||
$(id).classList.toggle("bad", bad);
|
||||
};
|
||||
|
||||
const parseChatStops = style => {
|
||||
const parsed = String(style.stops || "").split(";").map(value => {
|
||||
const match = /^([0-9a-f]{6}):(100|[1-9]?\d)$/i.exec(value);
|
||||
return match ? {color: match[1].toLowerCase(), position: Number(match[2])} : null;
|
||||
});
|
||||
return parsed.length >= 2 && parsed.length <= 5 && parsed.every(Boolean)
|
||||
? parsed : [{color: style.background, position: 0}, {color: style.accent, position: 100}];
|
||||
};
|
||||
|
||||
const styleValue = () => {
|
||||
if (chatStops.length < 2) chatStops = parseChatStops(DEFAULT_CHAT_STYLE);
|
||||
chatStops.sort((one, two) => one.position - two.position);
|
||||
chatStops[0].position = 0;
|
||||
chatStops.at(-1).position = 100;
|
||||
const background = chatStops[0].color;
|
||||
const accent = chatStops.at(-1).color;
|
||||
$("chat-background").value = `#${background}`;
|
||||
$("chat-accent").value = `#${accent}`;
|
||||
return {
|
||||
background, accent,
|
||||
text: $("chat-text-colour").value.slice(1).toLowerCase(),
|
||||
border: $("chat-border").value.slice(1).toLowerCase(),
|
||||
opacity: Number($("chat-opacity").value),
|
||||
animation: $("chat-animation").value,
|
||||
speed: Number($("chat-speed").value),
|
||||
gradient: $("chat-gradient").value,
|
||||
angle: Number($("chat-angle").value),
|
||||
strength: Number($("chat-strength").value),
|
||||
outline: Number($("chat-outline").value),
|
||||
stops: chatStops.map(stop => `${stop.color}:${stop.position}`).join(";"),
|
||||
};
|
||||
};
|
||||
|
||||
const paintChatPreview = () => {
|
||||
const style = styleValue();
|
||||
const preview = $("chat-preview");
|
||||
preview.className = `chat-preview ${style.animation}`;
|
||||
const mix = (one, two, amount) => one.map((part, index) => Math.round(part + (two[index] - part) * amount));
|
||||
const rgb = hex => [0, 2, 4].map(at => parseInt(hex.slice(at, at + 2), 16));
|
||||
const stops = parseChatStops(style).map((stop, index) => {
|
||||
const colour = index ? mix(rgb(style.background), rgb(stop.color), style.strength / 100) : rgb(stop.color);
|
||||
return `#${colour.map(part => part.toString(16).padStart(2, "0")).join("")} ${stop.position}%`;
|
||||
}).join(", ");
|
||||
preview.style.background = style.gradient === "solid" ? `#${style.background}` : style.gradient === "radial"
|
||||
? `radial-gradient(circle, ${stops})`
|
||||
: `linear-gradient(${style.angle}deg, ${stops})`;
|
||||
preview.style.color = `#${style.text}`;
|
||||
preview.style.borderColor = `#${style.border}`;
|
||||
preview.style.borderWidth = `${style.outline}px`;
|
||||
preview.style.opacity = String(style.opacity / 100);
|
||||
preview.style.animationDuration = `${Math.max(.25, 1.5 * 100 / style.speed)}s`;
|
||||
$("chat-opacity-value").textContent = `${style.opacity}%`;
|
||||
$("chat-speed-value").textContent = `${style.speed}%`;
|
||||
$("chat-strength-value").textContent = `${style.strength}%`;
|
||||
$("chat-outline-value").textContent = `${style.outline}px`;
|
||||
};
|
||||
|
||||
const renderChatStops = () => {
|
||||
chatStops.sort((one, two) => one.position - two.position);
|
||||
const holder = $("chat-stops");
|
||||
holder.replaceChildren();
|
||||
$("chat-ramp").style.background = `linear-gradient(90deg, ${chatStops.map(stop => `#${stop.color} ${stop.position}%`).join(", ")})`;
|
||||
chatStops.forEach((stop, index) => {
|
||||
const row = el("div", undefined, "gradient-stop");
|
||||
const colour = document.createElement("input");
|
||||
colour.type = "color";
|
||||
colour.value = `#${stop.color}`;
|
||||
colour.setAttribute("aria-label", `Gradient colour ${index + 1}`);
|
||||
const position = document.createElement("input");
|
||||
position.type = "range";
|
||||
position.min = String(index ? chatStops[index - 1].position + 1 : 0);
|
||||
position.max = String(index < chatStops.length - 1 ? chatStops[index + 1].position - 1 : 100);
|
||||
position.value = String(stop.position);
|
||||
position.disabled = index === 0 || index === chatStops.length - 1;
|
||||
const value = document.createElement("output");
|
||||
value.textContent = index === 0 ? "Start" : index === chatStops.length - 1 ? "End" : `${stop.position}%`;
|
||||
const remove = document.createElement("button");
|
||||
remove.type = "button";
|
||||
remove.textContent = "Remove";
|
||||
remove.disabled = chatStops.length <= 2;
|
||||
colour.addEventListener("input", () => {
|
||||
stop.color = colour.value.slice(1).toLowerCase();
|
||||
renderChatStops();
|
||||
paintChatPreview();
|
||||
});
|
||||
position.addEventListener("input", () => {
|
||||
stop.position = Number(position.value);
|
||||
value.textContent = `${stop.position}%`;
|
||||
$("chat-ramp").style.background = `linear-gradient(90deg, ${chatStops.map(item => `#${item.color} ${item.position}%`).join(", ")})`;
|
||||
paintChatPreview();
|
||||
});
|
||||
remove.addEventListener("click", () => {
|
||||
chatStops.splice(index, 1);
|
||||
renderChatStops();
|
||||
paintChatPreview();
|
||||
});
|
||||
row.append(colour, position, value, remove);
|
||||
holder.append(row);
|
||||
});
|
||||
$("chat-stop-add").disabled = chatStops.length >= 5;
|
||||
};
|
||||
|
||||
const fillChatStyle = style => {
|
||||
style = {...DEFAULT_CHAT_STYLE, ...style};
|
||||
chatStops = parseChatStops(style);
|
||||
$("chat-background").value = `#${style.background}`;
|
||||
$("chat-accent").value = `#${style.accent}`;
|
||||
$("chat-text-colour").value = `#${style.text}`;
|
||||
$("chat-border").value = `#${style.border}`;
|
||||
$("chat-opacity").value = String(style.opacity);
|
||||
$("chat-animation").value = style.animation;
|
||||
$("chat-speed").value = String(style.speed);
|
||||
$("chat-gradient").value = style.gradient;
|
||||
$("chat-angle").value = String(style.angle);
|
||||
$("chat-strength").value = String(style.strength);
|
||||
$("chat-outline").value = String(style.outline);
|
||||
renderChatStops();
|
||||
paintChatPreview();
|
||||
};
|
||||
|
||||
const api = async (path, body) => {
|
||||
try {
|
||||
const response = await fetch(`/account/api/${path}`, body === undefined ? {} : {
|
||||
@@ -687,8 +870,8 @@
|
||||
// moving), else drawn into a PNG that fits, smaller until it is small
|
||||
// enough. any picture this browser can open will do (WebP, AVIF, BMP...).
|
||||
// null when it cannot be read at all.
|
||||
const PICTURE_SIDE = 512;
|
||||
const PICTURE_BYTES = 300 * 1024;
|
||||
const PICTURE_SIDE = 256;
|
||||
const PICTURE_BYTES = 100 * 1024;
|
||||
const preparePicture = async file => {
|
||||
const kept = ["image/png", "image/jpeg", "image/gif"].includes(file.type);
|
||||
let image = null;
|
||||
@@ -702,7 +885,7 @@
|
||||
image.close();
|
||||
return file;
|
||||
}
|
||||
for (const side of [PICTURE_SIDE, 384, 256, 128]) {
|
||||
for (const side of [PICTURE_SIDE, 192, 128, 96]) {
|
||||
const scale = Math.min(1, side / image.width, side / image.height);
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = Math.max(1, Math.round(image.width * scale));
|
||||
@@ -757,6 +940,9 @@
|
||||
}
|
||||
renderMyItems();
|
||||
$("lock-notice").hidden = !account.locked;
|
||||
if (!$("chat-style-form").contains(document.activeElement)) {
|
||||
fillChatStyle(account.chatStyle);
|
||||
}
|
||||
|
||||
const tiles = [
|
||||
[account.online ? "Playing now" : account.lastSeen ? when(account.lastSeen) : "Not played yet", "Last seen"],
|
||||
@@ -843,6 +1029,8 @@
|
||||
}));
|
||||
}
|
||||
$("no-buddies").hidden = account.buddyList.length > 0;
|
||||
$("buddies-box").hidden = account.buddyList.length === 0;
|
||||
$("buddies-summary").textContent = `Show ${account.buddyList.length.toLocaleString()} ${account.buddyList.length === 1 ? "buddy" : "buddies"}`;
|
||||
|
||||
$("blocked").replaceChildren(...account.blocked.map(name => {
|
||||
const row = el("div", undefined, "switch");
|
||||
@@ -888,6 +1076,8 @@
|
||||
return entry;
|
||||
}));
|
||||
$("no-visits").hidden = account.denVisits.length > 0;
|
||||
$("visits-box").hidden = account.denVisits.length === 0;
|
||||
$("visits-summary").textContent = `Show ${account.denVisits.length.toLocaleString()} ${account.denVisits.length === 1 ? "visit" : "visits"}`;
|
||||
|
||||
$("achievement-summary").textContent = `${account.achievements.earned} of ${account.achievements.of} earned.`;
|
||||
$("achievements").replaceChildren(...account.achievements.counted.map(counted => {
|
||||
@@ -944,9 +1134,71 @@
|
||||
}
|
||||
else {
|
||||
showGate(result.status === 0 ? result.data.error : "");
|
||||
if (Object.hasOwn(CLIENT_RESULTS, clientResult || "")) {
|
||||
setStatus("gate-status", CLIENT_RESULTS[clientResult], true);
|
||||
}
|
||||
// never by itself on the way back from it: a browser that would
|
||||
// not keep the sign-in would open tab after tab.
|
||||
else if (!clientResult && clientRemembered()) {
|
||||
signInWithClient();
|
||||
}
|
||||
}
|
||||
if (clientResult) {
|
||||
if (result.ok && clientResult === "ok") {
|
||||
try {
|
||||
localStorage.setItem(CLIENT_KEY, "1");
|
||||
}
|
||||
catch (err) {
|
||||
// not kept: the button stays the way in.
|
||||
}
|
||||
}
|
||||
history.replaceState(null, "", location.pathname + location.hash);
|
||||
}
|
||||
};
|
||||
|
||||
// "Sign in with the Burrow client" (lib/manage.js): the browser asks
|
||||
// whether to open Burrow, which opens this page again signed in (in a
|
||||
// new tab: this one follows). once that has worked in this browser, the
|
||||
// page asks by itself each time it opens signed out.
|
||||
const CLIENT_KEY = "burrow-client-sign-in";
|
||||
const CLIENT_RESULTS = {
|
||||
ok: "Burrow signed you in, but this browser did not keep it. Sign in with your password.",
|
||||
expired: "That sign-in took too long. Try again.",
|
||||
elsewhere: "Burrow opened the page in another browser than the one you started in. Start from this browser again, or sign in with your password.",
|
||||
};
|
||||
const clientResult = new URLSearchParams(location.search).get("client");
|
||||
const clientRemembered = () => {
|
||||
try {
|
||||
return localStorage.getItem(CLIENT_KEY) === "1";
|
||||
}
|
||||
catch (err) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
let clientWait = null;
|
||||
const signInWithClient = async () => {
|
||||
const started = await api("client-start", {});
|
||||
if (!started.ok) {
|
||||
setStatus("gate-status", started.data.error || "That did not work.", true);
|
||||
return;
|
||||
}
|
||||
setStatus("gate-status", "Opening Burrow… Allow it if your browser asks. Burrow must be logged in, or remember you.");
|
||||
location.href = `burrow://account?n=${started.data.nonce}`;
|
||||
clearInterval(clientWait);
|
||||
const until = Date.now() + 120000;
|
||||
clientWait = setInterval(async () => {
|
||||
if (account || Date.now() > until) {
|
||||
clearInterval(clientWait);
|
||||
return;
|
||||
}
|
||||
if ((await api("me")).ok) {
|
||||
clearInterval(clientWait);
|
||||
await load();
|
||||
}
|
||||
}, 2000);
|
||||
};
|
||||
$("client-sign-in").addEventListener("click", signInWithClient);
|
||||
|
||||
$("sign-in").addEventListener("submit", async event => {
|
||||
event.preventDefault();
|
||||
const answer = captchaPass ? undefined : await check.answer();
|
||||
@@ -1343,6 +1595,44 @@
|
||||
});
|
||||
$("bio-remove").addEventListener("click", () => act({action: "bio", text: ""}, "bio-status"));
|
||||
|
||||
["chat-background", "chat-accent", "chat-text-colour", "chat-border", "chat-opacity", "chat-gradient", "chat-angle", "chat-strength", "chat-outline", "chat-animation", "chat-speed"].forEach(id => {
|
||||
$(id).addEventListener("input", paintChatPreview);
|
||||
$(id).addEventListener("change", paintChatPreview);
|
||||
});
|
||||
$("chat-style-form").addEventListener("submit", async event => {
|
||||
event.preventDefault();
|
||||
await act({action: "chatStyle", style: styleValue()}, "chat-style-status");
|
||||
});
|
||||
$("chat-stop-add").addEventListener("click", () => {
|
||||
if (chatStops.length >= 5) return;
|
||||
let gapAt = 0;
|
||||
for (let index = 1; index < chatStops.length - 1; index++) {
|
||||
if (chatStops[index + 1].position - chatStops[index].position > chatStops[gapAt + 1].position - chatStops[gapAt].position) gapAt = index;
|
||||
}
|
||||
const before = chatStops[gapAt];
|
||||
const after = chatStops[gapAt + 1];
|
||||
const rgb = hex => [0, 2, 4].map(at => parseInt(hex.slice(at, at + 2), 16));
|
||||
const mixed = rgb(before.color).map((part, index) => Math.round((part + rgb(after.color)[index]) / 2).toString(16).padStart(2, "0")).join("");
|
||||
chatStops.splice(gapAt + 1, 0, {color: mixed, position: Math.round((before.position + after.position) / 2)});
|
||||
renderChatStops();
|
||||
paintChatPreview();
|
||||
});
|
||||
$("chat-style-swap").addEventListener("click", () => {
|
||||
chatStops = chatStops.slice().reverse().map(stop => ({color: stop.color, position: 100 - stop.position}));
|
||||
renderChatStops();
|
||||
paintChatPreview();
|
||||
});
|
||||
$("chat-style-random").addEventListener("click", () => {
|
||||
const randomColour = () => Math.floor(Math.random() * 0x1000000).toString(16).padStart(6, "0");
|
||||
chatStops.forEach(stop => { stop.color = randomColour(); });
|
||||
renderChatStops();
|
||||
paintChatPreview();
|
||||
});
|
||||
$("chat-style-reset").addEventListener("click", async () => {
|
||||
fillChatStyle(DEFAULT_CHAT_STYLE);
|
||||
await act({action: "chatStyle", style: DEFAULT_CHAT_STYLE}, "chat-style-status");
|
||||
});
|
||||
|
||||
// off to Discord's sign-in; it comes back to /account?discord=<how it went>
|
||||
$("discord-link").addEventListener("click", () => {
|
||||
location.href = "/account/discord/link";
|
||||
|
||||
+156
-6
@@ -392,6 +392,12 @@
|
||||
</div>
|
||||
<button class="primary" id="gate-button">Sign in</button>
|
||||
</form>
|
||||
<form id="discord-code-form" hidden>
|
||||
<p class="hint">Discord confirmed who you are. Enter that account's 2FA code to finish signing in.</p>
|
||||
<label for="discord-code">2FA code</label>
|
||||
<input id="discord-code" inputmode="numeric" autocomplete="one-time-code" maxlength="20" spellcheck="false" required>
|
||||
<button class="primary" id="discord-code-button">Finish signing in</button>
|
||||
</form>
|
||||
<button type="button" id="discord-sign-in" hidden>Sign in with Discord</button>
|
||||
<p class="hint" id="discord-gate-hint" hidden>Only Discord accounts explicitly allowed by the owner can use this.</p>
|
||||
<p class="status" id="gate-status" role="status"></p>
|
||||
@@ -490,6 +496,8 @@
|
||||
<input id="discord-status-title" maxlength="80" placeholder="Burrow status" aria-label="Discord public status-card title">
|
||||
<label for="discord-status-note">Status message</label>
|
||||
<textarea id="discord-status-note" rows="3" maxlength="500" placeholder="Optional message shown above the live player and moderation counts." aria-label="Discord public status-card message"></textarea>
|
||||
<label for="discord-status-banner">Banner image URL</label>
|
||||
<input id="discord-status-banner" type="url" maxlength="500" placeholder="https://… (leave blank for no banner)" aria-label="Discord public status-card banner image URL">
|
||||
<div class="send-row">
|
||||
<button class="primary" type="submit">Save status card</button>
|
||||
<button type="button" id="discord-status-publish">Publish now</button>
|
||||
@@ -1051,6 +1059,34 @@
|
||||
</div>
|
||||
<p class="status" id="announce-status" role="status"></p>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Redemption codes</h2>
|
||||
<p class="hint">For the game's Redeem Code window (in its settings). Each account may use a code once; "uses" is how many may use it in all, 0 for any number.</p>
|
||||
<form id="code-form">
|
||||
<div class="row">
|
||||
<input id="code-code" maxlength="32" placeholder="CODE" autocomplete="off" spellcheck="false" aria-label="Code" required style="text-transform:uppercase">
|
||||
<select id="code-kind" aria-label="What it gives">
|
||||
<option value="clothing">Clothing</option>
|
||||
<option value="den">Den item</option>
|
||||
<option value="gems">Gems</option>
|
||||
<option value="diamonds">Diamonds</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="row">
|
||||
<input id="code-item" type="number" min="1" placeholder="Item id" aria-label="Item id">
|
||||
<input id="code-color" placeholder="Colour (optional)" aria-label="Colour" autocomplete="off">
|
||||
<input id="code-amount" type="number" min="1" placeholder="Amount" aria-label="Amount" hidden>
|
||||
<input id="code-uses" type="number" min="0" value="0" aria-label="Uses in all" title="Uses in all, 0 for any number">
|
||||
<button class="primary" type="submit">Make</button>
|
||||
</div>
|
||||
</form>
|
||||
<p class="status" id="code-status" role="status"></p>
|
||||
<table>
|
||||
<thead><tr><th>Code</th><th>Gives</th><th>Used</th><th></th></tr></thead>
|
||||
<tbody id="codes"></tbody>
|
||||
</table>
|
||||
<div class="empty" id="no-codes" hidden>No codes yet.</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1091,6 +1127,16 @@
|
||||
<label class="check"><input id="debug-onsale" type="checkbox"> Everything on sale</label>
|
||||
<p class="status" id="debug-sale-status" role="status"></p>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Worlds</h2>
|
||||
<form id="debug-worlds-form" class="row">
|
||||
<label for="debug-worlds">How many worlds</label>
|
||||
<input id="debug-worlds" type="number" min="1" max="10" style="width:5em">
|
||||
<button type="submit">Set</button>
|
||||
</form>
|
||||
<p class="hint">Aldan, Congo, Draa and on. Takes effect at once; anyone in a world taken away is moved to Aldan.</p>
|
||||
<p class="status" id="debug-worlds-status" role="status"></p>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Theatre browser (experimental)</h2>
|
||||
<label class="check"><input id="debug-theatre-browser" type="checkbox"> Players may open a web browser on the theatre screen</label>
|
||||
@@ -1170,6 +1216,35 @@
|
||||
return {ok: response.ok, status: response.status, data};
|
||||
};
|
||||
|
||||
// the redemption codes (Messages): what each gives and how often it was used
|
||||
const renderCodes = list => {
|
||||
$("codes").replaceChildren(...list.map(code => {
|
||||
const row = el("tr");
|
||||
const gives = code.kind === "clothing" ? `Clothing ${code.item}${code.color !== null ? ` (colour ${code.color})` : ""}`
|
||||
: code.kind === "den" ? `Den item ${code.item}` : `${code.amount.toLocaleString()} ${code.kind}`;
|
||||
const button = el("button", "Delete");
|
||||
button.type = "button";
|
||||
button.addEventListener("click", async () => {
|
||||
const result = await api("codes", {action: "remove", code: code.code});
|
||||
setStatus($("code-status"), result.data.ok || result.data.error || "That did not work.", !result.ok);
|
||||
if (result.ok) {
|
||||
row.remove();
|
||||
}
|
||||
});
|
||||
const cell = el("td");
|
||||
cell.append(button);
|
||||
row.append(el("td", code.code), el("td", gives), el("td", code.uses ? `${code.used} of ${code.uses}` : String(code.used)), cell);
|
||||
return row;
|
||||
}));
|
||||
$("no-codes").hidden = list.length > 0;
|
||||
};
|
||||
const showCodeFields = () => {
|
||||
const item = ["clothing", "den"].includes($("code-kind").value);
|
||||
$("code-item").hidden = !item;
|
||||
$("code-color").hidden = $("code-kind").value !== "clothing";
|
||||
$("code-amount").hidden = item;
|
||||
};
|
||||
|
||||
const setStatus = (element, text, bad = false) => {
|
||||
element.textContent = text;
|
||||
element.classList.toggle("bad", bad);
|
||||
@@ -1259,6 +1334,38 @@
|
||||
location.href = "/dashboard/admin/discord/login";
|
||||
});
|
||||
|
||||
// after Discord: the linked account's 2FA code (POST discord/code)
|
||||
const discordGate = (codeStep, message) => {
|
||||
history.replaceState(null, "", location.pathname + location.hash);
|
||||
showGate(message);
|
||||
$("gate-form").hidden = codeStep;
|
||||
$("discord-code-form").hidden = !codeStep;
|
||||
if (codeStep) {
|
||||
$("discord-sign-in").textContent = "Start again with Discord";
|
||||
$("discord-code").focus();
|
||||
}
|
||||
};
|
||||
|
||||
$("discord-code-form").addEventListener("submit", async event => {
|
||||
event.preventDefault();
|
||||
$("discord-code-button").disabled = true;
|
||||
const result = await api("discord/code", {code: $("discord-code").value.trim()});
|
||||
$("discord-code-button").disabled = false;
|
||||
$("discord-code").value = "";
|
||||
if (result.ok) {
|
||||
$("discord-code-form").hidden = true;
|
||||
$("gate-form").hidden = false;
|
||||
state = {needsSetup: false, needsSetupCode: false, signedIn: true};
|
||||
showPanel();
|
||||
}
|
||||
else if (result.data.expired) {
|
||||
discordGate(false, result.data.error);
|
||||
}
|
||||
else {
|
||||
setStatus($("gate-status"), result.data.error || "That did not work.", true);
|
||||
}
|
||||
});
|
||||
|
||||
$("sign-out").addEventListener("click", async () => {
|
||||
await api("logout", {});
|
||||
state.signedIn = false;
|
||||
@@ -1328,10 +1435,11 @@
|
||||
? "Credentials and webhook secrets are intentionally never shown in this dashboard."
|
||||
: "Add the missing environment variables to the service that starts Burrow; dashboard settings cannot store bot secrets.";
|
||||
$("discord-bot-status").classList.toggle("bad", !configured || !data.connected);
|
||||
const editingStatusCard = ["discord-status-title", "discord-status-note"].includes(document.activeElement && document.activeElement.id);
|
||||
const editingStatusCard = ["discord-status-title", "discord-status-note", "discord-status-banner"].includes(document.activeElement && document.activeElement.id);
|
||||
if (!editingStatusCard) {
|
||||
$("discord-status-title").value = data.statusCard && data.statusCard.title || "Burrow status";
|
||||
$("discord-status-note").value = data.statusCard && data.statusCard.note || "";
|
||||
$("discord-status-banner").value = data.statusCard && data.statusCard.banner || "";
|
||||
}
|
||||
const editingRouting = document.activeElement && (document.activeElement.dataset.discordChannel || document.activeElement.id === "discord-github-repository");
|
||||
if (!editingRouting) {
|
||||
@@ -1444,12 +1552,13 @@
|
||||
event.preventDefault();
|
||||
const button = event.submitter;
|
||||
if (button) button.disabled = true;
|
||||
const result = await api("discord/status", {title: $("discord-status-title").value, note: $("discord-status-note").value});
|
||||
const result = await api("discord/status", {title: $("discord-status-title").value, note: $("discord-status-note").value, banner: $("discord-status-banner").value});
|
||||
if (button) button.disabled = false;
|
||||
setStatus($("discord-status-card-result"), said(result), !result.ok);
|
||||
if (result.ok && result.data.statusCard) {
|
||||
$("discord-status-title").value = result.data.statusCard.title;
|
||||
$("discord-status-note").value = result.data.statusCard.note;
|
||||
$("discord-status-banner").value = result.data.statusCard.banner;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1916,7 +2025,7 @@
|
||||
stateCell.append(el("span", "Hardware banned", "tag bad"));
|
||||
}
|
||||
row.append(el("td", alt.username), stateCell,
|
||||
el("td", alt.devices.length ? `${alt.devices.map(kind => KIND_NAMES[kind] || kind).join(", ")}${alt.weak ? " (weak)" : ""}` : "—"),
|
||||
el("td", alt.devices.length ? `${alt.devices.map(kind => KIND_NAMES[kind] || kind).join(", ")}` : "—"),
|
||||
el("td", alt.addresses ? String(alt.addresses) : "—", "num"));
|
||||
row.addEventListener("click", () => openAccount(alt.username));
|
||||
return row;
|
||||
@@ -2616,6 +2725,10 @@
|
||||
}
|
||||
$("debug-onsale").checked = data.everythingOnSale;
|
||||
$("debug-theatre-browser").checked = data.theatreBrowser;
|
||||
if (document.activeElement !== $("debug-worlds")) {
|
||||
$("debug-worlds").value = data.worlds;
|
||||
$("debug-worlds").max = data.maxWorlds;
|
||||
}
|
||||
if (debugRooms.length !== data.rooms.length) {
|
||||
debugRooms = data.rooms;
|
||||
renderDebugRooms();
|
||||
@@ -2632,6 +2745,25 @@
|
||||
const result = await api("debug", {action: "theatreBrowser", on: $("debug-theatre-browser").checked});
|
||||
setStatus($("debug-browser-status"), result.data.ok || result.data.error || "That did not work.", !result.ok);
|
||||
});
|
||||
$("code-kind").addEventListener("change", showCodeFields);
|
||||
$("code-form").addEventListener("submit", async event => {
|
||||
event.preventDefault();
|
||||
const result = await api("codes", {code: $("code-code").value, kind: $("code-kind").value, item: Number($("code-item").value),
|
||||
color: $("code-color").value.trim(), amount: Number($("code-amount").value), uses: Number($("code-uses").value) || 0});
|
||||
setStatus($("code-status"), result.data.ok || result.data.error || "That did not work.", !result.ok);
|
||||
if (result.ok) {
|
||||
$("code-code").value = "";
|
||||
const codeList = await api("codes");
|
||||
if (codeList.ok) {
|
||||
renderCodes(codeList.data.codes);
|
||||
}
|
||||
}
|
||||
});
|
||||
$("debug-worlds-form").addEventListener("submit", async event => {
|
||||
event.preventDefault();
|
||||
const result = await api("debug", {action: "worlds", count: Number($("debug-worlds").value)});
|
||||
setStatus($("debug-worlds-status"), result.data.ok || result.data.error || "That did not work.", !result.ok);
|
||||
});
|
||||
$("debug-onsale").addEventListener("change", async () => {
|
||||
const result = await api("debug", {action: "everythingOnSale", on: $("debug-onsale").checked});
|
||||
setStatus($("debug-sale-status"), result.data.ok || result.data.error || "That did not work.", !result.ok);
|
||||
@@ -2912,8 +3044,8 @@
|
||||
// moving), else drawn into a PNG that fits, smaller until it is small
|
||||
// enough. any picture this browser can open will do (WebP, AVIF, BMP...).
|
||||
// null when it cannot be read at all.
|
||||
const PICTURE_SIDE = 512;
|
||||
const PICTURE_BYTES = 300 * 1024;
|
||||
const PICTURE_SIDE = 256;
|
||||
const PICTURE_BYTES = 100 * 1024;
|
||||
const preparePicture = async file => {
|
||||
const kept = ["image/png", "image/jpeg", "image/gif"].includes(file.type);
|
||||
let image = null;
|
||||
@@ -2927,7 +3059,7 @@
|
||||
image.close();
|
||||
return file;
|
||||
}
|
||||
for (const side of [PICTURE_SIDE, 384, 256, 128]) {
|
||||
for (const side of [PICTURE_SIDE, 192, 128, 96]) {
|
||||
const scale = Math.min(1, side / image.width, side / image.height);
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = Math.max(1, Math.round(image.width * scale));
|
||||
@@ -3406,6 +3538,10 @@
|
||||
if (result.ok) {
|
||||
renderMessages(result.data);
|
||||
}
|
||||
const codeList = await api("codes");
|
||||
if (codeList.ok) {
|
||||
renderCodes(codeList.data.codes);
|
||||
}
|
||||
}
|
||||
else if (tab === "debug") {
|
||||
result = await api("debug");
|
||||
@@ -3510,9 +3646,23 @@
|
||||
showGate("The server did not answer.");
|
||||
return;
|
||||
}
|
||||
const discordResult = new URLSearchParams(location.search).get("discord");
|
||||
if (state.signedIn) {
|
||||
showPanel();
|
||||
}
|
||||
else if (discordResult === "code") {
|
||||
discordGate(true, "");
|
||||
}
|
||||
else if (discordResult) {
|
||||
discordGate(false, {
|
||||
denied: "That Discord account is not allowed to sign in here.",
|
||||
twostep: "Turn on 2FA for the linked account first.",
|
||||
expired: "The Discord sign-in request expired. Try again.",
|
||||
cancelled: "Discord sign-in was cancelled.",
|
||||
discord: "Discord could not confirm that sign-in. Try again.",
|
||||
off: "Discord sign-in is not configured.",
|
||||
}[discordResult] || "");
|
||||
}
|
||||
else {
|
||||
showGate();
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.6 MiB |
+7
-1
@@ -25,17 +25,21 @@
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
#status { margin: 0; text-align: center; }
|
||||
button { display: none; border: 1px solid #8c8c8c; border-radius: 5px; padding: 6px 12px; background: transparent; color: #ddd; font: inherit; cursor: pointer; }
|
||||
button.show { display: block; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="widget"></div>
|
||||
<p id="status" role="status">Checking…</p>
|
||||
<button id="retry" type="button">Try again</button>
|
||||
<script src="/captcha.js"></script>
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
const action = new URLSearchParams(location.search).get("action") === "signup" ? "signup" : "login";
|
||||
const status = document.getElementById("status");
|
||||
const retry = document.getElementById("retry");
|
||||
const done = token => {
|
||||
if (window.burrowCaptcha) {
|
||||
window.burrowCaptcha.done(token);
|
||||
@@ -53,10 +57,12 @@
|
||||
}});
|
||||
check.answer().then(token => {
|
||||
if (!token) {
|
||||
status.textContent = "Captcha failed. Close this and try again.";
|
||||
status.textContent = "Captcha could not load. Check your connection or content blocker.";
|
||||
retry.classList.add("show");
|
||||
}
|
||||
});
|
||||
}
|
||||
retry.addEventListener("click", () => location.reload());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+72
-23
@@ -10,14 +10,29 @@
|
||||
// captcha.FAILED then), and check.reset() after it: an answer is good once.
|
||||
window.captcha = (() => {
|
||||
const siteKey = "{{siteKey}}";
|
||||
const LOAD_TIMEOUT_MS = 15000;
|
||||
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);
|
||||
const timer = setTimeout(() => {
|
||||
loading = null;
|
||||
reject(new Error("the captcha took too long to load"));
|
||||
}, LOAD_TIMEOUT_MS);
|
||||
script.onload = () => {
|
||||
clearTimeout(timer);
|
||||
if (window.turnstile && typeof window.turnstile.render === "function") {
|
||||
resolve(window.turnstile);
|
||||
}
|
||||
else {
|
||||
loading = null;
|
||||
reject(new Error("the captcha did not start"));
|
||||
}
|
||||
};
|
||||
script.onerror = () => {
|
||||
clearTimeout(timer);
|
||||
loading = null;
|
||||
reject(new Error("the captcha did not load"));
|
||||
};
|
||||
@@ -26,12 +41,15 @@ window.captcha = (() => {
|
||||
return loading;
|
||||
};
|
||||
|
||||
// `options`: {appearance} ("interaction-only" by default: seen only when
|
||||
// cloudflare wants a click), {onAnswer(token)}.
|
||||
// `options`: {appearance} ("always" by default: hidden till cloudflare
|
||||
// wanted a click, it was taken for one that never showed), {onAnswer(token)}.
|
||||
const MAX_RETRIES = 2; // a widget that errs is started again this often first
|
||||
const mount = (element, action, options = {}) => {
|
||||
let widget = null;
|
||||
let answer = null; // a token, "" when none could be had, null while waiting
|
||||
let waiting = [];
|
||||
let retries = 0;
|
||||
let starting = false;
|
||||
const settle = value => {
|
||||
answer = value;
|
||||
if (value && options.onAnswer) {
|
||||
@@ -42,42 +60,73 @@ window.captcha = (() => {
|
||||
}
|
||||
waiting = [];
|
||||
};
|
||||
if (siteKey) {
|
||||
const start = () => {
|
||||
if (!siteKey || starting || widget !== null) {
|
||||
return;
|
||||
}
|
||||
starting = true;
|
||||
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(""));
|
||||
}
|
||||
starting = false;
|
||||
try {
|
||||
widget = turnstile.render(element, {
|
||||
sitekey: siteKey,
|
||||
action,
|
||||
theme: "dark",
|
||||
appearance: options.appearance || "always",
|
||||
callback: value => {
|
||||
retries = 0;
|
||||
settle(value);
|
||||
},
|
||||
"expired-callback": () => {
|
||||
answer = null;
|
||||
},
|
||||
// its code is cloudflare's (110200: this site's name is not on
|
||||
// the widget). many pass with a second go: it is had first.
|
||||
"error-callback": code => {
|
||||
console.log(`captcha error ${code}`);
|
||||
if (retries < MAX_RETRIES) {
|
||||
retries++;
|
||||
answer = null;
|
||||
setTimeout(() => window.turnstile.reset(widget), 1000 * retries);
|
||||
return true;
|
||||
}
|
||||
settle("");
|
||||
return true;
|
||||
},
|
||||
});
|
||||
}
|
||||
catch (err) {
|
||||
console.log(`captcha could not start: ${err.message}`);
|
||||
settle("");
|
||||
}
|
||||
}, () => {
|
||||
starting = false;
|
||||
settle("");
|
||||
});
|
||||
};
|
||||
start();
|
||||
return {
|
||||
on: Boolean(siteKey),
|
||||
answer: () => {
|
||||
if (!siteKey) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
// one that could not load is tried again when an answer is wanted
|
||||
if (answer === "" && widget === null) {
|
||||
answer = null;
|
||||
start();
|
||||
}
|
||||
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;
|
||||
retries = 0;
|
||||
window.turnstile.reset(widget);
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
return {on: Boolean(siteKey), mount, FAILED: "Captcha could not load. Reload the page."};
|
||||
return {on: Boolean(siteKey), mount, FAILED: "Captcha could not load. Check your connection or content blocker, then reload."};
|
||||
})();
|
||||
+380
-122
@@ -135,6 +135,18 @@
|
||||
#browser-address:focus {
|
||||
border-color: #7f6744;
|
||||
}
|
||||
/* a site the client keeps out of the theatre (its own list): offered
|
||||
in the player's own browser instead */
|
||||
#browser-blocked {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font: 400 calc(12 * var(--px)) / 1 Arial, Helvetica, sans-serif;
|
||||
color: #3d2716;
|
||||
cursor: text;
|
||||
}
|
||||
#browser-bar .aj-button {
|
||||
min-width: 0;
|
||||
font-size: calc(12 * var(--px));
|
||||
@@ -237,6 +249,41 @@
|
||||
.aj-box-close:hover {
|
||||
background: radial-gradient(circle at 50% 35%, #ff8f74, #d93d22 70%);
|
||||
}
|
||||
/* a video spot's box (ajVideoSpot): a screen of the theatre's size with
|
||||
a link box under it, over the middle of the stage */
|
||||
#spot {
|
||||
--s: 1;
|
||||
--px: calc(var(--s) * 1px);
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 3;
|
||||
pointer-events: none;
|
||||
font-family: "DigitalDelivery", Arial, Helvetica, sans-serif;
|
||||
}
|
||||
#spot[hidden], #spot [hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
#spot-box {
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: calc(548 * var(--px));
|
||||
}
|
||||
#spot-screen {
|
||||
width: calc(512 * var(--px));
|
||||
height: calc(288 * var(--px));
|
||||
background: #000;
|
||||
border: calc(2 * var(--px)) solid #7f6744;
|
||||
border-radius: calc(6 * var(--px));
|
||||
overflow: hidden;
|
||||
margin-bottom: calc(10 * var(--px));
|
||||
}
|
||||
#spot-screen > * {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 0;
|
||||
display: block;
|
||||
}
|
||||
.aj-box-said {
|
||||
min-height: calc(15 * var(--px));
|
||||
margin: calc(8 * var(--px)) 0 0;
|
||||
@@ -258,7 +305,9 @@
|
||||
<button type="button" id="browser-forward" class="aj-round" aria-label="Forward" disabled>▶</button>
|
||||
<button type="button" id="browser-reload" class="aj-round" aria-label="Reload">↻</button>
|
||||
<input id="browser-address" type="text" placeholder="Search or type an address" autocomplete="off" spellcheck="false" aria-label="Address">
|
||||
<button type="submit" class="aj-button go">Go</button>
|
||||
<button type="submit" id="browser-go" class="aj-button go">Go</button>
|
||||
<span id="browser-blocked" role="status" hidden></span>
|
||||
<button type="button" id="browser-elsewhere" class="aj-button go" hidden>Open in your browser</button>
|
||||
<button type="button" id="browser-close" class="aj-round" aria-label="Close the browser">×</button>
|
||||
</form>
|
||||
<form id="own-video-box" class="aj-box" hidden>
|
||||
@@ -272,6 +321,19 @@
|
||||
<p id="own-video-said" class="aj-box-said" role="status"></p>
|
||||
</form>
|
||||
</div>
|
||||
<div id="spot" hidden>
|
||||
<form id="spot-box" class="aj-box">
|
||||
<h2>Your Video</h2>
|
||||
<button type="button" id="spot-close" class="aj-box-close" aria-label="Close">×</button>
|
||||
<div id="spot-screen"></div>
|
||||
<input id="spot-url" type="url" placeholder="Paste a link: YouTube, Vimeo, .mp4, .webm, .mp3" autocomplete="off" spellcheck="false" aria-label="Video link">
|
||||
<div class="own-video-buttons">
|
||||
<button type="submit" class="aj-button go">Play</button>
|
||||
<button type="button" id="spot-stop" class="aj-button stop">Stop</button>
|
||||
</div>
|
||||
<p id="spot-said" class="aj-box-said" role="status"></p>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
@@ -343,8 +405,11 @@
|
||||
// an address the SWF wants open (AJClient.finderLink): the client opens
|
||||
// it in the system browser, being a webview that may open no window.
|
||||
function ajOpenPage(url) {
|
||||
if (/^https:\/\//.test(String(url))) {
|
||||
window.ipc.sendToHost("openPage", String(url));
|
||||
// https anywhere, or this server's own pages however it is reached
|
||||
// (a server tried on this machine has no https)
|
||||
const link = String(url);
|
||||
if (/^https:\/\//.test(link) || link.startsWith(`${location.origin}/`)) {
|
||||
window.ipc.sendToHost("openPage", link);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -376,9 +441,24 @@
|
||||
? {x: numbers[0], y: numbers[1], w: numbers[2], h: numbers[3]} : null;
|
||||
theatreCover = theatreScreen && parts.length === 3 ? coverRects(Number(parts[1]), parts[2].split(",")) : [];
|
||||
placeTheatre();
|
||||
ownVideo.inTheatre(theatreScreen !== null);
|
||||
browserPage.inTheatre(theatreScreen !== null);
|
||||
// the screen gone for a moment (the room redrawing it) is no reason
|
||||
// to stop the player's video and put its box away: only gone for good.
|
||||
clearTimeout(theatreLeftTimer);
|
||||
if (theatreScreen !== null) {
|
||||
ownVideo.inTheatre(true);
|
||||
browserPage.inTheatre(true);
|
||||
}
|
||||
else {
|
||||
theatreLeftTimer = setTimeout(() => {
|
||||
if (theatreScreen === null) {
|
||||
ownVideo.inTheatre(false);
|
||||
browserPage.inTheatre(false);
|
||||
}
|
||||
}, THEATRE_GONE_MS);
|
||||
}
|
||||
}
|
||||
const THEATRE_GONE_MS = 1500;
|
||||
let theatreLeftTimer = null;
|
||||
|
||||
// the covered cells as rectangles: runs along each row, and a run
|
||||
// that the row above has too made taller.
|
||||
@@ -482,7 +562,9 @@
|
||||
x: theatre.offsetLeft + x * scale, y: theatre.offsetTop + y * scale,
|
||||
w: w * scale, h: (below ? h : h - BUTTON_ROOM) * scale, clip,
|
||||
});
|
||||
for (const id of ["theatre-pills", "own-video-box", "browser-bar"]) {
|
||||
// (not the Your Video box: the player opened it, and with it open the
|
||||
// button is away, so hiding it too left nothing to click)
|
||||
for (const id of ["theatre-pills", "browser-bar"]) {
|
||||
const element = document.getElementById(id);
|
||||
element.classList.toggle("covered", underCover(element, scale));
|
||||
}
|
||||
@@ -511,11 +593,101 @@
|
||||
browserPage.roomVideo(true);
|
||||
}
|
||||
|
||||
// a link of the player's own, to play: YouTube and Vimeo links in those
|
||||
// sites' own players; any other http(s) address in a <video>, which
|
||||
// plays a media file or nothing (a web page in it runs no script and
|
||||
// asks nobody for anything). {frame}, {file} or {error}; null for no link.
|
||||
const videoEmbedFor = text => {
|
||||
let url;
|
||||
try {
|
||||
url = new URL(text);
|
||||
}
|
||||
catch (err) {
|
||||
return null;
|
||||
}
|
||||
if (url.protocol !== "https:" && url.protocol !== "http:") {
|
||||
return null;
|
||||
}
|
||||
const host = url.hostname.replace(/^(?:www\.|m\.)/, "").toLowerCase();
|
||||
let match = null;
|
||||
if (host === "youtu.be") {
|
||||
match = /^\/([A-Za-z0-9_-]{11})/.exec(url.pathname);
|
||||
}
|
||||
else if (host === "youtube.com" || host === "youtube-nocookie.com") {
|
||||
match = url.pathname === "/watch" ? /^([A-Za-z0-9_-]{11})$/.exec(url.searchParams.get("v") || "")
|
||||
: /^\/(?:embed|shorts|live)\/([A-Za-z0-9_-]{11})/.exec(url.pathname);
|
||||
}
|
||||
if (match) {
|
||||
return {frame: `https://www.youtube-nocookie.com/embed/${match[1]}?autoplay=1&rel=0&modestbranding=1`};
|
||||
}
|
||||
if (host === "vimeo.com" || host === "player.vimeo.com") {
|
||||
match = /^\/(?:video\/)?(\d{1,12})(?:\/|$)/.exec(url.pathname);
|
||||
return match ? {frame: `https://player.vimeo.com/video/${match[1]}?autoplay=1`} : {error: "That Vimeo link has no video in it."};
|
||||
}
|
||||
if (host.endsWith("youtube.com")) {
|
||||
return {error: "That YouTube link has no video in it."};
|
||||
}
|
||||
return {file: url.href};
|
||||
};
|
||||
|
||||
// the desktop client loads nothing for this page from elsewhere but
|
||||
// what it is told the player chose (client 1.3.2, app/main.js): it
|
||||
// says when that address may load. an older client never answers.
|
||||
const CLIENT_WAIT_MS = 1500;
|
||||
let videoCleared = null; // {link, go}
|
||||
window.ipc.on("ownVideoReady", (event, link) => {
|
||||
if (videoCleared && videoCleared.link === link) {
|
||||
videoCleared.go();
|
||||
}
|
||||
});
|
||||
const whenVideoCleared = link => new Promise(resolve => {
|
||||
const timer = setTimeout(resolve, CLIENT_WAIT_MS);
|
||||
videoCleared = {link, go: () => {
|
||||
clearTimeout(timer);
|
||||
resolve();
|
||||
}};
|
||||
window.ipc.sendToHost("ownVideo", link);
|
||||
});
|
||||
|
||||
// the element that plays `found` (videoEmbedFor). a file starts once
|
||||
// the client lets it, and only while `stillWanted(element)`;
|
||||
// `failed` hears of a file that would not play.
|
||||
const videoElementFor = (found, stillWanted, failed, started) => {
|
||||
if (found.frame) {
|
||||
const frame = document.createElement("iframe");
|
||||
frame.title = "Your video";
|
||||
frame.allow = "autoplay; encrypted-media; fullscreen";
|
||||
frame.referrerPolicy = "strict-origin-when-cross-origin";
|
||||
frame.src = found.frame;
|
||||
return frame;
|
||||
}
|
||||
const video = document.createElement("video");
|
||||
video.controls = true;
|
||||
video.autoplay = true;
|
||||
video.playsInline = true;
|
||||
video.addEventListener("error", failed);
|
||||
whenVideoCleared(found.file).then(() => {
|
||||
if (stillWanted(video)) {
|
||||
video.src = found.file;
|
||||
started();
|
||||
}
|
||||
});
|
||||
return video;
|
||||
};
|
||||
const VIDEO_DID_NOT_PLAY = "That link did not play. It has to be a video or sound file (.mp4, .webm, .mp3), and the site has to allow it.";
|
||||
|
||||
// a playing element stopped: a file's sound with it, and the client told.
|
||||
const stopVideoElement = element => {
|
||||
if (element instanceof HTMLMediaElement) {
|
||||
element.pause();
|
||||
element.removeAttribute("src");
|
||||
element.load();
|
||||
window.ipc.sendToHost("ownVideo", "");
|
||||
}
|
||||
};
|
||||
|
||||
// a video of the player's own choosing on the theatre screen, seen by
|
||||
// them alone: nothing of it goes to the server. YouTube and Vimeo
|
||||
// links play in those sites' own players; any other http(s) address
|
||||
// in a <video>, which plays a media file or nothing (a web page in it
|
||||
// runs no script and asks nobody for anything).
|
||||
// them alone: nothing of it goes to the server.
|
||||
const ownVideo = (() => {
|
||||
const $ = id => document.getElementById(id);
|
||||
const screen = $("own-video");
|
||||
@@ -528,39 +700,6 @@
|
||||
let roomPlaying = false;
|
||||
let playing = null; // the element showing it
|
||||
|
||||
const embedFor = text => {
|
||||
let url;
|
||||
try {
|
||||
url = new URL(text);
|
||||
}
|
||||
catch (err) {
|
||||
return null;
|
||||
}
|
||||
if (url.protocol !== "https:" && url.protocol !== "http:") {
|
||||
return null;
|
||||
}
|
||||
const host = url.hostname.replace(/^(?:www\.|m\.)/, "").toLowerCase();
|
||||
let match = null;
|
||||
if (host === "youtu.be") {
|
||||
match = /^\/([A-Za-z0-9_-]{11})/.exec(url.pathname);
|
||||
}
|
||||
else if (host === "youtube.com" || host === "youtube-nocookie.com") {
|
||||
match = url.pathname === "/watch" ? /^([A-Za-z0-9_-]{11})$/.exec(url.searchParams.get("v") || "")
|
||||
: /^\/(?:embed|shorts|live)\/([A-Za-z0-9_-]{11})/.exec(url.pathname);
|
||||
}
|
||||
if (match) {
|
||||
return {frame: `https://www.youtube-nocookie.com/embed/${match[1]}?autoplay=1&rel=0&modestbranding=1`};
|
||||
}
|
||||
if (host === "vimeo.com" || host === "player.vimeo.com") {
|
||||
match = /^\/(?:video\/)?(\d{1,12})(?:\/|$)/.exec(url.pathname);
|
||||
return match ? {frame: `https://player.vimeo.com/video/${match[1]}?autoplay=1`} : {error: "That Vimeo link has no video in it."};
|
||||
}
|
||||
if (host.endsWith("youtube.com")) {
|
||||
return {error: "That YouTube link has no video in it."};
|
||||
}
|
||||
return {file: url.href};
|
||||
};
|
||||
|
||||
const show = () => {
|
||||
screen.hidden = !playing || !here || roomPlaying;
|
||||
if (playing instanceof HTMLMediaElement) {
|
||||
@@ -574,99 +713,71 @@
|
||||
};
|
||||
|
||||
const stop = () => {
|
||||
if (playing instanceof HTMLMediaElement) {
|
||||
playing.pause();
|
||||
playing.removeAttribute("src");
|
||||
playing.load();
|
||||
window.ipc.sendToHost("ownVideo", "");
|
||||
}
|
||||
stopVideoElement(playing);
|
||||
screen.replaceChildren();
|
||||
playing = null;
|
||||
show();
|
||||
};
|
||||
|
||||
// the desktop client loads nothing for this page from elsewhere but
|
||||
// what it is told the player chose (client 1.3.2, app/main.js): it
|
||||
// says when that address may load. an older client never answers.
|
||||
const CLIENT_WAIT_MS = 1500;
|
||||
let cleared = null; // {link, go}
|
||||
window.ipc.on("ownVideoReady", (event, link) => {
|
||||
if (cleared && cleared.link === link) {
|
||||
cleared.go();
|
||||
}
|
||||
});
|
||||
const whenCleared = link => new Promise(resolve => {
|
||||
const timer = setTimeout(resolve, CLIENT_WAIT_MS);
|
||||
cleared = {link, go: () => {
|
||||
clearTimeout(timer);
|
||||
resolve();
|
||||
}};
|
||||
window.ipc.sendToHost("ownVideo", link);
|
||||
});
|
||||
|
||||
const play = text => {
|
||||
const found = embedFor(String(text || "").trim());
|
||||
if (!found || found.error) {
|
||||
said.textContent = found ? found.error : "Paste a link starting with https://";
|
||||
return;
|
||||
}
|
||||
stop();
|
||||
browserPage.close();
|
||||
if (found.frame) {
|
||||
playing = document.createElement("iframe");
|
||||
playing.title = "Your video";
|
||||
playing.allow = "autoplay; encrypted-media; fullscreen";
|
||||
playing.referrerPolicy = "strict-origin-when-cross-origin";
|
||||
playing.src = found.frame;
|
||||
}
|
||||
else {
|
||||
const video = document.createElement("video");
|
||||
playing = video;
|
||||
video.controls = true;
|
||||
video.autoplay = true;
|
||||
video.playsInline = true;
|
||||
video.addEventListener("error", () => {
|
||||
said.textContent = "That link did not play. It has to be a video or sound file (.mp4, .webm, .mp3), and the site has to allow it.";
|
||||
});
|
||||
whenCleared(found.file).then(() => {
|
||||
if (playing === video) {
|
||||
video.src = found.file;
|
||||
show();
|
||||
}
|
||||
});
|
||||
}
|
||||
screen.append(playing);
|
||||
said.textContent = roomPlaying ? "It plays when the theatre's own video stops." : "";
|
||||
try {
|
||||
localStorage.setItem(SAVED, input.value.trim());
|
||||
}
|
||||
catch (err) {
|
||||
}
|
||||
show();
|
||||
};
|
||||
|
||||
opener.addEventListener("click", () => {
|
||||
box.hidden = !box.hidden;
|
||||
opener.hidden = !box.hidden;
|
||||
const open = () => {
|
||||
box.hidden = false;
|
||||
opener.hidden = true;
|
||||
placeTheatre();
|
||||
if (!box.hidden) {
|
||||
if (!input.value) {
|
||||
try {
|
||||
input.value = localStorage.getItem(SAVED) || "";
|
||||
}
|
||||
catch (err) {
|
||||
}
|
||||
if (!input.value) {
|
||||
try {
|
||||
input.value = localStorage.getItem(SAVED) || "";
|
||||
}
|
||||
catch (err) {
|
||||
}
|
||||
input.focus();
|
||||
input.select();
|
||||
}
|
||||
});
|
||||
input.focus();
|
||||
input.select();
|
||||
};
|
||||
// the box away and the button back: the two are never gone at once.
|
||||
const close = () => {
|
||||
box.hidden = true;
|
||||
opener.hidden = false;
|
||||
placeTheatre();
|
||||
said.textContent = "";
|
||||
};
|
||||
|
||||
const play = text => {
|
||||
const found = videoEmbedFor(String(text || "").trim());
|
||||
if (!found || found.error) {
|
||||
said.textContent = found ? found.error : "Paste a link starting with https://";
|
||||
return;
|
||||
}
|
||||
stop();
|
||||
browserPage.close();
|
||||
const element = videoElementFor(found, video => playing === video, () => {
|
||||
open();
|
||||
said.textContent = VIDEO_DID_NOT_PLAY;
|
||||
}, show);
|
||||
playing = element;
|
||||
screen.append(playing);
|
||||
try {
|
||||
localStorage.setItem(SAVED, input.value.trim());
|
||||
}
|
||||
catch (err) {
|
||||
}
|
||||
// the box goes once it plays, the button back to change it
|
||||
if (roomPlaying) {
|
||||
said.textContent = "It plays when the theatre's own video stops.";
|
||||
}
|
||||
else {
|
||||
close();
|
||||
}
|
||||
show();
|
||||
};
|
||||
|
||||
opener.addEventListener("click", () => {
|
||||
if (box.hidden) {
|
||||
open();
|
||||
}
|
||||
else {
|
||||
close();
|
||||
}
|
||||
});
|
||||
$("own-video-close").addEventListener("click", close);
|
||||
$("own-video-stop").addEventListener("click", () => {
|
||||
stop();
|
||||
@@ -683,6 +794,7 @@
|
||||
});
|
||||
|
||||
return {
|
||||
open,
|
||||
// the browser takes the screen: the player's own video and its box go.
|
||||
giveWay() {
|
||||
stop();
|
||||
@@ -710,6 +822,113 @@
|
||||
};
|
||||
})();
|
||||
|
||||
// a video spot of the game's (a screen in a room, a "videos" button,
|
||||
// the trade list's help): its videos came from the official server,
|
||||
// and here the spot opens a box for a video of the player's own, over
|
||||
// the middle of the stage, seen by them alone. the game says when
|
||||
// (AJClient's GenericListGuiManager.openVideoSpot).
|
||||
const spotVideo = (() => {
|
||||
const $ = id => document.getElementById(id);
|
||||
const spot = $("spot");
|
||||
const screen = $("spot-screen");
|
||||
const input = $("spot-url");
|
||||
const said = $("spot-said");
|
||||
const SAVED = "ownVideoUrl";
|
||||
let playing = null;
|
||||
|
||||
const fit = () => {
|
||||
spot.style.setProperty("--s", String(Math.min(window.innerWidth / STAGE_W, window.innerHeight / STAGE_H)));
|
||||
};
|
||||
const stop = () => {
|
||||
stopVideoElement(playing);
|
||||
screen.replaceChildren();
|
||||
playing = null;
|
||||
};
|
||||
const play = text => {
|
||||
const found = videoEmbedFor(String(text || "").trim());
|
||||
if (!found || found.error) {
|
||||
said.textContent = found ? found.error : "Paste a link starting with https://";
|
||||
return;
|
||||
}
|
||||
stop();
|
||||
said.textContent = "";
|
||||
playing = videoElementFor(found, video => playing === video, () => {
|
||||
said.textContent = VIDEO_DID_NOT_PLAY;
|
||||
}, () => {});
|
||||
screen.append(playing);
|
||||
};
|
||||
const close = () => {
|
||||
stop();
|
||||
spot.hidden = true;
|
||||
said.textContent = "";
|
||||
};
|
||||
|
||||
$("spot-close").addEventListener("click", close);
|
||||
$("spot-stop").addEventListener("click", () => {
|
||||
stop();
|
||||
said.textContent = "";
|
||||
});
|
||||
$("spot-box").addEventListener("submit", event => {
|
||||
event.preventDefault();
|
||||
play(input.value);
|
||||
try {
|
||||
localStorage.setItem(SAVED, input.value.trim());
|
||||
}
|
||||
catch (err) {
|
||||
}
|
||||
});
|
||||
input.addEventListener("keydown", event => {
|
||||
if (event.key === "Escape") {
|
||||
close();
|
||||
}
|
||||
});
|
||||
window.addEventListener("resize", fit);
|
||||
|
||||
return {
|
||||
close,
|
||||
// `videoId`: a YouTube video to play at once, or none
|
||||
open(videoId) {
|
||||
fit();
|
||||
spot.hidden = false;
|
||||
said.textContent = "";
|
||||
if (videoId) {
|
||||
input.value = "";
|
||||
play(`https://youtu.be/${videoId}`);
|
||||
return;
|
||||
}
|
||||
if (!input.value) {
|
||||
try {
|
||||
input.value = localStorage.getItem(SAVED) || "";
|
||||
}
|
||||
catch (err) {
|
||||
}
|
||||
}
|
||||
input.focus();
|
||||
input.select();
|
||||
},
|
||||
};
|
||||
})();
|
||||
|
||||
// from the game: a video spot clicked ("" or a YouTube id of ours to
|
||||
// play), or "close" (the player left the room). in a theatre, its own
|
||||
// Your Video box.
|
||||
function ajVideoSpot(text) {
|
||||
const wanted = String(text || "");
|
||||
if (wanted === "close") {
|
||||
spotVideo.close();
|
||||
return;
|
||||
}
|
||||
if (/^[A-Za-z0-9_-]{11}$/.test(wanted)) {
|
||||
spotVideo.open(wanted);
|
||||
}
|
||||
else if (theatreScreen !== null) {
|
||||
ownVideo.open();
|
||||
}
|
||||
else {
|
||||
spotVideo.open("");
|
||||
}
|
||||
}
|
||||
|
||||
// the theatre's browser (experimental): a web page on the screen, for
|
||||
// the player alone, when the admin has turned it on (the server marks
|
||||
// this page so: lib/panel.js). the desktop client (1.3.3) draws it in a
|
||||
@@ -729,6 +948,10 @@
|
||||
let roomPlaying = false;
|
||||
let where = null; // the last place told, without `shown`
|
||||
let told = "";
|
||||
// an address the client would not show here (the old browser engine
|
||||
// it needs for Flash shows only the sites it lists): the bar offers
|
||||
// to open it in the player's own browser instead. "" when none.
|
||||
let elsewhere = "";
|
||||
|
||||
const tell = message => window.ipc.sendToHost("browser", message);
|
||||
const placeMessage = () => ({...where, shown: open && theatreScreen !== null && !roomPlaying});
|
||||
@@ -760,6 +983,24 @@
|
||||
opener.hidden = !allowed;
|
||||
pills.hidden = open;
|
||||
bar.hidden = !open;
|
||||
address.hidden = elsewhere !== "";
|
||||
$("browser-go").hidden = elsewhere !== "";
|
||||
$("browser-blocked").hidden = elsewhere === "";
|
||||
$("browser-elsewhere").hidden = elsewhere === "";
|
||||
};
|
||||
|
||||
const showElsewhere = (url, sites) => {
|
||||
let host = "";
|
||||
try {
|
||||
host = new URL(url).hostname;
|
||||
}
|
||||
catch (err) {
|
||||
url = "";
|
||||
}
|
||||
elsewhere = url;
|
||||
$("browser-blocked").textContent = elsewhere ? `${host} opens in your own browser, not here.` : "";
|
||||
$("browser-blocked").title = sites.length ? `The theatre shows only ${sites.join(", ")}.` : "";
|
||||
show();
|
||||
};
|
||||
|
||||
const close = () => {
|
||||
@@ -768,6 +1009,7 @@
|
||||
}
|
||||
open = false;
|
||||
told = "";
|
||||
elsewhere = "";
|
||||
tell({action: "close"});
|
||||
show();
|
||||
};
|
||||
@@ -782,6 +1024,18 @@
|
||||
address.focus();
|
||||
});
|
||||
$("browser-close").addEventListener("click", close);
|
||||
// the client opens http and https addresses in the system browser
|
||||
$("browser-elsewhere").addEventListener("click", () => {
|
||||
if (/^https?:\/\//.test(elsewhere)) {
|
||||
window.ipc.sendToHost("openPage", elsewhere);
|
||||
}
|
||||
showElsewhere("", []);
|
||||
});
|
||||
// back to the address, to go somewhere else
|
||||
$("browser-blocked").addEventListener("click", () => {
|
||||
showElsewhere("", []);
|
||||
address.focus();
|
||||
});
|
||||
$("browser-back").addEventListener("click", () => tell({action: "back"}));
|
||||
$("browser-forward").addEventListener("click", () => tell({action: "forward"}));
|
||||
$("browser-reload").addEventListener("click", () => tell({action: "reload"}));
|
||||
@@ -816,6 +1070,10 @@
|
||||
}
|
||||
$("browser-back").disabled = state.back !== true;
|
||||
$("browser-forward").disabled = state.forward !== true;
|
||||
const blocked = typeof state.blocked === "string" && /^https?:\/\//.test(state.blocked) ? state.blocked : "";
|
||||
if (blocked !== elsewhere) {
|
||||
showElsewhere(blocked, Array.isArray(state.sites) ? state.sites.map(String).slice(0, 10) : []);
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Item preview</title>
|
||||
<style>
|
||||
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: #1a1a1a; }
|
||||
ruffle-player, ruffle-object, ruffle-embed { display: block; width: 100%; height: 100%; }
|
||||
</style>
|
||||
<script>
|
||||
// ruffle's own settings: no menus, overlays or sound.
|
||||
window.RufflePlayer = {config: {
|
||||
publicPath: "https://cdn.jsdelivr.net/npm/@ruffle-rs/[email protected]/",
|
||||
polyfills: false,
|
||||
autoplay: "on",
|
||||
unmuteOverlay: "hidden",
|
||||
splashScreen: false,
|
||||
contextMenu: "off",
|
||||
letterbox: "off",
|
||||
backgroundColor: "#1A1A1A", // the giver page's
|
||||
volume: 0,
|
||||
openUrlMode: "deny",
|
||||
allowScriptAccess: false,
|
||||
showSwfDownload: false,
|
||||
warnOnUnsupportedContent: false,
|
||||
logLevel: "error",
|
||||
}};
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@ruffle-rs/[email protected]/ruffle.js" integrity="sha256-JgNqlFZwiN+z3oinWejtEKTOoHspUArzbzRe70JCAJg=" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
// one den item for the web item giver (public/items.html), in a frame of
|
||||
// its own: #id=&v=&tint=rrggbb&s=, as Give would give it. its art plays
|
||||
// in public/item-preview.swf (tools/preview-host), which sets the
|
||||
// variant and tint as a den does. served sandboxed (lib/manage.js): this
|
||||
// page has no origin, so no sign-in, of its own.
|
||||
let player = null;
|
||||
|
||||
const show = () => {
|
||||
const wanted = new URLSearchParams(location.hash.slice(1));
|
||||
const id = /^\d{1,9}$/.test(wanted.get("id") || "") ? wanted.get("id") : null;
|
||||
if (player) {
|
||||
player.remove();
|
||||
player = null;
|
||||
}
|
||||
if (!id || !window.RufflePlayer || !window.RufflePlayer.newest) {
|
||||
return;
|
||||
}
|
||||
player = window.RufflePlayer.newest().createPlayer();
|
||||
document.body.append(player);
|
||||
const parameters = {art: new URL(`/account/art/den/${id}`, location.href).href, version: String(Number(wanted.get("v")) || 0)};
|
||||
if (/^[0-9a-f]{6}$/i.test(wanted.get("tint") || "")) {
|
||||
parameters.tint = wanted.get("tint");
|
||||
parameters.strength = String(Number(wanted.get("s")) || 100);
|
||||
}
|
||||
const movie = {url: new URL("/account/item-preview.swf", location.href).href, parameters};
|
||||
(player.ruffle ? player.ruffle().load(movie) : player.load(movie)).catch(() => {});
|
||||
};
|
||||
|
||||
window.addEventListener("hashchange", show);
|
||||
show();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
@@ -0,0 +1,786 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Item giver</title>
|
||||
<link rel="icon" type="image/png" href="/logo-square.png">
|
||||
<style>
|
||||
/* the account page's look (public/account.html): black and white, in
|
||||
the game's own text font. the only colours are the items' own. */
|
||||
@font-face { font-family: "DigitalDelivery"; font-weight: 400; src: url("/fonts/CCDigitalDelivery-Regular.otf") format("opentype"); }
|
||||
@font-face { font-family: "DigitalDelivery"; font-weight: 700; src: url("/fonts/CCDigitalDelivery-Bold.otf") format("opentype"); }
|
||||
:root {
|
||||
color-scheme: dark;
|
||||
--bg: #000;
|
||||
--panel: #0d0d0d;
|
||||
--raised: #1a1a1a;
|
||||
--line: #2e2e2e;
|
||||
--text: #fff;
|
||||
--muted: #8c8c8c;
|
||||
}
|
||||
* { box-sizing: border-box; }
|
||||
[hidden] { display: none !important; }
|
||||
::selection { background: #fff; color: #000; }
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 32px 16px 48px;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font: 15px/1.4 "DigitalDelivery", system-ui, "Segoe UI", sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
a { color: inherit; text-underline-offset: 3px; }
|
||||
h1 { margin: 0; font-size: 26px; font-weight: 700; flex: 1; }
|
||||
h2 { margin: 0 0 6px; font-size: 17px; font-weight: 700; }
|
||||
h3 { margin: 16px 0 8px; font-size: 14px; font-weight: 700; }
|
||||
p { margin: 0 0 12px; color: var(--muted); }
|
||||
.wrap { max-width: 760px; margin: 0 auto; }
|
||||
header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
|
||||
header img { width: 40px; height: 40px; }
|
||||
section {
|
||||
padding: 20px;
|
||||
margin-bottom: 16px;
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 18px;
|
||||
}
|
||||
input, select {
|
||||
font: inherit;
|
||||
color: var(--text);
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 14px;
|
||||
padding: 9px 14px 10px;
|
||||
}
|
||||
input:hover, select:hover { border-color: #555; }
|
||||
input:focus, select:focus { outline: none; border-color: var(--text); }
|
||||
input:disabled { opacity: 0.4; }
|
||||
button, a.button {
|
||||
font: inherit;
|
||||
color: var(--text);
|
||||
background: none;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 999px;
|
||||
padding: 7px 16px 8px;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
text-decoration: none;
|
||||
}
|
||||
button:hover, a.button:hover { background: var(--raised); border-color: #555; }
|
||||
button:disabled { opacity: 0.45; cursor: default; }
|
||||
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
|
||||
button.primary { font-weight: 700; color: #000; background: var(--text); border-color: var(--text); }
|
||||
button.primary:hover { background: #d9d9d9; border-color: #d9d9d9; }
|
||||
button[aria-pressed="true"] { border-color: var(--text); background: var(--raised); }
|
||||
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
|
||||
#search-row input { flex: 1; min-width: 180px; }
|
||||
.status { min-height: 20px; margin: 10px 0 0; font-size: 13px; color: var(--muted); }
|
||||
.status.bad { color: var(--text); }
|
||||
.status.bad::before { content: "! "; font-weight: 700; }
|
||||
#results { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
|
||||
#results button {
|
||||
display: flex; width: 100%; gap: 10px; align-items: baseline;
|
||||
border-radius: 14px; padding: 9px 14px 10px; text-align: left; white-space: normal;
|
||||
}
|
||||
#results .name { flex: 1; overflow-wrap: anywhere; }
|
||||
.meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
|
||||
.swatches { display: inline-flex; gap: 3px; vertical-align: middle; }
|
||||
.swatch { width: 16px; height: 16px; border-radius: 5px; border: 1px solid rgba(255, 255, 255, 0.25); }
|
||||
#presets, #variants { display: flex; flex-wrap: wrap; gap: 6px; }
|
||||
#presets button, #variants button { padding: 6px 10px 7px; border-radius: 12px; }
|
||||
.slot { display: grid; grid-template-columns: 74px 44px 1fr; gap: 8px; align-items: center; margin-bottom: 8px; }
|
||||
.slot span { color: var(--muted); font-size: 13px; }
|
||||
.colour-slot { grid-template-columns: 74px 44px minmax(0, 160px) 96px; }
|
||||
input.aj { width: 100%; min-width: 0; font-variant-numeric: tabular-nums; }
|
||||
#whole-row { margin-top: 4px; }
|
||||
#whole-row > span:first-child { width: 74px; color: var(--muted); font-size: 13px; }
|
||||
#whole { width: 190px; }
|
||||
#whole-note { white-space: normal; }
|
||||
input[type="color"] { width: 44px; height: 38px; padding: 3px; border-radius: 10px; cursor: pointer; }
|
||||
input.hex { width: 100%; max-width: 160px; font-variant-numeric: tabular-nums; text-transform: lowercase; }
|
||||
input[type="range"] { flex: 1; padding: 0; border: none; accent-color: #fff; }
|
||||
label.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
|
||||
#give-row { margin-top: 16px; }
|
||||
#item-head { display: flex; gap: 16px; align-items: center; }
|
||||
#item-head > div:first-child { flex: 1; min-width: 0; }
|
||||
#preview {
|
||||
position: relative; flex: none; width: 160px; height: 160px;
|
||||
display: grid; place-items: center;
|
||||
background: var(--raised); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
|
||||
}
|
||||
#preview canvas, #preview img { max-width: 144px; max-height: 144px; }
|
||||
#preview iframe { width: 100%; height: 100%; border: 0; }
|
||||
#preview-note { position: absolute; inset: auto 8px 6px; font-size: 11px; text-align: center; color: var(--muted); }
|
||||
@media (max-width: 480px) {
|
||||
.slot { grid-template-columns: 64px 44px 1fr; }
|
||||
.colour-slot { grid-template-columns: 64px 44px minmax(0, 1fr) 56px; }
|
||||
.colour-slot span { white-space: nowrap; }
|
||||
#whole-row > span:first-child { width: auto; }
|
||||
#whole { width: 100%; }
|
||||
#item-head { flex-direction: column-reverse; align-items: flex-start; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
<header>
|
||||
<img src="/logo.png" alt="">
|
||||
<h1>Item giver</h1>
|
||||
<a class="button" href="/account">Your account</a>
|
||||
</header>
|
||||
|
||||
<section id="gate" hidden>
|
||||
<h2 id="gate-title">Sign in first</h2>
|
||||
<p id="gate-text">The item giver uses your account page's sign-in.</p>
|
||||
<a class="button" href="/account">Go to your account page</a>
|
||||
</section>
|
||||
|
||||
<section id="finder" hidden>
|
||||
<p id="who"></p>
|
||||
<div class="row" id="search-row">
|
||||
<input id="query" type="search" placeholder="Name or id" maxlength="60" autocomplete="off" spellcheck="false" aria-label="Search items">
|
||||
<select id="kind" aria-label="Kind of item">
|
||||
<option value="all">Everything</option>
|
||||
<option value="clothing">Clothing</option>
|
||||
<option value="den">Den items</option>
|
||||
</select>
|
||||
</div>
|
||||
<p class="status" id="search-status" role="status"></p>
|
||||
<ul id="results"></ul>
|
||||
</section>
|
||||
|
||||
<section id="detail" hidden>
|
||||
<div id="item-head">
|
||||
<div>
|
||||
<h2 id="item-name"></h2>
|
||||
<p class="meta" id="item-meta"></p>
|
||||
</div>
|
||||
<div id="preview" aria-label="How it looks">
|
||||
<canvas id="preview-icon" hidden></canvas>
|
||||
<img id="preview-art" alt="" hidden>
|
||||
<iframe id="preview-den" title="How it looks" sandbox="allow-scripts" hidden></iframe>
|
||||
<span id="preview-note"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="clothing-part">
|
||||
<h3>The item's own colours</h3>
|
||||
<div id="presets"></div>
|
||||
<h3>Your own colours</h3>
|
||||
<div id="slots"></div>
|
||||
<div class="row" id="whole-row">
|
||||
<span>Whole item</span>
|
||||
<input class="aj" id="whole" inputmode="numeric" maxlength="11" spellcheck="false" autocomplete="off" placeholder="AJ colour" aria-label="The whole item's colour as the game writes it">
|
||||
<span class="meta" id="whole-note"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="den-part">
|
||||
<h3>Variant</h3>
|
||||
<div id="variants"></div>
|
||||
<p id="no-variants" hidden>This item has no other variants.</p>
|
||||
<h3>Tint</h3>
|
||||
<p id="tint-off" hidden>Mannequins cannot be tinted.</p>
|
||||
<div id="tint-on">
|
||||
<label class="check"><input id="tint" type="checkbox"> The whole item in shades of a colour</label>
|
||||
<div class="slot" style="margin-top:10px">
|
||||
<span>Colour</span>
|
||||
<input type="color" id="tint-picker" value="#4ab3f4" aria-label="Tint colour">
|
||||
<input class="hex" id="tint-hex" value="#4ab3f4" maxlength="7" spellcheck="false" aria-label="Tint colour as #RRGGBB">
|
||||
</div>
|
||||
<div class="row">
|
||||
<span class="meta">Strength</span>
|
||||
<input type="range" id="tint-strength" min="1" max="100" value="70" aria-label="Tint strength">
|
||||
<span class="meta" id="tint-strength-text">70%</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" id="give-row">
|
||||
<button class="primary" id="give" type="button">Give</button>
|
||||
<span class="meta" id="give-what"></span>
|
||||
</div>
|
||||
<p class="status" id="give-status" role="status"></p>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
// the item giver on the web (lib/admin.js searchFor and giveAs, by way
|
||||
// of lib/manage.js), signed in as on the account page: items go to that
|
||||
// account, as the in-game giver's go to the one playing.
|
||||
const $ = id => document.getElementById(id);
|
||||
const KINDS = {clothing: "Clothing", den: "Den item"};
|
||||
|
||||
let chosen = null; // the result picked
|
||||
let preset = 0; // the item's own colour picked, or null for the slots' own
|
||||
let variant = 0;
|
||||
|
||||
const setStatus = (id, text, bad = false) => {
|
||||
$(id).textContent = text;
|
||||
$(id).classList.toggle("bad", bad);
|
||||
};
|
||||
|
||||
const api = async (path, body) => {
|
||||
try {
|
||||
const response = await fetch(`/account/api/${path}`, body === undefined ? {} : {
|
||||
method: "POST",
|
||||
headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
return {ok: response.ok, status: response.status, data: await response.json().catch(() => ({}))};
|
||||
}
|
||||
catch (err) {
|
||||
return {ok: false, status: 0, data: {error: "The server did not answer."}};
|
||||
}
|
||||
};
|
||||
|
||||
// "#abc", "abc", "#aabbcc" or "aabbcc" as "#aabbcc"; null for anything else.
|
||||
const readHex = text => {
|
||||
const match = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(String(text).trim());
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
const digits = match[1].length === 3 ? match[1].replace(/./g, digit => digit + digit) : match[1];
|
||||
return `#${digits.toLowerCase()}`;
|
||||
};
|
||||
|
||||
const swatches = colours => {
|
||||
const box = document.createElement("span");
|
||||
box.className = "swatches";
|
||||
for (const colour of colours) {
|
||||
const swatch = document.createElement("span");
|
||||
swatch.className = "swatch";
|
||||
swatch.style.background = `#${colour}`;
|
||||
box.append(swatch);
|
||||
}
|
||||
return box;
|
||||
};
|
||||
|
||||
// a colour picker and a #RRGGBB box that follow each other; `onChange`
|
||||
// is told of each colour taken.
|
||||
const pairUp = (picker, box, onChange) => {
|
||||
picker.addEventListener("input", () => {
|
||||
box.value = picker.value;
|
||||
onChange();
|
||||
});
|
||||
box.addEventListener("input", () => {
|
||||
const hex = readHex(box.value);
|
||||
box.setCustomValidity(hex ? "" : "#RRGGBB");
|
||||
if (hex) {
|
||||
picker.value = hex;
|
||||
onChange();
|
||||
}
|
||||
});
|
||||
box.addEventListener("change", () => {
|
||||
const hex = readHex(box.value);
|
||||
box.value = hex || picker.value;
|
||||
box.setCustomValidity("");
|
||||
});
|
||||
};
|
||||
|
||||
// the game's way of writing colours: one number for the whole item, its
|
||||
// four colours' places in the game's palette of 256, colour 1 the top
|
||||
// byte; written unsigned, or signed as lists of the game's colours often
|
||||
// have them. top byte 0xFD: a custom colour, four RGB values of the
|
||||
// server's own (lib/colours.js), not palette places.
|
||||
let palette = null; // the game's 256 colours, "#rrggbb", once the server says
|
||||
let customId = null; // the custom colour the four make, when one is known
|
||||
const CUSTOM_TOP = 0xFD;
|
||||
const isCustom = value => value >>> 24 === CUSTOM_TOP;
|
||||
const readWhole = text => {
|
||||
const value = /^-?\d{1,10}$/.test(String(text).trim()) ? Number(String(text).trim()) : NaN;
|
||||
return value >= -0x80000000 && value <= 0xFFFFFFFF ? value >>> 0 : null;
|
||||
};
|
||||
// one colour's place, 0 to 255; -128 to -1 are 128 to 255 written signed
|
||||
const readIndex = text => {
|
||||
const value = /^-?\d{1,3}$/.test(String(text).trim()) ? Number(String(text).trim()) : NaN;
|
||||
return value >= -128 && value <= 255 ? (value + 256) % 256 : null;
|
||||
};
|
||||
const pack = indexes => indexes.reduce((value, index) => value * 256 + index, 0);
|
||||
|
||||
// a slot set: its colour, and its place in the palette or null. `from`
|
||||
// is the box typed in, left as typed.
|
||||
const setSlot = (slot, hex, index, from = null) => {
|
||||
slot.index = index;
|
||||
if (from !== "hex") {
|
||||
slot.picker.value = hex;
|
||||
slot.box.value = hex;
|
||||
}
|
||||
if (from !== "aj") {
|
||||
slot.aj.value = index === null ? "" : String(index);
|
||||
slot.aj.setCustomValidity("");
|
||||
}
|
||||
slot.aj.placeholder = index === null && palette ? "custom" : "AJ";
|
||||
};
|
||||
|
||||
// what Give gives: a colour id, or null for a custom colour still to make.
|
||||
const wholeValue = () => {
|
||||
if (preset !== null && chosen && chosen.presets[preset]) {
|
||||
return chosen.presets[preset].id;
|
||||
}
|
||||
if (customId !== null) {
|
||||
return customId;
|
||||
}
|
||||
return slots.every(slot => slot.index !== null) ? pack(slots.map(slot => slot.index)) : null;
|
||||
};
|
||||
|
||||
let lookupTimer = null;
|
||||
const showWhole = () => {
|
||||
const value = wholeValue();
|
||||
if (document.activeElement !== $("whole")) {
|
||||
$("whole").value = value === null ? "" : String(value);
|
||||
$("whole").setCustomValidity("");
|
||||
}
|
||||
$("whole-note").textContent = value === null ? "A new custom colour, made when you give it."
|
||||
: `${value} unsigned · ${value | 0} signed${isCustom(value) ? " · a custom colour" : ""}`;
|
||||
// four colours not all the palette's: a custom colour they make already?
|
||||
clearTimeout(lookupTimer);
|
||||
if (value === null) {
|
||||
const asked = slots.map(slot => slot.picker.value.slice(1)).join(",");
|
||||
lookupTimer = setTimeout(async () => {
|
||||
const result = await api(`colour?rgbs=${asked}`);
|
||||
if (result.ok && result.data.id !== null && preset === null && customId === null
|
||||
&& slots.map(slot => slot.picker.value.slice(1)).join(",") === asked) {
|
||||
customId = result.data.id;
|
||||
showWhole();
|
||||
showChoice();
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
};
|
||||
|
||||
// a whole item's colour taken: from the whole box (`from`) or one of the item's own.
|
||||
const applyWhole = async (value, from = null, own = null) => {
|
||||
if (isCustom(value)) {
|
||||
const colours = own || await api(`colour?id=${value}`).then(result => (result.ok ? result.data.colours : null));
|
||||
if (!colours) {
|
||||
$("whole-note").textContent = "No such custom colour.";
|
||||
return;
|
||||
}
|
||||
if (from === "whole" && readWhole($("whole").value) !== value) {
|
||||
return; // typed on since
|
||||
}
|
||||
colours.forEach((colour, index) => setSlot(slots[index], `#${colour}`, null));
|
||||
customId = value;
|
||||
}
|
||||
else {
|
||||
[24, 16, 8, 0].forEach((shift, index) => {
|
||||
const place = value >>> shift & 255;
|
||||
setSlot(slots[index], palette ? palette[place] : own ? `#${own[index]}` : slots[index].picker.value, place);
|
||||
});
|
||||
customId = null;
|
||||
}
|
||||
showChoice();
|
||||
};
|
||||
|
||||
const slots = [];
|
||||
for (let slot = 0; slot < 4; slot++) {
|
||||
const row = document.createElement("div");
|
||||
row.className = "slot colour-slot";
|
||||
const name = document.createElement("span");
|
||||
name.textContent = `Colour ${slot + 1}`;
|
||||
const picker = document.createElement("input");
|
||||
picker.type = "color";
|
||||
picker.value = "#ffffff";
|
||||
picker.setAttribute("aria-label", `Colour ${slot + 1}`);
|
||||
const box = document.createElement("input");
|
||||
box.className = "hex";
|
||||
box.maxLength = 7;
|
||||
box.spellcheck = false;
|
||||
box.value = "#ffffff";
|
||||
box.setAttribute("aria-label", `Colour ${slot + 1} as #RRGGBB`);
|
||||
const aj = document.createElement("input");
|
||||
aj.className = "aj";
|
||||
aj.inputMode = "numeric";
|
||||
aj.maxLength = 4;
|
||||
aj.spellcheck = false;
|
||||
aj.autocomplete = "off";
|
||||
aj.placeholder = "AJ";
|
||||
aj.title = "Its place in the game's palette: 0 to 255 (-128 to -1 written signed)";
|
||||
aj.setAttribute("aria-label", `Colour ${slot + 1} as the game writes it, 0 to 255`);
|
||||
const own = {picker, box, aj, index: null};
|
||||
pairUp(picker, box, () => {
|
||||
const place = palette ? palette.indexOf(picker.value) : -1;
|
||||
setSlot(own, picker.value, place < 0 ? null : place, "hex");
|
||||
preset = null;
|
||||
customId = null;
|
||||
showChoice();
|
||||
});
|
||||
aj.addEventListener("input", () => {
|
||||
const place = readIndex(aj.value);
|
||||
aj.setCustomValidity(place === null || !palette ? "0 to 255" : "");
|
||||
if (place !== null && palette) {
|
||||
setSlot(own, palette[place], place, "aj");
|
||||
preset = null;
|
||||
customId = null;
|
||||
showChoice();
|
||||
}
|
||||
});
|
||||
aj.addEventListener("change", () => setSlot(own, own.picker.value, own.index));
|
||||
row.append(name, picker, box, aj);
|
||||
$("slots").append(row);
|
||||
slots.push(own);
|
||||
}
|
||||
$("whole").addEventListener("input", () => {
|
||||
const value = readWhole($("whole").value);
|
||||
$("whole").setCustomValidity(value === null ? "A colour id, signed or not" : "");
|
||||
if (value !== null) {
|
||||
preset = null;
|
||||
applyWhole(value, "whole");
|
||||
}
|
||||
else if ($("whole").value.trim()) {
|
||||
$("whole-note").textContent = "A whole number: -2147483648 to 4294967295.";
|
||||
}
|
||||
});
|
||||
$("whole").addEventListener("change", showChoice);
|
||||
pairUp($("tint-picker"), $("tint-hex"), () => {
|
||||
$("tint").checked = true;
|
||||
showChoice();
|
||||
});
|
||||
$("tint").addEventListener("change", showChoice);
|
||||
$("tint-strength").addEventListener("input", () => {
|
||||
$("tint-strength-text").textContent = `${$("tint-strength").value}%`;
|
||||
$("tint").checked = true;
|
||||
showChoice();
|
||||
});
|
||||
|
||||
// the item as it would be given (lib/itempreview.js). clothing: its
|
||||
// closet icon, coloured here as the game colours it
|
||||
// (PaletteHelper.BuildAnimalPalette, LayerBitmap.paintFrame). den items:
|
||||
// their art played in a frame of public/item-preview.html. a custom
|
||||
// item with a picture of its own: that picture.
|
||||
const icons = new Map(); // clothing id: its icon, {w, h, bytes}, or null
|
||||
const rgbOf = hex => parseInt(hex.slice(1), 16);
|
||||
const gradient = (palette, rgb, start, count) => {
|
||||
let [red, green, blue] = [rgb >> 16 & 255, rgb >> 8 & 255, rgb & 255];
|
||||
const [stepRed, stepGreen, stepBlue] = [red, green, blue].map(value => Math.floor(value / (count + 2)));
|
||||
for (let at = start + count - 1, left = count; left > 0; left--, at--) {
|
||||
[255, 192, 128, 64].forEach((alpha, shade) => {
|
||||
palette[at + 25 * shade] = [red, green, blue, alpha];
|
||||
});
|
||||
red -= stepRed;
|
||||
green -= stepGreen;
|
||||
blue -= stepBlue;
|
||||
}
|
||||
};
|
||||
const mix = (one, other) => [16, 8, 0].reduce((sum, shift) => sum | (((one >> shift & 255) + (other >> shift & 255)) >> 1) << shift, 0);
|
||||
const paletteOf = ([one, two, three, four]) => {
|
||||
const palette = [];
|
||||
[[one, 1, 3], [two, 4, 3], [three, 7, 3], [four, 10, 3], [mix(one, two), 13, 2], [mix(two, three), 15, 2],
|
||||
[mix(one, three), 17, 2], [mix(one, four), 19, 2], [mix(two, four), 21, 2], [mix(three, four), 23, 2]]
|
||||
.forEach(([rgb, start, count]) => gradient(palette, rgb, start, count));
|
||||
return palette;
|
||||
};
|
||||
const paintIcon = (icon, colours) => {
|
||||
const canvas = $("preview-icon");
|
||||
canvas.width = icon.w;
|
||||
canvas.height = icon.h;
|
||||
const context = canvas.getContext("2d");
|
||||
const image = context.createImageData(icon.w, icon.h);
|
||||
const palette = paletteOf(colours.map(rgbOf));
|
||||
const bytes = icon.bytes;
|
||||
let [x, y, at] = [0, 0, 0];
|
||||
while (at < bytes.length) {
|
||||
let index = bytes[at++];
|
||||
let run = 1;
|
||||
if (index & 0x80) {
|
||||
index &= 0x7F;
|
||||
run = bytes[at++] + 1;
|
||||
}
|
||||
if (index === 0) {
|
||||
x += run;
|
||||
if (x >= icon.w) {
|
||||
const over = x - icon.w;
|
||||
x = over % icon.w;
|
||||
y += Math.floor(over / icon.w) + 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
const colour = palette[index];
|
||||
for (; run > 0; run--) {
|
||||
if (colour && y < icon.h) {
|
||||
image.data.set(colour, (y * icon.w + x) * 4);
|
||||
}
|
||||
if (++x === icon.w) {
|
||||
x = 0;
|
||||
y++;
|
||||
}
|
||||
}
|
||||
}
|
||||
context.putImageData(image, 0, 0);
|
||||
};
|
||||
|
||||
let previewShown = null; // what the preview shows, to change only what changed
|
||||
let denTimer = null;
|
||||
const showPreview = () => {
|
||||
const entry = chosen;
|
||||
const note = text => {
|
||||
$("preview-note").textContent = text;
|
||||
};
|
||||
const only = id => {
|
||||
for (const one of ["preview-icon", "preview-art", "preview-den"]) {
|
||||
$(one).hidden = one !== id;
|
||||
}
|
||||
};
|
||||
if (entry.art) {
|
||||
if (previewShown !== entry.art) {
|
||||
previewShown = entry.art;
|
||||
only("preview-art");
|
||||
note("");
|
||||
$("preview-art").src = entry.art;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (entry.kind === "clothing") {
|
||||
const colours = slots.map(slot => slot.picker.value);
|
||||
const icon = icons.get(entry.id);
|
||||
if (icon === undefined) {
|
||||
only(null);
|
||||
note("Loading…");
|
||||
icons.set(entry.id, false);
|
||||
fetch(`/account/art/clothing/${entry.id}`).then(response => (response.ok ? response.json() : null)).catch(() => null).then(found => {
|
||||
icons.set(entry.id, found ? {w: found.w, h: found.h, bytes: Uint8Array.from(atob(found.b), letter => letter.charCodeAt(0))} : null);
|
||||
if (chosen === entry) {
|
||||
showPreview();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (icon) {
|
||||
only("preview-icon");
|
||||
note("");
|
||||
paintIcon(icon, colours);
|
||||
}
|
||||
else if (icon === null) {
|
||||
only(null);
|
||||
note("No picture");
|
||||
}
|
||||
previewShown = null;
|
||||
return;
|
||||
}
|
||||
const wanted = new URLSearchParams({id: entry.id, v: variant});
|
||||
if (entry.tintable && $("tint").checked) {
|
||||
wanted.set("tint", $("tint-picker").value.slice(1));
|
||||
wanted.set("s", $("tint-strength").value);
|
||||
}
|
||||
const address = `/account/item-preview#${wanted}`;
|
||||
if (previewShown === address) {
|
||||
return;
|
||||
}
|
||||
previewShown = address;
|
||||
only("preview-den");
|
||||
note("");
|
||||
// a new player each time: a slider dragged waits for it to stop
|
||||
clearTimeout(denTimer);
|
||||
denTimer = setTimeout(() => {
|
||||
$("preview-den").src = address;
|
||||
}, $("preview-den").src ? 250 : 0);
|
||||
};
|
||||
|
||||
// what Give would give, said beside it.
|
||||
function showChoice() {
|
||||
for (const [index, button] of [...$("presets").children].entries()) {
|
||||
button.setAttribute("aria-pressed", String(index === preset));
|
||||
}
|
||||
for (const button of $("variants").children) {
|
||||
button.setAttribute("aria-pressed", String(Number(button.dataset.variant) === variant));
|
||||
}
|
||||
if (!chosen) {
|
||||
return;
|
||||
}
|
||||
showPreview();
|
||||
if (chosen.kind === "clothing") {
|
||||
showWhole();
|
||||
const value = wholeValue();
|
||||
$("give-what").textContent = preset !== null ? `Its own colour ${preset + 1} (${value})`
|
||||
: value !== null ? `Colour ${value}` : `A new colour of ${slots.map(slot => slot.picker.value).join(" ")}`;
|
||||
}
|
||||
else {
|
||||
const parts = [chosen.variants.length ? `Variant ${chosen.variants.indexOf(variant) + 1}` : "As it is"];
|
||||
if (chosen.tintable && $("tint").checked) {
|
||||
parts.push(`tinted ${$("tint-picker").value} at ${$("tint-strength").value}%`);
|
||||
}
|
||||
$("give-what").textContent = parts.join(", ");
|
||||
}
|
||||
}
|
||||
|
||||
const choosePreset = index => {
|
||||
preset = index;
|
||||
applyWhole(chosen.presets[index].id, null, chosen.presets[index].colours);
|
||||
};
|
||||
|
||||
const choose = entry => {
|
||||
chosen = entry;
|
||||
$("detail").hidden = false;
|
||||
$("item-name").textContent = entry.name;
|
||||
$("item-meta").textContent = `${KINDS[entry.kind]} · id ${entry.id}${entry.cost ? ` · ${entry.cost} gems in shops` : ""}`;
|
||||
$("clothing-part").hidden = entry.kind !== "clothing";
|
||||
$("den-part").hidden = entry.kind !== "den";
|
||||
setStatus("give-status", "");
|
||||
if (entry.kind === "clothing") {
|
||||
$("presets").textContent = "";
|
||||
entry.presets.forEach((option, index) => {
|
||||
const button = document.createElement("button");
|
||||
button.type = "button";
|
||||
button.title = `Colour ${index + 1} (${option.id})`;
|
||||
button.append(option.colours ? swatches(option.colours) : String(index + 1));
|
||||
button.addEventListener("click", () => choosePreset(index));
|
||||
$("presets").append(button);
|
||||
});
|
||||
if (entry.presets.length) {
|
||||
choosePreset(0);
|
||||
}
|
||||
else {
|
||||
preset = null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$("variants").textContent = "";
|
||||
variant = entry.variants.length ? entry.variants[0] : 0;
|
||||
entry.variants.forEach((version, index) => {
|
||||
const button = document.createElement("button");
|
||||
button.type = "button";
|
||||
button.dataset.variant = String(version);
|
||||
button.title = `Variant ${index + 1}`;
|
||||
button.append(entry.variantColours ? swatches(entry.variantColours[index]) : String(index + 1));
|
||||
button.addEventListener("click", () => {
|
||||
variant = version;
|
||||
showChoice();
|
||||
});
|
||||
$("variants").append(button);
|
||||
});
|
||||
$("no-variants").hidden = entry.variants.length > 0;
|
||||
$("tint-on").hidden = !entry.tintable;
|
||||
$("tint-off").hidden = entry.tintable;
|
||||
$("tint").checked = false;
|
||||
}
|
||||
showChoice();
|
||||
$("detail").scrollIntoView({behavior: "smooth", block: "nearest"});
|
||||
};
|
||||
|
||||
const showResults = found => {
|
||||
const list = $("results");
|
||||
list.textContent = "";
|
||||
for (const entry of found.results) {
|
||||
const row = document.createElement("li");
|
||||
const button = document.createElement("button");
|
||||
button.type = "button";
|
||||
const name = document.createElement("span");
|
||||
name.className = "name";
|
||||
name.textContent = entry.name;
|
||||
const meta = document.createElement("span");
|
||||
meta.className = "meta";
|
||||
meta.textContent = `${KINDS[entry.kind]} · ${entry.id}`;
|
||||
button.append(name, meta);
|
||||
button.addEventListener("click", () => choose(entry));
|
||||
row.append(button);
|
||||
list.append(row);
|
||||
}
|
||||
setStatus("search-status", found.total === 0 ? "Nothing found." : found.total > found.results.length
|
||||
? `${found.total} found; the first ${found.results.length} shown. Type more to narrow it down.` : `${found.total} found.`);
|
||||
};
|
||||
|
||||
const showGate = (title, text) => {
|
||||
$("gate").hidden = false;
|
||||
$("finder").hidden = true;
|
||||
$("detail").hidden = true;
|
||||
$("gate-title").textContent = title;
|
||||
$("gate-text").textContent = text;
|
||||
};
|
||||
|
||||
let asked = 0;
|
||||
const search = async () => {
|
||||
const mine = ++asked;
|
||||
const result = await api(`giver?q=${encodeURIComponent($("query").value.trim())}&kind=${encodeURIComponent($("kind").value)}`);
|
||||
if (mine !== asked) {
|
||||
return;
|
||||
}
|
||||
if (result.status === 401) {
|
||||
showGate("Sign in first", "The item giver uses your account page's sign-in.");
|
||||
}
|
||||
else if (result.status === 403) {
|
||||
showGate("Not now", "The item giver is not open to this account at the moment. Your account page says why.");
|
||||
}
|
||||
else if (!result.ok) {
|
||||
setStatus("search-status", result.data.error || "That did not work.", true);
|
||||
}
|
||||
else {
|
||||
$("gate").hidden = true;
|
||||
$("finder").hidden = false;
|
||||
showResults(result.data);
|
||||
}
|
||||
};
|
||||
|
||||
let typing = null;
|
||||
$("query").addEventListener("input", () => {
|
||||
clearTimeout(typing);
|
||||
typing = setTimeout(search, 250);
|
||||
});
|
||||
$("kind").addEventListener("change", search);
|
||||
|
||||
$("give").addEventListener("click", async () => {
|
||||
if (!chosen) {
|
||||
return;
|
||||
}
|
||||
const body = {kind: chosen.kind, id: chosen.id};
|
||||
if (chosen.kind === "clothing") {
|
||||
const value = wholeValue();
|
||||
if (preset !== null) {
|
||||
body.colorIndex = preset;
|
||||
}
|
||||
else if (value !== null) {
|
||||
body.color = String(value);
|
||||
}
|
||||
else {
|
||||
body.color = slots.map(slot => slot.picker.value).join(" ");
|
||||
}
|
||||
}
|
||||
else {
|
||||
body.version = variant;
|
||||
if (chosen.tintable && $("tint").checked) {
|
||||
body.tint = $("tint-picker").value;
|
||||
body.tintStrength = Number($("tint-strength").value);
|
||||
}
|
||||
}
|
||||
$("give").disabled = true;
|
||||
const result = await api("give", body);
|
||||
$("give").disabled = false;
|
||||
if (result.status === 401) {
|
||||
showGate("Sign in again", "Your account page's sign-in ended.");
|
||||
return;
|
||||
}
|
||||
if (!result.ok) {
|
||||
setStatus("give-status", result.data.error || "That did not work.", true);
|
||||
return;
|
||||
}
|
||||
const as = result.data.color !== undefined ? ` Its colour in the game: ${result.data.color}.` : result.data.version ? ` Its version in the game: ${result.data.version}.` : "";
|
||||
setStatus("give-status", `${chosen.name}: given. ${result.data.online ? "It is in your inventory in the game now." : "It is in your inventory next time you play."}${as}`);
|
||||
});
|
||||
|
||||
api("colour").then(result => {
|
||||
if (result.ok && result.data.palette) {
|
||||
palette = result.data.palette.map(colour => `#${colour}`);
|
||||
for (const slot of slots) {
|
||||
const place = palette.indexOf(slot.picker.value);
|
||||
setSlot(slot, slot.picker.value, slot.index !== null ? slot.index : place < 0 ? null : place);
|
||||
}
|
||||
showChoice();
|
||||
}
|
||||
else {
|
||||
for (const slot of slots) {
|
||||
slot.aj.disabled = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
api("me").then(result => {
|
||||
if (result.ok) {
|
||||
$("who").textContent = `Items go to ${result.data.username}.`;
|
||||
}
|
||||
});
|
||||
search();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+48
-5
@@ -454,6 +454,12 @@
|
||||
<div id="captcha"></div>
|
||||
<button class="primary" id="gate-button">Sign in</button>
|
||||
</form>
|
||||
<form id="discord-code-form" hidden>
|
||||
<p class="hint">Discord confirmed who you are. Enter your 2FA code to finish signing in.</p>
|
||||
<label for="discord-code">2FA code</label>
|
||||
<input id="discord-code" inputmode="numeric" autocomplete="one-time-code" maxlength="20" spellcheck="false" required>
|
||||
<button class="primary" id="discord-code-button">Finish signing in</button>
|
||||
</form>
|
||||
<button type="button" id="discord-sign-in" hidden>Sign in with Discord</button>
|
||||
<p class="hint" id="discord-gate-hint" hidden>Use the Discord account linked to your active staff account.</p>
|
||||
<p class="status" id="gate-status" role="status"></p>
|
||||
@@ -1498,7 +1504,7 @@
|
||||
const tags = stateTags({...alt, silenced: 0, nameRejected: false, moderator: false, role: null, banned: alt.banned});
|
||||
stateCell.append(...(tags.length ? tags.flatMap(tag => [tag, " "]) : ["—"]));
|
||||
row.append(el("td", alt.username), stateCell,
|
||||
el("td", alt.devices.length ? `${alt.devices.map(kind => KIND_NAMES[kind] || kind).join(", ")}${alt.weak ? " (weak)" : ""}` : "—"),
|
||||
el("td", alt.devices.length ? `${alt.devices.map(kind => KIND_NAMES[kind] || kind).join(", ")}` : "—"),
|
||||
el("td", alt.addresses ? String(alt.addresses) : "—", "num"));
|
||||
row.addEventListener("click", () => openPlayer(alt.username));
|
||||
return row;
|
||||
@@ -2385,8 +2391,8 @@
|
||||
// moving), else drawn into a PNG that fits, smaller until it is small
|
||||
// enough. any picture this browser can open will do (WebP, AVIF, BMP...).
|
||||
// null when it cannot be read at all.
|
||||
const PICTURE_SIDE = 512;
|
||||
const PICTURE_BYTES = 300 * 1024;
|
||||
const PICTURE_SIDE = 256;
|
||||
const PICTURE_BYTES = 100 * 1024;
|
||||
const preparePicture = async file => {
|
||||
const kept = ["image/png", "image/jpeg", "image/gif"].includes(file.type);
|
||||
let image = null;
|
||||
@@ -2400,7 +2406,7 @@
|
||||
image.close();
|
||||
return file;
|
||||
}
|
||||
for (const side of [PICTURE_SIDE, 384, 256, 128]) {
|
||||
for (const side of [PICTURE_SIDE, 192, 128, 96]) {
|
||||
const scale = Math.min(1, side / image.width, side / image.height);
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = Math.max(1, Math.round(image.width * scale));
|
||||
@@ -3195,6 +3201,38 @@
|
||||
location.href = "/dashboard/staff/discord/login";
|
||||
});
|
||||
|
||||
// after Discord: the 2FA code, which opens the panel (POST discord/code)
|
||||
const showDiscordCode = message => {
|
||||
showGate(message);
|
||||
$("gate-form").hidden = true;
|
||||
$("discord-code-form").hidden = false;
|
||||
$("discord-sign-in").textContent = "Start again with Discord";
|
||||
$("discord-code").focus();
|
||||
};
|
||||
|
||||
$("discord-code-form").addEventListener("submit", async event => {
|
||||
event.preventDefault();
|
||||
$("discord-code-button").disabled = true;
|
||||
const result = await api("discord/code", {code: $("discord-code").value.trim()});
|
||||
$("discord-code-button").disabled = false;
|
||||
$("discord-code").value = "";
|
||||
if (result.ok) {
|
||||
history.replaceState(null, "", location.pathname + location.hash);
|
||||
$("discord-code-form").hidden = true;
|
||||
$("gate-form").hidden = false;
|
||||
showPanel(result.data.username);
|
||||
}
|
||||
else if (result.data.expired) {
|
||||
history.replaceState(null, "", location.pathname + location.hash);
|
||||
$("discord-code-form").hidden = true;
|
||||
$("gate-form").hidden = false;
|
||||
showGate(said(result));
|
||||
}
|
||||
else {
|
||||
setStatus($("gate-status"), said(result), true);
|
||||
}
|
||||
});
|
||||
|
||||
$("sign-out").addEventListener("click", async () => {
|
||||
await api("logout", {});
|
||||
showGate("");
|
||||
@@ -3215,7 +3253,12 @@
|
||||
discord: "Discord could not confirm that sign-in. Try again.",
|
||||
off: "Discord sign-in is not configured.",
|
||||
}[discordResult] || "";
|
||||
showGate(result.status === 0 ? result.data.error : discordMessage);
|
||||
if (discordResult === "code" && result.status !== 0) {
|
||||
showDiscordCode("");
|
||||
}
|
||||
else {
|
||||
showGate(result.status === 0 ? result.data.error : discordMessage);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -242,7 +242,7 @@
|
||||
|
||||
<section>
|
||||
<h2>7. Children</h2>
|
||||
<p>Burrow is for people aged 16 and over. 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}}.</p>
|
||||
<p>Burrow is for people aged 18 and over. 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}}.</p>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
|
||||
+2
-2
@@ -4,5 +4,5 @@
|
||||
<style>@font-face{font-family:d;src:url('/fonts/CCDigitalDelivery-Regular.otf')}*{box-sizing:border-box}body{margin:0;padding:48px 16px;background:#000;color:#fff;font:16px/1.45 d,system-ui}main{max-width:420px;margin:auto;padding:28px;background:#0d0d0d;border:1px solid #2e2e2e;border-radius:18px}.logo{height:62px}h1{font-size:25px;margin:10px 0}p,label{color:#aaa}label{display:block;margin:14px 0 5px}input,select,button{width:100%;font:inherit;color:#fff;background:#000;border:1px solid #444;border-radius:12px;padding:10px 12px}button{margin-top:20px;background:#fff;color:#000;font-weight:bold;cursor:pointer}.status{min-height:24px;margin:14px 0 0;color:#aaa}a{color:#fff}</style></head>
|
||||
<body><main><img class="logo" src="/logo.png" alt=""><h1>Account recovery</h1>
|
||||
<div id="request"><p>We’ll send a one-time recovery link to the email saved on your account.</p><form id="request-form"><label>Username<input id="username" autocomplete="username" required></label><label>Recovery email<input id="email" type="email" autocomplete="email" required></label><label>What do you need to recover?<select id="kind"><option value="password">Password</option><option value="twoStep">2FA</option></select></label><button>Send recovery link</button></form></div>
|
||||
<div id="complete" hidden><p id="intro"></p><form id="complete-form"><label id="password-label">New password<input id="password" type="password" autocomplete="new-password" minlength="10"></label><button>Complete recovery</button></form></div><p class="status" id="status" role="status"></p><p><a href="/account">Back to sign in</a></p></main>
|
||||
<script>"use strict";const $=id=>document.getElementById(id),token=new URLSearchParams(location.search).get('token');const post=async(path,body)=>{const r=await fetch(path,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(body)});return {ok:r.ok,data:await r.json()}};const status=(text)=>$('status').textContent=text;if(token){post('/account/api/recover/check',{token}).then(r=>{if(!r.ok){status(r.data.error);return}$('request').hidden=true;$('complete').hidden=false;const two=r.data.kind==='twoStep';$('intro').textContent=two?'Confirm that you want to remove 2FA from this account.':'Choose a new password.';$('password-label').hidden=two;$('password').required=!two}).catch(()=>status('The server did not answer.'))}$('request-form').addEventListener('submit',async e=>{e.preventDefault();const r=await post('/account/api/recover/request',{username:$('username').value,email:$('email').value,kind:$('kind').value});status(r.data.ok||'Could not start recovery.')});$('complete-form').addEventListener('submit',async e=>{e.preventDefault();const r=await post('/account/api/recover/complete',{token,password:$('password').value});status(r.data.ok||r.data.error||'Could not complete recovery.')});</script></body></html>
|
||||
<div id="complete" hidden><p id="intro"></p><form id="complete-form"><label id="password-label"><span id="password-text">New password</span><input id="password" type="password" autocomplete="new-password" minlength="10" required></label><button>Complete recovery</button></form></div><p class="status" id="status" role="status"></p><p><a href="/account">Back to sign in</a></p></main>
|
||||
<script>"use strict";const $=id=>document.getElementById(id),token=new URLSearchParams(location.search).get('token');const post=async(path,body)=>{const r=await fetch(path,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(body)});return {ok:r.ok,data:await r.json()}};const status=(text)=>$('status').textContent=text;if(token){post('/account/api/recover/check',{token}).then(r=>{if(!r.ok){status(r.data.error);return}$('request').hidden=true;$('complete').hidden=false;const two=r.data.kind==='twoStep';$('intro').textContent=two?'Enter your password to remove 2FA from this account.':'Choose a new password.';$('password-text').textContent=two?'Your password':'New password';$('password').autocomplete=two?'current-password':'new-password';$('password').minLength=two?1:10}).catch(()=>status('The server did not answer.'))}$('request-form').addEventListener('submit',async e=>{e.preventDefault();const r=await post('/account/api/recover/request',{username:$('username').value,email:$('email').value,kind:$('kind').value});status(r.data.ok||'Could not start recovery.')});$('complete-form').addEventListener('submit',async e=>{e.preventDefault();const r=await post('/account/api/recover/complete',{token,password:$('password').value});status(r.data.ok||r.data.error||'Could not complete recovery.')});</script></body></html>
|
||||
@@ -203,7 +203,7 @@
|
||||
<label for="email">Recovery email <span class="hint">Used only to recover your password or 2FA</span></label>
|
||||
<input id="email" name="email" type="email" autocomplete="email" maxlength="254" required>
|
||||
<label class="agree"><input id="agreed" name="agreed" type="checkbox" required>
|
||||
<span>I am 16 or older, and old enough in my country to agree to this myself. I agree to the <a href="/terms" target="_blank" rel="noopener">Terms of Service</a> and the <a href="/privacy" target="_blank" rel="noopener">Privacy Policy</a>.</span></label>
|
||||
<span>I am 18 or older, and old enough in my country to agree to this myself. I agree to the <a href="/terms" target="_blank" rel="noopener">Terms of Service</a> and the <a href="/privacy" target="_blank" rel="noopener">Privacy Policy</a>.</span></label>
|
||||
<div class="captcha" id="captcha"></div>
|
||||
<button class="primary" id="submit" type="submit">Create account</button>
|
||||
</form>
|
||||
|
||||
+2
-2
@@ -168,8 +168,8 @@
|
||||
<section>
|
||||
<h2>2. Who may play</h2>
|
||||
<ul>
|
||||
<li>You must be at least 16 years old.</li>
|
||||
<li>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.</li>
|
||||
<li>You must be at least 18 years old.</li>
|
||||
<li>If the law where you live sets a higher age for agreeing to the use of your personal data on your own, you must be at least that age.</li>
|
||||
<li>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.</li>
|
||||
</ul>
|
||||
<p>By creating an account you confirm that you meet these requirements and that you agree to these terms and to the <a href="/privacy">Privacy Policy</a>. We delete accounts that we learn belong to someone under the required age.</p>
|
||||
|
||||
+73
-28
@@ -1,5 +1,6 @@
|
||||
package
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import avatar.AvatarManager;
|
||||
import avatar.AvatarWorldView;
|
||||
import buddy.Buddy;
|
||||
@@ -1831,12 +1832,15 @@ package
|
||||
// 9004 Frame rate: 1 is 60; anything else is Max, as fast as the
|
||||
// timer goes (about 80 a second on the owner's machine, where
|
||||
// the 120 and 144 this once offered came to the same).
|
||||
// 9005 Camera: 1 Smooth (room.RoomManagerWorld.easeCamera), else the
|
||||
// game's own.
|
||||
// 9007 Performance profile: 1 Low-end, 2 High, unset Balanced. A
|
||||
// 9005 Camera: 2 the game's own, else Smooth
|
||||
// (room.RoomManagerWorld.easeCamera).
|
||||
// 9007 Performance profile: 1 Low-end, 3 Balanced, else (unset) High:
|
||||
// the best the game can look, which most machines manage. A
|
||||
// profile changes only optional rendering work, never the
|
||||
// game's native 24 FPS (which would slow its animations).
|
||||
// 9008 Play as your pet (gui.PetInventory, lib/pets.js): 1 on.
|
||||
// 9009 Expanded Inventory (expandedInventoryOn): 1 on.
|
||||
// 9010 Items a row with it on: 3, 4 or 5; unset is 5.
|
||||
|
||||
|
||||
private static var _smoothTimer:Timer;
|
||||
@@ -1871,12 +1875,13 @@ package
|
||||
return settingOf(9003) != 1;
|
||||
}
|
||||
|
||||
// 0 Balanced, 1 Low-end, 2 High. It is persisted with the other client
|
||||
// settings, so the preference follows the player to another computer.
|
||||
// 0 Balanced, 1 Low-end, 2 High (kept as 3, 1, and 2 or nothing). It
|
||||
// is persisted with the other client settings, so the preference
|
||||
// follows the player to another computer.
|
||||
public static function performanceProfile() : int
|
||||
{
|
||||
var _loc1_:int = settingOf(9007);
|
||||
return _loc1_ == 1 || _loc1_ == 2 ? _loc1_ : 0;
|
||||
return _loc1_ == 1 ? 1 : (_loc1_ == 3 ? 0 : 2);
|
||||
}
|
||||
|
||||
public static function performanceProfileLabel() : String
|
||||
@@ -1907,7 +1912,7 @@ package
|
||||
var _loc1_:Boolean = false;
|
||||
try
|
||||
{
|
||||
_loc1_ = smoothOn() && settingOf(9005) == 1;
|
||||
_loc1_ = smoothOn() && settingOf(9005) != 2;
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
@@ -2068,6 +2073,33 @@ package
|
||||
{
|
||||
return gMainFrame.userInfo.userVarCache.getUserVarValueById(9002) == 1;
|
||||
}
|
||||
|
||||
// "Expanded Inventory" (Strawberry Jam's): the clothes and item
|
||||
// pickers show more, smaller items a row. user var 9009, 1 on; the
|
||||
// + and - by the avatar editor's item counter pick 3, 4 or 5 a row,
|
||||
// user var 9010 (unset is 5, the widest, so turning it on shows).
|
||||
public static function expandedInventoryOn() : Boolean
|
||||
{
|
||||
return settingOf(9009) == 1;
|
||||
}
|
||||
|
||||
public static function inventoryColumns() : int
|
||||
{
|
||||
var _loc1_:int = settingOf(9010);
|
||||
if(!expandedInventoryOn())
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
return _loc1_ >= 3 && _loc1_ <= 5 ? _loc1_ : 5;
|
||||
}
|
||||
|
||||
// the next of 3, 4 and 5 a row, round about; param1 is 1 or -1.
|
||||
public static function stepInventoryColumns(param1:int) : void
|
||||
{
|
||||
var _loc2_:int = (inventoryColumns() - 3 + param1 + 3) % 3 + 3;
|
||||
gMainFrame.userInfo.userVarCache.updateUserVar(9010,_loc2_);
|
||||
AchievementXtCommManager.requestSetUserVar(9010,_loc2_);
|
||||
}
|
||||
|
||||
// the arrow key a key stands for: itself, or with the setting on and
|
||||
// nothing being typed, the arrow W, A, S or D stands for.
|
||||
@@ -3470,7 +3502,6 @@ package
|
||||
|
||||
private var _emojiCaret:int = -1;
|
||||
|
||||
private var _emojiTimer:Timer;
|
||||
|
||||
// the characters of code points in hex ("1f468-200d-1f469")
|
||||
public static function charsOfHex(param1:String) : String
|
||||
@@ -3512,7 +3543,8 @@ package
|
||||
|
||||
// a line about to be sent: each ":name:" of an emoji above becomes it,
|
||||
// but not the game's own emote codes (":happy:", ":joy:"), which the
|
||||
// bubble shows as the game's.
|
||||
// bubble shows as the game's, nor one after a "\" ("\:fire:"), which
|
||||
// the bubble shows as typed (ChatBalloon.inlineEmotes).
|
||||
public static function emojiShortcodes(param1:String) : String
|
||||
{
|
||||
if(param1.indexOf(":") == -1)
|
||||
@@ -3520,13 +3552,13 @@ package
|
||||
return param1;
|
||||
}
|
||||
emojiTable();
|
||||
return param1.replace(/:([a-z0-9_]{1,30}):/g,function(param1:String, param2:String, ... rest):String
|
||||
return param1.replace(/(\\?):([a-z0-9_]{1,30}):/g,function(param1:String, param2:String, param3:String, ... rest):String
|
||||
{
|
||||
if(EmoticonUtility.doesStringMatchAnEmote(param1) || _emojiByName[param2] == null)
|
||||
if(param2 != "" || EmoticonUtility.doesStringMatchAnEmote(":" + param3 + ":") || _emojiByName[param3] == null)
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
return _emojiByName[param2];
|
||||
return _emojiByName[param3];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4072,9 +4104,9 @@ package
|
||||
|
||||
private function startEmojiButton() : void
|
||||
{
|
||||
_emojiTimer = new Timer(500);
|
||||
_emojiTimer.addEventListener("timer",placeEmojiButton);
|
||||
_emojiTimer.start();
|
||||
// every frame: on a timer it went a moment after the HUD did, when
|
||||
// a window opened over it
|
||||
gMainFrame.stage.addEventListener("enterFrame",placeEmojiButton,false,0,true);
|
||||
gMainFrame.stage.addEventListener("mouseDown",onEmojiStageDown,false,0,true);
|
||||
}
|
||||
|
||||
@@ -4523,7 +4555,7 @@ package
|
||||
_loc3_.currTxt.text = (_loc5_ ? "> " : "") + makerShort(String(_loc4_.name || "(no name)"),24) + (_makerMode == "mine" ? (_loc4_.waiting == "item" ? " (waiting)" : _loc4_.waiting == "picture" ? " (picture waiting)" : _loc4_.art ? (_loc4_.kind == "clothing" ? (_loc4_.artMode == "texture" ? " (texture)" : " (sticker)") : " (picture)") : "") : " #" + _loc4_.id);
|
||||
_loc3_.addEventListener("mouseDown",onMakerButton);
|
||||
_makerRowsSprite.addChild(_loc3_);
|
||||
_makerRowsSprite.addChild(finderPreview(_loc4_,_loc2_,186,_loc3_.y));
|
||||
_makerRowsSprite.addChild(finderPreview(_loc4_,_loc2_,186,_loc3_.y,false));
|
||||
_loc2_++;
|
||||
}
|
||||
if(_makerMode == "mine" && _loc1_.length == 0)
|
||||
@@ -4719,9 +4751,9 @@ package
|
||||
// the picture read: sent as it is when the server takes it so (a PNG,
|
||||
// JPEG or GIF small enough, or a BMP, which the server makes a PNG); one
|
||||
// too big is drawn smaller here and sent as a PNG.
|
||||
private static const MAKER_PICTURE_SIDE:int = 512;
|
||||
private static const MAKER_PICTURE_SIDE:int = 256;
|
||||
|
||||
private static const MAKER_PICTURE_BYTES:int = 300 * 1024;
|
||||
private static const MAKER_PICTURE_BYTES:int = 100 * 1024;
|
||||
|
||||
private function onMakerPictureRead(param1:Event) : void
|
||||
{
|
||||
@@ -4761,7 +4793,7 @@ package
|
||||
private static function shrunkPng(param1:BitmapData) : ByteArray
|
||||
{
|
||||
var _loc2_:ByteArray = null;
|
||||
for each(var _loc3_:int in [MAKER_PICTURE_SIDE,384,256,128])
|
||||
for each(var _loc3_:int in [MAKER_PICTURE_SIDE,192,128,96])
|
||||
{
|
||||
var _loc4_:Number = Math.min(1,_loc3_ / param1.width,_loc3_ / param1.height);
|
||||
var _loc5_:BitmapData = new BitmapData(Math.max(1,Math.round(param1.width * _loc4_)),Math.max(1,Math.round(param1.height * _loc4_)),true,0);
|
||||
@@ -5190,6 +5222,17 @@ package
|
||||
return _loc4_;
|
||||
}
|
||||
|
||||
// the item's own colour that a row is on (param1.colorIndex), or 0
|
||||
private function itemOwnColour(param1:Object) : uint
|
||||
{
|
||||
var _loc2_:Object = ItemXtCommManager.getItemDef(int(param1.id));
|
||||
if(_loc2_ == null || _loc2_.colors == null || _loc2_.colors.length == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return uint(_loc2_.colors[Math.min(int(param1.colorIndex),_loc2_.colors.length - 1)]);
|
||||
}
|
||||
|
||||
// the colour a clothing row is drawn in: the box's colour id or hex
|
||||
// colour, else the item's own colour that the row is on
|
||||
private function finderPreviewColour(param1:Object) : uint
|
||||
@@ -5218,16 +5261,15 @@ package
|
||||
// a negative id is the same colour written signed
|
||||
return uint(Number(_loc2_));
|
||||
}
|
||||
_loc4_ = ItemXtCommManager.getItemDef(int(param1.id));
|
||||
if(_loc4_ == null || _loc4_.colors == null || _loc4_.colors.length == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return uint(_loc4_.colors[Math.min(int(param1.colorIndex),_loc4_.colors.length - 1)]);
|
||||
return itemOwnColour(param1);
|
||||
}
|
||||
|
||||
// the row's item as the game draws it in a shop, in a box at the row's end
|
||||
private function finderPreview(param1:Object, param2:int, param3:Number, param4:Number) : Sprite
|
||||
// param5: a row of the item giver's, drawn in its colour box's colour
|
||||
// and recoloured as that changes. the Item Maker's rows are drawn by
|
||||
// this too, in the item's own colour: the giver's box coloured them,
|
||||
// and its colour turned up in the maker.
|
||||
private function finderPreview(param1:Object, param2:int, param3:Number, param4:Number, param5:Boolean = true) : Sprite
|
||||
{
|
||||
var _loc5_:Sprite = new Sprite();
|
||||
var _loc6_:Sprite = new Sprite();
|
||||
@@ -5267,7 +5309,7 @@ package
|
||||
return _loc5_;
|
||||
}
|
||||
_loc8_ = new Item();
|
||||
Item(_loc8_).init(int(param1.id),0,finderPreviewColour(param1),null,true);
|
||||
Item(_loc8_).init(int(param1.id),0,param5 ? finderPreviewColour(param1) : itemOwnColour(param1),null,true);
|
||||
}
|
||||
// fitted to the box once drawn, which may be before the icon is
|
||||
// handed back when its picture was loaded already
|
||||
@@ -5293,7 +5335,10 @@ package
|
||||
_loc8_.imageLoadedCallback();
|
||||
}
|
||||
}
|
||||
_finderIcons[param2] = _loc8_;
|
||||
if(param5)
|
||||
{
|
||||
_finderIcons[param2] = _loc8_;
|
||||
}
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
|
||||
+234
-4
@@ -38,6 +38,8 @@ package gui
|
||||
import flash.events.MouseEvent;
|
||||
import flash.geom.Matrix;
|
||||
import flash.geom.Point;
|
||||
import flash.text.TextField;
|
||||
import flash.text.TextFormat;
|
||||
import gui.itemWindows.ItemWindowNameBarIcon;
|
||||
import gui.itemWindows.ItemWindowOriginal;
|
||||
import inventory.Iitem;
|
||||
@@ -222,6 +224,17 @@ package gui
|
||||
private var _colorTableColor2:ColorTable;
|
||||
|
||||
private var _colorTablePatterns:ColorTable;
|
||||
|
||||
// a special animal's pattern has four colours, a byte each of its
|
||||
// colour number (its presets set all four; LayerBitmap draws them and
|
||||
// the blends between them): the tables of the second, third and
|
||||
// fourth, each shown in place of the first's while its number beside
|
||||
// them is chosen
|
||||
private var _patternColorTables:Array;
|
||||
|
||||
private var _patternColorBtns:Array;
|
||||
|
||||
private var _patternColorSlot:int;
|
||||
|
||||
private var _colorTableEyes:ColorTable;
|
||||
|
||||
@@ -242,6 +255,10 @@ package gui
|
||||
private var _itemClothingWindows:WindowAndScrollbarGenerator;
|
||||
|
||||
private var _itemTradeWindows:WindowAndScrollbarGenerator;
|
||||
|
||||
private var _inventoryPlusBtn:Sprite;
|
||||
|
||||
private var _inventoryMinusBtn:Sprite;
|
||||
|
||||
public var numClothingItemsInTradeListInitially:int;
|
||||
|
||||
@@ -428,6 +445,15 @@ package gui
|
||||
_colorTableColor1.destroy();
|
||||
_colorTableColor2.destroy();
|
||||
_colorTablePatterns.destroy();
|
||||
for each(var _loc9_:ColorTable in _patternColorTables)
|
||||
{
|
||||
if(_loc9_ != _colorTablePatterns)
|
||||
{
|
||||
_loc9_.destroy();
|
||||
}
|
||||
}
|
||||
_patternColorTables = null;
|
||||
_patternColorBtns = null;
|
||||
_colorTableEyes.destroy();
|
||||
_namebarBadgeMediaIds = null;
|
||||
_nameBars = null;
|
||||
@@ -549,6 +575,7 @@ package gui
|
||||
{
|
||||
createItemWindows(_currClothesArray,avEditor.itemBlock);
|
||||
}
|
||||
setupInventoryControls();
|
||||
addListeners();
|
||||
KeepAlive.startKATimer(avEditor);
|
||||
_loadingMediaHelper.destroy();
|
||||
@@ -615,6 +642,17 @@ package gui
|
||||
_colorTableColor2.init(1,240,150,10,5,_gamePalette,_avatarPalette2,_loc10_,onColorChanged,102);
|
||||
_colorTablePatterns = new ColorTable();
|
||||
_colorTablePatterns.init(3,240,150,10,5,_gamePalette,_avatarPalette1,_loc8_,onColorChanged,102);
|
||||
_patternColorTables = [_colorTablePatterns];
|
||||
var _loc13_:int = 1;
|
||||
while(_loc13_ < 4)
|
||||
{
|
||||
_patternColorTables[_loc13_] = new ColorTable();
|
||||
ColorTable(_patternColorTables[_loc13_]).init(3 + _loc13_,240,150,10,5,_gamePalette,_avatarPalette1,_loc2_[1] >> 24 - _loc13_ * 8 & 0xFF,onColorChanged,102);
|
||||
ColorTable(_patternColorTables[_loc13_]).x = 21;
|
||||
ColorTable(_patternColorTables[_loc13_]).y = 176;
|
||||
_loc13_++;
|
||||
}
|
||||
_patternColorSlot = 0;
|
||||
_colorTableEyes = new ColorTable();
|
||||
_colorTableEyes.init(2,240,150,10,5,_gamePalette,_avatarPalette1,_loc5_,onColorChanged,102);
|
||||
_colorTableColor1.x = 21;
|
||||
@@ -909,9 +947,16 @@ package gui
|
||||
_loc9_ = _loc6_ >> 8 & 0xFF;
|
||||
_loc3_ = _loc6_ & 0xFF;
|
||||
_loc6_ = uint(_loc5_ << 24 | _loc7_ << 16 | _loc9_ << 8 | _loc3_);
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
// a special animal's pattern's second, third or fourth colour
|
||||
_loc5_ = 24 - (param1 - 3) * 8;
|
||||
_loc6_ = uint(_loc6_ & ~(0xFF << _loc5_) | (param2 & 0xFF) << _loc5_);
|
||||
}
|
||||
_avatarEditorView.colors = [_loc4_,_loc6_,_loc8_];
|
||||
if(param1 == 2 || param1 == 3)
|
||||
if(param1 >= 2)
|
||||
{
|
||||
colorCurrEyePattIcon();
|
||||
}
|
||||
@@ -1256,6 +1301,7 @@ package gui
|
||||
avEditor.colorTableBlock.patternsAndEyes.removeChild(_colorTableEyes);
|
||||
}
|
||||
avEditor.colorTableBlock.patternsAndEyes.addChild(_colorTablePatterns);
|
||||
showPatternColorChoice(_worldAvatar.customAvId != -1);
|
||||
if(_patterns.length > 0)
|
||||
{
|
||||
if(_patterns.length <= 1 && _worldAvatar.customAvId == -1)
|
||||
@@ -1286,6 +1332,7 @@ package gui
|
||||
{
|
||||
avEditor.colorTableBlock.patternsAndEyes.removeChild(_colorTablePatterns);
|
||||
}
|
||||
showPatternColorChoice(false);
|
||||
if(_customAvtIcon && avEditor.colorTableBlock.patternsAndEyes.specialAvtIconCont.contains(_customAvtIcon))
|
||||
{
|
||||
avEditor.colorTableBlock.patternsAndEyes.specialAvtIconCont.removeChild(_customAvtIcon);
|
||||
@@ -1316,6 +1363,77 @@ package gui
|
||||
avEditor.colorTableBlock.colors.visible = false;
|
||||
}
|
||||
|
||||
// the "1" to "4" left of the pattern's colour table, choosing which of
|
||||
// its four colours it sets, with that colour's table (param1), or
|
||||
// neither, and the first's table back
|
||||
private function showPatternColorChoice(param1:Boolean) : void
|
||||
{
|
||||
var _loc2_:MovieClip = avEditor.colorTableBlock.patternsAndEyes;
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Sprite = null;
|
||||
if(_patternColorBtns == null)
|
||||
{
|
||||
_patternColorBtns = [];
|
||||
while(_loc3_ < 4)
|
||||
{
|
||||
_loc4_ = createSmallButton(String(_loc3_ + 1));
|
||||
_loc4_.name = "patternColor" + _loc3_;
|
||||
_loc4_.x = 2;
|
||||
_loc4_.y = 176 + _loc3_ * 20;
|
||||
_loc4_.addEventListener("mouseDown",onPatternColorBtn,false,0,true);
|
||||
_patternColorBtns.push(_loc4_);
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _patternColorBtns.length)
|
||||
{
|
||||
_loc4_ = _patternColorBtns[_loc3_];
|
||||
if(param1)
|
||||
{
|
||||
_loc2_.addChild(_loc4_);
|
||||
_loc4_.alpha = _loc3_ == _patternColorSlot ? 1 : 0.45;
|
||||
}
|
||||
else if(_loc4_.parent)
|
||||
{
|
||||
_loc4_.parent.removeChild(_loc4_);
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
// the first's table is added and taken away with the tab
|
||||
_loc3_ = 1;
|
||||
while(_loc3_ < _patternColorTables.length)
|
||||
{
|
||||
if(_loc2_.contains(_patternColorTables[_loc3_]))
|
||||
{
|
||||
_loc2_.removeChild(_patternColorTables[_loc3_]);
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
if(param1)
|
||||
{
|
||||
if(_patternColorSlot == 0)
|
||||
{
|
||||
_loc2_.addChild(_colorTablePatterns);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_loc2_.contains(_colorTablePatterns))
|
||||
{
|
||||
_loc2_.removeChild(_colorTablePatterns);
|
||||
}
|
||||
_loc2_.addChild(_patternColorTables[_patternColorSlot]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onPatternColorBtn(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
_patternColorSlot = int(Sprite(param1.currentTarget).name.charAt(12));
|
||||
showPatternColorChoice(true);
|
||||
}
|
||||
|
||||
private function onCustomIconLoaded(param1:MovieClip) : void
|
||||
{
|
||||
if(_avatarEditorView)
|
||||
@@ -1920,6 +2038,7 @@ package gui
|
||||
var _loc7_:Boolean = false;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc5_:Object = null;
|
||||
var _loc9_:int = 0;
|
||||
_loc6_ = param1 == _currTradesArray;
|
||||
if(_loc6_)
|
||||
{
|
||||
@@ -1979,7 +2098,9 @@ package gui
|
||||
}
|
||||
_loc5_ = generateItemAndIndexArray(param1);
|
||||
_loc8_ = new WindowAndScrollbarGenerator();
|
||||
_loc8_.init(param2.width,param2.height,3,_loc4_,3,4,12,2,2,2 * 0.5,0,ItemWindowOriginal,_loc5_.items,"icon",0,{
|
||||
// Expanded Inventory: more, smaller items a row (AJClient.inventoryColumns)
|
||||
_loc9_ = AJClient.inventoryColumns();
|
||||
_loc8_.init(param2.width,param2.height,3,_loc4_,_loc9_,4,_loc9_ * 4,2,2,2 * 0.5,0,ItemWindowOriginal,_loc5_.items,"icon",0,{
|
||||
"mouseDown":winMouseClick,
|
||||
"mouseOver":winMouseOver,
|
||||
"mouseOut":winMouseOut,
|
||||
@@ -1990,7 +2111,8 @@ package gui
|
||||
"showAddRemoveBtns":_loc6_,
|
||||
"isChoosingForTradeList":_loc7_,
|
||||
"indexArray":_loc5_.indexes,
|
||||
"mannequinInvIdx":(_mannequinDenItemHelper != null ? _mannequinDenItemHelper.mannequin.invIdx : -1)
|
||||
"mannequinInvIdx":(_mannequinDenItemHelper != null ? _mannequinDenItemHelper.mannequin.invIdx : -1),
|
||||
"itemScale":3 / _loc9_
|
||||
});
|
||||
if(param2 == avEditor.itemBlock)
|
||||
{
|
||||
@@ -2201,6 +2323,15 @@ package gui
|
||||
if(!DenAndClothesItemSelect.moreToCome)
|
||||
{
|
||||
openCloseTradeWindow();
|
||||
// the list drawn again with all of it: each item added went into
|
||||
// an empty window of the list, and with many picked at once
|
||||
// there were too few of those, so the rest were not shown
|
||||
if(_itemTradeWindows && avEditor.tradeBtnUp.visible)
|
||||
{
|
||||
_itemTradeWindows.destroy();
|
||||
_itemTradeWindows = null;
|
||||
createItemWindows(_currTradesArray,avEditor.itemBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2656,7 +2787,106 @@ package gui
|
||||
avEditor.sortPopup.visible = false;
|
||||
createItemWindows(_currClothesArray,avEditor.itemBlock);
|
||||
}
|
||||
|
||||
|
||||
// Expanded Inventory's + and - (Strawberry Jam's), by the item counter:
|
||||
// 3, 4 or 5 items a row (AJClient.inventoryColumns). they are put in
|
||||
// the counter, where Strawberry Jam puts them by it, so they are shown
|
||||
// and hidden with it.
|
||||
private function setupInventoryControls() : void
|
||||
{
|
||||
var _loc1_:MovieClip = null;
|
||||
var _loc2_:Point = null;
|
||||
if(_inventoryPlusBtn && _inventoryPlusBtn.parent)
|
||||
{
|
||||
_inventoryPlusBtn.parent.removeChild(_inventoryPlusBtn);
|
||||
}
|
||||
if(_inventoryMinusBtn && _inventoryMinusBtn.parent)
|
||||
{
|
||||
_inventoryMinusBtn.parent.removeChild(_inventoryMinusBtn);
|
||||
}
|
||||
_inventoryPlusBtn = null;
|
||||
_inventoryMinusBtn = null;
|
||||
if(!AJClient.expandedInventoryOn() || !avEditor || !("itemCounter" in avEditor) || !avEditor.itemCounter)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_loc1_ = avEditor.itemCounter;
|
||||
_loc2_ = _loc1_.globalToLocal(avEditor.localToGlobal(new Point(_loc1_.x + _loc1_.counterTxt.width - 30,_loc1_.y - 7)));
|
||||
_inventoryPlusBtn = createSmallButton("+");
|
||||
_inventoryMinusBtn = createSmallButton("-");
|
||||
_inventoryPlusBtn.x = _loc2_.x;
|
||||
_inventoryPlusBtn.y = _loc2_.y;
|
||||
_inventoryMinusBtn.x = _loc2_.x + 18;
|
||||
_inventoryMinusBtn.y = _loc2_.y;
|
||||
_inventoryPlusBtn.addEventListener("mouseDown",onInventoryPlus,false,0,true);
|
||||
_inventoryMinusBtn.addEventListener("mouseDown",onInventoryMinus,false,0,true);
|
||||
_loc1_.addChild(_inventoryPlusBtn);
|
||||
_loc1_.addChild(_inventoryMinusBtn);
|
||||
}
|
||||
|
||||
private function createSmallButton(param1:String) : Sprite
|
||||
{
|
||||
var _loc2_:Sprite = new Sprite();
|
||||
var _loc3_:TextField = new TextField();
|
||||
_loc2_.graphics.beginFill(3355443,0.8);
|
||||
_loc2_.graphics.drawRoundRect(0,0,16,16,3,3);
|
||||
_loc2_.graphics.endFill();
|
||||
_loc2_.graphics.lineStyle(1,16777215,0.5);
|
||||
_loc2_.graphics.drawRoundRect(0,0,16,16,3,3);
|
||||
_loc3_.defaultTextFormat = new TextFormat("_sans",12,16777215,true);
|
||||
_loc3_.text = param1;
|
||||
_loc3_.x = 4;
|
||||
_loc3_.y = 1;
|
||||
_loc3_.width = 12;
|
||||
_loc3_.height = 16;
|
||||
_loc3_.selectable = false;
|
||||
_loc3_.mouseEnabled = false;
|
||||
_loc2_.addChild(_loc3_);
|
||||
_loc2_.buttonMode = true;
|
||||
_loc2_.mouseChildren = false;
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
private function onInventoryPlus(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
stepInventoryColumns(1);
|
||||
}
|
||||
|
||||
private function onInventoryMinus(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
stepInventoryColumns(-1);
|
||||
}
|
||||
|
||||
private function stepInventoryColumns(param1:int) : void
|
||||
{
|
||||
AJClient.stepInventoryColumns(param1);
|
||||
refreshInventoryLayout();
|
||||
}
|
||||
|
||||
// the clothes drawn again as many a row as now asked for, and the + and
|
||||
// - put up or taken away (also when Settings turns the switch). only
|
||||
// while the clothes are shown (the counter is, then): the trade list's
|
||||
// windows take the new count when they are next made.
|
||||
public function refreshInventoryLayout() : void
|
||||
{
|
||||
if(!avEditor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(_itemClothingWindows && "itemCounter" in avEditor && avEditor.itemCounter && avEditor.itemCounter.visible)
|
||||
{
|
||||
_itemClothingWindows.destroy();
|
||||
_itemClothingWindows = null;
|
||||
if(_currClothesArray)
|
||||
{
|
||||
createItemWindows(_currClothesArray,avEditor.itemBlock);
|
||||
}
|
||||
}
|
||||
setupInventoryControls();
|
||||
}
|
||||
|
||||
private static function sortByName(param1:Object, param2:Object) : int
|
||||
{
|
||||
var _loc3_:String = String(param1.name).toLowerCase();
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -229,6 +229,11 @@ package avatar
|
||||
|
||||
private var _chatBalloon:ChatBalloon;
|
||||
|
||||
// Set while the normal uc packet is handled, immediately before its
|
||||
// message is drawn. Keeping setMessage's original arguments preserves
|
||||
// the game's pending-message and chat-history behaviour.
|
||||
private var _nextChatStyle:String = "";
|
||||
|
||||
// "..." where the chat bubble goes, while the player is typing
|
||||
// (AJClient.onTyping). gone when a line arrives, when they stop, or
|
||||
// TYPING_SHOWN ms after they last said they were, if a "stopped" is lost.
|
||||
@@ -805,9 +810,34 @@ package avatar
|
||||
return false;
|
||||
}
|
||||
|
||||
// plays an animation and keeps it as this avatar's idle, so the client's
|
||||
// own idle refreshes don't put the avatar back to standing. Walking or
|
||||
// an action replaces it, as with any idle.
|
||||
public function holdIdleAnim(param1:int, param2:Boolean) : void
|
||||
{
|
||||
_lastIdleAnim = param1;
|
||||
_lastIdleFlip = param2;
|
||||
playAnim(param1,param2);
|
||||
}
|
||||
|
||||
public function getBaseIdle() : int
|
||||
{
|
||||
return _roomType == 1 ? 32 : 14;
|
||||
return drawnSwimming() ? 32 : 14;
|
||||
}
|
||||
|
||||
// whether the animal is drawn with its swimming animations: the
|
||||
// room's kind when it has art for both, else the one it has. a land
|
||||
// animal in water (or a sea one on land) asked for art it has none of,
|
||||
// and stood invisible until it did something it had art for.
|
||||
private function drawnSwimming() : Boolean
|
||||
{
|
||||
var _loc1_:Boolean = _avatar == null || Utility.isLand(_avatar.enviroTypeFlag);
|
||||
var _loc2_:Boolean = _avatar == null || Utility.isOcean(_avatar.enviroTypeFlag);
|
||||
if(_loc1_ == _loc2_)
|
||||
{
|
||||
return _roomType == 1;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function setPath(param1:Array) : void
|
||||
@@ -1166,6 +1196,11 @@ package avatar
|
||||
}
|
||||
}
|
||||
|
||||
public function setChatStyle(param1:String) : void
|
||||
{
|
||||
_nextChatStyle = param1;
|
||||
}
|
||||
|
||||
public function setMessage(param1:String, param2:int) : void
|
||||
{
|
||||
var _loc3_:Boolean = false;
|
||||
@@ -1181,8 +1216,9 @@ package avatar
|
||||
}
|
||||
_loc3_ = true;
|
||||
}
|
||||
_chatBalloon.setText(param1,_loc3_);
|
||||
updateOffScreenChat(param1,_loc3_);
|
||||
_chatBalloon.setText(param1,_loc3_,true,_nextChatStyle);
|
||||
updateOffScreenChat(param1,_loc3_,_nextChatStyle);
|
||||
_nextChatStyle = "";
|
||||
}
|
||||
|
||||
public function setCustomAdventureMessage(param1:String, param2:String, param3:int, param4:int, param5:Boolean = false) : void
|
||||
@@ -2583,11 +2619,11 @@ package avatar
|
||||
_secondaryEmot.y = -235 * _loc1_;
|
||||
}
|
||||
|
||||
private function updateOffScreenChat(param1:String, param2:Boolean) : void
|
||||
private function updateOffScreenChat(param1:String, param2:Boolean, param3:String = "") : void
|
||||
{
|
||||
if(shouldShowOffscreen() && gMainFrame.userInfo.myUserName != _avatar.userName && _hudViewHolder)
|
||||
{
|
||||
_hudViewHolder.questChatBalloon.setText(param1,param2,false);
|
||||
_hudViewHolder.questChatBalloon.setText(param1,param2,false,param3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2611,7 +2647,7 @@ package avatar
|
||||
_lastMoveAngle = _loc7_;
|
||||
var _loc8_:Object = convertToIdle(_lastMoveAngle);
|
||||
_lastIdleAnim = _loc8_.anim;
|
||||
if(_roomType == 1)
|
||||
if(drawnSwimming())
|
||||
{
|
||||
_lastIdleAnim = getBaseIdle();
|
||||
}
|
||||
@@ -2678,7 +2714,7 @@ package avatar
|
||||
_loc9_ = 14;
|
||||
}
|
||||
}
|
||||
if(_roomType == 1)
|
||||
if(drawnSwimming())
|
||||
{
|
||||
_loc9_ = 29;
|
||||
}
|
||||
@@ -2771,7 +2807,7 @@ package avatar
|
||||
public function preload(param1:Function) : void
|
||||
{
|
||||
var _loc2_:Array = [];
|
||||
if(_roomType == 1)
|
||||
if(drawnSwimming())
|
||||
{
|
||||
_loc2_.push(29);
|
||||
_loc2_.push(32);
|
||||
|
||||
@@ -133,6 +133,11 @@ package buddy
|
||||
|
||||
private var _joinLabel:Sprite;
|
||||
|
||||
// the animal's box as the card's art has it, measured before an animal
|
||||
// is put in it: measured with one in, a tall animal (or the one still
|
||||
// there from the card's last opening) put the label up on the name
|
||||
private var _charBoxRect:Rectangle;
|
||||
|
||||
private var _badgeRow:Sprite;
|
||||
|
||||
private var _discordIcon:Sprite;
|
||||
@@ -829,6 +834,7 @@ package buddy
|
||||
_bioMediaHelper = new MediaHelper();
|
||||
_bioMediaHelper.init(BIO_TAB_MEDIA_ID,onBioTabLoaded);
|
||||
charBox = _buddyCardMC.charBox;
|
||||
_charBoxRect = charBox.getBounds(_buddyCardMC);
|
||||
userNameTxt = _buddyCardMC.userName_txt;
|
||||
avatarNameTxt = _buddyCardMC.avatarNameTxt;
|
||||
shamanTag = _buddyCardMC.shamanTag;
|
||||
@@ -993,7 +999,7 @@ package buddy
|
||||
}
|
||||
_joinLabel = AJClient.makePill(_loc3_,9067051,6044183,false,11);
|
||||
_joinLabel.mouseEnabled = false;
|
||||
_loc2_ = charBox.getBounds(_buddyCardMC);
|
||||
_loc2_ = _charBoxRect != null ? _charBoxRect : charBox.getBounds(_buddyCardMC);
|
||||
_joinLabel.x = int(_loc2_.right - _joinLabel.width - 8);
|
||||
_joinLabel.y = int(_loc2_.top + 8);
|
||||
_buddyCardMC.addChild(_joinLabel);
|
||||
|
||||
@@ -167,7 +167,7 @@ package buddy
|
||||
private static function onHasReferralAssociationResponse(param1:int) : void
|
||||
{
|
||||
_hasRequestedReferralAssociation = true;
|
||||
_buddyListReferFriendBg.visible = true;
|
||||
_buddyListReferFriendBg.visible = param1 == 1;
|
||||
if(param1 == 1)
|
||||
{
|
||||
_buddyListReferAFriendBtn.visible = true;
|
||||
@@ -175,8 +175,10 @@ package buddy
|
||||
}
|
||||
else
|
||||
{
|
||||
// "How did you hear?" is never offered here: its window soft
|
||||
// locked the game, and nothing reads its answer.
|
||||
_buddyListReferAFriendBtn.visible = false;
|
||||
_buddyListHowDidYouHearBtn.visible = true;
|
||||
_buddyListHowDidYouHearBtn.visible = false;
|
||||
}
|
||||
if(_buddyListPopup.visible)
|
||||
{
|
||||
|
||||
+407
-11
@@ -1,12 +1,19 @@
|
||||
package gui
|
||||
{
|
||||
import flash.display.Bitmap;
|
||||
import flash.display.BitmapData;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.Sprite;
|
||||
import flash.display.GradientType;
|
||||
import flash.display.SpreadMethod;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.events.TextEvent;
|
||||
import flash.filters.ConvolutionFilter;
|
||||
import flash.geom.ColorTransform;
|
||||
import flash.geom.Point;
|
||||
import flash.geom.Rectangle;
|
||||
import flash.geom.Matrix;
|
||||
import flash.text.TextField;
|
||||
import flash.utils.setTimeout;
|
||||
import loader.MediaHelper;
|
||||
@@ -66,18 +73,47 @@ package gui
|
||||
private var _emoteBGOffsetFunc:Function;
|
||||
|
||||
// emotes drawn inside a line of chat, small, where they were typed: an
|
||||
// emote's code standing as a word of its own ("hi :) there", ":fever:"),
|
||||
// or anywhere after a "\" ("yay\:)"). and emoji (typed with Windows'
|
||||
// emote's code standing as a word of its own ("hi :) there", ":fever:").
|
||||
// a "\" before one keeps it as typed ("\:)" shows ":)"), as it does a
|
||||
// ":name:" of an emoji (AJClient.emojiShortcodes). and emoji (typed with Windows'
|
||||
// emoji panel, say), which the game's font has none of: each is drawn
|
||||
// as a picture of it, from the server (/emoji/<code points>.png,
|
||||
// Twemoji's). each is {at, clip}: where its gap starts in the text shown.
|
||||
// Three spaces fit the line-height-sized emoji without the noticeably
|
||||
// wide hole four spaces left between neighbouring words or emoji.
|
||||
private static const INLINE_GAP:String = " ";
|
||||
// Four spaces reserve a full inline cell. placeInline() scales wide
|
||||
// artwork to this measured slot with a one-pixel gutter on each side,
|
||||
// so consecutive emoji neither overlap nor touch surrounding text.
|
||||
private static const INLINE_GAP:String = " ";
|
||||
|
||||
// after each gap: a gap ending the text was trailing spaces, which a
|
||||
// centred line leaves out, so the text sat off centre and its last
|
||||
// emoji past it. this is no space, and has no width.
|
||||
private static const INLINE_END:String = "\u200B";
|
||||
|
||||
private static const LONGEST_EMOTE_CODE:int = 16;
|
||||
|
||||
private var _inline:Array = [];
|
||||
|
||||
// The server appends this compact style to spoken chat packets. It is
|
||||
// deliberately drawn over the stock balloon rather than requiring new
|
||||
// artwork, so every combination of the account-page colour controls is
|
||||
// available at once.
|
||||
private var _styleFill:Sprite;
|
||||
private var _styleMask:Bitmap;
|
||||
private var _styleBorderLayer:Bitmap;
|
||||
private var _styleBackground:uint;
|
||||
private var _styleAccent:uint;
|
||||
private var _styleText:uint;
|
||||
private var _styleBorder:uint;
|
||||
private var _styleOpacity:Number;
|
||||
private var _styleAnimation:String = "none";
|
||||
private var _styleSpeed:Number = 100;
|
||||
private var _styleGradient:String = "linear";
|
||||
private var _styleAngle:Number = 45;
|
||||
private var _styleStrength:Number = 100;
|
||||
private var _styleOutline:Number = 1;
|
||||
private var _styleStops:Array = [];
|
||||
private var _styleElapsed:int = 0;
|
||||
private var _hasStyle:Boolean = false;
|
||||
|
||||
public function ChatBalloon()
|
||||
{
|
||||
@@ -112,7 +148,7 @@ package gui
|
||||
setEmoteBgOffsets();
|
||||
}
|
||||
|
||||
public function setText(param1:String, param2:Boolean = false, param3:Boolean = true) : void
|
||||
public function setText(param1:String, param2:Boolean = false, param3:Boolean = true, param4:String = "") : void
|
||||
{
|
||||
if(_emote)
|
||||
{
|
||||
@@ -142,7 +178,8 @@ package gui
|
||||
_msgTxt.height;
|
||||
// AJClient.whisperNext is set by the server's "xw" just ahead of a
|
||||
// whispered line.
|
||||
_balloonBG.transform.colorTransform = AJClient.whisperNext ? AJClient.whisperTint() : new ColorTransform();
|
||||
var _loc10_:Boolean = AJClient.whisperNext;
|
||||
_balloonBG.transform.colorTransform = _loc10_ ? AJClient.whisperTint() : new ColorTransform();
|
||||
AJClient.whisperNext = false;
|
||||
if(!_hasSbTextfield)
|
||||
{
|
||||
@@ -172,6 +209,10 @@ package gui
|
||||
{
|
||||
_msgTxt.textColor = 4477529;
|
||||
}
|
||||
// Emoji-window choices are inline chat content, so even a lone one
|
||||
// keeps the selected chat style. Standalone game emotes use
|
||||
// setEmote(), where any previous custom bubble is cleared.
|
||||
applyStyle(param4,param2,_loc10_);
|
||||
// tags (AJClient.resolveMentions): once the server says which "@"s
|
||||
// are players', light blue and underlined, each a link to that
|
||||
// player's card, if the balloon still says the same. (the field is
|
||||
@@ -181,6 +222,8 @@ package gui
|
||||
var field:TextField = TextField(_msgTxt);
|
||||
var shown:String = field.text;
|
||||
field.addEventListener("link",onMentionLink,false,0,true);
|
||||
field.addEventListener("mouseDown",onMentionMouse,false,0,true);
|
||||
field.addEventListener("mouseUp",onMentionMouse,false,0,true);
|
||||
AJClient.resolveMentions(shown,function(param1:Array):void
|
||||
{
|
||||
if(field.text == shown)
|
||||
@@ -199,6 +242,12 @@ package gui
|
||||
}
|
||||
});
|
||||
}
|
||||
// The stock balloon has now stretched to the measured text height;
|
||||
// redraw the custom body at its final size (also for still styles).
|
||||
if(_hasStyle)
|
||||
{
|
||||
drawStyle();
|
||||
}
|
||||
_timeout = 8000;
|
||||
if(param3 && this.parent)
|
||||
{
|
||||
@@ -212,6 +261,311 @@ package gui
|
||||
setTimeout(placeInline,42);
|
||||
}
|
||||
}
|
||||
|
||||
// `background,accent,text,border,opacity,animation,speed,gradient,angle,
|
||||
// strength,outline,stops`, emitted by
|
||||
// lib/chatstyles.js. Staff warnings and whispers intentionally retain
|
||||
// their existing colours, so those states are never made ambiguous.
|
||||
private function applyStyle(param1:String, param2:Boolean, param3:Boolean) : void
|
||||
{
|
||||
clearStyle();
|
||||
if(param1 == "" || param2 || param3 || !GuiManager.customChatBubblesEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
var _loc4_:Array = param1.split(",");
|
||||
if((_loc4_.length != 7 && _loc4_.length != 10 && _loc4_.length != 11 && _loc4_.length != 12) || !/^[0-9a-fA-F]{6}$/.test(_loc4_[0]) || !/^[0-9a-fA-F]{6}$/.test(_loc4_[1]) || !/^[0-9a-fA-F]{6}$/.test(_loc4_[2]) || !/^[0-9a-fA-F]{6}$/.test(_loc4_[3]) || !/^(?:2[5-9]|[3-9][0-9]|100)$/.test(_loc4_[4]) || !/^(?:[4-9][0-9]|[12][0-9]{2}|300)$/.test(_loc4_[6]))
|
||||
{
|
||||
return;
|
||||
}
|
||||
_styleBackground = uint(parseInt(_loc4_[0],16));
|
||||
_styleAccent = uint(parseInt(_loc4_[1],16));
|
||||
_styleText = uint(parseInt(_loc4_[2],16));
|
||||
_styleBorder = uint(parseInt(_loc4_[3],16));
|
||||
_styleOpacity = Math.max(0.25,Math.min(1,Number(_loc4_[4]) / 100));
|
||||
_styleAnimation = GuiManager.chatBubbleAnimationsEnabled() && (_loc4_[5] == "pulse" || _loc4_[5] == "shimmer" || _loc4_[5] == "flow" || _loc4_[5] == "rainbow") ? _loc4_[5] : "none";
|
||||
_styleSpeed = Math.max(40,Math.min(300,Number(_loc4_[6])));
|
||||
_styleGradient = _loc4_.length > 7 && (_loc4_[7] == "solid" || _loc4_[7] == "radial") ? _loc4_[7] : "linear";
|
||||
_styleAngle = _loc4_.length > 8 && int(_loc4_[8]) >= 0 && int(_loc4_[8]) <= 315 && int(_loc4_[8]) % 45 == 0 ? int(_loc4_[8]) : 45;
|
||||
_styleStrength = _loc4_.length > 9 ? Math.max(0,Math.min(100,int(_loc4_[9]))) : 100;
|
||||
_styleOutline = _loc4_.length > 10 ? Math.max(0,Math.min(4,int(_loc4_[10]))) : 1;
|
||||
_styleStops = parseStyleStops(_loc4_.length > 11 ? String(_loc4_[11]) : "");
|
||||
_styleElapsed = 0;
|
||||
_hasStyle = true;
|
||||
_msgTxt.textColor = _styleText;
|
||||
// The native artwork remains underneath as the exact outer border;
|
||||
// drawStyle masks the custom fill to that artwork's silhouette.
|
||||
_balloonBG.transform.colorTransform = colourTransform(_styleBorder,1);
|
||||
}
|
||||
|
||||
private function clearStyle() : void
|
||||
{
|
||||
if(_styleFill)
|
||||
{
|
||||
_styleFill.mask = null;
|
||||
}
|
||||
if(_styleFill && _styleFill.parent)
|
||||
{
|
||||
_styleFill.parent.removeChild(_styleFill);
|
||||
}
|
||||
if(_styleMask)
|
||||
{
|
||||
if(_styleMask.parent)
|
||||
{
|
||||
_styleMask.parent.removeChild(_styleMask);
|
||||
}
|
||||
if(_styleMask.bitmapData)
|
||||
{
|
||||
_styleMask.bitmapData.dispose();
|
||||
}
|
||||
}
|
||||
if(_styleBorderLayer)
|
||||
{
|
||||
if(_styleBorderLayer.parent)
|
||||
{
|
||||
_styleBorderLayer.parent.removeChild(_styleBorderLayer);
|
||||
}
|
||||
if(_styleBorderLayer.bitmapData)
|
||||
{
|
||||
_styleBorderLayer.bitmapData.dispose();
|
||||
}
|
||||
}
|
||||
_styleFill = null;
|
||||
_styleMask = null;
|
||||
_styleBorderLayer = null;
|
||||
_styleAnimation = "none";
|
||||
_styleGradient = "linear";
|
||||
_styleStops = [];
|
||||
_hasStyle = false;
|
||||
}
|
||||
|
||||
private static function colourTransform(param1:uint, param2:Number) : ColorTransform
|
||||
{
|
||||
return new ColorTransform(0,0,0,param2,param1 >> 16 & 255,param1 >> 8 & 255,param1 & 255,0);
|
||||
}
|
||||
|
||||
private static function blendColour(param1:uint, param2:uint, param3:Number) : uint
|
||||
{
|
||||
var _loc4_:Number = 1 - param3;
|
||||
var _loc5_:uint = uint((param1 >> 16 & 255) * _loc4_ + (param2 >> 16 & 255) * param3);
|
||||
var _loc6_:uint = uint((param1 >> 8 & 255) * _loc4_ + (param2 >> 8 & 255) * param3);
|
||||
var _loc7_:uint = uint((param1 & 255) * _loc4_ + (param2 & 255) * param3);
|
||||
return _loc5_ << 16 | _loc6_ << 8 | _loc7_;
|
||||
}
|
||||
|
||||
private static function rainbowColour(param1:Number) : uint
|
||||
{
|
||||
var _loc2_:int = int(param1 * 6) % 6;
|
||||
var _loc3_:Number = param1 * 6 - int(param1 * 6);
|
||||
var _loc4_:uint = uint(255 * _loc3_);
|
||||
var _loc5_:uint = 255 - _loc4_;
|
||||
if(_loc2_ == 0)
|
||||
{
|
||||
return 0xFF0000 | _loc4_ << 8;
|
||||
}
|
||||
if(_loc2_ == 1)
|
||||
{
|
||||
return _loc5_ << 16 | 0xFF00;
|
||||
}
|
||||
if(_loc2_ == 2)
|
||||
{
|
||||
return 0x00FF00 | _loc4_;
|
||||
}
|
||||
if(_loc2_ == 3)
|
||||
{
|
||||
return _loc5_ << 8 | 0xFF;
|
||||
}
|
||||
if(_loc2_ == 4)
|
||||
{
|
||||
return _loc4_ << 16 | 0xFF;
|
||||
}
|
||||
return 0xFF0000 | _loc5_ << 8;
|
||||
}
|
||||
|
||||
private function parseStyleStops(param1:String) : Array
|
||||
{
|
||||
var _loc1_:Array = [];
|
||||
var _loc2_:Array = String(param1 || "").split(";");
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Array = null;
|
||||
var _loc5_:int = -1;
|
||||
while(_loc3_ < _loc2_.length && _loc2_.length >= 2 && _loc2_.length <= 5)
|
||||
{
|
||||
_loc4_ = String(_loc2_[_loc3_]).split(":");
|
||||
if(_loc4_.length != 2 || !/^[0-9a-fA-F]{6}$/.test(String(_loc4_[0])) || !/^100$|^[1-9]?\d$/.test(String(_loc4_[1])) || int(_loc4_[1]) <= _loc5_)
|
||||
{
|
||||
_loc1_ = [];
|
||||
break;
|
||||
}
|
||||
_loc5_ = int(_loc4_[1]);
|
||||
_loc1_.push({"color":uint(parseInt(_loc4_[0],16)),"position":_loc5_});
|
||||
_loc3_++;
|
||||
}
|
||||
if(_loc1_.length < 2 || int(_loc1_[0].position) != 0 || int(_loc1_[_loc1_.length - 1].position) != 100)
|
||||
{
|
||||
_loc1_ = [{"color":_styleBackground,"position":0},{"color":_styleAccent,"position":100}];
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
private function drawStyle() : void
|
||||
{
|
||||
if(!_hasStyle || !_balloonBG || !_msgTxt)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(_styleFill == null)
|
||||
{
|
||||
_styleFill = new Sprite();
|
||||
_styleFill.mouseEnabled = false;
|
||||
_styleFill.mouseChildren = false;
|
||||
// Flash uses a Bitmap mask's alpha channel only when both sides
|
||||
// are cached. Without this it masks to the bitmap's rectangle.
|
||||
_styleFill.cacheAsBitmap = true;
|
||||
// The stock background contains masks and nested timeline layers.
|
||||
// Put this beside it, directly below the text, so those masks
|
||||
// cannot hide custom colours or animated gradients.
|
||||
var _loc8_:DisplayObject = _msgTxt as DisplayObject;
|
||||
while(_loc8_ && _loc8_.parent != this)
|
||||
{
|
||||
_loc8_ = _loc8_.parent;
|
||||
}
|
||||
if(_loc8_ && _loc8_.parent == this)
|
||||
{
|
||||
addChildAt(_styleFill,getChildIndex(_loc8_));
|
||||
}
|
||||
else
|
||||
{
|
||||
addChildAt(_styleFill,Math.min(numChildren,getChildIndex(_balloonBG) + 1));
|
||||
}
|
||||
}
|
||||
var _loc9_:Rectangle = _balloonBG.getBounds(this);
|
||||
if(_styleMask == null)
|
||||
{
|
||||
// Snapshot only the native bubble's alpha and use it as a mask.
|
||||
// Eroding that silhouette by the chosen outline width leaves the
|
||||
// tinted native artwork visible as an even border, including the
|
||||
// speech tail. A rounded-rectangle inset cannot match that shape.
|
||||
var _loc10_:BitmapData = new BitmapData(Math.max(1,Math.ceil(_loc9_.width)),Math.max(1,Math.ceil(_loc9_.height)),true,0);
|
||||
var _loc11_:Matrix = _balloonBG.transform.matrix.clone();
|
||||
_loc11_.translate(-_loc9_.x,-_loc9_.y);
|
||||
_loc10_.draw(_balloonBG,_loc11_,null,null,null,true);
|
||||
var _loc20_:BitmapData = new BitmapData(_loc10_.width,_loc10_.height,true,0);
|
||||
_loc20_.threshold(_loc10_,_loc10_.rect,new Point(),">",0x08000000,0xFFFFFFFF,0xFF000000,false);
|
||||
_loc10_.dispose();
|
||||
var _loc32_:BitmapData = _loc20_.clone();
|
||||
if(_styleOutline > 0)
|
||||
{
|
||||
var _loc21_:int = int(_styleOutline) * 2 + 1;
|
||||
var _loc22_:Array = [];
|
||||
var _loc23_:int = 0;
|
||||
var _loc24_:int = 0;
|
||||
var _loc25_:int = 0;
|
||||
while(_loc24_ < _loc21_)
|
||||
{
|
||||
_loc25_ = 0;
|
||||
while(_loc25_ < _loc21_)
|
||||
{
|
||||
if(Math.abs(_loc24_ - int(_styleOutline)) + Math.abs(_loc25_ - int(_styleOutline)) <= _styleOutline)
|
||||
{
|
||||
_loc22_.push(1);
|
||||
_loc23_++;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc22_.push(0);
|
||||
}
|
||||
_loc25_++;
|
||||
}
|
||||
_loc24_++;
|
||||
}
|
||||
var _loc26_:BitmapData = new BitmapData(_loc20_.width,_loc20_.height,true,0);
|
||||
// Outside the snapshot must be transparent. Clamping repeats
|
||||
// opaque edge pixels and prevents the top/side of the mask
|
||||
// from shrinking, which made thick outlines appear only at
|
||||
// the lower edge and corners.
|
||||
_loc26_.applyFilter(_loc20_,_loc20_.rect,new Point(),new ConvolutionFilter(_loc21_,_loc21_,_loc22_,_loc23_,0,false,false,0,0));
|
||||
_loc20_.fillRect(_loc20_.rect,0);
|
||||
_loc20_.threshold(_loc26_,_loc26_.rect,new Point(),">",0xFE000000,0xFFFFFFFF,0xFF000000,false);
|
||||
_loc26_.dispose();
|
||||
// Keep only the pixels removed from the inner mask. This is a
|
||||
// solid, even ring and does not inherit the stock art's uneven
|
||||
// border opacity.
|
||||
_loc32_.threshold(_loc20_,_loc20_.rect,new Point(),">",0x00000000,0x00000000,0xFF000000,false);
|
||||
_loc32_.colorTransform(_loc32_.rect,colourTransform(_styleBorder,1));
|
||||
_styleBorderLayer = new Bitmap(_loc32_,"auto",true);
|
||||
_styleBorderLayer.x = _loc9_.x;
|
||||
_styleBorderLayer.y = _loc9_.y;
|
||||
_styleBorderLayer.cacheAsBitmap = true;
|
||||
addChildAt(_styleBorderLayer,getChildIndex(_styleFill));
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc32_.dispose();
|
||||
}
|
||||
_styleMask = new Bitmap(_loc20_,"auto",true);
|
||||
_styleMask.x = _loc9_.x;
|
||||
_styleMask.y = _loc9_.y;
|
||||
_styleMask.cacheAsBitmap = true;
|
||||
addChildAt(_styleMask,getChildIndex(_styleFill));
|
||||
_styleFill.mask = _styleMask;
|
||||
}
|
||||
var _loc1_:Number = _loc9_.x;
|
||||
var _loc2_:Number = _loc9_.y;
|
||||
var _loc3_:Number = Math.max(12,_loc9_.width);
|
||||
var _loc4_:Number = Math.max(12,_loc9_.height);
|
||||
var _loc5_:Number = (_styleElapsed * _styleSpeed / 100000) % 1;
|
||||
var _loc27_:Array = [];
|
||||
var _loc28_:Array = [];
|
||||
var _loc29_:Array = [];
|
||||
var _loc30_:int = 0;
|
||||
var _loc31_:uint = 0;
|
||||
while(_loc30_ < _styleStops.length)
|
||||
{
|
||||
_loc31_ = uint(_styleStops[_loc30_].color);
|
||||
if(_loc30_ > 0)
|
||||
{
|
||||
_loc31_ = blendColour(_styleBackground,_loc31_,_styleStrength / 100);
|
||||
}
|
||||
if(_styleAnimation == "shimmer")
|
||||
{
|
||||
_loc31_ = blendColour(_loc31_,_styleBackground,(Math.sin(_loc5_ * Math.PI * 2) + 1) * 0.5);
|
||||
}
|
||||
_loc27_.push(_loc31_);
|
||||
_loc28_.push(_styleOpacity);
|
||||
_loc29_.push(int(Number(_styleStops[_loc30_].position) * 2.55));
|
||||
_loc30_++;
|
||||
}
|
||||
_styleFill.graphics.clear();
|
||||
var _loc7_:Matrix = new Matrix();
|
||||
var _loc12_:Number = _styleAngle * Math.PI / 180;
|
||||
var _loc13_:String = _styleGradient == "radial" ? GradientType.RADIAL : GradientType.LINEAR;
|
||||
_loc7_.createGradientBox(_loc3_,_loc4_,_loc12_,_loc1_,_loc2_);
|
||||
if(_styleGradient == "solid" && _styleAnimation != "rainbow")
|
||||
{
|
||||
_styleFill.graphics.beginFill(_styleBackground,_styleOpacity);
|
||||
}
|
||||
else if(_styleAnimation == "flow")
|
||||
{
|
||||
_loc7_.createGradientBox(_loc3_ * 0.75,_loc4_ * 0.75,_loc12_,_loc1_ + Math.cos(_loc12_) * (_loc5_ * 2 - 1) * _loc3_,_loc2_ + Math.sin(_loc12_) * (_loc5_ * 2 - 1) * _loc4_);
|
||||
_styleFill.graphics.beginGradientFill(_loc13_,_loc27_,_loc28_,_loc29_,_loc7_,SpreadMethod.REFLECT);
|
||||
}
|
||||
else if(_styleAnimation == "rainbow" && _styleGradient == "solid")
|
||||
{
|
||||
_styleFill.graphics.beginFill(rainbowColour(_loc5_),_styleOpacity);
|
||||
}
|
||||
else if(_styleAnimation == "rainbow")
|
||||
{
|
||||
_styleFill.graphics.beginGradientFill(_loc13_,[rainbowColour(_loc5_),rainbowColour((_loc5_ + 0.18) % 1),rainbowColour((_loc5_ + 0.36) % 1)],[_styleOpacity,_styleOpacity,_styleOpacity],[0,128,255],_loc7_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_styleFill.graphics.beginGradientFill(_loc13_,_loc27_,_loc28_,_loc29_,_loc7_);
|
||||
}
|
||||
_styleFill.graphics.drawRect(_loc1_,_loc2_,_loc3_,_loc4_);
|
||||
_styleFill.graphics.endFill();
|
||||
_styleFill.alpha = _styleAnimation == "pulse" ? 0.55 + 0.45 * (Math.sin(_loc5_ * Math.PI * 2) + 1) * 0.5 : 1;
|
||||
}
|
||||
|
||||
// the text with each emote code and emoji (above) replaced by a gap, the
|
||||
// picture for it kept in _inline. what is neither stays as typed.
|
||||
@@ -231,7 +585,7 @@ package gui
|
||||
"at":_loc2_.length,
|
||||
"clip":emojiClip(param1.substr(_loc3_,_loc8_))
|
||||
});
|
||||
_loc2_ += INLINE_GAP;
|
||||
_loc2_ += INLINE_GAP + INLINE_END;
|
||||
_loc3_ += _loc8_;
|
||||
continue;
|
||||
}
|
||||
@@ -246,14 +600,26 @@ package gui
|
||||
"at":_loc2_.length,
|
||||
"clip":emojiClipNamed(_loc9_[1])
|
||||
});
|
||||
_loc2_ += INLINE_GAP;
|
||||
_loc2_ += INLINE_GAP + INLINE_END;
|
||||
_loc3_ += String(_loc9_[0]).length;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(param1.charAt(_loc3_) == "\\")
|
||||
{
|
||||
// "\" and an emote's code, or ":name:": that, as typed
|
||||
_loc5_ = emoteCodeAt(param1,_loc3_ + 1,false);
|
||||
var _loc10_:Array = /^:[a-z0-9_]{1,30}:/.exec(param1.substr(_loc3_ + 1,32));
|
||||
if(_loc5_ == null && _loc10_ != null)
|
||||
{
|
||||
_loc5_ = _loc10_[0];
|
||||
}
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
_loc2_ += _loc5_;
|
||||
_loc3_ += 1 + _loc5_.length;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if(_loc3_ == 0 || param1.charAt(_loc3_ - 1) == " ")
|
||||
{
|
||||
@@ -268,8 +634,8 @@ package gui
|
||||
"at":_loc2_.length,
|
||||
"clip":_loc7_
|
||||
});
|
||||
_loc2_ += INLINE_GAP;
|
||||
_loc3_ += (param1.charAt(_loc3_) == "\\" ? 1 : 0) + _loc5_.length;
|
||||
_loc2_ += INLINE_GAP + INLINE_END;
|
||||
_loc3_ += _loc5_.length;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -428,6 +794,8 @@ package gui
|
||||
var _loc1_:Object = null;
|
||||
var _loc2_:Rectangle = null;
|
||||
var _loc3_:Rectangle = null;
|
||||
var _loc4_:Number = 0;
|
||||
var _loc5_:Number = 1;
|
||||
for each(_loc1_ in _inline)
|
||||
{
|
||||
_loc2_ = _msgTxt.getCharBoundaries(_loc1_.at);
|
||||
@@ -445,6 +813,13 @@ package gui
|
||||
_loc1_.clip.scaleX = _loc1_.clip.scaleY = 1;
|
||||
_loc1_.clip.height = _loc2_.height;
|
||||
_loc1_.clip.scaleX = _loc1_.clip.scaleY;
|
||||
_loc4_ = Math.max(1,_loc3_.x + _loc3_.width - _loc2_.x - 2);
|
||||
if(_loc1_.clip.width > _loc4_)
|
||||
{
|
||||
_loc5_ = _loc4_ / _loc1_.clip.width;
|
||||
_loc1_.clip.scaleX *= _loc5_;
|
||||
_loc1_.clip.scaleY *= _loc5_;
|
||||
}
|
||||
_loc1_.clip.x = _msgTxt.x + (_loc2_.x + _loc3_.x + _loc3_.width) / 2;
|
||||
_loc1_.clip.y = _msgTxt.y + _loc2_.y + _loc2_.height / 2;
|
||||
if(_loc1_.clip.parent != this)
|
||||
@@ -624,6 +999,18 @@ package gui
|
||||
}
|
||||
}
|
||||
|
||||
// a press on a tag goes no further: the room under the balloon would
|
||||
// take it for a click on the floor and walk the player there.
|
||||
private function onMentionMouse(param1:MouseEvent) : void
|
||||
{
|
||||
var _loc2_:TextField = param1.currentTarget as TextField;
|
||||
var _loc3_:int = _loc2_ != null ? _loc2_.getCharIndexAtPoint(param1.localX,param1.localY) : -1;
|
||||
if(_loc3_ >= 0 && _loc2_.getTextFormat(_loc3_,_loc3_ + 1).url)
|
||||
{
|
||||
param1.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
// a tag clicked: "@name" (setText)
|
||||
private function onMentionLink(param1:TextEvent) : void
|
||||
{
|
||||
@@ -662,6 +1049,10 @@ package gui
|
||||
|
||||
public function setEmote(param1:Sprite, param2:int = -1) : void
|
||||
{
|
||||
// Native one-emote messages hide balloon_bg. Remove any independent
|
||||
// custom fill left by the preceding text message as well.
|
||||
clearStyle();
|
||||
_balloonBG.transform.colorTransform = new ColorTransform();
|
||||
clearMentionBacks();
|
||||
if(this.currentFrameLabel != "advBtn")
|
||||
{
|
||||
@@ -718,6 +1109,11 @@ package gui
|
||||
|
||||
public function heartbeat(param1:int) : void
|
||||
{
|
||||
if(_styleAnimation != "none" && visible)
|
||||
{
|
||||
_styleElapsed += param1;
|
||||
drawStyle();
|
||||
}
|
||||
if(_timeout && _permEmoteMediaId < 0)
|
||||
{
|
||||
if(param1 >= _timeout)
|
||||
|
||||
+16
-2
@@ -15,6 +15,7 @@ package gui
|
||||
import flash.text.StyleSheet;
|
||||
import flash.text.TextField;
|
||||
import flash.text.TextFormat;
|
||||
import flash.utils.getTimer;
|
||||
import flash.ui.Mouse;
|
||||
import gui.itemWindows.ItemWindowTextNode;
|
||||
import localization.LocalizationManager;
|
||||
@@ -50,6 +51,13 @@ package gui
|
||||
|
||||
private var _chatRepeatArray:Array;
|
||||
|
||||
// a repeat list line (emoji as names) -> {line: as it was said, with
|
||||
// its emoji, at: getTimer() then}. the names were sent instead, and the
|
||||
// server says nothing to a line said again within REPEAT_MS (lib/chatspam.js)
|
||||
private var _chatRepeatSaid:Object = {};
|
||||
|
||||
private static const REPEAT_MS:int = 20000;
|
||||
|
||||
private var _hasSetupChatRepeatBtn:Boolean;
|
||||
|
||||
private var _isOverChatText:Boolean;
|
||||
@@ -288,6 +296,7 @@ package gui
|
||||
|
||||
public function addMessage(param1:String, param2:String, param3:String, param4:String) : void
|
||||
{
|
||||
var said:String = param4;
|
||||
// emoji as their names here: this list has no pictures (AJClient.emojiAsNames)
|
||||
param4 = AJClient.emojiAsNames(param4);
|
||||
var _loc5_:Boolean = false;
|
||||
@@ -298,6 +307,10 @@ package gui
|
||||
addLine("<a href=\"event:" + plain(param2) + "\">" + plain(Utility.isSettingOn(MySettings.SETTINGS_USERNAME_BADGE) ? param3 : param1) + ": " + "</a>",param4,"\n");
|
||||
if(_chatRepeatWindow && AvatarManager.playerAvatar && param2.toLowerCase() == AvatarManager.playerAvatar.userName.toLowerCase())
|
||||
{
|
||||
_chatRepeatSaid[param4] = {
|
||||
"line":said,
|
||||
"at":getTimer()
|
||||
};
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _chatRepeatArray.length)
|
||||
{
|
||||
@@ -991,9 +1004,10 @@ package gui
|
||||
|
||||
private function onRepeatChatSelected(param1:MouseEvent) : void
|
||||
{
|
||||
if(!AvatarManager.playerAvatarWorldView.isSameMessage(param1.currentTarget.text))
|
||||
var _loc2_:Object = _chatRepeatSaid[param1.currentTarget.text];
|
||||
if(!AvatarManager.playerAvatarWorldView.isSameMessage(param1.currentTarget.text) && !(_loc2_ && getTimer() - _loc2_.at < REPEAT_MS))
|
||||
{
|
||||
sendMsgCallback(null,param1.currentTarget.text);
|
||||
sendMsgCallback(null,_loc2_ ? _loc2_.line : param1.currentTarget.text);
|
||||
SBTracker.trackPageview("/game/play/popup/repeatChat/#repeat",-1,1);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -0,0 +1,279 @@
|
||||
package gameRedemption
|
||||
{
|
||||
import com.sbi.popup.SBOkPopup;
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.Event;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.text.TextField;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiManager;
|
||||
import loader.MediaHelper;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class CodeRedemptionPopup
|
||||
{
|
||||
|
||||
private const POPUP_MEDIA_ID:int = 4625;
|
||||
|
||||
private const HELP_POPUP_MEDIA_ID:int = 4628;
|
||||
|
||||
private var _mediaHelper:MediaHelper;
|
||||
|
||||
private var _closeCallback:Function;
|
||||
|
||||
private var _guiLayer:DisplayLayer;
|
||||
|
||||
private var _redemptionPopup:MovieClip;
|
||||
|
||||
private var _closeBtn:MovieClip;
|
||||
|
||||
private var _continueBtn:MovieClip;
|
||||
|
||||
private var _codeInput:TextField;
|
||||
|
||||
private var _helpBtn:MovieClip;
|
||||
|
||||
private var _helpPopup:MovieClip;
|
||||
|
||||
private var _captchaPopup:CaptchaPopup;
|
||||
|
||||
private var _chosenCaptchaAnswer:String;
|
||||
|
||||
private var _captchaQuestion:String;
|
||||
|
||||
public function CodeRedemptionPopup()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function init(param1:Function) : void
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
_closeCallback = param1;
|
||||
_guiLayer = GuiManager.guiLayer;
|
||||
_mediaHelper = new MediaHelper();
|
||||
_mediaHelper.init(4625,onRedemptionPopupLoaded);
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
var _loc1_:Function = null;
|
||||
if(_closeCallback != null)
|
||||
{
|
||||
_loc1_ = _closeCallback;
|
||||
_closeCallback = null;
|
||||
_loc1_();
|
||||
_loc1_ = null;
|
||||
return;
|
||||
}
|
||||
if(_mediaHelper)
|
||||
{
|
||||
_mediaHelper.destroy();
|
||||
_mediaHelper = null;
|
||||
}
|
||||
if(_redemptionPopup)
|
||||
{
|
||||
removeEventListeners();
|
||||
DarkenManager.unDarken(_redemptionPopup);
|
||||
_guiLayer.removeChild(_redemptionPopup);
|
||||
}
|
||||
if(_helpPopup)
|
||||
{
|
||||
removeHelpPopupEventListeners();
|
||||
DarkenManager.unDarken(_helpPopup);
|
||||
_guiLayer.removeChild(_helpPopup);
|
||||
_helpPopup = null;
|
||||
}
|
||||
_guiLayer = null;
|
||||
_redemptionPopup = null;
|
||||
}
|
||||
|
||||
private function loadHelpPopup() : void
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
_mediaHelper = new MediaHelper();
|
||||
_mediaHelper.init(4628,onHelpPopupLoaded);
|
||||
}
|
||||
|
||||
private function onRedemptionPopupLoaded(param1:MovieClip) : void
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
_redemptionPopup = param1.getChildAt(0) as MovieClip;
|
||||
_redemptionPopup.x = 900 * 0.5;
|
||||
_redemptionPopup.y = 550 * 0.5;
|
||||
_guiLayer.addChild(_redemptionPopup);
|
||||
DarkenManager.darken(_redemptionPopup);
|
||||
_closeBtn = _redemptionPopup.bx;
|
||||
_continueBtn = _redemptionPopup.continueBtn;
|
||||
_codeInput = _redemptionPopup.codeTxt;
|
||||
_codeInput.restrict = "A-Za-z0-9\\-";
|
||||
_helpBtn = _redemptionPopup.helpBtn;
|
||||
if(gMainFrame.clientInfo.redemptionCode != undefined && gMainFrame.clientInfo.redemptionCode.length > 0)
|
||||
{
|
||||
_codeInput.text = gMainFrame.clientInfo.redemptionCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
_continueBtn.activateGrayState(true);
|
||||
}
|
||||
gMainFrame.stage.focus = _codeInput;
|
||||
_codeInput.setSelection(_codeInput.text.length,_codeInput.text.length);
|
||||
addEventListeners();
|
||||
}
|
||||
|
||||
private function onHelpPopupLoaded(param1:MovieClip) : void
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
_helpPopup = param1.getChildAt(0) as MovieClip;
|
||||
_helpPopup.x = 900 * 0.5;
|
||||
_helpPopup.y = 550 * 0.5;
|
||||
_guiLayer.addChild(_helpPopup);
|
||||
DarkenManager.unDarken(_redemptionPopup);
|
||||
DarkenManager.darken(_helpPopup);
|
||||
addHelpPopupEventListeners();
|
||||
}
|
||||
|
||||
private function addEventListeners() : void
|
||||
{
|
||||
gMainFrame.stage.addEventListener("keyDown",onKeyDown,false,0,true);
|
||||
_redemptionPopup.addEventListener("mouseDown",onPopup,false,0,true);
|
||||
_closeBtn.addEventListener("mouseDown",onCloseBtn,false,0,true);
|
||||
_continueBtn.addEventListener("mouseDown",onContinueBtn,false,0,true);
|
||||
_codeInput.addEventListener("change",onCodeInputChange,false,0,true);
|
||||
_helpBtn.addEventListener("mouseDown",onHelpBtn,false,0,true);
|
||||
}
|
||||
|
||||
private function addHelpPopupEventListeners() : void
|
||||
{
|
||||
_helpPopup.addEventListener("mouseDown",onPopup,false,0,true);
|
||||
_helpPopup.bx.addEventListener("mouseDown",onHelpClose,false,0,true);
|
||||
}
|
||||
|
||||
private function removeEventListeners() : void
|
||||
{
|
||||
gMainFrame.stage.removeEventListener("keyDown",onKeyDown);
|
||||
_redemptionPopup.removeEventListener("mouseDown",onPopup);
|
||||
_closeBtn.removeEventListener("mouseDown",onCloseBtn);
|
||||
_continueBtn.removeEventListener("mouseDown",onContinueBtn);
|
||||
_codeInput.removeEventListener("change",onCodeInputChange);
|
||||
_helpBtn.removeEventListener("mouseDown",onHelpBtn);
|
||||
}
|
||||
|
||||
private function removeHelpPopupEventListeners() : void
|
||||
{
|
||||
_helpPopup.removeEventListener("mouseDown",onPopup);
|
||||
_helpPopup.bx.removeEventListener("mouseDown",onHelpClose);
|
||||
}
|
||||
|
||||
private function onPopup(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
}
|
||||
|
||||
private function onCloseBtn(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
destroy();
|
||||
}
|
||||
|
||||
private function onContinueBtn(param1:MouseEvent) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
param1.stopPropagation();
|
||||
}
|
||||
if(!_continueBtn.isGray && _codeInput.length > 0)
|
||||
{
|
||||
if(GameRedemptionXtCommManager.captchaToShowData != null)
|
||||
{
|
||||
_captchaPopup = new CaptchaPopup();
|
||||
_captchaPopup.init(GameRedemptionXtCommManager.captchaToShowData.question,GameRedemptionXtCommManager.captchaToShowData.options,onCaptchaClose);
|
||||
}
|
||||
else
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
GameRedemptionXtCommManager.requestRedeemCode(_codeInput.text,_captchaQuestion,_chosenCaptchaAnswer,onCodeRedeemResponse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function onCodeInputChange(param1:Event) : void
|
||||
{
|
||||
if(_codeInput.length <= 0)
|
||||
{
|
||||
_continueBtn.activateGrayState(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_continueBtn.activateGrayState(false);
|
||||
}
|
||||
}
|
||||
|
||||
// what codes are on this server, in the game's own message box: the
|
||||
// official help window (media 4628) loaded and showed nothing
|
||||
private function onHelpBtn(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
new SBOkPopup(_guiLayer,"Codes are given out by the Burrow team: in announcements, at events and on our Discord. Type the code in the box and press Continue. Each code works once for each account.");
|
||||
}
|
||||
|
||||
private function onHelpClose(param1:MouseEvent) : void
|
||||
{
|
||||
_helpPopup.visible = false;
|
||||
DarkenManager.unDarken(_helpPopup);
|
||||
DarkenManager.darken(_redemptionPopup);
|
||||
}
|
||||
|
||||
private function onKeyDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
if(param1.keyCode == 13)
|
||||
{
|
||||
onContinueBtn(null);
|
||||
}
|
||||
}
|
||||
|
||||
private function onCodeRedeemResponse(param1:String, param2:Object) : void
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
_captchaQuestion = "";
|
||||
_chosenCaptchaAnswer = "";
|
||||
switch(param1)
|
||||
{
|
||||
case "1":
|
||||
gMainFrame.clientInfo.redemptionCode = undefined;
|
||||
destroy();
|
||||
break;
|
||||
case "-3":
|
||||
GuiManager.initEmailConfirmation(null,null,true);
|
||||
break;
|
||||
case "-4":
|
||||
case "-5":
|
||||
new SBOkPopup(_guiLayer,LocalizationManager.translateIdOnly(25352));
|
||||
break;
|
||||
case "-6":
|
||||
GameRedemptionXtCommManager.captchaToShowData = param2;
|
||||
onContinueBtn(null);
|
||||
break;
|
||||
case "-7":
|
||||
GameRedemptionXtCommManager.captchaToShowData = param2;
|
||||
default:
|
||||
new SBOkPopup(_guiLayer,LocalizationManager.translateIdOnly(24878));
|
||||
}
|
||||
}
|
||||
|
||||
private function onCaptchaClose(param1:Boolean, param2:String, param3:String) : void
|
||||
{
|
||||
_captchaPopup.destroy();
|
||||
_captchaPopup = null;
|
||||
if(param3 != null && param3 != "")
|
||||
{
|
||||
_captchaQuestion = param2;
|
||||
_chosenCaptchaAnswer = param3;
|
||||
}
|
||||
GameRedemptionXtCommManager.captchaToShowData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -438,6 +438,7 @@ package gui
|
||||
var _loc6_:int = 0;
|
||||
var _loc9_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc17_:int = 0;
|
||||
while(_popup.itemBlock.numChildren > 1)
|
||||
{
|
||||
_popup.itemBlock.removeChildAt(_popup.itemBlock.numChildren - 1);
|
||||
@@ -627,7 +628,9 @@ package gui
|
||||
_itemDenWindows = _currItemWindow;
|
||||
}
|
||||
_popup.searchBar.mouse.searchTxt.text = "";
|
||||
_currItemWindow.init(_popup.itemBlock.width,_popup.itemBlock.height,2,_loc11_,3,4,12,2,2,0,2 * 0.5,ItemWindowOriginal,_loc3_,"icon",0,{
|
||||
// Expanded Inventory: more, smaller items a row (AJClient.inventoryColumns)
|
||||
_loc17_ = AJClient.inventoryColumns();
|
||||
_currItemWindow.init(_popup.itemBlock.width,_popup.itemBlock.height,2,_loc11_,_loc17_,4,_loc17_ * 4,2,2,0,2 * 0.5,ItemWindowOriginal,_loc3_,"icon",0,{
|
||||
"mouseDown":winMouseDown,
|
||||
"mouseOver":winMouseOver,
|
||||
"mouseOut":winMouseOut
|
||||
@@ -635,7 +638,8 @@ package gui
|
||||
"giftItemIdx":_giftItemIdx,
|
||||
"isECard":_type == 1,
|
||||
"isChoosingForTradeList":_type == 0 || _type == 3,
|
||||
"indexArray":_loc5_
|
||||
"indexArray":_loc5_,
|
||||
"itemScale":3 / _loc17_
|
||||
},onListLoaded);
|
||||
}
|
||||
else
|
||||
|
||||
+9
-91
@@ -15,13 +15,10 @@ package gui
|
||||
import den.DenStateItem;
|
||||
import den.DenXtCommManager;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.geom.Point;
|
||||
import flash.text.TextField;
|
||||
import flash.text.TextFormat;
|
||||
import flash.utils.Timer;
|
||||
import gui.itemWindows.ItemWindowOriginal;
|
||||
import localization.LocalizationManager;
|
||||
@@ -142,8 +139,6 @@ package gui
|
||||
private var _privacyId:int;
|
||||
|
||||
private var _itemSetEvent:DenItemHolderEvent;
|
||||
|
||||
private var _layerControls:Sprite;
|
||||
|
||||
public function DenEditor()
|
||||
{
|
||||
@@ -162,7 +157,6 @@ package gui
|
||||
_roomMgr = RoomManagerWorld.instance;
|
||||
_denItemHolder = _roomMgr.denItemHolder;
|
||||
_guiLayer.addChild(_denEditor);
|
||||
createLayerControls();
|
||||
initAssetVisibility();
|
||||
setupPlayerItems();
|
||||
DenXtCommManager.denEditorDIResponseCallback = diResponseCallback;
|
||||
@@ -176,7 +170,6 @@ package gui
|
||||
_denItemHolder.removeEventListener("OnItemRemoved",onDenItemRemoved);
|
||||
_denItemHolder.removeEventListener("OnSaveState",onDenSaveState);
|
||||
removeListeners();
|
||||
destroyLayerControls();
|
||||
_guiLayer.removeChild(_denEditor);
|
||||
if(_denLockPopup)
|
||||
{
|
||||
@@ -242,14 +235,8 @@ package gui
|
||||
|
||||
public function updateSwitchRecycleBtnVisibility() : void
|
||||
{
|
||||
if(!_denEditor.switchDenBtn.visible)
|
||||
{
|
||||
if(gMainFrame.userInfo.numLogins >= 2 || gMainFrame.userInfo.userVarCache.getUserVarValueById(3) > 1)
|
||||
{
|
||||
_denEditor.switchDenBtn.visible = true;
|
||||
_denEditor.recycleBtn.visible = true;
|
||||
}
|
||||
}
|
||||
_denEditor.switchDenBtn.visible = true;
|
||||
_denEditor.recycleBtn.visible = true;
|
||||
}
|
||||
|
||||
public function clearItemWindows() : void
|
||||
@@ -440,11 +427,11 @@ package gui
|
||||
{
|
||||
_denEditor.petBtnDn.visible = false;
|
||||
}
|
||||
if(gMainFrame.userInfo.numLogins < 2 && gMainFrame.userInfo.userVarCache.getUserVarValueById(3) <= 1)
|
||||
{
|
||||
_denEditor.switchDenBtn.visible = false;
|
||||
_denEditor.recycleBtn.visible = false;
|
||||
}
|
||||
// the switch den and recycle buttons are not kept from a new
|
||||
// player any more: the game hid them before a second login (or a
|
||||
// den tutorial var), and players found them gone
|
||||
_denEditor.switchDenBtn.visible = true;
|
||||
_denEditor.recycleBtn.visible = true;
|
||||
_denEditor.denAudioPopup.visible = false;
|
||||
_denEditor.itemBlock.glowCont.glow.visible = false;
|
||||
_denEditor.lockBtn.denLock.initToolTip(_guiLayer,LocalizationManager.translateIdOnly(14639),900 * 0.5,105);
|
||||
@@ -697,7 +684,8 @@ package gui
|
||||
{
|
||||
_denEditor.itemBlock.itemBlock.addChild(_itemWindow);
|
||||
}
|
||||
if(_numItems <= 10 + 1)
|
||||
// ten to a page: with eleven the last could not be scrolled to
|
||||
if(_numItems <= 10)
|
||||
{
|
||||
_denEditor.lArrowBtn.activateGrayState(true);
|
||||
_denEditor.rArrowBtn.activateGrayState(true);
|
||||
@@ -1203,76 +1191,6 @@ package gui
|
||||
_roomMgr.spawnNewDenItem(_loc3_);
|
||||
}
|
||||
|
||||
// Small controls added at runtime so every den item can be stacked
|
||||
// deliberately, instead of relying solely on where its feet land.
|
||||
private function createLayerControls() : void
|
||||
{
|
||||
_layerControls = new Sprite();
|
||||
_layerControls.x = _denEditor.width - 258;
|
||||
_layerControls.y = 12;
|
||||
_layerControls.addChild(makeLayerLabel("Selected item layer",0,0,230,22,13,16774041));
|
||||
addLayerButton("Send behind",0,onSendBehind);
|
||||
addLayerButton("Bring on top",116,onBringOnTop);
|
||||
addLayerButton("Use natural depth",0,onResetLayer,62,230,30);
|
||||
_denEditor.addChild(_layerControls);
|
||||
}
|
||||
|
||||
private function addLayerButton(param1:String, param2:Number, param3:Function, param4:Number = 26, param5:Number = 110, param6:Number = 30) : void
|
||||
{
|
||||
var _loc6_:Sprite = new Sprite();
|
||||
_loc6_.x = param2;
|
||||
_loc6_.y = param4;
|
||||
_loc6_.buttonMode = true;
|
||||
_loc6_.mouseChildren = false;
|
||||
_loc6_.graphics.beginFill(5986842,0.96);
|
||||
_loc6_.graphics.drawRoundRect(0,0,param5,param6,8,8);
|
||||
_loc6_.graphics.endFill();
|
||||
_loc6_.addChild(makeLayerLabel(param1,0,5,param5,param6 - 5,12,16777215));
|
||||
_loc6_.addEventListener("mouseDown",param3,false,0,true);
|
||||
_layerControls.addChild(_loc6_);
|
||||
}
|
||||
|
||||
private function makeLayerLabel(param1:String, param2:Number, param3:Number, param4:Number, param5:Number, param6:int, param7:uint) : TextField
|
||||
{
|
||||
var _loc8_:TextField = new TextField();
|
||||
_loc8_.x = param2;
|
||||
_loc8_.y = param3;
|
||||
_loc8_.width = param4;
|
||||
_loc8_.height = param5;
|
||||
_loc8_.selectable = false;
|
||||
_loc8_.mouseEnabled = false;
|
||||
_loc8_.defaultTextFormat = new TextFormat("Arial",param6,param7,true,null,null,null,null,"center");
|
||||
_loc8_.text = param1;
|
||||
return _loc8_;
|
||||
}
|
||||
|
||||
private function onSendBehind(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopImmediatePropagation();
|
||||
_denItemHolder.sendSelectedBehind();
|
||||
}
|
||||
|
||||
private function onBringOnTop(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopImmediatePropagation();
|
||||
_denItemHolder.bringSelectedToFront();
|
||||
}
|
||||
|
||||
private function onResetLayer(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopImmediatePropagation();
|
||||
_denItemHolder.resetSelectedStacking();
|
||||
}
|
||||
|
||||
private function destroyLayerControls() : void
|
||||
{
|
||||
if(_layerControls && _layerControls.parent)
|
||||
{
|
||||
_layerControls.parent.removeChild(_layerControls);
|
||||
}
|
||||
_layerControls = null;
|
||||
}
|
||||
|
||||
private function onClose(param1:MouseEvent) : void
|
||||
{
|
||||
SBTracker.pop();
|
||||
|
||||
@@ -3,6 +3,7 @@ package loader
|
||||
import Enums.DenItemDef;
|
||||
import avatar.AvatarManager;
|
||||
import avatar.MannequinData;
|
||||
import com.sbi.graphics.PaletteHelper;
|
||||
import com.sbi.loader.FileServerEvent;
|
||||
import den.DenItem;
|
||||
import den.DenStateItem;
|
||||
@@ -13,6 +14,7 @@ package loader
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.filters.ColorMatrixFilter;
|
||||
import pet.PetItem;
|
||||
import pet.PetManager;
|
||||
|
||||
@@ -467,7 +469,7 @@ package loader
|
||||
{
|
||||
_version = getVersions()[0];
|
||||
}
|
||||
_loader.content["setVersion"](param1);
|
||||
_loader.content["setVersion"](artVersion(param1));
|
||||
}
|
||||
else if(_loader.content.hasOwnProperty("pet"))
|
||||
{
|
||||
@@ -483,6 +485,50 @@ package loader
|
||||
}
|
||||
}
|
||||
}
|
||||
applyTint();
|
||||
}
|
||||
|
||||
// a den item's version (the server's lib/admin.js): the art's own
|
||||
// variant in the low 8 bits, and above them 1 + the number of a custom
|
||||
// colour entry (PaletteHelper.customColors, [rgb, strength 1-100, 0,
|
||||
// 0]) the whole item is tinted with. the art is only ever given its
|
||||
// variant.
|
||||
private static const CUSTOM_BASE:uint = 0xFD000000;
|
||||
|
||||
private function artVersion(param1:int) : int
|
||||
{
|
||||
return param1 < 0 ? param1 : param1 & 0xFF;
|
||||
}
|
||||
|
||||
private function applyTint() : void
|
||||
{
|
||||
if(!_loader || !_loader.content || _loader.content.hasOwnProperty("pet"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var _loc1_:int = _version > 0 ? _version >> 8 & 0x7FFFFF : 0;
|
||||
var _loc2_:Array = _loc1_ > 0 ? PaletteHelper.customColors[uint(CUSTOM_BASE + _loc1_ - 1)] : null;
|
||||
_loader.filters = _loc2_ != null ? [new ColorMatrixFilter(tintMatrix(uint(_loc2_[0]),Math.min(100,Math.max(1,_loc2_[1])) / 100))] : [];
|
||||
}
|
||||
|
||||
// the item in shades of `param1`, `param2` of the way (0-1): each
|
||||
// pixel's brightness, times the colour (made as bright as white would
|
||||
// be, up to twice), mixed with the pixel as it was.
|
||||
private static function tintMatrix(param1:uint, param2:Number) : Array
|
||||
{
|
||||
var _loc3_:Array = [(param1 >> 16 & 0xFF) / 255,(param1 >> 8 & 0xFF) / 255,(param1 & 0xFF) / 255];
|
||||
var _loc4_:Number = 0.299 * _loc3_[0] + 0.587 * _loc3_[1] + 0.114 * _loc3_[2];
|
||||
var _loc5_:Number = Math.min(2,1 / Math.max(0.001,_loc4_));
|
||||
var _loc6_:Array = [];
|
||||
var _loc7_:int = 0;
|
||||
while(_loc7_ < 3)
|
||||
{
|
||||
var _loc8_:Number = _loc3_[_loc7_] * _loc5_ * param2;
|
||||
_loc6_.push(0.299 * _loc8_ + (_loc7_ == 0 ? 1 - param2 : 0),0.587 * _loc8_ + (_loc7_ == 1 ? 1 - param2 : 0),0.114 * _loc8_ + (_loc7_ == 2 ? 1 - param2 : 0),0,0);
|
||||
_loc7_++;
|
||||
}
|
||||
_loc6_.push(0,0,0,1,0);
|
||||
return _loc6_;
|
||||
}
|
||||
|
||||
public function rebuildMannequinView() : void
|
||||
@@ -567,7 +613,7 @@ package loader
|
||||
}
|
||||
if(_loader.content.hasOwnProperty("setVersion") && _version >= 0)
|
||||
{
|
||||
MovieClip(_loader.content).setVersion(_version);
|
||||
MovieClip(_loader.content).setVersion(artVersion(_version));
|
||||
}
|
||||
else if(_loader.content.hasOwnProperty("pet"))
|
||||
{
|
||||
@@ -582,6 +628,7 @@ package loader
|
||||
}
|
||||
}
|
||||
}
|
||||
applyTint();
|
||||
if(MovieClip(_loader.content).isMoveToDisabled)
|
||||
{
|
||||
_loader.name = "moveToDisabled";
|
||||
|
||||
@@ -391,12 +391,19 @@ package den
|
||||
}
|
||||
_loc26_ = int(param1[_loc23_++]);
|
||||
_loc18_.init(_loc28_,_loc31_,_loc32_,_loc24_,0,null,_loc14_,_loc33_,"",_loc17_,_loc30_,_loc4_,_loc26_);
|
||||
_loc6_.setDenItem(_loc21_,_loc18_);
|
||||
// pushed, not set at its place: one skipped left a hole, and
|
||||
// the inventory's windows scrolled over an empty one
|
||||
_loc6_.pushDenItem(_loc18_);
|
||||
if(_loc18_.minigameDefId > 0 && !MinigameManager.minigameInfoCache.getMinigameInfo(_loc18_.minigameDefId))
|
||||
{
|
||||
_loc20_.push(_loc18_.minigameDefId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// its last field (the den shop's), read past as above
|
||||
_loc23_++;
|
||||
}
|
||||
_loc21_++;
|
||||
}
|
||||
_loc6_.getCoreArray().sortOn("invIdx",0x10 | 2);
|
||||
@@ -846,6 +853,11 @@ package den
|
||||
_loc19_ = getDenItemDef(_loc27_);
|
||||
if(!_loc19_)
|
||||
{
|
||||
// the rest of its fields, read past: left there, every item
|
||||
// after it was read from the wrong place (lib/dens.js
|
||||
// sendDenState: placed, x, y, version, flip, link, image,
|
||||
// creator id, creator uuid, eco state)
|
||||
_loc20_ += 10;
|
||||
_loc9_.setDenStateItem(_loc21_,new DenStateItem(0,_loc38_,0,0,0,0,0,0,0,0,0,0,0,0,0,"",0,"",0,0,"","",-1,"",false,null,0,0,null,null,2));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -0,0 +1,318 @@
|
||||
package ecard
|
||||
{
|
||||
import buddy.BuddyManager;
|
||||
import com.sbi.client.SFEvent;
|
||||
import com.sbi.popup.SBOkPopup;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiManager;
|
||||
import gui.SafeChatManager;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class ECardXtCommManager
|
||||
{
|
||||
private static var _requestCallback:Function;
|
||||
private static var _readResponseCallback:Function;
|
||||
private static var _sendResponseCallback:Function;
|
||||
private static var _privacyResponseCallback:Function;
|
||||
private static var _giftResponseCallback:Function;
|
||||
private static var _giftRequestCallbackQueue:Object;
|
||||
public static var _deleteResponseCallback:Function;
|
||||
private static var NUM_JAGS_PER_NON_BUDDY_PER_SESSION:int = 5;
|
||||
private static var NUM_JAGS_PER_BUDDY_PER_SESSION:int = 25;
|
||||
private static var _jaggedPlayers:Object;
|
||||
private static var _privacySettingId:int;
|
||||
|
||||
public function ECardXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
_jaggedPlayers = {};
|
||||
_giftRequestCallbackQueue = {};
|
||||
}
|
||||
|
||||
public static function sendECardListRequest(param1:Function = null) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
if(param1 != null)
|
||||
{
|
||||
_loc2_ = 1;
|
||||
_requestCallback = param1;
|
||||
}
|
||||
gMainFrame.server.setXtObject_Str("el",[_loc2_]);
|
||||
}
|
||||
|
||||
public static function sendECardReadRequest(param1:int, param2:Function = null) : void
|
||||
{
|
||||
if(!gMainFrame.clientInfo.invisMode)
|
||||
{
|
||||
if(param2 != null)
|
||||
{
|
||||
_readResponseCallback = param2;
|
||||
}
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
gMainFrame.server.setXtObject_Str("er",[param1]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendECardSendRequest(param1:String, param2:String, param3:int, param4:int, param5:int, param6:String, param7:int, param8:int, param9:int, param10:Function = null) : Boolean
|
||||
{
|
||||
if(_jaggedPlayers[param1] == null)
|
||||
{
|
||||
_jaggedPlayers[param1] = 0;
|
||||
}
|
||||
var _loc11_:int = BuddyManager.isBuddy(param1) ? NUM_JAGS_PER_BUDDY_PER_SESSION : NUM_JAGS_PER_NON_BUDDY_PER_SESSION;
|
||||
// Moderators need to be able to send follow-up cards while helping
|
||||
// players, so do not apply the local per-recipient session cap.
|
||||
if(gMainFrame.userInfo.isModerator || _jaggedPlayers[param1] < _loc11_)
|
||||
{
|
||||
_jaggedPlayers[param1]++;
|
||||
if(param10 != null)
|
||||
{
|
||||
_sendResponseCallback = param10;
|
||||
}
|
||||
gMainFrame.server.setXtObject_Str("es",[param1,param3,param4,param5,param6,param7,param8,param9]);
|
||||
return true;
|
||||
}
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdAndInsertOnly(14691,param2));
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function sendECardDeleteRequest(param1:int, param2:Function = null) : void
|
||||
{
|
||||
if(param2 != null)
|
||||
{
|
||||
_deleteResponseCallback = param2;
|
||||
}
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
gMainFrame.server.setXtObject_Str("ed",[param1]);
|
||||
}
|
||||
|
||||
public static function sendECardBuddyRequest(param1:int, param2:Boolean) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("eb",[param1,param2 ? 1 : 0]);
|
||||
}
|
||||
|
||||
public static function sendECardAcceptDiscardGiftRequest(param1:int, param2:Boolean, param3:Function, param4:int = -1, param5:ECard = null) : void
|
||||
{
|
||||
if(!gMainFrame.clientInfo.invisMode)
|
||||
{
|
||||
if(param3 != null)
|
||||
{
|
||||
_giftResponseCallback = param3;
|
||||
}
|
||||
_giftRequestCallbackQueue[param1] = param5;
|
||||
gMainFrame.server.setXtObject_Str("eg",param4 >= 0 ? [param1,param2 ? 1 : 0,param4] : [param1,param2 ? 1 : 0]);
|
||||
}
|
||||
else if(param3 != null)
|
||||
{
|
||||
param3(0,true,param5);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendECardClearCache() : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("ec",[]);
|
||||
}
|
||||
|
||||
public static function sendECardPrivacySettingUpdateRequest(param1:int, param2:Function) : void
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
_privacyResponseCallback = param2;
|
||||
_privacySettingId = param1;
|
||||
gMainFrame.server.setXtObject_Str("ei",[param1]);
|
||||
}
|
||||
|
||||
public static function handleXtReply(param1:SFEvent) : void
|
||||
{
|
||||
var _loc2_:Object = param1.obj;
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
switch(_loc2_[0])
|
||||
{
|
||||
case "el":
|
||||
eCardListResponse(_loc2_);
|
||||
break;
|
||||
case "er":
|
||||
eCardReadResponse(_loc2_);
|
||||
break;
|
||||
case "ed":
|
||||
eCardDeleteResponse(_loc2_);
|
||||
break;
|
||||
case "es":
|
||||
eCardSendResponse(_loc2_);
|
||||
break;
|
||||
case "eg":
|
||||
eCardGiftResponse(_loc2_);
|
||||
break;
|
||||
case "eb":
|
||||
eCardBuddyResponse(_loc2_);
|
||||
break;
|
||||
case "ep":
|
||||
eCardPushHandler(_loc2_);
|
||||
break;
|
||||
case "eu":
|
||||
eCardUpdateHandler(_loc2_);
|
||||
break;
|
||||
case "ei":
|
||||
eCardIsolationHandler(_loc2_);
|
||||
break;
|
||||
default:
|
||||
throw new Error("ECardXtCommManager: Received illegal cmd: " + _loc2_[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static function eCardListResponse(param1:Object) : void
|
||||
{
|
||||
var _loc7_:ECard = null;
|
||||
var _loc5_:int = 0;
|
||||
if(!SafeChatManager.hasLoadedLists)
|
||||
{
|
||||
SafeChatManager.safeChatStringForCode(eCardListResponse,[param1],"",1);
|
||||
return;
|
||||
}
|
||||
var _loc2_:int = int(param1[2]);
|
||||
var _loc3_:Array = new Array(_loc2_);
|
||||
if(_loc2_ == -1)
|
||||
{
|
||||
_loc2_ = 0;
|
||||
}
|
||||
var _loc4_:int = 0;
|
||||
var _loc6_:int = 3;
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc2_)
|
||||
{
|
||||
_loc7_ = new ECard();
|
||||
_loc7_.init(int(param1[_loc6_++]),param1[_loc6_++],int(param1[_loc6_++]),int(param1[_loc6_++]),param1[_loc6_++] == "1",param1[_loc6_++],int(param1[_loc6_++]),int(param1[_loc6_++]),uint(param1[_loc6_++]),param1[_loc6_++],int(param1[_loc6_++]),int(param1[_loc6_++]),int(param1[_loc6_++]),int(param1[_loc6_++]),int(param1[_loc6_++]),param1[_loc6_++],param1[_loc6_++]);
|
||||
setGiftName(_loc7_);
|
||||
_loc3_[_loc2_ - 1 - _loc5_] = _loc7_;
|
||||
if(!_loc7_.isRead)
|
||||
{
|
||||
_loc4_++;
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
ECardManager.processECardList(_loc3_,_loc4_);
|
||||
if(_requestCallback != null)
|
||||
{
|
||||
_requestCallback(_loc3_);
|
||||
_requestCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function setGiftName(param1:ECard) : void
|
||||
{
|
||||
if(param1.msg.match("(^[0-9]{1,2},[0-9]{1,2}$)|(^[0-9]{1,2}$)"))
|
||||
{
|
||||
param1.msg = SafeChatManager.safeChatStringForCode(null,null,param1.msg,1);
|
||||
}
|
||||
if(param1.type == 4)
|
||||
{
|
||||
param1.giftName = LocalizationManager.translateIdAndInsertOnly(param1.giftName == "1" ? 11114 : 11097,Utility.convertNumberToString(int(param1.giftName)));
|
||||
}
|
||||
else if(param1.type == 9)
|
||||
{
|
||||
param1.giftName = LocalizationManager.translateIdAndInsertOnly(param1.giftName == "1" ? 11116 : 11103,Utility.convertNumberToString(int(param1.giftName)));
|
||||
}
|
||||
else if(param1.type == 5)
|
||||
{
|
||||
param1.giftName = LocalizationManager.translateIdAndInsertOnly(15000,LocalizationManager.translateIdOnly(int(param1.giftName)));
|
||||
}
|
||||
else
|
||||
{
|
||||
param1.giftName = LocalizationManager.translateIdOnly(int(param1.giftName));
|
||||
}
|
||||
}
|
||||
|
||||
private static function eCardReadResponse(param1:Object) : void
|
||||
{
|
||||
if(_readResponseCallback != null)
|
||||
{
|
||||
_readResponseCallback(int(param1[2]),param1[3] == "1");
|
||||
}
|
||||
}
|
||||
|
||||
private static function eCardDeleteResponse(param1:Object) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc6_:Boolean = param1[2] == "1" ? true : false;
|
||||
var _loc4_:int = int(param1[3]);
|
||||
var _loc3_:int = 4;
|
||||
var _loc5_:Array = new Array(_loc4_);
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _loc4_)
|
||||
{
|
||||
_loc5_[_loc2_] = param1[_loc3_++];
|
||||
_loc2_++;
|
||||
}
|
||||
if(_deleteResponseCallback != null)
|
||||
{
|
||||
_deleteResponseCallback(_loc5_,_loc6_);
|
||||
}
|
||||
}
|
||||
|
||||
private static function eCardSendResponse(param1:Object) : void
|
||||
{
|
||||
if(_sendResponseCallback != null)
|
||||
{
|
||||
_sendResponseCallback(param1[2]);
|
||||
}
|
||||
}
|
||||
|
||||
private static function eCardGiftResponse(param1:Object) : void
|
||||
{
|
||||
var _loc2_:ECard = null;
|
||||
if(_giftResponseCallback != null)
|
||||
{
|
||||
_loc2_ = _giftRequestCallbackQueue[int(param1[2])];
|
||||
delete _giftRequestCallbackQueue[int(param1[2])];
|
||||
_giftResponseCallback(int(param1[2]),param1[3] == "1",_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
private static function eCardBuddyResponse(param1:Object) : void
|
||||
{
|
||||
if(param1[2] == -1)
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14692));
|
||||
}
|
||||
}
|
||||
|
||||
private static function eCardIsolationHandler(param1:Object) : void
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
var _loc2_:Boolean = param1[2] == "1";
|
||||
if(_loc2_)
|
||||
{
|
||||
gMainFrame.userInfo.eCardPrivacySettings = _privacySettingId;
|
||||
}
|
||||
if(_privacyResponseCallback != null)
|
||||
{
|
||||
_privacyResponseCallback(_loc2_,_privacySettingId);
|
||||
_privacyResponseCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function eCardPushHandler(param1:Object) : void
|
||||
{
|
||||
if(!SafeChatManager.hasLoadedLists)
|
||||
{
|
||||
SafeChatManager.safeChatStringForCode(eCardPushHandler,[param1],"",1);
|
||||
return;
|
||||
}
|
||||
var _loc2_:ECard = new ECard();
|
||||
var _loc3_:int = 2;
|
||||
_loc2_.init(int(param1[_loc3_++]),param1[_loc3_++],int(param1[_loc3_++]),int(param1[_loc3_++]),param1[_loc3_++] == "1",param1[_loc3_++],int(param1[_loc3_++]),int(param1[_loc3_++]),uint(param1[_loc3_++]),param1[_loc3_++],int(param1[_loc3_++]),int(param1[_loc3_++]),int(param1[_loc3_++]),int(param1[_loc3_++]),int(param1[_loc3_++]),param1[_loc3_++],param1[_loc3_++]);
|
||||
setGiftName(_loc2_);
|
||||
ECardManager.processECardPush(_loc2_);
|
||||
}
|
||||
|
||||
private static function eCardUpdateHandler(param1:Object) : void
|
||||
{
|
||||
ECardManager.processECardUpdate(param1[2],param1[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,592 @@
|
||||
package gui
|
||||
{
|
||||
import achievement.AchievementXtCommManager;
|
||||
import com.sbi.analytics.SBTracker;
|
||||
import com.sbi.client.KeepAlive;
|
||||
import com.sbi.popup.SBStandardTitlePopup;
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.Event;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.external.ExternalInterface;
|
||||
import flash.net.URLLoader;
|
||||
import flash.net.URLRequest;
|
||||
import flash.net.URLRequestHeader;
|
||||
import flash.utils.ByteArray;
|
||||
import loader.FeedbackDefHelper;
|
||||
import loader.MediaHelper;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class FeedbackManager
|
||||
{
|
||||
|
||||
public static const TYPE_ASK_BRADY:int = 1;
|
||||
|
||||
public static const TYPE_ITEMS:int = 2;
|
||||
|
||||
public static const TYPE_HOWL:int = 3;
|
||||
|
||||
public static const TYPE_WORK:int = 4;
|
||||
|
||||
public static const TYPE_GENERIC:int = 5;
|
||||
|
||||
public static const TYPE_FLAGS:int = 6;
|
||||
|
||||
public static const TYPE_PETS:int = 7;
|
||||
|
||||
public static const TYPE_PARTIES:int = 8;
|
||||
|
||||
public static const TYPE_EPIC_ITEMS:int = 9;
|
||||
|
||||
public static const TYPE_ARCADE:int = 10;
|
||||
|
||||
public static const TYPE_ASK_TIERNEY:int = 11;
|
||||
|
||||
public static const TYPE_DONATION:int = 12;
|
||||
|
||||
public static const TYPE_CARNIVAL:int = 13;
|
||||
|
||||
public static const TYPE_ARTSTUDIO:int = 14;
|
||||
|
||||
public static const TYPE_JAMSESSION:int = 15;
|
||||
|
||||
public static const TYPE_DIAMOND:int = 16;
|
||||
|
||||
public static const TYPE_ADVENTURE:int = 17;
|
||||
|
||||
public static const TYPE_DICTIONARY:int = 18;
|
||||
|
||||
public static const TYPE_CHAT_EXPERIENCE:int = 19;
|
||||
|
||||
public static const TYPE_MASTERPIECES:int = 20;
|
||||
|
||||
public static const TYPE_ASK_CAMI:int = 21;
|
||||
|
||||
public static const TYPE_ASK_GABBY:int = 22;
|
||||
|
||||
private static const TAB_MEDIA_ID:int = 153;
|
||||
|
||||
private static const POPUP_MEDIA_ID:int = 457;
|
||||
|
||||
private static const TAB_FRAME_LABEL:String = "answer";
|
||||
|
||||
private static var _feedbackDefCache:Array;
|
||||
|
||||
private static var _feedbackLocs:Array;
|
||||
|
||||
private static var _feedbackDefHelpers:Array;
|
||||
|
||||
private static var _tabMediaHelper:MediaHelper;
|
||||
|
||||
private static var _tabTemplate:MovieClip;
|
||||
|
||||
private static var _popupMediaHelper:MediaHelper;
|
||||
|
||||
private static var _popup:MovieClip;
|
||||
|
||||
private static var _imageUploader:UserImageUpload;
|
||||
|
||||
private static var _guiLayer:DisplayLayer;
|
||||
|
||||
private static var _worldLayer:DisplayLayer;
|
||||
|
||||
private static var _secondaryType:int;
|
||||
|
||||
public function FeedbackManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init(param1:DisplayLayer, param2:DisplayLayer) : void
|
||||
{
|
||||
_feedbackDefCache = [];
|
||||
_guiLayer = param1;
|
||||
_worldLayer = param2;
|
||||
_popupMediaHelper = new MediaHelper();
|
||||
_tabMediaHelper = new MediaHelper();
|
||||
_tabMediaHelper.init(153,mediaHelperCallback,true);
|
||||
_imageUploader = new UserImageUpload();
|
||||
_imageUploader.init();
|
||||
if(ExternalInterface.available)
|
||||
{
|
||||
ExternalInterface.addCallback("openFeedback",handleOpenDefaultFeedback);
|
||||
}
|
||||
}
|
||||
|
||||
public static function setUpOrbs(param1:Array, param2:Array) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:Object = null;
|
||||
var _loc5_:FeedbackDefHelper = null;
|
||||
_feedbackLocs = param2;
|
||||
_feedbackDefHelpers = [];
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < param1.length)
|
||||
{
|
||||
if(param1[_loc4_] == 0)
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
throw new Error("Id == 0");
|
||||
}
|
||||
_loc3_ = _feedbackDefCache[param1[_loc4_]];
|
||||
if(!_loc3_)
|
||||
{
|
||||
_loc5_ = new FeedbackDefHelper();
|
||||
_loc5_.init(param1[_loc4_],onDefReceived);
|
||||
_feedbackDefHelpers[param1[_loc4_]] = _loc5_;
|
||||
}
|
||||
else
|
||||
{
|
||||
setUpOrb(_loc3_);
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
|
||||
public static function openFeedbackPopup(param1:int) : void
|
||||
{
|
||||
var _loc3_:FeedbackDefHelper = null;
|
||||
if(param1 == 0)
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
throw new Error("Id == 0");
|
||||
}
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
if(!_feedbackDefHelpers)
|
||||
{
|
||||
_feedbackDefHelpers = [];
|
||||
}
|
||||
var _loc2_:Object = _feedbackDefCache[param1];
|
||||
if(!_loc2_)
|
||||
{
|
||||
_loc3_ = new FeedbackDefHelper();
|
||||
_loc3_.init(param1,onDefReceived);
|
||||
_feedbackDefHelpers[param1] = _loc3_;
|
||||
}
|
||||
else
|
||||
{
|
||||
displayFeedbackPopup(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
private static function handleOpenDefaultFeedback() : void
|
||||
{
|
||||
openFeedbackPopup(5);
|
||||
}
|
||||
|
||||
private static function onDefReceived(param1:FeedbackDefHelper) : void
|
||||
{
|
||||
var _loc5_:Object = param1.def;
|
||||
var _loc4_:String = LocalizationManager.translateIdOnly(int(_loc5_.defaultStrRef));
|
||||
var _loc3_:RegExp = /\r\n/g;
|
||||
_loc4_ = _loc4_.replace(_loc3_,"\n");
|
||||
_loc3_ = /\r/g;
|
||||
_loc4_ = _loc4_.replace(_loc3_,"\n");
|
||||
var _loc2_:Object = {
|
||||
"id":int(_loc5_.id),
|
||||
"titleTxt":LocalizationManager.translateIdOnly(int(_loc5_.titleStrRef)),
|
||||
"defaultTxt":_loc4_,
|
||||
"thanksTxt":LocalizationManager.translateIdOnly(int(_loc5_.thankStrRef)),
|
||||
"allowImg":Boolean(int(_loc5_.bAcceptImage)),
|
||||
"userVarId":int(_loc5_.userVarRef),
|
||||
"bitIdx":int(_loc5_.bitIndex)
|
||||
};
|
||||
_feedbackDefCache[_loc2_.id] = _loc2_;
|
||||
_feedbackDefHelpers[_loc2_.id] = null;
|
||||
_loc2_.seen = gMainFrame.userInfo.userVarCache.isBitSet(_loc2_.userVarId,_loc2_.bitIdx);
|
||||
if(_loc2_.id == 1 || _loc2_.id == 11 || _loc2_.id == 3 || _loc2_.id == 4 || _loc2_.id == 5 || _loc2_.id == 18 || _loc2_.id == 19 || _loc2_.id == 21 || _loc2_.id == 22)
|
||||
{
|
||||
displayFeedbackPopup(_loc2_);
|
||||
}
|
||||
else
|
||||
{
|
||||
setUpOrb(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
private static function setUpOrb(param1:Object) : void
|
||||
{
|
||||
var _loc3_:MovieClip = null;
|
||||
var _loc2_:int = 0;
|
||||
if(_tabTemplate)
|
||||
{
|
||||
_loc3_ = new _tabTemplate.constructor();
|
||||
_loc3_.def = param1;
|
||||
_loc2_ = int(_loc3_.id = int(param1.id));
|
||||
_loc3_.x = _feedbackLocs[_loc2_].x;
|
||||
_loc3_.y = _feedbackLocs[_loc2_].y;
|
||||
if(param1.seen)
|
||||
{
|
||||
_loc3_.gotoAndPlay("answerDim");
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_.gotoAndPlay("answer");
|
||||
}
|
||||
_loc3_.addEventListener("mouseDown",onTabMouseDown,false,0,true);
|
||||
_worldLayer.addChild(_loc3_);
|
||||
}
|
||||
}
|
||||
|
||||
private static function mediaHelperCallback(param1:MovieClip) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
if(param1)
|
||||
{
|
||||
if(param1.mediaHelper.id == 153)
|
||||
{
|
||||
_loc2_ = int(param1.mediaHelper.id);
|
||||
_tabTemplate = MovieClip(param1.getChildAt(0));
|
||||
_tabMediaHelper.destroy();
|
||||
_tabMediaHelper = null;
|
||||
}
|
||||
else if(param1.mediaHelper.id == 457)
|
||||
{
|
||||
_popup = param1;
|
||||
_popupMediaHelper.destroy();
|
||||
_popupMediaHelper = null;
|
||||
_popup.x = 900 * 0.5;
|
||||
_popup.y = 550 * 0.5;
|
||||
_popup.parent.x = _popup.x;
|
||||
_popup.parent.y = _popup.y;
|
||||
displayFeedbackPopup(param1.passback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function onTabMouseDown(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
var _loc2_:MovieClip = MovieClip(param1.currentTarget);
|
||||
var _loc3_:Object = _loc2_.def;
|
||||
SBTracker.push();
|
||||
SBTracker.trackPageview("/game/play/popup/feedback/" + _loc3_.id);
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
if(!_loc3_.seen)
|
||||
{
|
||||
_loc2_.gotoAndPlay("answerDim");
|
||||
}
|
||||
displayFeedbackPopup(_loc3_);
|
||||
}
|
||||
|
||||
public static function displayFeedbackPopup(param1:Object) : void
|
||||
{
|
||||
var _loc3_:Array = null;
|
||||
var _loc2_:int = int(param1.id);
|
||||
if(!_popup)
|
||||
{
|
||||
_popupMediaHelper.init(457,mediaHelperCallback,param1);
|
||||
return;
|
||||
}
|
||||
if(!param1.seen)
|
||||
{
|
||||
param1.seen = true;
|
||||
AchievementXtCommManager.requestSetUserVar(param1.userVarId,param1.bitIdx);
|
||||
}
|
||||
removePopup();
|
||||
_popup.gotoAndStop(frameLabelForType(_loc2_));
|
||||
_popup.submitBtn.addEventListener("mouseDown",onMouseDown,false,0,true);
|
||||
_popup.bx.addEventListener("mouseDown",onMouseDown,false,0,true);
|
||||
_popup.addEventListener("mouseDown",onMouseDown,false,0,true);
|
||||
_popup.txt.addEventListener("mouseDown",onMouseDown,false,0,true);
|
||||
_popup.def = param1;
|
||||
if(_popup["descTxt"])
|
||||
{
|
||||
_loc3_ = param1.defaultTxt.split("|");
|
||||
LocalizationManager.updateToFit(_popup.descTxt,_loc3_[0]);
|
||||
LocalizationManager.updateToFit(_popup.txt,_loc3_[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
LocalizationManager.updateToFit(_popup.txt,param1.defaultTxt);
|
||||
}
|
||||
_popup.defaultTxt = _popup.txt.text;
|
||||
_popup.titleTxt.text = param1.titleTxt;
|
||||
if(param1.allowImg)
|
||||
{
|
||||
_popup.addFileBtn.visible = true;
|
||||
_imageUploader.setUploadBtn(_popup.addFileBtn);
|
||||
_popup.removeFileBtn.addEventListener("mouseDown",onRemoveFileBtn,false,0,true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_popup.addFileBtn)
|
||||
{
|
||||
_popup.addFileBtn.visible = false;
|
||||
}
|
||||
if(_popup.removeFileBtn)
|
||||
{
|
||||
_popup.removeFileBtn.visible = false;
|
||||
}
|
||||
}
|
||||
_popup.txt.maxChars = maxCharsForType(_loc2_);
|
||||
if(_loc2_ == 18)
|
||||
{
|
||||
_popup.txt.restrict = "^ ";
|
||||
}
|
||||
else
|
||||
{
|
||||
_popup.txt.restrict = null;
|
||||
}
|
||||
_popup.visible = true;
|
||||
_popup.clickedTextBox = false;
|
||||
KeepAlive.startKATimer(_popup);
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
DarkenManager.darken(DisplayObjectContainer(_popup));
|
||||
_guiLayer.addChild(DisplayObjectContainer(_popup));
|
||||
}
|
||||
|
||||
private static function frameLabelForType(param1:int) : int
|
||||
{
|
||||
switch(param1)
|
||||
{
|
||||
case 1:
|
||||
return 1;
|
||||
case 3:
|
||||
case 19:
|
||||
return 2;
|
||||
case 4:
|
||||
case 2:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 13:
|
||||
case 15:
|
||||
case 16:
|
||||
case 17:
|
||||
break;
|
||||
case 11:
|
||||
return 4;
|
||||
case 18:
|
||||
return 6;
|
||||
case 21:
|
||||
return 7;
|
||||
case 22:
|
||||
return 8;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
|
||||
private static function maxCharsForType(param1:int) : int
|
||||
{
|
||||
switch(param1)
|
||||
{
|
||||
case 1:
|
||||
case 11:
|
||||
case 21:
|
||||
case 22:
|
||||
return 150;
|
||||
case 3:
|
||||
return 50;
|
||||
case 4:
|
||||
return 3000;
|
||||
case 2:
|
||||
case 9:
|
||||
case 16:
|
||||
case 10:
|
||||
case 17:
|
||||
case 5:
|
||||
return 300;
|
||||
case 12:
|
||||
case 8:
|
||||
case 7:
|
||||
case 15:
|
||||
case 6:
|
||||
case 13:
|
||||
case 14:
|
||||
break;
|
||||
case 19:
|
||||
return 200;
|
||||
case 18:
|
||||
return 25;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
return 100;
|
||||
}
|
||||
|
||||
private static function onRemoveFileBtn(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
_imageUploader.resetUploader();
|
||||
_popup.addFileBtn.visible = true;
|
||||
}
|
||||
|
||||
private static function onMouseDown(param1:MouseEvent) : void
|
||||
{
|
||||
var _loc3_:String = null;
|
||||
var _loc2_:RegExp = null;
|
||||
param1.stopPropagation();
|
||||
if(param1.currentTarget == _popup)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(param1.currentTarget == _popup.txt)
|
||||
{
|
||||
if(!_popup.clickedTextBox)
|
||||
{
|
||||
_popup.txt.text = "";
|
||||
_popup.clickedTextBox = true;
|
||||
gMainFrame.stage.focus = _popup.txt;
|
||||
_popup.txt.setSelection(0,0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(param1.currentTarget.name == "submitBtn")
|
||||
{
|
||||
_loc3_ = _popup.txt.text;
|
||||
_loc2_ = /\r\n/g;
|
||||
_loc3_ = _loc3_.replace(_loc2_,"\n");
|
||||
_loc2_ = /\r/g;
|
||||
_loc3_ = _loc3_.replace(_loc2_,"\n");
|
||||
if(_loc3_.length > 0 && _loc3_ != _popup.defaultTxt || _imageUploader.fileName != "")
|
||||
{
|
||||
if(_loc3_ == _popup.def.defaultTxt)
|
||||
{
|
||||
_loc3_ = _popup.txt.text = "";
|
||||
}
|
||||
setupRequest(_imageUploader,_loc3_,_popup.def.id,_secondaryType,onSendComplete,onSendError);
|
||||
}
|
||||
}
|
||||
removePopup(param1.currentTarget.name == "bx");
|
||||
}
|
||||
|
||||
private static function removePopup(param1:Boolean = true) : void
|
||||
{
|
||||
if(_popup)
|
||||
{
|
||||
_popup.removeEventListener("mouseDown",onMouseDown);
|
||||
_popup.bx.removeEventListener("mouseDown",onMouseDown);
|
||||
_popup.submitBtn.removeEventListener("mouseDown",onMouseDown);
|
||||
_popup.txt.removeEventListener("mouseDown",onMouseDown);
|
||||
if(_popup.def && _popup.def.allowImg)
|
||||
{
|
||||
_imageUploader.resetUploader();
|
||||
_popup.addFileBtn.visible = true;
|
||||
_popup.removeFileBtn.removeEventListener("mouseDown",onRemoveFileBtn);
|
||||
}
|
||||
DarkenManager.unDarken(_popup);
|
||||
_popup.visible = false;
|
||||
SBTracker.pop();
|
||||
if(!param1)
|
||||
{
|
||||
new SBStandardTitlePopup(_guiLayer,_popup.def.thanksTxt);
|
||||
}
|
||||
KeepAlive.stopKATimer(_popup);
|
||||
}
|
||||
}
|
||||
|
||||
// feedback goes to this server's staff (lib/world.js xfb) over the
|
||||
// game's own connection, which says who wrote it: it went to the
|
||||
// official moderation server's "fb", which here answered nothing. a
|
||||
// museum donation (type 12) is the gems themselves
|
||||
// (ItemXtCommManager.requestDonateGems): nothing more goes. pictures
|
||||
// are not taken.
|
||||
public static function setupRequest(param1:UserImageUpload, param2:String, param3:int, param4:int, param5:Function, param6:Function) : void
|
||||
{
|
||||
var _loc7_:String = param2 != null ? param2.split("%").join("").replace(/[\r\n]+/g," ") : "";
|
||||
if(param3 != 12 && _loc7_.replace(/\s+/g,"").length > 0)
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("xfb",[param3,_loc7_.substr(0,1000)]);
|
||||
}
|
||||
if(param5 != null)
|
||||
{
|
||||
param5(new Event("complete"));
|
||||
}
|
||||
}
|
||||
|
||||
public static function createPostData(param1:String, param2:ByteArray, param3:String, param4:Object = null) : ByteArray
|
||||
{
|
||||
var _loc5_:String = null;
|
||||
var _loc7_:int = 0;
|
||||
var _loc8_:ByteArray = new ByteArray();
|
||||
_loc8_.endian = "bigEndian";
|
||||
if(param4 == null)
|
||||
{
|
||||
param4 = {};
|
||||
}
|
||||
for(var _loc6_:String in param4)
|
||||
{
|
||||
writeBoundary(_loc8_,param3);
|
||||
writeLineBreak(_loc8_);
|
||||
_loc5_ = "Content-Disposition: form-data; name=\"" + _loc6_ + "\"";
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc5_.length)
|
||||
{
|
||||
_loc8_.writeByte(_loc5_.charCodeAt(_loc7_));
|
||||
_loc7_++;
|
||||
}
|
||||
writeLineBreak(_loc8_);
|
||||
writeLineBreak(_loc8_);
|
||||
_loc8_.writeUTFBytes(param4[_loc6_]);
|
||||
writeLineBreak(_loc8_);
|
||||
}
|
||||
if(param2)
|
||||
{
|
||||
writeBoundary(_loc8_,param3);
|
||||
writeLineBreak(_loc8_);
|
||||
_loc5_ = "Content-Disposition: form-data; name=\"image\"; filename=\"" + param1 + "\"";
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc5_.length)
|
||||
{
|
||||
_loc8_.writeByte(_loc5_.charCodeAt(_loc7_));
|
||||
_loc7_++;
|
||||
}
|
||||
writeLineBreak(_loc8_);
|
||||
_loc5_ = "Content-Type: image/jpeg";
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc5_.length)
|
||||
{
|
||||
_loc8_.writeByte(_loc5_.charCodeAt(_loc7_));
|
||||
_loc7_++;
|
||||
}
|
||||
writeLineBreak(_loc8_);
|
||||
writeLineBreak(_loc8_);
|
||||
_loc8_.writeBytes(param2,0,param2.length);
|
||||
writeLineBreak(_loc8_);
|
||||
}
|
||||
writeBoundary(_loc8_,param3);
|
||||
writeDoubleDash(_loc8_);
|
||||
writeLineBreak(_loc8_);
|
||||
return _loc8_;
|
||||
}
|
||||
|
||||
private static function writeLineBreak(param1:ByteArray) : void
|
||||
{
|
||||
param1.writeShort(3338);
|
||||
}
|
||||
|
||||
private static function writeDoubleDash(param1:ByteArray) : void
|
||||
{
|
||||
param1.writeShort(11565);
|
||||
}
|
||||
|
||||
private static function writeBoundary(param1:ByteArray, param2:String) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
writeDoubleDash(param1);
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < param2.length)
|
||||
{
|
||||
param1.writeByte(param2.charCodeAt(_loc3_));
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
|
||||
private static function onSendComplete(param1:Event) : void
|
||||
{
|
||||
trace("w00t!");
|
||||
}
|
||||
|
||||
private static function onSendError(param1:Event) : void
|
||||
{
|
||||
trace("Argh! Error sending....");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package gui
|
||||
{
|
||||
import collection.StreamDefCollection;
|
||||
import flash.external.ExternalInterface;
|
||||
import movie.MovieManager;
|
||||
import quest.QuestManager;
|
||||
import room.RoomManagerWorld;
|
||||
@@ -50,10 +51,17 @@ package gui
|
||||
var _loc4_:Boolean = false;
|
||||
// the video lists came from the official server; this one answers
|
||||
// them empty, and a player with nothing to play threw (#1009 in
|
||||
// VideoPlayerOSMF.playNonStreaming)
|
||||
// VideoPlayerOSMF.playNonStreaming). a video spot clicked opens the
|
||||
// game page's video box instead (game.html ajVideoSpot), for a link
|
||||
// of the player's own; the trade list's help plays a video of ours.
|
||||
// a list the room plays by itself ("autoplay") opens nothing.
|
||||
if(param2 == null || param2.length == 0)
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
if(param3 == null || param3.msg == null || String(param3.msg).indexOf("autoplay") == -1)
|
||||
{
|
||||
openVideoSpot(param1 == TRADE_HELP_LIST ? TRADE_HELP_VIDEO : "");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(param2.length > 1)
|
||||
@@ -143,6 +151,27 @@ package gui
|
||||
movieSelector.destroy();
|
||||
movieSelector = null;
|
||||
}
|
||||
openVideoSpot("close");
|
||||
}
|
||||
|
||||
// the trade list's "how to trade" video (AvatarEditor.onInfoBtnDown)
|
||||
private static const TRADE_HELP_LIST:int = 22;
|
||||
private static const TRADE_HELP_VIDEO:String = "dQw4w9WgXcQ";
|
||||
|
||||
// the game page's video box (game.html ajVideoSpot): a YouTube id to
|
||||
// play, "" for a link of the player's choosing, "close" to put it away
|
||||
public static function openVideoSpot(param1:String) : void
|
||||
{
|
||||
try
|
||||
{
|
||||
if(ExternalInterface.available)
|
||||
{
|
||||
ExternalInterface.call("ajVideoSpot",param1);
|
||||
}
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public static function togglePlayPauseVideoPlayer(param1:Boolean) : void
|
||||
|
||||
@@ -270,6 +270,10 @@ package gui
|
||||
private static var _namebarBadgeList:Array;
|
||||
|
||||
private static var _sharedObj:SharedObject;
|
||||
|
||||
private static var _customChatBubbles:Boolean = true;
|
||||
|
||||
private static var _chatBubbleAnimations:Boolean = true;
|
||||
|
||||
private static var _giftGemsMediaHelper:MediaHelper;
|
||||
|
||||
@@ -365,11 +369,15 @@ package gui
|
||||
public static function setupSharedObject() : void
|
||||
{
|
||||
_sharedObj = null;
|
||||
_customChatBubbles = true;
|
||||
_chatBubbleAnimations = true;
|
||||
if(gMainFrame.myFlashVarUserName != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
_sharedObj = SharedObject.getLocal(gMainFrame.myFlashVarUserName);
|
||||
_customChatBubbles = _sharedObj.data.customChatBubbles !== false;
|
||||
_chatBubbleAnimations = _sharedObj.data.chatBubbleAnimations !== false;
|
||||
if(_sharedObj.data.cursor == null || _sharedObj.data.cursor == "custom")
|
||||
{
|
||||
CursorManager.switchToCursor("custom_cursor");
|
||||
@@ -459,6 +467,55 @@ package gui
|
||||
{
|
||||
return _sharedObj;
|
||||
}
|
||||
|
||||
// A local accessibility/preference switch: players can keep their own
|
||||
// saved style visible to others while rendering every bubble normally
|
||||
// on this installation.
|
||||
public static function customChatBubblesEnabled() : Boolean
|
||||
{
|
||||
return _customChatBubbles;
|
||||
}
|
||||
|
||||
public static function setCustomChatBubblesEnabled(param1:Boolean) : void
|
||||
{
|
||||
_customChatBubbles = param1;
|
||||
if(_sharedObj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_sharedObj.data.customChatBubbles = param1;
|
||||
try
|
||||
{
|
||||
_sharedObj.flush();
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// the same, for custom bubbles' animations (pulse, shimmer, flow,
|
||||
// rainbow): off, every bubble keeps its colours and stands still.
|
||||
public static function chatBubbleAnimationsEnabled() : Boolean
|
||||
{
|
||||
return _chatBubbleAnimations;
|
||||
}
|
||||
|
||||
public static function setChatBubbleAnimationsEnabled(param1:Boolean) : void
|
||||
{
|
||||
_chatBubbleAnimations = param1;
|
||||
if(_sharedObj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_sharedObj.data.chatBubbleAnimations = param1;
|
||||
try
|
||||
{
|
||||
_sharedObj.flush();
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public static function startFFM(param1:Boolean = false) : void
|
||||
{
|
||||
@@ -966,6 +1023,15 @@ package gui
|
||||
|
||||
public static function initMoviePlayer(param1:int, param2:StreamDefCollection, param3:Boolean = true, param4:int = 512, param5:int = 288) : void
|
||||
{
|
||||
// nothing to play (the official server's video lists are gone; a
|
||||
// tutorial video that never came): the game page's video box
|
||||
// instead, as GenericListGuiManager.launchMovies does.
|
||||
if(param2 == null || param2.length == 0 || param2.getStreamDefItem(0) == null)
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
GenericListGuiManager.openVideoSpot("");
|
||||
return;
|
||||
}
|
||||
if(_videoPlayer)
|
||||
{
|
||||
_videoPlayer.destroy();
|
||||
|
||||
@@ -61,7 +61,11 @@ package gui.itemWindows
|
||||
private var _hasSetState:Boolean;
|
||||
|
||||
private var _isSellShop:Boolean;
|
||||
|
||||
|
||||
// smaller with Expanded Inventory on (AJClient.inventoryColumns): 3
|
||||
// over the items a row, so a row is as wide as the game's three.
|
||||
private var _itemScale:Number = 1;
|
||||
|
||||
public function ItemWindowOriginal(param1:Function, param2:Object, param3:String, param4:int, param5:Function = null, param6:Function = null, param7:Function = null, param8:Function = null, param9:Object = null)
|
||||
{
|
||||
var _loc11_:int = 0;
|
||||
@@ -89,6 +93,10 @@ package gui.itemWindows
|
||||
_loc11_ = int(param9.indexArray.length);
|
||||
_loc10_ = int(_loc11_ - 1 >= param4 ? param9.indexArray[param4] : param4);
|
||||
}
|
||||
if(param9.itemScale > 0)
|
||||
{
|
||||
_itemScale = param9.itemScale;
|
||||
}
|
||||
}
|
||||
super("itemWindow",param1,param2,param3,_loc10_,param5,param6,param7,param8,true);
|
||||
}
|
||||
@@ -576,6 +584,19 @@ package gui.itemWindows
|
||||
|
||||
override protected function onWindowLoadCallback() : void
|
||||
{
|
||||
// the generator spaces the windows by their width and height,
|
||||
// which are sizeCont's (ItemWindowBase) and do not shrink with the
|
||||
// window, so sizeCont is made as much smaller.
|
||||
if(_itemScale != 1 && _window)
|
||||
{
|
||||
if(_window.hasOwnProperty("sizeCont") && _window.sizeCont)
|
||||
{
|
||||
_window.sizeCont.width *= _itemScale;
|
||||
_window.sizeCont.height *= _itemScale;
|
||||
}
|
||||
this.scaleX = _itemScale;
|
||||
this.scaleY = _itemScale;
|
||||
}
|
||||
if(_windowLoadedCallback != null)
|
||||
{
|
||||
resetVisibility();
|
||||
|
||||
+1025
-52
File diff suppressed because it is too large.
Load diff
+37
-14
@@ -171,8 +171,10 @@ package com.sbi.graphics
|
||||
|
||||
private var _receivedData:Array;
|
||||
|
||||
// each requested image's place in _layers: items worn in the same
|
||||
// slot are drawn in that order, the later over the earlier
|
||||
// each requested image's places in _layers: different items can use
|
||||
// the same art layer, so one image response can paint several pieces.
|
||||
// Items worn in the same slot are drawn in their original order, the
|
||||
// later over the earlier.
|
||||
private var _order:Object;
|
||||
|
||||
private var _requestedIds:Set;
|
||||
@@ -738,10 +740,16 @@ package com.sbi.graphics
|
||||
param2.push(_loc4_);
|
||||
if(param3)
|
||||
{
|
||||
param3[_loc4_] = _loc5_.c;
|
||||
if(_order)
|
||||
{
|
||||
_order[_loc4_] = _loc6_;
|
||||
if(!_order[_loc4_])
|
||||
{
|
||||
_order[_loc4_] = [];
|
||||
}
|
||||
_order[_loc4_].push({
|
||||
"p":_loc6_,
|
||||
"c":_loc5_.c
|
||||
});
|
||||
}
|
||||
}
|
||||
_loc6_++;
|
||||
@@ -761,6 +769,8 @@ package com.sbi.graphics
|
||||
{
|
||||
var _loc2_:* = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc8_:Array = null;
|
||||
var _loc9_:Object = null;
|
||||
if(_preloadRequestedIds.remove(param1.id))
|
||||
{
|
||||
if(_preloadRequestedIds.isEmpty())
|
||||
@@ -778,18 +788,31 @@ package com.sbi.graphics
|
||||
if(_requestedIds.remove(param1.id))
|
||||
{
|
||||
_loc3_ = param1.layer;
|
||||
if(_loc3_ > 0)
|
||||
{
|
||||
_loc2_ = uint(_colors[param1.id]);
|
||||
}
|
||||
if(param1.success)
|
||||
{
|
||||
_receivedData.push({
|
||||
"l":_loc3_,
|
||||
"d":param1.imageData,
|
||||
"c":_loc2_,
|
||||
"p":(_order && _order.hasOwnProperty(param1.id) ? int(_order[param1.id]) : -1)
|
||||
});
|
||||
_loc8_ = _order && _order.hasOwnProperty(param1.id) ? _order[param1.id] as Array : null;
|
||||
if(_loc8_ && _loc8_.length > 0)
|
||||
{
|
||||
for each(_loc9_ in _loc8_)
|
||||
{
|
||||
_receivedData.push({
|
||||
"l":_loc3_,
|
||||
"d":param1.imageData,
|
||||
"c":uint(_loc9_.c),
|
||||
"p":int(_loc9_.p)
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// the animal's base has no entry in _order
|
||||
_receivedData.push({
|
||||
"l":_loc3_,
|
||||
"d":param1.imageData,
|
||||
"c":_loc2_,
|
||||
"p":-1
|
||||
});
|
||||
}
|
||||
}
|
||||
if(_requestedIds.isEmpty())
|
||||
{
|
||||
|
||||
@@ -0,0 +1,551 @@
|
||||
package game.microSmoothie
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.geom.Point;
|
||||
import flash.utils.getTimer;
|
||||
import game.GameBase;
|
||||
import game.IMinigame;
|
||||
import game.MinigameManager;
|
||||
import game.SoundManager;
|
||||
import gskinner.motion.GTween;
|
||||
|
||||
public class MicroSmoothie extends GameBase implements IMinigame
|
||||
{
|
||||
|
||||
private static const MAX_VELOCITY_X:Number = 900;
|
||||
|
||||
private static const MAX_VELOCITY_Y:Number = 250;
|
||||
|
||||
private static const ACCELERATION_X:Number = 2500;
|
||||
|
||||
private static const ACCELERATION_Y:Number = 450;
|
||||
|
||||
private static const BRAKE_X:Number = 4000;
|
||||
|
||||
private static const BRAKE_Y:Number = 800;
|
||||
|
||||
private static const REQUIRED_FRUITS:int = 10;
|
||||
|
||||
public var _fruitTypesColor:Array;
|
||||
|
||||
public var _fruitTypes:Array;
|
||||
|
||||
public var myId:uint;
|
||||
|
||||
public var _pIDs:Array;
|
||||
|
||||
public var _dbIDs:Array;
|
||||
|
||||
private var _sceneLoaded:Boolean;
|
||||
|
||||
private var _bInit:Boolean;
|
||||
|
||||
public var _layerBack:Sprite;
|
||||
|
||||
public var _layerFront:Sprite;
|
||||
|
||||
public var _layerFruits:Sprite;
|
||||
|
||||
public var _layerCupFront:Sprite;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _frameTime:Number;
|
||||
|
||||
private var _gameTime:Number;
|
||||
|
||||
private var _cupFront:Object;
|
||||
|
||||
private var _cupBack:Object;
|
||||
|
||||
private var _cupFrontMax:Object;
|
||||
|
||||
private var _cupBackMax:Object;
|
||||
|
||||
private var _fruitMachine:Object;
|
||||
|
||||
private var _ready:Object;
|
||||
|
||||
private var _congrats:Object;
|
||||
|
||||
private var _fruitStart:Object;
|
||||
|
||||
public var _leftArrowDown:Boolean;
|
||||
|
||||
public var _rightArrowDown:Boolean;
|
||||
|
||||
public var _downArrowDown:Boolean;
|
||||
|
||||
public var _upArrowDown:Boolean;
|
||||
|
||||
public var _nextFruitTimer:Number;
|
||||
|
||||
public var _congratsTimer:Number;
|
||||
|
||||
public var _velocityX:Number;
|
||||
|
||||
public var _fruitCaught:int;
|
||||
|
||||
public var _smoothieType:int;
|
||||
|
||||
private var _dismissDialogTimer:Number;
|
||||
|
||||
public var _soundMan:SoundManager;
|
||||
|
||||
public var _fruitStartSounds:Array;
|
||||
|
||||
private var _audio:Array = ["slushy_fruit_passby.mp3","slushy_fruit_passby2.mp3","slushy_correct_fruit.mp3","slushy_wrong_fruit.mp3","MG_popup_youWon.mp3"];
|
||||
|
||||
private var _soundNameFruitStart1:String = _audio[0];
|
||||
|
||||
private var _soundNameFruitStart2:String = _audio[1];
|
||||
|
||||
private var _soundNameCorrect:String = _audio[2];
|
||||
|
||||
private var _soundNameWrong:String = _audio[3];
|
||||
|
||||
private var _soundNamePlayerWins:String = _audio[4];
|
||||
|
||||
public function MicroSmoothie()
|
||||
{
|
||||
super();
|
||||
_fruitTypesColor = new Array("purple","orange","red","yellow");
|
||||
_fruitTypes = new Array("grapes","orange","strawberry","banana");
|
||||
init();
|
||||
}
|
||||
|
||||
private function loadSounds() : void
|
||||
{
|
||||
_fruitStartSounds = [];
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameFruitStart1],_soundNameFruitStart1,0.5);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameFruitStart2],_soundNameFruitStart2,0.5);
|
||||
_fruitStartSounds = new Array(_soundNameFruitStart1,_soundNameFruitStart2);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameCorrect],_soundNameCorrect,0.8);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNameWrong],_soundNameWrong,0.8);
|
||||
_soundMan.addSoundByName(_audioByName[_soundNamePlayerWins],_soundNamePlayerWins,0.35);
|
||||
}
|
||||
|
||||
private function keyHandleUp(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(int(param1.keyCode) - 37)
|
||||
{
|
||||
case 0:
|
||||
_leftArrowDown = false;
|
||||
break;
|
||||
case 1:
|
||||
_upArrowDown = false;
|
||||
break;
|
||||
case 2:
|
||||
_rightArrowDown = false;
|
||||
break;
|
||||
case 3:
|
||||
_downArrowDown = false;
|
||||
}
|
||||
}
|
||||
|
||||
private function keyHandleDown(param1:KeyboardEvent) : void
|
||||
{
|
||||
switch(int(param1.keyCode) - 37)
|
||||
{
|
||||
case 0:
|
||||
_leftArrowDown = true;
|
||||
break;
|
||||
case 1:
|
||||
_upArrowDown = true;
|
||||
break;
|
||||
case 2:
|
||||
_rightArrowDown = true;
|
||||
break;
|
||||
case 3:
|
||||
_downArrowDown = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function start(param1:uint, param2:Array) : void
|
||||
{
|
||||
myId = param1;
|
||||
_pIDs = param2;
|
||||
init();
|
||||
}
|
||||
|
||||
public function end(param1:Array) : void
|
||||
{
|
||||
releaseBase();
|
||||
stage.removeEventListener("keyUp",keyHandleUp);
|
||||
stage.removeEventListener("keyDown",keyHandleDown);
|
||||
stage.removeEventListener("enterFrame",heartbeat);
|
||||
stage.removeEventListener("click",mouseClickHandler);
|
||||
resetGame();
|
||||
_bInit = false;
|
||||
removeLayer(_layerBack);
|
||||
removeLayer(_layerFront);
|
||||
removeLayer(_layerFruits);
|
||||
removeLayer(_layerCupFront);
|
||||
removeLayer(_guiLayer);
|
||||
_layerBack = null;
|
||||
_layerFront = null;
|
||||
_layerFruits = null;
|
||||
_layerCupFront = null;
|
||||
_guiLayer = null;
|
||||
MinigameManager.leave();
|
||||
}
|
||||
|
||||
private function init() : void
|
||||
{
|
||||
if(!_bInit)
|
||||
{
|
||||
_layerBack = new Sprite();
|
||||
_layerFront = new Sprite();
|
||||
_layerFruits = new Sprite();
|
||||
_layerCupFront = new Sprite();
|
||||
_layerBack.mouseEnabled = false;
|
||||
_layerFront.mouseEnabled = false;
|
||||
_layerFruits.mouseEnabled = false;
|
||||
_layerCupFront.mouseEnabled = false;
|
||||
_guiLayer = new Sprite();
|
||||
addChild(_layerBack);
|
||||
addChild(_layerFruits);
|
||||
addChild(_layerFront);
|
||||
addChild(_layerCupFront);
|
||||
addChild(_guiLayer);
|
||||
loadScene("SmoothieAssets/room_main.xroom",_audio);
|
||||
_bInit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
|
||||
override protected function sceneLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:* = null;
|
||||
_soundMan = new SoundManager(this);
|
||||
loadSounds();
|
||||
_loc4_ = _scene.getLayer("closeButton");
|
||||
addBtn("CloseButton",_loc4_.x,_loc4_.y,onCloseButton);
|
||||
_cupFront = _scene.getLayer("cupFront");
|
||||
_cupBack = _scene.getLayer("cupBack");
|
||||
_cupFrontMax = _scene.getLayer("cupFrontMax");
|
||||
_cupBackMax = _scene.getLayer("cupBackMax");
|
||||
_fruitMachine = _scene.getLayer("smoothieGame");
|
||||
_layerBack.addChild(_scene.getLayer("smoothieBackground").loader);
|
||||
_layerBack.addChild(_cupBack.loader);
|
||||
_layerFruits.addChild(_fruitMachine.loader);
|
||||
_layerCupFront.addChild(_cupFront.loader);
|
||||
_congrats = _scene.getLayer("smoothieSuccess");
|
||||
_leftArrowDown = false;
|
||||
_rightArrowDown = false;
|
||||
_downArrowDown = false;
|
||||
_upArrowDown = false;
|
||||
stage.addEventListener("keyUp",keyHandleUp);
|
||||
stage.addEventListener("keyDown",keyHandleDown);
|
||||
_sceneLoaded = true;
|
||||
stage.addEventListener("enterFrame",heartbeat,false,0,true);
|
||||
stage.addEventListener("click",mouseClickHandler);
|
||||
startGame();
|
||||
super.sceneLoaded(param1);
|
||||
}
|
||||
|
||||
public function message(param1:Array) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] != "ml")
|
||||
{
|
||||
if(param1[0] == "ms")
|
||||
{
|
||||
_dbIDs = [];
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _pIDs.length)
|
||||
{
|
||||
_dbIDs[_loc2_] = param1[_loc2_ + 1];
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
else if(param1[0] == "mm")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function heartbeat(param1:Event) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc7_:* = null;
|
||||
var _loc6_:Point = null;
|
||||
var _loc5_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
var _loc4_:int = 0;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_frameTime = (getTimer() - _lastTime) / 1000;
|
||||
if(_frameTime > 0.5)
|
||||
{
|
||||
_frameTime = 0.5;
|
||||
}
|
||||
_lastTime = getTimer();
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_gameTime += _frameTime;
|
||||
if(_fruitCaught < 10)
|
||||
{
|
||||
if(_dismissDialogTimer > 0)
|
||||
{
|
||||
_dismissDialogTimer -= _frameTime;
|
||||
if(_dismissDialogTimer <= 0)
|
||||
{
|
||||
hideDlg();
|
||||
_nextFruitTimer = 1.5;
|
||||
}
|
||||
}
|
||||
else if(_nextFruitTimer >= 0)
|
||||
{
|
||||
_loc6_ = localToGlobal(new Point(_cupBack.loader.x,_cupBack.loader.y));
|
||||
_loc5_ = int(_fruitMachine.loader.content.detectCollision(_loc6_.x,_loc6_.y,_cupBack.width,_cupBack.height + 75));
|
||||
if(_loc5_ >= 0)
|
||||
{
|
||||
if(_loc5_ == _smoothieType)
|
||||
{
|
||||
_soundMan.playByName(_soundNameCorrect);
|
||||
_fruitCaught += 2;
|
||||
updateFruitMeter();
|
||||
if(_fruitCaught >= 10)
|
||||
{
|
||||
new GTween(_fruitMachine.loader,0.5,{"alpha":0});
|
||||
_guiLayer.addChild(_congrats.loader);
|
||||
_congrats.loader.content.Ready_Text.gotoAndPlay("on");
|
||||
if(_closeBtn)
|
||||
{
|
||||
_closeBtn.visible = false;
|
||||
}
|
||||
// the adventure's own smoothie machine (91) counts
|
||||
// towards it; any other gives a smoothie, even when
|
||||
// the game it is was not noted down (-1), where
|
||||
// before it gave nothing
|
||||
if(MinigameManager.minigameInfoCache && MinigameManager.minigameInfoCache.currMinigameId == 91)
|
||||
{
|
||||
MinigameManager.handleQuestMiniGameComplete(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
MinigameManager.msg(["_a",2,_fruitTypesColor[_smoothieType]]);
|
||||
}
|
||||
_congratsTimer = 3;
|
||||
_soundMan.playByName(_soundNamePlayerWins);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_soundMan.playByName(_soundNameWrong);
|
||||
_cupFront.loader.content.loseSlush();
|
||||
_fruitCaught -= 2;
|
||||
if(_fruitCaught < 0)
|
||||
{
|
||||
_fruitCaught = 0;
|
||||
}
|
||||
updateFruitMeter();
|
||||
}
|
||||
}
|
||||
_nextFruitTimer -= _frameTime;
|
||||
if(_nextFruitTimer <= 0)
|
||||
{
|
||||
_loc2_ = Math.random() * 6;
|
||||
if(_loc2_ >= 3)
|
||||
{
|
||||
_loc2_ = _smoothieType;
|
||||
}
|
||||
else if(_smoothieType == _loc2_)
|
||||
{
|
||||
_loc2_ = 3;
|
||||
}
|
||||
_nextFruitTimer = 0.5 + Math.random() * 0.5;
|
||||
_fruitMachine.loader.content.createFruit(_loc2_);
|
||||
_loc4_ = Math.random() * _fruitStartSounds.length;
|
||||
_soundMan.playByName(_fruitStartSounds[_loc4_]);
|
||||
}
|
||||
_cupBack.loader.x = stage.mouseX - _cupFront.width / 2;
|
||||
_cupFront.loader.x = stage.mouseX - _cupFront.width / 2;
|
||||
if(_cupFront.loader.x < _cupFront.x)
|
||||
{
|
||||
_cupBack.loader.x = _cupBack.x;
|
||||
_cupFront.loader.x = _cupFront.x;
|
||||
}
|
||||
else if(_cupFront.loader.x > _cupFrontMax.x)
|
||||
{
|
||||
_cupBack.loader.x = _cupBackMax.x;
|
||||
_cupFront.loader.x = _cupFrontMax.x;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_congratsTimer -= _frameTime;
|
||||
if(_congratsTimer <= 0)
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function updateFruitMeter() : void
|
||||
{
|
||||
var _loc1_:int = 2;
|
||||
if(_fruitCaught > 0)
|
||||
{
|
||||
_loc1_ = Math.max(3,_fruitCaught / 10 * 15 + 1);
|
||||
if(_loc1_ > 16)
|
||||
{
|
||||
_loc1_ = 16;
|
||||
}
|
||||
}
|
||||
_cupFront.loader.content.gotoAndStop(_loc1_);
|
||||
}
|
||||
|
||||
public function updateControls() : void
|
||||
{
|
||||
if(stage.mouseX < _cupFront.loader.x + _cupFront.width / 5)
|
||||
{
|
||||
_velocityX -= 2500 * _frameTime;
|
||||
if(_velocityX < -900)
|
||||
{
|
||||
_velocityX = -900;
|
||||
}
|
||||
}
|
||||
else if(stage.mouseX > _cupFront.loader.x + 4 * _cupFront.width / 5)
|
||||
{
|
||||
_velocityX += 2500 * _frameTime;
|
||||
if(_velocityX > 900)
|
||||
{
|
||||
_velocityX = 900;
|
||||
}
|
||||
}
|
||||
else if(_velocityX > 0)
|
||||
{
|
||||
_velocityX -= 4000 * _frameTime;
|
||||
if(_velocityX < 0)
|
||||
{
|
||||
_velocityX = 0;
|
||||
}
|
||||
}
|
||||
else if(_velocityX < 0)
|
||||
{
|
||||
_velocityX += 4000 * _frameTime;
|
||||
if(_velocityX > 0)
|
||||
{
|
||||
_velocityX = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function startGame() : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc4_:* = null;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc1_:MovieClip = null;
|
||||
_gameTime = 0;
|
||||
_lastTime = getTimer();
|
||||
_frameTime = 0;
|
||||
_nextFruitTimer = -1;
|
||||
_dismissDialogTimer = 0;
|
||||
_fruitCaught = 0;
|
||||
_velocityX = 0;
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
_loc3_ = (_cupFrontMax.x - _cupFront.x) / 2;
|
||||
_cupFront.loader.x = _cupFront.x + _loc3_;
|
||||
_cupBack.loader.x = _cupBack.x + _loc3_;
|
||||
_cupFront.loader.content.gotoAndStop(2);
|
||||
_loc1_ = showDlg("popup_flavor",[{
|
||||
"name":"button_strawberry",
|
||||
"f":onFlavorStrawberry
|
||||
},{
|
||||
"name":"button_orange",
|
||||
"f":onFlavorOrange
|
||||
},{
|
||||
"name":"button_banana",
|
||||
"f":onFlavorBanana
|
||||
},{
|
||||
"name":"button_grape",
|
||||
"f":onFlavorGrape
|
||||
}]);
|
||||
_loc1_.x = 455;
|
||||
_loc1_.y = 225;
|
||||
}
|
||||
}
|
||||
|
||||
public function resetGame() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
}
|
||||
|
||||
private function mouseClickHandler(param1:MouseEvent) : void
|
||||
{
|
||||
if(_sceneLoaded)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public function onCloseButton() : void
|
||||
{
|
||||
end(null);
|
||||
}
|
||||
|
||||
public function onStart() : void
|
||||
{
|
||||
hideDlg();
|
||||
if(_ready && _ready.loader.parent)
|
||||
{
|
||||
_ready.loader.parent.removeChild(_ready.loader);
|
||||
}
|
||||
_nextFruitTimer = 3;
|
||||
}
|
||||
|
||||
public function selectFlavor(param1:int) : void
|
||||
{
|
||||
_smoothieType = param1;
|
||||
_cupFront.loader.content.slush.gotoAndStop(_fruitTypesColor[_smoothieType]);
|
||||
hideDlg();
|
||||
var _loc2_:MovieClip = showDlg("popup_fillcup",[]);
|
||||
_loc2_.x = 455;
|
||||
_loc2_.y = 300;
|
||||
_loc2_.gotoAndStop(_fruitTypes[_smoothieType]);
|
||||
_dismissDialogTimer = 3;
|
||||
addChild(_scene.getLayer("pickedFruit").loader);
|
||||
}
|
||||
|
||||
public function onFlavorStrawberry() : void
|
||||
{
|
||||
_scene.getLayer("pickedFruit").loader.content.gotoAndStop("icon_strawberry");
|
||||
selectFlavor(2);
|
||||
}
|
||||
|
||||
public function onFlavorBanana() : void
|
||||
{
|
||||
_scene.getLayer("pickedFruit").loader.content.gotoAndStop("icon_banana");
|
||||
selectFlavor(3);
|
||||
}
|
||||
|
||||
public function onFlavorOrange() : void
|
||||
{
|
||||
_scene.getLayer("pickedFruit").loader.content.gotoAndStop("icon_orange");
|
||||
selectFlavor(1);
|
||||
}
|
||||
|
||||
public function onFlavorGrape() : void
|
||||
{
|
||||
_scene.getLayer("pickedFruit").loader.content.gotoAndStop("icon_grape");
|
||||
selectFlavor(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
+34
-5
@@ -77,6 +77,9 @@ package gui
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
// Never leave the editor's full-screen layer behind to swallow
|
||||
// clicks after Settings is closed by another path.
|
||||
ItemWindowToggle.closeChatBubbleEditor();
|
||||
removeEventListeners();
|
||||
_popupLayer.removeChild(_mySettings);
|
||||
_closeCallback = null;
|
||||
@@ -174,6 +177,15 @@ package gui
|
||||
"iconFrame":"buddyRequest",
|
||||
"labelLabel":"Chat Filter",
|
||||
"btnLabel":"Open"
|
||||
},{
|
||||
// Chat appearance is account-wide; this opens the centered
|
||||
// in-game editor rather than burying it in the emoji picker.
|
||||
"type":TOGGLE_TYPE_JOIN,
|
||||
"frame":"chatBubble",
|
||||
// Reuse Predict Chat's ABC artwork and keep it in its on state.
|
||||
"iconFrame":"predictTxt",
|
||||
"labelLabel":"Chat Bubble",
|
||||
"btnLabel":"Customize"
|
||||
},{
|
||||
"type":TOGGLE_TYPE_JOIN,
|
||||
"frame":"themeMenu",
|
||||
@@ -201,9 +213,14 @@ package gui
|
||||
"run":showSavedList
|
||||
*/
|
||||
},{
|
||||
"type":TOGGLE_TYPE_JOIN,
|
||||
// this server's switches, drawn as the Nametag row is: the two
|
||||
// choices named either side of the knob (ItemWindowToggle)
|
||||
"type":TOGGLE_TYPE_TOGGLE_BTN,
|
||||
"frame":"wasd",
|
||||
"iconFrame":"world"
|
||||
"iconFrame":"world",
|
||||
"labelLabel":"WASD Movement",
|
||||
"onLabel":"On",
|
||||
"offLabel":"Off"
|
||||
},{
|
||||
"type":TOGGLE_TYPE_JOIN,
|
||||
"frame":"performance",
|
||||
@@ -221,13 +238,25 @@ package gui
|
||||
"frame":"camera",
|
||||
"iconFrame":"world"
|
||||
},{
|
||||
"type":TOGGLE_TYPE_JOIN,
|
||||
"type":TOGGLE_TYPE_TOGGLE_BTN,
|
||||
"frame":"hideBlocked",
|
||||
"iconFrame":"buddyRequest"
|
||||
"iconFrame":"buddyRequest",
|
||||
"labelLabel":"Blocked Players",
|
||||
"onLabel":"Shown",
|
||||
"offLabel":"Hidden"
|
||||
},{
|
||||
// the pictures players give their items (AJClient.customArtOn)
|
||||
"type":TOGGLE_TYPE_JOIN,
|
||||
"type":TOGGLE_TYPE_TOGGLE_BTN,
|
||||
"frame":"customArt",
|
||||
"iconFrame":"redeemCode",
|
||||
"labelLabel":"Custom Items",
|
||||
"onLabel":"Shown",
|
||||
"offLabel":"Hidden"
|
||||
},{
|
||||
// more, smaller items a row in the clothes and item pickers
|
||||
// (AJClient.expandedInventoryOn)
|
||||
"type":TOGGLE_TYPE_JOIN,
|
||||
"frame":"expandedInventory",
|
||||
"iconFrame":"redeemCode"
|
||||
},{
|
||||
"type":TOGGLE_TYPE_JOIN,
|
||||
|
||||
@@ -702,11 +702,17 @@ package gui
|
||||
{
|
||||
_loc2_.txt.text = "";
|
||||
}
|
||||
if(_loc2_.title != null)
|
||||
// the Alpha HQ's bios have no title (string 0), and an id with no
|
||||
// string throws: the popup stayed on screen with nothing able to
|
||||
// close it. none is left as it is.
|
||||
if(_loc2_.title != null && param1.title > 0)
|
||||
{
|
||||
LocalizationManager.translateId(_loc2_.title.txt,param1.title);
|
||||
}
|
||||
LocalizationManager.translateId(_loc2_.txt,param1.description);
|
||||
if(param1.description > 0)
|
||||
{
|
||||
LocalizationManager.translateId(_loc2_.txt,param1.description);
|
||||
}
|
||||
if(param1.media && param1.media != 0)
|
||||
{
|
||||
_loc3_ = new MediaHelper();
|
||||
@@ -724,7 +730,13 @@ package gui
|
||||
}
|
||||
}
|
||||
_loc2_.addEventListener("mouseDown",factMouseDownHandler,false,0,true);
|
||||
if(_loc2_.nextBtn)
|
||||
// one fact on its own (not one of a list) has no next or previous
|
||||
if(_loc2_.nextBtn && (_genericFactDefIndexList == null || isNaN(param1.index)))
|
||||
{
|
||||
_loc2_.nextBtn.visible = false;
|
||||
_loc2_.prevBtn.visible = false;
|
||||
}
|
||||
else if(_loc2_.nextBtn)
|
||||
{
|
||||
_loc2_.nextBtn.addEventListener("mouseDown",factNextPrevBtnHandler,false,0,true);
|
||||
_loc2_.prevBtn.addEventListener("mouseDown",factNextPrevBtnHandler,false,0,true);
|
||||
@@ -809,6 +821,11 @@ package gui
|
||||
|
||||
private static function reloadGenericFactPopup(param1:Object) : void
|
||||
{
|
||||
// a fact had by its id is in no list: the arrows have nowhere to go
|
||||
if(param1 == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
factCloseHandler(null);
|
||||
if(param1.type == 18 || param1.type == 12 || param1.type == 17 || param1.type == 9 || param1.type == 19)
|
||||
{
|
||||
@@ -824,6 +841,11 @@ package gui
|
||||
{
|
||||
var _loc3_:String = null;
|
||||
var _loc5_:Array = null;
|
||||
// a fact had by its id is in no list: the arrows have nowhere to go
|
||||
if(param1 == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_factPopup.index = param1.index;
|
||||
_factPopup.bitIdx = param1.bitIdx;
|
||||
while(_factPopup.imgBlock.numChildren > 0)
|
||||
@@ -1022,10 +1044,12 @@ package gui
|
||||
}
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
_loc2_ = _genericFactDefList[_genericFactId];
|
||||
// the fact lists came from the official server; one this server has
|
||||
// no entry for opens nothing (#1009)
|
||||
// the fact lists came from the official server, and this one
|
||||
// answers them empty: the fact is had by its id instead, from the
|
||||
// CDN's factDefs (requestFactInfo), as the game's other facts are
|
||||
if(_loc2_ == null)
|
||||
{
|
||||
requestFactInfo([_genericFactId]);
|
||||
return;
|
||||
}
|
||||
if(_loc2_.type == 18 || _loc2_.type == 12 || _loc2_.type == 17 || _loc2_.type == 9 || _loc2_.type == 19)
|
||||
@@ -1063,6 +1087,14 @@ package gui
|
||||
_museumFactDefIndexList[_loc3_] = _loc2_.id;
|
||||
_loc3_++;
|
||||
}
|
||||
// as above: an exhibit this server's list does not have is had by
|
||||
// its id. opening nothing left the game behind its spinner.
|
||||
if(_museumFactDefList[_museumRequest] == null)
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
requestFactInfo([_museumRequest]);
|
||||
return;
|
||||
}
|
||||
displayMuseumEngangermentPopup(_museumFactDefList[_museumRequest]);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,487 @@
|
||||
package pet
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import loader.MediaHelper;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class PetBase extends Sprite
|
||||
{
|
||||
|
||||
public static const DEF_ID_CAT:int = 1;
|
||||
|
||||
public static const DEF_ID_FROG:int = 2;
|
||||
|
||||
public static const DEF_ID_DUCK:int = 3;
|
||||
|
||||
public static const DEF_ID_DOG:int = 4;
|
||||
|
||||
public static const DEF_ID_BFLY:int = 5;
|
||||
|
||||
public static const DEF_ID_HAMS:int = 6;
|
||||
|
||||
public static const DEF_ID_BAT:int = 7;
|
||||
|
||||
public static const DEF_ID_SEAHORSE:int = 8;
|
||||
|
||||
public static const DEF_ID_ANGLER:int = 9;
|
||||
|
||||
public static const DEF_ID_REINDEER:int = 10;
|
||||
|
||||
public static const DEF_ID_SNAKE:int = 11;
|
||||
|
||||
public static const DEF_ID_JELLYFISH:int = 12;
|
||||
|
||||
public static const DEF_ID_BUNNY:int = 13;
|
||||
|
||||
public static const DEF_ID_HUMMINGBIRD:int = 14;
|
||||
|
||||
public static const DEF_ID_TURTLE:int = 15;
|
||||
|
||||
public static const DEF_ID_MONKEY:int = 16;
|
||||
|
||||
public static const DEF_ID_TARANTUAL:int = 17;
|
||||
|
||||
public static const DEF_ID_FOX:int = 18;
|
||||
|
||||
public static const DEF_ID_OWL:int = 19;
|
||||
|
||||
public static const DEF_ID_TIGER:int = 20;
|
||||
|
||||
public static const DEF_ID_ARCTIC_WOLF:int = 21;
|
||||
|
||||
public static const DEF_ID_RACCOON:int = 22;
|
||||
|
||||
public static const DEF_ID_JOEY:int = 23;
|
||||
|
||||
public static const DEF_ID_EAGLET:int = 24;
|
||||
|
||||
public static const DEF_ID_CHEETAH:int = 25;
|
||||
|
||||
public static const DEF_ID_RHINO:int = 26;
|
||||
|
||||
public static const DEF_ID_GIRAFFE:int = 27;
|
||||
|
||||
public static const DEF_ID_SUGAR_GLIDER:int = 28;
|
||||
|
||||
public static const DEF_ID_LION_CUB:int = 29;
|
||||
|
||||
public static const DEF_ID_PANDA:int = 30;
|
||||
|
||||
public static const DEF_ID_POLAR_BEAR_CUB:int = 31;
|
||||
|
||||
public static const DEF_ID_GECKO:int = 32;
|
||||
|
||||
public static const DEF_ID_PONY:int = 34;
|
||||
|
||||
public static const DEF_ID_PIGLET:int = 35;
|
||||
|
||||
public static const DEF_ID_FERRET:int = 36;
|
||||
|
||||
public static const DEF_ID_ELEPHANT:int = 37;
|
||||
|
||||
public static const DEF_ID_ARMADILLO:int = 38;
|
||||
|
||||
public static const DEF_ID_PEACOCK:int = 39;
|
||||
|
||||
public static const DEF_ID_BEE:int = 40;
|
||||
|
||||
public static const DEF_ID_ROOSTER:int = 41;
|
||||
|
||||
public static const DEF_ID_SKUNK:int = 42;
|
||||
|
||||
public static const DEF_ID_TURKEY:int = 43;
|
||||
|
||||
public static const DEF_ID_PENGUIN:int = 44;
|
||||
|
||||
public static const DEF_ID_SNOW_LEOPARD:int = 45;
|
||||
|
||||
public static const DEF_ID_MANITS:int = 46;
|
||||
|
||||
public static const DEF_ID_LADYBUG:int = 47;
|
||||
|
||||
public static const DEF_ID_CRICKET:int = 48;
|
||||
|
||||
public static const DEF_ID_SQUIRREL:int = 49;
|
||||
|
||||
public static const DEF_ID_MOUSE:int = 50;
|
||||
|
||||
public static const DEF_ID_FIREFLY:int = 51;
|
||||
|
||||
public static const DEF_ID_LEMUR:int = 52;
|
||||
|
||||
public static const DEF_ID_HIPPO:int = 53;
|
||||
|
||||
public static const DEF_ID_GOAT:int = 54;
|
||||
|
||||
public static const DEF_ID_MEERKAT:int = 55;
|
||||
|
||||
public static const DEF_ID_GOLDEN_BUNNY:int = 56;
|
||||
|
||||
public static const DEF_ID_PHANTOM:int = 57;
|
||||
|
||||
public static const DEF_ID_SEAL:int = 58;
|
||||
|
||||
public static const DEF_ID_OTTER:int = 59;
|
||||
|
||||
public static const DEF_ID_PHANTOM_RARE:int = 60;
|
||||
|
||||
public static const DEF_ID_GROUND_HOG:int = 61;
|
||||
|
||||
public static const DEF_ID_LLAMA:int = 62;
|
||||
|
||||
public static const DEF_ID_ARCTIC_FOX:int = 63;
|
||||
|
||||
public static const DEF_ID_HYENA:int = 64;
|
||||
|
||||
public static const DEF_ID_SLOTH:int = 65;
|
||||
|
||||
public static const DEF_ID_DOVE:int = 66;
|
||||
|
||||
public static const DEF_ID_CHICK:int = 67;
|
||||
|
||||
public static const DEF_ID_GOLDEN_ARMADILLO:int = 68;
|
||||
|
||||
public static const DEF_ID_FALCON:int = 69;
|
||||
|
||||
public static const DEF_ID_CROCODILE:int = 70;
|
||||
|
||||
public static const DEF_ID_PLATYPUS:int = 71;
|
||||
|
||||
public static const DEF_ID_PHANTOM_JW:int = 72;
|
||||
|
||||
public static const DEF_ID_GOLDEN_PONY:int = 73;
|
||||
|
||||
public static const DEF_ID_SHARK:int = 74;
|
||||
|
||||
public static const DEF_ID_DOLPHIN:int = 75;
|
||||
|
||||
public static const DEF_ID_ECHIDNA:int = 76;
|
||||
|
||||
public static const DEF_ID_KOALA:int = 77;
|
||||
|
||||
public static const DEF_ID_LYNX:int = 80;
|
||||
|
||||
public static const DEF_ID_OCTOPUS:int = 81;
|
||||
|
||||
public static const DEF_ID_FENNEC_FOX_JW:int = 82;
|
||||
|
||||
public static const DEF_ID_HEDGEHOG:int = 83;
|
||||
|
||||
public static const DEF_ID_SCORPION:int = 84;
|
||||
|
||||
public static const DEF_ID_CROW:int = 85;
|
||||
|
||||
public static const DEF_ID_MOOSE:int = 86;
|
||||
|
||||
public static const DEF_ID_POODLE:int = 87;
|
||||
|
||||
public static const DEF_ID_LOVEBUNNY:int = 88;
|
||||
|
||||
public static const DEF_ID_SABERTOOTH:int = 89;
|
||||
|
||||
public static const DEF_ID_DIREWOLF:int = 90;
|
||||
|
||||
public static const DEF_ID_DODO:int = 91;
|
||||
|
||||
public static const DEF_ID_FANTASY_PEACOCK:int = 92;
|
||||
|
||||
public static const DEF_ID_MILLIPEDE:int = 93;
|
||||
|
||||
public static const DEF_ID_MOTH:int = 94;
|
||||
|
||||
public static const DEF_ID_VULTURE:int = 95;
|
||||
|
||||
public static const DEF_ID_COYOTE:int = 96;
|
||||
|
||||
public static const DEF_ID_MEAGYNS:int = 97;
|
||||
|
||||
public static const DEF_ID_FALCON2:int = 98;
|
||||
|
||||
public static const DEF_ID_LOVE_BUG:int = 99;
|
||||
|
||||
public static const DEF_ID_FLYING_PIG:int = 100;
|
||||
|
||||
public static const DEF_ID_SPARROW:int = 101;
|
||||
|
||||
public static const DEF_ID_FENNEC_FOX:int = 102;
|
||||
|
||||
public static const DEF_ID_CARDINAL:int = 103;
|
||||
|
||||
public static const DEF_ID_FRILLED_LIZARD:int = 104;
|
||||
|
||||
public static const DEF_ID_DRAGONFLY:int = 105;
|
||||
|
||||
public static const DEF_ID_MAGENTA_SEAL:int = 106;
|
||||
|
||||
public static const DEF_ID_PANGOLIN:int = 107;
|
||||
|
||||
public static const DEF_ID_CAMEL:int = 108;
|
||||
|
||||
public static const DEF_ID_SNAIL:int = 109;
|
||||
|
||||
public static const DEF_ID_GALACTIC_FIREFLY:int = 110;
|
||||
|
||||
public static const DEF_ID_CATERPILLAR:int = 111;
|
||||
|
||||
public static const DEF_ID_LAMB:int = 112;
|
||||
|
||||
public static const DEF_ID_GOLDEN_REINDEER:int = 113;
|
||||
|
||||
public static const DEF_ID_HIGHLANDCOW:int = 114;
|
||||
|
||||
public static const DEF_ID_NIGHTHAWK:int = 115;
|
||||
|
||||
public static const DEF_ID_FRANKENKITTEN:int = 116;
|
||||
|
||||
public static const TYPE_LAND_GROUND:int = 0;
|
||||
|
||||
public static const TYPE_LAND_AIR:int = 1;
|
||||
|
||||
public static const TYPE_OCEAN_GROUND:int = 2;
|
||||
|
||||
public static const TYPE_OCEAN_AIR:int = 3;
|
||||
|
||||
public static const TYPE_AMPHIB_GROUND:int = 4;
|
||||
|
||||
public static const TYPE_AMPHIB_AIR:int = 5;
|
||||
|
||||
protected var _petDef:PetDef;
|
||||
|
||||
protected var _lBits:uint;
|
||||
|
||||
protected var _uBits:uint;
|
||||
|
||||
protected var _eBits:uint;
|
||||
|
||||
protected var _traitDefId:uint;
|
||||
|
||||
protected var _toyDefId:uint;
|
||||
|
||||
protected var _foodDefId:uint;
|
||||
|
||||
protected var _content:MovieClip;
|
||||
|
||||
protected var _createdTs:Number;
|
||||
|
||||
private var _mediaHelper:MediaHelper;
|
||||
|
||||
private var _onPetLoadedCallback:Function;
|
||||
|
||||
public function PetBase(param1:Number, param2:uint, param3:uint, param4:uint, param5:uint, param6:uint, param7:uint, param8:Function)
|
||||
{
|
||||
super();
|
||||
_createdTs = param1;
|
||||
_lBits = param2;
|
||||
_uBits = param3;
|
||||
_eBits = param4;
|
||||
_traitDefId = param5;
|
||||
_toyDefId = param6;
|
||||
_foodDefId = param7;
|
||||
_onPetLoadedCallback = param8;
|
||||
_petDef = PetManager.getPetDef(param2 & 0xFF);
|
||||
// bits naming no pet the game has: the first pet, rather than
|
||||
// a pet that never loads and stops what was drawing it
|
||||
if(_petDef == null)
|
||||
{
|
||||
_petDef = PetManager.getPetDef(1);
|
||||
}
|
||||
_mediaHelper = new MediaHelper();
|
||||
_mediaHelper.init(mediaIdForDefId(_petDef.defId),onMediaLoaded,true);
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function getPetTitleName() : String
|
||||
{
|
||||
return LocalizationManager.translateIdOnly(_petDef.titleStrId);
|
||||
}
|
||||
|
||||
public function isGround() : Boolean
|
||||
{
|
||||
if(_petDef.isEgg && !PetManager.hasHatched(_createdTs))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return PetManager.isGround(_petDef.type);
|
||||
}
|
||||
|
||||
public function isEggAndHasNotHatched() : Boolean
|
||||
{
|
||||
if(_petDef.isEgg)
|
||||
{
|
||||
return PetManager.hasHatched(_createdTs) == false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isEgg() : Boolean
|
||||
{
|
||||
return _petDef.isEgg;
|
||||
}
|
||||
|
||||
public function getType() : int
|
||||
{
|
||||
return _petDef.type;
|
||||
}
|
||||
|
||||
public function getDefID() : int
|
||||
{
|
||||
return _petDef.defId;
|
||||
}
|
||||
|
||||
public function canGoInOcean() : Boolean
|
||||
{
|
||||
if(_petDef.type == 2 || _petDef.type == 3 || _petDef.type == 4 || _petDef.type == 5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function canGoOnLand() : Boolean
|
||||
{
|
||||
if(_petDef.type == 0 || _petDef.type == 1 || _petDef.type == 4 || _petDef.type == 5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getLBits() : uint
|
||||
{
|
||||
return _lBits;
|
||||
}
|
||||
|
||||
public function getUBits() : uint
|
||||
{
|
||||
return _uBits;
|
||||
}
|
||||
|
||||
public function getEBits() : uint
|
||||
{
|
||||
return _eBits;
|
||||
}
|
||||
|
||||
public function getContent() : MovieClip
|
||||
{
|
||||
return _content;
|
||||
}
|
||||
|
||||
public function getCreatedTs() : Number
|
||||
{
|
||||
return _createdTs;
|
||||
}
|
||||
|
||||
public function colorMyItem(param1:int, param2:MovieClip, param3:int, param4:int, param5:int, param6:int, param7:int, param8:int) : void
|
||||
{
|
||||
if(_content)
|
||||
{
|
||||
_content.colorMe(param1,param2,param3,param4,param5,param6,param7,param8);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateAllBits(param1:uint, param2:uint, param3:uint) : void
|
||||
{
|
||||
if(_content)
|
||||
{
|
||||
_lBits = param1;
|
||||
_uBits = param2;
|
||||
_eBits = param3;
|
||||
PetManager.setPetState(_content,_lBits,_uBits,_eBits);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateUBits(param1:uint) : void
|
||||
{
|
||||
_uBits = param1;
|
||||
PetManager.setPetState(_content,_lBits,_uBits,_eBits);
|
||||
}
|
||||
|
||||
public function animatePet(param1:Boolean) : void
|
||||
{
|
||||
if(_content && "willItAnimate" in _content.pet)
|
||||
{
|
||||
_content.pet.willItAnimate(param1);
|
||||
}
|
||||
}
|
||||
|
||||
protected function setSparkle(param1:int) : void
|
||||
{
|
||||
if(_content)
|
||||
{
|
||||
_content.pet.setSparkle(param1);
|
||||
}
|
||||
}
|
||||
|
||||
private function onMediaLoaded(param1:MovieClip) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
if(param1)
|
||||
{
|
||||
_content = param1;
|
||||
this.addChild(_content);
|
||||
_mediaHelper.destroy();
|
||||
delete _content.mediaHelper;
|
||||
delete _content.passback;
|
||||
PetManager.setPetState(_content,_lBits,_uBits,_eBits);
|
||||
if(_onPetLoadedCallback != null)
|
||||
{
|
||||
_onPetLoadedCallback(_content);
|
||||
}
|
||||
_content.pet.setAnim(0);
|
||||
if(_petDef.isEgg)
|
||||
{
|
||||
if(_content.pet.hasOwnProperty("setEggDayInt"))
|
||||
{
|
||||
_loc2_ = _createdTs > 0 ? Math.floor((Utility.getInitialEpochTime() - _createdTs) / 86400) : 0;
|
||||
_content.pet.setEggDayInt(_loc2_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function mediaIdForDefId(param1:int) : int
|
||||
{
|
||||
var _loc2_:PetDef = PetManager.getPetDef(param1);
|
||||
if(_loc2_)
|
||||
{
|
||||
return _loc2_.mediaRefId;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public function get personalityDefId() : uint
|
||||
{
|
||||
return _traitDefId;
|
||||
}
|
||||
|
||||
public function set personalityDefId(param1:uint) : void
|
||||
{
|
||||
_traitDefId = param1;
|
||||
}
|
||||
|
||||
public function get favoriteToyDefId() : uint
|
||||
{
|
||||
return _toyDefId;
|
||||
}
|
||||
|
||||
public function set favoriteToyDefId(param1:uint) : void
|
||||
{
|
||||
_toyDefId = param1;
|
||||
}
|
||||
|
||||
public function get favoriteFoodDefId() : uint
|
||||
{
|
||||
return _foodDefId;
|
||||
}
|
||||
|
||||
public function set favoriteFoodDefId(param1:uint) : void
|
||||
{
|
||||
_foodDefId = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,853 @@
|
||||
package playerWall
|
||||
{
|
||||
import buddy.BuddyManager;
|
||||
import collection.IntItemCollection;
|
||||
import com.sbi.client.SFEvent;
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import flash.events.ErrorEvent;
|
||||
import flash.events.Event;
|
||||
import flash.net.URLLoader;
|
||||
import flash.net.URLRequest;
|
||||
import flash.net.URLRequestHeader;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiManager;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class PlayerWallXtCommManager
|
||||
{
|
||||
|
||||
private static var _requestor:URLLoader;
|
||||
|
||||
private static var _deleteResponseCallback:Function;
|
||||
|
||||
private static var _getResponseCallback:Function;
|
||||
|
||||
private static var _putResponseCallback:Function;
|
||||
|
||||
private static var _setSettingsResponseCallback:Function;
|
||||
|
||||
private static var _getSettingsResponseCallback:Function;
|
||||
|
||||
private static var _setParametersResponseCallback:Function;
|
||||
|
||||
private static var _blockedMessagesCallback:Function;
|
||||
|
||||
private static var _setBlockedMessageCallback:Function;
|
||||
|
||||
private static var _wallTokenCallback:Function;
|
||||
|
||||
private static var _checkResponseCallback:Function;
|
||||
|
||||
private static var _sendClearAllMessagesCallback:Function;
|
||||
|
||||
private static var _sendMasterpieceCallback:Function;
|
||||
|
||||
private static var _setCounterIncrementResponseCallback:Function;
|
||||
|
||||
private static var _sendAcknowledgeNotificationCallback:Function;
|
||||
|
||||
private static var _wallTokenPassback:Object;
|
||||
|
||||
private static var _setSettingsId:int;
|
||||
|
||||
private static var _currentRequestUsername:String;
|
||||
|
||||
private static var _messageToPost:PostMessage;
|
||||
|
||||
private static var _currMessageuuid:String;
|
||||
|
||||
private static var _setWallParameters:Object;
|
||||
|
||||
private static var _messageToBeBlocked:String;
|
||||
|
||||
private static var _wallTokenShouldShowFailure:Boolean;
|
||||
|
||||
private static var _masterpieceInvIdsToRemove:IntItemCollection;
|
||||
|
||||
private static var _setCounterIncrementWallOwner:String;
|
||||
|
||||
private static var _sendAcknowledgeMessages:Array;
|
||||
|
||||
private static var _isProcessingRequest:Boolean;
|
||||
|
||||
private static var _currCommand:String;
|
||||
|
||||
private static var _tokenFailures:int;
|
||||
|
||||
private static var _isFromHudTimer:Boolean;
|
||||
|
||||
// requests made while one was on its way, each with what its reply is
|
||||
// read with ({request, state}), and that of the one on its way
|
||||
private static var _waitingRequests:Array = [];
|
||||
|
||||
private static var _sentRequestState:Object;
|
||||
|
||||
public function PlayerWallXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
_requestor = new URLLoader();
|
||||
}
|
||||
|
||||
public static function destroy() : void
|
||||
{
|
||||
}
|
||||
|
||||
public static function sendWallTokenRequest(param1:String, param2:Function = null, param3:Object = null, param4:Boolean = true, param5:Boolean = false) : void
|
||||
{
|
||||
if(_tokenFailures < 2)
|
||||
{
|
||||
if(param5)
|
||||
{
|
||||
_tokenFailures = _tokenFailures + 1;
|
||||
}
|
||||
PlayerWallManager.setForWaitingOnWallResponse(true);
|
||||
_wallTokenCallback = param2;
|
||||
_wallTokenPassback = param3;
|
||||
_wallTokenShouldShowFailure = param4;
|
||||
gMainFrame.server.setXtObject_Str("wt",[param1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerWallManager.closeOpenPlayerWallDueToTokenFailures();
|
||||
_tokenFailures = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendSetWallSettingsRequest(param1:int, param2:Function) : void
|
||||
{
|
||||
_setSettingsResponseCallback = param2;
|
||||
_setSettingsId = param1;
|
||||
gMainFrame.server.setXtObject_Str("wss",[param1]);
|
||||
}
|
||||
|
||||
public static function sendGetWallSettingsRequest(param1:String, param2:Function) : void
|
||||
{
|
||||
_getSettingsResponseCallback = param2;
|
||||
gMainFrame.server.setXtObject_Str("wsg",[param1]);
|
||||
}
|
||||
|
||||
public static function sendSetWallParametersRequest(param1:Object, param2:Object, param3:Function) : void
|
||||
{
|
||||
_setParametersResponseCallback = param3;
|
||||
_setWallParameters = param1;
|
||||
gMainFrame.server.setXtObject_Str("wps",[JSON.stringify(param2)]);
|
||||
}
|
||||
|
||||
public static function sendSetWallCounterIncrementRequest(param1:String, param2:Function) : void
|
||||
{
|
||||
_setCounterIncrementResponseCallback = param2;
|
||||
_setCounterIncrementWallOwner = param1;
|
||||
gMainFrame.server.setXtObject_Str("wci",[param1]);
|
||||
}
|
||||
|
||||
public static function handleXtReply(param1:SFEvent) : void
|
||||
{
|
||||
var _loc3_:Array = null;
|
||||
if(!param1.status)
|
||||
{
|
||||
DebugUtility.debugTrace("ERROR: PlayerWallXtCommManager handleXtReply was called with bad evt.status:" + param1.status);
|
||||
return;
|
||||
}
|
||||
var _loc2_:Array = param1.obj;
|
||||
switch(_loc2_[0])
|
||||
{
|
||||
case "wt":
|
||||
PlayerWallManager.handleTokenResponse(_loc2_,_wallTokenShouldShowFailure);
|
||||
if(_wallTokenCallback != null)
|
||||
{
|
||||
if(_wallTokenPassback != null)
|
||||
{
|
||||
if(_wallTokenPassback.hasOwnProperty("data"))
|
||||
{
|
||||
_loc3_ = _wallTokenPassback.data;
|
||||
switch(int(_loc3_.length) - 1)
|
||||
{
|
||||
case 0:
|
||||
_wallTokenCallback(_loc3_[0],_loc2_[2] == "1");
|
||||
break;
|
||||
case 1:
|
||||
_wallTokenCallback(_loc3_[0],_loc3_[1],_loc2_[2] == "1");
|
||||
break;
|
||||
case 2:
|
||||
_wallTokenCallback(_loc3_[0],_loc3_[1],_loc3_[2],_loc2_[2] == "1");
|
||||
break;
|
||||
case 3:
|
||||
_wallTokenCallback(_loc3_[0],_loc3_[1],_loc3_[2],_loc3_[3],_loc2_[2] == "1");
|
||||
break;
|
||||
case 4:
|
||||
_wallTokenCallback(_loc3_[0],_loc3_[1],_loc3_[2],_loc3_[3],_loc3_[4],_loc2_[2] == "1");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_wallTokenCallback(_wallTokenPassback,_loc2_[2] == "1");
|
||||
}
|
||||
_wallTokenPassback = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_wallTokenCallback(_loc2_[2] == "1");
|
||||
}
|
||||
_wallTokenCallback = null;
|
||||
}
|
||||
break;
|
||||
case "wss":
|
||||
PlayerWallManager.onPrivacyResponse(_loc2_[2] == "1",_setSettingsId);
|
||||
if(_setSettingsResponseCallback != null)
|
||||
{
|
||||
_setSettingsResponseCallback(_loc2_[2] == "1",_setSettingsId);
|
||||
_setSettingsResponseCallback = null;
|
||||
}
|
||||
break;
|
||||
case "wsg":
|
||||
if(_getSettingsResponseCallback != null)
|
||||
{
|
||||
_getSettingsResponseCallback(_loc2_[2]);
|
||||
_getSettingsResponseCallback = null;
|
||||
}
|
||||
break;
|
||||
case "wps":
|
||||
setParametersResponse(_loc2_);
|
||||
break;
|
||||
case "wci":
|
||||
PlayerWallManager.onWallCountIncrementResponse(_loc2_[2] == "1",_setCounterIncrementWallOwner);
|
||||
if(_setCounterIncrementResponseCallback != null)
|
||||
{
|
||||
_setCounterIncrementResponseCallback(_loc2_[2]);
|
||||
_setCounterIncrementResponseCallback = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendCheckPlayerWall(param1:String, param2:Function, param3:Boolean = false, param4:Boolean = true) : void
|
||||
{
|
||||
var _loc5_:Object = PlayerWallManager.tokenMap[param1.toLowerCase()];
|
||||
var _loc6_:String = null;
|
||||
if(_loc5_)
|
||||
{
|
||||
_loc6_ = _loc5_.token;
|
||||
}
|
||||
_currentRequestUsername = param1;
|
||||
_checkResponseCallback = param2;
|
||||
_isFromHudTimer = param3;
|
||||
if(_loc6_)
|
||||
{
|
||||
sendServiceRequest({
|
||||
"cmd":"CHK",
|
||||
"t":_loc6_
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
sendWallTokenRequest(param1,sendCheckPlayerWall,{"data":[param1,param2,param3]},!param3,!param4);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendPutToPlayerWall(param1:String, param2:PostMessage, param3:Object, param4:Function, param5:Boolean = true) : void
|
||||
{
|
||||
var _loc6_:Object = null;
|
||||
var _loc7_:Object = PlayerWallManager.tokenMap[param1.toLowerCase()];
|
||||
var _loc8_:String = null;
|
||||
if(_loc7_)
|
||||
{
|
||||
_loc8_ = _loc7_.token;
|
||||
}
|
||||
_messageToPost = param2;
|
||||
_currentRequestUsername = param1;
|
||||
_putResponseCallback = param4;
|
||||
if(_loc8_)
|
||||
{
|
||||
_loc6_ = {
|
||||
"cmd":"PUT",
|
||||
"t":_loc8_,
|
||||
"sid":param2.senderDbId,
|
||||
"s":param2.patternId,
|
||||
"c":param2.colorId,
|
||||
"m":param2.message,
|
||||
"ai":param2.avtDefId,
|
||||
"ac":param2.avtColors,
|
||||
"ae":param2.avtEyeDefId,
|
||||
"ap":param2.avtPatternDefId,
|
||||
"aci":param2.avtCustomId,
|
||||
"l":param2.localizationId,
|
||||
"p":param3
|
||||
};
|
||||
if(param2.parentMessageId != null && param2.parentMessageId.length > 0)
|
||||
{
|
||||
_loc6_.pp = param2.parentMessageId;
|
||||
}
|
||||
sendServiceRequest(_loc6_);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendWallTokenRequest(param1,sendPutToPlayerWall,{"data":[param1,param4,param2,param3]},true,!param5);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendDeleteFromPlayerWall(param1:String, param2:String, param3:Function, param4:Boolean = true) : void
|
||||
{
|
||||
var _loc5_:Object = PlayerWallManager.tokenMap[param1.toLowerCase()];
|
||||
var _loc6_:String = null;
|
||||
if(_loc5_)
|
||||
{
|
||||
_loc6_ = _loc5_.token;
|
||||
}
|
||||
_currentRequestUsername = param1;
|
||||
_currMessageuuid = param2;
|
||||
_deleteResponseCallback = param3;
|
||||
if(_loc6_)
|
||||
{
|
||||
sendServiceRequest({
|
||||
"cmd":"DEL",
|
||||
"t":_loc6_,
|
||||
"x":param2
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
sendWallTokenRequest(param1,sendDeleteFromPlayerWall,{"data":[param1,param3,param2]},true,!param4);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendGetFromPlayerWall(param1:String, param2:Function, param3:Boolean = false, param4:Boolean = true) : void
|
||||
{
|
||||
var _loc5_:Object = PlayerWallManager.tokenMap[param1.toLowerCase()];
|
||||
var _loc6_:String = null;
|
||||
if(_loc5_)
|
||||
{
|
||||
_loc6_ = _loc5_.token;
|
||||
}
|
||||
_currentRequestUsername = param1;
|
||||
_getResponseCallback = param2;
|
||||
_isFromHudTimer = param3;
|
||||
if(_loc6_)
|
||||
{
|
||||
sendServiceRequest({
|
||||
"cmd":"GET",
|
||||
"t":_loc6_
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
sendWallTokenRequest(param1,sendGetFromPlayerWall,{"data":[param1,param2,param3]},true,!param4);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendGetBlockedMessages(param1:Function, param2:Boolean = true) : void
|
||||
{
|
||||
_blockedMessagesCallback = param1;
|
||||
var _loc3_:Object = PlayerWallManager.tokenMap[gMainFrame.userInfo.myUserName.toLowerCase()];
|
||||
var _loc4_:String = null;
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc4_ = _loc3_.token;
|
||||
}
|
||||
_currentRequestUsername = gMainFrame.userInfo.myUserName;
|
||||
if(_loc4_)
|
||||
{
|
||||
sendServiceRequest({
|
||||
"cmd":"GMB",
|
||||
"t":_loc4_
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
sendWallTokenRequest(_currentRequestUsername,sendGetBlockedMessages,{"callback":param1},true,!param2);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendSetBlockedMessage(param1:String, param2:Function, param3:Boolean = true) : void
|
||||
{
|
||||
_setBlockedMessageCallback = param2;
|
||||
_messageToBeBlocked = param1;
|
||||
var _loc4_:Object = PlayerWallManager.tokenMap[gMainFrame.userInfo.myUserName.toLowerCase()];
|
||||
var _loc5_:String = null;
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc5_ = _loc4_.token;
|
||||
}
|
||||
_currentRequestUsername = gMainFrame.userInfo.myUserName;
|
||||
if(_loc5_)
|
||||
{
|
||||
sendServiceRequest({
|
||||
"cmd":"AMB",
|
||||
"t":_loc5_,
|
||||
"x":param1
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
sendWallTokenRequest(_currentRequestUsername,sendSetBlockedMessage,{"data":[param2,param1]},true,!param3);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendClearAllMessages(param1:Function, param2:Boolean = true) : void
|
||||
{
|
||||
_sendClearAllMessagesCallback = param1;
|
||||
var _loc3_:Object = PlayerWallManager.tokenMap[gMainFrame.userInfo.myUserName.toLowerCase()];
|
||||
var _loc4_:String = null;
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc4_ = _loc3_.token;
|
||||
}
|
||||
_currentRequestUsername = gMainFrame.userInfo.myUserName;
|
||||
if(_loc4_)
|
||||
{
|
||||
sendServiceRequest({
|
||||
"cmd":"CLW",
|
||||
"t":_loc4_
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
sendWallTokenRequest(_currentRequestUsername,sendClearAllMessages,{"callback":param1},true,!param2);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendRemoveMasterpiece(param1:IntItemCollection, param2:Function, param3:Boolean = true) : void
|
||||
{
|
||||
_masterpieceInvIdsToRemove = param1;
|
||||
_sendMasterpieceCallback = param2;
|
||||
var _loc4_:Object = PlayerWallManager.tokenMap[gMainFrame.userInfo.myUserName.toLowerCase()];
|
||||
var _loc5_:String = null;
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc5_ = _loc4_.token;
|
||||
}
|
||||
_currentRequestUsername = gMainFrame.userInfo.myUserName;
|
||||
if(_loc5_)
|
||||
{
|
||||
sendServiceRequest({
|
||||
"cmd":"RMP",
|
||||
"t":_loc5_,
|
||||
"mp":param1.getCoreArray()
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
sendWallTokenRequest(_currentRequestUsername,sendRemoveMasterpiece,{"data":[param2,param1]},true,!param3);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendAcknowledgeNotificationRequest(param1:Array, param2:Function, param3:Boolean = true) : void
|
||||
{
|
||||
var _loc4_:Object = PlayerWallManager.tokenMap[gMainFrame.userInfo.myUserName.toLowerCase()];
|
||||
var _loc5_:String = null;
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc5_ = _loc4_.token;
|
||||
}
|
||||
_sendAcknowledgeNotificationCallback = param2;
|
||||
_currentRequestUsername = gMainFrame.userInfo.myUserName;
|
||||
_sendAcknowledgeMessages = param1;
|
||||
if(_loc5_)
|
||||
{
|
||||
sendServiceRequest({
|
||||
"cmd":"ACK",
|
||||
"t":_loc5_,
|
||||
"x":param1
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
sendWallTokenRequest(_currentRequestUsername,sendAcknowledgeNotificationRequest,{"data":[param2,param1]},true,!param3);
|
||||
}
|
||||
}
|
||||
|
||||
public static function ContinueCommandAfterTokenRequest(param1:Object, param2:Boolean) : void
|
||||
{
|
||||
var _loc3_:String = null;
|
||||
var _loc4_:String = null;
|
||||
if(param1 && param2)
|
||||
{
|
||||
_loc3_ = param1.cmd;
|
||||
_loc4_ = param1.username;
|
||||
switch(_loc3_)
|
||||
{
|
||||
case "CHK":
|
||||
sendCheckPlayerWall(_loc4_,param1.callback,param1.isFromHudTimer,param2);
|
||||
break;
|
||||
case "PUT":
|
||||
sendPutToPlayerWall(_loc4_,param1.msgToPost,param1.wallParameters,param1.callback,param2);
|
||||
break;
|
||||
case "DEL":
|
||||
sendDeleteFromPlayerWall(_loc4_,param1.messageuuid,param1.callback,param2);
|
||||
break;
|
||||
case "GET":
|
||||
sendGetFromPlayerWall(_loc4_,param1.callback,param1.isFromHudTimer,param2);
|
||||
break;
|
||||
case "GMP":
|
||||
sendGetBlockedMessages(param1.callback,param2);
|
||||
break;
|
||||
case "AMB":
|
||||
sendSetBlockedMessage(param1.messageToBeBlocked,param1.callback,param2);
|
||||
break;
|
||||
case "CLW":
|
||||
sendClearAllMessages(param1.callback,param2);
|
||||
break;
|
||||
case "RMP":
|
||||
sendRemoveMasterpiece(param1.invIdToRemove,param1.callback,param2);
|
||||
break;
|
||||
case "ACK":
|
||||
sendAcknowledgeNotificationRequest(param1.messageId,param1.callback,param2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerWallManager.closeOpenPlayerWallDueToTokenFailures();
|
||||
}
|
||||
}
|
||||
|
||||
private static function checkResponse(param1:Object) : void
|
||||
{
|
||||
var _loc2_:Boolean = param1 != null ? Boolean(param1.s) : false;
|
||||
PlayerWallManager.onCheckResponse(_loc2_,param1,_currentRequestUsername,_isFromHudTimer);
|
||||
if(_checkResponseCallback != null)
|
||||
{
|
||||
_checkResponseCallback(_loc2_,param1);
|
||||
}
|
||||
}
|
||||
|
||||
private static function deleteResponse(param1:Object) : void
|
||||
{
|
||||
var _loc2_:Boolean = param1 != null ? Boolean(param1.s) : false;
|
||||
if(_deleteResponseCallback != null)
|
||||
{
|
||||
_deleteResponseCallback(_loc2_,_currMessageuuid,param1.e);
|
||||
_deleteResponseCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function addResponse(param1:Object) : void
|
||||
{
|
||||
var _loc4_:Boolean = param1 != null ? Boolean(param1.PUT.s) : false;
|
||||
var _loc2_:int = int(param1.PUT.cs != null ? param1.PUT.cs : 0);
|
||||
var _loc3_:int = int(param1.PUT.tag != null ? param1.PUT.tag : 0);
|
||||
if(_loc4_)
|
||||
{
|
||||
_messageToPost.msgId = param1.x;
|
||||
_messageToPost.postTime = param1.t;
|
||||
getResponse(param1.GET);
|
||||
}
|
||||
if(_putResponseCallback != null)
|
||||
{
|
||||
_putResponseCallback(_loc4_,_messageToPost,_loc2_,_loc3_,param1.PUT.e);
|
||||
_putResponseCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getResponse(param1:Object) : void
|
||||
{
|
||||
var _loc11_:Object = null;
|
||||
var _loc5_:int = 0;
|
||||
var _loc4_:int = 0;
|
||||
var _loc12_:String = null;
|
||||
var _loc10_:Boolean = false;
|
||||
var _loc2_:Array = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc13_:Array = null;
|
||||
var _loc8_:Object = null;
|
||||
var _loc7_:int = 0;
|
||||
var _loc3_:Vector.<PostMessage> = new Vector.<PostMessage>();
|
||||
var _loc9_:Vector.<PostMessage> = new Vector.<PostMessage>();
|
||||
var _loc14_:Boolean = param1 != null ? Boolean(param1.s) : false;
|
||||
if(_loc14_)
|
||||
{
|
||||
_loc2_ = param1.r;
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc2_.length)
|
||||
{
|
||||
_loc11_ = _loc2_[_loc6_];
|
||||
if(_loc11_)
|
||||
{
|
||||
_loc12_ = _loc11_.um == 1 ? _loc11_.un : LocalizationManager.translateIdOnly(11098);
|
||||
_loc10_ = _loc11_.u == gMainFrame.userInfo.myUUID ? true : BuddyManager.isBuddy(_loc11_.un);
|
||||
_loc3_.push(new PostMessage(_loc11_.x,_loc11_.m,_loc11_.uid,_loc11_.un,_loc12_,_loc11_.s,_loc11_.c,_loc11_.t,_loc10_,_loc11_.ai,_loc11_.ac,_loc11_.ae,_loc11_.ap,_loc11_.l,_loc11_.aci,_loc11_.pp,"",false));
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_++;
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
_loc13_ = param1.n;
|
||||
if(_loc13_ != null && _loc13_.length > 0)
|
||||
{
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc13_.length)
|
||||
{
|
||||
_loc8_ = _loc13_[_loc7_];
|
||||
if(_loc8_ != null)
|
||||
{
|
||||
_loc12_ = _loc8_.um == 1 ? _loc8_.un : LocalizationManager.translateIdOnly(11098);
|
||||
_loc10_ = _loc8_.un == gMainFrame.userInfo.myUserName ? true : BuddyManager.isBuddy(_loc8_.un);
|
||||
_loc9_.push(new PostMessage(_loc8_.x,_loc8_.m,0,_loc8_.un,_loc12_,0,_loc8_.c,_loc8_.t,_loc10_,_loc8_.ai,_loc8_.ac,_loc8_.ae,_loc8_.ap,_loc8_.l,_loc8_.aci,_loc8_.pp,_loc8_.u,_loc8_.read));
|
||||
}
|
||||
_loc7_++;
|
||||
}
|
||||
_loc9_.sort(orderTimestamp);
|
||||
}
|
||||
PlayerWallManager.updateTimestamp(_currentRequestUsername,param1.t);
|
||||
_loc3_.sort(orderTimestamp);
|
||||
}
|
||||
PlayerWallManager.onGetResponse(_loc14_,_loc3_,_loc9_,param1.p,_isFromHudTimer,_currentRequestUsername,param1.e,_getResponseCallback);
|
||||
if(_getResponseCallback != null)
|
||||
{
|
||||
_getResponseCallback(_loc14_);
|
||||
_getResponseCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function setSettingsResponse(param1:Array) : void
|
||||
{
|
||||
var _loc2_:Boolean = param1 != null ? Boolean(param1.s) : false;
|
||||
PlayerWallManager.onPrivacyResponse(_loc2_,_setSettingsId);
|
||||
if(_setSettingsResponseCallback != null)
|
||||
{
|
||||
_setSettingsResponseCallback(_loc2_,_setSettingsId);
|
||||
_setSettingsResponseCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function setParametersResponse(param1:Array) : void
|
||||
{
|
||||
var _loc2_:Boolean = param1[2] == "1";
|
||||
PlayerWallManager.onParametersResponse(_loc2_,_setWallParameters);
|
||||
if(_setParametersResponseCallback != null)
|
||||
{
|
||||
_setParametersResponseCallback(_loc2_,_setWallParameters);
|
||||
_setParametersResponseCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function getBlockedMessagesResponse(param1:Object) : void
|
||||
{
|
||||
var _loc2_:Boolean = param1 != null ? Boolean(param1.s) : false;
|
||||
PlayerWallManager.onBlockedMessagesResponse(_loc2_,param1);
|
||||
if(_blockedMessagesCallback != null)
|
||||
{
|
||||
_blockedMessagesCallback(_loc2_,param1);
|
||||
_blockedMessagesCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function setBlockedMessageResponse(param1:Object) : void
|
||||
{
|
||||
var _loc2_:Boolean = param1 != null ? Boolean(param1.s) : false;
|
||||
PlayerWallManager.onSetBlockedMessageResponse(_loc2_,_messageToBeBlocked);
|
||||
if(_setBlockedMessageCallback != null)
|
||||
{
|
||||
_setBlockedMessageCallback(_loc2_,_messageToBeBlocked);
|
||||
_setBlockedMessageCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function sendClearAllMessagesResponse(param1:Object) : void
|
||||
{
|
||||
var _loc2_:Boolean = param1 != null ? Boolean(param1.s) : false;
|
||||
PlayerWallManager.onSendClearAllMessagesResponse(_loc2_);
|
||||
if(_sendClearAllMessagesCallback != null)
|
||||
{
|
||||
_sendClearAllMessagesCallback(_loc2_);
|
||||
_sendClearAllMessagesCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function sendRemoveMasterpieceResponse(param1:Object) : void
|
||||
{
|
||||
var _loc2_:Boolean = param1 != null ? Boolean(param1.s) : false;
|
||||
PlayerWallManager.onSendRemoveMasterpieceResponse(_loc2_,_masterpieceInvIdsToRemove);
|
||||
if(_sendMasterpieceCallback != null)
|
||||
{
|
||||
_sendMasterpieceCallback(_loc2_,_masterpieceInvIdsToRemove);
|
||||
_sendMasterpieceCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function sendAcknowledgeNotificationResponse(param1:Object) : void
|
||||
{
|
||||
var _loc2_:Boolean = param1 != null ? Boolean(param1.s) : false;
|
||||
PlayerWallManager.onSendAcknowledgeNotificationResponse(_loc2_,_sendAcknowledgeMessages);
|
||||
if(_sendAcknowledgeNotificationCallback != null)
|
||||
{
|
||||
_sendAcknowledgeNotificationCallback(_loc2_,_sendAcknowledgeMessages,param1.e);
|
||||
_sendAcknowledgeNotificationCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
// what a reply is read with: its caller sets these before asking
|
||||
private static function requestState() : Object
|
||||
{
|
||||
return {
|
||||
"del":_deleteResponseCallback,
|
||||
"get":_getResponseCallback,
|
||||
"put":_putResponseCallback,
|
||||
"blocked":_blockedMessagesCallback,
|
||||
"block":_setBlockedMessageCallback,
|
||||
"check":_checkResponseCallback,
|
||||
"clear":_sendClearAllMessagesCallback,
|
||||
"masterpiece":_sendMasterpieceCallback,
|
||||
"ack":_sendAcknowledgeNotificationCallback,
|
||||
"username":_currentRequestUsername,
|
||||
"message":_messageToPost,
|
||||
"uuid":_currMessageuuid,
|
||||
"toBlock":_messageToBeBlocked,
|
||||
"masterpieces":_masterpieceInvIdsToRemove,
|
||||
"ackMessages":_sendAcknowledgeMessages,
|
||||
"hud":_isFromHudTimer
|
||||
};
|
||||
}
|
||||
|
||||
private static function setRequestState(param1:Object) : void
|
||||
{
|
||||
_deleteResponseCallback = param1.del;
|
||||
_getResponseCallback = param1.get;
|
||||
_putResponseCallback = param1.put;
|
||||
_blockedMessagesCallback = param1.blocked;
|
||||
_setBlockedMessageCallback = param1.block;
|
||||
_checkResponseCallback = param1.check;
|
||||
_sendClearAllMessagesCallback = param1.clear;
|
||||
_sendMasterpieceCallback = param1.masterpiece;
|
||||
_sendAcknowledgeNotificationCallback = param1.ack;
|
||||
_currentRequestUsername = param1.username;
|
||||
_messageToPost = param1.message;
|
||||
_currMessageuuid = param1.uuid;
|
||||
_messageToBeBlocked = param1.toBlock;
|
||||
_masterpieceInvIdsToRemove = param1.masterpieces;
|
||||
_sendAcknowledgeMessages = param1.ackMessages;
|
||||
_isFromHudTimer = param1.hud;
|
||||
}
|
||||
|
||||
// the next request that waited, once none is on its way (a reply's
|
||||
// handler may have sent one of its own)
|
||||
private static function sendWaitingRequest() : void
|
||||
{
|
||||
var _loc1_:Object = null;
|
||||
if(!_isProcessingRequest && _waitingRequests.length > 0)
|
||||
{
|
||||
_loc1_ = _waitingRequests.shift();
|
||||
setRequestState(_loc1_.state);
|
||||
sendServiceRequest(_loc1_.request);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendServiceRequest(... rest) : void
|
||||
{
|
||||
var _loc3_:URLRequestHeader = null;
|
||||
var _loc4_:String = null;
|
||||
var _loc2_:URLRequest = null;
|
||||
// one made while another was on its way was dropped: a wall
|
||||
// opened while the HUD's timer was checking the player's own did
|
||||
// not open. it waits for its turn now, and the one on its way gets
|
||||
// back what its reply is read with.
|
||||
if(_isProcessingRequest)
|
||||
{
|
||||
_waitingRequests.push({
|
||||
"request":rest[0],
|
||||
"state":requestState()
|
||||
});
|
||||
if(_sentRequestState)
|
||||
{
|
||||
setRequestState(_sentRequestState);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_isProcessingRequest = true;
|
||||
_sentRequestState = requestState();
|
||||
_currCommand = rest[0].cmd;
|
||||
_loc3_ = new URLRequestHeader("Content-type","application/json");
|
||||
_loc4_ = JSON.stringify(rest[0]);
|
||||
_loc2_ = new URLRequest(gMainFrame.clientInfo.playerWallHost);
|
||||
_loc2_.method = "POST";
|
||||
_loc2_.requestHeaders.push(_loc3_);
|
||||
_loc2_.data = _loc4_;
|
||||
_requestor = new URLLoader();
|
||||
_requestor.addEventListener("complete",httpRequestComplete);
|
||||
_requestor.addEventListener("ioError",httpRequestError);
|
||||
_requestor.addEventListener("securityError",httpRequestError);
|
||||
_requestor.load(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
private static function httpRequestComplete(param1:Event) : void
|
||||
{
|
||||
_isProcessingRequest = false;
|
||||
var _loc2_:Object = param1.target.data != "" ? JSON.parse(param1.target.data) : null;
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
if("s" in _loc2_)
|
||||
{
|
||||
if(_loc2_.s == true)
|
||||
{
|
||||
_tokenFailures = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
switch(_currCommand)
|
||||
{
|
||||
case "CHK":
|
||||
checkResponse(_loc2_);
|
||||
break;
|
||||
case "PUT":
|
||||
addResponse(_loc2_);
|
||||
if(_loc2_.PUT.s == true)
|
||||
{
|
||||
_tokenFailures = 0;
|
||||
}
|
||||
break;
|
||||
case "DEL":
|
||||
deleteResponse(_loc2_);
|
||||
break;
|
||||
case "GET":
|
||||
getResponse(_loc2_);
|
||||
break;
|
||||
case "GMB":
|
||||
getBlockedMessagesResponse(_loc2_);
|
||||
break;
|
||||
case "AMB":
|
||||
setBlockedMessageResponse(_loc2_);
|
||||
break;
|
||||
case "CLW":
|
||||
sendClearAllMessagesResponse(_loc2_);
|
||||
break;
|
||||
case "RMP":
|
||||
sendRemoveMasterpieceResponse(_loc2_);
|
||||
break;
|
||||
case "ACK":
|
||||
sendAcknowledgeNotificationResponse(_loc2_);
|
||||
}
|
||||
sendWaitingRequest();
|
||||
}
|
||||
|
||||
private static function httpRequestError(param1:ErrorEvent) : void
|
||||
{
|
||||
_isProcessingRequest = false;
|
||||
if(GuiManager.mainHud.playerWall)
|
||||
{
|
||||
GuiManager.mainHud.playerWall.activateLoadingState(false);
|
||||
}
|
||||
BuddyManager.setPlayerWallLoading(false);
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
sendWaitingRequest();
|
||||
}
|
||||
|
||||
private static function orderTimestamp(param1:PostMessage, param2:PostMessage) : int
|
||||
{
|
||||
if(param1.postTime < param2.postTime)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if(param1.postTime > param2.postTime)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,8 +242,7 @@ package gui
|
||||
_loc2_.addEventListener("change",onDetailTyped,false,0,true);
|
||||
_loc1_.x = -143;
|
||||
_loc1_.y = -19;
|
||||
LocalizationManager.updateToFit(_reportFromCard.bodyTxt,"Choose a REASON, tell the moderator what happened, then click REPORT.");
|
||||
_reportFromCard.bodyTxt.height = 48;
|
||||
_reportFromCard.bodyTxt.visible = false;
|
||||
_reportFromCard.addChildAt(_loc1_,_reportFromCard.getChildIndex(_reportFromCard.reasonChatTree));
|
||||
_detailBar = _loc1_;
|
||||
_detailInput = _loc2_;
|
||||
|
||||
@@ -1205,6 +1205,11 @@ package shop
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:MovieClip = param1.daysLeftTag;
|
||||
// no "X days left": an item's window here comes round every year
|
||||
// (lib/sales.js), so a count to its end told players little but
|
||||
// that it was going, which it mostly was not
|
||||
_loc3_.visible = false;
|
||||
return;
|
||||
if(!param2.isRare && !_shopToSell)
|
||||
{
|
||||
_loc4_ = Math.ceil((param2.endTime - Utility.getCurrEpochTime()) / 60 / 60 / 24);
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
package adoptAPet
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.MouseEvent;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiManager;
|
||||
import loader.MediaHelper;
|
||||
|
||||
public class TierPathPopup
|
||||
{
|
||||
|
||||
private const POPUP_MEDIA_ID:int = 7208;
|
||||
|
||||
private var _tierPopup:MovieClip;
|
||||
|
||||
private var _mediaHelper:MediaHelper;
|
||||
|
||||
private var _closeCallback:Function;
|
||||
|
||||
public function TierPathPopup(param1:Function)
|
||||
{
|
||||
super();
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
_closeCallback = param1;
|
||||
_mediaHelper = new MediaHelper();
|
||||
_mediaHelper.init(7208,onPopupLoaded);
|
||||
}
|
||||
|
||||
public function destroy() : void
|
||||
{
|
||||
removeEventListeners();
|
||||
DarkenManager.unDarken(_tierPopup);
|
||||
GuiManager.guiLayer.removeChild(_tierPopup);
|
||||
_closeCallback = null;
|
||||
_tierPopup = null;
|
||||
}
|
||||
|
||||
private function onPopupLoaded(param1:MovieClip) : void
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
_tierPopup = MovieClip(param1.getChildAt(0));
|
||||
_tierPopup.x = 900 / 2;
|
||||
_tierPopup.y = 550 / 2;
|
||||
// a fault laying out the path left the window unshown, its
|
||||
// checklist waiting under it: it is shown either way now
|
||||
try
|
||||
{
|
||||
setupPathAndDots();
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
GlobalErrorCatch.reportToServer("adopt a pet gift path: " + e + "\n" + e.getStackTrace());
|
||||
}
|
||||
addEventListeners();
|
||||
GuiManager.guiLayer.addChild(_tierPopup);
|
||||
DarkenManager.darken(_tierPopup);
|
||||
}
|
||||
|
||||
private function setupPathAndDots() : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:MovieClip = null;
|
||||
var _loc8_:MovieClip = null;
|
||||
var _loc1_:MovieClip = null;
|
||||
var _loc7_:MovieClip = null;
|
||||
var _loc10_:Boolean = false;
|
||||
var _loc2_:Boolean = false;
|
||||
var _loc5_:int = int(AdoptAPetManager.TIERED_GIFT_COUNTS[AdoptAPetManager.TIERED_GIFT_COUNTS.length - 1]);
|
||||
var _loc9_:int = AdoptAPetManager.numTieredGiftCount;
|
||||
var _loc6_:Boolean = false;
|
||||
// frames count from 1: none adopted yet is the first
|
||||
_tierPopup.pinkPath.gotoAndStop(Math.max(1,Math.min(_loc9_,_tierPopup.pinkPath.totalFrames)));
|
||||
_loc4_ = 1;
|
||||
while(_loc4_ <= _loc5_)
|
||||
{
|
||||
_loc3_ = _tierPopup["dot_" + _loc4_];
|
||||
_loc8_ = _tierPopup["threshold" + _loc4_];
|
||||
if(_loc4_ <= _loc9_)
|
||||
{
|
||||
_loc2_ = true;
|
||||
}
|
||||
if(_loc3_ != null)
|
||||
{
|
||||
_loc7_ = _loc3_;
|
||||
if(_loc2_)
|
||||
{
|
||||
_loc10_ = false;
|
||||
_loc2_ = false;
|
||||
_loc1_ = _loc3_;
|
||||
_loc3_.num.text = _loc4_;
|
||||
_loc3_.star.visible = true;
|
||||
if(_loc7_ != null)
|
||||
{
|
||||
_loc7_.num.visible = false;
|
||||
if(_loc7_.num.text != "1")
|
||||
{
|
||||
_loc7_.star.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc7_.star.visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_.num.visible = false;
|
||||
_loc3_.star.visible = false;
|
||||
}
|
||||
}
|
||||
else if(_loc8_ != null)
|
||||
{
|
||||
if(_loc4_ <= _loc9_)
|
||||
{
|
||||
_loc10_ = true;
|
||||
_loc8_.gotoAndStop("open");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!_loc6_)
|
||||
{
|
||||
_loc8_.gotoAndStop("next");
|
||||
_loc6_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_.gotoAndStop("future");
|
||||
}
|
||||
_loc8_.numTxt.text = _loc4_;
|
||||
}
|
||||
}
|
||||
else if(!_loc10_)
|
||||
{
|
||||
_loc2_ = false;
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
if(_loc1_ != null)
|
||||
{
|
||||
if(_loc10_)
|
||||
{
|
||||
_loc1_.num.visible = false;
|
||||
_loc1_.star.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_.num.visible = true;
|
||||
_loc1_.star.visible = true;
|
||||
_loc1_.num.text = _loc9_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function addEventListeners() : void
|
||||
{
|
||||
_tierPopup.bx.addEventListener("mouseDown",onCloseBtn,false,0,true);
|
||||
}
|
||||
|
||||
private function removeEventListeners() : void
|
||||
{
|
||||
_tierPopup.bx.removeEventListener("mouseDown",onCloseBtn);
|
||||
}
|
||||
|
||||
private function onCloseBtn(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
if(_closeCallback != null)
|
||||
{
|
||||
_closeCallback();
|
||||
}
|
||||
else
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -878,7 +878,9 @@ package gui
|
||||
_loc32_.dispatchEvent(new AvatarEvent("OnAvatarChanged"));
|
||||
}
|
||||
GuiManager.showHudAvt();
|
||||
closeRequestSentPopup();
|
||||
// the "waiting" window goes quietly: the trade went through, and
|
||||
// its failure sound played over the success one
|
||||
closeRequestSentPopup(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2308,11 +2310,14 @@ package gui
|
||||
}
|
||||
}
|
||||
|
||||
private static function closeRequestSentPopup() : void
|
||||
private static function closeRequestSentPopup(param1:Boolean = true) : void
|
||||
{
|
||||
if(_requestSentPopup && _requestSentPopup.visible)
|
||||
{
|
||||
AJAudio.playTradeFailedSound();
|
||||
if(param1)
|
||||
{
|
||||
AJAudio.playTradeFailedSound();
|
||||
}
|
||||
DarkenManager.unDarken(_requestSentPopup);
|
||||
if(_requestSentPopup.parent == _guiLayer)
|
||||
{
|
||||
|
||||
@@ -173,7 +173,8 @@ package avatar
|
||||
{
|
||||
return;
|
||||
}
|
||||
AvatarManager.addAvatarMessage(param1,_playerSfsUserId,0);
|
||||
// the bubble comes with the server's echo, as typed chat's does, so
|
||||
// that it is drawn in the player's chat style (lib/world.js)
|
||||
addChatMessage(param1);
|
||||
gMainFrame.server.sendMessage(param2 + RAW_STR + 1);
|
||||
if(_chatHist.enableFreeChatValue)
|
||||
@@ -221,7 +222,9 @@ package avatar
|
||||
{
|
||||
throw new Error("setAvatarAction: sent invalid action sprite?!");
|
||||
}
|
||||
addChatMessage(_actionMgr.getActionString(param1));
|
||||
// Actions animate the avatar, but are not chat messages. Keeping the
|
||||
// wire command out of the history prevents entries such as
|
||||
// ":sitS:" and ":sitSW:" from filling the player's chat log.
|
||||
var _loc2_:AvatarWorldView = AvatarManager.avatarViewList[AvatarManager.playerSfsUserId];
|
||||
if(_loc2_ && _actionMgr.mirrorActions)
|
||||
{
|
||||
@@ -760,6 +763,13 @@ package avatar
|
||||
{
|
||||
_loc2_ = reverseSpecialWords(_loc2_);
|
||||
}
|
||||
// Burrow appends a style after the normal extra field.
|
||||
// Message and type remain at their stock indexes, so
|
||||
// pending chat and every unpatched client still work.
|
||||
if(param1.length > 6 && AvatarManager.avatarViewList[_loc19_])
|
||||
{
|
||||
AvatarManager.avatarViewList[_loc19_].setChatStyle(String(param1[6]));
|
||||
}
|
||||
AvatarManager.addAvatarMessage(_loc2_,_loc19_,int(param1[5]));
|
||||
break;
|
||||
case 2:
|
||||
@@ -775,6 +785,20 @@ package avatar
|
||||
_loc2_ = EmoticonUtility.stringForId(int(_loc2_));
|
||||
break;
|
||||
case 3:
|
||||
// "sja:<anim>,<flip>": an animation that is not one of
|
||||
// the emote-bar actions (any id the client has, 1-255),
|
||||
// sent as an action message by modded clients. The
|
||||
// normal client finds no action for it and drops it.
|
||||
if(_loc2_.indexOf("sja:") == 0)
|
||||
{
|
||||
_loc10_ = _loc2_.substr(4).split(",");
|
||||
_loc12_ = int(_loc10_[0]);
|
||||
if(_loc19_ != gMainFrame.server.userId && _loc12_ > 0 && _loc12_ <= 255 && !MinigameManager.inMinigame() && AvatarManager.avatarViewList[_loc19_])
|
||||
{
|
||||
AvatarManager.avatarViewList[_loc19_].holdIdleAnim(_loc12_,_loc10_[1] == "1");
|
||||
}
|
||||
return;
|
||||
}
|
||||
_loc5_ = _actionMgr.matchActionString(_loc2_);
|
||||
if(_loc5_)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ package
|
||||
import flash.events.TimerEvent;
|
||||
import flash.utils.Timer;
|
||||
import flash.utils.getTimer;
|
||||
import gui.itemWindows.ItemWindowToggle;
|
||||
|
||||
public class XtReplyDemuxer
|
||||
{
|
||||
@@ -159,6 +160,11 @@ package
|
||||
AJClient.onFilterState(param1.obj);
|
||||
return;
|
||||
}
|
||||
if(param1.obj[0] == "xcs")
|
||||
{
|
||||
ItemWindowToggle.chatStyleState(param1.obj);
|
||||
return;
|
||||
}
|
||||
if(param1.obj[0] == "xfa")
|
||||
{
|
||||
AJClient.onFilterAsk(param1.obj);
|
||||
|
||||
Binary file not shown.
@@ -66,6 +66,87 @@ const run = async () => {
|
||||
// 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]]);
|
||||
|
||||
// --- signing in with the Burrow client: the page's nonce, the client's
|
||||
// token for a ticket, and the ticket only for the browser that started it
|
||||
const clientStart = async () => {
|
||||
const started = await mine("client-start", {});
|
||||
assert.strictEqual(started.status, 200);
|
||||
assert.match(started.cookie, /^ajc_clink=[0-9a-f]{48}$/);
|
||||
return {nonce: started.data.nonce, cookie: started.cookie};
|
||||
};
|
||||
const openTicket = async (link, cookie) => {
|
||||
const response = await fetch(`${BASE}${new URL(link).pathname}${new URL(link).search}`, {headers: cookie ? {Cookie: cookie} : {}});
|
||||
const result = /client=(\w+)/.exec(await response.text())[1];
|
||||
const session = response.headers.getSetCookie().map(line => line.split(";")[0]).find(line => /^ajc_account=[0-9a-f]{48}$/.test(line));
|
||||
return {result, session};
|
||||
};
|
||||
const annToken = (await (await authenticate("Ann", "KettlePass01")).json()).auth_token;
|
||||
const browser = await clientStart();
|
||||
assert.strictEqual((await mine("client-ticket", {token: annToken, nonce: "0".repeat(48)})).status, 400);
|
||||
assert.strictEqual((await mine("client-ticket", {token: "f".repeat(annToken.length), nonce: browser.nonce})).status, 401);
|
||||
const ticket = await mine("client-ticket", {token: annToken, nonce: browser.nonce});
|
||||
assert.deepStrictEqual([ticket.status, ticket.data.username], [200, "Ann"]);
|
||||
// another browser (no cookie, or another start's) gets nothing from it, and it is then used up
|
||||
const other = await clientStart();
|
||||
assert.deepStrictEqual(await openTicket(ticket.data.url, other.cookie), {result: "elsewhere", session: undefined});
|
||||
assert.deepStrictEqual(await openTicket(ticket.data.url, browser.cookie), {result: "expired", session: undefined});
|
||||
const second = await mine("client-ticket", {token: annToken, nonce: browser.nonce});
|
||||
assert.deepStrictEqual(await openTicket(second.data.url), {result: "elsewhere", session: undefined});
|
||||
const third = await mine("client-ticket", {token: annToken, nonce: browser.nonce});
|
||||
const opened = await openTicket(third.data.url, browser.cookie);
|
||||
assert.strictEqual(opened.result, "ok");
|
||||
assert.strictEqual((await mine("me", undefined, opened.session)).data.username, "Ann");
|
||||
// the start is used up with the sign-in
|
||||
assert.strictEqual((await mine("client-ticket", {token: annToken, nonce: browser.nonce})).status, 400);
|
||||
|
||||
// --- the item giver on the web (/account/items): signed in as on this page
|
||||
assert.match(await (await fetch(`${BASE}/account/items`)).text(), /Item giver/);
|
||||
// (an account of its own: the others' inventories are counted further down)
|
||||
assert.strictEqual((await register("Cleo", 5)).status, 200);
|
||||
const cleo = (await mine("login", {username: "Cleo", password: "KettlePass01"})).cookie;
|
||||
assert.strictEqual((await mine("giver?q=top%20hat")).status, 401);
|
||||
const hats = (await mine("giver?q=top%20hat&kind=clothing", undefined, cleo)).data;
|
||||
const hat = hats.results.find(entry => entry.id === 21);
|
||||
assert.ok(hat.presets.length > 1 && hat.presets[0].colours.every(colour => /^[0-9a-f]{6}$/.test(colour)));
|
||||
const ownColour = await mine("give", {kind: "clothing", id: 21, colorIndex: 1}, cleo);
|
||||
assert.deepStrictEqual([ownColour.status, ownColour.data.color], [200, hat.presets[1].id]);
|
||||
// four colours of one's own: a custom colour (lib/colours.js), the same one for the same four
|
||||
const hexColours = await mine("give", {kind: "clothing", id: 21, color: "#ff0000 #00ff00 #0000ff #ffffff"}, cleo);
|
||||
assert.strictEqual(hexColours.status, 200);
|
||||
assert.ok(hexColours.data.color >= 0xFD000000 && hexColours.data.color <= 0xFDFFFFFF);
|
||||
assert.strictEqual((await mine("give", {kind: "clothing", id: 21, color: "#ff0000 #00ff00 #0000ff #ffffff"}, cleo)).data.color, hexColours.data.color);
|
||||
// the page's colour boxes: the palette, a custom colour's four, the custom colour four make
|
||||
assert.strictEqual((await mine("colour", undefined, cleo)).data.palette.length, 256);
|
||||
assert.deepStrictEqual((await mine(`colour?id=${hexColours.data.color | 0}`, undefined, cleo)).data.colours, ["ff0000", "00ff00", "0000ff", "ffffff"]);
|
||||
assert.strictEqual((await mine("colour?rgbs=ff0000,00ff00,0000ff,ffffff", undefined, cleo)).data.id, hexColours.data.color);
|
||||
assert.strictEqual((await mine("colour?rgbs=123456,00ff00,0000ff,ffffff", undefined, cleo)).data.id, null);
|
||||
assert.strictEqual((await mine("colour?id=4261412863", undefined, cleo)).status, 404);
|
||||
// a colour as the game writes it, signed or not; a custom one only if it is made
|
||||
assert.strictEqual((await mine("give", {kind: "clothing", id: 21, color: "-16777216"}, cleo)).data.color, 0xFF000000);
|
||||
assert.strictEqual((await mine("give", {kind: "clothing", id: 21, color: "4261412863"}, cleo)).status, 400);
|
||||
// a den item's variants (lib/den-variants.json) and a tint: 1 + the tint's colour entry above the variant's 8 bits
|
||||
const chair = (await mine("giver?q=1&kind=den", undefined, cleo)).data.results.find(entry => entry.id === 1);
|
||||
assert.deepStrictEqual([chair.variants, chair.variantColours.length, chair.tintable], [[0, 1, 2, 3, 4, 5, 6, 7], 8, true]);
|
||||
assert.deepStrictEqual((await mine("give", {kind: "den", id: 1, version: 5}, cleo)).data.version, 5);
|
||||
assert.strictEqual((await mine("give", {kind: "den", id: 1, version: 9}, cleo)).status, 400);
|
||||
assert.strictEqual((await mine("give", {kind: "den", id: 1, tint: "red"}, cleo)).status, 400);
|
||||
assert.strictEqual((await mine("give", {kind: "den", id: 1, tint: "#ff8800", tintStrength: 0}, cleo)).status, 400);
|
||||
const tinted = await mine("give", {kind: "den", id: 1, version: 3, tint: "#ff8800", tintStrength: 60}, cleo);
|
||||
assert.strictEqual(tinted.status, 200);
|
||||
assert.strictEqual(tinted.data.version & 0xFF, 3);
|
||||
assert.ok(tinted.data.version >> 8 >= 1);
|
||||
// only from this server's own pages
|
||||
assert.strictEqual((await mine("give", {kind: "den", id: 1}, cleo, {Origin: "http://evil.example"})).status, 403);
|
||||
// its previews (lib/itempreview.js), the same for anyone: a clothing icon to colour, a den item's SWF
|
||||
const icon = await (await fetch(`${BASE}/account/art/clothing/21`)).json();
|
||||
assert.ok(icon.w > 0 && icon.h > 0 && Buffer.from(icon.b, "base64").length > 0);
|
||||
const denArt = await fetch(`${BASE}/account/art/den/1`);
|
||||
assert.strictEqual(denArt.headers.get("access-control-allow-origin"), "*");
|
||||
assert.match(Buffer.from(await denArt.arrayBuffer()).subarray(0, 3).toString(), /^[CFZ]WS$/);
|
||||
assert.strictEqual((await fetch(`${BASE}/account/art/den/999999`)).status, 404);
|
||||
assert.match((await fetch(`${BASE}/account/item-preview`)).headers.get("content-security-policy"), /sandbox allow-scripts$/);
|
||||
assert.match(Buffer.from(await (await fetch(`${BASE}/account/item-preview.swf`)).arrayBuffer()).subarray(0, 3).toString(), /^[CFZ]WS$/);
|
||||
|
||||
// --- parts of the game switched off
|
||||
const {client: a, roomId} = await arrive("Ann", "KettlePass01");
|
||||
const {client: b} = await arrive("Ben", "KettlePass01");
|
||||
|
||||
+14
-14
@@ -11,7 +11,7 @@ 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 GAMES = {ticTacToe: 1, fourGems: 31, rockPaperScissors: 32, shellGame: 38, pairs: 101, scooped: 53, bowling: 108, marbles: 45};
|
||||
|
||||
const arrive = async username => {
|
||||
const auth = await (await postJson(`${BASE}/authenticate`, {username, password: "KettlePass01"})).json();
|
||||
@@ -48,22 +48,22 @@ const run = async () => {
|
||||
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"]);
|
||||
assert.deepStrictEqual([first[0], first[2], first[4], first[5], first[7], first[8], first[12], first[17]], ["1", "PVP_TicTacToe", "2", "2", "0", "5055", "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"]);
|
||||
assert.deepStrictEqual((await b.nextXt("mp")).slice(2), ["1", "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"]);
|
||||
assert.deepStrictEqual((await c.nextXt("mp")).slice(2), ["101", "1"]);
|
||||
b.xt("mp", ben.roomId, GAMES.ticTacToe, 1);
|
||||
assert.deepStrictEqual((await a.nextXt("mp")).slice(2), ["89", "1"]);
|
||||
assert.deepStrictEqual((await a.nextXt("mp")).slice(2), ["1", "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"]);
|
||||
assert.deepStrictEqual((await b.nextXt("mp")).slice(2), ["1", "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);
|
||||
@@ -301,13 +301,13 @@ const run = async () => {
|
||||
const bubble = (client, me, word, game) => client.send(`<msg t='sys'><body action='pubMsg' r='${me.roomId}'><txt><![CDATA[${word}%12%${game}]]></txt></body></msg>`);
|
||||
bubble(a, ann, "on", GAMES.pairs);
|
||||
for (const client of [a, b, c]) {
|
||||
assert.deepStrictEqual((await client.untilXt("uc")).slice(1), [ann.roomId, ann.id, "on|93", "12", "0"]);
|
||||
assert.deepStrictEqual((await client.untilXt("uc")).slice(1), [ann.roomId, ann.id, "on|101", "12", "0"]);
|
||||
}
|
||||
// A game that is not the one in the bubble, or a bubble nobody has up: "no".
|
||||
c.xt("mcp", cat.roomId, GAMES.ticTacToe, 0, "Ann");
|
||||
assert.deepStrictEqual((await c.untilXt("mp")).slice(2), ["89", "1"]);
|
||||
assert.deepStrictEqual((await c.untilXt("mp")).slice(2), ["1", "1"]);
|
||||
c.xt("mcp", cat.roomId, GAMES.pairs, 0, "Ben");
|
||||
assert.deepStrictEqual((await c.untilXt("mp")).slice(2), ["93", "1"]);
|
||||
assert.deepStrictEqual((await c.untilXt("mp")).slice(2), ["101", "1"]);
|
||||
// Ben clicks it: the game starts for the two of them and the bubble goes
|
||||
// for Cat. Ann hears her own "off" only once the game is over.
|
||||
b.xt("mcp", ben.roomId, GAMES.pairs, 0, "Ann");
|
||||
@@ -319,7 +319,7 @@ const run = async () => {
|
||||
}
|
||||
// too late for Cat
|
||||
c.xt("mcp", cat.roomId, GAMES.pairs, 0, "Ann");
|
||||
assert.deepStrictEqual((await c.untilXt("mp")).slice(2), ["93", "1"]);
|
||||
assert.deepStrictEqual((await c.untilXt("mp")).slice(2), ["101", "1"]);
|
||||
// while in it, Ann's client turning the bubble off is not answered yet
|
||||
bubble(a, ann, "off", 0);
|
||||
b.xt("rl", pairsRoom, pairsRoom);
|
||||
@@ -327,8 +327,8 @@ const run = async () => {
|
||||
assert.deepStrictEqual((await a.untilXt("uc")).slice(1), [ann.roomId, ann.id, "off", "12"]);
|
||||
// put up and taken down again outside a game: answered at once
|
||||
bubble(a, ann, "on", GAMES.bowling);
|
||||
assert.deepStrictEqual((await a.untilXt("uc")).slice(3), ["on|98", "12", "0"]);
|
||||
assert.deepStrictEqual((await c.untilXt("uc")).slice(3), ["on|98", "12", "0"]);
|
||||
assert.deepStrictEqual((await a.untilXt("uc")).slice(3), ["on|108", "12", "0"]);
|
||||
assert.deepStrictEqual((await c.untilXt("uc")).slice(3), ["on|108", "12", "0"]);
|
||||
bubble(a, ann, "off", 0);
|
||||
assert.deepStrictEqual((await a.untilXt("uc")).slice(3), ["off", "12"]);
|
||||
assert.deepStrictEqual((await c.untilXt("uc")).slice(3), ["off", "12"]);
|
||||
@@ -351,7 +351,7 @@ const run = async () => {
|
||||
do {
|
||||
seen = await dee.client.untilXt("uc");
|
||||
} while (seen[2] !== ann.id);
|
||||
assert.deepStrictEqual(seen.slice(3), ["on|92", "12", "0"]);
|
||||
assert.deepStrictEqual(seen.slice(3), ["on|38", "12", "0"]);
|
||||
bubble(a, ann, "off", 0);
|
||||
await a.untilXt("uc");
|
||||
dee.client.socket.destroy();
|
||||
@@ -367,7 +367,7 @@ const run = async () => {
|
||||
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"]);
|
||||
assert.deepStrictEqual((await b.untilXt("mp")).slice(2), ["45", "1"]);
|
||||
|
||||
// --- a room game played together (lib/minigames.js MULTIPLAYER): Gem
|
||||
// Breaker offers its waiting list, Ben waits in the room, Cat joins, both
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
|
||||
// loaded into the test server (NODE_OPTIONS --require, by test/signin.js):
|
||||
// Discord's OAuth2 API answered here, so a sign-in with Discord can be gone
|
||||
// through without Discord. the code Discord would send back names who signs
|
||||
// in ("mira" -> Mira's Discord account); anything else goes out as usual.
|
||||
|
||||
const USERS = {
|
||||
mira: {id: "100000000000000001", username: "mira_discord"},
|
||||
hal: {id: "100000000000000002", username: "hal_discord"},
|
||||
};
|
||||
|
||||
const realFetch = globalThis.fetch;
|
||||
globalThis.fetch = async (url, options = {}) => {
|
||||
const href = String(url);
|
||||
if (!href.startsWith("https://discord.com/api/")) {
|
||||
return realFetch(url, options);
|
||||
}
|
||||
const json = (status, body) => new Response(JSON.stringify(body), {status, headers: {"Content-Type": "application/json"}});
|
||||
if (href.endsWith("/oauth2/token")) {
|
||||
const code = new URLSearchParams(String(options.body || "")).get("code");
|
||||
return USERS[code] ? json(200, {access_token: `token-${code}`, token_type: "Bearer"}) : json(400, {error: "invalid_grant"});
|
||||
}
|
||||
if (href.endsWith("/users/@me")) {
|
||||
const user = USERS[String((options.headers || {}).Authorization || "").replace(/^Bearer token-/, "")];
|
||||
return user ? json(200, {...user, discriminator: "0"}) : json(401, {});
|
||||
}
|
||||
return json(404, {});
|
||||
};
|
||||
+244
@@ -0,0 +1,244 @@
|
||||
"use strict";
|
||||
|
||||
// end to end: what a sign-in takes besides a password. Discord says who
|
||||
// someone is, but the moderator and admin panels open only with their 2FA
|
||||
// code as well (lib/modpanel.js, lib/panel.js); and a recovery email resets
|
||||
// a password, but removes 2FA only with the password too, never right after
|
||||
// a password reset by email, and never for staff (lib/manage.js). Discord's
|
||||
// API is test/fake-discord.js, and recovery mail goes to a server of ours.
|
||||
|
||||
const assert = require("assert");
|
||||
const crypto = require("crypto");
|
||||
const http = require("http");
|
||||
const path = require("path");
|
||||
const harness = require("./harness.js");
|
||||
|
||||
const HTTP_PORT = 18096;
|
||||
const GAME_PORT = 19356;
|
||||
const MAIL_PORT = 18097;
|
||||
const BASE = `http://127.0.0.1:${HTTP_PORT}`;
|
||||
|
||||
// the authenticator app's side of 2FA (as in test/staff.js)
|
||||
const STEP = 30;
|
||||
const base32Decode = text => {
|
||||
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
||||
const bits = text.replace(/=+$/, "").toUpperCase().split("").map(c => alphabet.indexOf(c).toString(2).padStart(5, "0")).join("");
|
||||
const bytes = [];
|
||||
for (let i = 0; i + 8 <= bits.length; i += 8) {
|
||||
bytes.push(parseInt(bits.slice(i, i + 8), 2));
|
||||
}
|
||||
return Buffer.from(bytes);
|
||||
};
|
||||
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) % 1000000).padStart(6, "0");
|
||||
};
|
||||
const stepNow = () => Math.floor(Date.now() / 1000 / STEP);
|
||||
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
|
||||
// a code is taken once: each use needs a later step than the last.
|
||||
const used = {};
|
||||
const freshCode = async (who, secret) => {
|
||||
while (used[who] !== undefined && stepNow() <= used[who]) {
|
||||
await sleep(250);
|
||||
}
|
||||
used[who] = stepNow();
|
||||
return codeAt(secret, used[who]);
|
||||
};
|
||||
|
||||
// a browser: keeps every cookie it is given, follows no redirects.
|
||||
const browser = () => {
|
||||
const jar = new Map();
|
||||
const request = async (where, {body, method} = {}) => {
|
||||
const headers = {cookie: [...jar].map(([name, value]) => `${name}=${value}`).join("; ")};
|
||||
const options = {method: method || (body === undefined ? "GET" : "POST"), headers, redirect: "manual"};
|
||||
if (body !== undefined) {
|
||||
options.headers["Content-Type"] = "application/json";
|
||||
options.body = JSON.stringify(body);
|
||||
}
|
||||
const res = await fetch(where.startsWith("http") ? where : `${BASE}${where}`, options);
|
||||
for (const line of res.headers.getSetCookie()) {
|
||||
const [pair, ...attributes] = line.split(";");
|
||||
const [name, value] = pair.split("=");
|
||||
if (attributes.some(attribute => /^\s*max-age=0$/i.test(attribute)) || value === "") {
|
||||
jar.delete(name.trim());
|
||||
}
|
||||
else {
|
||||
jar.set(name.trim(), value);
|
||||
}
|
||||
}
|
||||
return {status: res.status, location: res.headers.get("location") || "", data: await res.json().catch(() => ({})), cookies: res.headers.getSetCookie()};
|
||||
};
|
||||
request.has = name => jar.has(name);
|
||||
return request;
|
||||
};
|
||||
|
||||
// a Discord sign-in through the fake Discord: start at `start`, come back
|
||||
// to `callback` as `who`. the redirect's address.
|
||||
const throughDiscord = async (page, start, callback, who) => {
|
||||
const begun = await page(start);
|
||||
assert.strictEqual(begun.status, 302, JSON.stringify(begun));
|
||||
const state = new URL(begun.location).searchParams.get("state");
|
||||
assert.ok(state, begun.location);
|
||||
const back = await page(`${callback}?state=${state}&code=${who}`);
|
||||
assert.strictEqual(back.status, 302);
|
||||
return back;
|
||||
};
|
||||
|
||||
const run = async mail => {
|
||||
const people = {Mira: "KettlePass21", Hal: "KettlePass22", Pip: "KettlePass23"};
|
||||
for (const [username, password] of Object.entries(people)) {
|
||||
const res = await fetch(`${BASE}/api/register`, {method: "POST", headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify({username, password, email: `${username.toLowerCase()}@example.com`, avatarType: 1, agreed: true})});
|
||||
assert.strictEqual(res.status, 200, await res.text());
|
||||
}
|
||||
|
||||
// Mira and Hal turn on 2FA and link their Discord accounts.
|
||||
const secrets = {};
|
||||
for (const username of ["Mira", "Hal"]) {
|
||||
const page = browser();
|
||||
assert.strictEqual((await page("/account/api/login", {body: {username, password: people[username]}})).status, 200);
|
||||
const begun = await page("/account/api/act", {body: {action: "twoStepStart", current: people[username]}});
|
||||
secrets[username] = begun.data.setup.secret;
|
||||
const confirmed = await page("/account/api/act", {body: {action: "twoStepConfirm", code: await freshCode(username, secrets[username])}});
|
||||
assert.ok(confirmed.data.ok, JSON.stringify(confirmed.data));
|
||||
const linked = await throughDiscord(page, "/account/discord/link", "/account/discord/callback", username.toLowerCase());
|
||||
assert.match(linked.location, /discord=linked/);
|
||||
}
|
||||
|
||||
// the admin makes Mira a moderator, and lets Hal into this dashboard with Discord.
|
||||
const admin = browser();
|
||||
assert.strictEqual((await admin("/admin/api/setup", {body: {password: "AdminPass99!"}})).status, 200);
|
||||
assert.strictEqual((await admin("/admin/api/login", {body: {password: "AdminPass99!"}})).status, 200);
|
||||
assert.match((await admin("/admin/api/account", {body: {username: "Mira", action: "role", role: "moderator"}})).data.ok, /moderator/);
|
||||
assert.ok((await admin("/admin/api/account", {body: {username: "Hal", action: "adminDashboardAccess", on: true}})).data.ok);
|
||||
|
||||
// --- the moderator panel: Discord, then the code
|
||||
const mod = browser();
|
||||
const back = await throughDiscord(mod, "/dashboard/staff/discord/login", "/dashboard/staff/discord/callback", "mira");
|
||||
assert.match(back.location, /discord=code$/);
|
||||
assert.ok(!mod.has("ajc_mod"), "Discord alone opened the moderator panel");
|
||||
assert.ok(mod.has("ajc_mod_pending"));
|
||||
assert.strictEqual((await mod("/dashboard/api/staff/state")).data.signedIn, false);
|
||||
assert.strictEqual((await mod("/dashboard/api/staff/players")).status, 401);
|
||||
const wrong = await mod("/dashboard/api/staff/discord/code", {body: {code: "000000"}});
|
||||
assert.strictEqual(wrong.status, 401);
|
||||
assert.strictEqual(wrong.data.expired, undefined);
|
||||
const right = await mod("/dashboard/api/staff/discord/code", {body: {code: await freshCode("Mira", secrets.Mira)}});
|
||||
assert.strictEqual(right.status, 200, JSON.stringify(right.data));
|
||||
assert.strictEqual(right.data.username, "Mira");
|
||||
assert.ok(mod.has("ajc_mod") && !mod.has("ajc_mod_pending"));
|
||||
assert.strictEqual((await mod("/dashboard/api/staff/state")).data.signedIn, true);
|
||||
// a waiting sign-in is used once
|
||||
const again = await mod("/dashboard/api/staff/discord/code", {body: {code: await freshCode("Mira", secrets.Mira)}});
|
||||
assert.strictEqual(again.data.expired, true);
|
||||
|
||||
// a few wrong codes, and it must start again at Discord
|
||||
const guesser = browser();
|
||||
await throughDiscord(guesser, "/dashboard/staff/discord/login", "/dashboard/staff/discord/callback", "mira");
|
||||
for (let i = 1; i <= 5; i++) {
|
||||
const guess = await guesser("/dashboard/api/staff/discord/code", {body: {code: String(100000 + i)}});
|
||||
assert.strictEqual(guess.status, 401);
|
||||
assert.strictEqual(Boolean(guess.data.expired), i === 5);
|
||||
}
|
||||
assert.strictEqual((await guesser("/dashboard/api/staff/discord/code", {body: {code: await freshCode("Mira", secrets.Mira)}})).data.expired, true);
|
||||
assert.ok(!guesser.has("ajc_mod"));
|
||||
|
||||
// a Discord account linked to no staff gets nowhere
|
||||
const player = browser();
|
||||
const denied = await throughDiscord(player, "/dashboard/staff/discord/login", "/dashboard/staff/discord/callback", "hal");
|
||||
assert.match(denied.location, /discord=denied$/);
|
||||
assert.ok(!player.has("ajc_mod_pending"));
|
||||
|
||||
// --- the admin dashboard: the same
|
||||
const owner = browser();
|
||||
const adminBack = await throughDiscord(owner, "/dashboard/admin/discord/login", "/dashboard/admin/discord/callback", "hal");
|
||||
assert.match(adminBack.location, /discord=code$/);
|
||||
assert.ok(!owner.has("ajc_admin"), "Discord alone opened the admin dashboard");
|
||||
assert.strictEqual((await owner("/dashboard/api/admin/state")).data.signedIn, false);
|
||||
assert.strictEqual((await owner("/dashboard/api/admin/discord/code", {body: {code: "000000"}})).status, 401);
|
||||
const adminRight = await owner("/dashboard/api/admin/discord/code", {body: {code: await freshCode("Hal", secrets.Hal)}});
|
||||
assert.strictEqual(adminRight.status, 200, JSON.stringify(adminRight.data));
|
||||
assert.strictEqual((await owner("/dashboard/api/admin/state")).data.signedIn, true);
|
||||
|
||||
// --- recovery by email
|
||||
const recover = async (username, kind) => {
|
||||
const before = mail.length;
|
||||
const sent = await (browser())("/account/api/recover/request", {body: {username, email: `${username.toLowerCase()}@example.com`, kind}});
|
||||
assert.strictEqual(sent.status, 200);
|
||||
if (mail.length === before) {
|
||||
return null;
|
||||
}
|
||||
const message = mail.at(-1);
|
||||
assert.strictEqual(message.to, `${username.toLowerCase()}@example.com`);
|
||||
return new URL(/https?:\/\/\S+/.exec(message.text)[0]).searchParams.get("token");
|
||||
};
|
||||
const page = browser();
|
||||
|
||||
// a password, by the email alone
|
||||
const pipToken = await recover("Pip", "password");
|
||||
assert.strictEqual((await page("/account/api/recover/check", {body: {token: pipToken}})).data.kind, "password");
|
||||
assert.strictEqual((await page("/account/api/recover/complete", {body: {token: pipToken, password: "KettlePass33"}})).status, 200);
|
||||
// and then not 2FA as well, by the email, for a week
|
||||
const pipTwoStep = await recover("Pip", "twoStep");
|
||||
assert.match((await page("/account/api/recover/check", {body: {token: pipTwoStep}})).data.error, /within 7 days/);
|
||||
assert.match((await page("/account/api/recover/complete", {body: {token: pipTwoStep, password: "KettlePass33"}})).data.error, /within 7 days/);
|
||||
|
||||
// 2FA, by the email and the password
|
||||
const halToken = await recover("Hal", "twoStep");
|
||||
assert.strictEqual((await page("/account/api/recover/check", {body: {token: halToken}})).data.kind, "twoStep");
|
||||
const noPassword = await page("/account/api/recover/complete", {body: {token: halToken, password: "not it"}});
|
||||
assert.strictEqual(noPassword.status, 401);
|
||||
assert.strictEqual((await page("/account/api/recover/complete", {body: {token: halToken, password: people.Hal}})).status, 200);
|
||||
const halNow = browser();
|
||||
assert.strictEqual((await halNow("/account/api/login", {body: {username: "Hal", password: people.Hal}})).status, 200, "2FA was not removed");
|
||||
|
||||
// never for staff: a mailbox does not make anyone a moderator
|
||||
const miraToken = await recover("Mira", "twoStep");
|
||||
assert.match((await page("/account/api/recover/check", {body: {token: miraToken}})).data.error, /Staff accounts/);
|
||||
assert.match((await page("/account/api/recover/complete", {body: {token: miraToken, password: people.Mira}})).data.error, /Staff accounts/);
|
||||
assert.strictEqual((await mod("/dashboard/api/staff/state")).data.signedIn, true, "Mira's 2FA went");
|
||||
|
||||
// a few recovery emails an hour for one account, from anywhere
|
||||
assert.ok(await recover("Mira", "password"));
|
||||
assert.ok(await recover("Mira", "password"));
|
||||
assert.strictEqual(await recover("Mira", "password"), null);
|
||||
};
|
||||
|
||||
const main = async () => {
|
||||
const mail = [];
|
||||
const mailServer = http.createServer((req, res) => {
|
||||
let body = "";
|
||||
req.on("data", chunk => {
|
||||
body += chunk;
|
||||
});
|
||||
req.on("end", () => {
|
||||
assert.strictEqual(req.headers.authorization, "Bearer test-mail-token");
|
||||
mail.push(JSON.parse(body));
|
||||
res.writeHead(200);
|
||||
res.end();
|
||||
});
|
||||
});
|
||||
await new Promise(resolve => mailServer.listen(MAIL_PORT, "127.0.0.1", resolve));
|
||||
Object.assign(process.env, {
|
||||
// forward slashes: NODE_OPTIONS reads a backslash as an escape (Windows)
|
||||
NODE_OPTIONS: `${process.env.NODE_OPTIONS || ""} --require "${path.join(__dirname, "fake-discord.js").replace(/\\/g, "/")}"`.trim(),
|
||||
AJ_DISCORD_CLIENT_ID: "123456789012345678",
|
||||
AJ_DISCORD_CLIENT_SECRET: "test-secret",
|
||||
AJ_RECOVERY_MAIL_URL: `http://127.0.0.1:${MAIL_PORT}/mail`,
|
||||
AJ_RECOVERY_MAIL_TOKEN: "test-mail-token",
|
||||
});
|
||||
try {
|
||||
await harness.withServer("sign-in test", HTTP_PORT, GAME_PORT, () => run(mail));
|
||||
}
|
||||
finally {
|
||||
mailServer.close();
|
||||
}
|
||||
};
|
||||
|
||||
main().catch(err => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
+13
-1
@@ -158,6 +158,17 @@ const run = async () => {
|
||||
assert.deepStrictEqual((await b.nextXt("uc")).slice(1), [roomId, String(bobId), "hi & bye", "0"]);
|
||||
b.send(`<msg t='sys'><body action='pubMsg' r='${roomId}'><txt><![CDATA[7%2]]></txt></body></msg>`); // emote: not echoed
|
||||
assert.deepStrictEqual((await a.nextXt("uc")).slice(3), ["7", "2"]);
|
||||
|
||||
// A saved bubble style is acknowledged with every customization field and
|
||||
// travels with the next public line so every patched client renders it.
|
||||
const chatStyle = ["112233", "445566", "ffffff", "abcdef", "85", "flow", "150", "radial", "225", "75", "2", "112233:0;ff0069:45;445566:100"];
|
||||
b.xt("xcs", roomId, ...chatStyle);
|
||||
assert.deepStrictEqual((await b.nextXt("xcs")).slice(2), chatStyle);
|
||||
b.send(`<msg t='sys'><body action='pubMsg' r='${roomId}'><txt><![CDATA[styled%0]]></txt></body></msg>`);
|
||||
const styledPacket = [roomId, String(bobId), "styled", "0", "", chatStyle.join(",")];
|
||||
assert.deepStrictEqual((await a.nextXt("uc")).slice(1), styledPacket);
|
||||
assert.deepStrictEqual((await b.nextXt("uc")).slice(1), styledPacket);
|
||||
|
||||
// Actions are sent to every other player in the room. The sender has
|
||||
// already applied the action locally, so it is not echoed back to them.
|
||||
b.send(`<msg t='sys'><body action='pubMsg' r='${roomId}'><txt><![CDATA[:sitS:%3%m1]]></txt></body></msg>`);
|
||||
@@ -654,7 +665,8 @@ const run = async () => {
|
||||
login_choices: {accountType: 0, isGuide: true, membershipDays: 12, isModerator: "yes"}})).json();
|
||||
assert.strictEqual((await (await fetch(`${BASE}/player`, {headers: {Authorization: `Bearer ${chosen.auth_token}`}})).json()).game_account_type, 0);
|
||||
a.xt("ag", denId, "Erin", 0);
|
||||
assert.deepStrictEqual((await a.untilXt("ag")).slice(5, 7), ["0", "1"]); // account type, guide
|
||||
// account type, guide: asking to be a guide is refused unless the admin made them one
|
||||
assert.deepStrictEqual((await a.untilXt("ag")).slice(5, 7), ["0", "0"]);
|
||||
await postJson(`${BASE}/authenticate`, {username: "Erin", password: "KettlePass05"}); // and back to normal
|
||||
a.xt("ag", denId, "Erin", 0);
|
||||
assert.deepStrictEqual((await a.untilXt("ag")).slice(5, 7), ["2", "0"]);
|
||||
|
||||
@@ -85,6 +85,7 @@ set -- \
|
||||
com.sbi.graphics.LayerAnim LayerAnim.as \
|
||||
com.sbi.graphics.LayerBitmap LayerBitmap.as \
|
||||
ecard.ECard ECard.as \
|
||||
ecard.ECardXtCommManager ECardXtCommManager.as \
|
||||
game.ArtStudioKit ArtStudioKit.as \
|
||||
game.artStudioPainting.ArtStudioPainting ArtStudioPainting.as \
|
||||
game.artStudioGridDrawing.ArtStudioGridDrawing ArtStudioGridDrawing.as \
|
||||
@@ -95,6 +96,17 @@ set -- \
|
||||
avatar.AvatarUtility AvatarUtility.as \
|
||||
item.Item Item.as \
|
||||
loader.DenItemHelper DenItemHelper.as \
|
||||
gui.FeedbackManager FeedbackManager.as \
|
||||
gameRedemption.CodeRedemptionPopup CodeRedemptionPopup.as \
|
||||
playerWall.PlayerWallXtCommManager PlayerWallXtCommManager.as \
|
||||
playerWall.PlayerWallGui PlayerWallGui.as \
|
||||
pet.PetManager PetManager.as \
|
||||
adoptAPet.TierPathPopup TierPathPopup.as \
|
||||
pet.PetBase PetBase.as \
|
||||
game.touchPool.TouchPool TouchPool.as \
|
||||
game.phantomsTreasure.PhantomsTreasure PhantomsTreasure.as \
|
||||
game.microSmoothie.MicroSmoothie MicroSmoothie.as \
|
||||
avatar.AvatarSwitch AvatarSwitch.as \
|
||||
room.DenItemHolder ../tools/decompiled/room/DenItemHolder.as
|
||||
# not in the game: added before the replace (game.ArtStudioKit is Strawberry
|
||||
# Jam's, shared by its two art studio painters; gui.SitForwardAction is the
|
||||
|
||||
+1860
-1726
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,139 @@
|
||||
"use strict";
|
||||
|
||||
// the variants (colours) each den item's art has, into lib/den-variants.json,
|
||||
// which the item giver offers (lib/admin.js). the art says so itself, in
|
||||
// ActionScript: getVersions() returns them, and setVersion(n) shows one.
|
||||
// the server cannot run that, so tools/den-variants.sh reads it once:
|
||||
//
|
||||
// node tools/den-variants.js fetch <folder> every den item's art, as SWFs
|
||||
// (ffdec decompiles <folder>/swf into <folder>/out)
|
||||
// node tools/den-variants.js index <folder> reads <folder>/out
|
||||
//
|
||||
// most items with variants draw each as a frame of their own; some colour
|
||||
// parts of themselves from a table instead (colArray, one row of RGB values
|
||||
// per variant), and for those the table's colours are kept too, as a
|
||||
// preview. items with no variants are left out.
|
||||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const amf3 = require("../lib/amf3.js");
|
||||
const cdn = require("../lib/cdn.js");
|
||||
const defpacks = require("../lib/defpacks.js");
|
||||
|
||||
const OUT = path.join(__dirname, "..", "lib", "den-variants.json");
|
||||
const AT_ONCE = 16;
|
||||
const MAX_VARIANTS = 64;
|
||||
const PREVIEW_COLOURS = 4;
|
||||
|
||||
// DenItem.getIconId: which of an item's pictures the den shows, by its sort category.
|
||||
const iconId = sortCat => ([0, 99, 6, 5].includes(sortCat) ? 1 : sortCat === 1 ? 2 : [2, 3, 4].includes(sortCat) ? 3 : sortCat + 1);
|
||||
|
||||
const fetchAll = async folder => {
|
||||
await defpacks.init();
|
||||
fs.mkdirSync(path.join(folder, "swf"), {recursive: true});
|
||||
const ids = defpacks.denItemIds();
|
||||
let next = 0;
|
||||
let written = 0;
|
||||
const work = async () => {
|
||||
while (next < ids.length) {
|
||||
const id = ids[next++];
|
||||
const def = defpacks.denItemDef(id);
|
||||
const file = await cdn.get(cdn.hashedPath(`items/${((id << 16) | iconId(Number(def.sortCat))) >>> 0}`));
|
||||
try {
|
||||
const wrapped = file && amf3.decode(file);
|
||||
if (wrapped && wrapped.ba) {
|
||||
fs.writeFileSync(path.join(folder, "swf", `${id}.swf`), Buffer.from(wrapped.ba));
|
||||
written++;
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
// not art this can read: left out.
|
||||
}
|
||||
}
|
||||
};
|
||||
await Promise.all(Array.from({length: AT_ONCE}, work));
|
||||
console.log(`${written} of ${ids.length} den items' art written`);
|
||||
};
|
||||
|
||||
const hex = ([r, g, b]) => ((r << 16) | (g << 8) | b).toString(16).padStart(6, "0");
|
||||
|
||||
// one item's decompiled scripts: its variants, and the colour table's first
|
||||
// colours for each when it has one.
|
||||
const readItem = scripts => {
|
||||
let versions = null;
|
||||
for (const text of scripts) {
|
||||
const literal = /function getVersions\(\)\s*:\s*Array\s*\{\s*return \[([\d,\s]*)\];/.exec(text);
|
||||
if (literal) {
|
||||
const list = literal[1].split(",").map(value => Number(value.trim())).filter(Number.isInteger);
|
||||
if (!versions || list.length > versions.length) {
|
||||
versions = list;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!versions || versions.length < 2) {
|
||||
return null;
|
||||
}
|
||||
const entry = {versions: versions.slice(0, MAX_VARIANTS)};
|
||||
const rows = {};
|
||||
for (const text of scripts) {
|
||||
for (const match of text.matchAll(/colArray\[(\d+)\] = (\[\[[\d,\s[\]]*\]\]);/g)) {
|
||||
try {
|
||||
rows[match[1]] = JSON.parse(match[2]).slice(0, PREVIEW_COLOURS).map(hex);
|
||||
}
|
||||
catch (err) {
|
||||
// not a plain table
|
||||
}
|
||||
}
|
||||
}
|
||||
if (entry.versions.every(version => rows[version])) {
|
||||
entry.colours = entry.versions.map(version => rows[version]);
|
||||
}
|
||||
return entry;
|
||||
};
|
||||
|
||||
const scriptsIn = folder => {
|
||||
const found = [];
|
||||
const walk = dir => {
|
||||
for (const name of fs.readdirSync(dir, {withFileTypes: true})) {
|
||||
const full = path.join(dir, name.name);
|
||||
if (name.isDirectory()) {
|
||||
walk(full);
|
||||
}
|
||||
else if (name.name.endsWith(".as")) {
|
||||
found.push(fs.readFileSync(full, "utf8"));
|
||||
}
|
||||
}
|
||||
};
|
||||
walk(folder);
|
||||
return found;
|
||||
};
|
||||
|
||||
const index = folder => {
|
||||
const out = path.join(folder, "out");
|
||||
const result = {};
|
||||
for (const name of fs.readdirSync(out)) {
|
||||
const id = /^(\d+)\.swf$/.exec(name);
|
||||
const entry = id && readItem(scriptsIn(path.join(out, name)));
|
||||
if (entry) {
|
||||
result[id[1]] = entry;
|
||||
}
|
||||
}
|
||||
const sorted = Object.fromEntries(Object.entries(result).sort((a, b) => Number(a[0]) - Number(b[0])));
|
||||
fs.writeFileSync(OUT, `${JSON.stringify(sorted)}\n`);
|
||||
console.log(`${Object.keys(sorted).length} den items with variants, ${Object.values(sorted).filter(entry => entry.colours).length} with colour previews: ${OUT}`);
|
||||
};
|
||||
|
||||
const [command, folder] = process.argv.slice(2);
|
||||
if (command === "fetch" && folder) {
|
||||
fetchAll(folder).then(() => process.exit(0), err => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
else if (command === "index" && folder) {
|
||||
index(folder);
|
||||
}
|
||||
else {
|
||||
console.error("node tools/den-variants.js fetch|index <folder>");
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
# rebuilds lib/den-variants.json: every den item's art fetched (into cache/
|
||||
# too), decompiled by JPEXS (tools/ffdec, needs Java) and read for its
|
||||
# variants. see tools/den-variants.js.
|
||||
#
|
||||
# tools/den-variants.sh [work folder] (default: a new temporary one)
|
||||
set -e
|
||||
cd "$(dirname "$(readlink -f "$0")")/.."
|
||||
work=${1:-$(mktemp -d)}
|
||||
node tools/den-variants.js fetch "$work"
|
||||
java -jar tools/ffdec/ffdec-cli.jar -export script "$work/out" "$work/swf" > "$work/ffdec.log" 2>&1
|
||||
node tools/den-variants.js index "$work"
|
||||
@@ -0,0 +1,93 @@
|
||||
package
|
||||
{
|
||||
import flash.display.Loader;
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.Event;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.filters.ColorMatrixFilter;
|
||||
import flash.geom.Rectangle;
|
||||
import flash.net.URLRequest;
|
||||
import flash.system.ApplicationDomain;
|
||||
import flash.system.LoaderContext;
|
||||
|
||||
// the web item giver's den item preview (public/item-preview.html): one
|
||||
// den item's art, as a den shows it. flashvars: art (its address),
|
||||
// version (the variant) and tint ("rrggbb") with strength (1 to 100), as
|
||||
// DenItemHelper gives them.
|
||||
public class PreviewHost extends MovieClip
|
||||
{
|
||||
private static const MARGIN:Number = 10;
|
||||
|
||||
private var _loader:Loader;
|
||||
|
||||
public function PreviewHost()
|
||||
{
|
||||
super();
|
||||
stage.scaleMode = "noScale";
|
||||
stage.align = "TL";
|
||||
_loader = new Loader();
|
||||
_loader.contentLoaderInfo.addEventListener("complete",onLoaded);
|
||||
_loader.contentLoaderInfo.addEventListener("ioError",onFailed);
|
||||
addChild(_loader);
|
||||
var _loc1_:String = loaderInfo.parameters.art;
|
||||
if(_loc1_)
|
||||
{
|
||||
_loader.load(new URLRequest(_loc1_),new LoaderContext(false,new ApplicationDomain()));
|
||||
}
|
||||
}
|
||||
|
||||
private function onLoaded(param1:Event) : void
|
||||
{
|
||||
var _loc2_:Object = _loader.content;
|
||||
var _loc3_:int = int(loaderInfo.parameters.version);
|
||||
if(_loc2_.hasOwnProperty("setVersion"))
|
||||
{
|
||||
_loc2_.setVersion(_loc3_);
|
||||
}
|
||||
var _loc4_:String = loaderInfo.parameters.tint;
|
||||
if(_loc4_)
|
||||
{
|
||||
_loader.filters = [new ColorMatrixFilter(tintMatrix(uint(parseInt(_loc4_,16)),Math.max(1,Math.min(100,Number(loaderInfo.parameters.strength) || 100)) / 100))];
|
||||
}
|
||||
addEventListener("enterFrame",fit);
|
||||
}
|
||||
|
||||
private function onFailed(param1:IOErrorEvent) : void
|
||||
{
|
||||
}
|
||||
|
||||
// fitted to the stage, centred: kept on as an item may grow as it plays.
|
||||
private function fit(param1:Event) : void
|
||||
{
|
||||
_loader.scaleX = _loader.scaleY = 1;
|
||||
_loader.x = _loader.y = 0;
|
||||
var _loc2_:Rectangle = _loader.getBounds(this);
|
||||
if(_loc2_.width <= 0 || _loc2_.height <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var _loc3_:Number = Math.min((stage.stageWidth - MARGIN * 2) / _loc2_.width,(stage.stageHeight - MARGIN * 2) / _loc2_.height);
|
||||
_loader.scaleX = _loader.scaleY = _loc3_;
|
||||
_loader.x = (stage.stageWidth - _loc2_.width * _loc3_) / 2 - _loc2_.x * _loc3_;
|
||||
_loader.y = (stage.stageHeight - _loc2_.height * _loc3_) / 2 - _loc2_.y * _loc3_;
|
||||
}
|
||||
|
||||
// DenItemHelper.tintMatrix's
|
||||
private static function tintMatrix(param1:uint, param2:Number) : Array
|
||||
{
|
||||
var _loc3_:Array = [(param1 >> 16 & 0xFF) / 255,(param1 >> 8 & 0xFF) / 255,(param1 & 0xFF) / 255];
|
||||
var _loc4_:Number = 0.299 * _loc3_[0] + 0.587 * _loc3_[1] + 0.114 * _loc3_[2];
|
||||
var _loc5_:Number = Math.min(2,1 / Math.max(0.001,_loc4_));
|
||||
var _loc6_:Array = [];
|
||||
var _loc7_:int = 0;
|
||||
while(_loc7_ < 3)
|
||||
{
|
||||
var _loc8_:Number = _loc3_[_loc7_] * _loc5_ * param2;
|
||||
_loc6_.push(0.299 * _loc8_ + (_loc7_ == 0 ? 1 - param2 : 0),0.587 * _loc8_ + (_loc7_ == 1 ? 1 - param2 : 0),0.114 * _loc8_ + (_loc7_ == 2 ? 1 - param2 : 0),0,0);
|
||||
_loc7_++;
|
||||
}
|
||||
_loc6_.push(0,0,0,1,0);
|
||||
return _loc6_;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,450 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><!--
|
||||
WARNING: The structure of this XML is not final.
|
||||
In later versions of FFDec it can be changed.
|
||||
Make sure you use compatible reader/writer based on _xmlExportMajor/_xmlExportMinor keys.
|
||||
--><swf _xmlExportMajor="2" _xmlExportMinor="2" _generator="JPEXS Free Flash Decompiler v.26.3.0" type="SWF" charset="UTF-8" compression="ZLIB" encrypted="false" frameCount="1" frameRate="24.0" gfx="false" hasEndTag="true" version="10">
|
||||
<displayRect type="RECT" Xmax="4000" Xmin="0" Ymax="4000" Ymin="0" nbits="13"/>
|
||||
<tags>
|
||||
<item type="FileAttributesTag" actionScript3="true" forceWriteAsLong="false" hasMetadata="false" noCrossDomainCache="false" reservedA="false" reservedB="0" swfRelativeUrls="false" useDirectBlit="false" useGPU="false" useNetwork="true"/>
|
||||
<item type="SetBackgroundColorTag" forceWriteAsLong="false">
|
||||
<backgroundColor type="RGB" blue="255" green="255" red="255"/>
|
||||
</item>
|
||||
<item type="DoABC2Tag" flags="1" forceWriteAsLong="true" name="">
|
||||
<abc type="ABC">
|
||||
<version type="ABCVersion" major="46" minor="16"/>
|
||||
<constants type="AVM2ConstantPool">
|
||||
<constant_int>
|
||||
<item isNull="true"/>
|
||||
<item>4</item>
|
||||
</constant_int>
|
||||
<constant_uint/>
|
||||
<constant_double>
|
||||
<item isNull="true"/>
|
||||
<item>0.299</item>
|
||||
<item>0.587</item>
|
||||
<item>0.114</item>
|
||||
<item>0.001</item>
|
||||
</constant_double>
|
||||
<constant_decimal/>
|
||||
<constant_float/>
|
||||
<constant_float4/>
|
||||
<constant_string>
|
||||
<item isNull="true"/>
|
||||
<item/>
|
||||
<item>Array</item>
|
||||
<item>void</item>
|
||||
<item>flash.display</item>
|
||||
<item>MovieClip</item>
|
||||
<item>setVersion</item>
|
||||
<item>http://adobe.com/AS3/2006/builtin</item>
|
||||
<item>flash.events</item>
|
||||
<item>flash.filters</item>
|
||||
<item>flash.geom</item>
|
||||
<item>flash.net</item>
|
||||
<item>flash.system</item>
|
||||
<item>flash.display:MovieClip</item>
|
||||
<item>flash.display:Sprite</item>
|
||||
<item>flash.display:DisplayObjectContainer</item>
|
||||
<item>flash.display:InteractiveObject</item>
|
||||
<item>flash.display:DisplayObject</item>
|
||||
<item>flash.events:EventDispatcher</item>
|
||||
<item>Object</item>
|
||||
<item>EventDispatcher</item>
|
||||
<item>DisplayObject</item>
|
||||
<item>InteractiveObject</item>
|
||||
<item>DisplayObjectContainer</item>
|
||||
<item>Sprite</item>
|
||||
<item>PreviewHost</item>
|
||||
<item>_loader</item>
|
||||
<item>onLoaded</item>
|
||||
<item>onFailed</item>
|
||||
<item>fit</item>
|
||||
<item>MARGIN</item>
|
||||
<item>tintMatrix</item>
|
||||
<item>Loader</item>
|
||||
<item>PreviewHost/private/onLoaded</item>
|
||||
<item>Event</item>
|
||||
<item>PreviewHost/private/onFailed</item>
|
||||
<item>IOErrorEvent</item>
|
||||
<item>PreviewHost/private/fit</item>
|
||||
<item>loaderInfo</item>
|
||||
<item>uint</item>
|
||||
<item>parseInt</item>
|
||||
<item>Math</item>
|
||||
<item>Number</item>
|
||||
<item>addEventListener</item>
|
||||
<item>content</item>
|
||||
<item>parameters</item>
|
||||
<item>version</item>
|
||||
<item>hasOwnProperty</item>
|
||||
<item>tint</item>
|
||||
<item>filters</item>
|
||||
<item>ColorMatrixFilter</item>
|
||||
<item>max</item>
|
||||
<item>min</item>
|
||||
<item>strength</item>
|
||||
<item>enterFrame</item>
|
||||
<item>param1</item>
|
||||
<item>_loc2_</item>
|
||||
<item>_loc3_</item>
|
||||
<item>_loc4_</item>
|
||||
<item>stage</item>
|
||||
<item>scaleX</item>
|
||||
<item>scaleY</item>
|
||||
<item>x</item>
|
||||
<item>y</item>
|
||||
<item>Rectangle</item>
|
||||
<item>getBounds</item>
|
||||
<item>width</item>
|
||||
<item>height</item>
|
||||
<item>stageWidth</item>
|
||||
<item>stageHeight</item>
|
||||
<item>PreviewHost/private/tintMatrix</item>
|
||||
<item>push</item>
|
||||
<item>param2</item>
|
||||
<item>_loc5_</item>
|
||||
<item>_loc6_</item>
|
||||
<item>_loc7_</item>
|
||||
<item>_loc8_</item>
|
||||
<item>PreviewHost/PreviewHost</item>
|
||||
<item>addChild</item>
|
||||
<item>scaleMode</item>
|
||||
<item>noScale</item>
|
||||
<item>align</item>
|
||||
<item>TL</item>
|
||||
<item>contentLoaderInfo</item>
|
||||
<item>complete</item>
|
||||
<item>ioError</item>
|
||||
<item>art</item>
|
||||
<item>load</item>
|
||||
<item>URLRequest</item>
|
||||
<item>LoaderContext</item>
|
||||
<item>ApplicationDomain</item>
|
||||
<item>_loc1_</item>
|
||||
<item>PreviewUnused</item>
|
||||
<item>PreviewHost.as$0</item>
|
||||
</constant_string>
|
||||
<constant_namespace>
|
||||
<item isNull="true"/>
|
||||
<item type="Namespace" kind="22" name_index="1"/>
|
||||
<item type="Namespace" kind="22" name_index="4"/>
|
||||
<item type="Namespace" kind="8" name_index="7"/>
|
||||
<item type="Namespace" kind="22" name_index="8"/>
|
||||
<item type="Namespace" kind="22" name_index="9"/>
|
||||
<item type="Namespace" kind="22" name_index="10"/>
|
||||
<item type="Namespace" kind="22" name_index="11"/>
|
||||
<item type="Namespace" kind="22" name_index="12"/>
|
||||
<item type="Namespace" kind="26" name_index="13"/>
|
||||
<item type="Namespace" kind="26" name_index="14"/>
|
||||
<item type="Namespace" kind="26" name_index="15"/>
|
||||
<item type="Namespace" kind="26" name_index="16"/>
|
||||
<item type="Namespace" kind="26" name_index="17"/>
|
||||
<item type="Namespace" kind="26" name_index="18"/>
|
||||
<item type="Namespace" kind="23" name_index="1"/>
|
||||
<item type="Namespace" kind="5" name_index="25"/>
|
||||
<item type="Namespace" kind="24" name_index="25"/>
|
||||
<item type="Namespace" kind="26" name_index="25"/>
|
||||
<item type="Namespace" kind="24" name_index="92"/>
|
||||
<item type="Namespace" kind="5" name_index="93"/>
|
||||
</constant_namespace>
|
||||
<constant_namespace_set>
|
||||
<item isNull="true"/>
|
||||
<item type="NamespaceSet">
|
||||
<namespaces>
|
||||
<item>1</item>
|
||||
</namespaces>
|
||||
</item>
|
||||
<item type="NamespaceSet">
|
||||
<namespaces>
|
||||
<item>1</item>
|
||||
<item>3</item>
|
||||
<item>15</item>
|
||||
<item>9</item>
|
||||
<item>10</item>
|
||||
<item>11</item>
|
||||
<item>12</item>
|
||||
<item>13</item>
|
||||
<item>14</item>
|
||||
<item>16</item>
|
||||
<item>17</item>
|
||||
<item>18</item>
|
||||
<item>20</item>
|
||||
</namespaces>
|
||||
</item>
|
||||
</constant_namespace_set>
|
||||
<constant_multiname>
|
||||
<item isNull="true"/>
|
||||
<item type="Multiname" kind="7" name_index="2" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="3" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="5" namespace_index="2" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="19" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="20" namespace_index="4" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="21" namespace_index="2" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="22" namespace_index="2" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="23" namespace_index="2" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="24" namespace_index="2" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="25" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="26" namespace_index="16" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="27" namespace_index="16" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="28" namespace_index="16" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="29" namespace_index="16" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="30" namespace_index="16" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="31" namespace_index="16" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="32" namespace_index="2" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="34" namespace_index="4" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="36" namespace_index="4" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="38" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="39" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="40" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="41" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="42" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="43" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="44" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="45" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="47" namespace_index="3" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="49" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="50" namespace_index="5" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="51" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="52" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="59" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="60" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="61" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="62" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="63" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="64" namespace_index="6" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="65" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="66" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="67" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="68" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="69" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="71" namespace_index="3" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="78" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="79" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="81" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="83" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="87" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="88" namespace_index="7" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="89" namespace_index="8" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="90" namespace_index="8" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="7" name_index="92" namespace_index="1" namespace_set_index="0" qname_index="0"/>
|
||||
<item type="Multiname" kind="9" name_index="92" namespace_index="0" namespace_set_index="1" qname_index="0"/>
|
||||
<item type="Multiname" kind="9" name_index="46" namespace_index="0" namespace_set_index="2" qname_index="0"/>
|
||||
<item type="Multiname" kind="9" name_index="6" namespace_index="0" namespace_set_index="2" qname_index="0"/>
|
||||
<item type="Multiname" kind="9" name_index="48" namespace_index="0" namespace_set_index="2" qname_index="0"/>
|
||||
<item type="Multiname" kind="9" name_index="53" namespace_index="0" namespace_set_index="2" qname_index="0"/>
|
||||
<item type="Multiname" kind="27" name_index="0" namespace_index="0" namespace_set_index="2" qname_index="0"/>
|
||||
<item type="Multiname" kind="9" name_index="86" namespace_index="0" namespace_set_index="2" qname_index="0"/>
|
||||
</constant_multiname>
|
||||
</constants>
|
||||
<method_info>
|
||||
<item type="MethodInfo" flags="0" name_index="1" ret_type="0">
|
||||
<param_types/>
|
||||
<optional/>
|
||||
<paramNames/>
|
||||
</item>
|
||||
<item type="MethodInfo" flags="0" name_index="33" ret_type="2">
|
||||
<param_types>
|
||||
<item>18</item>
|
||||
</param_types>
|
||||
<optional/>
|
||||
<paramNames>
|
||||
<item>0</item>
|
||||
</paramNames>
|
||||
</item>
|
||||
<item type="MethodInfo" flags="0" name_index="35" ret_type="2">
|
||||
<param_types>
|
||||
<item>19</item>
|
||||
</param_types>
|
||||
<optional/>
|
||||
<paramNames>
|
||||
<item>0</item>
|
||||
</paramNames>
|
||||
</item>
|
||||
<item type="MethodInfo" flags="0" name_index="37" ret_type="2">
|
||||
<param_types>
|
||||
<item>18</item>
|
||||
</param_types>
|
||||
<optional/>
|
||||
<paramNames>
|
||||
<item>0</item>
|
||||
</paramNames>
|
||||
</item>
|
||||
<item type="MethodInfo" flags="0" name_index="70" ret_type="1">
|
||||
<param_types>
|
||||
<item>21</item>
|
||||
<item>24</item>
|
||||
</param_types>
|
||||
<optional/>
|
||||
<paramNames>
|
||||
<item>0</item>
|
||||
<item>0</item>
|
||||
</paramNames>
|
||||
</item>
|
||||
<item type="MethodInfo" flags="0" name_index="77" ret_type="0">
|
||||
<param_types/>
|
||||
<optional/>
|
||||
<paramNames/>
|
||||
</item>
|
||||
<item type="MethodInfo" flags="0" name_index="1" ret_type="0">
|
||||
<param_types/>
|
||||
<optional/>
|
||||
<paramNames/>
|
||||
</item>
|
||||
<item type="MethodInfo" flags="0" name_index="1" ret_type="0">
|
||||
<param_types/>
|
||||
<optional/>
|
||||
<paramNames/>
|
||||
</item>
|
||||
<item type="MethodInfo" flags="0" name_index="0" ret_type="0">
|
||||
<param_types/>
|
||||
<optional/>
|
||||
<paramNames/>
|
||||
</item>
|
||||
<item type="MethodInfo" flags="0" name_index="1" ret_type="0">
|
||||
<param_types/>
|
||||
<optional/>
|
||||
<paramNames/>
|
||||
</item>
|
||||
</method_info>
|
||||
<metadata_info/>
|
||||
<instance_info>
|
||||
<item type="InstanceInfo" flags="9" iinit_index="5" name_index="10" protectedNS="17" super_index="3">
|
||||
<interfaces/>
|
||||
<instance_traits type="Traits">
|
||||
<traits>
|
||||
<item type="TraitSlotConst" bytes="0b00001100" deleted="false" fileOffset="1461" kindFlags="0" kindType="0" name_index="11" slot_id="0" type_index="17" value_index="0" value_kind="0">
|
||||
<metadata/>
|
||||
</item>
|
||||
<item type="TraitMethodGetterSetter" bytes="0c010001" deleted="false" disp_id="0" fileOffset="1466" kindFlags="0" kindType="1" method_info="1" name_index="12">
|
||||
<metadata/>
|
||||
</item>
|
||||
<item type="TraitMethodGetterSetter" bytes="0d010002" deleted="false" disp_id="0" fileOffset="1470" kindFlags="0" kindType="1" method_info="2" name_index="13">
|
||||
<metadata/>
|
||||
</item>
|
||||
<item type="TraitMethodGetterSetter" bytes="0e010003" deleted="false" disp_id="0" fileOffset="1474" kindFlags="0" kindType="1" method_info="3" name_index="14">
|
||||
<metadata/>
|
||||
</item>
|
||||
</traits>
|
||||
</instance_traits>
|
||||
</item>
|
||||
<item type="InstanceInfo" flags="9" iinit_index="8" name_index="53" protectedNS="19" super_index="4">
|
||||
<interfaces/>
|
||||
<instance_traits type="Traits">
|
||||
<traits/>
|
||||
</instance_traits>
|
||||
</item>
|
||||
</instance_info>
|
||||
<class_info>
|
||||
<item type="ClassInfo" cinit_index="6">
|
||||
<static_traits type="Traits">
|
||||
<traits>
|
||||
<item type="TraitSlotConst" bytes="0f0601180103" deleted="false" fileOffset="1487" kindFlags="0" kindType="6" name_index="15" slot_id="1" type_index="24" value_index="1" value_kind="3">
|
||||
<metadata/>
|
||||
</item>
|
||||
<item type="TraitMethodGetterSetter" bytes="10110304" deleted="false" disp_id="3" fileOffset="1493" kindFlags="1" kindType="1" method_info="4" name_index="16">
|
||||
<metadata/>
|
||||
</item>
|
||||
</traits>
|
||||
</static_traits>
|
||||
</item>
|
||||
<item type="ClassInfo" cinit_index="9">
|
||||
<static_traits type="Traits">
|
||||
<traits/>
|
||||
</static_traits>
|
||||
</item>
|
||||
</class_info>
|
||||
<script_info>
|
||||
<item type="ScriptInfo" init_index="0">
|
||||
<traits type="Traits">
|
||||
<traits>
|
||||
<item type="TraitClass" bytes="0a040100" class_info="0" deleted="false" fileOffset="1502" kindFlags="0" kindType="4" name_index="10" slot_id="1">
|
||||
<metadata/>
|
||||
</item>
|
||||
</traits>
|
||||
</traits>
|
||||
</item>
|
||||
<item type="ScriptInfo" init_index="7">
|
||||
<traits type="Traits">
|
||||
<traits>
|
||||
<item type="TraitClass" bytes="35040101" class_info="1" deleted="false" fileOffset="1508" kindFlags="0" kindType="4" name_index="53" slot_id="1">
|
||||
<metadata/>
|
||||
</item>
|
||||
</traits>
|
||||
</traits>
|
||||
</item>
|
||||
</script_info>
|
||||
<bodies>
|
||||
<item type="MethodBody" codeBytes="d0306500600430600530600630600730600830600930600330600358001d1d1d1d1d1d1d680a47" init_scope_depth="1" max_regs="1" max_scope_depth="9" max_stack="2" method_info="0">
|
||||
<exceptions/>
|
||||
<traits type="Traits">
|
||||
<traits/>
|
||||
</traits>
|
||||
</item>
|
||||
<item type="MethodBody" codeBytes="d030ef01370000ef01380129ef0139022aef013a032f600b661a8004d66014661b66377373d7d22c06461c0112050000d2d34f38016014661b66398563046204123d0000600b5d1e5d105d16620424104616027460172401601724646014661b663a75752a761104000029246475462002461f022464a34610024a1e015601611d5d192c36600e4f190247" init_scope_depth="10" max_regs="5" max_scope_depth="11" max_stack="10" method_info="1">
|
||||
<exceptions/>
|
||||
<traits type="Traits">
|
||||
<traits/>
|
||||
</traits>
|
||||
</item>
|
||||
<item type="MethodBody" codeBytes="d030ef0137000047" init_scope_depth="10" max_regs="2" max_scope_depth="11" max_stack="1" method_info="2">
|
||||
<exceptions/>
|
||||
<traits type="Traits">
|
||||
<traits/>
|
||||
</traits>
|
||||
</item>
|
||||
<item type="MethodBody" codeBytes="d030ef01370000ef01380140ef01390245600b600b24012a63046123620408046122600b600b24002a63046125620408046124600bd04627018026d6d266282400ae2a1107000029d266292400ae120100004760176021662a600f2402a2a1d26628a36021662b600f2402a2a1d26629a346200275d7600b600bd32a63046123620408046122600b6021662ad26628d3a2a12402a3d26624d3a2a16124600b6021662bd26629d3a2a12402a3d26625d3a2a1612547" init_scope_depth="10" max_regs="5" max_scope_depth="11" max_stack="5" method_info="3">
|
||||
<exceptions/>
|
||||
<traits type="Traits">
|
||||
<traits/>
|
||||
</traits>
|
||||
</item>
|
||||
<item type="MethodBody" codeBytes="d030ef01370000ef01480100ef0139024eef013a034fef01490450ef014a0551ef014b0652ef014c0755d12410a625ff01a825ff01a3d12408a625ff01a825ff01a3d125ff01a825ff01a356038001d72f01d32400663ba22f02d32401663ba2a02f03d32402663ba2a075630460172402240160172f046204461f02a346200275630556008001630624007363071061000009d36207663b6205a2d2a275630862062f016208a262072400140800002401d2a1100200002400a02f026208a262072401140800002401d2a1100200002400a02f036208a262072402140800002401d2a1100200002400a0240024004f2c05c207620724031597ffff6206240024002400240124004f2c05620648" init_scope_depth="9" max_regs="9" max_scope_depth="10" max_stack="6" method_info="4">
|
||||
<exceptions/>
|
||||
<traits type="Traits">
|
||||
<traits/>
|
||||
</traits>
|
||||
</item>
|
||||
<item type="MethodBody" codeBytes="d030ef015b0020d0490060212c50612e60212c52612f5e0b5d114a1100610b600b66302c54600c4f1902600b66302c55600d4f19025d2d600b4f2d016014661b663c85d5d112160000600b5d32d14a32015d33275d344a34004a33024f310247" init_scope_depth="10" max_regs="2" max_scope_depth="11" max_stack="5" method_info="5">
|
||||
<exceptions/>
|
||||
<traits type="Traits">
|
||||
<traits/>
|
||||
</traits>
|
||||
</item>
|
||||
<item type="MethodBody" codeBytes="d0305e0f2404680f47" init_scope_depth="9" max_regs="1" max_scope_depth="10" max_stack="2" method_info="6">
|
||||
<exceptions/>
|
||||
<traits type="Traits">
|
||||
<traits/>
|
||||
</traits>
|
||||
</item>
|
||||
<item type="MethodBody" codeBytes="d0305d36600430600458011d683547" init_scope_depth="1" max_regs="1" max_scope_depth="3" max_stack="2" method_info="7">
|
||||
<exceptions/>
|
||||
<traits type="Traits">
|
||||
<traits/>
|
||||
</traits>
|
||||
</item>
|
||||
<item type="MethodBody" codeBytes="d030d0490047" init_scope_depth="4" max_regs="1" max_scope_depth="5" max_stack="1" method_info="8">
|
||||
<exceptions/>
|
||||
<traits type="Traits">
|
||||
<traits/>
|
||||
</traits>
|
||||
</item>
|
||||
<item type="MethodBody" codeBytes="d03047" init_scope_depth="3" max_regs="1" max_scope_depth="4" max_stack="1" method_info="9">
|
||||
<exceptions/>
|
||||
<traits type="Traits">
|
||||
<traits/>
|
||||
</traits>
|
||||
</item>
|
||||
</bodies>
|
||||
</abc>
|
||||
</item>
|
||||
<item type="SymbolClassTag" forceWriteAsLong="true">
|
||||
<tags>
|
||||
<item>0</item>
|
||||
</tags>
|
||||
<names>
|
||||
<item>PreviewHost</item>
|
||||
</names>
|
||||
</item>
|
||||
<item type="ShowFrameTag" forceWriteAsLong="false"/>
|
||||
</tags>
|
||||
</swf>
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
# rebuilds public/item-preview.swf, the web item giver's den item preview
|
||||
# (public/item-preview.html plays it with Ruffle): PreviewHost.as compiled by
|
||||
# JPEXS (tools/ffdec, needs Java) into base.xml, a SWF of one frame holding
|
||||
# only code. JPEXS can only compile a class over one already there, so
|
||||
# base.xml has a PreviewHost (and an empty PreviewUnused, left from making it).
|
||||
#
|
||||
# tools/preview-host/build.sh [output.swf] (default: public/item-preview.swf)
|
||||
set -e
|
||||
cd "$(dirname "$(readlink -f "$0")")/../.."
|
||||
out=${1:-public/item-preview.swf}
|
||||
work=$(mktemp -d)
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
ffdec="java -jar tools/ffdec/ffdec-cli.jar"
|
||||
mkdir "$work/src"
|
||||
cp tools/preview-host/PreviewHost.as "$work/src/"
|
||||
$ffdec -xml2swf tools/preview-host/base.xml "$work/base.swf" > "$work/log" 2>&1
|
||||
$ffdec -importScript "$work/base.swf" "$work/host.swf" "$work/src" >> "$work/log" 2>&1
|
||||
$ffdec -abcclean "$work/host.swf" "$out" >> "$work/log" 2>&1 || { cat "$work/log"; exit 1; }
|
||||
echo "$out: $(wc -c < "$out") bytes"
|
||||
Reference in new issue
Block a user