Exemplo n.º 1
0
 public static void ValidateGender(PBEAlphabeticalList <PBEGender> valid, PBEGender value)
 {
     if (!valid.Contains(value))
     {
         throw new ArgumentOutOfRangeException(nameof(value));
     }
 }
Exemplo n.º 2
0
        public static Bitmap GetMinispriteBitmap(PBESpecies species, PBEForm form, PBEGender gender, bool shiny)
        {
            string speciesStr = PBEDataUtils.GetNameOfForm(species, form) ?? species.ToString();
            string genderStr  = gender == PBEGender.Female && HasFemaleSprite(species, true) ? "_F" : string.Empty;

            return(new Bitmap(GetResourceStream("PKMN.PKMN_" + speciesStr + (shiny ? "_S" : string.Empty) + genderStr + ".png")));
        }
Exemplo n.º 3
0
 public Pokedex()
 {
     _data = new Dictionary <PBESpecies, Dictionary <PBEForm, Dictionary <PBEGender, Entry> > >((int)PBESpecies.MAX);
     for (var species = (PBESpecies)1; species < PBESpecies.MAX; species++)
     {
         PBEGender[]             genders = GetGenderKeys(species);
         IReadOnlyList <PBEForm> forms   = PBEDataUtils.GetForms(species, false);
         if (forms.Count == 0)
         {
             forms = new PBEForm[] { 0 };
         }
         var formDict = new Dictionary <PBEForm, Dictionary <PBEGender, Entry> >(forms.Count);
         for (int f = 0; f < forms.Count; f++)
         {
             PBEForm form       = forms[f];
             var     genderDict = new Dictionary <PBEGender, Entry>(genders.Length);
             for (int g = 0; g < genders.Length; g++)
             {
                 PBEGender gender = genders[g];
                 genderDict.Add(gender, new Entry(species, form, gender));
             }
             formDict.Add(form, genderDict);
         }
         _data.Add(species, formDict);
     }
 }
Exemplo n.º 4
0
        public static Sprite GetMinisprite(PBESpecies species, PBEForm form, PBEGender gender, bool shiny)
        {
            string speciesStr = PBEDataUtils.GetNameOfForm(species, form) ?? species.ToString();
            string genderStr  = gender == PBEGender.Female && HasFemaleSprite(species, true) ? "_F" : string.Empty;

            return(Sprite.LoadOrGet("Pkmn.PKMN_" + speciesStr + (shiny ? "_S" : string.Empty) + genderStr + ".png"));
        }
 public static PBELocalizedString GetGenderName(PBEGender gender)
 {
     if (gender >= PBEGender.MAX)
     {
         throw new ArgumentOutOfRangeException(nameof(gender));
     }
     return(new PBELocalizedString(PBEUtils.QueryDatabase <SearchResult>(string.Format(QueryId, "GenderNames", (byte)gender))[0]));
 }
Exemplo n.º 6
0
        public static Bitmap GetMinisprite(PBESpecies species, PBEGender gender, bool shiny)
        {
            ushort speciesID = (ushort)species;
            uint   formID    = (uint)species >> 0x10;
            string sss       = speciesID + (formID > 0 ? ("_" + formID) : string.Empty) + (shiny ? "_S" : string.Empty);
            string genderStr = gender == PBEGender.Female && DoesResourceExist("PKMN.PKMN_" + sss + "_F.png") ? "_F" : string.Empty;

            return(new Bitmap(GetResourceStream("PKMN.PKMN_" + sss + genderStr + ".png")));
        }
Exemplo n.º 7
0
        public static Bitmap GetMinisprite(PBESpecies species, PBEGender gender, bool shiny)
        {
            uint   speciesID             = (uint)species & 0xFFFF;
            uint   formeID               = (uint)species >> 0x10;
            string sss                   = $"{speciesID}{(formeID > 0 ? $"_{formeID}" : string.Empty)}{(shiny ? "_S" : string.Empty)}";
            bool   spriteIsGenderNeutral = DoesResourceExist($"Kermalis.PokemonBattleEngineClient.PKMN.PKMN_{sss}.png");
            string genderStr             = spriteIsGenderNeutral ? string.Empty : gender == PBEGender.Female ? "_F" : "_M";

            return(UriToBitmap(new Uri($"resm:Kermalis.PokemonBattleEngineClient.PKMN.PKMN_{sss}{genderStr}.png?assembly=PokemonBattleEngineClient")));
        }
