diff --git a/lib/accounts.js b/lib/accounts.js index fe501e2..48f7480 100644 --- a/lib/accounts.js +++ b/lib/accounts.js @@ -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 diff --git a/lib/panel.js b/lib/panel.js index f476813..1d17591 100644 --- a/lib/panel.js +++ b/lib/panel.js @@ -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) { diff --git a/lib/world.js b/lib/world.js index ca8cbdf..8c68593 100644 --- a/lib/world.js +++ b/lib/world.js @@ -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); diff --git a/public/admin.html b/public/admin.html index 714ce8b..69992ef 100644 --- a/public/admin.html +++ b/public/admin.html @@ -526,6 +526,8 @@