Remove collection of player locale (#508)

This commit is contained in:
Cooldude2606 authored and GitHub committed 2026-10-16 13:55:06 +01:00
1 parent 8d7d5ff10f
commit a7e66ccdd4
17 files changed
+7 -163

No files matched your search

-12
View File
@@ -278,18 +278,6 @@ t.test("player settings", t2 => {
t3.equal(record.joinMessage, "Bye", "kept across restarts");
});
t2.test("PlayerLocaleEvent stores the locale next to the join message", async t3 => {
const { send } = await startPlugin(t3, { withPlugins: false });
await send(new messages.JoinMessageSetRequest("Alice", "Hi"));
await send(new messages.PlayerLocaleEvent("Alice", "pt-BR"));
const record = await send(new messages.PlayerGetRequest("Alice"));
t3.strictSame([record.joinMessage, record.locale], ["Hi", "pt-BR"]);
await send(new messages.JoinMessageSetRequest("Alice", null));
const cleared = await send(new messages.PlayerGetRequest("Alice"));
t3.equal(cleared.locale, "pt-BR", "clearing the message keeps the locale");
});
t2.test("PlayerToolbarEvent stores the toolbar and it is saved", async t3 => {
const databaseDirectory = t3.testdir();
const { send, save } = await startPlugin(t3, { withPlugins: false, databaseDirectory });
+1 -8
View File
@@ -196,7 +196,7 @@ t.test("player settings", t2 => {
});
t2.test("a joining player's stored toolbar is sent to the lua side", async t3 => {
const bob = new messages.PlayerRecord("Bob", undefined, undefined, "eNqrVkrLz1eyUlBKSixSqgUAGQwD8g==");
const bob = new messages.PlayerRecord("Bob", undefined, "eNqrVkrLz1eyUlBKSixSqgUAGQwD8g==");
const { start, playerEvent, setStatus, state } = await startPlugin(t3, [], [bob]);
await start();
setStatus("running");
@@ -216,13 +216,6 @@ t.test("player settings", t2 => {
t3.strictSame([event.playerName, event.toolbar], ["Alice", "abc"]);
});
t2.test("ipc with a locale is forwarded to the controller", async t3 => {
const { ipc, state } = await startPlugin(t3);
await ipc("exp_scenario:locale", { player_name: "Alice", locale: "de" });
const [event] = state.sent.filter(request => request instanceof messages.PlayerLocaleEvent);
t3.strictSame([event.playerName, event.locale], ["Alice", "de"]);
});
t2.test("ipc asking for the message prints it to the player", async t3 => {
const { ipc, setStatus, state } = await startPlugin(t3, [], [alice]);
setStatus("running");
-26
View File
@@ -1,26 +0,0 @@
import t from "tap";
import { localeFlag, localeName } from "../dist/node/locales.js";
// The locale folders of Factorio 2.1
const factorioLocales = [
"af", "ar", "be", "bg", "ca", "cs", "da", "de", "el", "en", "eo", "es-ES", "et", "eu", "fa", "fi", "fil", "fr",
"fy-NL", "ga-IE", "he", "hr", "hu", "id", "is", "it", "ja", "ka", "kk", "ko", "lt", "lv", "nl", "no", "pl",
"pt-BR", "pt-PT", "ro", "ru", "sk", "sl", "sq", "sr", "sv-SE", "th", "tr", "uk", "vi", "zh-CN", "zh-TW",
];
const noFlag = ["ar", "ca", "eo", "eu"];
t.test("localeFlag()", async t2 => {
t2.equal(localeFlag("de"), "\u{1F1E9}\u{1F1EA}", "language codes use the table");
t2.equal(localeFlag("pt-BR"), "\u{1F1E7}\u{1F1F7}", "regions are used directly");
t2.equal(localeFlag("zh-TW"), "\u{1F1F9}\u{1F1FC}");
for (const locale of factorioLocales) {
t2.equal(localeFlag(locale) === "", noFlag.includes(locale), `${locale} has a flag unless it has no country`);
}
t2.equal(localeFlag("xx"), "", "unknown languages have no flag");
t2.equal(localeFlag(""), "");
});
t.test("localeName()", async t2 => {
t2.equal(localeName("de"), "German");
t2.equal(localeName("not a locale"), "not a locale", "invalid codes are shown as they are");
});
+1 -8
View File
@@ -9,7 +9,7 @@ local valid_state = { order = { { name = "readme", favourite = true } }, open =
--- @return table restored Calls to set_state as { player name, state }
local function load(env, toolbar)
local restored = {}
env.extend_defines{ events = { on_player_locale_changed = 3, on_player_left_game = 4 } }
env.extend_defines{ events = { on_player_left_game = 4 } }
env.extend_requires{
["modules/exp_gui"] = {
toolbar = toolbar or {
@@ -28,13 +28,6 @@ local function load(env, toolbar)
return env.load_module("control/player_settings"), restored
end
Suite.test("send_locale() sends the locale of the player", function(env)
local PlayerSettings = load(env)
rawset(env.add_player{ name = "Alice" }, "locale", "pt-BR")
PlayerSettings.events[defines.events.on_player_joined_game]{ player_index = 1 }
Suite.eq(env.sent, { { channel = "exp_scenario:locale", data = { player_name = "Alice", locale = "pt-BR" } } }, "sent")
end)
Suite.test("send_toolbar() sends the compressed toolbar when a player leaves", function(env)
local PlayerSettings = load(env)
env.add_player{ name = "Alice" }