Exemplo n.º 8
0
        public void SetSeen(PBESpecies species, PBEForm form, PBEGender gender, bool shiny, uint pid)
        {
            gender = GetGenderKey(species, gender);
            Entry en = _data[species][form][gender];

            SetSpindaPIDIfFirstSpinda(en, pid);
            if (!en.Seen)
            {
                en.IsShiny = shiny;
            }
            en.Seen = true;
        }
        public unsafe void UpdateInfoBar()
        {
            fixed(uint *bmpAddress = InfoBarImg.Bitmap)
            {
                RenderUtils.OverwriteRectangle(bmpAddress, InfoBarImg.Width, InfoBarImg.Height, RenderUtils.Color(48, 48, 48, 128));
                // Nickname
                Font.DefaultSmall.DrawString(bmpAddress, InfoBarImg.Width, InfoBarImg.Height, 2, 3, Pkmn.KnownNickname, Font.DefaultWhite_I);
                // Gender
                PBEGender gender = _useKnownInfo && !Pkmn.KnownStatus2.HasFlag(PBEStatus2.Transformed) ? Pkmn.KnownGender : Pkmn.Gender;

                if (gender != PBEGender.Genderless)
                {
                    Font.Default.DrawString(bmpAddress, InfoBarImg.Width, InfoBarImg.Height, 51, -2, gender.ToSymbol(), gender == PBEGender.Male ? Font.DefaultBlue_O : Font.DefaultRed_O);
                }
                // Level
                const int lvX = 62;

                Font.PartyNumbers.DrawString(bmpAddress, InfoBarImg.Width, InfoBarImg.Height, lvX, 3, "[LV]", Font.DefaultWhite_I);
                Font.PartyNumbers.DrawString(bmpAddress, InfoBarImg.Width, InfoBarImg.Height, lvX + 12, 3, Pkmn.Level.ToString(), Font.DefaultWhite_I);
                // Caught
                if (_useKnownInfo && Pkmn.IsWild && Game.Instance.Save.Pokedex.IsCaught(Pkmn.KnownSpecies))
                {
                    Font.Default.DrawString(bmpAddress, InfoBarImg.Width, InfoBarImg.Height, 2, 12, "*", Font.DefaultRed_O);
                }
                // Status
                PBEStatus1 status = Pkmn.Status1;

                if (status != PBEStatus1.None)
                {
                    Font.DefaultSmall.DrawString(bmpAddress, InfoBarImg.Width, InfoBarImg.Height, 30, 13, status.ToString(), Font.DefaultWhite_I);
                }
                // HP
                if (!_useKnownInfo)
                {
                    string str = Pkmn.HP.ToString();
                    Font.PartyNumbers.MeasureString(str, out int strW, out int _);
                    Font.PartyNumbers.DrawString(bmpAddress, InfoBarImg.Width, InfoBarImg.Height, 45 - strW, 28, str, Font.DefaultWhite_I);
                    Font.PartyNumbers.DrawString(bmpAddress, InfoBarImg.Width, InfoBarImg.Height, 46, 28, "/" + Pkmn.MaxHP, Font.DefaultWhite_I);
                }

                const int lineStartX = 9;
                const int lineW      = 82;

                RenderUtils.HP_TripleLine(bmpAddress, InfoBarImg.Width, InfoBarImg.Height, lineStartX, 23, lineW, Pkmn.HPPercentage);

                // EXP
                if (!_useKnownInfo)
                {
                    RenderUtils.EXP_SingleLine(bmpAddress, InfoBarImg.Width, InfoBarImg.Height, lineStartX, 37, lineW, Pkmn.EXP, Pkmn.Level, Pkmn.Species, Pkmn.RevertForm);
                }
            }
        }
