2021-02-09 04:39:46 +00:00
|
|
|
|
using System;
|
2021-02-09 04:42:19 +00:00
|
|
|
|
using static PKHeX.Core.Species;
|
2021-02-09 04:39:46 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Alternate form data has an associated value.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// <see cref="Furfrou"/> How long (days) the form can last before reverting to Form-0 (5 days max)
|
|
|
|
|
/// <see cref="Hoopa"/>: How long (days) the form can last before reverting to Form-0 (3 days max)
|
|
|
|
|
/// <see cref="Alcremie"/>: Topping (Strawberry, Star, etc); [0,7]
|
|
|
|
|
/// <see cref="Yamask"/> How much damage the Pokémon has taken as Yamask-1 [0,9999].
|
|
|
|
|
/// <see cref="Runerigus"/> How much damage the Pokémon has taken as Yamask-1 [0,9999].
|
|
|
|
|
/// <see cref="Stantler"/> How many times the Pokémon has used Psyshield Bash in the Agile Style [0,9999].
|
|
|
|
|
/// <see cref="Qwilfish"/> How many times the Pokémon has used Barb Barrage in the Strong Style as Qwilfish-1 [0,9999].
|
|
|
|
|
/// <see cref="Basculin"/> How much damage the Pokémon has taken through recoil as Basculin-2 [0,9999].
|
|
|
|
|
/// </remarks>
|
|
|
|
|
public interface IFormArgument
|
2019-11-29 18:44:52 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2022-06-18 18:04:24 +00:00
|
|
|
|
/// Argument for the associated <see cref="PKM.Form"/>
|
2019-11-29 18:44:52 +00:00
|
|
|
|
/// </summary>
|
2022-06-18 18:04:24 +00:00
|
|
|
|
uint FormArgument { get; set; }
|
2021-02-09 04:26:53 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Amount of days the timed <see cref="PKM.Form"/> will remain active for.
|
|
|
|
|
/// </summary>
|
|
|
|
|
byte FormArgumentRemain { get; set; }
|
2021-02-09 04:26:53 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Amount of days the timed <see cref="PKM.Form"/> has been active for.
|
|
|
|
|
/// </summary>
|
|
|
|
|
byte FormArgumentElapsed { get; set; }
|
2021-02-09 04:26:53 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Maximum amount of days the <see cref="Species.Furfrou"/> has maintained a <see cref="PKM.Form"/> without reverting to its base form.
|
|
|
|
|
/// </summary>
|
|
|
|
|
byte FormArgumentMaximum { get; set; }
|
|
|
|
|
}
|
2021-02-09 04:39:46 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Logic for mutating an <see cref="IFormArgument"/> object.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class FormArgumentUtil
|
|
|
|
|
{
|
2021-02-09 04:39:46 +00:00
|
|
|
|
/// <summary>
|
2022-06-18 18:04:24 +00:00
|
|
|
|
/// Sets the suggested Form Argument to the <see cref="pk"/>.
|
2021-02-09 04:39:46 +00:00
|
|
|
|
/// </summary>
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public static void SetSuggestedFormArgument(this PKM pk, int originalSpecies = 0)
|
2021-02-09 04:39:46 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
if (pk is not IFormArgument)
|
|
|
|
|
return;
|
|
|
|
|
if (!IsFormArgumentTypeDatePair(pk.Species, pk.Form))
|
2021-02-09 04:39:46 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
uint suggest = originalSpecies switch
|
2021-02-09 04:39:46 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
(int) Yamask when pk.Species == (int) Runerigus => 49u,
|
|
|
|
|
(int) Qwilfish when pk.Species == (int) Overqwil => 20u,
|
|
|
|
|
(int) Stantler when pk.Species == (int) Wyrdeer => 20u,
|
|
|
|
|
(int) Basculin when pk.Species == (int) Basculegion => 294u,
|
|
|
|
|
_ => 0u,
|
|
|
|
|
};
|
|
|
|
|
pk.ChangeFormArgument(suggest);
|
|
|
|
|
return;
|
2021-02-09 04:39:46 +00:00
|
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
|
var max = GetFormArgumentMax(pk.Species, pk.Form, pk.Format);
|
|
|
|
|
pk.ChangeFormArgument(max);
|
|
|
|
|
}
|
2021-02-09 04:39:46 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Modifies the <see cref="IFormArgument"/> values for the provided <see cref="pk"/> to the requested <see cref="value"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void ChangeFormArgument(this PKM pk, uint value)
|
|
|
|
|
{
|
|
|
|
|
if (pk is not IFormArgument f)
|
|
|
|
|
return;
|
|
|
|
|
f.ChangeFormArgument(pk.Species, pk.Form, pk.Format, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Modifies the <see cref="IFormArgument"/> values for the provided inputs to the requested <see cref="value"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="f">Form Argument object</param>
|
|
|
|
|
/// <param name="species">Entity Species</param>
|
|
|
|
|
/// <param name="form">Entity Species</param>
|
|
|
|
|
/// <param name="generation">Entity current format generation</param>
|
|
|
|
|
/// <param name="value">Value to apply</param>
|
|
|
|
|
public static void ChangeFormArgument(this IFormArgument f, int species, int form, int generation, uint value)
|
|
|
|
|
{
|
|
|
|
|
if (!IsFormArgumentTypeDatePair(species, form))
|
2021-02-09 04:39:46 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
f.FormArgument = value;
|
|
|
|
|
return;
|
2021-02-09 04:39:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
var max = GetFormArgumentMax(species, form, generation);
|
|
|
|
|
f.FormArgumentRemain = (byte)value;
|
|
|
|
|
if (value == max)
|
2021-02-09 04:39:46 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
f.FormArgumentElapsed = f.FormArgumentMaximum = 0;
|
|
|
|
|
return;
|
2021-02-09 04:39:46 +00:00
|
|
|
|
}
|
2021-02-09 04:42:19 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
byte elapsed = max < value ? (byte)0 : (byte)(max - value);
|
|
|
|
|
f.FormArgumentElapsed = elapsed;
|
|
|
|
|
if (species == (int)Furfrou)
|
|
|
|
|
f.FormArgumentMaximum = Math.Max(f.FormArgumentMaximum, elapsed);
|
|
|
|
|
}
|
2021-02-09 04:42:19 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
public static uint GetFormArgumentMax(int species, int form, int generation)
|
|
|
|
|
{
|
|
|
|
|
if (generation <= 5)
|
|
|
|
|
return 0;
|
2021-02-09 04:42:19 +00:00
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
|
return species switch
|
2021-02-09 04:42:19 +00:00
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
|
(int)Furfrou when form != 0 => 5,
|
|
|
|
|
(int)Hoopa when form == 1 => 3,
|
|
|
|
|
(int)Yamask when form == 1 => 9999,
|
|
|
|
|
(int)Runerigus when form == 0 => 9999,
|
|
|
|
|
(int)Alcremie => (uint)AlcremieDecoration.Ribbon,
|
|
|
|
|
(int)Qwilfish when form == 1 && generation == 8 => 9999, // 20
|
|
|
|
|
(int)Overqwil => 9999, // 20
|
|
|
|
|
(int)Stantler or (int)Wyrdeer when generation == 8 => 9999, // 20
|
|
|
|
|
(int)Basculin when form == 2 => 9999, // 294
|
|
|
|
|
(int)Basculegion => 9999, // 294
|
|
|
|
|
_ => 0,
|
2022-03-06 02:54:50 +00:00
|
|
|
|
};
|
2021-02-09 04:39:46 +00:00
|
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
|
|
|
|
|
|
public static bool IsFormArgumentTypeDatePair(int species, int form) => species switch
|
|
|
|
|
{
|
|
|
|
|
(int)Furfrou when form != 0 => true,
|
|
|
|
|
(int)Hoopa when form == 1 => true,
|
|
|
|
|
_ => false,
|
|
|
|
|
};
|
2021-02-09 04:39:46 +00:00
|
|
|
|
}
|