Add list of regions to the database.

This commit is contained in:
Greg Edwards 2015-05-02 16:15:03 -04:00
parent c714be02ec
commit 01b3c9a3ef
3 changed files with 39 additions and 0 deletions

View File

@ -607,6 +607,14 @@ namespace VeekunImport
}
}
// pkmncf_pokedex_regions
ProcessTSV("regions.txt", fields =>
{
if (fields.Length < 2) return;
int id = Convert.ToInt32(fields[0]);
db.PokedexInsertRegion(new Region(null, id, new LocalizedString(){{"EN", fields[1]}}));
});
connVeekun.Close();
}
@ -633,6 +641,27 @@ namespace VeekunImport
if (reader["damage_class_id"] is DBNull) return DamageClass.None;
return (DamageClass)(Convert.ToInt32(reader["damage_class_id"]) - 1);
}
private static bool ProcessTSV(String filename, Action<String[]> action)
{
if (!File.Exists(filename))
{
Console.WriteLine("File {0} not found, skipped.", filename);
return false;
}
using (FileStream fs = File.Open(filename, FileMode.Open))
{
StreamReader sr = new StreamReader(fs, Encoding.UTF8);
String line;
while ((line = sr.ReadLine()) != null)
{
String[] fields = line.Split('\t');
action(fields);
}
fs.Close();
}
return true;
}
}
internal class ItemLoading

View File

@ -92,6 +92,7 @@
<Content Include="families.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="regions.txt" />
<Content Include="ribbons.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>

9
VeekunImport/regions.txt Normal file
View File

@ -0,0 +1,9 @@
1 Event
2 Kanto
3 Johto
4 Hoenn
5 Orre
6 Sevii Islands
7 Sinnoh
8 Unova
9 Kalos