diff --git a/lib/commands.js b/lib/commands.js index b9c5245..60424e9 100644 --- a/lib/commands.js +++ b/lib/commands.js @@ -321,7 +321,7 @@ module.exports = ({findOnline, players, watchers, sendItemList, blocks, setHideB // lib/disguises.js become(session, [choice]) { if (!choice || choice === "list") { - tell(session, `You can become: ${disguises.names().join(", ")}, or any character by its number. !become off to be yourself.`); + tell(session, `You can become: ${disguises.names().join(", ")}. !become off to be yourself.`); return; } if (choice === "off") { diff --git a/lib/disguises.js b/lib/disguises.js index 4e7683b..2ab3a15 100644 --- a/lib/disguises.js +++ b/lib/disguises.js @@ -30,23 +30,27 @@ const NPC_PHANTOM = 2; // what the client draws when no id is given const TYPE_CLIP = "0"; const TYPE_ANIMAL = "1"; // an ordinary animal in an outfit: the villagers of the adventures -// the names "!become" takes, with the NPC each is. +// the names "!become" takes, with the NPC each is: the alphas and the +// phantom, nothing else. numbers are not taken: most of the NPC table is +// the adventures' set pieces and bosses, drawn at a size that fills the +// screen. const NAMED = new Map([ ["peck", 20], ["liza", 21], ["greely", 22], ["graham", 23], ["gilbert", 24], ["cosmo", 25], ["tavie", 219], ["phantom", NPC_PHANTOM], ]); +const ALLOWED = new Set(NAMED.values()); -// is this NPC one a player can be drawn as? clips with no artwork (two -// rows have none) would leave them invisible. +// is this NPC one a player can be drawn as? only those named above, and +// only with artwork. a disguise saved before the list was this short is +// ignored, so it falls away by itself. const usable = id => { - const def = defpacks.npcDef(id); + const def = ALLOWED.has(id) && defpacks.npcDef(id); return Boolean(def) && (def.type === TYPE_ANIMAL || (def.type === TYPE_CLIP && Number(def.mediaRefId) > 0)); }; -// the NPC id for what a player typed (a name above or a number), or null. +// the NPC id for what a player typed (a name above), or null. const find = text => { - const word = String(text).toLowerCase(); - const id = NAMED.has(word) ? NAMED.get(word) : /^\d{1,4}$/.test(word) ? Number(word) : NaN; + const id = NAMED.get(String(text).toLowerCase()); return usable(id) ? id : null; };