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`.
|
// fields stored in their own columns rather than in `state`.
|
||||||
const COLUMN_FIELDS = ["id", "username", "salt", "hash", "createdAt"];
|
const COLUMN_FIELDS = ["id", "username", "salt", "hash", "createdAt"];
|
||||||
// how the game treats the account this session; set again at every login.
|
// 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 DEFAULT_MEMBERSHIP_DAYS = 9999;
|
||||||
const MAX_ACCOUNT_TYPE = 5;
|
const MAX_ACCOUNT_TYPE = 5;
|
||||||
const MEMBERSHIP_TYPES = [0, 2]; // non-member, member
|
const MEMBERSHIP_TYPES = [0, 2]; // non-member, member
|
||||||
@@ -302,13 +302,17 @@ const MAX_START_ROOM = 80;
|
|||||||
function setLoginChoices(account, choices) {
|
function setLoginChoices(account, choices) {
|
||||||
const asked = config.loginChoices && choices && typeof choices === "object" ? choices : {};
|
const asked = config.loginChoices && choices && typeof choices === "object" ? choices : {};
|
||||||
const whole = (value, max) => Number.isInteger(value) && value >= 0 && value <= max;
|
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
|
// member or not is the player's own choice on any server; the rest only
|
||||||
// server; the rest only with config.loginChoices: another account type
|
// with config.loginChoices: another account type shows to everyone.
|
||||||
// shows to everyone.
|
|
||||||
const own = choices && typeof choices === "object" ? choices : {};
|
const own = choices && typeof choices === "object" ? choices : {};
|
||||||
const type = MEMBERSHIP_TYPES.includes(own.accountType) ? own.accountType : asked.accountType;
|
const type = MEMBERSHIP_TYPES.includes(own.accountType) ? own.accountType : asked.accountType;
|
||||||
account.accountType = whole(type, MAX_ACCOUNT_TYPE) ? type : config.defaultAccountType;
|
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.isModerator = asked.isModerator === true;
|
||||||
account.membershipDays = whole(asked.membershipDays, MAX_MEMBERSHIP_DAYS) ? asked.membershipDays : DEFAULT_MEMBERSHIP_DAYS;
|
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
|
// 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),
|
twoStep: totp.isOn(account),
|
||||||
discord: account.discord,
|
discord: account.discord,
|
||||||
adminDashboardAccess: Boolean(account.adminDashboardAccess),
|
adminDashboardAccess: Boolean(account.adminDashboardAccess),
|
||||||
|
guide: account.guideGiven === true,
|
||||||
bio: account.bio,
|
bio: account.bio,
|
||||||
badges: account.badges,
|
badges: account.badges,
|
||||||
featuresOff: accounts.FEATURES.filter(name => !accounts.featureOn(account, name)),
|
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"}`);
|
`+${(account.permGrants || []).join(",") || "none"} -${(account.permDenies || []).join(",") || "none"}`);
|
||||||
return {ok: `${name}'s permissions are saved.`};
|
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": {
|
case "adminDashboardAccess": {
|
||||||
const on = body.on === true;
|
const on = body.on === true;
|
||||||
if (on && !account.discordId) {
|
if (on && !account.discordId) {
|
||||||
|
|||||||
+9
-3
@@ -459,11 +459,14 @@ const sendAvatarCreate = (to, target) => {
|
|||||||
avatar.questLevel || 0,
|
avatar.questLevel || 0,
|
||||||
1, // userNameModeratedFlag
|
1, // userNameModeratedFlag
|
||||||
lastSeenField(account, Boolean(findOnline(account.username))), // daysSinceLastLogin: see lib/player.js
|
lastSeenField(account, Boolean(findOnline(account.username))), // daysSinceLastLogin: see lib/player.js
|
||||||
// optional-field flags: bit 0 accountType, bit 1 nameBarData, bit 2 pet
|
// optional-field flags: bit 0 accountType, bit 1 nameBarData, bit 2 pet,
|
||||||
pet ? 7 : 3,
|
// 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.accountType,
|
||||||
account.nameBarData,
|
account.nameBarData,
|
||||||
...(pet ? petFields(pet) : []));
|
...(pet ? petFields(pet) : []),
|
||||||
|
...(account.isGuide ? [0, 1] : []));
|
||||||
sendItemList(to, target, false);
|
sendItemList(to, target, false);
|
||||||
disguises.show(to, target);
|
disguises.show(to, target);
|
||||||
if (target.invisible) {
|
if (target.invisible) {
|
||||||
@@ -692,6 +695,9 @@ const handlers = {
|
|||||||
if (motd) {
|
if (motd) {
|
||||||
tell(session, 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);
|
buddies.greet(session);
|
||||||
minigames.greet(session);
|
minigames.greet(session);
|
||||||
moderation.greet(session);
|
moderation.greet(session);
|
||||||
|
|||||||
@@ -526,6 +526,8 @@
|
|||||||
<h3>Badges</h3>
|
<h3>Badges</h3>
|
||||||
<div class="buttons" id="badge-boxes"></div>
|
<div class="buttons" id="badge-boxes"></div>
|
||||||
<div class="row" style="margin-top:8px"><button type="button" data-action="badges">Set</button></div>
|
<div class="row" style="margin-top:8px"><button type="button" data-action="badges">Set</button></div>
|
||||||
|
<div class="row" style="margin-top:8px" title="A guide's name tag and chat bubble, seen by everyone; from their next login">
|
||||||
|
<button type="button" data-action="guide" id="guide-toggle"></button></div>
|
||||||
<div class="row" style="margin-top:8px" title="Players link their Discord themselves, on the account page">
|
<div class="row" style="margin-top:8px" title="Players link their Discord themselves, on the account page">
|
||||||
<span class="hint" id="discord-name"></span>
|
<span class="hint" id="discord-name"></span>
|
||||||
<button type="button" data-action="discord">Unlink Discord</button></div>
|
<button type="button" data-action="discord">Unlink Discord</button></div>
|
||||||
@@ -1527,6 +1529,7 @@
|
|||||||
label.append(box, ` ${badge.label}`);
|
label.append(box, ` ${badge.label}`);
|
||||||
return label;
|
return label;
|
||||||
}));
|
}));
|
||||||
|
$("guide-toggle").textContent = current && current.guide ? "Remove guide" : "Make guide";
|
||||||
$("discord-name").textContent = current && current.discord ? `Discord: ${current.discord}` : "No Discord linked";
|
$("discord-name").textContent = current && current.discord ? `Discord: ${current.discord}` : "No Discord linked";
|
||||||
$("admin-dashboard-access").textContent = current && current.adminDashboardAccess ? "Remove Discord dashboard access" : "Allow Discord dashboard access";
|
$("admin-dashboard-access").textContent = current && current.adminDashboardAccess ? "Remove Discord dashboard access" : "Allow Discord dashboard access";
|
||||||
$("admin-dashboard-access").disabled = !current || (!current.discord && !current.adminDashboardAccess);
|
$("admin-dashboard-access").disabled = !current || (!current.discord && !current.adminDashboardAccess);
|
||||||
@@ -1716,6 +1719,7 @@
|
|||||||
case "role": return {role: $("role-select").value};
|
case "role": return {role: $("role-select").value};
|
||||||
case "permissions": return permissionChoices();
|
case "permissions": return permissionChoices();
|
||||||
case "adminDashboardAccess": return {on: !(current || {}).adminDashboardAccess};
|
case "adminDashboardAccess": return {on: !(current || {}).adminDashboardAccess};
|
||||||
|
case "guide": return {on: !(current || {}).guide};
|
||||||
case "message": return {text: $("message-text").value};
|
case "message": return {text: $("message-text").value};
|
||||||
case "gems": return {amount: numberFrom("gems-amount")};
|
case "gems": return {amount: numberFrom("gems-amount")};
|
||||||
case "gift": return giftBody();
|
case "gift": return giftBody();
|
||||||
|
|||||||
Reference in new issue
Block a user