mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-18 17:27:50 -05:00
feat(guide): guides only by the admin, and seen by everyone
The login's Guide option made a player a guide on their own screen only: the room's avatar packet never said so, so everyone else drew a plain player. "ac" now sends the guide field (bit 4, after a blend colour of 0), which gives the guide's name tag and chat bubble on every client. Guide is now given in the admin panel (Make guide / Remove guide, logged). Asked for at login by anyone else, it is refused, with a plain message on arrival. A guide's custom client can still leave it off; the official launcher asks nothing, and a guide shows as one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
da9f2fd5a6
commit
a860a67626
4 files changed
+32
-8
No files matched your search
+9
-5
@@ -46,7 +46,7 @@ const SCHEMA = `
|
||||
// fields stored in their own columns rather than in `state`.
|
||||
const COLUMN_FIELDS = ["id", "username", "salt", "hash", "createdAt"];
|
||||
// how the game treats the account this session; set again at every login.
|
||||
const SESSION_FIELDS = ["accountType", "isGuide", "isModerator", "membershipDays", "startInDen", "startRoom"];
|
||||
const SESSION_FIELDS = ["accountType", "isGuide", "guideRefused", "isModerator", "membershipDays", "startInDen", "startRoom"];
|
||||
const DEFAULT_MEMBERSHIP_DAYS = 9999;
|
||||
const MAX_ACCOUNT_TYPE = 5;
|
||||
const MEMBERSHIP_TYPES = [0, 2]; // non-member, member
|
||||
@@ -302,13 +302,17 @@ const MAX_START_ROOM = 80;
|
||||
function setLoginChoices(account, choices) {
|
||||
const asked = config.loginChoices && choices && typeof choices === "object" ? choices : {};
|
||||
const whole = (value, max) => Number.isInteger(value) && value >= 0 && value <= max;
|
||||
// member or not, and guide or not, are the player's own choice on any
|
||||
// server; the rest only with config.loginChoices: another account type
|
||||
// shows to everyone.
|
||||
// member or not is the player's own choice on any server; the rest only
|
||||
// with config.loginChoices: another account type shows to everyone.
|
||||
const own = choices && typeof choices === "object" ? choices : {};
|
||||
const type = MEMBERSHIP_TYPES.includes(own.accountType) ? own.accountType : asked.accountType;
|
||||
account.accountType = whole(type, MAX_ACCOUNT_TYPE) ? type : config.defaultAccountType;
|
||||
account.isGuide = own.isGuide === true;
|
||||
// guide (the name tag, the chat bubble, what others see) only for an
|
||||
// account the admin made one (lib/panel.js); asked for without that, it is
|
||||
// refused. a guide's own client may leave it off; the official launcher
|
||||
// asks nothing, and a guide is one.
|
||||
account.isGuide = account.guideGiven === true && (choices && typeof choices === "object" ? own.isGuide === true : true);
|
||||
account.guideRefused = own.isGuide === true && account.guideGiven !== true;
|
||||
account.isModerator = asked.isModerator === true;
|
||||
account.membershipDays = whole(asked.membershipDays, MAX_MEMBERSHIP_DAYS) ? asked.membershipDays : DEFAULT_MEMBERSHIP_DAYS;
|
||||
// where to start is the player's to say on any server: their own den in
|
||||
|
||||
@@ -149,6 +149,7 @@ const accountRow = (account, playing) => {
|
||||
twoStep: totp.isOn(account),
|
||||
discord: account.discord,
|
||||
adminDashboardAccess: Boolean(account.adminDashboardAccess),
|
||||
guide: account.guideGiven === true,
|
||||
bio: account.bio,
|
||||
badges: account.badges,
|
||||
featuresOff: accounts.FEATURES.filter(name => !accounts.featureOn(account, name)),
|
||||
@@ -534,6 +535,15 @@ const act = (account, body) => {
|
||||
`+${(account.permGrants || []).join(",") || "none"} -${(account.permDenies || []).join(",") || "none"}`);
|
||||
return {ok: `${name}'s permissions are saved.`};
|
||||
}
|
||||
// guide: lets the player log in as one (lib/accounts.js setLoginChoices).
|
||||
// it shows from their next login.
|
||||
case "guide": {
|
||||
const on = body.on === true;
|
||||
account.guideGiven = on;
|
||||
accounts.save(account);
|
||||
modlog.record("admin", on ? "made a guide" : "no longer a guide", account.username, "");
|
||||
return {ok: on ? `${name} is a guide from their next login.` : `${name} is no longer a guide from their next login.`};
|
||||
}
|
||||
case "adminDashboardAccess": {
|
||||
const on = body.on === true;
|
||||
if (on && !account.discordId) {
|
||||
|
||||
+9
-3
@@ -459,11 +459,14 @@ const sendAvatarCreate = (to, target) => {
|
||||
avatar.questLevel || 0,
|
||||
1, // userNameModeratedFlag
|
||||
lastSeenField(account, Boolean(findOnline(account.username))), // daysSinceLastLogin: see lib/player.js
|
||||
// optional-field flags: bit 0 accountType, bit 1 nameBarData, bit 2 pet
|
||||
pet ? 7 : 3,
|
||||
// optional-field flags: bit 0 accountType, bit 1 nameBarData, bit 2 pet,
|
||||
// bit 3 a blend colour (none: 0), bit 4 guide (the name tag and bubble
|
||||
// every client draws for a guide)
|
||||
3 | (pet ? 4 : 0) | (account.isGuide ? 24 : 0),
|
||||
account.accountType,
|
||||
account.nameBarData,
|
||||
...(pet ? petFields(pet) : []));
|
||||
...(pet ? petFields(pet) : []),
|
||||
...(account.isGuide ? [0, 1] : []));
|
||||
sendItemList(to, target, false);
|
||||
disguises.show(to, target);
|
||||
if (target.invisible) {
|
||||
@@ -692,6 +695,9 @@ const handlers = {
|
||||
if (motd) {
|
||||
tell(session, motd);
|
||||
}
|
||||
if (session.account.guideRefused) {
|
||||
session.sendXt("xtl", -1, "Guide is only for players the Burrow team has made guides.");
|
||||
}
|
||||
buddies.greet(session);
|
||||
minigames.greet(session);
|
||||
moderation.greet(session);
|
||||
|
||||
Reference in new issue
Block a user