Switch-Gift-Data-Manager/SwitchGiftDataManager.Core/Classes/WCManager/GiftData/OtherGift.cs
Manu ef1c90dbea
Some checks failed
Linux / build (Release) (push) Has been cancelled
MacOS / build (Release) (push) Has been cancelled
Windows / build (Release) (push) Has been cancelled
Initial handling for Flag wondercards
2025-11-08 22:54:36 +01:00

123 lines
6.1 KiB
C#

using Enums;
using System.Runtime.CompilerServices;
namespace SwitchGiftDataManager.Core;
public class OtherGift
{
public object? Type { get; set; }
public ushort Item { get; set; }
public uint Quantity { get; set; }
public uint Opt { get; set; }
public string GetItemName() => GetItemName(Item, Type!, Opt);
public static string GetItemName(ushort id, object type, uint opt = 0)
{
var str = "";
if (type.GetType() == typeof(GiftType7))
{
if ((GiftType7)type is GiftType7.Item)
str = Properties.Resources.Items.Split(new String[] { "\n" }, StringSplitOptions.None)[id];
else
str = ((GiftType7)type).ToString();
}
else if (type.GetType() == typeof(GiftType8))
{
if ((GiftType8)type is GiftType8.Item)
str = Properties.Resources.Items.Split(new String[] { "\n" }, StringSplitOptions.None)[id];
else if ((GiftType8)type is GiftType8.Clothing)
{
var category = (ClothingType8)id;
var description = category switch
{
ClothingType8.Glasses => Properties.Resources.SWSHClothingGlasses.Split(new String[] { "\n" }, StringSplitOptions.None)[opt],
ClothingType8.Hats => Properties.Resources.SWSHClothingHats.Split(new String[] { "\n" }, StringSplitOptions.None)[opt],
ClothingType8.Jackets => Properties.Resources.SWSHClothingJackets.Split(new String[] { "\n" }, StringSplitOptions.None)[opt],
ClothingType8.Tops => Properties.Resources.SWSHClothingTops.Split(new String[] { "\n" }, StringSplitOptions.None)[opt],
ClothingType8.Bags => Properties.Resources.SWSHClothingBags.Split(new String[] { "\n" }, StringSplitOptions.None)[opt],
ClothingType8.Gloves => Properties.Resources.SWSHClothingGloves.Split(new String[] { "\n" }, StringSplitOptions.None)[opt],
ClothingType8.Bottoms => Properties.Resources.SWSHClothingBottoms.Split(new String[] { "\n" }, StringSplitOptions.None)[opt],
ClothingType8.Legwear => Properties.Resources.SWSHClothingLegwear.Split(new String[] { "\n" }, StringSplitOptions.None)[opt],
ClothingType8.Footwear => Properties.Resources.SWSHClothingShoes.Split(new String[] { "\n" }, StringSplitOptions.None)[opt],
_ => throw new ArgumentOutOfRangeException(),
};
str = $"[{category}] {description}";
}
else
str = ((GiftType8)type).ToString();
}
else if(type.GetType() == typeof(GiftType8B))
{
if ((GiftType8B)type is GiftType8B.Item)
str = Properties.Resources.Items.Split(new String[] { "\n" }, StringSplitOptions.None)[id];
else if ((GiftType8B)type is GiftType8B.Clothing)
str = Properties.Resources.BDSPClothing.Split(new String[] { "\n" }, StringSplitOptions.None)[id];
else if ((GiftType8B)type is GiftType8B.Underground)
str = Properties.Resources.UndergroundItems.Split(new String[] { "\n" }, StringSplitOptions.None)[id];
else
str = ((GiftType8B)type).ToString();
}
else if (type.GetType() == typeof(GiftType8A))
{
if ((GiftType8A)type is GiftType8A.Item)
str = Properties.Resources.Items.Split(new String[] { "\n" }, StringSplitOptions.None)[id];
else if ((GiftType8A)type is GiftType8A.Clothing)
{
var category = (ClothingType8A)id;
var description = category switch
{
ClothingType8A.Headwear => Properties.Resources.PLAClothingHeads.Split(new String[] { "\n" }, StringSplitOptions.None)[opt],
ClothingType8A.Tops => Properties.Resources.PLAClothingTops.Split(new String[] { "\n" }, StringSplitOptions.None)[opt],
ClothingType8A.Bottoms => Properties.Resources.PLAClothingBottoms.Split(new String[] { "\n" }, StringSplitOptions.None)[opt],
ClothingType8A.Outfit => "",
ClothingType8A.Footwear => "",
ClothingType8A.Glasses => "",
ClothingType8A.Eyewear => "",
_ => throw new ArgumentOutOfRangeException(),
};
if(string.IsNullOrWhiteSpace(description))
description = $"{opt:X4}";
str = $"[{category}] {description}";
}
else
str = ((GiftType8A)type).ToString();
}
else if (type.GetType() == typeof(GiftType9))
{
if ((GiftType9)type is GiftType9.Item)
str = Properties.Resources.Items.Split(new String[] { "\n" }, StringSplitOptions.None)[id];
else if ((GiftType9)type is GiftType9.Clothing)
{
var category = (ClothingType9)id;
var description = Properties.Resources.SCVIClothings.Split(new String[] { "\n" }, StringSplitOptions.None)[opt];
if (string.IsNullOrWhiteSpace(description))
description = $"{opt:X4}";
str = $"[{category.ToString().Replace("Uniform", "Clothing")}] {description}";
}
else
str = ((GiftType9)type).ToString();
}
else if (type.GetType() == typeof(GiftType9A))
{
if ((GiftType9A)type is GiftType9A.Item or GiftType9A.Flag)
str = Properties.Resources.Items.Split(new String[] { "\n" }, StringSplitOptions.None)[id];
else if ((GiftType9A)type is GiftType9A.Clothing)
{
if (!Clothing9A.TryGetValue(opt, out str))
str = "Unknown Clothing Item";
}
else
{
str = ((GiftType9A)type).ToString();
}
}
return str;
}
private static Dictionary<uint, string> Clothing9A = new()
{
{ 0x2E1937, "Trench Coat and Pants Set (Beige)" },
};
}