mirror of
https://github.com/mm201/pkmn-classic-framework.git
synced 2026-09-08 02:05:13 -05:00
Moved GTS record Pokémon validation over to Pokemon classes.
This commit is contained in:
@@ -126,6 +126,7 @@
|
||||
<Compile Include="Support\TrendyPhrase4.cs" />
|
||||
<Compile Include="Support\TrendyPhrase5.cs" />
|
||||
<Compile Include="Support\TrendyPhraseBase.cs" />
|
||||
<Compile Include="Support\ValidationSummary.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
|
||||
@@ -195,44 +195,6 @@ namespace PkmnFoundations.Structures
|
||||
{
|
||||
if (!base.Validate()) return false;
|
||||
|
||||
// todo: these checks belong on the pokemon class based on database fields.
|
||||
var thePokemon = (PokemonParty4)Pokemon;
|
||||
|
||||
if (thePokemon.SpeciesID < 1 || thePokemon.SpeciesID > 493) return false;
|
||||
|
||||
try
|
||||
{
|
||||
if (thePokemon.Form == null) return false;
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
return false; // form not in pokedex
|
||||
}
|
||||
if (thePokemon.SpeciesID == 479 && thePokemon.FormID != 0) return false; // rotoms
|
||||
if (thePokemon.SpeciesID == 487 && thePokemon.FormID != 0) return false; // origin giratina
|
||||
if (thePokemon.SpeciesID == 492 && thePokemon.FormID != 0) return false; // sky shaymin
|
||||
if (thePokemon.Form.Suffix == "spiky-eared") return false;
|
||||
if (thePokemon.Form.Suffix == "fairy") return false;
|
||||
if (thePokemon.Form.Suffix == "mega") return false;
|
||||
if (thePokemon.Form.Suffix == "mega-x") return false;
|
||||
if (thePokemon.Form.Suffix == "mega-y") return false;
|
||||
if (thePokemon.Form.Suffix == "primal") return false;
|
||||
if (thePokemon.SpeciesID == 25 && thePokemon.FormID > 0) return false; // cosplay pikachu
|
||||
|
||||
if (thePokemon.HeldItemID < 0) return false;
|
||||
if (thePokemon.HeldItemID >= 112 && thePokemon.HeldItemID <= 134) return false;
|
||||
if (thePokemon.HeldItemID >= 428) return false;
|
||||
|
||||
if (thePokemon.AbilityID <= 0) return false;
|
||||
if (thePokemon.AbilityID > 123) return false;
|
||||
|
||||
foreach (MoveSlot move in thePokemon.Moves)
|
||||
{
|
||||
if (move.MoveID < 0) return false;
|
||||
if (move.MoveID == 165) return false; // struggle
|
||||
if (move.MoveID > 467) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -202,52 +202,6 @@ namespace PkmnFoundations.Structures
|
||||
{
|
||||
if (!base.Validate()) return false;
|
||||
|
||||
// todo: these checks belong on the pokemon class based on database fields.
|
||||
var thePokemon = (PokemonParty5)Pokemon;
|
||||
|
||||
if (thePokemon.SpeciesID < 1 || thePokemon.SpeciesID > 649) return false;
|
||||
|
||||
try
|
||||
{
|
||||
if (thePokemon.Form == null) return false;
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
return false; // form not in pokedex
|
||||
}
|
||||
if (thePokemon.SpeciesID == 641 && thePokemon.FormID != 0) return false; // therian tornadus
|
||||
if (thePokemon.SpeciesID == 642 && thePokemon.FormID != 0) return false; // therian thundrus
|
||||
if (thePokemon.SpeciesID == 645 && thePokemon.FormID != 0) return false; // therian landorus
|
||||
if (thePokemon.SpeciesID == 646 && thePokemon.FormID != 0) return false; // black/white kyurem
|
||||
if (thePokemon.SpeciesID == 647 && thePokemon.FormID != 0) return false; // resolute keldeo
|
||||
if (thePokemon.Form.Suffix == "spiky-eared") return false;
|
||||
if (thePokemon.Form.Suffix == "fairy") return false;
|
||||
if (thePokemon.Form.Suffix == "mega") return false;
|
||||
if (thePokemon.Form.Suffix == "mega-x") return false;
|
||||
if (thePokemon.Form.Suffix == "mega-y") return false;
|
||||
if (thePokemon.Form.Suffix == "primal") return false;
|
||||
if (thePokemon.SpeciesID == 25 && thePokemon.FormID > 0) return false; // cosplay pikachu
|
||||
|
||||
if (thePokemon.HeldItemID < 0) return false;
|
||||
if (thePokemon.HeldItemID >= 113 && thePokemon.HeldItemID <= 115) return false;
|
||||
if (thePokemon.HeldItemID >= 120 && thePokemon.HeldItemID <= 133) return false;
|
||||
if (thePokemon.HeldItemID >= 328 && thePokemon.HeldItemID <= 503) return false;
|
||||
if (thePokemon.HeldItemID >= 505 && thePokemon.HeldItemID <= 536) return false;
|
||||
if (thePokemon.HeldItemID == 574) return false;
|
||||
if (thePokemon.HeldItemID == 576) return false;
|
||||
if (thePokemon.HeldItemID >= 578 && thePokemon.HeldItemID <= 579) return false;
|
||||
if (thePokemon.HeldItemID >= 592) return false;
|
||||
|
||||
if (thePokemon.AbilityID <= 0) return false;
|
||||
if (thePokemon.AbilityID > 164) return false;
|
||||
|
||||
foreach (MoveSlot move in thePokemon.Moves)
|
||||
{
|
||||
if (move.MoveID < 0) return false;
|
||||
if (move.MoveID == 165) return false; // struggle
|
||||
if (move.MoveID > 559) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using PkmnFoundations.Support;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -103,6 +104,9 @@ namespace PkmnFoundations.Structures
|
||||
if (thePokemon.Level > 100) return false;
|
||||
if (thePokemon.EVs.ToArray().Select(i => (int)i).Sum() > 510) return false;
|
||||
|
||||
ValidationSummary summary = Pokemon.Validate();
|
||||
if (!summary.IsValid) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -311,5 +311,45 @@ namespace PkmnFoundations.Structures
|
||||
{
|
||||
get { return 136; }
|
||||
}
|
||||
|
||||
public static ValidationSummary ValidateActual(PokemonBase thePokemon)
|
||||
{
|
||||
if (thePokemon.SpeciesID < 1 || thePokemon.SpeciesID > 493) return new ValidationSummary() { IsValid = false };
|
||||
|
||||
try
|
||||
{
|
||||
if (thePokemon.Form == null) return new ValidationSummary() { IsValid = false };
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
return new ValidationSummary() { IsValid = false }; // form not in pokedex
|
||||
}
|
||||
if (thePokemon.SpeciesID == 479 && thePokemon.FormID != 0) return new ValidationSummary() { IsValid = false }; // rotoms
|
||||
if (thePokemon.SpeciesID == 487 && thePokemon.FormID != 0) return new ValidationSummary() { IsValid = false }; // origin giratina
|
||||
if (thePokemon.SpeciesID == 492 && thePokemon.FormID != 0) return new ValidationSummary() { IsValid = false }; // sky shaymin
|
||||
if (thePokemon.Form.Suffix == "spiky-eared") return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.Form.Suffix == "fairy") return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.Form.Suffix == "mega") return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.Form.Suffix == "mega-x") return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.Form.Suffix == "mega-y") return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.Form.Suffix == "primal") return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.SpeciesID == 25 && thePokemon.FormID > 0) return new ValidationSummary() { IsValid = false }; // cosplay pikachu
|
||||
|
||||
if (thePokemon.HeldItemID < 0) return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.HeldItemID >= 112 && thePokemon.HeldItemID <= 134) return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.HeldItemID >= 428) return new ValidationSummary() { IsValid = false };
|
||||
|
||||
if (thePokemon.AbilityID <= 0) return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.AbilityID > 123) return new ValidationSummary() { IsValid = false };
|
||||
|
||||
foreach (MoveSlot move in thePokemon.Moves)
|
||||
{
|
||||
if (move.MoveID < 0) return new ValidationSummary() { IsValid = false };
|
||||
if (move.MoveID == 165) return new ValidationSummary() { IsValid = false }; // struggle
|
||||
if (move.MoveID > 467) return new ValidationSummary() { IsValid = false };
|
||||
}
|
||||
|
||||
return new ValidationSummary() { IsValid = true };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,5 +294,53 @@ namespace PkmnFoundations.Structures
|
||||
{
|
||||
get { return 136; }
|
||||
}
|
||||
|
||||
public static ValidationSummary ValidateActual(PokemonBase thePokemon)
|
||||
{
|
||||
if (thePokemon.SpeciesID < 1 || thePokemon.SpeciesID > 649) return new ValidationSummary() { IsValid = false };
|
||||
|
||||
try
|
||||
{
|
||||
if (thePokemon.Form == null) return new ValidationSummary() { IsValid = false };
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
return new ValidationSummary() { IsValid = false }; // form not in pokedex
|
||||
}
|
||||
if (thePokemon.SpeciesID == 641 && thePokemon.FormID != 0) return new ValidationSummary() { IsValid = false }; // therian tornadus
|
||||
if (thePokemon.SpeciesID == 642 && thePokemon.FormID != 0) return new ValidationSummary() { IsValid = false }; // therian thundrus
|
||||
if (thePokemon.SpeciesID == 645 && thePokemon.FormID != 0) return new ValidationSummary() { IsValid = false }; // therian landorus
|
||||
if (thePokemon.SpeciesID == 646 && thePokemon.FormID != 0) return new ValidationSummary() { IsValid = false }; // black/white kyurem
|
||||
if (thePokemon.SpeciesID == 647 && thePokemon.FormID != 0) return new ValidationSummary() { IsValid = false }; // resolute keldeo
|
||||
if (thePokemon.Form.Suffix == "spiky-eared") return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.Form.Suffix == "fairy") return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.Form.Suffix == "mega") return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.Form.Suffix == "mega-x") return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.Form.Suffix == "mega-y") return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.Form.Suffix == "primal") return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.SpeciesID == 25 && thePokemon.FormID > 0) return new ValidationSummary() { IsValid = false }; // cosplay pikachu
|
||||
|
||||
if (thePokemon.HeldItemID < 0) return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.HeldItemID >= 113 && thePokemon.HeldItemID <= 115) return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.HeldItemID >= 120 && thePokemon.HeldItemID <= 133) return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.HeldItemID >= 328 && thePokemon.HeldItemID <= 503) return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.HeldItemID >= 505 && thePokemon.HeldItemID <= 536) return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.HeldItemID == 574) return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.HeldItemID == 576) return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.HeldItemID >= 578 && thePokemon.HeldItemID <= 579) return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.HeldItemID >= 592) return new ValidationSummary() { IsValid = false };
|
||||
|
||||
if (thePokemon.AbilityID <= 0) return new ValidationSummary() { IsValid = false };
|
||||
if (thePokemon.AbilityID > 164) return new ValidationSummary() { IsValid = false };
|
||||
|
||||
foreach (MoveSlot move in thePokemon.Moves)
|
||||
{
|
||||
if (move.MoveID < 0) return new ValidationSummary() { IsValid = false };
|
||||
if (move.MoveID == 165) return new ValidationSummary() { IsValid = false }; // struggle
|
||||
if (move.MoveID > 559) return new ValidationSummary() { IsValid = false };
|
||||
}
|
||||
|
||||
return new ValidationSummary() { IsValid = true };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace PkmnFoundations.Structures
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
public abstract String Nickname { get; set; }
|
||||
public abstract string Nickname { get; set; }
|
||||
|
||||
public virtual bool IsShiny
|
||||
{
|
||||
@@ -178,6 +178,24 @@ namespace PkmnFoundations.Structures
|
||||
}
|
||||
}
|
||||
|
||||
public virtual ValidationSummary Validate()
|
||||
{
|
||||
// xxx: this is another one of those inheritance diamond things.
|
||||
// Since we specialize by generation after specializing by
|
||||
// structure type, we have to roll our own vtable here to be able
|
||||
// to have generation-specific validation in each inheritance
|
||||
// branch.
|
||||
switch (this.Generation)
|
||||
{
|
||||
case Generations.Generation4:
|
||||
return Pokemon4.ValidateActual(this);
|
||||
case Generations.Generation5:
|
||||
return Pokemon5.ValidateActual(this);
|
||||
default:
|
||||
return new ValidationSummary() { IsValid = true };
|
||||
}
|
||||
}
|
||||
|
||||
protected static List<int> BlockScramble(uint personality)
|
||||
{
|
||||
int x = 4; // todo: this can be an argument but YAGNI
|
||||
|
||||
12
library/Support/ValidationSummary.cs
Normal file
12
library/Support/ValidationSummary.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace PkmnFoundations.Support
|
||||
{
|
||||
public struct ValidationSummary
|
||||
{
|
||||
public bool IsValid { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user