feat(login): randomize Russian welcome headlines

This commit is contained in:
2026-09-08 21:36:26 +03:00
parent 4b1ac6ca5a
commit 5346f9296f
3 changed files with 59 additions and 7 deletions
+25 -2
View File
@@ -7,8 +7,18 @@
const MAX_VIEW_OBJECTS = 30;
const OBSERVER_CELL_SIZE = 8;
const NAME_ADJECTIVES = Object.freeze(["Бодрый", "Хитрый", "Тихий", "Смелый", "Ловкий", "Сонный", "Шустрый", "Лунный", "Яркий", "Дикий", "Вечный", "Храбрый"]);
const NAME_NOUNS = Object.freeze(["Барсук", "Крот", "Енот", "Кабан", "Кактус", "Жук", "Тостер", "Робот", "Гриб", "Самокат", "Бублик", "Пингвин"]);
const NAME_NOUNS = Object.freeze(["Барсук", "Крот", "Енот", "Кабан", "Кактус", "Жук", "Тостер", "Тюлень", "Гриб", "Ежик", "Бублик", "Пингвин"]);
const NAME_COMBINATION_COUNT = NAME_ADJECTIVES.length * NAME_NOUNS.length;
const LOGIN_HEADLINES = Object.freeze([
Object.freeze({first: "Кусты уже", highlight: "потеряли выход"}),
Object.freeze({first: "Лабиринт снова", highlight: "подстригли криво"}),
Object.freeze({first: "Пиксели дружно", highlight: "ушли в кусты"}),
Object.freeze({first: "Карта молчит", highlight: "но смотрит косо"}),
Object.freeze({first: "Выход рядом", highlight: "в другой вселенной"}),
Object.freeze({first: "Крот сказал", highlight: "что это срез"}),
Object.freeze({first: "Тупик машет", highlight: "обеими стенами"}),
Object.freeze({first: "Компас уверен", highlight: "почти наверняка"})
]);
const KEY_DIRECTIONS = Object.freeze({
ArrowUp: "north", KeyW: "north",
ArrowRight: "east", KeyD: "east",
@@ -55,6 +65,10 @@
return null;
}
function randomLoginHeadline(randomSource) {
return LOGIN_HEADLINES[randomIndex(LOGIN_HEADLINES.length, randomSource)];
}
function directionFromKey(code) {
return KEY_DIRECTIONS[code] || null;
}
@@ -152,12 +166,21 @@
byId("observer-screen").hidden = name !== "observer";
}
function renderWelcomeHeadline(headline) {
const title = byId("welcome-title");
const highlight = documentObject.createElement("span");
highlight.textContent = headline.highlight;
title.replaceChildren(documentObject.createTextNode(headline.first), documentObject.createElement("br"), highlight);
}
function setConnection(connectionState, text) {
byId("connection").dataset.state = connectionState;
byId("connection-text").textContent = text;
byId("details-text").textContent = connectionState === "online" ? "WebSocket подключён к локальному ESP." : "Команды временно не отправляются. Повторяем подключение автоматически.";
}
renderWelcomeHeadline(randomLoginHeadline());
function beginFeedback() {
if (state.feedbackReady) return;
state.feedbackReady = true;
@@ -493,7 +516,7 @@
return {state, handleMessage, move};
}
const api = Object.freeze({TOKEN_KEY, MAX_VIEW_CHUNKS, NAME_COMBINATION_COUNT, directionFromKey, directionFromSwipe, randomIndex, randomSuggestedName, createEnvelope, snapshotIsValid, SnapshotAssembler, projectedCellIndices, clampObserverZoom, observerFitScale, boot});
const api = Object.freeze({TOKEN_KEY, MAX_VIEW_CHUNKS, NAME_COMBINATION_COUNT, LOGIN_HEADLINES, directionFromKey, directionFromSwipe, randomIndex, randomSuggestedName, randomLoginHeadline, createEnvelope, snapshotIsValid, SnapshotAssembler, projectedCellIndices, clampObserverZoom, observerFitScale, boot});
if (typeof module !== "undefined" && module.exports) module.exports = api;
root.Maze32Player = api;
if (root.document) root.document.addEventListener("DOMContentLoaded", () => { root.maze32PlayerApp = boot(root.document, root); });