Exemplo n.º 10
0
            private unsafe void Draw(uint *bmpAddress, int bmpWidth, int bmpHeight)
            {
                _slot.DrawOn(bmpAddress, bmpWidth, bmpHeight, 0, 0);
                if (SPkmn is null)                                                      // Effectively the same as IsDisabled
                {
                    RenderUtils.FillColor(bmpAddress, bmpWidth, bmpHeight, 0x80313131); // Looks bad because it also affects the transparent bits
                    return;
                }

                PBEBattlePokemon pkmn             = SPkmn.Pkmn;
                Font             fontDefault      = Font.Default;
                Font             fontPartyNumbers = Font.PartyNumbers;

                uint[] defaultWhite = Font.DefaultWhite;

                fontDefault.DrawString(bmpAddress, bmpWidth, bmpHeight, 31, 6, pkmn.Nickname, defaultWhite);
                fontPartyNumbers.DrawString(bmpAddress, bmpWidth, bmpHeight, 7, 31, "[LV]", defaultWhite);
                fontPartyNumbers.DrawString(bmpAddress, bmpWidth, bmpHeight, 19, 31, pkmn.Level.ToString(), defaultWhite);
                string str = pkmn.HP.ToString();

                fontPartyNumbers.MeasureString(str, out int strW, out int _);
                fontPartyNumbers.DrawString(bmpAddress, bmpWidth, bmpHeight, 87 - strW, 31, str, defaultWhite);
                fontPartyNumbers.DrawString(bmpAddress, bmpWidth, bmpHeight, 88, 31, "/" + pkmn.MaxHP, defaultWhite);
                PBEGender gender = pkmn.Gender;

                if (gender != PBEGender.Genderless)
                {
                    fontDefault.DrawString(bmpAddress, bmpWidth, bmpHeight, 113, 6, gender.ToSymbol(), gender == PBEGender.Male ? Font.DefaultMale : Font.DefaultFemale);
                }

                SPkmn.Minisprite.DrawOn(bmpAddress, bmpWidth, bmpHeight, 0 - 1, 0 - 1);

                // Draw HP
                const int lineStartX = 64;
                const int lineStartY = 27;
                const int lineW      = 48;

                RenderUtils.FillColor(bmpAddress, bmpWidth, bmpHeight, lineStartX - 1, lineStartY - 1, lineW + 2, 4, 0xFF313131);
                RenderUtils.FillColor(bmpAddress, bmpWidth, bmpHeight, lineStartX, lineStartY, lineW, 2, 0xFF212121);
                double hpp  = pkmn.HPPercentage;
                int    theW = (int)(lineW * hpp);

                if (theW == 0 && hpp > 0)
                {
                    theW = 1;
                }
                RenderUtils.DrawHorizontalLine(bmpAddress, bmpWidth, bmpHeight, lineStartX, lineStartY, theW, 0xFF63FF63);
                RenderUtils.DrawHorizontalLine(bmpAddress, bmpWidth, bmpHeight, lineStartX, lineStartY + 1, theW, 0xFF18C621);
                _hpText.DrawOn(bmpAddress, bmpWidth, bmpHeight, 47, 23);
            }
Exemplo n.º 11
0
        public static PBEReadOnlyLocalizedString GetGenderName(PBEGender gender)
        {
            if (gender >= PBEGender.MAX)
            {
                throw new ArgumentOutOfRangeException(nameof(gender));
            }
            List <SearchResult> results = PBEDefaultDataProvider.Instance.QueryDatabase <SearchResult>(string.Format(QueryId, "GenderNames", gender));

            if (results.Count == 1)
            {
                return(new PBEReadOnlyLocalizedString(results[0]));
            }
            throw new InvalidDataException();
        }
Exemplo n.º 12
0
 public static Sprite GetPokemonSprite(PBESpecies species, PBEForm form, PBEGender gender, bool shiny, bool backSprite, bool behindSubstitute)
 {
     if (behindSubstitute)
     {
         return(backSprite ? _substituteBackSprite : _substituteFrontSprite);
     }
     else
     {
         string speciesStr  = PBEDataUtils.GetNameOfForm(species, form) ?? species.ToString();
         string orientation = backSprite ? "_B" : "_F";
         string genderStr   = gender == PBEGender.Female && HasFemaleSprite(species, false) ? "_F" : string.Empty;
         return(Sprite.LoadOrGet("Pkmn.PKMN_" + speciesStr + orientation + (shiny ? "_S" : string.Empty) + genderStr + ".gif"));
     }
 }
 internal PBESwitchInInfo(byte pkmnId, byte disguisedAsId, PBESpecies species, string nickname, byte level, bool shiny, PBEGender gender, ushort hp, ushort maxHP, double hpPercentage, PBEStatus1 status1, PBEFieldPosition fieldPosition)
 {
     PokemonId     = pkmnId;
     DisguisedAsId = disguisedAsId;
     Species       = species;
     Nickname      = nickname;
     Level         = level;
     Shiny         = shiny;
     Gender        = gender;
     HP            = hp;
     MaxHP         = maxHP;
     HPPercentage  = hpPercentage;
     Status1       = status1;
     FieldPosition = fieldPosition;
 }
