2019-05-30 05:40:39 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2019-05-30 04:35:52 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using static PKHeX.Core.MessageStrings;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
2019-07-14 22:06:45 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Utility for editing a <see cref="PKM"/>
|
|
|
|
|
/// </summary>
|
2019-05-30 04:35:52 +00:00
|
|
|
|
public static class EditPKMUtil
|
|
|
|
|
{
|
2020-06-17 02:46:22 +00:00
|
|
|
|
public static List<string> GetSuggestionMessage(PKM pkm, int level, int location, int minimumLevel)
|
2019-05-30 04:35:52 +00:00
|
|
|
|
{
|
|
|
|
|
var suggestion = new List<string> { MsgPKMSuggestionStart };
|
|
|
|
|
if (pkm.Format >= 3)
|
|
|
|
|
{
|
2020-06-17 02:46:22 +00:00
|
|
|
|
var metList = GameInfo.GetLocationList((GameVersion)pkm.Version, pkm.Format, egg: false);
|
|
|
|
|
var locationName = metList.First(loc => loc.Value == location).Text;
|
|
|
|
|
suggestion.Add($"{MsgPKMSuggestionMetLocation} {locationName}");
|
2019-05-30 04:35:52 +00:00
|
|
|
|
suggestion.Add($"{MsgPKMSuggestionMetLevel} {level}");
|
|
|
|
|
}
|
2020-06-17 02:46:22 +00:00
|
|
|
|
if (pkm.CurrentLevel < minimumLevel)
|
|
|
|
|
suggestion.Add($"{MsgPKMSuggestionLevel} {minimumLevel}");
|
2019-05-30 04:35:52 +00:00
|
|
|
|
return suggestion;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-30 05:40:39 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Applies junk data to a <see cref="SaveFile.BlankPKM"/>, which is preferable to a completely empty entity.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pk">Blank data</param>
|
|
|
|
|
/// <param name="tr">Trainer info to apply</param>
|
|
|
|
|
public static void TemplateFields(PKM pk, ITrainerInfo tr)
|
|
|
|
|
{
|
|
|
|
|
pk.Move1 = 1;
|
|
|
|
|
pk.Move1_PP = 40;
|
|
|
|
|
pk.Ball = 4;
|
|
|
|
|
pk.MetDate = DateTime.Today;
|
|
|
|
|
|
|
|
|
|
if (tr.Game >= 0)
|
|
|
|
|
pk.Version = tr.Game;
|
|
|
|
|
int spec = ((GameVersion)pk.Version).GetMaxSpeciesID();
|
|
|
|
|
if (spec <= 0)
|
|
|
|
|
spec = pk.MaxSpeciesID;
|
|
|
|
|
pk.Species = spec;
|
|
|
|
|
var lang = tr.Language;
|
|
|
|
|
if (lang <= 0)
|
|
|
|
|
lang = (int)LanguageID.English;
|
|
|
|
|
pk.Language = lang;
|
2019-12-01 07:44:37 +00:00
|
|
|
|
pk.Gender = pk.GetSaneGender();
|
2019-05-30 05:40:39 +00:00
|
|
|
|
|
|
|
|
|
pk.ClearNickname();
|
|
|
|
|
|
|
|
|
|
pk.OT_Name = tr.OT;
|
|
|
|
|
pk.OT_Gender = tr.Gender;
|
|
|
|
|
pk.TID = tr.TID;
|
|
|
|
|
pk.SID = tr.SID;
|
2020-07-31 18:17:31 +00:00
|
|
|
|
if (tr.ConsoleRegion >= 0 && pk is IGeoTrack gt)
|
2019-05-30 05:40:39 +00:00
|
|
|
|
{
|
2020-07-31 18:17:31 +00:00
|
|
|
|
gt.ConsoleRegion = tr.ConsoleRegion;
|
|
|
|
|
gt.Country = tr.Country;
|
|
|
|
|
gt.Region = tr.SubRegion;
|
2019-05-30 05:40:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Copy OT trash bytes for sensitive games (Gen1/2)
|
2019-10-26 19:42:33 +00:00
|
|
|
|
if (pk is GBPKM pk12)
|
2019-07-14 22:06:45 +00:00
|
|
|
|
{
|
|
|
|
|
switch (tr)
|
|
|
|
|
{
|
|
|
|
|
case SAV1 s1:
|
|
|
|
|
pk12.OT_Trash = s1.OT_Trash;
|
|
|
|
|
break;
|
|
|
|
|
case SAV2 s2:
|
|
|
|
|
pk12.OT_Trash = s2.OT_Trash;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-05-30 05:50:34 +00:00
|
|
|
|
|
|
|
|
|
pk.RefreshChecksum();
|
2019-05-30 05:40:39 +00:00
|
|
|
|
}
|
2019-05-30 04:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|