2017-10-31 16:24:54 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
2016-11-08 16:43:57 +00:00
|
|
|
|
{
|
2017-10-24 06:12:58 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Static Encounter Data
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// Static Encounters are fixed position encounters with properties that are not subject to Wild Encounter conditions.
|
|
|
|
|
/// </remarks>
|
2018-01-02 20:00:41 +00:00
|
|
|
|
public class EncounterStatic : IEncounterable, IMoveset, IGeneration, ILocation
|
2016-11-08 16:43:57 +00:00
|
|
|
|
{
|
2017-01-05 06:25:45 +00:00
|
|
|
|
public int Species { get; set; }
|
2017-04-07 00:41:25 +00:00
|
|
|
|
public int[] Moves { get; set; }
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public int Level { get; set; }
|
2016-11-08 16:43:57 +00:00
|
|
|
|
|
2017-04-22 20:04:12 +00:00
|
|
|
|
public int LevelMin => Level;
|
|
|
|
|
public int LevelMax => Level;
|
Gen 1 move analysis improvement. Adapted the valid moves to take into account that move deleter and move reminder do not exits in generation 1 (#1037)
* Fix getMoves with min level, when SkipWhile and TakeWhile is used together the index i in TakeWhile is calculated from the enumerator that results of the SkipWhile function, not the index of the initial array, those giving an incorrect index to check Levels array in the TakeWhile
* Fix getMoves when levelmin or levelmax is above max level in the levels array, TakeWhile and SkipWhile return empty list if the while goes beyond the last element of the array
* Include player hatched egg in the list of possible encounters for parseMoves only if the pokemon was an egg
Also change the valur of WasEgg for gen1,2,3 pokemon if the encounter analyzed is not an egg
add the non egg encounters to the list instead of checking the non-egg encounter inside parseMovesWasEggPreRelearn
* Fix for gen3 egg encounters
Remove non-egg encounters without special moves if there is an egg encounter because egg encounter already cover every possible move combination
Do not add daycare egg encounter for gen3 unhatched egg if there is another encounter, that means is an event or gift egg, not a daycare egg
Remove duplicate encounters
* Gift egg should not allow inherited moves even it they dont have special moves
Those gift eggs are hatched only with the species base moves
* Added getEncounterMoves functions, to be used for generation 1 encounters to find what moves have a pokemon at the moment of being caught because there is no move reminder in generation 1
* Added GBEncounterData, structure for refactor the tuples used in generation 1 and 2 encounters
* Add LevelMin and LevelMax to IEncounterable to get the encounter moves by the min level of the generation 1 EncounterLink
Add iGeneration to difference generation 1 and generation 2 encounters for GB Era pokemon
* Mark generation in gen 1 and 2 encounters
There is no need to mark the generation in gen 3 to 7 encounters because in that generations it match the pokemon generation number
* Add min level for generation 1 moves in getMoves functions
Add function to return the default moves for a GB encounters, for generation 1 games that included both moves from level up table and level 1 moves from personal table
Fix getMoves with min level when the moves list is empty, like Raichu generation 1
* Add maxSpecies to getBaseSpecies function for gen1 pokemon with a gen2 egg encounter
Refactor VC Encounter changing Tuples for GBData class
* Fixed for gen 2 Checks
Also do not search for generation1 encounter if the gen2 pokemon have met location from crystal
* Fix VC wild encounters, should be stored as array or else other verifyEncounter functions wont work
* Add generation 1 parse moves function including default moves
* Clean-up get encounters
* Verify empty moves for generation 1 encounters, in generation 1 does not exits move deleter
That means when a move slot have been used by a level up move or a TM/HM/Tutor move it cant be empty again
Does not apply if generation 2 tradeback is allowed, in generation 2 there is a move deleter
* Added two edge cases for pokemon that learn in red/blue and yellow different moves at the same level, this combinations can not exits until a later level when they learn again one of the levels in the other game, only happen for flareon and vaporeon
* Check incompatible moves between evolution species, it is for species that learn a move in a level as an evolved species and a move at a upper level as a preevolution
Also added most edge cases for the min slots used for generation 1 games, i think every weird combination is already covered
* Fix gen 1 eevee and evolutions move checks
* Cleanup
* Move the code to change valid moves for generation 1 to a function
* Fix getMoveMinLevelGBEncounter
* getUsedMoveSlots, removed wild Butterfree edge case, it is not possible
* Filter the min level of the encounter by the possible games the pokemon could be originated, yellow pikachu and kadabra can be detected
2017-04-09 00:17:20 +00:00
|
|
|
|
public int Generation { get; set; } = -1;
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public int Location { get; set; }
|
|
|
|
|
public int Ability { get; set; }
|
|
|
|
|
public int Form { get; set; }
|
|
|
|
|
public bool? Shiny { get; set; } // false = never, true = always, null = possible
|
|
|
|
|
public int[] Relearn { get; set; } = new int[4];
|
|
|
|
|
public int Gender { get; set; } = -1;
|
|
|
|
|
public int EggLocation { get; set; }
|
|
|
|
|
public Nature Nature { get; set; } = Nature.Random;
|
|
|
|
|
public bool Gift { get; set; }
|
|
|
|
|
public int Ball { get; set; } = 4; // Only checked when is Gift
|
2016-11-08 16:43:57 +00:00
|
|
|
|
public GameVersion Version = GameVersion.Any;
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public int[] IVs { get; set; } = { -1, -1, -1, -1, -1, -1 };
|
|
|
|
|
public bool IV3 { get; set; }
|
|
|
|
|
public int[] Contest { get; set; } = { 0, 0, 0, 0, 0, 0 };
|
2016-11-08 16:43:57 +00:00
|
|
|
|
public int HeldItem { get; set; }
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public int EggCycles { get; set; }
|
2016-11-13 17:37:28 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public bool Fateful { get; set; }
|
|
|
|
|
public bool RibbonWishing { get; set; }
|
|
|
|
|
public bool SkipFormCheck { get; set; }
|
|
|
|
|
public bool Roaming { get; set; }
|
Gen 1 move analysis improvement. Adapted the valid moves to take into account that move deleter and move reminder do not exits in generation 1 (#1037)
* Fix getMoves with min level, when SkipWhile and TakeWhile is used together the index i in TakeWhile is calculated from the enumerator that results of the SkipWhile function, not the index of the initial array, those giving an incorrect index to check Levels array in the TakeWhile
* Fix getMoves when levelmin or levelmax is above max level in the levels array, TakeWhile and SkipWhile return empty list if the while goes beyond the last element of the array
* Include player hatched egg in the list of possible encounters for parseMoves only if the pokemon was an egg
Also change the valur of WasEgg for gen1,2,3 pokemon if the encounter analyzed is not an egg
add the non egg encounters to the list instead of checking the non-egg encounter inside parseMovesWasEggPreRelearn
* Fix for gen3 egg encounters
Remove non-egg encounters without special moves if there is an egg encounter because egg encounter already cover every possible move combination
Do not add daycare egg encounter for gen3 unhatched egg if there is another encounter, that means is an event or gift egg, not a daycare egg
Remove duplicate encounters
* Gift egg should not allow inherited moves even it they dont have special moves
Those gift eggs are hatched only with the species base moves
* Added getEncounterMoves functions, to be used for generation 1 encounters to find what moves have a pokemon at the moment of being caught because there is no move reminder in generation 1
* Added GBEncounterData, structure for refactor the tuples used in generation 1 and 2 encounters
* Add LevelMin and LevelMax to IEncounterable to get the encounter moves by the min level of the generation 1 EncounterLink
Add iGeneration to difference generation 1 and generation 2 encounters for GB Era pokemon
* Mark generation in gen 1 and 2 encounters
There is no need to mark the generation in gen 3 to 7 encounters because in that generations it match the pokemon generation number
* Add min level for generation 1 moves in getMoves functions
Add function to return the default moves for a GB encounters, for generation 1 games that included both moves from level up table and level 1 moves from personal table
Fix getMoves with min level when the moves list is empty, like Raichu generation 1
* Add maxSpecies to getBaseSpecies function for gen1 pokemon with a gen2 egg encounter
Refactor VC Encounter changing Tuples for GBData class
* Fixed for gen 2 Checks
Also do not search for generation1 encounter if the gen2 pokemon have met location from crystal
* Fix VC wild encounters, should be stored as array or else other verifyEncounter functions wont work
* Add generation 1 parse moves function including default moves
* Clean-up get encounters
* Verify empty moves for generation 1 encounters, in generation 1 does not exits move deleter
That means when a move slot have been used by a level up move or a TM/HM/Tutor move it cant be empty again
Does not apply if generation 2 tradeback is allowed, in generation 2 there is a move deleter
* Added two edge cases for pokemon that learn in red/blue and yellow different moves at the same level, this combinations can not exits until a later level when they learn again one of the levels in the other game, only happen for flareon and vaporeon
* Check incompatible moves between evolution species, it is for species that learn a move in a level as an evolved species and a move at a upper level as a preevolution
Also added most edge cases for the min slots used for generation 1 games, i think every weird combination is already covered
* Fix gen 1 eevee and evolutions move checks
* Cleanup
* Move the code to change valid moves for generation 1 to a function
* Fix getMoveMinLevelGBEncounter
* getUsedMoveSlots, removed wild Butterfree edge case, it is not possible
* Filter the min level of the encounter by the possible games the pokemon could be originated, yellow pikachu and kadabra can be detected
2017-04-09 00:17:20 +00:00
|
|
|
|
public bool EggEncounter => EggLocation > 0;
|
2017-03-20 12:35:12 +00:00
|
|
|
|
|
2017-12-18 23:25:40 +00:00
|
|
|
|
protected void CloneArrays()
|
|
|
|
|
{
|
|
|
|
|
// dereference original arrays with new copies
|
|
|
|
|
Moves = (int[])Moves?.Clone();
|
|
|
|
|
Relearn = (int[])Relearn.Clone();
|
|
|
|
|
IVs = (int[])IVs.Clone();
|
|
|
|
|
Contest = (int[])Contest.Clone();
|
|
|
|
|
}
|
|
|
|
|
private EncounterStatic Clone()
|
|
|
|
|
{
|
|
|
|
|
var result = (EncounterStatic)MemberwiseClone();
|
|
|
|
|
result.CloneArrays();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
public virtual EncounterStatic Clone(int location)
|
|
|
|
|
{
|
|
|
|
|
var result = Clone();
|
|
|
|
|
result.Location = location;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2017-03-20 12:35:12 +00:00
|
|
|
|
public EncounterStatic[] Clone(int[] locations)
|
|
|
|
|
{
|
|
|
|
|
EncounterStatic[] Encounters = new EncounterStatic[locations.Length];
|
|
|
|
|
for (int i = 0; i < locations.Length; i++)
|
|
|
|
|
Encounters[i] = Clone(locations[i]);
|
|
|
|
|
return Encounters;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 16:24:54 +00:00
|
|
|
|
public IEnumerable<EncounterStatic> DreamRadarClone()
|
2017-03-24 22:50:00 +00:00
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < 8; i++)
|
2017-10-31 16:24:54 +00:00
|
|
|
|
yield return DreamRadarClone(5 * i + 5); //Level from 5->40 depends on the number of badges
|
2017-03-24 22:50:00 +00:00
|
|
|
|
}
|
2017-10-31 16:24:54 +00:00
|
|
|
|
private EncounterStatic DreamRadarClone(int level)
|
2017-03-24 22:50:00 +00:00
|
|
|
|
{
|
2017-12-18 23:25:40 +00:00
|
|
|
|
var result = Clone();
|
|
|
|
|
result.Level = level;
|
|
|
|
|
result.Location = 30015;// Pokemon Dream Radar
|
|
|
|
|
result.Gift = true; // Only
|
|
|
|
|
result.Ball = 25; // Dream Ball
|
|
|
|
|
return result;
|
2017-03-24 22:50:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-15 06:06:15 +00:00
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
const string game = "Static Encounter";
|
|
|
|
|
if (Version == GameVersion.Any)
|
|
|
|
|
return game;
|
2017-09-30 05:58:25 +00:00
|
|
|
|
return $"{game} ({Version})";
|
2017-02-15 06:06:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-08 16:43:57 +00:00
|
|
|
|
}
|
2017-04-22 20:04:12 +00:00
|
|
|
|
|
|
|
|
|
public class EncounterStaticTyped : EncounterStatic
|
|
|
|
|
{
|
2017-12-18 23:25:40 +00:00
|
|
|
|
public EncounterType TypeEncounter { get; internal set; } = EncounterType.None;
|
|
|
|
|
private EncounterStaticTyped Clone()
|
|
|
|
|
{
|
|
|
|
|
var result = (EncounterStaticTyped)MemberwiseClone();
|
|
|
|
|
result.CloneArrays();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2017-05-11 02:00:56 +00:00
|
|
|
|
public override EncounterStatic Clone(int location)
|
2017-04-22 20:04:12 +00:00
|
|
|
|
{
|
2017-12-18 23:25:40 +00:00
|
|
|
|
var result = Clone();
|
|
|
|
|
result.Location = location;
|
|
|
|
|
return result;
|
2017-04-22 20:04:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-04-23 16:18:42 +00:00
|
|
|
|
|
|
|
|
|
public class EncounterStaticShadow : EncounterStatic
|
|
|
|
|
{
|
2017-12-18 23:25:40 +00:00
|
|
|
|
public EncounterLock[][] Locks { get; internal set; } = new EncounterLock[0][];
|
|
|
|
|
public int Gauge { get; internal set; }
|
|
|
|
|
public bool EReader { get; set; }
|
|
|
|
|
private EncounterStaticShadow Clone()
|
|
|
|
|
{
|
|
|
|
|
var result = (EncounterStaticShadow)MemberwiseClone();
|
|
|
|
|
result.CloneArrays();
|
|
|
|
|
result.CloneLocks();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CloneLocks()
|
|
|
|
|
{
|
|
|
|
|
Locks = new EncounterLock[Locks.Length][];
|
|
|
|
|
for (var i = 0; i < Locks.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
Locks[i] = (EncounterLock[])Locks[i].Clone();
|
|
|
|
|
for (int j = 0; j < Locks[i].Length; j++)
|
|
|
|
|
Locks[i][j] = Locks[i][j].Clone();
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-04-30 19:17:27 +00:00
|
|
|
|
|
2017-05-11 02:00:56 +00:00
|
|
|
|
public override EncounterStatic Clone(int location)
|
2017-04-23 16:18:42 +00:00
|
|
|
|
{
|
2017-12-18 23:25:40 +00:00
|
|
|
|
var result = Clone();
|
|
|
|
|
result.Location = location;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public class EncounterStaticPID : EncounterStatic
|
|
|
|
|
{
|
|
|
|
|
public uint PID { get; set; }
|
|
|
|
|
public bool NSparkle { get; set; }
|
|
|
|
|
private EncounterStaticPID Clone()
|
|
|
|
|
{
|
|
|
|
|
var result = (EncounterStaticPID)MemberwiseClone();
|
|
|
|
|
result.CloneArrays();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
public override EncounterStatic Clone(int location)
|
|
|
|
|
{
|
|
|
|
|
var result = Clone();
|
|
|
|
|
result.Location = location;
|
|
|
|
|
return result;
|
2017-04-23 16:18:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-08 16:43:57 +00:00
|
|
|
|
}
|