diff --git a/changelog.d/20261004-squid-playerbots.md b/changelog.d/20261004-squid-playerbots.md index 3fd45e4..a77e5b1 100644 --- a/changelog.d/20261004-squid-playerbots.md +++ b/changelog.d/20261004-squid-playerbots.md @@ -4,4 +4,4 @@ type: added audience: admins title: Configure SQUID Playerbots and prevent conflicting bot systems --- -SQUID Playerbots has translated controls for its existing settings. Enable one bot system at a time; the Manager checks manual config changes before starting the server. Recovery points also include the SQUID database when installed. +The Bots tab shows translated settings for the active bot system. Bot module cards only offer enable switches, without duplicate settings. Enable one bot system at a time; the Manager checks manual config changes before starting the server. Recovery points also include the SQUID database when installed. diff --git a/modules/catalog.json b/modules/catalog.json index 5ad4ff1..e1db3bf 100644 --- a/modules/catalog.json +++ b/modules/catalog.json @@ -118,7 +118,8 @@ "status": "early", "icon": "swords", "enable_key": "AiPlayerbot.Enabled", - "default_on": false + "default_on": false, + "page": "bots" }, { "id": "client-compat", diff --git a/src/dev/mock.ts b/src/dev/mock.ts index ba417f5..74d1a79 100644 --- a/src/dev/mock.ts +++ b/src/dev/mock.ts @@ -65,7 +65,7 @@ export {}; if(cmd==="realmlist_save"){const w=window as any;const rl=w.__rl;if(args.profileId){const p=rl.profiles.find((x: any)=>x.id===args.profileId);p.name=args.name;p.data=args.data;return p;}if(rl.profiles.some((x: any)=>x.name.toLowerCase()===String(args.name).toLowerCase()))throw {human:{code:"unknown",title:"",message:"",actions:[]},technical:"A realmlist with that name already exists."};const p={id:String(args.name).toLowerCase().replace(/[^a-z0-9]+/g,"-"),name:args.name,data:(/\s/.test(args.data.trim())?args.data.trim():"set realmlist "+args.data.trim())+"\r\n"};rl.profiles.push(p);return p;} if(cmd==="realmlist_delete"){const rl=(window as any).__rl;rl.profiles=rl.profiles.filter((x: any)=>x.id!==args.profileId);return null;} if(cmd==="account_delete") return null; - if(cmd==="modules_list") return [{id:"companions",name:"CoA Companions",description:{en:"Companion bots for groups, dungeons and your guild.",ru:"Боты-компаньоны для групп, подземелий и гильдии."},repo:"https://github.com/Corfirean/mod-coa-playerbots",installed:true,enabled:modState["companions"],switchable:true,status:"beta",icon:"bot",page:"bots"},{id:"content-scaling",name:"Content Scaling",description:{en:"Scales dungeons and raids to your group, with solo modes.",ru:"Подстраивает подземелья и рейды под вашу группу, есть соло-режимы."},repo:"https://github.com/Corfirean/mod-coa-content-scaling",installed:true,enabled:modState["content-scaling"],switchable:true,status:"early",icon:"scaling",page:null},{id:"tbc-content",name:"TBC Content",description:{en:"Outland dungeons and raids, scaled to your level range.",ru:"Подземелья и рейды Запределья, подогнанные под ваши уровни."},repo:"https://github.com/Corfirean/mod-coa-content-scaling/tree/main/content-packs/mod-coa-tbc-content",installed:true,enabled:modState["tbc-content"],switchable:true,status:"early",icon:"tbc",page:null},{id:"wotlk-content",name:"WotLK Content",description:{en:"Northrend dungeons and raids, scaled to your level range.",ru:"Подземелья и рейды Нордскола, подогнанные под ваши уровни."},repo:"https://github.com/Corfirean/mod-coa-content-scaling/tree/main/content-packs/mod-coa-wotlk-content",installed:true,enabled:modState["wotlk-content"],switchable:true,status:"early",icon:"wotlk",page:null},{id:"ah-bot",name:"Auction House Bot",description:{en:"Fills the auction house with realistic, adjustable listings.",ru:"Наполняет аукцион реалистичными настраиваемыми лотами."},repo:"https://github.com/Corfirean/azerothcore-wotlk-coa",installed:true,enabled:modState["ah-bot"] ?? false,switchable:true,status:"early",icon:"gavel",page:null,hidden:false},{id:"npc-enchanter",name:"NPC Enchanter",description:{en:"An NPC that enchants your gear for you.",ru:"НПС, который зачаровывает ваше снаряжение."},repo:"https://github.com/azerothcore/mod-npc-enchanter",installed:true,enabled:modState["npc-enchanter"],switchable:true,status:"early",icon:"sparkles",page:null,hidden:false},{id:"playerbots",name:"SQUID's Playerbots",description:{en:"An alternative bot system with random bots and full AI.",ru:"Альтернативная система ботов со случайными ботами и полным ИИ."},repo:"https://github.com/Zyth45/mod-playerbots",installed:true,enabled:modState["playerbots"] ?? false,switchable:true,status:"early",icon:"swords",page:null,hidden:false},{id:"client-compat",name:"Client compatibility",description:{en:"Client-server link and appearance unlocks.",ru:"Связь клиента с сервером и разблокировка внешних видов."},repo:"https://github.com/Corfirean/azerothcore-wotlk-coa",installed:true,enabled:modState["client-compat"],switchable:false,status:"release",icon:"plug",page:null,hidden:true}].map(m => ({...m, has_settings: !["tbc-content", "wotlk-content"].includes(m.id), compatibility: realm === "wildcard" ? (["companions", "playerbots"].includes(m.id) ? "unsupported" : m.id === "client-compat" ? "compatible" : "experimental") : "compatible", switchable: realm === "wildcard" && ["companions", "playerbots"].includes(m.id) ? false : m.switchable})); + if(cmd==="modules_list") return [{id:"companions",name:"CoA Companions",description:{en:"Companion bots for groups, dungeons and your guild.",ru:"Боты-компаньоны для групп, подземелий и гильдии."},repo:"https://github.com/Corfirean/mod-coa-playerbots",installed:true,enabled:modState["companions"],switchable:true,status:"beta",icon:"bot",page:"bots"},{id:"content-scaling",name:"Content Scaling",description:{en:"Scales dungeons and raids to your group, with solo modes.",ru:"Подстраивает подземелья и рейды под вашу группу, есть соло-режимы."},repo:"https://github.com/Corfirean/mod-coa-content-scaling",installed:true,enabled:modState["content-scaling"],switchable:true,status:"early",icon:"scaling",page:null},{id:"tbc-content",name:"TBC Content",description:{en:"Outland dungeons and raids, scaled to your level range.",ru:"Подземелья и рейды Запределья, подогнанные под ваши уровни."},repo:"https://github.com/Corfirean/mod-coa-content-scaling/tree/main/content-packs/mod-coa-tbc-content",installed:true,enabled:modState["tbc-content"],switchable:true,status:"early",icon:"tbc",page:null},{id:"wotlk-content",name:"WotLK Content",description:{en:"Northrend dungeons and raids, scaled to your level range.",ru:"Подземелья и рейды Нордскола, подогнанные под ваши уровни."},repo:"https://github.com/Corfirean/mod-coa-content-scaling/tree/main/content-packs/mod-coa-wotlk-content",installed:true,enabled:modState["wotlk-content"],switchable:true,status:"early",icon:"wotlk",page:null},{id:"ah-bot",name:"Auction House Bot",description:{en:"Fills the auction house with realistic, adjustable listings.",ru:"Наполняет аукцион реалистичными настраиваемыми лотами."},repo:"https://github.com/Corfirean/azerothcore-wotlk-coa",installed:true,enabled:modState["ah-bot"] ?? false,switchable:true,status:"early",icon:"gavel",page:null,hidden:false},{id:"npc-enchanter",name:"NPC Enchanter",description:{en:"An NPC that enchants your gear for you.",ru:"НПС, который зачаровывает ваше снаряжение."},repo:"https://github.com/azerothcore/mod-npc-enchanter",installed:true,enabled:modState["npc-enchanter"],switchable:true,status:"early",icon:"sparkles",page:null,hidden:false},{id:"playerbots",name:"SQUID's Playerbots",description:{en:"An alternative bot system with random bots and full AI.",ru:"Альтернативная система ботов со случайными ботами и полным ИИ."},repo:"https://github.com/Zyth45/mod-playerbots",installed:true,enabled:modState["playerbots"] ?? false,switchable:true,status:"early",icon:"swords",page:"bots",hidden:false},{id:"client-compat",name:"Client compatibility",description:{en:"Client-server link and appearance unlocks.",ru:"Связь клиента с сервером и разблокировка внешних видов."},repo:"https://github.com/Corfirean/azerothcore-wotlk-coa",installed:true,enabled:modState["client-compat"],switchable:false,status:"release",icon:"plug",page:null,hidden:true}].map(m => ({...m, has_settings: !["tbc-content", "wotlk-content"].includes(m.id), compatibility: realm === "wildcard" ? (["companions", "playerbots"].includes(m.id) ? "unsupported" : m.id === "client-compat" ? "compatible" : "experimental") : "compatible", switchable: realm === "wildcard" && ["companions", "playerbots"].includes(m.id) ? false : m.switchable})); if(cmd==="module_set_enabled"){ if(args.enabled && ["companions","playerbots"].includes(args.module) && modState[args.module === "companions" ? "playerbots" : "companions"]) throw {human:{code:"bot_modules_conflict",title:"",message:"",actions:[]},technical:"Only one bot system may be enabled."}; modState[args.module]=args.enabled; return null; } if(cmd==="all_settings") return [{key:"Visibility.Distance.Continents",value:"100",default:"90",doc:"Description: Visibility distance on continents. Range: 45-250 Default: 90",changed:true},{key:"Death.SicknessLevel",value:"11",default:"11",doc:"Description: Character level up to which characters get resurrection sickness. Default: 11",changed:false},{key:"Rate.Drop.Item.Epic",value:"3",default:"1",doc:"Description: Drop rates for money and items based on quality. Default: 1",changed:true},{key:"Instance.ResetTimeHour",value:"4",default:"4",doc:"Description: Hour of the day when the global instance reset occurs. Range: 0-23 Default: 4 - (04:00 AM)",changed:false},{key:"PlayerLimit",value:"1000",default:"1000",doc:"Description: Maximum number of players in the world.",changed:false}]; if(cmd==="all_settings_save") return Object.keys(args&&args.changes||{}); diff --git a/src/lib/squidSettings.ts b/src/lib/squidSettings.ts new file mode 100644 index 0000000..b7a2fd7 --- /dev/null +++ b/src/lib/squidSettings.ts @@ -0,0 +1,45 @@ +import type { JsonValue, ModuleSetting, SettingsView, SettingView } from "@/lib/api"; +import type { Locale } from "@/i18n"; +import { moduleField } from "@/lib/moduleSettings"; + +const languages: Locale[] = ["en", "ru", "de", "fr", "es", "zh"]; +const groups = [ + { id: "squid.population", titles: ["Population", "Население мира", "Bevölkerung", "Population", "Población", "世界人口"] }, + { id: "squid.party", titles: ["Groups", "Группы", "Gruppen", "Groupes", "Grupos", "队伍"] }, + { id: "squid.combat", titles: ["Combat", "Бой", "Kampf", "Combat", "Combate", "战斗"] }, + { id: "squid.activities", titles: ["Dungeons and PvP", "Подземелья и PvP", "Dungeons und PvP", "Donjons et JcJ", "Mazmorras y JcJ", "地下城与PvP"] }, + { id: "squid.chat", titles: ["Chat", "Общение", "Chat", "Discussion", "Chat", "聊天"] }, + { id: "squid.other", titles: ["Other settings", "Другие настройки", "Weitere Einstellungen", "Autres réglages", "Otros ajustes", "其他设置"] }, +]; + +function group(key: string, curated: boolean) { + if (!curated) return "squid.other"; + if (/Talk|Emote|Suggest/.test(key)) return "squid.chat"; + if (/Lfg|JoinBG/.test(key)) return "squid.activities"; + if (/Smart|SpecRotations|Interrupt/.test(key)) return "squid.combat"; + if (/AddedBots|BotAutologin$|Invite|AddClassCommand|KeepAlts|Recruit|FollowDistance/.test(key) && !key.endsWith("RandomBotAutologin")) return "squid.party"; + return "squid.population"; +} + +/** Use the same settings screen as Companions, backed only by shipped SQUID options. */ +export function squidSettingsView(items: ModuleSetting[], locale: Locale): SettingsView { + const settings: SettingView[] = items.filter(s => s.key !== "AiPlayerbot.Enabled" && !s.key.startsWith("PlayerbotsDatabase") && !s.key.startsWith("Playerbots.Updates.")).map(s => { + const field = moduleField(s.key, locale); + const type = field?.type === "bool" || field?.type === "int" || field?.type === "float" || field?.type === "enum" ? field.type : "string"; + const decode = (raw: string): JsonValue => { + const value = raw.trim().replace(/^"|"$/g, ""); + if (type === "bool") return !["0", "false", "no", "off"].includes(value.toLowerCase()); + if (type === "int" || type === "float") return Number(value); + return value; + }; + const value = decode(s.value), defaultValue = decode(s.default ?? s.value); + return { + key: s.key, type, title: field?.title ?? s.key, description: field?.description ?? s.doc, + category: group(s.key, !!field), advanced: !field || !!field.advanced, + min: field?.min, max: field?.max, options: field?.options ?? [], + value, default: defaultValue, is_default: value === defaultValue, present: true, problem: null, + drift: false, restartRequired: "world", dangerous: false, + }; + }); + return { scope: "bots", categories: groups.map(g => ({ id: g.id, title: g.titles[languages.indexOf(locale)] })), settings, unknown_keys: 0, drift_keys: [], files: ["Core/configs/modules/playerbots.conf"] }; +} diff --git a/src/screens/ModulesPage.tsx b/src/screens/ModulesPage.tsx index 4a7123d..c3da379 100644 --- a/src/screens/ModulesPage.tsx +++ b/src/screens/ModulesPage.tsx @@ -162,7 +162,7 @@ export function ModulesPage({ serverId, onChanged }: { serverId: string; onChang > - {m.installed && m.has_settings && m.status !== "soon" && m.compatibility !== "unsupported" && ( + {!m.page && m.installed && m.has_settings && m.status !== "soon" && m.compatibility !== "unsupported" && ( setOpen(open === m.id ? null : m.id)}> {t("mod.settings")} @@ -170,7 +170,7 @@ export function ModulesPage({ serverId, onChanged }: { serverId: string; onChang {/* The settings open right under the row of the card they belong to, so they are never out of sight below a long grid. */} - {selected?.has_settings && selectedAt >= 0 && Math.floor(selectedAt / 2) === Math.floor(i / 2) && (i % 2 === 1 || i === modules.length - 1) && ( + {selected?.has_settings && !selected.page && selectedAt >= 0 && Math.floor(selectedAt / 2) === Math.floor(i / 2) && (i % 2 === 1 || i === modules.length - 1) && ( {t("mod.settingsOf", { name: selected.name })} setChanged(true)} /> diff --git a/src/screens/SettingsPage.tsx b/src/screens/SettingsPage.tsx index 09f8f0d..29bce36 100644 --- a/src/screens/SettingsPage.tsx +++ b/src/screens/SettingsPage.tsx @@ -15,6 +15,7 @@ import { type SettingView, type UiError, } from "@/lib/api"; +import { squidSettingsView } from "@/lib/squidSettings"; import { cn } from "@/lib/utils"; import { Button } from "@/components/ui/button"; import { Card } from "@/components/ui/card"; @@ -153,9 +154,10 @@ function Row(props: { s: SettingView; value: JsonValue; error: string | null; on ); } -export function SettingsPage(props: { serverId: string; scope: Scope; title: string; question: string }) { +export function SettingsPage(props: { serverId: string; scope: Scope; botModule?: "companions" | "playerbots"; title: string; question: string }) { const { serverId, scope } = props; - const { t, tn } = useI18n(); + const { t, tn, locale } = useI18n(); + const squid = scope === "bots" && props.botModule === "playerbots"; const sx = useSchemaText(); const human = useHuman(); const [view, setView] = useState(null); @@ -181,7 +183,7 @@ export function SettingsPage(props: { serverId: string; scope: Scope; title: str const load = useCallback(async () => { try { - const v = await api.settings(serverId, scope); + const v = squid ? squidSettingsView(await api.moduleSettings(serverId, "playerbots"), locale) : await api.settings(serverId, scope); setView(v); setDraft({}); setErrors({}); @@ -190,14 +192,14 @@ export function SettingsPage(props: { serverId: string; scope: Scope; title: str } catch (e) { setFatal(asUiError(e)); } - }, [serverId, scope]); + }, [serverId, scope, squid, locale]); useEffect(() => { setView(null); setSaved(null); setCategory(""); void load(); - void api.presets(scope).then(setPresets); + if (squid) setPresets([]); else void api.presets(scope).then(setPresets); void api.status(serverId).then((s) => setRunning(s.observed.world.state === "running")); setQuery(""); setRaw(null); @@ -290,7 +292,10 @@ export function SettingsPage(props: { serverId: string; scope: Scope; title: str setBusy(true); setSaveErr(null); try { - const report = await api.save(serverId, scope, changes); + const report: SaveReport = squid ? { + changed: (await api.moduleSaveSettings(serverId, "playerbots", Object.fromEntries(Object.entries(changes).map(([key, value]) => [key, typeof value === "boolean" ? value ? "1" : "0" : String(value)])))).map(key => ({ key, title: view!.settings.find(s => s.key === key)!.title, restart: "world", dangerous: false })), + restart: "world", snapshot: null, + } : await api.save(serverId, scope, changes); setSaved(report); setPreview(null); await load(); @@ -338,7 +343,9 @@ export function SettingsPage(props: { serverId: string; scope: Scope; title: str async function openPreset(id: string) { setSaved(null); - setPreview(await api.previewPreset(serverId, scope, id)); + if (squid) { + setPreview({ id: "defaults", title: t("set.restoreDefaults"), description: "", changes: view!.settings.filter(s => s.value !== s.default).map(s => ({ key: s.key, title: s.title, from: s.value, to: s.default, dangerous: false })) }); + } else setPreview(await api.previewPreset(serverId, scope, id)); } async function restartNow() { @@ -356,9 +363,9 @@ export function SettingsPage(props: { serverId: string; scope: Scope; title: str return ( {props.title} - {props.question} + {squid ? "SQUID’s Playerbots" : props.question} - {scope === "bots" && } + {scope === "bots" && !squid && } {view.drift_keys.length > 0 && ( @@ -372,7 +379,7 @@ export function SettingsPage(props: { serverId: string; scope: Scope; title: str )} - {t("set.presets")} + {presets.length > 0 && {t("set.presets")}} {presets.map((p) => ( void openPreset(p.id)}> {sx.preset(p).title} diff --git a/src/screens/Shell.tsx b/src/screens/Shell.tsx index 8dfe98c..ff81391 100644 --- a/src/screens/Shell.tsx +++ b/src/screens/Shell.tsx @@ -47,11 +47,16 @@ export function Shell(props: { const update = useServerUpdate(props.activeId); // A module that is switched off takes its page away (the companions' "Bots" page, for one). + const [botModule, setBotModule] = useState<"companions" | "playerbots">("companions"); const [hiddenPages, setHiddenPages] = useState([]); const reloadModules = useCallback(() => { void api .modulesList(props.activeId) - .then((list) => setHiddenPages(list.filter((m) => m.page && (!m.installed || m.compatibility === "unsupported" || (m.switchable && !m.enabled))).map((m) => m.page as string))) + .then((list) => { + const available = (m: typeof list[number]) => m.installed && m.compatibility !== "unsupported" && (!m.switchable || m.enabled); + setHiddenPages([...new Set(list.flatMap(m => m.page ? [m.page] : []))].filter(page => !list.some(m => m.page === page && available(m)))); + setBotModule(list.some(m => m.id === "playerbots" && available(m)) ? "playerbots" : "companions"); + }) .catch(() => setHiddenPages([])); }, [props.activeId]); useEffect(() => { @@ -122,9 +127,9 @@ export function Shell(props: { {page === "overview" ? ( - props.onForget(server.id)} onOpenUpdates={() => setPage("settings")} onRealmChanged={reloadModules} /> + props.onForget(server.id)} onOpenUpdates={() => setPage("settings")} onRealmChanged={reloadModules} /> ) : page === "bots" || page === "server" ? ( - + ) : page === "console" ? ( ) : page === "modules" ? ( diff --git a/tools/check-module-settings.mjs b/tools/check-module-settings.mjs index 61ab6b9..8aef9f5 100644 --- a/tools/check-module-settings.mjs +++ b/tools/check-module-settings.mjs @@ -40,3 +40,25 @@ const enabledZero = auctionTypeChanges(zero, true); if (enabledZero[weapon[0].key] !== "1" || enabledZero[weapon[1].key] !== "0") throw new Error("Zero-default types must become enabled without adding missing keys"); for (const label of [...Object.values(auctionCategories), ...Object.values(auctionQualities)]) if (label.length !== 6 || label.some(t => !t)) throw new Error("Incomplete auction type/quality translation"); console.log(`${ids.size} module controls: all six languages, unique keys, ranges and legacy aliases verified`); +let squidSource = readFileSync(new URL("src/lib/squidSettings.ts", root), "utf8"); +squidSource = squidSource.replace('import { moduleField } from "@/lib/moduleSettings";', `import { moduleField } from "data:text/javascript;base64,${Buffer.from(compiled).toString("base64")}";`); +const { squidSettingsView } = await import(`data:text/javascript;base64,${Buffer.from(stripTypeScriptTypes(squidSource)).toString("base64")}`); +const squidSample = [ + { key: "AiPlayerbot.Enabled", value: "1", default: "0", doc: "" }, + { key: "PlayerbotsDatabaseInfo", value: "private connection", default: "", doc: "" }, + { key: "Playerbots.Updates.EnableDatabases", value: "0", default: "1", doc: "" }, + { key: "AiPlayerbot.MaxRandomBots", value: "600", default: "500", doc: "" }, + { key: "AiPlayerbot.RandomBotTalk", value: "0", default: "1", doc: "" }, + { key: "AiPlayerbot.FollowDistance", value: "1.5", default: "1.5", doc: "" }, + { key: "AiPlayerbot.RandomBotAccountPrefix", value: '"rndbot"', default: '"rndbot"', doc: "Account prefix" }, +]; +for (const locale of ["en", "ru", "de", "fr", "es", "zh"]) { + const view = squidSettingsView(squidSample, locale); + if (view.settings.length !== 4 || view.settings.some(s => s.key === "AiPlayerbot.Enabled" || s.key.startsWith("Playerbots"))) throw new Error("Bots must hide master switches and managed connections"); + const count = view.settings.find(s => s.key === "AiPlayerbot.MaxRandomBots"); + if (count.value !== 600 || count.default !== 500 || count.category !== "squid.population") throw new Error("SQUID population values/defaults must be numeric and preserved"); + if (view.settings.find(s => s.key === "AiPlayerbot.RandomBotTalk").value !== false) throw new Error("SQUID switches must use boolean values"); + if (view.settings.find(s => s.key === "AiPlayerbot.FollowDistance").value !== 1.5) throw new Error("SQUID decimal settings must preserve fractions"); + if (view.categories.some(c => !c.title)) throw new Error("SQUID categories must be translated"); +} +console.log("SQUID Bots view: typed values, upstream defaults, categories and hidden managed settings verified");
{props.question}
{squid ? "SQUID’s Playerbots" : props.question}