Esempio n. 1
0
        private void SetSizeData(PB7 pkm)
        {
            int species = pkm.Species;
            int form    = pkm.AltForm;

            if (!TryGetSizeEntryIndex(species, form, out int index))
            {
                return;
            }

            if (Math.Round(pkm.HeightAbsolute) < pkm.PersonalInfo.Height) // possible minimum height
            {
                int ofs        = GetDexSizeOffset(DexSizeType.MinHeight, index);
                var minHeight  = BitConverter.ToUInt16(SAV.Data, ofs) >> 1;
                var calcHeight = PB7.GetHeightAbsolute(pkm.PersonalInfo, minHeight);
                if (Math.Round(pkm.HeightAbsolute) < Math.Round(calcHeight) || BitConverter.ToUInt32(SAV.Data, ofs) == 0x007F00FE) // unset
                {
                    SetSizeData(pkm, DexSizeType.MinHeight);
                }
            }
            else if (Math.Round(pkm.HeightAbsolute) > pkm.PersonalInfo.Height) // possible maximum height
            {
                int ofs        = GetDexSizeOffset(DexSizeType.MaxHeight, index);
                var maxHeight  = BitConverter.ToUInt16(SAV.Data, ofs) >> 1;
                var calcHeight = PB7.GetHeightAbsolute(pkm.PersonalInfo, maxHeight);
                if (Math.Round(pkm.HeightAbsolute) > Math.Round(calcHeight) || BitConverter.ToUInt32(SAV.Data, ofs) == 0x007F00FE) // unset
                {
                    SetSizeData(pkm, DexSizeType.MaxHeight);
                }
            }

            if (Math.Round(pkm.WeightAbsolute) < pkm.PersonalInfo.Weight) // possible minimum weight
            {
                int ofs        = GetDexSizeOffset(DexSizeType.MinWeight, index);
                var minWeight  = BitConverter.ToUInt16(SAV.Data, ofs + 2);
                var minHeight  = BitConverter.ToUInt16(SAV.Data, ofs) >> 1;
                var calcWeight = PB7.GetWeightAbsolute(pkm.PersonalInfo, minHeight, minWeight);
                if (Math.Round(pkm.WeightAbsolute) < Math.Round(calcWeight) || BitConverter.ToUInt32(SAV.Data, ofs) == 0x007F00FE) // unset
                {
                    SetSizeData(pkm, DexSizeType.MinWeight);
                }
            }
            else if (Math.Round(pkm.WeightAbsolute) > pkm.PersonalInfo.Weight) // possible maximum weight
            {
                int ofs        = GetDexSizeOffset(DexSizeType.MaxWeight, index);
                var maxWeight  = BitConverter.ToUInt16(SAV.Data, ofs + 2);
                var maxHeight  = BitConverter.ToUInt16(SAV.Data, ofs) >> 1;
                var calcWeight = PB7.GetWeightAbsolute(pkm.PersonalInfo, maxHeight, maxWeight);
                if (Math.Round(pkm.WeightAbsolute) > Math.Round(calcWeight) || BitConverter.ToUInt32(SAV.Data, ofs) == 0x007F00FE) // unset
                {
                    SetSizeData(pkm, DexSizeType.MaxWeight);
                }
            }
        }
Esempio n. 2
0
 private static void VerifyBelugaStats(LegalityAnalysis data, PB7 pb7)
 {
     if (Math.Abs(pb7.HeightAbsolute - pb7.CalcHeightAbsolute) > 0.001)
     {
         data.AddLine(GetInvalid(LStatIncorrectHeight, CheckIdentifier.Encounter));
     }
     if (Math.Abs(pb7.WeightAbsolute - pb7.CalcWeightAbsolute) > 0.001)
     {
         data.AddLine(GetInvalid(LStatIncorrectWeight, CheckIdentifier.Encounter));
     }
     if (pb7.Stat_CP != pb7.CalcCP && !IsStarter(pb7))
     {
         data.AddLine(GetInvalid(LStatIncorrectCP, CheckIdentifier.Encounter));
     }
 }
