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

XFEWarframe

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

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

namespace XFEWarframe.Core.Services;

public sealed partial class WeeklyApi
{
    public void Mission(JObject account, JObject body, JObject info, JArray rewards, JObject response, SeededRng rng)
    {
        var inv = account.Obj("Inventory"); var steel = body["Missions"]?.Value<int>("Tier") == 1 || body["Alerts"]?.Value<int>("Tier") == 1;
        if (info.Value<string>("node") == "SolNode238")
        {
            var entry = inv.Array("EndlessXP").OfType<JObject>().FirstOrDefault(x => x.Value<string>("Category") == (steel ? "EXC_HARD" : "EXC_NORMAL"));
            if (entry is not null && Wire.DateMs(entry["Expiry"]) == WeekEnd)
            {
                var rounds = (info["rewardQualifications"] as JArray)?.Count ?? 0; if (rounds > 10000) throw new ApiException(400, "Too many circuit rounds");
                var xp = new[] { 100, 110, 125, 145 }.Take(rounds).Sum() + Math.Max(0, rounds - 4) * 170;
                if (rounds >= 4 && Wire.DateMs(entry["BonusAvailable"]) <= Now) { xp += 50; entry["BonusAvailable"] = Wire.Date(Now + WorldData.Day); }
                entry["Earn"] = checked(entry.Value<long>("Earn") + xp);
            }
        }
        if (info.Value<string>("missionType") == "MT_DESCENT")
        {
            var entry = inv.Array("DescentRewards").OfType<JObject>().FirstOrDefault(x => x.Value<string>("Category") == (steel ? "DM_COH_HARD" : "DM_COH_NORMAL"));
            if (entry is null || Wire.DateMs(entry["Expiry"]) != WeekEnd) throw new ApiException(409, "Descent rewards must be initialized for the current week");
            var floor = (int)info.Integer("EncounterEnemyLevel", 0, 21);
            if (floor > entry.Value<int>("FloorClaimed"))
            {
                entry["FloorClaimed"] = floor;
                var checkpoint = entry.Array("PendingRewards").FirstOrDefault(x => x.Value<int>("FloorCheckpoint") == floor);
                foreach (var reward in checkpoint?["Rewards"] as JArray ?? []) rewards.Add(reward.DeepClone());
            }
        }
        if (info["ConquestCompleted"] is null) return;
        ResetVault(inv, Now); var hex = info.Value<string>("ConquestType") == "HexConquest"; var prefix = hex ? "EchoesHexConquest" : "EntratiLabConquest";
        if (inv.Value<int>(prefix + "Unlocked") == 0) throw new ApiException(409, "Conquest mode has not been unlocked this week");
        var completed = (int)info.Integer("ConquestCompleted", 0, 2); var hard = info["ConquestHardModeActive"] is null ? 0 : (int)info.Integer("ConquestHardModeActive", 0, 1);
        var personal = info["ConquestPersonalModifiersActive"] is null ? 0 : (int)info.Integer("ConquestPersonalModifiersActive", 0, 4); var suggestions = info["ConquestEquipmentSuggestionsFulfilled"] is null ? 0 : (int)info.Integer("ConquestEquipmentSuggestionsFulfilled", 0, 4);
        var score = (1 + hard * 3 + personal + suggestions) * (completed + 1) + (completed == 2 ? hard : 0); var previous = inv.Value<int>(prefix + "CacheScoreMission");
        if (score >= 25) inv.Array("NodeIntrosCompleted").UniqueAdd(prefix + "HardModeUnlocked");
        foreach (var threshold in new[] { 5, 10, 15, 20, 28, 31, 34, 37 }.Where(x => previous < x && x <= score))
        {
            if (threshold == 15) rewards.Add(hex ? Counted("/Lotus/StoreItems/Types/BoosterPacks/1999StickersPackEchoesArchimedea") : Counted("/Lotus/StoreItems/Types/Gameplay/EntratiLab/Resources/EntratiLanthornBundle", 3));
            else if (threshold is 28 or 37) rewards.Add(Counted("/Lotus/StoreItems/Types/Items/MiscItems/" + (hex ? "1999ConquestBucks" : "DistillPoints"), hex ? threshold == 28 ? 6 : 9 : threshold == 28 ? 20 : 50));
            else { var deck = hex ? "1999Conquest" : "EntratiLabConquest"; MissionApi.Roll($"/Lotus/Types/Game/MissionDecks/{deck}Rewards/{deck}{(threshold < 15 ? "Silver" : threshold == 34 ? "Arcane" : "Gold")}Rewards", [0], rewards, rng); }
        }
        inv[prefix + "CacheScoreMission"] = Math.Max(previous, score); response["ConquestCompletedMissionsCount"] = completed == 2 ? 0 : completed + 1;
    }
    public static bool Duviri(JObject state, JObject body, JObject info, JArray rewards, SeededRng rng)
    {
        var kind = info.Value<int>("T"); var steel = body["Missions"]?.Value<int>("Tier") == 1; string? deck = kind switch
        { 13 => "DuviriStaticUndercroftResourceRewards", 14 => "DuviriSteelPathStaticUndercroftResourceRewards", 15 => steel ? "DuviriKullervoSteelPathRNGRewards" : "DuviriKullervoNormalRNGRewards", 17 => "DuviriMurmurFinalChestRewards", 19 => "DuviriMurmurFinalSteelChestRewards", _ => null };
        var clamps = kind switch { 13 => 1, 14 => 3, 17 => 10, 19 => 15, 70 or 6 => steel ? 15 : 10, _ => 0 };
        if (clamps > 0) MissionSpecialRewards.Reward(rewards, "/Lotus/Types/Gameplay/Duviri/Resource/DuviriDragonDropItem", clamps);
        if (kind is 17 or 19 && state["worldState"]?.Value<bool>("eightClaw") == true) MissionSpecialRewards.Reward(rewards, "/Lotus/Types/Gameplay/DuviriMITW/Resources/DuviriMurmurItemEvent", kind == 17 ? 10 : 15);
        if (deck is not null) MissionApi.Roll("/Lotus/Types/Game/MissionDecks/DuviriEncounterRewards/" + deck, kind is 17 or 19 ? [0, 1] : [0], rewards, rng);
        return deck is not null || clamps > 0;
    }
    public static void Purgatory(JObject info, JArray rewards, SeededRng rng)
    {
        foreach (var encoded in info["PurgatoryRewardQualifications"] as JArray ?? [])
        {
            if (!int.TryParse(encoded.ToString(), out var value) || value is < 1 or > 9) throw new ApiException(400, "Invalid Granum Void reward qualification");
            var type = new[] { "Blue", "Gold", "Black" }[(value - 1) / 3]; MissionApi.Roll($"/Lotus/Types/Game/MissionDecks/PurgatoryMissionRewards/Purgatory{type}TokenRewards", Enumerable.Range(0, (value - 1) % 3 + 1).ToArray(), rewards, rng);
        }
    }
}