-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathJsonBuilder.cs
59 lines (56 loc) · 2.11 KB
/
JsonBuilder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
namespace FortniteChecker;
internal class JsonBuilder
{
public static object CreateJsonFile(List<CosmeticsDB.Datum> cosmetics, List<QueryProfile.Modal.PastSeason> stats, List<Banners.Datum> banners, string vbucks, string giftsSent, string giftsReceived, string createdTimestamp, string displayName, string lifeTimeWins, string epicID) => new
{
cosmetics = BuildCosmetics(cosmetics), // Assume these methods return serialized objects
stats = stats,
banners = banners,
vbucks,
giftsSent,
giftsReceived,
createdTimestamp,
displayName,
LifeTimeWins = lifeTimeWins,
_id = epicID
};
public static List<object> BuildCosmetics(List<CosmeticsDB.Datum> cosmetics)
{
// Create a list to hold the structured cosmetics data
List<object> cosmeticsList = new();
// Add favorite items
foreach (var item in cosmetics.Where(x => x.favourite).OrderBy(x => x.introduction.backendValue))
{
var cosmeticItem = new
{
name = item.name,
id = item.id,
type = item.type.backendValue,
rarity = "mythic",
variants = item.OwnedVariant.Select(variant => new
{
Stage = variant.Stage,
Channel = variant.Channel
}).ToList()
};
cosmeticsList.Add(cosmeticItem);
}
foreach (var item in cosmetics.Where(x => !x.favourite).OrderByDescending(x => x.rarity.backendIntValue).ThenBy(x => x.introduction.backendValue))
{
var cosmeticItem = new
{
Name = item.name,
Id = item.id,
Type = item.type.backendValue,
Rarity = item.rarity.value,
Variants = item.OwnedVariant.Select(variant => new
{
Stage = variant.Stage,
Channel = variant.Channel
}).ToList()
};
cosmeticsList.Add(cosmeticItem);
}
return cosmeticsList;
}
}