Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
37 changes: 28 additions & 9 deletions docs/launcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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`).
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
19 changes: 18 additions & 1 deletion scripts/LeagueData.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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):
Expand Down
68 changes: 62 additions & 6 deletions src/Launcher.Core/LeagueCustomization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 (<see cref="BundleLeftOut"/>). 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.</summary>
/// a listed module that is not installed, nor the rules of a game mode in a league of another mode
/// (<see cref="RulesOnly"/>): ticked for a league made in Waypoint, they are an extra that unticking takes back.</summary>
public IReadOnlyList<string> 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)))];

/// <summary>The modules of the league's own bundle that <paramref name="paths"/> leaves out: what its user is told,
/// by the names the list shows, and asked to confirm.</summary>
Expand All @@ -118,8 +119,9 @@ public IReadOnlyList<GameSystem> BundleLeftOut(GameLeague league, IEnumerable<st
bool Installed(string path) => Systems.Any(s => s.Path.Equals(path, StringComparison.OrdinalIgnoreCase));

/// <summary>Whether the modules in <paramref name="paths"/> can run together for <paramref name="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 (<see cref="IsolatedModule"/>). 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 (<see cref="IsolatedModule"/>), and the rules of a game mode only where that mode fits
/// (<see cref="ModeOf"/>). A module has no knowledge of leagues (LocalExile's
/// <c>Agents/docs/dev/modules.md</c>), 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 (<see cref="BundleLeftOut"/>).
/// <paramref name="forNewLeague"/>: the modules are for a league made from this one, which is isolated whatever its
Expand All @@ -130,6 +132,10 @@ public void ValidateComposition(GameLeague league, IReadOnlyCollection<string> 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))))
Expand Down Expand Up @@ -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);

/// <summary>The game mode a module goes with, as the leagues LocalExile ships say it: every one of them that lists
/// the module has that <c>form</c> (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.</summary>
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;
}

/// <summary>Whether a module of a game mode may be on in <paramref name="league"/>. 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 (<see cref="RulesOnly"/>), 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.</summary>
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));

/// <summary>The modules of a game mode among <paramref name="paths"/> that are not of <paramref name="league"/>'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 (<c>dataSet</c>), which a module does not
/// change, and the game shows the league by its <c>form</c>. What the interface says before it saves.</summary>
public IReadOnlyList<GameSystem> RulesOnly(GameLeague league, IEnumerable<string> 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<GameSystem>()];

/// <summary>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.</summary>
public IReadOnlyList<string> 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)];

/// <summary>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 <see cref="ValidateComposition"/>.</summary>
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);
}

/// <summary>Whether <paramref name="path"/> can be turned on for <paramref name="league"/>: any module, but one made
/// for an isolated league in a league that leads to Standard.</summary>
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
/// (<see cref="ModeOf"/>). <paramref name="forNewLeague"/>: for a league made from this one, which is isolated and
/// its user's own.</summary>
public bool ModuleOffered(GameLeague league, string path, bool forNewLeague = false) =>
(forNewLeague || !IsolatedModule(path) || Isolated(league)) && ModeFits(league, path, forNewLeague);

public IReadOnlyList<GameLeague> VisibilityPlan(GameLeague league, bool visible)
{
Expand Down
Loading
Loading