// ServerPackInfo.cs - What a server plugin knows about its game server (shared by every server plugin).
//
// Identity (id, name, hosts, world names) comes from the plugin's csproj through RynthPluginInfo, the
// same values the engine reads from the embedded manifest, so detection has one source. The rest is
// what is publicly known about the server (ServerData.cs in each project): connection, rule set,
// summary, links, account limits and the botting policy. Unknown stays empty; nothing is guessed.
// Pure: RynthServerPack.Tests compiles it.
using System;
namespace RynthCore.Plugin.ServerPack;
/// What the server's rules say about bots (RynthAi automation).
internal enum BottingPolicy
{
/// Not published here: check the server's own rules.
Unknown,
Allowed,
/// Allowed with limits (attended only, a client cap, ...): see .
Restricted,
/// The server forbids bots.
Forbidden,
}
/// A chat command the server adds, and what it does.
internal sealed record ServerCommand(string Command, string What);
///
/// A salvage the server's own recipes apply (beyond retail tinkering), shown on the Mini Remote's
/// Crafting tab under "Server tinkering".
///
/// The Crafting tab: "armor", "melee", "missile", "caster", "jewelry", "items" or "trinkets".
/// The bag's MaterialType (131), e.g. 64 = Steel.
/// What it does, one short line.
/// "tink" (repeatable), "imbue" (one per item) or "once" (one application).
/// Counts toward the item's 10 tinks.
/// The bag's name must contain this (bags that share a material id); "" = any.
/// An int property of the item that reads 2 once this salvage is on it (0 = none).
/// The bag must first be prepared on the chosen tier's Ammunition (its name then carries the tier).
/// Apply order on the tab (lower first); 0 = by kind (imbues, then tinks, then one-application rows).
/// Applied last, and only once the item's tink slots are full.
/// Rows with the same group share one cap per item (); "" = none.
/// The group's combined cap per item (with ).
internal sealed record ServerSalvage(string Bench, int Material, string Effect, string Kind = "tink",
bool UsesTinkSlot = true, string NameMatch = "", int AppliedInt = 0,
bool Prepared = false, int Order = 0, bool AfterCap = false,
string StackGroup = "", int StackCap = 0);
internal sealed class ServerPackInfo
{
public ServerPackInfo(string id, string name, string[] hosts, string[] worldNames)
{
Id = (id ?? string.Empty).Trim().ToLowerInvariant();
Name = string.IsNullOrWhiteSpace(name) ? Id : name.Trim();
Hosts = hosts ?? Array.Empty();
WorldNames = worldNames ?? Array.Empty();
}
/// The engine's id for the server ("coldeve"); a built-in one ("ilt", "aelrynth") keeps the engine's own detection.
public string Id { get; }
public string Name { get; }
/// Connect hosts (the first is the one players are given).
public string[] Hosts { get; }
/// World names the server announces at login.
public string[] WorldNames { get; }
public int Port { get; init; } = 9000;
/// "ACE" or "GDLE" (the launcher's emulator setting).
public string Emulator { get; init; } = "ACE";
/// "PvE" or "PvP".
public string Ruleset { get; init; } = "PvE";
/// "Stable", "Development", ... as the server list says.
public string Status { get; init; } = string.Empty;
/// The server's own one-paragraph description.
public string Summary { get; init; } = string.Empty;
/// Notable rules and features, one line each.
public string[] Facts { get; init; } = Array.Empty();
/// Chat commands the server adds (only ones known to exist).
public ServerCommand[] Commands { get; init; } = Array.Empty();
/// The server's own tinkering salvage (only recipes known to exist); empty = none defined.
public ServerSalvage[] Salvage { get; init; } = Array.Empty();
///
/// Jewelry that is a trinket on this server (the Crafting tab's Trinkets bench, not Jewelry): name
/// words, case-insensitive, and words that rule a name out again ("top" but not "topaz"). Empty:
/// the server has no trinkets (retail: every jewelry piece is Jewelry).
///
public string[] TrinketNames { get; init; } = Array.Empty();
public string[] TrinketExcept { get; init; } = Array.Empty();
/// "3 accounts", "3 active characters", ...; empty when not published.
public string AccountLimit { get; init; } = string.Empty;
public BottingPolicy Botting { get; init; } = BottingPolicy.Unknown;
/// The rule in the server's words, when there is one.
public string BottingNote { get; init; } = string.Empty;
public string Discord { get; init; } = string.Empty;
public string Website { get; init; } = string.Empty;
public string Wiki { get; init; } = string.Empty;
/// Where the facts come from, and when they were checked.
public string Source { get; init; } = string.Empty;
/// "play.coldeve.ac:9000" (the first host), or "" with none.
public string Address => Hosts.Length == 0 ? string.Empty : Hosts[0] + ":" + Port;
/// The botting line for the card.
public string BottingText => Botting switch
{
BottingPolicy.Allowed => "Allowed" + (BottingNote.Length > 0 ? " - " + BottingNote : string.Empty),
BottingPolicy.Restricted => "Restricted" + (BottingNote.Length > 0 ? " - " + BottingNote : string.Empty),
BottingPolicy.Forbidden => "Forbidden" + (BottingNote.Length > 0 ? " - " + BottingNote : string.Empty),
_ => "Not published here - check the server's rules" + (Discord.Length > 0 ? " (Discord)" : string.Empty),
};
}