Exemplo n.º 14
0
        public static Stream GetPokemonSpriteStream(PBESpecies species, bool shiny, PBEGender gender, bool behindSubstitute, bool backSprite)
        {
            string orientation = backSprite ? "_B" : "_F";

            if (behindSubstitute)
            {
                return(GetResourceStream("PKMN.STATUS2_Substitute" + orientation + ".gif"));
            }
            else
            {
                ushort speciesID = (ushort)species;
                uint   formID    = (uint)species >> 0x10;
                string sss       = speciesID + (formID > 0 ? ("_" + formID) : string.Empty) + orientation + (shiny ? "_S" : string.Empty);
                string genderStr = gender == PBEGender.Female && DoesResourceExist("PKMN.PKMN_" + sss + "_F.gif") ? "_F" : string.Empty;
                return(GetResourceStream("PKMN.PKMN_" + sss + genderStr + ".gif"));
            }
        }
Exemplo n.º 15
0
        public static string GetPokemonSprite(PBESpecies species, bool shiny, PBEGender gender, bool behindSubstitute, bool backSprite)
        {
            const string path        = "https://raw.githubusercontent.com/Kermalis/PokemonBattleEngine/master/Shared%20Assets/PKMN/";
            string       orientation = backSprite ? "_B" : "_F";

            if (behindSubstitute)
            {
                return(path + "STATUS2_Substitute" + orientation + ".gif");
            }
            else
            {
                ushort speciesID = (ushort)species;
                uint   formID    = (uint)species >> 0x10;
                string sss       = speciesID + (formID > 0 ? ("_" + formID) : string.Empty) + orientation + (shiny ? "_S" : string.Empty);
                string genderStr = gender == PBEGender.Female && URLExists(path + "PKMN_" + sss + "_F.gif") ? "_F" : string.Empty;
                return(path + "PKMN_" + sss + genderStr + ".gif");
            }
        }
Exemplo n.º 16
0
        public static string GetPokemonSprite(PBESpecies species, bool shiny, PBEGender gender, bool behindSubstitute, bool backSprite)
        {
            string orientation = backSprite ? "_B" : "_F";

            if (behindSubstitute)
            {
                return($"https://raw.githubusercontent.com/Kermalis/PokemonBattleEngine/master/Shared%20Assets/PKMN/STATUS2_Substitute{orientation}.gif");
            }
            else
            {
                uint   speciesID             = (uint)species & 0xFFFF;
                uint   formeID               = (uint)species >> 0x10;
                string sss                   = $"{speciesID}{(formeID > 0 ? $"_{formeID}" : string.Empty)}{orientation}{(shiny ? "_S" : string.Empty)}";
                bool   spriteIsGenderNeutral = URLExists($"https://raw.githubusercontent.com/Kermalis/PokemonBattleEngine/master/Shared%20Assets/PKMN/PKMN_{sss}.gif");
                string genderStr             = spriteIsGenderNeutral ? string.Empty : gender == PBEGender.Female ? "_F" : "_M";
                return($"https://raw.githubusercontent.com/Kermalis/PokemonBattleEngine/master/Shared%20Assets/PKMN/PKMN_{sss}{genderStr}.gif");
            }
        }
