mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 01:27:51 -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
@@ -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`
|
||||
@@ -314,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 => {
|
||||
@@ -331,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
|
||||
@@ -1112,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 || ""));
|
||||
|
||||
Reference in new issue
Block a user