Added logic to override (incorrect) form values from veekun.

This commit is contained in:
Greg Edwards
2015-02-10 13:36:29 -05:00
parent 9e33f63ecb
commit a7437dd691
3 changed files with 119 additions and 11 deletions

View File

@@ -68,8 +68,7 @@ namespace VeekunImport
{
lineNumber++;
String[] fields = line.Split('\t');
// todo: allow and reject blank lines at the end.
if (fields.Length == 0) throw new Exception("families_map.txt has a blank line.");
if (fields.Length == 0) continue;
int[] fieldsInt = fields.Select(s => Convert.ToInt32(s)).ToArray();
familyList.Add(fieldsInt);
foreach (int x in fieldsInt)
@@ -189,6 +188,45 @@ namespace VeekunImport
rdPokemon.Close();
// pkmncf_pokedex_pokemon_forms
/*
* List<Family> overrideFamilies = new List<Family>();
using (FileStream fs = File.Open("families.txt", FileMode.Open))
{
StreamReader sr = new StreamReader(fs, Encoding.UTF8);
String line;
while ((line = sr.ReadLine()) != null)
{
String[] fields = line.Split('\t');
overrideFamilies.Add(new Family(null,
Convert.ToInt32(fields[0]),
Convert.ToInt32(fields[1]),
Convert.ToInt32(fields[2]),
Convert.ToInt32(fields[3]),
Convert.ToInt32(fields[4]),
Convert.ToInt32(fields[5]),
Convert.ToByte(fields[6])
));
}
}
*/
// xxx: DRY these file parsers up by adding a helper that takes
// a filename and a lambda of what to run for each line in the document.
Dictionary<int, byte> formValueMap = new Dictionary<int, byte>();
using (FileStream fs = File.Open("form_values.txt", FileMode.Open))
{
StreamReader sr = new StreamReader(fs, Encoding.UTF8);
String line;
while ((line = sr.ReadLine()) != null)
{
String[] fields = line.Split('\t');
if (fields.Length == 0) continue;
if (fields.Length != 3) throw new Exception("form_values.txt has a line with unexpected number of tabs.");
formValueMap.Add(Convert.ToInt32(fields[1]), Convert.ToByte(fields[2]));
}
}
SQLiteDataReader rdForms = (SQLiteDataReader)connVeekun.ExecuteReader("SELECT id, " +
"(SELECT species_id FROM pokemon WHERE id = pokemon_id) AS NationalDex, " +
"form_order - 1 AS FormValue, " +
@@ -215,6 +253,8 @@ namespace VeekunImport
int weight = Convert.ToInt32(rdForms["weight"]);
int experience = Convert.ToInt32(rdForms["experience"]);
if (formValueMap.ContainsKey(id)) FormValue = formValueMap[id];
Form f = new Form(null, id,
NationalDex, FormValue,
GetLocalizedString(rdForms, "name_"),

View File

@@ -54,31 +54,34 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="form_stats1.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="form_stats6.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="form_stats5.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="form_stats4.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="form_stats3.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="form_stats2.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="form_values.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="items3.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="items5.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="items4.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="families.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

View File

@@ -0,0 +1,65 @@
201 201 0
201 10001 1
201 10002 2
201 10003 3
201 10004 4
201 10005 5
201 10006 6
201 10007 7
201 10008 8
201 10009 9
201 10010 10
201 10011 11
201 10012 12
201 10013 13
201 10014 14
201 10015 15
201 10016 16
201 10017 17
201 10018 18
201 10019 19
201 10020 20
201 10021 21
201 10022 22
201 10023 23
201 10024 24
201 10025 25
201 10026 26
201 10027 27
493 493 0
493 10045 1
493 10047 2
493 10052 3
493 10050 4
493 10054 5
493 10041 6
493 10048 7
493 10055 8
493 10046 9
493 10056 10
493 10049 11
493 10044 12
493 10053 13
493 10051 14
493 10043 15
493 10042 16
493 10057 31
493 10085 17
646 646 0
646 10083 1
646 10082 2
649 649 0
649 10075 1
649 10076 2
649 10077 3
649 10078 4
676 676 0
676 10115 1
676 10116 2
676 10117 3
676 10118 4
676 10119 5
676 10120 6
676 10121 7
676 10122 8
676 10123 9