2018-07-28 21:01:19 -05:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
using ACE.Database.Models.World;
|
|
|
|
|
using ACE.Entity.Enum;
|
|
|
|
|
using ACE.Entity.Enum.Properties;
|
|
|
|
|
|
|
|
|
|
namespace ACE.Database.SQLFormatters.World
|
|
|
|
|
{
|
|
|
|
|
public class RecipeSQLWriter : SQLWriter
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Default is formed from: input.RecipeId.ToString("00000") + " " + [SuccessWeenieName or Cook Book Source]
|
|
|
|
|
/// </summary>
|
2020-02-26 23:54:17 -05:00
|
|
|
public string GetDefaultFileName(Recipe input, IList<CookBook> cookBooks, bool descOnly = false)
|
2018-07-28 21:01:19 -05:00
|
|
|
{
|
|
|
|
|
string description = null;
|
|
|
|
|
|
|
|
|
|
if (WeenieNames != null)
|
|
|
|
|
{
|
|
|
|
|
if (WeenieNames.TryGetValue(input.SuccessWCID, out var weenieName))
|
|
|
|
|
description = weenieName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string alternateDescription = null;
|
|
|
|
|
|
|
|
|
|
if (cookBooks != null && cookBooks.Count > 0 && WeenieNames != null)
|
|
|
|
|
{
|
|
|
|
|
WeenieNames.TryGetValue(cookBooks[0].SourceWCID, out alternateDescription);
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i < cookBooks.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (WeenieNames.TryGetValue(cookBooks[i].SourceWCID, out var sourceWeenieName) && sourceWeenieName != alternateDescription)
|
|
|
|
|
{
|
|
|
|
|
alternateDescription = null;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-12 03:31:38 -05:00
|
|
|
if (string.IsNullOrEmpty(description) && !string.IsNullOrEmpty(alternateDescription))
|
2018-07-28 21:01:19 -05:00
|
|
|
description = alternateDescription;
|
|
|
|
|
|
2020-02-12 03:31:38 -05:00
|
|
|
if (description == "Cooking Pot" && !string.IsNullOrEmpty(alternateDescription))
|
2018-07-28 21:01:19 -05:00
|
|
|
description = alternateDescription;
|
|
|
|
|
|
2020-02-26 23:54:17 -05:00
|
|
|
if (descOnly)
|
|
|
|
|
return description;
|
|
|
|
|
|
2018-08-01 21:35:18 -05:00
|
|
|
string fileName = input.Id.ToString("00000");
|
2020-02-12 03:31:38 -05:00
|
|
|
if (!string.IsNullOrEmpty(description))
|
2018-07-28 21:01:19 -05:00
|
|
|
fileName += " " + description;
|
|
|
|
|
fileName = IllegalInFileName.Replace(fileName, "_");
|
|
|
|
|
fileName += ".sql";
|
|
|
|
|
|
|
|
|
|
return fileName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CreateSQLDELETEStatement(Recipe input, StreamWriter writer)
|
|
|
|
|
{
|
2019-02-11 14:35:18 -06:00
|
|
|
writer.WriteLine($"DELETE FROM `recipe` WHERE `id` = {input.Id};");
|
2018-07-28 21:01:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CreateSQLINSERTStatement(Recipe input, StreamWriter writer)
|
|
|
|
|
{
|
2018-08-01 22:09:09 -05:00
|
|
|
writer.WriteLine("INSERT INTO `recipe` (`id`, `unknown_1`, `skill`, `difficulty`, `salvage_Type`, `success_W_C_I_D`, `success_Amount`, `success_Message`, `fail_W_C_I_D`, `fail_Amount`, `fail_Message`, " +
|
|
|
|
|
"`success_Destroy_Source_Chance`, `success_Destroy_Source_Amount`, `success_Destroy_Source_Message`, `success_Destroy_Target_Chance`, `success_Destroy_Target_Amount`, `success_Destroy_Target_Message`, " +
|
|
|
|
|
"`fail_Destroy_Source_Chance`, `fail_Destroy_Source_Amount`, `fail_Destroy_Source_Message`, `fail_Destroy_Target_Chance`, `fail_Destroy_Target_Amount`, `fail_Destroy_Target_Message`, " +
|
2019-02-04 11:55:13 -06:00
|
|
|
"`data_Id`, `last_Modified`)");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
|
|
|
|
string skillLabel = null;
|
|
|
|
|
if (input.Skill != 0)
|
|
|
|
|
skillLabel = Enum.GetName(typeof(Skill), input.Skill);
|
|
|
|
|
|
|
|
|
|
string successWeenieLabel = null;
|
|
|
|
|
if (WeenieNames != null)
|
|
|
|
|
WeenieNames.TryGetValue(input.SuccessWCID, out successWeenieLabel);
|
|
|
|
|
|
|
|
|
|
string failWeenieLabel = null;
|
|
|
|
|
if (WeenieNames != null)
|
|
|
|
|
WeenieNames.TryGetValue(input.FailWCID, out failWeenieLabel);
|
|
|
|
|
|
|
|
|
|
var output = "VALUES (" +
|
2018-08-01 22:09:09 -05:00
|
|
|
$"{input.Id}, " +
|
|
|
|
|
$"{input.Unknown1}, " +
|
|
|
|
|
$"{input.Skill} /* {skillLabel} */, " +
|
|
|
|
|
$"{input.Difficulty}, " +
|
|
|
|
|
$"{input.SalvageType}, " +
|
|
|
|
|
$"{input.SuccessWCID} /* {successWeenieLabel} */, " +
|
|
|
|
|
$"{input.SuccessAmount}, " +
|
|
|
|
|
$"{GetSQLString(input.SuccessMessage)}, " +
|
|
|
|
|
$"{input.FailWCID} /* {failWeenieLabel} */, " +
|
|
|
|
|
$"{input.FailAmount}, " +
|
|
|
|
|
$"{GetSQLString(input.FailMessage)}, " +
|
|
|
|
|
$"{input.SuccessDestroySourceChance}, " +
|
|
|
|
|
$"{input.SuccessDestroySourceAmount}, " +
|
|
|
|
|
$"{GetSQLString(input.SuccessDestroySourceMessage)}, " +
|
|
|
|
|
$"{input.SuccessDestroyTargetChance}, " +
|
|
|
|
|
$"{input.SuccessDestroyTargetAmount}, " +
|
|
|
|
|
$"{GetSQLString(input.SuccessDestroyTargetMessage)}, " +
|
|
|
|
|
$"{input.FailDestroySourceChance}, " +
|
|
|
|
|
$"{input.FailDestroySourceAmount}, " +
|
|
|
|
|
$"{GetSQLString(input.FailDestroySourceMessage)}, " +
|
|
|
|
|
$"{input.FailDestroyTargetChance}, " +
|
|
|
|
|
$"{input.FailDestroyTargetAmount}, " +
|
|
|
|
|
$"{GetSQLString(input.FailDestroyTargetMessage)}, " +
|
2019-02-04 11:55:13 -06:00
|
|
|
$"{input.DataId}, " +
|
2019-04-10 20:48:34 -05:00
|
|
|
$"'{input.LastModified:yyyy-MM-dd HH:mm:ss}'" +
|
2018-08-01 22:09:09 -05:00
|
|
|
");";
|
2018-07-28 21:01:19 -05:00
|
|
|
|
|
|
|
|
output = FixNullFields(output);
|
|
|
|
|
|
|
|
|
|
writer.WriteLine(output);
|
|
|
|
|
|
|
|
|
|
if (input.RecipeRequirementsInt != null && input.RecipeRequirementsInt.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteLine();
|
2018-08-01 21:35:18 -05:00
|
|
|
CreateSQLINSERTStatement(input.Id, input.RecipeRequirementsInt.ToList(), writer);
|
2018-07-28 21:01:19 -05:00
|
|
|
}
|
|
|
|
|
if (input.RecipeRequirementsDID != null && input.RecipeRequirementsDID.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteLine();
|
2018-08-01 21:35:18 -05:00
|
|
|
CreateSQLINSERTStatement(input.Id, input.RecipeRequirementsDID.ToList(), writer);
|
2018-07-28 21:01:19 -05:00
|
|
|
}
|
|
|
|
|
if (input.RecipeRequirementsIID != null && input.RecipeRequirementsIID.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteLine();
|
2018-08-01 21:35:18 -05:00
|
|
|
CreateSQLINSERTStatement(input.Id, input.RecipeRequirementsIID.ToList(), writer);
|
2018-07-28 21:01:19 -05:00
|
|
|
}
|
|
|
|
|
if (input.RecipeRequirementsFloat != null && input.RecipeRequirementsFloat.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteLine();
|
2018-08-01 21:35:18 -05:00
|
|
|
CreateSQLINSERTStatement(input.Id, input.RecipeRequirementsFloat.ToList(), writer);
|
2018-07-28 21:01:19 -05:00
|
|
|
}
|
|
|
|
|
if (input.RecipeRequirementsString != null && input.RecipeRequirementsString.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteLine();
|
2018-08-01 21:35:18 -05:00
|
|
|
CreateSQLINSERTStatement(input.Id, input.RecipeRequirementsString.ToList(), writer);
|
2018-07-28 21:01:19 -05:00
|
|
|
}
|
|
|
|
|
if (input.RecipeRequirementsBool != null && input.RecipeRequirementsBool.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteLine();
|
2018-08-01 21:35:18 -05:00
|
|
|
CreateSQLINSERTStatement(input.Id, input.RecipeRequirementsBool.ToList(), writer);
|
2018-07-28 21:01:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (input.RecipeMod != null && input.RecipeMod.Count > 0)
|
|
|
|
|
{
|
2018-08-01 18:47:05 -05:00
|
|
|
//writer.WriteLine(); // This is not needed because CreateSQLINSERTStatement will take care of it for us on each Recipe.
|
2018-08-01 21:35:18 -05:00
|
|
|
CreateSQLINSERTStatement(input.Id, input.RecipeMod.ToList(), writer);
|
2018-07-28 21:01:19 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CreateSQLINSERTStatement(uint recipeId, IList<RecipeRequirementsInt> input, StreamWriter writer)
|
|
|
|
|
{
|
2019-04-13 15:07:09 -05:00
|
|
|
writer.WriteLine("INSERT INTO `recipe_requirements_int` (`recipe_Id`, `index`, `stat`, `value`, `enum`, `message`)");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
|
|
|
|
var lineGenerator = new Func<int, string>(i =>
|
|
|
|
|
{
|
|
|
|
|
string propertyValueDescription = GetValueEnumName((PropertyInt)input[i].Stat, input[i].Value);
|
|
|
|
|
|
|
|
|
|
var comment = Enum.GetName(typeof(PropertyInt), input[i].Stat);
|
|
|
|
|
if (propertyValueDescription != null)
|
|
|
|
|
comment += " - " + propertyValueDescription;
|
|
|
|
|
|
2019-05-01 19:44:03 -05:00
|
|
|
return $"{recipeId}, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {input[i].Value}, {input[i].Enum}, {GetSQLString(input[i].Message)}) /* {((RequirementType)input[i].Index).ToString()}.{comment} {((CompareType)input[i].Enum).ToString()} {input[i].Value} */";
|
2018-07-28 21:01:19 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ValuesWriter(input.Count, lineGenerator, writer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CreateSQLINSERTStatement(uint recipeId, IList<RecipeRequirementsDID> input, StreamWriter writer)
|
|
|
|
|
{
|
2019-04-13 15:07:09 -05:00
|
|
|
writer.WriteLine("INSERT INTO `recipe_requirements_d_i_d` (`recipe_Id`, `index`, `stat`, `value`, `enum`, `message`)");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
2019-05-01 19:44:03 -05:00
|
|
|
var lineGenerator = new Func<int, string>(i => $"{recipeId}, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {input[i].Value}, {input[i].Enum}, {GetSQLString(input[i].Message)}) /* {((RequirementType)input[i].Index).ToString()}.{Enum.GetName(typeof(PropertyDataId), input[i].Stat)} {((CompareType)input[i].Enum).ToString()} {input[i].Value} */");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
|
|
|
|
ValuesWriter(input.Count, lineGenerator, writer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CreateSQLINSERTStatement(uint recipeId, IList<RecipeRequirementsIID> input, StreamWriter writer)
|
|
|
|
|
{
|
2019-04-13 15:07:09 -05:00
|
|
|
writer.WriteLine("INSERT INTO `recipe_requirements_i_i_d` (`recipe_Id`, `index`, `stat`, `value`, `enum`, `message`)");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
2019-05-01 19:44:03 -05:00
|
|
|
var lineGenerator = new Func<int, string>(i => $"{recipeId}, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {input[i].Value}, {input[i].Enum}, {GetSQLString(input[i].Message)}) /* {((RequirementType)input[i].Index).ToString()}.{Enum.GetName(typeof(PropertyInstanceId), input[i].Stat)} {((CompareType)input[i].Enum).ToString()} {input[i].Value} */");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
|
|
|
|
ValuesWriter(input.Count, lineGenerator, writer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CreateSQLINSERTStatement(uint recipeId, IList<RecipeRequirementsFloat> input, StreamWriter writer)
|
|
|
|
|
{
|
2019-04-13 15:07:09 -05:00
|
|
|
writer.WriteLine("INSERT INTO `recipe_requirements_float` (`recipe_Id`, `index`, `stat`, `value`, `enum`, `message`)");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
2019-05-01 19:44:03 -05:00
|
|
|
var lineGenerator = new Func<int, string>(i => $"{recipeId}, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {input[i].Value}, {input[i].Enum}, {GetSQLString(input[i].Message)}) /* {((RequirementType)input[i].Index).ToString()}.{Enum.GetName(typeof(PropertyFloat), input[i].Stat)} {((CompareType)input[i].Enum).ToString()} {input[i].Value} */");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
|
|
|
|
ValuesWriter(input.Count, lineGenerator, writer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CreateSQLINSERTStatement(uint recipeId, IList<RecipeRequirementsString> input, StreamWriter writer)
|
|
|
|
|
{
|
2019-04-13 15:07:09 -05:00
|
|
|
writer.WriteLine("INSERT INTO `recipe_requirements_string` (`recipe_Id`, `index`, `stat`, `value`, `enum`, `message`)");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
2019-05-01 19:44:03 -05:00
|
|
|
var lineGenerator = new Func<int, string>(i => $"{recipeId}, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {GetSQLString(input[i].Value)}, {input[i].Enum}, {GetSQLString(input[i].Message)}) /* {((RequirementType)input[i].Index).ToString()}.{Enum.GetName(typeof(PropertyString), input[i].Stat)} {((CompareType)input[i].Enum).ToString()} {input[i].Value} */");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
|
|
|
|
ValuesWriter(input.Count, lineGenerator, writer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CreateSQLINSERTStatement(uint recipeId, IList<RecipeRequirementsBool> input, StreamWriter writer)
|
|
|
|
|
{
|
2019-04-13 15:07:09 -05:00
|
|
|
writer.WriteLine("INSERT INTO `recipe_requirements_bool` (`recipe_Id`, `index`, `stat`, `value`, `enum`, `message`)");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
2019-05-01 19:44:03 -05:00
|
|
|
var lineGenerator = new Func<int, string>(i => $"{recipeId}, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {input[i].Value}, {input[i].Enum}, {GetSQLString(input[i].Message)}) /* {((RequirementType)input[i].Index).ToString()}.{Enum.GetName(typeof(PropertyBool), input[i].Stat)} {((CompareType)input[i].Enum).ToString()} {input[i].Value} */");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
|
|
|
|
ValuesWriter(input.Count, lineGenerator, writer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CreateSQLINSERTStatement(uint recipeId, IList<RecipeMod> input, StreamWriter writer)
|
|
|
|
|
{
|
2018-08-01 18:47:05 -05:00
|
|
|
foreach (var value in input)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteLine();
|
2018-08-01 22:54:06 -05:00
|
|
|
writer.WriteLine("INSERT INTO `recipe_mod` (`recipe_Id`, `executes_On_Success`, `health`, `stamina`, `mana`, `unknown_7`, `data_Id`, `unknown_9`, `instance_Id`)");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
2021-11-07 03:53:43 -05:00
|
|
|
var output = $"VALUES ({recipeId}, {value.ExecutesOnSuccess}, {value.Health}, {value.Stamina}, {value.Mana}, {value.Unknown7}, {(value.DataId > 0 ? $"0x{value.DataId:X8}" : $"{value.DataId}")}, {value.Unknown9}, {value.InstanceId});";
|
2018-07-28 21:01:19 -05:00
|
|
|
|
2018-08-01 18:47:05 -05:00
|
|
|
output = FixNullFields(output);
|
|
|
|
|
|
|
|
|
|
writer.WriteLine(output);
|
|
|
|
|
|
|
|
|
|
if ((value.RecipeModsInt != null && value.RecipeModsInt.Count > 0) ||
|
|
|
|
|
(value.RecipeModsDID != null && value.RecipeModsDID.Count > 0) ||
|
|
|
|
|
(value.RecipeModsIID != null && value.RecipeModsIID.Count > 0) ||
|
|
|
|
|
(value.RecipeModsFloat != null && value.RecipeModsFloat.Count > 0) ||
|
|
|
|
|
(value.RecipeModsString != null && value.RecipeModsString.Count > 0) ||
|
|
|
|
|
(value.RecipeModsBool != null && value.RecipeModsBool.Count > 0))
|
|
|
|
|
{
|
|
|
|
|
writer.WriteLine();
|
|
|
|
|
writer.WriteLine("SET @parent_id = LAST_INSERT_ID();");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (value.RecipeModsInt != null && value.RecipeModsInt.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteLine();
|
|
|
|
|
CreateSQLINSERTStatement(value.RecipeModsInt.ToList(), writer);
|
|
|
|
|
}
|
|
|
|
|
if (value.RecipeModsDID != null && value.RecipeModsDID.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteLine();
|
|
|
|
|
CreateSQLINSERTStatement(value.RecipeModsDID.ToList(), writer);
|
|
|
|
|
}
|
|
|
|
|
if (value.RecipeModsIID != null && value.RecipeModsIID.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteLine();
|
|
|
|
|
CreateSQLINSERTStatement(value.RecipeModsIID.ToList(), writer);
|
|
|
|
|
}
|
|
|
|
|
if (value.RecipeModsFloat != null && value.RecipeModsFloat.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteLine();
|
|
|
|
|
CreateSQLINSERTStatement(value.RecipeModsFloat.ToList(), writer);
|
|
|
|
|
}
|
|
|
|
|
if (value.RecipeModsString != null && value.RecipeModsString.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteLine();
|
|
|
|
|
CreateSQLINSERTStatement(value.RecipeModsString.ToList(), writer);
|
|
|
|
|
}
|
|
|
|
|
if (value.RecipeModsBool != null && value.RecipeModsBool.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteLine();
|
|
|
|
|
CreateSQLINSERTStatement(value.RecipeModsBool.ToList(), writer);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-28 21:01:19 -05:00
|
|
|
}
|
|
|
|
|
|
2018-08-01 18:47:05 -05:00
|
|
|
private void CreateSQLINSERTStatement(IList<RecipeModsInt> input, StreamWriter writer)
|
2018-07-28 21:01:19 -05:00
|
|
|
{
|
2019-04-13 15:07:09 -05:00
|
|
|
writer.WriteLine("INSERT INTO `recipe_mods_int` (`recipe_Mod_Id`, `index`, `stat`, `value`, `enum`, `source`)");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
|
|
|
|
var lineGenerator = new Func<int, string>(i =>
|
|
|
|
|
{
|
|
|
|
|
string propertyValueDescription = GetValueEnumName((PropertyInt)input[i].Stat, input[i].Value);
|
|
|
|
|
|
|
|
|
|
var comment = Enum.GetName(typeof(PropertyInt), input[i].Stat);
|
|
|
|
|
if (propertyValueDescription != null)
|
|
|
|
|
comment += " - " + propertyValueDescription;
|
|
|
|
|
|
2019-05-01 19:44:03 -05:00
|
|
|
return $"@parent_id, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {input[i].Value}, {input[i].Enum}, {input[i].Source}) /* On {((RecipeSourceType)input[i].Source).ToString()}.{((ModificationType)input[i].Index).ToString()} {((ModificationOperation)input[i].Enum).ToString()}{(comment == null ? "" : $" {comment}")}{(comment != null && comment.Contains(" - ") || input[i].Enum == 7 ? "" : $" {input[i].Value}")}{(input[i].Enum == 7 ? $" {((SpellId)input[i].Stat).ToString()}" : "")} to {((ModificationType)input[i].Index).ToString().Substring(7)} */";
|
2018-07-28 21:01:19 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ValuesWriter(input.Count, lineGenerator, writer);
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-01 18:47:05 -05:00
|
|
|
private void CreateSQLINSERTStatement(IList<RecipeModsDID> input, StreamWriter writer)
|
2018-07-28 21:01:19 -05:00
|
|
|
{
|
2019-04-13 15:07:09 -05:00
|
|
|
writer.WriteLine("INSERT INTO `recipe_mods_d_i_d` (`recipe_Mod_Id`, `index`, `stat`, `value`, `enum`, `source`)");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
2019-05-01 19:44:03 -05:00
|
|
|
var lineGenerator = new Func<int, string>(i => $"@parent_id, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {input[i].Value}, {input[i].Enum}, {input[i].Source}) /* On {((RecipeSourceType)input[i].Source).ToString()}.{((ModificationType)input[i].Index).ToString()} {((ModificationOperation)input[i].Enum).ToString()} {Enum.GetName(typeof(PropertyDataId), input[i].Stat)} to {((ModificationType)input[i].Index).ToString().Substring(7)} */");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
|
|
|
|
ValuesWriter(input.Count, lineGenerator, writer);
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-01 18:47:05 -05:00
|
|
|
private void CreateSQLINSERTStatement(IList<RecipeModsIID> input, StreamWriter writer)
|
2018-07-28 21:01:19 -05:00
|
|
|
{
|
2019-04-13 15:07:09 -05:00
|
|
|
writer.WriteLine("INSERT INTO `recipe_mods_i_i_d` (`recipe_Mod_Id`, `index`, `stat`, `value`, `enum`, `source`)");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
2019-05-01 19:44:03 -05:00
|
|
|
var lineGenerator = new Func<int, string>(i => $"@parent_id, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {input[i].Value}, {input[i].Enum}, {input[i].Source}) /* On {((RecipeSourceType)input[i].Source).ToString()}.{((ModificationType)input[i].Index).ToString()} {((ModificationOperation)input[i].Enum).ToString()} {Enum.GetName(typeof(PropertyInstanceId), input[i].Stat)} to {((ModificationType)input[i].Index).ToString().Substring(7)} */");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
|
|
|
|
ValuesWriter(input.Count, lineGenerator, writer);
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-01 18:47:05 -05:00
|
|
|
private void CreateSQLINSERTStatement(IList<RecipeModsFloat> input, StreamWriter writer)
|
2018-07-28 21:01:19 -05:00
|
|
|
{
|
2019-04-13 15:07:09 -05:00
|
|
|
writer.WriteLine("INSERT INTO `recipe_mods_float` (`recipe_Mod_Id`, `index`, `stat`, `value`, `enum`, `source`)");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
2019-05-01 19:44:03 -05:00
|
|
|
var lineGenerator = new Func<int, string>(i => $"@parent_id, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {input[i].Value}, {input[i].Enum}, {input[i].Source}) /* On {((RecipeSourceType)input[i].Source).ToString()}.{((ModificationType)input[i].Index).ToString()} {((ModificationOperation)input[i].Enum).ToString()} {Enum.GetName(typeof(PropertyFloat), input[i].Stat)} to {((ModificationType)input[i].Index).ToString().Substring(7)} */");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
|
|
|
|
ValuesWriter(input.Count, lineGenerator, writer);
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-01 18:47:05 -05:00
|
|
|
private void CreateSQLINSERTStatement(IList<RecipeModsString> input, StreamWriter writer)
|
2018-07-28 21:01:19 -05:00
|
|
|
{
|
2019-04-13 15:07:09 -05:00
|
|
|
writer.WriteLine("INSERT INTO `recipe_mods_string` (`recipe_Mod_Id`, `index`, `stat`, `value`, `enum`, `source`)");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
2019-05-01 19:44:03 -05:00
|
|
|
var lineGenerator = new Func<int, string>(i => $"@parent_id, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {GetSQLString(input[i].Value)}, {input[i].Enum}, {input[i].Source}) /* On {((RecipeSourceType)input[i].Source).ToString()}.{((ModificationType)input[i].Index).ToString()} {((ModificationOperation)input[i].Enum).ToString()} {Enum.GetName(typeof(PropertyString), input[i].Stat)} to {((ModificationType)input[i].Index).ToString().Substring(7)} */");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
|
|
|
|
ValuesWriter(input.Count, lineGenerator, writer);
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-01 18:47:05 -05:00
|
|
|
private void CreateSQLINSERTStatement(IList<RecipeModsBool> input, StreamWriter writer)
|
2018-07-28 21:01:19 -05:00
|
|
|
{
|
2019-04-13 15:07:09 -05:00
|
|
|
writer.WriteLine("INSERT INTO `recipe_mods_bool` (`recipe_Mod_Id`, `index`, `stat`, `value`, `enum`, `source`)");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
2019-05-01 19:44:03 -05:00
|
|
|
var lineGenerator = new Func<int, string>(i => $"@parent_id, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {input[i].Value}, {input[i].Enum}, {input[i].Source}) /* On {((RecipeSourceType)input[i].Source).ToString()}.{((ModificationType)input[i].Index).ToString()} {((ModificationOperation)input[i].Enum).ToString()} {Enum.GetName(typeof(PropertyBool), input[i].Stat)} to {((ModificationType)input[i].Index).ToString().Substring(7)} */");
|
2018-07-28 21:01:19 -05:00
|
|
|
|
|
|
|
|
ValuesWriter(input.Count, lineGenerator, writer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|