2018-08-02 01:30:51 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
2016-07-03 03:24:17 +00:00
|
|
|
|
{
|
2017-10-24 06:12:58 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Stat/misc data for individual species or their associated alternate forme data.
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract class PersonalInfo
|
|
|
|
|
{
|
2018-07-04 15:43:19 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Raw Data
|
|
|
|
|
/// </summary>
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
protected readonly byte[] Data;
|
|
|
|
|
|
|
|
|
|
protected PersonalInfo(byte[] data) => Data = data;
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Writes entry to raw bytes.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2016-07-07 12:44:43 +00:00
|
|
|
|
public abstract byte[] Write();
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Base HP
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract int HP { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Base Attack
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract int ATK { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Base Defense
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract int DEF { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Base Speed
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract int SPE { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Base Special Attack
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract int SPA { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Base Special Defense
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract int SPD { get; set; }
|
2016-08-28 10:18:22 +00:00
|
|
|
|
|
2018-07-04 15:43:19 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Base Stat values
|
|
|
|
|
/// </summary>
|
2018-06-25 04:55:00 +00:00
|
|
|
|
public int[] Stats
|
|
|
|
|
{
|
|
|
|
|
get => new[] { HP, ATK, DEF, SPE, SPA, SPD };
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
HP = value[0];
|
|
|
|
|
ATK = value[1];
|
|
|
|
|
DEF = value[2];
|
|
|
|
|
SPE = value[3];
|
|
|
|
|
SPA = value[4];
|
|
|
|
|
SPD = value[5];
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-28 10:18:22 +00:00
|
|
|
|
|
2018-07-04 15:43:19 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Amount of HP Effort Values to yield when defeating this entry.
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract int EV_HP { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Amount of Attack Effort Values to yield when defeating this entry.
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract int EV_ATK { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Amount of Defense Effort Values to yield when defeating this entry.
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract int EV_DEF { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Amount of Speed Effort Values to yield when defeating this entry.
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract int EV_SPE { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Amount of Special Attack Effort Values to yield when defeating this entry.
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract int EV_SPA { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Amount of Special Defense Effort Values to yield when defeating this entry.
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract int EV_SPD { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Primary Type
|
|
|
|
|
/// </summary>
|
2017-12-27 02:54:03 +00:00
|
|
|
|
public abstract int Type1 { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Secondary Type
|
|
|
|
|
/// </summary>
|
2017-12-27 02:54:03 +00:00
|
|
|
|
public abstract int Type2 { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// First Egg Group
|
|
|
|
|
/// </summary>
|
2017-12-27 02:54:03 +00:00
|
|
|
|
public abstract int EggGroup1 { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Second Egg Group
|
|
|
|
|
/// </summary>
|
2017-12-27 02:54:03 +00:00
|
|
|
|
public abstract int EggGroup2 { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Catch Rate
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract int CatchRate { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Evolution Stage value (or equivalent for unevolved).
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public virtual int EvoStage { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Held Items the entry can be randomly encountered with.
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract int[] Items { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gender Ratio value determining if the entry is a fixed gender or bigendered.
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract int Gender { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Amount of Hatching Step Cycles required to hatch if in an egg.
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract int HatchCycles { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initial Friendship when captured or received.
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract int BaseFriendship { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Experience-Level Growth Rate type
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract int EXPGrowth { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Full list of <see cref="PKM.Ability"/> values the entry can have.
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract int [] Abilities { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Escape factor used for fleeing the Safari Zone or calling for help in SOS Battles.
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract int EscapeRate { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Count of <see cref="PKM.AltForm"/> values the entry can have.
|
|
|
|
|
/// </summary>
|
2017-11-20 16:08:48 +00:00
|
|
|
|
public virtual int FormeCount { get; set; } = 1;
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Pointer to the first <see cref="PKM.AltForm"/> <see cref="PersonalInfo"/> index
|
|
|
|
|
/// </summary>
|
2016-11-12 18:19:17 +00:00
|
|
|
|
protected internal virtual int FormStatsIndex { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Pointer to the <see cref="PKM.AltForm"/> sprite index.
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public virtual int FormeSprite { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Base Experience Yield factor
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract int BaseEXP { get; set; }
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Main color ID of the entry. The majority of the pkm's color is of this color, usually.
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public abstract int Color { get; set; }
|
|
|
|
|
|
2018-07-04 15:43:19 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Height of the entry in meters (m).
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public virtual int Height { get; set; } = 0;
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Mass of the entry in kilograms (kg).
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public virtual int Weight { get; set; } = 0;
|
|
|
|
|
|
2018-07-04 15:43:19 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Dual Type IDs used for same-type attack bonuses, weakness, etc.
|
|
|
|
|
/// </summary>
|
2017-12-27 02:54:03 +00:00
|
|
|
|
public int[] Types
|
|
|
|
|
{
|
|
|
|
|
get => new[] { Type1, Type2 };
|
|
|
|
|
set
|
|
|
|
|
{
|
2020-01-19 00:57:25 +00:00
|
|
|
|
if (value.Length != 2) return;
|
2017-12-27 02:54:03 +00:00
|
|
|
|
Type1 = value[0];
|
|
|
|
|
Type2 = value[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Dual Egg Group IDs used to determine if an egg should be created as a result of both parents sharing at least one group ID.
|
|
|
|
|
/// </summary>
|
2017-12-27 02:54:03 +00:00
|
|
|
|
public int[] EggGroups
|
|
|
|
|
{
|
|
|
|
|
get => new[] { EggGroup1, EggGroup2 };
|
|
|
|
|
set
|
|
|
|
|
{
|
2020-01-19 00:57:25 +00:00
|
|
|
|
if (value.Length != 2) return;
|
2017-12-27 02:54:03 +00:00
|
|
|
|
EggGroup1 = (byte)value[0];
|
|
|
|
|
EggGroup2 = (byte)value[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-07 06:44:51 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// TM/HM learn compatibility flags for individual moves.
|
|
|
|
|
/// </summary>
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
public bool[] TMHM { get; protected set; } = Array.Empty<bool>();
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
2017-11-07 06:44:51 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Grass-Fire-Water-Etc typed learn compatibility flags for individual moves.
|
|
|
|
|
/// </summary>
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
public bool[] TypeTutors { get; protected set; } = Array.Empty<bool>();
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
2017-11-07 06:44:51 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Special tutor learn compatibility flags for individual moves.
|
|
|
|
|
/// </summary>
|
2018-08-02 01:30:51 +00:00
|
|
|
|
public bool[][] SpecialTutors { get; protected set; } = Array.Empty<bool[]>();
|
2016-07-03 03:24:17 +00:00
|
|
|
|
|
2018-02-17 03:34:42 +00:00
|
|
|
|
protected static bool[] GetBits(byte[] data, int start = 0, int length = -1)
|
2016-07-03 03:24:17 +00:00
|
|
|
|
{
|
2018-02-17 03:34:42 +00:00
|
|
|
|
if (length < 0)
|
|
|
|
|
length = data.Length;
|
2019-02-07 07:28:02 +00:00
|
|
|
|
bool[] result = new bool[length << 3];
|
|
|
|
|
for (int i = 0; i < result.Length; i++)
|
|
|
|
|
result[i] = (data[start + (i >> 3)] >> (i & 7) & 0x1) == 1;
|
|
|
|
|
return result;
|
2016-07-03 03:24:17 +00:00
|
|
|
|
}
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
protected static byte[] SetBits(bool[] bits)
|
2016-07-03 03:24:17 +00:00
|
|
|
|
{
|
2017-03-18 23:50:34 +00:00
|
|
|
|
byte[] data = new byte[bits.Length>>3];
|
2016-07-03 03:24:17 +00:00
|
|
|
|
for (int i = 0; i < bits.Length; i++)
|
2017-03-18 23:50:34 +00:00
|
|
|
|
data[i>>3] |= (byte)(bits[i] ? 1 << (i&0x7) : 0);
|
2016-07-03 03:24:17 +00:00
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-24 06:12:58 +00:00
|
|
|
|
/// <summary>
|
2017-11-07 06:44:51 +00:00
|
|
|
|
/// Injects supplementary TM/HM compatibility which is not present in the generation specific <see cref="PersonalInfo"/> format.
|
2017-10-24 06:12:58 +00:00
|
|
|
|
/// </summary>
|
2018-05-12 19:28:48 +00:00
|
|
|
|
/// <param name="data">Data to read from</param>
|
|
|
|
|
/// <param name="start">Starting offset to read at</param>
|
|
|
|
|
/// <param name="length">Amount of bytes to decompose into bits</param>
|
2018-02-17 03:34:42 +00:00
|
|
|
|
internal void AddTMHM(byte[] data, int start = 0, int length = -1) => TMHM = GetBits(data, start, length);
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
2017-10-24 06:12:58 +00:00
|
|
|
|
/// <summary>
|
2017-11-07 06:44:51 +00:00
|
|
|
|
/// Injects supplementary Type Tutor compatibility which is not present in the generation specific <see cref="PersonalInfo"/> format.
|
2017-10-24 06:12:58 +00:00
|
|
|
|
/// </summary>
|
2018-05-12 19:28:48 +00:00
|
|
|
|
/// <param name="data">Data to read from</param>
|
|
|
|
|
/// <param name="start">Starting offset to read at</param>
|
|
|
|
|
/// <param name="length">Amount of bytes to decompose into bits</param>
|
2018-02-17 03:34:42 +00:00
|
|
|
|
internal void AddTypeTutors(byte[] data, int start = 0, int length = -1) => TypeTutors = GetBits(data, start, length);
|
2017-03-18 23:50:34 +00:00
|
|
|
|
|
2017-11-07 06:44:51 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the <see cref="PersonalTable"/> <see cref="PKM.AltForm"/> entry index for the input criteria, with fallback for the original species entry.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="species"><see cref="PKM.Species"/> to retrieve for</param>
|
|
|
|
|
/// <param name="forme"><see cref="PKM.AltForm"/> to retrieve for</param>
|
|
|
|
|
/// <returns>Index the <see cref="PKM.AltForm"/> exists as in the <see cref="PersonalTable"/>.</returns>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public int FormeIndex(int species, int forme)
|
|
|
|
|
{
|
2016-07-05 06:53:15 +00:00
|
|
|
|
if (forme <= 0) // no forme requested
|
2016-07-03 20:04:07 +00:00
|
|
|
|
return species;
|
2016-07-05 06:53:15 +00:00
|
|
|
|
if (FormStatsIndex <= 0) // no formes present
|
2016-07-03 20:04:07 +00:00
|
|
|
|
return species;
|
2017-11-11 03:53:11 +00:00
|
|
|
|
if (forme >= FormeCount) // beyond range of species' formes
|
2016-07-03 20:04:07 +00:00
|
|
|
|
return species;
|
|
|
|
|
|
|
|
|
|
return FormStatsIndex + forme - 1;
|
2016-07-03 03:24:17 +00:00
|
|
|
|
}
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a random valid gender for the entry.
|
|
|
|
|
/// </summary>
|
2019-02-18 06:13:40 +00:00
|
|
|
|
public int RandomGender()
|
2018-12-30 06:19:44 +00:00
|
|
|
|
{
|
2019-02-18 06:13:40 +00:00
|
|
|
|
var fix = FixedGender;
|
|
|
|
|
return fix >= 0 ? fix : Util.Rand.Next(2);
|
2018-12-30 06:19:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsDualGender => FixedGender < 0;
|
|
|
|
|
|
|
|
|
|
public int FixedGender
|
2016-07-03 03:24:17 +00:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2018-06-25 04:55:00 +00:00
|
|
|
|
if (Genderless)
|
|
|
|
|
return 2;
|
|
|
|
|
if (OnlyFemale)
|
|
|
|
|
return 1;
|
|
|
|
|
if (OnlyMale)
|
|
|
|
|
return 0;
|
2018-12-30 06:19:44 +00:00
|
|
|
|
return -1;
|
2016-07-03 03:24:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-05-13 15:14:46 +00:00
|
|
|
|
|
2018-07-04 15:43:19 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Indicates that the entry is exclusively Genderless.
|
|
|
|
|
/// </summary>
|
2018-05-13 15:14:46 +00:00
|
|
|
|
public bool Genderless => Gender == 255;
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Indicates that the entry is exclusively Female gendered.
|
|
|
|
|
/// </summary>
|
2018-05-13 15:14:46 +00:00
|
|
|
|
public bool OnlyFemale => Gender == 254;
|
2018-07-27 02:34:27 +00:00
|
|
|
|
|
2018-07-04 15:43:19 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Indicates that the entry is exclusively Male gendered.
|
|
|
|
|
/// </summary>
|
2018-05-13 15:14:46 +00:00
|
|
|
|
public bool OnlyMale => Gender == 0;
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Indicates if the entry has Formes or not.
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public bool HasFormes => FormeCount > 1;
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Base Stat Total sum of all stats.
|
|
|
|
|
/// </summary>
|
2016-07-03 03:24:17 +00:00
|
|
|
|
public int BST => HP + ATK + DEF + SPE + SPA + SPD;
|
2017-11-22 02:31:24 +00:00
|
|
|
|
|
2018-07-04 15:43:19 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Checks to see if the <see cref="PKM.AltForm"/> is valid within the <see cref="FormeCount"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="forme"></param>
|
|
|
|
|
/// <returns></returns>
|
2017-11-22 02:31:24 +00:00
|
|
|
|
public bool IsFormeWithinRange(int forme)
|
|
|
|
|
{
|
|
|
|
|
if (forme == 0)
|
|
|
|
|
return true;
|
|
|
|
|
return forme < FormeCount;
|
|
|
|
|
}
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Checks to see if the provided Types match the entry's types.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>Input order matters! If input order does not matter, use <see cref="o:IsType(type1, type2)"/>.</remarks>
|
|
|
|
|
/// <param name="type1">First type</param>
|
|
|
|
|
/// <param name="type2">Second type</param>
|
|
|
|
|
/// <returns>Typing is an exact match</returns>
|
2018-03-25 20:53:48 +00:00
|
|
|
|
public bool IsValidTypeCombination(int type1, int type2) => Type1 == type1 && Type2 == type2;
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Checks if the entry has either type equal to the input type.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="type1">Type</param>
|
|
|
|
|
/// <returns>Typing is present in entry</returns>
|
2018-03-25 20:53:48 +00:00
|
|
|
|
public bool IsType(int type1) => Type1 == type1 || Type2 == type1;
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Checks if the entry has either type equal to both input types.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>Input order does not matter.</remarks>
|
|
|
|
|
/// <param name="type1">Type 1</param>
|
|
|
|
|
/// <param name="type2">Type 2</param>
|
|
|
|
|
/// <returns>Typing is present in entry</returns>
|
2018-03-25 20:53:48 +00:00
|
|
|
|
public bool IsType(int type1, int type2) => (Type1 == type1 || Type2 == type1) && (Type1 == type2 || Type2 == type2);
|
2018-07-04 15:43:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Checks if the entry has either egg group equal to the input type.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="group">Egg group</param>
|
|
|
|
|
/// <returns>Egg is present in entry</returns>
|
2018-03-25 20:53:48 +00:00
|
|
|
|
public bool IsEggGroup(int group) => EggGroup1 == group || EggGroup2 == group;
|
2016-07-03 03:24:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|