mirror of
https://github.com/mm201/pkmn-classic-framework.git
synced 2026-08-01 23:53:39 -05:00
Added families to VeekunImport project.
This commit is contained in:
parent
30b820b87f
commit
3cacfbb608
|
|
@ -51,6 +51,93 @@ namespace VeekunImport
|
|||
// 2. foreach DataRow, instance a class from the PkmnFoundations.Pokedex namespace.
|
||||
// 3. call Database.AddToPokedex on that object.
|
||||
|
||||
// pkmncf_pokedex_pokemon_families
|
||||
// Obtain the families map. We will use it in a few places.
|
||||
Dictionary<int, int> familyMap = new Dictionary<int, int>();
|
||||
List<int[]> familyList = new List<int[]>();
|
||||
using (FileStream fs = File.Open("families_map.txt", FileMode.Open))
|
||||
{
|
||||
StreamReader sr = new StreamReader(fs, Encoding.UTF8);
|
||||
int lineNumber = 0;
|
||||
String line;
|
||||
while ((line = sr.ReadLine()) != null)
|
||||
{
|
||||
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.");
|
||||
int[] fieldsInt = fields.Select(s => Convert.ToInt32(s)).ToArray();
|
||||
familyList.Add(fieldsInt);
|
||||
foreach (int x in fieldsInt)
|
||||
{
|
||||
// lineNumber is one-based, unlike familyList index.
|
||||
// species is the key, family ID is the value.
|
||||
// If any species is repeated in family_map.txt, this ought to fail.
|
||||
familyMap.Add(x, lineNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// families from families.txt override default behaviour.
|
||||
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])
|
||||
));
|
||||
}
|
||||
}
|
||||
// already sorted
|
||||
//someFamilies.Sort((f, other) => f.ID.CompareTo(other.ID));
|
||||
|
||||
int familyCount = familyList.Count;
|
||||
int nextOverrideIndex = 0;
|
||||
for (int familyId = 1; familyId <= familyCount; familyId++)
|
||||
{
|
||||
int basicSpeciesId = familyList[familyId - 1][0];
|
||||
Family f;
|
||||
if (nextOverrideIndex < overrideFamilies.Count && overrideFamilies[nextOverrideIndex].ID == familyId)
|
||||
{
|
||||
// An override exists in the table; use it.
|
||||
f = overrideFamilies[nextOverrideIndex];
|
||||
nextOverrideIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No override exists so go with default:
|
||||
// Basic male/female are the same species which is the one listed first.
|
||||
// There is no baby species nor incense
|
||||
// (Non-incense babies are considered basic in this system anyway.)
|
||||
// Gender ratio comes from the basic species.
|
||||
byte genderRatio = (byte)Convert.ToInt32(connVeekun.ExecuteScalar("SELECT gender_rate FROM pokemon_species WHERE id = @id", new SQLiteParameter("@id", basicSpeciesId)));
|
||||
f = new Family(null, familyId, basicSpeciesId, basicSpeciesId, 0, 0, 0, genderRatio);
|
||||
}
|
||||
db.PokedexInsertFamily(f);
|
||||
String basic = (f.BasicMaleID != f.BasicFemaleID) ?
|
||||
String.Format(" {0}/{1}", f.BasicMaleID, f.BasicFemaleID) :
|
||||
String.Format(" {0}", f.BasicMaleID);
|
||||
String baby;
|
||||
if (f.BabyMaleID != f.BabyFemaleID)
|
||||
baby = String.Format(" {0}/{1} incense {2}", f.BabyMaleID, f.BabyFemaleID, f.IncenseID);
|
||||
else
|
||||
baby = (f.BabyMaleID == 0) ? "" :
|
||||
String.Format(" {0} incense {1}", f.BabyMaleID, f.IncenseID);
|
||||
String gender = (f.GenderRatio == 255) ? "genderless" :
|
||||
String.Format("{0}% female", (float)f.GenderRatio * 12.5f);
|
||||
Console.WriteLine("Inserted family {0}{1}{2} {3}", f.ID, basic, baby, gender);
|
||||
}
|
||||
|
||||
// pkmncf_pokedex_pokemon
|
||||
SQLiteDataReader rdPokemon = (SQLiteDataReader)connVeekun.ExecuteReader("SELECT " +
|
||||
"pokemon_species.id, " +
|
||||
|
|
@ -81,6 +168,7 @@ namespace VeekunImport
|
|||
|
||||
// todo: Family ID
|
||||
Species s = new Species(null, id,
|
||||
familyMap[id],
|
||||
GetLocalizedString(rdPokemon, "name_"),
|
||||
(GrowthRates)growth_rate_id,
|
||||
(byte)gender_rate,
|
||||
|
|
@ -139,8 +227,10 @@ namespace VeekunImport
|
|||
}
|
||||
rdForms.Close();
|
||||
|
||||
// pkmncf_pokedex_pokemon_families
|
||||
// pkmncf_pokedex_pokemon_evolutions
|
||||
// todo: pkmncf_pokedex_pokemon_form_stats_x
|
||||
// todo: pkmncf_pokedex_pokemon_families
|
||||
// todo: pkmncf_pokedex_pokemon_evolutions
|
||||
|
||||
// pkmncf_pokedex_types
|
||||
SQLiteDataReader rdTypes = (SQLiteDataReader)connVeekun.ExecuteReader("SELECT id, damage_class_id, " +
|
||||
"(SELECT name FROM type_names WHERE type_names.type_id = types.id AND local_language_id = 1) AS name_ja, " +
|
||||
|
|
@ -167,6 +257,7 @@ namespace VeekunImport
|
|||
}
|
||||
rdTypes.Close();
|
||||
|
||||
// pkmncf_pokedex_moves
|
||||
SQLiteDataReader rdMoves = (SQLiteDataReader)connVeekun.ExecuteReader("SELECT id, type_id, " +
|
||||
"(SELECT name FROM move_names WHERE move_names.move_id = moves.id AND local_language_id = 1) AS name_ja, " +
|
||||
"(SELECT name FROM move_names WHERE move_names.move_id = moves.id AND local_language_id = 9) AS name_en, " +
|
||||
|
|
@ -204,6 +295,7 @@ namespace VeekunImport
|
|||
Console.WriteLine("Inserted {0} {1}", m.ID, m.Name.ToString());
|
||||
}
|
||||
|
||||
// pkmncf_pokedex_abilities
|
||||
SQLiteDataReader rdAbilities = (SQLiteDataReader)connVeekun.ExecuteReader("SELECT id, " +
|
||||
"(SELECT name FROM ability_names WHERE ability_names.ability_id = abilities.id AND local_language_id = 1) AS name_ja, " +
|
||||
"(SELECT name FROM ability_names WHERE ability_names.ability_id = abilities.id AND local_language_id = 9) AS name_en, " +
|
||||
|
|
@ -226,9 +318,10 @@ namespace VeekunImport
|
|||
}
|
||||
rdAbilities.Close();
|
||||
|
||||
// pkmncf_pokedex_items
|
||||
Dictionary<int, ItemLoading> items = new Dictionary<int, ItemLoading>();
|
||||
|
||||
for (int generation = 3; generation < 7; generation++)
|
||||
for (int generation = 3; generation < 6; generation++)
|
||||
{
|
||||
String filename = String.Format("items{0}.txt", generation);
|
||||
if (!File.Exists(filename))
|
||||
|
|
|
|||
|
|
@ -50,6 +50,9 @@
|
|||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="families_map.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="items3.txt">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
|
@ -59,6 +62,9 @@
|
|||
<Content Include="items4.txt">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="families.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\library\Library.csproj">
|
||||
|
|
|
|||
18
VeekunImport/families.txt
Normal file
18
VeekunImport/families.txt
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
010 172 172 000 000 0000 4
|
||||
012 029 032 000 000 0000 4
|
||||
013 173 173 000 000 0000 6
|
||||
015 174 174 000 000 0000 6
|
||||
046 236 236 000 000 0000 0
|
||||
050 113 113 440 440 4319 8
|
||||
056 122 122 439 439 4314 4
|
||||
058 238 238 000 000 0000 8
|
||||
059 239 239 000 000 0000 2
|
||||
060 240 240 000 000 0000 2
|
||||
071 143 143 446 446 4316 4
|
||||
089 183 183 298 298 3220 4
|
||||
090 185 185 438 438 4315 1
|
||||
099 202 202 360 360 3221 4
|
||||
115 226 226 458 458 4317 4
|
||||
155 313 314 000 000 0000 4
|
||||
156 315 315 406 406 4318 4
|
||||
182 358 358 433 433 4320 4
|
||||
364
VeekunImport/families_map.txt
Normal file
364
VeekunImport/families_map.txt
Normal file
|
|
@ -0,0 +1,364 @@
|
|||
001 002 003
|
||||
004 005 006
|
||||
007 008 009
|
||||
010 011 012
|
||||
013 014 015
|
||||
016 017 018
|
||||
019 020
|
||||
021 022
|
||||
023 024
|
||||
025 026 172
|
||||
027 028
|
||||
029 030 031 032 033 034
|
||||
035 036 173
|
||||
037 038
|
||||
039 040 174
|
||||
041 042 169
|
||||
043 044 045 182
|
||||
046 047
|
||||
048 049
|
||||
050 051
|
||||
052 053
|
||||
054 055
|
||||
056 057
|
||||
058 059
|
||||
060 061 062 186
|
||||
063 064 065
|
||||
066 067 068
|
||||
069 070 071
|
||||
072 073
|
||||
074 075 076
|
||||
077 078
|
||||
079 080 199
|
||||
081 082 462
|
||||
083
|
||||
084 085
|
||||
086 087
|
||||
088 089
|
||||
090 091
|
||||
092 093 094
|
||||
095 208
|
||||
096 097
|
||||
098 099
|
||||
100 101
|
||||
102 103
|
||||
104 105
|
||||
106 107 236 237
|
||||
108 463
|
||||
109 110
|
||||
111 112 464
|
||||
113 242 440
|
||||
114 465
|
||||
115
|
||||
116 117 230
|
||||
118 119
|
||||
120 121
|
||||
122 439
|
||||
123 212
|
||||
124 238
|
||||
125 239 466
|
||||
126 240 467
|
||||
127
|
||||
128
|
||||
129 130
|
||||
131
|
||||
132
|
||||
133 134 135 136 196 197 470 471 700
|
||||
137 233 474
|
||||
138 139
|
||||
140 141
|
||||
142
|
||||
143 446
|
||||
144
|
||||
145
|
||||
146
|
||||
147 148 149
|
||||
150
|
||||
151
|
||||
152 153 154
|
||||
155 156 157
|
||||
158 159 160
|
||||
161 162
|
||||
163 164
|
||||
165 166
|
||||
167 168
|
||||
170 171
|
||||
175 176 468
|
||||
177 178
|
||||
179 180 181
|
||||
183 184 298
|
||||
185 438
|
||||
187 188 189
|
||||
190 424
|
||||
191 192
|
||||
193 469
|
||||
194 195
|
||||
198 430
|
||||
200 429
|
||||
201
|
||||
202 360
|
||||
203
|
||||
204 205
|
||||
206
|
||||
207 472
|
||||
209 210
|
||||
211
|
||||
213
|
||||
214
|
||||
215 461
|
||||
216 217
|
||||
218 219
|
||||
220 221 473
|
||||
222
|
||||
223 224
|
||||
225
|
||||
226 458
|
||||
227
|
||||
228 229
|
||||
231 232
|
||||
234
|
||||
235
|
||||
241
|
||||
243
|
||||
244
|
||||
245
|
||||
246 247 248
|
||||
249
|
||||
250
|
||||
251
|
||||
252 253 254
|
||||
255 256 257
|
||||
258 259 260
|
||||
261 262
|
||||
263 264
|
||||
265 266 267 268 269
|
||||
270 271 272
|
||||
273 274 275
|
||||
276 277
|
||||
278 279
|
||||
280 281 282 475
|
||||
283 284
|
||||
285 286
|
||||
287 288 289
|
||||
290 291 292
|
||||
293 294 295
|
||||
296 297
|
||||
299 476
|
||||
300 301
|
||||
302
|
||||
303
|
||||
304 305 306
|
||||
307 308
|
||||
309 310
|
||||
311
|
||||
312
|
||||
313 314
|
||||
315 406 407
|
||||
316 317
|
||||
318 319
|
||||
320 321
|
||||
322 323
|
||||
324
|
||||
325 326
|
||||
327
|
||||
328 329 330
|
||||
331 332
|
||||
333 334
|
||||
335
|
||||
336
|
||||
337
|
||||
338
|
||||
339 340
|
||||
341 342
|
||||
343 344
|
||||
345 346
|
||||
347 348
|
||||
349 350
|
||||
351
|
||||
352
|
||||
353 354
|
||||
355 356 477
|
||||
357
|
||||
358 433
|
||||
359
|
||||
361 362 478
|
||||
363 364 365
|
||||
366 367 368
|
||||
369
|
||||
370
|
||||
371 372 373
|
||||
374 375 376
|
||||
377
|
||||
378
|
||||
379
|
||||
380
|
||||
381
|
||||
382
|
||||
383
|
||||
384
|
||||
385
|
||||
386
|
||||
387 388 389
|
||||
390 391 392
|
||||
393 394 395
|
||||
396 397 398
|
||||
399 400
|
||||
401 402
|
||||
403 404 405
|
||||
408 409
|
||||
410 411
|
||||
412 413 414
|
||||
415 416
|
||||
417
|
||||
418 419
|
||||
420 421
|
||||
422 423
|
||||
425 426
|
||||
427 428
|
||||
431 432
|
||||
434 435
|
||||
436 437
|
||||
441
|
||||
442
|
||||
443 444 445
|
||||
447 448
|
||||
449 450
|
||||
451 452
|
||||
453 454
|
||||
455
|
||||
456 457
|
||||
459 460
|
||||
479
|
||||
480
|
||||
481
|
||||
482
|
||||
483
|
||||
484
|
||||
485
|
||||
486
|
||||
487
|
||||
488
|
||||
489 490
|
||||
491
|
||||
492
|
||||
493
|
||||
494
|
||||
495 496 497
|
||||
498 499 500
|
||||
501 502 503
|
||||
504 505
|
||||
506 507 508
|
||||
509 510
|
||||
511 512
|
||||
513 514
|
||||
515 516
|
||||
517 518
|
||||
519 520 521
|
||||
522 523
|
||||
524 525 526
|
||||
527 528
|
||||
529 530
|
||||
531
|
||||
532 533 534
|
||||
535 536 537
|
||||
538
|
||||
539
|
||||
540 541 542
|
||||
543 544 545
|
||||
546 547
|
||||
548 549
|
||||
550
|
||||
551 552 553
|
||||
554 555
|
||||
556
|
||||
557 558
|
||||
559 560
|
||||
561
|
||||
562 563
|
||||
564 565
|
||||
566 567
|
||||
568 569
|
||||
570 571
|
||||
572 573
|
||||
574 575 576
|
||||
577 578 579
|
||||
580 581
|
||||
582 583 584
|
||||
585 586
|
||||
587
|
||||
588 589
|
||||
590 591
|
||||
592 593
|
||||
594
|
||||
595 596
|
||||
597 598
|
||||
599 600 601
|
||||
602 603 604
|
||||
605 606
|
||||
607 608 609
|
||||
610 611 612
|
||||
613 614
|
||||
615
|
||||
616 617
|
||||
618
|
||||
619
|
||||
620
|
||||
621
|
||||
622 623
|
||||
624 625
|
||||
626
|
||||
627 628
|
||||
629 630
|
||||
631
|
||||
632
|
||||
633 634 635
|
||||
636 637
|
||||
638
|
||||
639
|
||||
640
|
||||
641
|
||||
642
|
||||
643
|
||||
644
|
||||
645
|
||||
646
|
||||
647
|
||||
648
|
||||
649
|
||||
650 651 652
|
||||
653 654 655
|
||||
656 657 658
|
||||
659 660
|
||||
661 662 663
|
||||
664 665 666
|
||||
667 668
|
||||
669 670 671
|
||||
672 673
|
||||
674 675
|
||||
676
|
||||
677 678
|
||||
679 680 681
|
||||
682 683
|
||||
684 685
|
||||
686 687
|
||||
688 689
|
||||
690 691
|
||||
692 693
|
||||
694 695
|
||||
696 697
|
||||
698 699
|
||||
701
|
||||
702
|
||||
703
|
||||
704 705 706
|
||||
707
|
||||
708 709
|
||||
710 711
|
||||
712 713
|
||||
714 715
|
||||
716
|
||||
717
|
||||
718
|
||||
719
|
||||
720
|
||||
721
|
||||
|
|
@ -7,5 +7,28 @@ namespace PkmnFoundations.Pokedex
|
|||
{
|
||||
public class Family
|
||||
{
|
||||
public Family(Pokedex pokedex, int id, int basic_male_id, int basic_female_id,
|
||||
int baby_male_id, int baby_female_id, int incense_id, byte gender_ratio)
|
||||
{
|
||||
m_pokedex = pokedex;
|
||||
|
||||
ID = id;
|
||||
BasicMaleID = basic_male_id;
|
||||
BasicFemaleID = basic_female_id;
|
||||
BabyMaleID = baby_male_id;
|
||||
BabyFemaleID = baby_female_id;
|
||||
IncenseID = incense_id;
|
||||
GenderRatio = gender_ratio;
|
||||
}
|
||||
|
||||
private Pokedex m_pokedex;
|
||||
|
||||
public int ID { get; private set; }
|
||||
public int BasicMaleID { get; private set; }
|
||||
public int BasicFemaleID { get; private set; }
|
||||
public int BabyMaleID { get; private set; }
|
||||
public int BabyFemaleID { get; private set; }
|
||||
public int IncenseID { get; private set; }
|
||||
public byte GenderRatio { get; private set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,12 +9,13 @@ namespace PkmnFoundations.Pokedex
|
|||
{
|
||||
public class Species
|
||||
{
|
||||
public Species(Pokedex pokedex, int national_dex, LocalizedString name,
|
||||
public Species(Pokedex pokedex, int national_dex, int family_id, LocalizedString name,
|
||||
GrowthRates growth_rate, byte gender_ratio, EggGroups egg_group_1,
|
||||
EggGroups egg_group_2, int egg_steps, bool gender_variations)
|
||||
{
|
||||
m_pokedex = pokedex;
|
||||
NationalDex = national_dex;
|
||||
FamilyID = family_id;
|
||||
Name = name;
|
||||
GrowthRate = growth_rate;
|
||||
GenderRatio = gender_ratio;
|
||||
|
|
@ -58,6 +59,7 @@ namespace PkmnFoundations.Pokedex
|
|||
private Pokedex m_pokedex;
|
||||
|
||||
public int NationalDex { get; private set; }
|
||||
public int FamilyID { get; private set; }
|
||||
public LocalizedString Name { get; private set; }
|
||||
public GrowthRates GrowthRate { get; private set; }
|
||||
public byte GenderRatio { get; private set; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user