mirror of
https://github.com/ACEmulator/ACE
synced 2026-08-17 12:26:06 -04:00
46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
|
|
using System;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.IO;
|
||
|
|
|
||
|
|
using ACE.Database.Models.World;
|
||
|
|
|
||
|
|
namespace ACE.Database.SQLFormatters.World
|
||
|
|
{
|
||
|
|
public class EncounterSQLWriter : SQLWriter
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// Default is formed from: input.Landblock.ToString("X4")
|
||
|
|
/// </summary>
|
||
|
|
public string GetDefaultFileName(Encounter input)
|
||
|
|
{
|
||
|
|
string fileName = input.Landblock.ToString("X4");
|
||
|
|
fileName = IllegalInFileName.Replace(fileName, "_");
|
||
|
|
fileName += ".sql";
|
||
|
|
|
||
|
|
return fileName;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void CreateSQLDELETEStatement(IList<Encounter> input, StreamWriter writer)
|
||
|
|
{
|
||
|
|
throw new NotImplementedException();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void CreateSQLINSERTStatement(IList<Encounter> input, StreamWriter writer)
|
||
|
|
{
|
||
|
|
writer.WriteLine("INSERT INTO `encounter` (`landblock`, `weenie_Class_Id`, `cell_X`, `cell_Y`)");
|
||
|
|
|
||
|
|
var lineGenerator = new Func<int, string>(i =>
|
||
|
|
{
|
||
|
|
string label = null;
|
||
|
|
|
||
|
|
if (WeenieNames != null)
|
||
|
|
WeenieNames.TryGetValue(input[i].WeenieClassId, out label);
|
||
|
|
|
||
|
|
return $"{input[i].Landblock}, {input[i].WeenieClassId}, {input[i].CellX}, {input[i].CellY}) /* {label} */";
|
||
|
|
});
|
||
|
|
|
||
|
|
ValuesWriter(input.Count, lineGenerator, writer);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|