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;
using XFEWarframe.Core.Data;
using XFEWarframe.Core.Services;
using Xunit;

namespace XFEWarframe.Tests;

public sealed partial class EngineTests
{
    [Fact] public async Task EquipmentRecipeCancellationRestoresTheOriginalEquipmentAndSlots()
    {
        var q = await Login(); var catalog = new ItemCatalog(); var entry = GameData.Table("Recipes").Properties().First(x => x.Value["secretIngredientAction"] is null && (x.Value["ingredients"] as JArray ?? []).Any(y => GameData.Find("Weapons", y.Value<string>("ItemType"))?.Value<double>("totalDamage") > 0)); var recipe = (JObject)entry.Value; var ids = new JArray(); var counted = new JObject();
        foreach (var ingredient in (JArray)recipe["ingredients"]!)
        {
            var type = ingredient.Value<string>("ItemType")!; var category = catalog.Get(type).Category;
            if (Inventory.EquipmentKeys.Contains(category)) { await Give(q, type); var gear = (await InventoryOf(q))[category]!.Last()!; ids.Add(Wire.Id(gear["ItemId"])); await store.Update(s => { Inventory.Equipment(s.Obj("accounts").Obj(q["accountId"]).Obj("Inventory"), category, Wire.Id(gear["ItemId"]))["XP"] = 1234; return 0; }); }
            else { ids.Add(type); counted.Array(category).Add(ingredient.DeepClone()); }
        }
        counted["RegularCredits"] = recipe.Value<long>("buildPrice"); counted["Recipes"] = new JArray(new JObject { ["ItemType"] = entry.Name, ["ItemCount"] = 1 }); await Import(q, counted); var before = await InventoryOf(q);
        var start = await Call("/api/startRecipe.php", new { RecipeName = entry.Name, Ids = ids }, q); Assert.True(start.Status == 200, start.Body); var id = JObject.Parse(start.Body)["RecipeId"]!;
        Assert.Equal(409, (await Call("/api/sell.php", new { Items = new { Recipes = new[] { new { String = entry.Name, Count = 1 } } }, SellPrice = 1 }, q)).Status);
        var cancel = await Call("/api/claimCompletedRecipe.php", new { RecipeIds = new[] { id } }, new(q) { ["cancel"] = "1" }); Assert.True(cancel.Status == 200, cancel.Body); var after = await InventoryOf(q);
        foreach (var category in new[] { "LongGuns", "Pistols", "Melee", "WeaponBin", "RegularCredits", "Recipes", "MiscItems" }) Assert.True(JToken.DeepEquals(before[category], after[category]), category); Assert.Empty(after["PendingRecipes"]!);
    }
    [Fact] public async Task IncubationCancellationDoesNotMintModsAndCompletedPetCanProduceOnePrint()
    {
        var time = new TestClock(new DateTimeOffset(2026, 9, 24, 12, 0, 0, TimeSpan.Zero)); engine = new(store, options, time); var q = await Login(); const string recipeName = "/Lotus/Types/Game/KubrowPet/KubrowQuestPetRecipe"; var recipe = GameData.Find("Recipes", recipeName)!;
        await Import(q, new { MiscItems = recipe["ingredients"] }); var before = await InventoryOf(q); var body = new { RecipeName = recipeName, Ids = new string[0] }; var start = await Call("/api/startRecipe.php", body, q); Assert.True(start.Status == 200, start.Body); var pending = JObject.Parse(start.Body); var petId = Wire.Id(pending["InventoryChanges"]!["KubrowPets"]![0]!["ItemId"]);
        Assert.Equal(409, (await Call("/api/adoptPet.php", new { petId, name = "Too soon" }, q)).Status); Assert.Equal(200, (await Call("/api/claimCompletedRecipe.php", new { RecipeIds = new[] { pending["RecipeId"] } }, new(q) { ["cancel"] = "1" })).Status); var canceled = await InventoryOf(q); Assert.Empty(canceled["KubrowPets"]!); Assert.True(JToken.DeepEquals(before["RawUpgrades"], canceled["RawUpgrades"])); Assert.True(JToken.DeepEquals(before["SentinelBin"], canceled["SentinelBin"]));
        pending = JObject.Parse((await Call("/api/startRecipe.php", body, q)).Body); time.Now = time.Now.AddSeconds(60); var claim = await Call("/api/claimCompletedRecipe.php", new { RecipeIds = new[] { pending["RecipeId"] } }, q); Assert.True(claim.Status == 200, claim.Body); var pet = (await InventoryOf(q))["KubrowPets"]![0]!; petId = Wire.Id(pet["ItemId"]); Assert.Equal("STATUS_INCUBATED", pet["Details"]!.Value<string>("Status")); Assert.Equal(200, (await Call("/api/adoptPet.php", new { petId, name = "Companion" }, q)).Status);
        const string printRecipe = "/Lotus/Types/Game/KubrowPet/DistillPrintRecipe"; var meta = GameData.Find("Recipes", printRecipe)!; await Give(q, meta["ingredients"]![0]!.Value<string>("ItemType")!);
        var printStart = await Call("/api/startRecipe.php", new { RecipeName = printRecipe, Ids = new[] { meta["ingredients"]![0]!.Value<string>("ItemType"), petId } }, q); Assert.True(printStart.Status == 200, printStart.Body); var printId = JObject.Parse(printStart.Body)["RecipeId"]!; time.Now = time.Now.AddSeconds(meta.Value<int>("buildTime")); Assert.Equal(200, (await Call("/api/claimCompletedRecipe.php", new { RecipeIds = new[] { printId } }, q)).Status);
        var inv = await InventoryOf(q); var print = inv["KubrowPetPrints"]!.Single()!; Assert.Equal("Companion", print.Value<string>("Name")); Assert.True(JToken.DeepEquals(pet["Details"]!["DominantTraits"], print["DominantTraits"])); Assert.Equal(1, inv["KubrowPets"]![0]!["Details"]!.Value<int>("PrintsRemaining")); Assert.Equal(404, (await Call("/api/claimCompletedRecipe.php", new { RecipeIds = new[] { printId } }, q)).Status);
    }
    [Fact] public async Task UmbraFoundryClaimIncludesRankedModsAndSkiajatiAndCannotRepeat()
    {
        var q = await Login(); var recipe = GameData.Table("Recipes").Properties().First(x => x.Value.Value<string>("resultType") == "/Lotus/Powersuits/Excalibur/ExcaliburUmbra"); var id = Wire.NewId(); await Import(q, new { Recipes = new[] { new { ItemType = recipe.Name, ItemCount = 1 } }, PendingRecipes = new[] { new { ItemId = Wire.Oid(id), ItemType = recipe.Name, CompletionDate = Wire.Date(0) } } });
        var result = await Call("/api/claimCompletedRecipe.php", new { RecipeIds = new[] { Wire.Oid(id) } }, q); Assert.True(result.Status == 200, result.Body); var inv = await InventoryOf(q); Assert.Equal(5, inv["Upgrades"]!.Count()); Assert.All(inv["Upgrades"]!, x => Assert.Equal(5, JObject.Parse(x.Value<string>("UpgradeFingerprint")!).Value<int>("lvl"))); Assert.Equal(900000, inv["Suits"]![0]!.Value<int>("XP")); Assert.Equal(450000, inv["Melee"]![0]!.Value<int>("XP")); Assert.Equal("/Lotus/Weapons/Tenno/Melee/Swords/UmbraKatana/UmbraKatana", inv["Melee"]![0]!.Value<string>("ItemType")); Assert.Equal(404, (await Call("/api/claimCompletedRecipe.php", new { RecipeIds = new[] { Wire.Oid(id) } }, q)).Status);
    }
    [Fact] public async Task PetAndRoboticCompanionAcquisitionIncludesTheirDefaultEquipment()
    {
        var q = await Login(); await Give(q, "/Lotus/Types/Game/CatbrowPet/VampireCatbrowPetPowerSuit"); await Give(q, "/Lotus/Types/Friendly/Pets/ZanukaPets/ZanukaPetAPowerSuit"); var inv = await InventoryOf(q);
        Assert.Equal("STATUS_STASIS", inv["KubrowPets"]![0]!["Details"]!.Value<string>("Status")); Assert.Equal("/Lotus/Types/Game/CatbrowPet/Heads/CatbrowHeadVampire", inv["KubrowPets"]![0]!["Details"]!["DominantTraits"]!.Value<string>("Head")); Assert.Equal(4, inv["MoaPets"]![0]!["ModularParts"]!.Count()); Assert.Contains(inv["MoaPets"]![0]!["ModularParts"]!, x => x.ToString().EndsWith("ZanukaPetPartHeadA", StringComparison.Ordinal)); Assert.Contains(inv["SentinelWeapons"]!, x => x.Value<string>("ItemType") == "/Lotus/Types/Friendly/Pets/ZanukaPets/ZanukaPetMeleeWeaponIP");
    }
}