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

XFEWarframe

【WinUI】基于Warframe游戏本体的公开服务器以及安装器

公开
关注 0 Fork 0 Star 0
UTF-8
using Newtonsoft.Json.Linq;

namespace XFEWarframe.Core.Services;

public static class ServerIdentity
{
    public const int ApiVersion = 3;
    public static string Name(JObject state, ServerOptions options) => (state["config"] as JObject)?.Value<string>("serverName") ?? options.ServerName;
    public static string ValidateName(string name)
    {
        name = name.Trim();
        if (name.Length is < 1 or > 64 || name.Any(c => char.IsControl(c) || c is '<' or '>'))
            throw new ApiException(400, "服务器名称须为 1–64 个字符,不能包含控制字符或尖括号。");
        return name;
    }
    public static object Health(JObject state, ServerOptions options, bool maintenance) => new
    {
        status = maintenance ? "maintenance" : "ok", service = "XFEWarframe", apiOnly = true,
        apiVersion = ApiVersion, serverName = Name(state, options), gameUrl = options.GamePublicUrl ?? options.PublicUrl,
        capabilities = new[] { "player-accounts", "mail", "game-news", "server-identity", "game-login-202608", "ship-module-recovery" }
    };
}