Exemplo n.º 17
0
        public static Uri GetPokemonSpriteUri(PBESpecies species, bool shiny, PBEGender gender, bool behindSubstitute, bool backSprite)
        {
            string orientation = backSprite ? "_B" : "_F";

            if (behindSubstitute)
            {
                return(new Uri($"resm:Kermalis.PokemonBattleEngineClient.PKMN.STATUS2_Substitute{orientation}.gif?assembly=PokemonBattleEngineClient"));
            }
            else
            {
                uint   speciesID             = (uint)species & 0xFFFF;
                uint   formeID               = (uint)species >> 0x10;
                string sss                   = $"{speciesID}{(formeID > 0 ? $"_{formeID}" : string.Empty)}{orientation}{(shiny ? "_S" : string.Empty)}";
                bool   spriteIsGenderNeutral = DoesResourceExist($"Kermalis.PokemonBattleEngineClient.PKMN.PKMN_{sss}.gif");
                string genderStr             = spriteIsGenderNeutral ? string.Empty : gender == PBEGender.Female ? "_F" : "_M";
                return(new Uri($"resm:Kermalis.PokemonBattleEngineClient.PKMN.PKMN_{sss}{genderStr}.gif?assembly=PokemonBattleEngineClient"));
            }
        }
Exemplo n.º 18
0
        private unsafe void RenderPkmnInfo(uint *bmpAddress, int bmpWidth, int bmpHeight, float x, float y, bool ally, SpritedBattlePokemon sPkmn)
        {
            Font fontDefault = Font.Default;

            PBEBattlePokemon pkmn = sPkmn.Pkmn;

            fontDefault.DrawString(bmpAddress, bmpWidth, bmpHeight, (int)(bmpWidth * x), (int)(bmpHeight * (y + 0.00f)), pkmn.KnownNickname, Font.DefaultWhite);
            string prefix = ally ? pkmn.HP.ToString() + "/" + pkmn.MaxHP.ToString() + " - " : string.Empty;

            fontDefault.DrawString(bmpAddress, bmpWidth, bmpHeight, (int)(bmpWidth * x), (int)(bmpHeight * (y + 0.06f)), prefix + pkmn.HPPercentage.ToString("P2"), Font.DefaultWhite);
            fontDefault.DrawString(bmpAddress, bmpWidth, bmpHeight, (int)(bmpWidth * x), (int)(bmpHeight * (y + 0.12f)), "Level " + pkmn.Level.ToString(), Font.DefaultWhite);
            fontDefault.DrawString(bmpAddress, bmpWidth, bmpHeight, (int)(bmpWidth * x), (int)(bmpHeight * (y + 0.18f)), "Status: " + pkmn.Status1.ToString(), Font.DefaultWhite);
            PBEGender gender = pkmn.KnownGender;

            if (gender != PBEGender.Genderless)
            {
                fontDefault.DrawString(bmpAddress, bmpWidth, bmpHeight, (int)(bmpWidth * x), (int)(bmpHeight * (y + 0.24f)), gender.ToSymbol(), gender == PBEGender.Male ? Font.DefaultMale : Font.DefaultFemale);
            }
        }
Exemplo n.º 19
0
        private unsafe void DrawBackground(uint *bmpAddress, int bmpWidth, int bmpHeight)
        {
            RenderUtils.OverwriteRectangle(bmpAddress, bmpWidth, bmpHeight, _color);
            // Shadow
            RenderUtils.FillEllipse_Points(bmpAddress, bmpWidth, bmpHeight, 3, 34, 29, 39, RenderUtils.Color(0, 0, 0, 100));
            // Nickname
            PartyPokemon p = _usePartyPkmn ? _partyPkmn : _battlePkmn.PartyPkmn;

            Font.DefaultSmall.DrawString(bmpAddress, bmpWidth, bmpHeight, 2, 3, p.Nickname, Font.DefaultWhite_I);
            if (p.IsEgg)
            {
                return;
            }
            PBEBattlePokemon bPkmn = _usePartyPkmn ? null : _battlePkmn.Pkmn;
            // Gender
            PBEGender gender = p.Gender;

            if (gender != PBEGender.Genderless)
            {
                Font.Default.DrawString(bmpAddress, bmpWidth, bmpHeight, 61, -2, gender.ToSymbol(), gender == PBEGender.Male ? Font.DefaultBlue_O : Font.DefaultRed_O);
            }
            // Level
            const int lvX = 72;

            Font.PartyNumbers.DrawString(bmpAddress, bmpWidth, bmpHeight, lvX, 3, "[LV]", Font.DefaultWhite_I);
            Font.PartyNumbers.DrawString(bmpAddress, bmpWidth, bmpHeight, lvX + 12, 3, (_usePartyPkmn ? p.Level : bPkmn.Level).ToString(), Font.DefaultWhite_I);
            // Status
            PBEStatus1 status = _usePartyPkmn ? p.Status1 : bPkmn.Status1;

            if (status != PBEStatus1.None)
            {
                Font.DefaultSmall.DrawString(bmpAddress, bmpWidth, bmpHeight, 61, 13, status.ToString(), Font.DefaultWhite_I);
            }
            // Item
            ItemType item = _usePartyPkmn ? p.Item : (ItemType)bPkmn.Item;

            if (item != ItemType.None)
            {
                Font.DefaultSmall.DrawString(bmpAddress, bmpWidth, bmpHeight, 61, 23, ItemData.GetItemName(item), Font.DefaultWhite_I);
            }
        }