Esempio n. 3
0
        private static int GetDexSizeOffset(DexSizeType group, int index) => 0x3978 + (index * 6) + ((int)group * 0x45C); // blockofs + 0xF78 + ([186*6]*n) + x*6

        private void SetSizeData(PB7 pkm, DexSizeType group)
        {
            var tree    = EvolutionTree.GetEvolutionTree(pkm, 7);
            int species = pkm.Species;
            int form    = pkm.AltForm;

            int height = pkm.HeightScalar;
            int weight = pkm.WeightScalar;

            // update for all species in potential lineage
            var allspec = tree.GetEvolutionsAndPreEvolutions(species, form);

            foreach (var s in allspec)
            {
                SetSizeData(group, s, form, height, weight);
            }
        }
Esempio n. 4
0
 private static void VerifyBelugaStats(LegalityAnalysis data, PB7 pb7)
 {
     // ReSharper disable once CompareOfFloatsByEqualityOperator -- THESE MUST MATCH EXACTLY
     if (!IsCloseEnough(pb7.HeightAbsolute, pb7.CalcHeightAbsolute))
     {
         data.AddLine(GetInvalid(LStatIncorrectHeight, Encounter));
     }
     // ReSharper disable once CompareOfFloatsByEqualityOperator -- THESE MUST MATCH EXACTLY
     if (!IsCloseEnough(pb7.WeightAbsolute, pb7.CalcWeightAbsolute))
     {
         data.AddLine(GetInvalid(LStatIncorrectWeight, Encounter));
     }
     if (pb7.Stat_CP != pb7.CalcCP && !IsStarter(pb7))
     {
         data.AddLine(GetInvalid(LStatIncorrectCP, Encounter));
     }
 }
Esempio n. 5
0
        private static void VerifyBelugaStats(LegalityAnalysis data, PB7 pb7)
        {
            if (Math.Abs(pb7.HeightAbsolute - pb7.CalcHeightAbsolute) > 0.001)
            {
                data.AddLine(GetInvalid(LStatIncorrectHeight, CheckIdentifier.Encounter));
            }
            if (Math.Abs(pb7.WeightAbsolute - pb7.CalcWeightAbsolute) > 0.001)
            {
                data.AddLine(GetInvalid(LStatIncorrectWeight, CheckIdentifier.Encounter));
            }
            if (pb7.Stat_CP != pb7.CalcCP && !IsStarter(pb7))
            {
                data.AddLine(GetInvalid(LStatIncorrectCP, CheckIdentifier.Encounter));
            }

            if (IsTradeEvoRequired7b(data.EncounterOriginal, pb7))
            {
                var unevolved = LegalityAnalysis.SpeciesStrings[pb7.Species];
                var evolved   = LegalityAnalysis.SpeciesStrings[pb7.Species + 1];
                data.AddLine(GetInvalid(string.Format(LEvoTradeReqOutsider, unevolved, evolved), CheckIdentifier.Evolution));
            }
        }
Esempio n. 6
0
        private static void VerifyBelugaStats(LegalityAnalysis data, PB7 pb7)
        {
            // ReSharper disable once CompareOfFloatsByEqualityOperator -- THESE MUST MATCH EXACTLY
            if (!IsCloseEnough(pb7.HeightAbsolute, pb7.CalcHeightAbsolute))
            {
                data.AddLine(GetInvalid(LStatIncorrectHeight, Encounter));
            }
            // ReSharper disable once CompareOfFloatsByEqualityOperator -- THESE MUST MATCH EXACTLY
            if (!IsCloseEnough(pb7.WeightAbsolute, pb7.CalcWeightAbsolute))
            {
                data.AddLine(GetInvalid(LStatIncorrectWeight, Encounter));
            }
            if (pb7.Stat_CP != pb7.CalcCP && !IsStarter(pb7))
            {
                data.AddLine(GetInvalid(LStatIncorrectCP, Encounter));
            }

            if (IsTradeEvoRequired7b(data.EncounterOriginal, pb7))
            {
                var unevolved = LegalityAnalysis.SpeciesStrings[pb7.Species];
                var evolved   = LegalityAnalysis.SpeciesStrings[pb7.Species + 1];
                data.AddLine(GetInvalid(string.Format(LEvoTradeReqOutsider, unevolved, evolved), Evolution));
            }
        }