mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-18 17:27:50 -05:00
feat: redemption codes, world count, den visitor count and more fixes
- codes made in the admin panel (Messages) give an item, gems or diamonds through the game's Redeem Code window, which was never answered; its "need help?" says what codes are here - the number of worlds is set in the admin panel (Debug), live - a den's owner is told how many are in it: the HUD's count and doorbell - the map counts the player's buddies in each land of their world - gifts whose item no longer exists, or with a nonsense amount, are no gift at all, rather than a window that will not close - custom item pictures are 256 pixels and 100 KB at most - the account page's buddies and den visitors fold away - shops no longer count down "X days left"
This commit is contained in:
1 parent
15f321fb00
commit
7de41ceed5
14 files changed
+707
-27
No files matched your search
+100
-4
@@ -20,6 +20,7 @@ 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");
|
||||
@@ -181,6 +182,7 @@ 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);
|
||||
@@ -242,6 +244,7 @@ const watchers = session => others(session).filter(other => sees(other, session)
|
||||
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
|
||||
@@ -1121,6 +1124,42 @@ const handlers = {
|
||||
}
|
||||
},
|
||||
|
||||
// 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
|
||||
@@ -1206,11 +1245,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]
|
||||
@@ -1453,6 +1509,19 @@ Object.assign(handlers, avatarHandlers(context), itemHandlers(context), pets.han
|
||||
parties.handlers, ecards.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) {
|
||||
@@ -1475,6 +1544,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
|
||||
@@ -1647,6 +1717,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);
|
||||
@@ -2246,6 +2317,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.
|
||||
|
||||
Reference in new issue
Block a user