2018-06-06 01:27:08 +00:00
|
|
|
using System;
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
{
|
|
|
|
[Flags]
|
2018-06-06 05:20:30 +00:00
|
|
|
public enum MysteryGiftRestriction
|
2018-06-06 01:27:08 +00:00
|
|
|
{
|
|
|
|
None = 0,
|
|
|
|
LangJapanese = 1 << LanguageID.Japanese,
|
|
|
|
LangEnglish = 1 << LanguageID.English,
|
|
|
|
LangFrench = 1 << LanguageID.French,
|
|
|
|
LangItalian = 1 << LanguageID.Italian,
|
|
|
|
LangGerman = 1 << LanguageID.German,
|
|
|
|
LangSpanish = 1 << LanguageID.Spanish,
|
|
|
|
LangKorean = 1 << LanguageID.Korean,
|
|
|
|
|
|
|
|
LangRestrict = LangJapanese | LangEnglish | LangFrench | LangItalian | LangGerman | LangSpanish | LangKorean,
|
|
|
|
RegionBase = LangKorean,
|
|
|
|
|
|
|
|
RegJP = RegionBase << RegionID.Japan,
|
|
|
|
RegNA = RegionBase << RegionID.NorthAmerica,
|
|
|
|
RegEU = RegionBase << RegionID.Europe,
|
|
|
|
RegZH = RegionBase << RegionID.China,
|
|
|
|
RegKO = RegionBase << RegionID.Korea,
|
|
|
|
RegTW = RegionBase << RegionID.Taiwan,
|
|
|
|
|
|
|
|
RegionRestrict = RegJP | RegNA | RegEU | RegZH | RegKO | RegTW,
|
|
|
|
|
|
|
|
OTReplacedOnTrade = RegTW << 1,
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class MysteryGiftRestrictionExtensions
|
|
|
|
{
|
|
|
|
public static bool HasFlagFast(this MysteryGiftRestriction value, MysteryGiftRestriction flag)
|
|
|
|
{
|
|
|
|
return (value & flag) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int GetSuggestedLanguage(this MysteryGiftRestriction value)
|
|
|
|
{
|
|
|
|
for (int i = (int)LanguageID.Japanese; i <= (int)LanguageID.Korean; i++)
|
2018-08-03 03:11:42 +00:00
|
|
|
{
|
2018-06-06 01:27:08 +00:00
|
|
|
if (value.HasFlagFast((MysteryGiftRestriction)(1 << i)))
|
|
|
|
return i;
|
2018-08-03 03:11:42 +00:00
|
|
|
}
|
2018-06-06 01:27:08 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2018-08-03 03:11:42 +00:00
|
|
|
|
2018-06-06 01:27:08 +00:00
|
|
|
public static int GetSuggestedRegion(this MysteryGiftRestriction value)
|
|
|
|
{
|
|
|
|
for (int i = (int)RegionID.Japan; i <= (int)RegionID.Taiwan; i++)
|
2018-08-03 03:11:42 +00:00
|
|
|
{
|
2018-06-06 01:27:08 +00:00
|
|
|
if (value.HasFlagFast((MysteryGiftRestriction)((int)MysteryGiftRestriction.RegionBase << i)))
|
|
|
|
return i;
|
2018-08-03 03:11:42 +00:00
|
|
|
}
|
2018-06-06 01:27:08 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|