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 SynthesisCollectionsAndCaptureStatePersistWithOneTimeMail() { var q = await Login(); await Call("/api/giveStartingGear.php", new { }, q); const string target = "/Lotus/Types/Game/Library/Targets/DragonframeQuestTarget"; const string collectible = "/Lotus/Objects/Orokin/Props/CollectibleSeriesOne"; await Import(q, new { LibraryPersonalTarget = target, CollectibleSeries = new[] { new { CollectibleType = collectible, Count = 0, ReqScans = 56, IncentiveStates = new[] { new { threshold = .5, sent = false }, new { threshold = .75, sent = false } } } } }); var suitId = Wire.Id((await InventoryOf(q))["Suits"]![0]!["ItemId"]); var body = new { BMI = true, LibraryScans = new[] { new { EnemyType = WorldData.Get("libraryTargetToAvatar").Value(target), Count = 3 } }, CollectibleScans = new[] { new { CollectibleType = collectible, Count = 56, Tracking = "complete" } }, DeathMarks = new[] { "/Lotus/Language/Bosses/Boss1" }, BrandedSuits = Wire.Oid(suitId), LockedWeaponGroup = new { s = Wire.Oid(suitId) } }; var result = await Call("/api/updateInventory.php", body, q); Assert.True(result.Status == 200, result.Body); var inv = await InventoryOf(q); Assert.Null(inv["LibraryPersonalTarget"]); Assert.True(inv["LibraryPersonalProgress"]![0]!.Value("Completed")); Assert.Equal(3, inv["LibraryPersonalProgress"]![0]!.Value("Scans")); Assert.Single(inv["DeathMarks"]!); Assert.Single(inv["BrandedSuits"]!); Assert.NotNull(inv["LockedWeaponGroup"]); var messages = await store.Read(s => s.Obj("accounts").Obj(q["accountId"]).Array("Inbox").Count); Assert.True(messages >= 5); Assert.Equal(200, (await Call("/api/updateInventory.php", body, q)).Status); Assert.Equal(messages, await store.Read(s => s.Obj("accounts").Obj(q["accountId"]).Array("Inbox").Count)); Assert.Equal(200, (await Call("/api/updateInventory.php", new { BMI = true, UnlockWeapons = true }, q)).Status); Assert.Null((await InventoryOf(q))["LockedWeaponGroup"]); } [Fact] public async Task MissionSculpturesAndEggsAreGrantedAndFilledSculpturesRollBack() { var q = await Login(); var sculpture = new ItemCatalog().Entries.First(x => x.Category == "FusionTreasures").Type; var result = await Call("/api/updateInventory.php", new { BMI = true, FusionTreasures = new[] { new { ItemType = sculpture, ItemCount = 2, Sockets = 0 } }, KubrowPetEggs = new[] { new { } } }, q); Assert.True(result.Status == 200, result.Body); var before = await InventoryOf(q); Assert.Equal(2, Count(before, "FusionTreasures", sculpture)); Assert.Equal(1, Count(before, "MiscItems", "/Lotus/Types/Game/KubrowPet/Eggs/KubrowEgg")); Assert.Equal(400, (await Call("/api/updateInventory.php", new { BMI = true, RegularCredits = 500, FusionTreasures = new[] { new { ItemType = sculpture, ItemCount = 1, Sockets = 1 } } }, q)).Status); Assert.True(JToken.DeepEquals(before, await InventoryOf(q))); } [Fact] public async Task ModularPartsRejectOtherEquipmentFamiliesAndInfestedCompanionsCanBeReconstructed() { var q = await Login(); var offer = ModularApi.Sales(20720)[0]!["Weapons"]![0]!; var parts = (JArray)offer["ModularParts"]!.DeepClone(); parts[0] = "/Lotus/Types/Items/MiscItems/Ferrite"; await Import(q, new { RegularCredits = 100000 }); foreach (var part in parts) await Give(q, part.ToString()); var before = await InventoryOf(q); Assert.Equal(400, (await Call("/api/modularWeaponCrafting.php", new { WeaponType = offer.Value("ItemType"), Parts = parts }, q)).Status); Assert.True(JToken.DeepEquals(before, await InventoryOf(q))); foreach (var type in ((JObject)WorldData.Get("modularWeaponTypes")).Properties().Where(x => x.Value.ToString() == "KubrowPets").Select(x => x.Name)) { var cat = type.Contains("Catbrow", StringComparison.Ordinal); var family = cat ? "CATBROW" : "KUBROW"; var rarity = type.Contains("Armored", StringComparison.Ordinal) || type.Contains("Medjay", StringComparison.Ordinal) ? "Rare" : type.Contains("Horned", StringComparison.Ordinal) || type.Contains("Pharaoh", StringComparison.Ordinal) ? "Uncommon" : "Common"; var animal = "/Lotus/Types/Items/Deimos/Wounded" + (cat ? "InfestedCritter" : "InfestedPredator") + rarity + "RewardItem"; var components = new[] { animal, GameData.Table("Weapons").Properties().First(x => x.Value.Value("partType") == "LWPT_" + family + "_MUTAGEN" && !x.Name.Contains("WoundedInfested", StringComparison.Ordinal)).Name, GameData.Table("Weapons").Properties().First(x => x.Value.Value("partType") == "LWPT_" + family + "_ANTIGEN").Name }; foreach (var part in components) await Give(q, part); var result = await Call("/api/modularWeaponCrafting.php", new { WeaponType = type, Parts = components }, q); Assert.True(result.Status == 200, result.Body); } Assert.Equal(6, (await InventoryOf(q))["KubrowPets"]!.Count()); } [Fact] public void ItemCatalogCategoriesHaveNativeAcquisitionHandlers() { var categories = new ItemCatalog().Entries.Select(x => x.Category).Distinct(); var supported = Inventory.EquipmentKeys.Concat(Inventory.CountedKeys).Concat(new[] { "BoosterPacks", "Boosters", "Bundles", "SlotItems", "FusionBundles", "CreditBundles", "EmailItems", "FlavourItems", "WeaponSkins", "FusionTreasures", "KubrowPetPrints" }).ToHashSet(); Assert.DoesNotContain(categories, x => !supported.Contains(x)); Assert.NotNull(GameData.Find("Recipes", "/Lotus/Types/Recipes/EidolonRecipes/OpenArchwingSummonBlueprint")); Assert.NotNull(GameData.Find("Warframes", "/Lotus/Powersuits/Excalibur/DarkExcalibur")); } }