Exemplo n.º 20
0
        public static ImageSource GetPokemonSprite(PBESpecies species, bool shiny, PBEGender gender, bool behindSubstitute, bool backSprite, out short width, out short height)
        {
            string resource;
            string orientation = backSprite ? "_B" : "_F";

            if (behindSubstitute)
            {
                resource = $"Kermalis.PokemonBattleEngineMobile.PKMN.STATUS2_Substitute{orientation}.gif";
            }
            else
            {
                uint   speciesID             = (uint)species & 0xFFFF;
                uint   formeID               = (uint)species >> 0x10;
                string sss                   = $"{speciesID}{(formeID > 0 ? $"_{formeID}" : string.Empty)}{orientation}{(shiny ? "_S" : string.Empty)}";
                bool   spriteIsGenderNeutral = DoesResourceExist($"Kermalis.PokemonBattleEngineMobile.PKMN.PKMN_{sss}.gif");
                string genderStr             = spriteIsGenderNeutral ? string.Empty : gender == PBEGender.Female ? "_F" : "_M";
                resource = $"Kermalis.PokemonBattleEngineMobile.PKMN.PKMN_{sss}{genderStr}.gif";
            }
            GetGifResourceWidthAndHeight(resource, out width, out height);
            return(ImageSource.FromResource(resource));
        }
Exemplo n.º 21
0
 public abstract IPBEReadOnlyLocalizedString GetGenderName(PBEGender gender);
Exemplo n.º 22
0
 public Entry(PBESpecies species, PBEForm form, PBEGender gender)
 {
     Species = species;
     Form    = form;
     Gender  = gender;
 }
Exemplo n.º 23
0
 private static PBEGender GetGenderKey(PBESpecies species, PBEGender gender)
 {
     return(PokemonImageUtils.HasFemaleVersion(species, false) ? gender : PBEGender.MAX);
 }
Exemplo n.º 24
0
 public virtual IPBELocalizedString GetGenderName(PBEGender gender)
 {
     return(PBELocalizedString.GetGenderName(gender));
 }
Exemplo n.º 25
0
 public static bool IsOppositeGender(this PBEGender gender, PBEGender otherGender)
 {
     return(gender != PBEGender.Genderless && otherGender != PBEGender.Genderless && gender != otherGender);
 }
Exemplo n.º 26
0
 public static BoxPokemon CreateDaycareEgg(PBESpecies species, PBEForm form, PBEGender gender, byte cycles, byte level, uint exp, bool shiny,
                                           PBENature nature, (AbilityType Type, PBEAbility Abil) ability, IVs ivs, BoxMoveset moves)
Exemplo n.º 27
0
        public static string GetPokemonSprite(PBESpecies species, PBEForm form, bool shiny, PBEGender gender, bool behindSubstitute, bool backSprite)
        {
            string orientation = backSprite ? "_B" : "_F";

            if (behindSubstitute)
            {
                return(ImageURL + "STATUS2_Substitute" + orientation + ".gif");
            }
            else
            {
                string speciesStr = PBEDataUtils.GetNameOfForm(species, form) ?? species.ToString();
                string genderStr  = gender == PBEGender.Female && HasFemaleSprite(species) ? "_F" : string.Empty;
                return(ImageURL + "PKMN_" + speciesStr + orientation + (shiny ? "_S" : string.Empty) + genderStr + ".gif");
            }
        }
Exemplo n.º 28
0
 public static string ToSymbol(this PBEGender gender)
 {
     return(gender == PBEGender.Female ? "♀" : gender == PBEGender.Male ? "♂" : string.Empty);
 }