diff --git a/SaintCoinach.Cmd/Commands/SqlExport.cs b/SaintCoinach.Cmd/Commands/SqlExport.cs index ba755ff3..59e36eb4 100644 --- a/SaintCoinach.Cmd/Commands/SqlExport.cs +++ b/SaintCoinach.Cmd/Commands/SqlExport.cs @@ -179,56 +179,63 @@ public override async Task InvokeAsync(string[] paramList) // .Where(n => !n.Contains("quest/") && !n.Contains("custom/")) foreach (var name in _Realm.GameData.AvailableSheets) { - var sheet = _Realm.GameData.GetSheet(name); - var variant = sheet.Header.Variant; - var sheet2 = sheet as XivSheet2; - - Console.WriteLine($"Sheet: {name}, variant: {variant}"); - - if (sheet.Count == 0) - continue; - - var sb = new StringBuilder(); - - sb.AppendLine($"CREATE TABLE {GetTableName(sheet)} ("); - - // key meme - if (sheet.Header.Variant == 1) - { - sb.AppendLine($" `_Key` INT NOT NULL,"); - } - else - { - sb.AppendLine($" `_Key` INT NOT NULL,"); - sb.AppendLine($" `_SubKey` INT NOT NULL,"); - } - - // add cols - foreach (var column in sheet.Header.Columns) - { - var colName = column.Name; - if (string.IsNullOrEmpty(colName)) - colName = $"unk{column.Index}"; - - sb.AppendLine($" `{colName}` {GetSqlType(column.Reader.Type)},"); - } - - // primary key - if (sheet.Header.Variant == 1) + try { - sb.AppendLine($" PRIMARY KEY (`_Key`)"); + var sheet = _Realm.GameData.GetSheet(name); + var variant = sheet.Header.Variant; + var sheet2 = sheet as XivSheet2; + + Console.WriteLine($"Sheet: {name}, variant: {variant}"); + + if (sheet.Count == 0) + continue; + + var sb = new StringBuilder(); + + sb.AppendLine($"CREATE TABLE {GetTableName(sheet)} ("); + + // key meme + if (sheet.Header.Variant == 1) + { + sb.AppendLine($" `_Key` INT NOT NULL,"); + } + else + { + sb.AppendLine($" `_Key` INT NOT NULL,"); + sb.AppendLine($" `_SubKey` INT NOT NULL,"); + } + + // add cols + foreach (var column in sheet.Header.Columns) + { + var colName = column.Name; + if (string.IsNullOrEmpty(colName)) + colName = $"unk{column.Index}"; + + sb.AppendLine($" `{colName}` {GetSqlType(column.Reader.Type)},"); + } + + // primary key + if (sheet.Header.Variant == 1) + { + sb.AppendLine($" PRIMARY KEY (`_Key`)"); + } + else + { + sb.AppendLine($" PRIMARY KEY (`_Key`, `_SubKey`)"); + } + + sb.AppendLine(") COLLATE='utf8mb4_unicode_ci' ENGINE=MyISAM;"); + sb.AppendLine(); + + WriteRows(sheet, sb); + + imports.Add(sb.ToString()); } - else + catch (Exception e) { - sb.AppendLine($" PRIMARY KEY (`_Key`, `_SubKey`)"); + Console.WriteLine($"Failed to export {name}: {e}"); } - - sb.AppendLine(") COLLATE='utf8mb4_unicode_ci' ENGINE=MyISAM;"); - sb.AppendLine(); - - WriteRows(sheet, sb); - - imports.Add(sb.ToString()); } File.WriteAllText("schema.sql", string.Join(Environment.NewLine, imports)); diff --git a/SaintCoinach/Xiv/InclusionShop.cs b/SaintCoinach/Xiv/InclusionShop.cs new file mode 100644 index 00000000..2e1b1cbd --- /dev/null +++ b/SaintCoinach/Xiv/InclusionShop.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using SaintCoinach.Ex.Relational; + +namespace SaintCoinach.Xiv; + +public class InclusionShop: XivRow +{ + private List _Categories; + + public IEnumerable Categories => _Categories ??= BuildCategories(); + + public bool IsValid => Categories.Any(); + + public byte UknownByte => As(1); + + private List BuildCategories() + { + var list = new List(); + for (var i = 0; i < 30; i++) + { + var cat = As($"Category[{i}]"); + if (cat.Key != 0) + list.Add(cat); + } + return list; + } + + public InclusionShop(IXivSheet sheet, IRelationalRow sourceRow) : base(sheet, sourceRow) + { + } +} \ No newline at end of file diff --git a/SaintCoinach/Xiv/InclusionShopCategory.cs b/SaintCoinach/Xiv/InclusionShopCategory.cs new file mode 100644 index 00000000..7e2c3615 --- /dev/null +++ b/SaintCoinach/Xiv/InclusionShopCategory.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using SaintCoinach.Ex.Relational; + +namespace SaintCoinach.Xiv; + +public class InclusionShopCategory : XivRow +{ + public string Name => AsString("Name"); + + public ClassJobCategory ClassJobCategory => As(); + + public IEnumerable Series => AsSubRows(); + + private IEnumerable AsSubRows() where T : XivSubRow + { + return AsSubRows(typeof(T).Name); + } + private IEnumerable AsSubRows(string rowName) where T :XivSubRow + { + var sheetName = typeof(T).Name; + var key = (ushort)GetRaw(rowName); + + var sheet = Sheet.Collection.GetSheet2(sheetName) + .Cast() + .Where(r => r.ParentKey == key) + .ToArray(); + + return sheet; + } + + public InclusionShopCategory(IXivSheet sheet, IRelationalRow sourceRow) : base(sheet, sourceRow) + { + } +} \ No newline at end of file diff --git a/SaintCoinach/Xiv/InclusionShopSeries.cs b/SaintCoinach/Xiv/InclusionShopSeries.cs new file mode 100644 index 00000000..744b46c2 --- /dev/null +++ b/SaintCoinach/Xiv/InclusionShopSeries.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; +using System.Linq; +using SaintCoinach.Ex.Relational; + +namespace SaintCoinach.Xiv; + +public class InclusionShopSeries: XivSubRow +{ + public SpecialShop SpecialShop => As(); + + public IEnumerable Items => SpecialShop.Items.SelectMany(i=> i.Rewards.Select(i=> i.Item)); + + public InclusionShopSeries(IXivSheet sheet, IRelationalRow sourceRow) : base(sheet, sourceRow) + { + } +} \ No newline at end of file diff --git a/SaintCoinach/Xiv/SpecialShopListing.cs b/SaintCoinach/Xiv/SpecialShopListing.cs index 77c5be90..8a37d9da 100644 --- a/SaintCoinach/Xiv/SpecialShopListing.cs +++ b/SaintCoinach/Xiv/SpecialShopListing.cs @@ -10,10 +10,20 @@ public class SpecialShopListing : IShopListing { private static Dictionary _Currencies = new Dictionary() { { 1, 28 }, - { 2, 25199 }, - { 4, 25200 }, - { 6, 33913 }, - { 7, 33914 } + + // 6.0 + /* + { 2, 25199 }, // White Crafters Scrips + { 4, 25200 }, // White Gatherers Scrips + { 6, 33913 }, // Purple Crafters Scrips + { 7, 33914 } // Purple Gatherers Scrips + */ + + // 7.0 + { 2, 33913 }, // Purple Crafters Scrips + { 4, 33914 }, // Purple Gatherers Scrips + { 6, 41784 }, // Orange Crafters Scrips + { 7, 41785 } // Orange Gatherers Scrips }; private static Dictionary _Tomestones; @@ -93,6 +103,8 @@ public SpecialShopListing(SpecialShop shop, int index) { _Rewards = rewards.ToArray(); Quest = shop.As("Quest{Item}", index); + AchievementUnlock = shop.As("AchievementUnlock", index); + int UseCurrencyType = shop.As("UseCurrencyType"); const int CostCount = 3; @@ -129,7 +141,7 @@ public SpecialShopListing(SpecialShop shop, int index) { } hq = false; } - + var collectabilityRating = shop.AsInt16("CollectabilityRating{Cost}", index, i); costs.Add(new ShopListingItem(this, item, count, hq, collectabilityRating)); @@ -137,6 +149,8 @@ public SpecialShopListing(SpecialShop shop, int index) { _Costs = costs.ToArray(); } + public Achievement AchievementUnlock { get; set; } + #endregion /// @@ -161,4 +175,4 @@ public SpecialShopListing(SpecialShop shop, int index) { #endregion } -} +} \ No newline at end of file