XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEEDToolBox

【WinUI】XFE精英危险工具箱

公开
关注 0 Fork 0 Star 0
UTF-8
using XFEEDToolBox.Core.Models;

namespace XFEEDToolBox.Core.Planning;

public static class StationSourcePolicy
{
    // Journal and public-catalog spellings are kept together. In particular SurfaceStation
    // is a settlement, and a construction depot is not evidence of a completed starport.
    // Source: https://github.com/EDCD/EDDI/blob/develop/DataDefinitions/StationModel.cs
    public static StationSourceKinds Classify(Station station)
    {
        ArgumentNullException.ThrowIfNull(station);
        if (station.IsFleetCarrier) return StationSourceKinds.FleetCarrier;
        var type = Normalize(station.Type);
        return type switch
        {
            "fleetcarrier" or "carrier" or "squadroncarrier" or "strongholdcarrier" => StationSourceKinds.FleetCarrier,
            "coriolis" or "coriolisstarport" or "orbis" or "orbisstarport" or "ocellus" or "ocellusstarport"
                or "bernal" or "bernalstarport" or "dodec" or "dodecstarport" => StationSourceKinds.Starport,
            "station" or "starport" => station.IsPlanetary ? StationSourceKinds.PlanetaryPort : StationSourceKinds.Starport,
            "outpost" or "outpostscientific" or "civilianoutpost" or "commercialoutpost" or "industrialoutpost"
                or "militaryoutpost" or "miningoutpost" or "scientificoutpost" or "unknownoutpost" => StationSourceKinds.Outpost,
            "crateroutpost" or "craterport" or "planetaryoutpost" or "planetaryport" or "planetaryengineerbase"
                or "dockableplanetstation" => StationSourceKinds.PlanetaryPort,
            "onfootsettlement" or "odysseysettlement" or "settlement" or "planetarysettlement"
                or "surfacestation" or "unknownplanetary" => StationSourceKinds.Settlement,
            "asteroidbase" or "asteroidstation" => StationSourceKinds.AsteroidBase,
            "megaship" or "megashipcivilian" or "rescuemegaship" => StationSourceKinds.Megaship,
            "planetaryconstructiondepot" or "spaceconstructiondepot" or "shipdepot" or "gameplaypoi" => StationSourceKinds.Other,
            "" or "none" or "unknown" => StationSourceKinds.Unknown,
            _ => StationSourceKinds.Other
        };
    }

    public static bool Allows(Station station, StationSourceKinds allowedKinds) =>
        (allowedKinds & Classify(station)) != StationSourceKinds.None;

    // Fleet carriers provide large pads (Frontier's Fleet Carriers Content Reveal Recap,
    // 2020-04-02: eight large, four medium, four small pads).
    // https://store.steampowered.com/news/posts/?appids=359320&enddate=1586253728&feed=steam_community_announcements
    // Other source categories do not prove a pad size:
    // settlements, construction depots and megaships must retain their observed metadata.
    public static LandingPad EffectiveMaxLandingPad(Station station) =>
        Classify(station) == StationSourceKinds.FleetCarrier ? LandingPad.Large : station.MaxLandingPad;

    private static string Normalize(string? value) =>
        string.Concat((value ?? "").Where(char.IsLetterOrDigit)).ToLowerInvariant();
}