mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-09 04:24:36 -05:00
Readonly init EvolutionMethod
Add xmldoc
This commit is contained in:
parent
9c28ffacc0
commit
3813d5dba9
|
|
@ -7,17 +7,50 @@ namespace PKHeX.Core
|
|||
/// </summary>
|
||||
public sealed class EvolutionMethod
|
||||
{
|
||||
public int Method;
|
||||
public int Species;
|
||||
public int Argument;
|
||||
public int Form = AnyForm;
|
||||
public int Level;
|
||||
/// <summary>
|
||||
/// Evolution Method
|
||||
/// </summary>
|
||||
public readonly int Method;
|
||||
|
||||
public const int AnyForm = -1;
|
||||
/// <summary>
|
||||
/// Evolve to Species
|
||||
/// </summary>
|
||||
public readonly int Species;
|
||||
|
||||
/// <summary>
|
||||
/// Conditional Argument (different from <see cref="Level"/>)
|
||||
/// </summary>
|
||||
public readonly int Argument;
|
||||
|
||||
/// <summary>
|
||||
/// Conditional Argument (different from <see cref="Argument"/>)
|
||||
/// </summary>
|
||||
public readonly int Level;
|
||||
|
||||
/// <summary>
|
||||
/// Destination Form
|
||||
/// </summary>
|
||||
/// <remarks>Is <see cref="AnyForm"/> if the evolved form isn't modified. Special consideration for <see cref="LevelUpFormFemale1"/>, which forces 1.</remarks>
|
||||
public readonly int Form;
|
||||
|
||||
private const int AnyForm = -1;
|
||||
|
||||
// Not stored in binary data
|
||||
public bool RequiresLevelUp; // tracks if this method requires a Level Up, lazily set
|
||||
|
||||
public EvolutionMethod(int method, int species, int argument = 0, int level = 0, int form = AnyForm)
|
||||
{
|
||||
Method = method;
|
||||
Species = species;
|
||||
Argument = argument;
|
||||
Form = form;
|
||||
Level = level;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the form that the Pokémon will have after evolution.
|
||||
/// </summary>
|
||||
/// <param name="form">Un-evolved Form ID</param>
|
||||
public int GetDestinationForm(int form)
|
||||
{
|
||||
if (Method == (int)LevelUpFormFemale1)
|
||||
|
|
@ -55,11 +88,11 @@ public bool Valid(PKM pkm, int lvl, bool skipChecks)
|
|||
case TradeSpecies:
|
||||
return !pkm.IsUntraded || skipChecks;
|
||||
|
||||
// Special Level Up Cases -- return false if invalid
|
||||
case LevelUpNatureAmped when GetAmpLowKeyResult(pkm.Nature) != pkm.AltForm && !skipChecks:
|
||||
case LevelUpNatureLowKey when GetAmpLowKeyResult(pkm.Nature) != pkm.AltForm && !skipChecks:
|
||||
return false;
|
||||
|
||||
// Special Level Up Cases -- return false if invalid
|
||||
case LevelUpBeauty when !(pkm is IContestStats s) || s.CNT_Beauty < Argument:
|
||||
return skipChecks;
|
||||
case LevelUpMale when pkm.Gender != 0:
|
||||
|
|
|
|||
|
|
@ -13,12 +13,9 @@ private static EvolutionMethod GetMethod(byte[] data, int offset)
|
|||
int method = data[offset];
|
||||
int species = data[offset + 1];
|
||||
int arg = data[offset + 2];
|
||||
var obj = new EvolutionMethod {Method = method, Species = species};
|
||||
if (method == 1)
|
||||
obj.Level = arg;
|
||||
else
|
||||
obj.Argument = arg;
|
||||
return obj;
|
||||
return (method == 1)
|
||||
? new EvolutionMethod(method, species, level: arg)
|
||||
: new EvolutionMethod(method, species, argument: arg);
|
||||
}
|
||||
|
||||
public static IReadOnlyList<EvolutionMethod[]> GetArray(byte[] data, int maxSpecies)
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@ private static EvolutionMethod GetMethod(byte[] data, int offset)
|
|||
case 3: /* Friendship night*/
|
||||
case 5: /* Trade */
|
||||
case 6: /* Trade while holding */
|
||||
return new EvolutionMethod { Method = method, Species = species, Argument = arg };
|
||||
return new EvolutionMethod(method, species, argument: arg);
|
||||
case 4: /* Level Up */
|
||||
return new EvolutionMethod { Method = 4, Species = species, Level = arg, Argument = arg };
|
||||
return new EvolutionMethod(4, species, argument: arg, level:arg);
|
||||
case 7: /* Use item */
|
||||
case 15: /* Beauty evolution*/
|
||||
return new EvolutionMethod { Method = method + 1, Species = species, Argument = arg };
|
||||
return new EvolutionMethod(method + 1, species, argument: arg);
|
||||
case 8: /* Tyrogue -> Hitmonchan */
|
||||
case 9: /* Tyrogue -> Hitmonlee */
|
||||
case 10: /* Tyrogue -> Hitmontop*/
|
||||
|
|
@ -35,7 +35,7 @@ private static EvolutionMethod GetMethod(byte[] data, int offset)
|
|||
case 12: /* Wurmple -> Cascoon evolution */
|
||||
case 13: /* Nincada -> Ninjask evolution */
|
||||
case 14: /* Shedinja spawn in Nincada -> Ninjask evolution */
|
||||
return new EvolutionMethod { Method = method + 1, Species = species, Level = arg, Argument = arg };
|
||||
return new EvolutionMethod(method + 1, species, argument: arg, level: arg);
|
||||
|
||||
default:
|
||||
throw new ArgumentException(nameof(method));
|
||||
|
|
|
|||
|
|
@ -22,17 +22,8 @@ private static EvolutionMethod GetMethod(byte[] data, int offset)
|
|||
if (method > 6)
|
||||
method++;
|
||||
|
||||
var evo = new EvolutionMethod
|
||||
{
|
||||
Method = method,
|
||||
Argument = arg,
|
||||
Species = species,
|
||||
Level = arg,
|
||||
};
|
||||
|
||||
if (EvolutionSet6.EvosWithArg.Contains(method))
|
||||
evo.Level = 0;
|
||||
return evo;
|
||||
var lvl = EvolutionSet6.EvosWithArg.Contains(method) ? 0 : arg;
|
||||
return new EvolutionMethod(method, species, argument: arg, level: lvl);
|
||||
}
|
||||
|
||||
public static IReadOnlyList<EvolutionMethod[]> GetArray(byte[] data)
|
||||
|
|
|
|||
|
|
@ -17,17 +17,8 @@ private static EvolutionMethod GetMethod(byte[] data, int offset)
|
|||
if (method == 0)
|
||||
throw new ArgumentException(nameof(data));
|
||||
|
||||
var evo = new EvolutionMethod
|
||||
{
|
||||
Method = method,
|
||||
Argument = arg,
|
||||
Species = species,
|
||||
Level = arg,
|
||||
};
|
||||
|
||||
if (EvolutionSet6.EvosWithArg.Contains(method))
|
||||
evo.Level = 0;
|
||||
return evo;
|
||||
var lvl = EvolutionSet6.EvosWithArg.Contains(method) ? 0 : arg;
|
||||
return new EvolutionMethod(method, species, argument: arg, level: lvl);
|
||||
}
|
||||
|
||||
public static IReadOnlyList<EvolutionMethod[]> GetArray(byte[] data)
|
||||
|
|
|
|||
|
|
@ -16,21 +16,14 @@ private static EvolutionMethod[] GetMethods(byte[] data)
|
|||
var evos = new EvolutionMethod[data.Length / SIZE];
|
||||
for (int i = 0; i < data.Length; i += SIZE)
|
||||
{
|
||||
var evo = new EvolutionMethod
|
||||
{
|
||||
Method = BitConverter.ToUInt16(data, i + 0),
|
||||
Argument = BitConverter.ToUInt16(data, i + 2),
|
||||
Species = BitConverter.ToUInt16(data, i + 4),
|
||||
|
||||
// Copy
|
||||
Level = BitConverter.ToUInt16(data, i + 2),
|
||||
};
|
||||
var method = BitConverter.ToUInt16(data, i + 0);
|
||||
var arg = BitConverter.ToUInt16(data, i + 2);
|
||||
var spec = BitConverter.ToUInt16(data, i + 4);
|
||||
|
||||
// Argument is used by both Level argument and Item/Move/etc. Clear if appropriate.
|
||||
if (EvosWithArg.Contains(evo.Method))
|
||||
evo.Level = 0;
|
||||
var lvl = EvosWithArg.Contains(method) ? 0 : arg;
|
||||
|
||||
evos[i/SIZE] = evo;
|
||||
evos[i/SIZE] = new EvolutionMethod(method, spec, argument: arg, level: lvl);
|
||||
}
|
||||
return evos;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,14 +15,12 @@ private static EvolutionMethod[] GetMethods(byte[] data)
|
|||
var evos = new EvolutionMethod[data.Length / SIZE];
|
||||
for (int i = 0; i < data.Length; i += SIZE)
|
||||
{
|
||||
evos[i / SIZE] = new EvolutionMethod
|
||||
{
|
||||
Method = BitConverter.ToUInt16(data, i + 0),
|
||||
Argument = BitConverter.ToUInt16(data, i + 2),
|
||||
Species = BitConverter.ToUInt16(data, i + 4),
|
||||
Form = (sbyte)data[i + 6],
|
||||
Level = data[i + 7],
|
||||
};
|
||||
var method = BitConverter.ToUInt16(data, i + 0);
|
||||
var arg = BitConverter.ToUInt16(data, i + 2);
|
||||
var spec = BitConverter.ToUInt16(data, i + 4);
|
||||
var form = (sbyte) data[i + 6];
|
||||
var level = data[i + 7];
|
||||
evos[i / SIZE] = new EvolutionMethod(method, spec, argument: arg, level: level, form: form);
|
||||
}
|
||||
return evos;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user