mirror of
https://github.com/ACEmulator/ACE
synced 2026-08-17 12:26:06 -04:00
* This moves the .sql file generation code that Ripley has been using into ACE.Database This will help us import data from any source into ACE EF objects, and then use these SQLWriters to create a unified output. * Weenie and LandblockInstances SQL Writers added + Enums Some styling and comments added to the other SQL Writer classes. Still need to do the treasure tables, as well as recipe/cook books. Also need to confirm SQL output is well formed and accurate. * CookBookSQLWriter and RecipeSQLWriter Writers that still aren't implemented: PointsOfInterest TreasureDeath TreasureWielded Also, still need to test the output of these writers to make sure it's correct. * Formatting tweaked a little bit, much closer to the final product This creates scripts that import. Still need to verify a couple of data mismatches. * This moves the Int/Did property decoder to ACE.Entity.Enum.Properties This code will likely be used to help UI content editors and database viewers. * This fixes float output where precision was lost. Woops. * Fat fingered a variable in the weenie SQL writer This concludes all the testing for the SQL Writers. They all test OK and produce the same results as the code Ripley was using to generate the .sql files.
49 lines
1.7 KiB
C#
49 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
|
|
using ACE.Database.Models.World;
|
|
|
|
namespace ACE.Database.SQLFormatters.World
|
|
{
|
|
public class CookBookSQLWriter : SQLWriter
|
|
{
|
|
/// <summary>
|
|
/// Default is formed from: input.RecipeId.ToString("00000")
|
|
/// </summary>
|
|
public string GetDefaultFileName(CookBook input)
|
|
{
|
|
string fileName = input.RecipeId.ToString("00000");
|
|
fileName = IllegalInFileName.Replace(fileName, "_");
|
|
fileName += ".sql";
|
|
|
|
return fileName;
|
|
}
|
|
|
|
public void CreateSQLDELETEStatement(IList<CookBook> input, StreamWriter writer)
|
|
{
|
|
foreach (var value in input)
|
|
writer.WriteLine($"DELETE FROM `cook_book` WHERE `recipe_Id` = {value.RecipeId};");
|
|
}
|
|
|
|
public void CreateSQLINSERTStatement(IList<CookBook> input, StreamWriter writer)
|
|
{
|
|
writer.WriteLine("INSERT INTO `cook_book` (`recipe_Id`, `source_W_C_I_D`, `target_W_C_I_D`)");
|
|
|
|
var lineGenerator = new Func<int, string>(i =>
|
|
{
|
|
string sourceLabel = null;
|
|
if (WeenieNames != null)
|
|
WeenieNames.TryGetValue(input[i].SourceWCID, out sourceLabel);
|
|
|
|
string targetLabel = null;
|
|
if (WeenieNames != null)
|
|
WeenieNames.TryGetValue(input[i].TargetWCID, out targetLabel);
|
|
|
|
return $"{input[i].RecipeId}, {input[i].SourceWCID} /* {sourceLabel} */, {input[i].TargetWCID.ToString().PadLeft(5)} /* {targetLabel} */)";
|
|
});
|
|
|
|
ValuesWriter(input.Count, lineGenerator, writer);
|
|
}
|
|
}
|
|
}
|