using System; using System.Collections.Generic; namespace ScrapYard.API { public class ShopPlatform { public readonly ShopPlatformSpacingType Type; public readonly string Title; internal List Entries = new List(); internal static Dictionary ShopPlatforms = new Dictionary(); public static ShopPlatform DefaultObjects { get => ShopPlatforms["DefaultObjects"]; } public static ShopPlatform DefaultBlocks { get => ShopPlatforms["DefaultBlocks"]; } public static ShopPlatform DefaultWalls { get => ShopPlatforms["DefaultWalls"]; } public ShopPlatform(string title, ShopPlatformSpacingType spacingType = ShopPlatformSpacingType.Normal) { this.Type = spacingType; this.Title = title; } public virtual ShopPlatform Register() { return Register(this.Title); } public virtual ShopPlatform Register(string id) { if (ShopPlatforms.ContainsKey(id)) ShopPlatforms.Remove(id); ShopPlatforms.Add(id, this); return this; } public ShopPlatformSpacingType GetShopPlatformSpacingType() { return Type; } public void AddShopPlatformEntry(ShopPlatformEntry row) { foreach (var e in Entries) if (e.CurrencyItemID == row.CurrencyItemID && e.Id == row.Id && e.Quantity == row.Quantity && e.Price == row.Price && e.EntryType == row.EntryType) return; Entries.Add(row); } public void RemoveShopPlatformEntry(ShopPlatformEntry row) { Entries.Remove(row); } public ShopPlatformEntry[] GetShopPlatformEntries() { return Entries.ToArray(); } public static ShopPlatform[] GetShopPlatforms() { return new List(ShopPlatforms.Values).ToArray(); } internal int GetSpacesPerRow() { int spaces = 0; switch (Type) { case ShopPlatformSpacingType.Normal: spaces = 7; break; case ShopPlatformSpacingType.Near: spaces = 13; break; case ShopPlatformSpacingType.Far: spaces = 3; break; } return spaces; } internal int GetRowsNeeded() { return ((Entries.Count - 1) / GetSpacesPerRow()) + 1; } internal static void Reset() { ShopPlatforms = new Dictionary(); } } public enum ShopPlatformSpacingType { Normal, Near, Far } public enum ShopPlatformEntryType { Item, Chip } }