diff --git a/README.md b/README.md index 26e3c87..6cf6c4c 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ number of source checkouts, and choosing one opens it: no file moves, and Waypoi **Modules** and **Leagues** can be edited on a release from v0.2.0-beta on and on a source checkout that exposes the supported settings and league-choice hooks: which modules a league uses, their settings, and new leagues. Any installed module can be ticked for any league when what it needs is on, Player Bots among them; turning off a league's own bundle -(Ruthless in a Ruthless league) asks first, and the Survivors modules stay in isolated leagues. A release hides and shows only the leagues made in Waypoint. The league card's name, description and mode links have a read-only preview. +(Ruthless in a Ruthless league) asks first, the Survivors modules stay in isolated leagues, and the rules of a game mode (Ruthless) go with that mode's leagues and with leagues made in Waypoint. A release hides and shows only the leagues made in Waypoint. The league card's name, description and mode links have a read-only preview. On a release install, **Settings → Developer → Developer Mode** adds a **Simple | Advanced** switch at the bottom of the sidebar: **Advanced** gives every section below, with full control over branches and pull requests. Someone coming from an earlier launcher starts there. diff --git a/docs/launcher.md b/docs/launcher.md index 195d9dc..88cf927 100644 --- a/docs/launcher.md +++ b/docs/launcher.md @@ -971,9 +971,9 @@ under **Unavailable modules**. **Which modules a league can have** follows LocalExile's own rules, in the interface (`GameSystems.ValidateComposition`) and again in the adapter (`LeagueData.py`, `validate_modules`). LocalExile says that a module has no knowledge of leagues -and that any league can list it, so every installed module is a box to tick for every league that can be edited: a core +and that any league can list it, so an installed module is a box to tick for every league that can be edited: a core module the league does not ship with (the Currency Exchange in an SSF or a Ruthless league), another league's module -(Ruthless, the Phrecia ascendancies), and an add-on. What stays: +(the Phrecia ascendancies), and an add-on. What stays: - **The game and dependencies.** `Core/Game` cannot be removed, and what a module needs has to be on, as LocalExile itself requires. @@ -988,6 +988,26 @@ module the league does not ship with (the Currency Exchange in an SSF or a Ruthl when its parents lead to Void, so nothing of it reaches Standard: Survivors is one, and so is every league made in Waypoint. A module LocalExile ships only in such leagues (the three Survivors modules: a run starts by itself, refuses ordinary exits and hands out rewards) shows as **For isolated leagues only** in a league that leads to Standard. +- **The rules of a game mode go with that mode** (`ModeOf`, `ModeFits`, `RulesOnly`). A module that LocalExile ships + only in leagues of one `form` is that mode's rules: the Ruthless module, which the eight leagues of the form + `ruthless` list and no other. Nothing names the module or the mode; the league files say it, and once a league + LocalExile ships in another mode lists the module, it is a module like any other. LocalExile takes a league's rules + whole from one module, so turning it on changes every rule of the mode for every character of the league, and the + rest of the mode does not come with it: the mode's own versions of skills, vendors and quest rewards belong to the + league's definition (`dataSet`), and the game shows the league by its `form`. So: + - in a league of that mode it is the league's own bundle, as above; + - the leagues LocalExile ships in another mode (Standard, Allflame, Phrecia, Survivors and their Hardcore and SSF + versions) do not get it: they have their own versions in that mode. It shows under **Unavailable modules** as + **Rules of a game mode**, and its tooltip names the flags a new league can start from to have it (`ModeStarts`); + - a league made in Waypoint can have it when the game base it was made on has that mode: one that starts from + Standard, Allflame or Phrecia, not one that starts from Survivors, whose own base has no league of that mode. Once + the box is ticked, the line under the list and the question before saving say that the league gets that mode's + rules, for every character in it, without that mode's own skills, vendors and quest rewards, and that the game + still shows the league as it is. A new league says the same, and where its starting flag has a league of that + mode, that the whole mode is a choice of the first step (**Game mode**). There it is an extra and not part of the + league's bundle: unticking it takes it back without a question; + - one that is already on where it does not fit (a hand edit of `data/league-modules.json`) stays ticked until its + user unticks it, and other changes still save. It cannot be turned on anew there. - **An add-on** is a module that no league LocalExile ships lists (`GameSystems.AddOn`: PlayerBots and NessaDevelopmentTabs, at the time of writing), off until its user lists it in the league they want it in, which is how LocalExile's own guide turns PlayerBots on (`{"Standard": {"add": ["PlayerBots"]}}` in `data/league-modules.json`). @@ -1014,11 +1034,8 @@ the original files in configuration history, apply children before hiding parent roll back their own writes on failure without overwriting another tool's changes. Visibility takes effect at the next server start. Per-account visibility requires a separate LocalExile hook and is not implied by this global control. -Module selection is conservative. The whole selection must fit at least one existing non-Waypoint league definition with -the same mode-linked family, game base and exact mode flags/data set, rather than combining modules merely because each appears somewhere. -Dependencies must be present and acyclic. Game is required; dedicated non-Core bundles from the starting profile, and -their dependencies, stay together. Unverified modules are labelled and cannot be added. An already selected incompatible -module can be deselected to repair a draft; invalid selections cannot be saved. Parent chains must lead to Standard or Void. +Dependencies must be present and acyclic, and Game is required. An already selected module that can't be turned on here +can be deselected to repair a draft; invalid selections cannot be saved. Parent chains must lead to Standard or Void. The backend repeats these checks, even if an outside caller bypasses the interface. **New league** creates a separate league in two steps. First choose the starting league and game mode, then enter a new @@ -1051,8 +1068,10 @@ files keep their existing behavior. Drafts review the complete relevant manifest/source inventory and user overrides. Adding, removing or changing a definition invalidates the draft; the backend checks again after backup. These checks enforce the declared structure, not every hidden assumption in arbitrary module code. LocalExile currently has no complete conflicts/supported-modes metadata contract. -Waypoint adds one rule to LocalExile's, the modules of isolated leagues, and one warning, about a league's own bundle; -a declaration from LocalExile or the modules of what belongs together would replace both. The implemented controls require no LocalExile source changes. +Waypoint adds two rules to LocalExile's, the modules of isolated leagues and the rules of a game mode, and two warnings, +about a league's own bundle and about a mode's rules without the rest of the mode; a declaration from LocalExile or the +modules of what belongs together would replace them. One thing no file says: two modules that both supply league rules +(Ruthless and Nessa's development tabs) in one league, where LocalExile uses the first listed and ignores the other. The implemented controls require no LocalExile source changes. **League card preview** shows the definition's name, description, Hardcore/SSF/form flags and linked mode variants in a collapsed, read-only panel. It reads files, not the running server's startup snapshot. LocalExile already reads descriptions diff --git a/scripts/LeagueData.py b/scripts/LeagueData.py index 94f6c77..30e2c2b 100644 --- a/scripts/LeagueData.py +++ b/scripts/LeagueData.py @@ -181,7 +181,8 @@ def isolated(profile, profiles): def validate_modules(profile, selected, systems, profiles, new=False, listed=()): """Whether these modules can run together for the league, by what LocalExile itself asks: the game, each module's own dependencies, and nothing made for an isolated league in one that leads to Standard. A module has no knowledge of - leagues (LocalExile's modules.md), so any other module goes with any league. A league's own bundle (Ruthless in a + leagues (LocalExile's modules.md), so any other module goes with any league, but the rules of a game mode, which go + with that mode's leagues and with a league made in Waypoint on a base that has the mode. A league's own bundle (Ruthless in a Ruthless league) can be left out too: LocalExile loads the league without it and keeps its saved data, and the interface asks its user first. `new`: the modules are for a league made from this one, which is isolated whatever its template is. `listed`: what the league lists now, which may name a module that is not installed.""" @@ -204,6 +205,22 @@ def installed(path): users = [p for p in profiles if not p["custom"] and path.casefold() in {m.casefold() for m in p["modules"]}] require(not users or not all(isolated(p, profiles) for p in users), path.rsplit("/", 1)[-1] + " is made for an isolated league and cannot be turned on in a league that leads to Standard.") + # A module of a game mode: every shipped league that lists it has that form (Ruthless and "ruthless"). In a league of + # that mode it is the league's own. In another it brings the mode's rules alone, which is for a league made in + # Waypoint, on a game base LocalExile ships that mode for. One the league already lists (a hand edit) stays until its + # user unticks it, so that another change still saves. + own = (profile["data"].get("form") or "").casefold() + for path in active.values(): + if not new and path.casefold() in known: + continue + forms = {(p["data"].get("form") or "").casefold() for p in profiles + if not p["custom"] and path.casefold() in {m.casefold() for m in p["modules"]}} + if len(forms) != 1 or "" in forms or forms == {own}: + continue + form = next(iter(forms)) + require((new or profile["custom"]) and any(not p["custom"] and (p["data"].get("form") or "").casefold() == form + and p["base"].casefold() == profile["base"].casefold() for p in profiles), + path.rsplit("/", 1)[-1] + " holds the rules of a game mode: it can be turned on for a league made in Waypoint, on a game base that has that mode.") visiting, done = set(), set() def visit(identifier): diff --git a/src/Launcher.Core/LeagueCustomization.cs b/src/Launcher.Core/LeagueCustomization.cs index 807849c..bed57b2 100644 --- a/src/Launcher.Core/LeagueCustomization.cs +++ b/src/Launcher.Core/LeagueCustomization.cs @@ -96,10 +96,11 @@ void AddDependencies(string path) /// module: its hooks do not run … Saved data stays"), so they can be turned off; the league then no longer has the /// rules or content it is named for, which the interface says before it saves (). An /// add-on is never part of a bundle: a league made in Waypoint with an add-on ticked lists it in its own file. Nor is - /// a listed module that is not installed. + /// a listed module that is not installed, nor the rules of a game mode in a league of another mode + /// (): ticked for a league made in Waypoint, they are an extra that unticking takes back. public IReadOnlyList BundleModules(GameLeague league) => [.. league.BaseSystems.Where(p => !p.StartsWith("Core/", StringComparison.OrdinalIgnoreCase) && !Id(p).Equals("Game", StringComparison.OrdinalIgnoreCase) - && !AddOn(p) && Installed(p))]; + && !AddOn(p) && Installed(p) && !(ModeOf(p) is { } form && !league.Form.Equals(form, StringComparison.OrdinalIgnoreCase)))]; /// The modules of the league's own bundle that leaves out: what its user is told, /// by the names the list shows, and asked to confirm. @@ -118,8 +119,9 @@ public IReadOnlyList BundleLeftOut(GameLeague league, IEnumerable Systems.Any(s => s.Path.Equals(path, StringComparison.OrdinalIgnoreCase)); /// Whether the modules in can run together for , by what - /// LocalExile itself asks: the game, each module's own dependencies, and nothing made for an isolated league in one - /// that leads to Standard (). A module has no knowledge of leagues (LocalExile's + /// LocalExile itself asks: the game, each module's own dependencies, nothing made for an isolated league in one + /// that leads to Standard (), and the rules of a game mode only where that mode fits + /// (). A module has no knowledge of leagues (LocalExile's /// Agents/docs/dev/modules.md), so any other module goes with any league. Turning off a league's own bundle /// is allowed too, and is what the interface asks about first (). /// : the modules are for a league made from this one, which is isolated whatever its @@ -130,6 +132,10 @@ public void ValidateComposition(GameLeague league, IReadOnlyCollection p if (!forNewLeague && !Isolated(league) && paths.FirstOrDefault(IsolatedModule) is { } apart) throw new InvalidOperationException(L.Text("{0} is made for an isolated league, whose characters and rewards never reach Standard. It can't be turned on in a league that leads to Standard.", Systems.FirstOrDefault(s => s.Path.Equals(apart, StringComparison.OrdinalIgnoreCase))?.Name ?? apart)); + // The rules of a game mode, where that mode does not fit. One this league already lists (a hand edit) stays until + // its user unticks it, so that another change still saves; it is not turned on anew. + if (paths.FirstOrDefault(p => !ModeFits(league, p, forNewLeague) && (forNewLeague || !league.Systems.Contains(p, StringComparer.OrdinalIgnoreCase))) is { } ofMode) + throw new InvalidOperationException(ModeNote(ofMode)); // A listed module that is not installed: LocalExile logs it and loads the league without it. One this league // already lists stays until its user unticks it; one that is new here is refused. if (paths.Any(p => !Installed(p) && (forNewLeague || !league.Systems.Contains(p, StringComparer.OrdinalIgnoreCase)))) @@ -172,9 +178,59 @@ public bool Isolated(GameLeague league) public bool IsolatedModule(string path) => Leagues.Where(l => !l.Custom && l.BaseSystems.Contains(path, StringComparer.OrdinalIgnoreCase)).ToArray() is { Length: > 0 } users && users.All(Isolated); + /// The game mode a module goes with, as the leagues LocalExile ships say it: every one of them that lists + /// the module has that form (the Ruthless module and the form "ruthless"). Such a module gives a league that + /// mode's rules, whole: LocalExile takes a league's rules from one module and never merges them. Null for a module + /// of no mode: one listed by leagues of different modes, of none, or by no league. A league made in Waypoint does + /// not count: its list is its user's. Nothing here names a module or a mode; once a league LocalExile ships in + /// another mode lists the module, the files say it is no longer one mode's. + public string? ModeOf(string path) + { + var users = Leagues.Where(l => !l.Custom && l.BaseSystems.Contains(path, StringComparer.OrdinalIgnoreCase)).ToArray(); + return users.Length > 0 && users[0].Form is { Length: > 0 } form && users.All(l => l.Form.Equals(form, StringComparison.OrdinalIgnoreCase)) ? form : null; + } + + /// Whether a module of a game mode may be on in . In a league of that mode it is the + /// league's own. In another it brings the mode's rules without the rest of the mode (), which + /// is for a league its user made in Waypoint, on a game base LocalExile ships that mode for: the Standard and + /// Allflame bases have Ruthless leagues, Survivors' own base has none. The leagues LocalExile ships stay as they + /// are, with their own versions in that mode. + bool ModeFits(GameLeague league, string path, bool forNewLeague) => + ModeOf(path) is not { } form || league.Form.Equals(form, StringComparison.OrdinalIgnoreCase) + || (forNewLeague || league.Custom) && Leagues.Any(l => !l.Custom && l.Form.Equals(form, StringComparison.OrdinalIgnoreCase) + && l.Base.Equals(league.Base, StringComparison.OrdinalIgnoreCase)); + + /// The modules of a game mode among that are not of 's own + /// mode: there they give the mode's rules alone, for every character of the league. The mode's own versions of + /// skills, vendors and quest rewards come from the league's definition (dataSet), which a module does not + /// change, and the game shows the league by its form. What the interface says before it saves. + public IReadOnlyList RulesOnly(GameLeague league, IEnumerable paths) => + [.. paths.Select(Normal).Where(p => ModeOf(p) is { } form && !league.Form.Equals(form, StringComparison.OrdinalIgnoreCase)) + .Select(p => Systems.FirstOrDefault(s => s.Path.Equals(p, StringComparison.OrdinalIgnoreCase))).OfType()]; + + /// The flags a league made in Waypoint can start from to have the rules of this module's mode: those whose + /// game base LocalExile ships that mode for, and that can be copied. Empty for a module of no mode. + public IReadOnlyList ModeStarts(string path) => ModeOf(path) is not { } form ? [] : + [.. Cards.Where(c => c.IsFlag && !c.Primary.Custom && Configurable(c.Primary) && EmptyTemplate(c.Primary.Folder) + && Leagues.Any(l => !l.Custom && l.Form.Equals(form, StringComparison.OrdinalIgnoreCase) && l.Base.Equals(c.Primary.Base, StringComparison.OrdinalIgnoreCase))) + .Select(c => c.Name)]; + + /// Why a module of a game mode is not offered for a league, and where it is: the tooltip of its row and + /// the refusal of . + public string ModeNote(string path) + { + string name = Systems.FirstOrDefault(s => s.Path.Equals(path, StringComparison.OrdinalIgnoreCase))?.Name ?? path; + return ModeStarts(path) is { Count: > 0 } starts + ? L.Text("{0} holds the rules of a game mode. It can be turned on for a league made in Waypoint that starts from one of: {1}.", name, string.Join(", ", starts)) + : L.Text("{0} holds the rules of a game mode, and goes with the leagues of that mode.", name); + } + /// Whether can be turned on for : any module, but one made - /// for an isolated league in a league that leads to Standard. - public bool ModuleOffered(GameLeague league, string path) => !IsolatedModule(path) || Isolated(league); + /// for an isolated league in a league that leads to Standard, and one of a game mode where that mode does not fit + /// (). : for a league made from this one, which is isolated and + /// its user's own. + public bool ModuleOffered(GameLeague league, string path, bool forNewLeague = false) => + (forNewLeague || !IsolatedModule(path) || Isolated(league)) && ModeFits(league, path, forNewLeague); public IReadOnlyList VisibilityPlan(GameLeague league, bool visible) { diff --git a/src/Launcher.Core/Resources/Strings.resx b/src/Launcher.Core/Resources/Strings.resx index 661c87c..cb07d84 100644 --- a/src/Launcher.Core/Resources/Strings.resx +++ b/src/Launcher.Core/Resources/Strings.resx @@ -900,6 +900,9 @@ Start on the newest changes. You update the copy yourself from Versions. + + Any installed module can be turned on or off here when what it needs is on. Turning off this league's own bundle asks first, a module made for an isolated league stays in isolated leagues, and the rules of a game mode go with that mode's leagues and with leagues made in Waypoint. + Start when you are ready. You can stop at any point, and the game can stay closed the whole time. @@ -1174,6 +1177,9 @@ Close the game and anything else using that folder, then try again. Not read yet. + + For the whole mode, go back and choose {0} as the game mode. + Errors and warnings only @@ -1409,6 +1415,9 @@ Change location above to choose somewhere else. Get Node.js + + {0} holds the rules of a game mode. The new league gets them without that mode's own skills, vendors and quest rewards, and the game does not show it as a league of that mode. + game running @@ -1944,6 +1953,9 @@ This checkout has modified tracked files. Waypoint mint + + Rules of a game mode + default @@ -3744,6 +3756,9 @@ Switching to it builds and runs that code on this computer with your rights, liv Eldritch implicits + + Here it gives the rules of a game mode only, without that mode's own skills, vendors and quest rewards. + Prefixes @@ -6675,6 +6690,9 @@ Steam layout and a newer official client are unsupported. The launcher does not The tested version could not be chosen (git exit {0}). + + {0} holds the rules of a game mode. It can be turned on for a league made in Waypoint that starts from one of: {1}. + {0} d ago @@ -7016,9 +7034,6 @@ Client: {2} LocalExile {0} is already installed here. - - Any installed module can be turned on or off here when what it needs is on. Turning off this league's own bundle asks first, and a module made for an isolated league stays in isolated leagues. - League settings @@ -7560,6 +7575,9 @@ Dependencies: {2} LocalExile as released: tested, and updated when you accept. + + {0} holds the rules of a game mode. Turned on here, they apply to every character in this league from the next server start, without that mode's own skills, vendors and quest rewards, and the game still shows the league as it is. Untick it to go back. + Not found @@ -8143,6 +8161,9 @@ Mods at backup: Delirium + + {0} holds the rules of a game mode, and goes with the leagues of that mode. + {0} of {1} accounts diff --git a/src/Launcher.Core/Resources/Strings.ru.resx b/src/Launcher.Core/Resources/Strings.ru.resx index ce19a89..4d5336b 100644 --- a/src/Launcher.Core/Resources/Strings.ru.resx +++ b/src/Launcher.Core/Resources/Strings.ru.resx @@ -900,6 +900,9 @@ Начать с последних изменений. Копию вы обновляете сами в разделе «Версии». + + Здесь можно включить или выключить любой установленный модуль, если включено всё, что ему требуется. Перед отключением собственного набора этой лиги Waypoint спросит подтверждение, модуль, созданный для изолированной лиги, остаётся в изолированных лигах, а правила режима игры относятся к лигам этого режима и к лигам, созданным в Waypoint. + Начните, когда будете готовы. Остановиться можно в любой момент, а игру всё это время можно не запускать. @@ -1174,6 +1177,9 @@ Ещё не прочитано. + + Чтобы получить режим целиком, вернитесь назад и выберите «{0}» в поле «Режим игры». + Только ошибки и предупреждения @@ -1409,6 +1415,9 @@ Скачать Node.js + + {0} содержит правила режима игры. Новая лига получит их без собственных умений, торговцев и наград за задания этого режима, и игра не будет показывать её как лигу этого режима. + игра запущена @@ -1944,6 +1953,9 @@ Мятная Waypoint + + Правила режима игры + основная @@ -3744,6 +3756,9 @@ Жуткие собственные свойства + + Здесь он даёт только правила режима игры, без собственных умений, торговцев и наград за задания этого режима. + Префиксы @@ -6675,6 +6690,9 @@ Не удалось выбрать проверенную версию (git завершился с кодом {0}). + + {0} содержит правила режима игры. Его можно включить для лиги, созданной в Waypoint на основе одной из этих: {1}. + {0} дн. назад @@ -7016,9 +7034,6 @@ LocalExile {0} уже установлен здесь. - - Здесь можно включить или выключить любой установленный модуль, если включено всё, что ему требуется. Перед отключением собственного набора этой лиги Waypoint спросит подтверждение, а модуль, созданный для изолированной лиги, остаётся в изолированных лигах. - Настройки лиги @@ -7560,6 +7575,9 @@ LocalExile в виде релиза: проверенный, обновляется, когда вы согласитесь. + + {0} содержит правила режима игры. Если включить его здесь, они будут действовать для всех персонажей этой лиги со следующего запуска сервера, без собственных умений, торговцев и наград за задания этого режима, а игра по-прежнему будет показывать лигу как есть. Снимите флажок, чтобы вернуть всё назад. + Не найдено @@ -8143,6 +8161,9 @@ Делириум + + {0} содержит правила режима игры и относится к лигам этого режима. + Аккаунтов: {0} из {1} diff --git a/src/Launcher.Core/Resources/Strings.zh-CN.resx b/src/Launcher.Core/Resources/Strings.zh-CN.resx index 7a1ff8e..3415673 100644 --- a/src/Launcher.Core/Resources/Strings.zh-CN.resx +++ b/src/Launcher.Core/Resources/Strings.zh-CN.resx @@ -900,6 +900,9 @@ 从最新更改开始。之后由你自己在“版本”部分更新此副本。 + + 只要所需的模块已启用,这里可以启用或停用任何已安装的模块。停用此联赛自身的模块组前会先询问,为独立联赛制作的模块只能用于独立联赛,游戏模式的规则则用于该模式的联赛以及在 Waypoint 中创建的联赛。 + 准备好后即可开始。你可以随时停止,整个过程中游戏都可以保持关闭。 @@ -1174,6 +1177,9 @@ 尚未读取。 + + 若要完整的模式,请返回上一步,将游戏模式选为“{0}”。 + 仅错误和警告 @@ -1409,6 +1415,9 @@ 获取 Node.js + + {0} 包含一种游戏模式的规则。新联赛会采用这些规则,但不包含该模式自身的技能、商人和任务奖励,游戏也不会把它显示为该模式的联赛。 + 游戏运行中 @@ -1944,6 +1953,9 @@ Waypoint 薄荷绿 + + 游戏模式的规则 + 默认 @@ -3744,6 +3756,9 @@ 异能固定词缀 + + 在这里它只提供一种游戏模式的规则,不包含该模式自身的技能、商人和任务奖励。 + 前缀 @@ -6675,6 +6690,9 @@ Gateway 最近报告的事件。打开 Gateway 输出查看详情。 无法选择经过测试的版本(git 退出代码 {0})。 + + {0} 包含一种游戏模式的规则。可以为在 Waypoint 中创建、并以下列之一为基础的联赛启用:{1}。 + {0} 天前 @@ -7016,9 +7034,6 @@ Gateway 最近报告的事件。打开 Gateway 输出查看详情。 此处已安装 LocalExile {0}。 - - 只要所需的模块已启用,这里可以启用或停用任何已安装的模块。停用此联赛自身的模块组前会先询问,为独立联赛制作的模块只能用于独立联赛。 - 联盟设置 @@ -7560,6 +7575,9 @@ Gateway 最近报告的事件。打开 Gateway 输出查看详情。 已发布的 LocalExile:经过测试,在你同意时更新。 + + {0} 包含一种游戏模式的规则。在此启用后,这些规则将从下次服务器启动起对此联赛的所有角色生效,但不包含该模式自身的技能、商人和任务奖励,游戏仍按原样显示此联赛。取消勾选即可恢复。 + 未找到 @@ -8143,6 +8161,9 @@ Gateway 最近报告的事件。打开 Gateway 输出查看详情。 惊悸迷雾 + + {0} 包含一种游戏模式的规则,用于该模式的联赛。 + {0} / {1} 个账号 diff --git a/src/Waypoint/GameSystemsTab.Draft.cs b/src/Waypoint/GameSystemsTab.Draft.cs index 178719c..c1a3830 100644 --- a/src/Waypoint/GameSystemsTab.Draft.cs +++ b/src/Waypoint/GameSystemsTab.Draft.cs @@ -119,6 +119,23 @@ void RenderDraftModules() string DraftBundleWarning() => _catalog is not null && _draftTemplate is not null && _catalog.BundleLeftOut(_draftTemplate, _draftModules) is { Count: > 0 } left ? L.Text("Without {0}, the new league has the mode of {1} but not its rules or content.", string.Join(", ", left.Select(ModuleTitle)), _draftTemplate.Name) : ""; + /// What a module of a game mode means in a new league of another mode: the rules without the rest of the + /// mode, and where the whole mode is to be had. Empty when the draft has none. + string DraftModeWarning() + { + if (_catalog is null || _draftTemplate is null || _catalog.RulesOnly(_draftTemplate, _draftModules) is not { Count: > 0 } rules) return ""; + // The whole mode is a choice of the first step, where the starting flag has a league of that mode to copy. + var whole = _draftCandidates.FirstOrDefault(c => ReferenceEquals(_catalog.FlagOf(c), _catalog.FlagOf(_draftTemplate)) + && c.Hardcore == _draftTemplate.Hardcore && c.Ssf == _draftTemplate.Ssf + && rules.Any(m => c.Form.Equals(_catalog.ModeOf(m.Path), StringComparison.OrdinalIgnoreCase))); + return L.Text("{0} holds the rules of a game mode. The new league gets them without that mode's own skills, vendors and quest rewards, and the game does not show it as a league of that mode.", + string.Join(", ", rules.Select(ModuleTitle))) + + (whole is null ? "" : " " + L.Text("For the whole mode, go back and choose {0} as the game mode.", _catalog.ModePath(whole))); + } + + /// Everything the draft calls for a word about before the league is made. + string DraftWarnings() => string.Join(" ", new[] { DraftBundleWarning(), DraftModeWarning() }.Where(text => text.Length > 0)); + string? DraftError() { if (_draftTemplate is null || _catalog is null) return L.Text("Choose a starting league." ); @@ -139,7 +156,7 @@ void UpdateDraftFeedback() // Nothing waits for the servers to stop: LocalExile reads its leagues when a server starts, so a league made // while one runs is there at its next start. else _validation.Text = error is not null ? L.Text("Cannot create: {0}", error) - : L.Text("Ready to create. Existing leagues and saves are preserved.") + (DraftBundleWarning() is { Length: > 0 } apart ? " " + apart : ""); + : L.Text("Ready to create. Existing leagues and saves are preserved.") + (DraftWarnings() is { Length: > 0 } apart ? " " + apart : ""); if (_primary is not null) _primary.IsEnabled = !Busy && error is null; } async Task CreateLeagueAsync() @@ -151,7 +168,7 @@ async Task CreateLeagueAsync() var request = _catalog.PlanCreate(_draftTemplate, name, _draftDescription?.Text ?? "", _draftModules); string consequence = _draftTemplate.Hardcore ? L.Text("Hardcore death in this custom league is permanent.") : L.Text("Its characters and stash stay separate from Standard."); // The new league takes its mode from the league it starts from, whose own bundle may have been unticked. - string apart = DraftBundleWarning(); + string apart = DraftWarnings(); if (!Dialog.Ask(Owner, apart.Length > 0 ? DialogKind.Warning : DialogKind.Question, L.Text("Create league"), L.Text("Create the league \"{0}\" in {1} mode? {2} Existing leagues and saves are preserved.", name, _catalog.Modes(_draftTemplate), consequence) + (apart.Length > 0 ? "\n\n" + apart : ""), L.Text("Create"), L.Text("Cancel"))) return; diff --git a/src/Waypoint/GameSystemsTab.cs b/src/Waypoint/GameSystemsTab.cs index ed20d01..044aad0 100644 --- a/src/Waypoint/GameSystemsTab.cs +++ b/src/Waypoint/GameSystemsTab.cs @@ -374,7 +374,7 @@ void RenderLeague(GameLeague league) bool reusable = !league.Custom && _catalog.Configurable(league) && GameSystems.EmptyTemplate(league.Folder); customize.IsEnabled = reusable && _catalog.Environment.CanCreate; details.Children.Add(customize); if (!reusable) details.Children.Add(SettingsEditor.Note(L.Text("This league has custom code or no reusable source template. It cannot be safely copied."))); - details.Children.Add(SettingsEditor.Note(L.Text("Any installed module can be turned on or off here when what it needs is on. Turning off this league's own bundle asks first, and a module made for an isolated league stays in isolated leagues."))); + details.Children.Add(SettingsEditor.Note(L.Text("Any installed module can be turned on or off here when what it needs is on. Turning off this league's own bundle asks first, a module made for an isolated league stays in isolated leagues, and the rules of a game mode go with that mode's leagues and with leagues made in Waypoint."))); details.Children.Add(SettingsEditor.Label(L.Text("Selected league definition: {0}", league.Name))); if (league.EntryOf.Length > 0) details.Children.Add(SettingsEditor.Note(L.Text("Shown as a mode of: {0}", league.EntryOf))); if (league.Parent.Length > 0) details.Children.Add(SettingsEditor.Note(L.Text("Parent league: {0}", league.Parent))); @@ -410,8 +410,12 @@ void ChoiceChanged() { bool selected = (_creating ? (IEnumerable)_draftModules : league.Systems).Contains(module.Path, StringComparer.OrdinalIgnoreCase); // Any module goes with any league, but one made for an isolated league in a league that leads to Standard - // (GameSystems.ModuleOffered). A league being made is isolated whatever its template is. - bool offered = _creating || _catalog.ModuleOffered(league, module.Path), locked = required.Contains(module.Path); + // and one of a game mode where that mode does not fit (GameSystems.ModuleOffered). A league being made is + // isolated, and its user's own, whatever its template is. + bool offered = _catalog.ModuleOffered(league, module.Path, forNewLeague: _creating), locked = required.Contains(module.Path); + // The rules of a game mode, in a league of another mode: on, they are that mode's rules alone. + bool ofMode = _catalog.ModeOf(module.Path) is not null, rulesOnly = _catalog.RulesOnly(league, [module.Path]).Count > 0; + string whyNot = ofMode ? L.Text("Rules of a game mode") : L.Text("For isolated leagues only"); string name = ModuleTitle(module); var box = Named(new CheckBox { Content = ModuleLabel(module), IsChecked = selected, IsEnabled = editable && !locked && (selected || offered), HorizontalAlignment = HorizontalAlignment.Stretch }, name); _checks[module.Path] = box; @@ -419,7 +423,7 @@ void ChoiceChanged() if (locked || !editable || !offered && !selected) { var readOnly = new DockPanel(); - var state = Badge(locked ? L.Text("Required") : !offered ? L.Text("For isolated leagues only") : selected ? L.Text("Enabled") : L.Text("Disabled")); + var state = Badge(locked ? L.Text("Required") : !offered ? whyNot : selected ? L.Text("Enabled") : L.Text("Disabled")); state.Margin = new Thickness(12, 0, 0, 0); DockPanel.SetDock(state, Dock.Right); readOnly.Children.Add(state); var mark = Type(selected ? "✓" : "–", 13, false, "Shell.TextSecondary"); mark.Margin = new Thickness(0, 0, 12, 0); DockPanel.SetDock(mark, Dock.Left); readOnly.Children.Add(mark); readOnly.Children.Add(ModuleLabel(module)); row = readOnly; @@ -427,7 +431,9 @@ void ChoiceChanged() else row = box; var holder = Card(row, 10, "Shell.Background"); holder.Margin = new Thickness(0, 0, 0, 6); Named(holder, name + (locked ? " · " + L.Text("Required") : "")); - string help = module.Description.Length > 0 ? module.Description : locked ? L.Text("Required by this league's gameplay bundle.") : !offered ? L.Text("For isolated leagues only") : L.Text("Optional module for this mode."); + string help = module.Description.Length > 0 ? module.Description : locked ? L.Text("Required by this league's gameplay bundle.") : !offered ? ofMode ? "" : whyNot : L.Text("Optional module for this mode."); + if (!offered && ofMode) help += (help.Length > 0 ? "\n" : "") + _catalog.ModeNote(module.Path); + if (rulesOnly && (offered || selected)) help += "\n" + L.Text("Here it gives the rules of a game mode only, without that mode's own skills, vendors and quest rewards."); if (module.Depends.Length > 0) help += "\n" + L.Text("Dependencies: {0}", string.Join(", ", module.Depends)); // The league's own bundle is a box like any other; what turning it off means is said once it is unticked. if (bundle.Contains(module.Path, StringComparer.OrdinalIgnoreCase)) help += "\n" + L.Text("Part of this league's own bundle. Turning it off asks first."); @@ -496,7 +502,7 @@ void UpdateFeedback() else if (_selected is GameLeague league) { string? error = _catalog.CompositionError(league, SelectedModules()); - string apart = error is null && _choicesDirty ? BundleWarning(league) : ""; + string apart = error is null && _choicesDirty ? Warnings(league) : ""; _validation.Text = error is not null ? L.Text("Cannot save: {0}", error) : !_catalog.Environment.CanChoose ? L.Text("Read-only module list. Update LocalExile to edit these choices.") : _editor?.Dirty == true ? L.Text("Save league settings before applying module choices.") : _choicesDirty ? L.Text("Unsaved module choices — applies after a server restart.") + (apart.Length > 0 ? " " + apart : "") : L.Text("No unsaved changes."); @@ -596,13 +602,24 @@ async Task SaveSettingsAsync(bool defaults = false) string BundleWarning(GameLeague league) => _catalog!.BundleLeftOut(league, SelectedModules()) is { Count: > 0 } left ? L.Text("Without {0}, this league runs without the rules or content it is named for. Its characters stay as they are, and you can turn it back on.", string.Join(", ", left.Select(ModuleTitle))) : ""; + /// What a module of a game mode means in a league of another mode (), said + /// when the ticked boxes turn one on: the mode's rules, for every character there, without the rest of the mode. + /// Empty when none is being turned on. + string ModeWarning(GameLeague league) => _catalog!.RulesOnly(league, SelectedModules()) + .Where(m => !league.Systems.Contains(m.Path, StringComparer.OrdinalIgnoreCase)).ToArray() is { Length: > 0 } turnedOn + ? L.Text("{0} holds the rules of a game mode. Turned on here, they apply to every character in this league from the next server start, without that mode's own skills, vendors and quest rewards, and the game still shows the league as it is. Untick it to go back.", + string.Join(", ", turnedOn.Select(ModuleTitle))) : ""; + + /// Everything the ticked boxes call for a word about before they are saved. + string Warnings(GameLeague league) => string.Join(" ", new[] { BundleWarning(league), ModeWarning(league) }.Where(text => text.Length > 0)); + async Task SaveChoicesAsync(GameLeague league) { if (_catalog is null || Busy) return; try { var values = _catalog.Plan(league, SelectedModules()); - string apart = BundleWarning(league); + string apart = Warnings(league); if (!Dialog.Ask(Owner, apart.Length > 0 ? DialogKind.Warning : DialogKind.Question, L.Text("Save league choices"), L.Text("Save module choices for {0}? They apply after a server restart. Existing characters and other leagues are preserved.", league.Name) + (apart.Length > 0 ? "\n\n" + apart : ""), L.Text("Save"), L.Text("Cancel"))) return; diff --git a/tests/LeagueData.Tests.py b/tests/LeagueData.Tests.py index 69f6576..c2cbc25 100644 --- a/tests/LeagueData.Tests.py +++ b/tests/LeagueData.Tests.py @@ -150,16 +150,16 @@ def choose(self, league, add=(), remove=()): def test_any_module_goes_with_any_league_but_one_made_for_an_isolated_league(self): self.standard_as_shipped() - self.profile("Ruthless", ["Core/Game", "Core/Vendors", "Extra/X"], base="Standard", parent="Standard", form="ruthless") + self.profile("Phrecia", ["Core/Game", "Core/Vendors", "Extra/X"], base="Standard", parent="Standard") # A core module the league does not ship with, and another league's own module: a module has no knowledge of # leagues, and any league can list it. - self.run_request(self.choose("Ruthless", ["Core/Harvest"]), action="SaveLeagueModules") + self.run_request(self.choose("Phrecia", ["Core/Harvest"]), action="SaveLeagueModules") self.run_request(self.choose("Standard", ["Extra/X"]), action="SaveLeagueModules") self.run_request(self.choose("Survivors", ["Core/Vendors", "Extra/X", "Extra/Y"]), action="SaveLeagueModules") saved = data.read_json(self.choices) - self.assertEqual((saved["Ruthless"]["add"], saved["Standard"]["add"]), (["Core/Harvest"], ["Extra/X"])) + self.assertEqual((saved["Phrecia"]["add"], saved["Standard"]["add"]), (["Core/Harvest"], ["Extra/X"])) # A module LocalExile ships only in an isolated league stays out of the leagues that lead to Standard... - for league in ("Standard", "Ruthless"): + for league in ("Standard", "Phrecia"): with self.assertRaisesRegex(data.AccountError, "isolated"): self.run_request(self.choose(league, ["Survivors/Skills"]), action="SaveLeagueModules") # ...goes with another isolated league, and with a new league, which is isolated whatever it is made from. @@ -171,6 +171,40 @@ def test_any_module_goes_with_any_league_but_one_made_for_an_isolated_league(sel with self.assertRaisesRegex(data.AccountError, "needs"): self.run_request(self.choose("Hardcore", ["Survivors/Run"]), action="SaveLeagueModules") + def test_the_rules_of_a_game_mode_go_with_that_mode_and_with_a_league_made_in_waypoint_on_a_base_that_has_it(self): + self.standard_as_shipped() + # As LocalExile ships Ruthless: a module listed by the leagues of the form "ruthless" and by no other. + self.profile("Ruthless", ["Core/Game", "Core/Vendors", "Extra/X"], base="Standard", parent="Standard", form="ruthless", dataSet="HardMode") + for name, base, modules in (("My Event", "Standard", ["Core/Game", "Core/Vendors"]), ("My Run", "Survivors", ["Core/Game", "Survivors/Skills"])): + self.profile(name, modules, base=base) + self.write(self.leagues / name / ".waypoint-league.json", {"version": 1, "template": base}) + # The leagues LocalExile ships in another mode have their own versions in that mode, and stay as they are. + for league in ("Standard", "SSF Standard", "Survivors"): + with self.assertRaisesRegex(data.AccountError, "game mode"): + self.run_request(self.choose(league, ["Extra/X"]), action="SaveLeagueModules") + # A league made in Waypoint can have the rules when its game base has that mode; one made from Survivors cannot. + self.run_request(self.choose("My Event", ["Extra/X"]), action="SaveLeagueModules") + self.assertEqual(data.read_json(self.choices)["My Event"]["add"], ["Extra/X"]) + with self.assertRaisesRegex(data.AccountError, "game mode"): + self.run_request(self.choose("My Run", ["Extra/X"]), action="SaveLeagueModules") + # The same for a league about to be made. + request = self.request(name="My Hard Event") + request["modules"].append("Extra/X") + self.run_request(request) + request = self.request("Survivors", "My Hard Run") + request["modules"].append("Extra/X") + with self.assertRaisesRegex(data.AccountError, "game mode"): + self.run_request(request) + # In a league of that mode it is a box like any other: off, and on again. + self.run_request(self.choose("Ruthless", remove=["Extra/X"]), action="SaveLeagueModules") + self.run_request(self.choose("Ruthless"), action="SaveLeagueModules") + # One already on where it does not fit, by a hand edit, stays while another change is saved... + self.write(self.choices, {"Standard": {"add": ["Extra/X"], "remove": []}}) + self.run_request(self.choose("Standard", ["Extra/X", "Extra/Y"]), action="SaveLeagueModules") + # ...and once a league LocalExile ships in another mode lists it, the files say it is no longer one mode's. + self.write(self.leagues / "SSF Standard/modules.json", {"modules": ["Core/Game", "Core/Vendors", "Extra/X"]}) + self.run_request(self.choose("Survivors", ["Extra/X"]), action="SaveLeagueModules") + def test_a_module_no_shipped_league_lists_is_an_add_on_that_is_never_required(self): # Extra/X is in no league's list: an add-on, as PlayerBots is. LocalExile's own guide turns it on this way. shipped = (self.leagues / "Standard/modules.json").read_text(encoding="utf-8") diff --git a/tests/Waypoint.Tests/LeagueCustomizationTests.cs b/tests/Waypoint.Tests/LeagueCustomizationTests.cs index b3f5524..fb708c2 100644 --- a/tests/Waypoint.Tests/LeagueCustomizationTests.cs +++ b/tests/Waypoint.Tests/LeagueCustomizationTests.cs @@ -52,45 +52,122 @@ public void Isolated_void_may_keep_its_core_game_foundation_but_no_gameplay_addo public void Any_module_goes_with_any_league_but_one_made_for_an_isolated_league() { Catalog(); - // A league that leads to Standard, with a module of its own, as Ruthless and Phrecia are. - Write("Modules/Ruthless/module.json", """{"id":"Ruthless","depends":["Game"]}"""); - Write("Leagues/Ruthless/league.json", """{"name":"Ruthless","base":"Standard","parent":"Standard","form":"ruthless","description":"Fixture."}"""); - Write("Leagues/Ruthless/modules.json", """{"modules":["Core/Game","Core/Vendors","Ruthless"]}"""); - Write("Leagues/Ruthless/Source/Fixture.cs", "public sealed class RuthlessLeague : League { }"); + // A league that leads to Standard, with a module of its own, as Phrecia is. + Write("Modules/PhreciaAscendancies/module.json", """{"id":"PhreciaAscendancies","depends":["Game"]}"""); + Write("Leagues/Phrecia/league.json", """{"name":"Phrecia","base":"Standard","parent":"Standard","description":"Fixture."}"""); + Write("Leagues/Phrecia/modules.json", """{"modules":["Core/Game","Core/Vendors","PhreciaAscendancies"]}"""); + Write("Leagues/Phrecia/Source/Fixture.cs", "public sealed class PhreciaLeague : League { }"); var catalog = new GameSystems(Environment); var standard = catalog.Leagues.Single(l => l.Name == "Standard"); var survivors = catalog.Leagues.Single(l => l.Name == "Survivors"); - var ruthless = catalog.Leagues.Single(l => l.Name == "Ruthless"); + var phrecia = catalog.Leagues.Single(l => l.Name == "Phrecia"); Assert.False(catalog.Isolated(standard)); - Assert.False(catalog.Isolated(ruthless)); + Assert.False(catalog.Isolated(phrecia)); Assert.True(catalog.Isolated(survivors)); // A core module the league does not ship with, and another league's own module: a module has no knowledge of // leagues, and any league can list it. - Assert.True(catalog.ModuleOffered(ruthless, "Core/Harvest")); - Assert.Null(catalog.CompositionError(ruthless, ["Core/Game", "Core/Vendors", "Ruthless", "Core/Harvest"])); - Assert.True(catalog.ModuleOffered(standard, "Ruthless")); - Assert.Null(catalog.CompositionError(standard, ["Core/Game", "Core/Vendors", "Ruthless"])); + Assert.True(catalog.ModuleOffered(phrecia, "Core/Harvest")); + Assert.Null(catalog.CompositionError(phrecia, ["Core/Game", "Core/Vendors", "PhreciaAscendancies", "Core/Harvest"])); + Assert.True(catalog.ModuleOffered(standard, "PhreciaAscendancies")); + Assert.Null(catalog.CompositionError(standard, ["Core/Game", "Core/Vendors", "PhreciaAscendancies"])); Assert.True(catalog.ModuleOffered(survivors, "Core/Vendors")); - Assert.Null(catalog.CompositionError(survivors, ["Core/Game", "Survivors/Run", "Core/Vendors", "Ruthless"])); + Assert.Null(catalog.CompositionError(survivors, ["Core/Game", "Survivors/Run", "Core/Vendors", "PhreciaAscendancies"])); // A module LocalExile ships only in an isolated league stays out of the leagues that lead to Standard... Assert.True(catalog.IsolatedModule("Survivors/Run")); - Assert.False(catalog.IsolatedModule("Ruthless")); + Assert.False(catalog.IsolatedModule("PhreciaAscendancies")); Assert.False(catalog.IsolatedModule("Core/Game")); Assert.False(catalog.ModuleOffered(standard, "Survivors/Run")); - Assert.False(catalog.ModuleOffered(ruthless, "Survivors/Run")); + Assert.False(catalog.ModuleOffered(phrecia, "Survivors/Run")); Assert.NotNull(catalog.CompositionError(standard, ["Core/Game", "Core/Vendors", "Survivors/Run"])); // ...and goes with a new league, which is isolated whatever it is made from. Assert.Null(catalog.CompositionError(standard, ["Core/Game", "Core/Vendors", "Survivors/Run"], forNewLeague: true)); Assert.NotNull(catalog.PlanCreate(standard, "My Event", "Custom.", ["Core/Game", "Core/Vendors", "Survivors/Run"])); // The game is what LocalExile requires, and the one box that stays locked. - Assert.Equal(["Core/Game"], catalog.RequiredModules(ruthless)); + Assert.Equal(["Core/Game"], catalog.RequiredModules(phrecia)); Assert.Equal(["Core/Game"], catalog.RequiredModules(survivors)); Assert.NotNull(catalog.CompositionError(standard, ["Core/Vendors"])); Assert.Null(catalog.CompositionError(standard, ["Core/Game", "Core/Vendors"])); } [Fact] + public void The_rules_of_a_game_mode_go_with_that_mode_and_with_a_league_made_in_Waypoint_on_a_base_that_has_it() + { + Catalog(); + // As LocalExile ships Ruthless: one module, listed by the leagues of the form "ruthless" and by no other. + Write("Modules/Ruthless/module.json", """{"id":"Ruthless","depends":["Game"]}"""); + Write("Modules/PlayerBots/module.json", """{"id":"PlayerBots","depends":["Game"]}"""); + foreach (var (name, flags) in new[] { ("Ruthless", ",\"entryOf\":\"Standard\",\"entryKind\":\"form\""), ("SSF Ruthless", ",\"ssf\":true,\"entryOf\":\"SSF Standard\",\"entryKind\":\"form\"") }) + { + Write($"Leagues/{name}/league.json", "{\"name\":\"" + name + "\",\"base\":\"Standard\",\"parent\":\"Standard\",\"form\":\"ruthless\",\"dataSet\":\"HardMode\",\"description\":\"Fixture.\"" + flags + "}"); + Write($"Leagues/{name}/modules.json", """{"modules":["Core/Game","Core/Vendors","Ruthless"]}"""); + Write($"Leagues/{name}/Source/Fixture.cs", "// template\npublic sealed class FixtureLeague : League { }"); + } + // Leagues made in Waypoint: one from Standard, one from Survivors. + Profile("My Event", "Standard", """["Core/Game","Core/Vendors"]"""); Write("Leagues/My Event/.waypoint-league.json", """{"version":1,"template":"Standard"}"""); + Profile("My Run", "Survivors", """["Core/Game","Survivors/Run"]"""); Write("Leagues/My Run/.waypoint-league.json", """{"version":1,"template":"Survivors"}"""); + var catalog = new GameSystems(Environment); + GameLeague League(string name) => catalog.Leagues.Single(l => l.Name == name); + + // The mode is read from the leagues that list the module, never from a name. + Assert.Equal("ruthless", catalog.ModeOf("Ruthless")); + Assert.Null(catalog.ModeOf("Core/Vendors")); // listed by leagues of that mode and of none + Assert.Null(catalog.ModeOf("Survivors/Run")); // its league has no mode + Assert.Null(catalog.ModeOf("PlayerBots")); // listed by no league + + // In a league of that mode it is the league's own. + Assert.True(catalog.ModuleOffered(League("Ruthless"), "Ruthless")); + Assert.Empty(catalog.RulesOnly(League("Ruthless"), ["Core/Game", "Ruthless"])); + // The leagues LocalExile ships in another mode have their own versions in that mode, and stay as they are. + foreach (string name in new[] { "Standard", "SSF Standard", "Survivors" }) + { + Assert.False(catalog.ModuleOffered(League(name), "Ruthless")); + Assert.Contains("Standard", catalog.CompositionError(League(name), [.. League(name).BaseSystems, "Ruthless"])); + } + // A league made in Waypoint can have the rules, when the game base it was made on has that mode... + Assert.True(catalog.ModuleOffered(League("My Event"), "Ruthless")); + Assert.Null(catalog.CompositionError(League("My Event"), ["Core/Game", "Core/Vendors", "Ruthless"])); + // ...and its user is told that these are the rules without the rest of the mode. + Assert.Equal("Ruthless", Assert.Single(catalog.RulesOnly(League("My Event"), ["Core/Game", "Core/Vendors", "Ruthless"])).Path); + Assert.Empty(catalog.RulesOnly(League("My Event"), ["Core/Game", "Core/Vendors"])); + // Survivors' own base has no league of that mode, so a league made from Survivors does not get it. + Assert.False(catalog.ModuleOffered(League("My Run"), "Ruthless")); + Assert.NotNull(catalog.CompositionError(League("My Run"), ["Core/Game", "Survivors/Run", "Ruthless"])); + + // The same for a league about to be made, and where one can start to have it. + Assert.True(catalog.ModuleOffered(League("Standard"), "Ruthless", forNewLeague: true)); + Assert.NotNull(catalog.PlanCreate(League("Standard"), "My Hard Event", "Custom.", ["Core/Game", "Core/Vendors", "Ruthless"])); + Assert.False(catalog.ModuleOffered(League("Survivors"), "Ruthless", forNewLeague: true)); + Assert.Throws(() => catalog.PlanCreate(League("Survivors"), "My Hard Run", "Custom.", ["Core/Game", "Survivors/Run", "Ruthless"])); + Assert.Equal(["Standard"], catalog.ModeStarts("Ruthless")); + Assert.Empty(catalog.ModeStarts("PlayerBots")); + + // One that is already on where it does not fit, by a hand edit, stays until its user unticks it: another change + // still saves. It is not turned on anew, there or elsewhere. + Write("data/league-modules.json", """{"Standard":{"add":["Ruthless"],"remove":[]}}"""); + catalog = new(Environment); + Assert.Contains("Ruthless", League("Standard").Systems); + Assert.False(catalog.ModuleOffered(League("Standard"), "Ruthless")); + Assert.Null(catalog.CompositionError(League("Standard"), [.. League("Standard").Systems, "PlayerBots"])); + Assert.Single(catalog.RulesOnly(League("Standard"), League("Standard").Systems)); + Assert.NotNull(catalog.CompositionError(League("SSF Standard"), [.. League("SSF Standard").Systems, "Ruthless"])); + + // A league made in Waypoint that lists the module does not change what the module is... + Write("Leagues/My Event/modules.json", """{"modules":["Core/Game","Core/Vendors","Ruthless"]}"""); + catalog = new(Environment); + Assert.Equal("ruthless", catalog.ModeOf("Ruthless")); + // There it is an extra, not the league's own bundle: unticking it takes it back and says nothing about what + // the league is named for. In a league of that mode it is the bundle. + Assert.DoesNotContain("Ruthless", catalog.BundleModules(League("My Event"))); + Assert.Empty(catalog.BundleLeftOut(League("My Event"), ["Core/Game", "Core/Vendors"])); + Assert.Contains("Ruthless", catalog.BundleModules(League("Ruthless"))); + // ...and once a league LocalExile ships in another mode lists it, the files say it is no longer one mode's. + Write("Leagues/Standard/modules.json", """{"modules":["Core/Game","Core/Vendors","Core/Harvest","Ruthless"]}"""); + catalog = new(Environment); + Assert.Null(catalog.ModeOf("Ruthless")); + Assert.True(catalog.ModuleOffered(League("SSF Standard"), "Ruthless")); + } + [Fact] public void A_league_can_run_without_its_own_bundle_and_its_user_is_told_what_is_left_out() { Catalog();