예제 #1
0
        public static string ThrowBall(Ball ball, Pokemon pokemon, int tries)
        {
            ball.count--;
            PokeData.WriteBalls(Balls);

            int number = rand.Next(1, 10 * pokemon.rarity);

            if (Ran(pokemon, tries))
            {
                return("ran");
            }
            else if (number % ball.power == 0)
            {
                PokedexEntry entry = GeneratePokedexEntry(pokemon);
                UpdatePokedex(entry);
                return("caught");
            }
            else if (number % ball.power != 0)
            {
                return("broke");
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        private (double Points, PokeData PokeData) MatchOrder(PokeData targetPoke, PokeData choicePoke)
        {
            var points = CalculateDamageMultiplicator(choicePoke, targetPoke);

            points -= CalculateDamageMultiplicator(targetPoke, choicePoke);

            return(points, choicePoke);
        }
 public PokeSystem()
 {
     InitializeComponent();
     P_pokeSystem = new PokeData();
     pictureBox_one_init.Image = P_pokeSystem.P_pokeImage[0];
     init_PBGroup_poke();
     init_PBGroup_code();
     init_52Poke();
 }
예제 #4
0
        private double CalculateDamageMultiplicator(PokeData sourcePoke, PokeData targetPoke)
        {
            var damage = Types.TypeMatrix[(int)sourcePoke.PokeMoveType - 1, (int)targetPoke.Values.type1 - 1];

            // vs type 2
            if (targetPoke.Values.type2.HasValue)
            {
                damage *= Types.TypeMatrix[(int)sourcePoke.PokeMoveType - 1, (int)targetPoke.Values.type2 - 1];
            }

            return(damage);
        }
예제 #5
0
        async Task PullData() {
            if (loadingData && await HasInternet()) {
                PokeData.NationalDex = await PokeData.GetPokedexList();
                await App.CaughtDatabaseInstance.PopulateDatabase(false);

                FullDex = new PokedexPage();
                CaughtDex = new PokedexPage(true);
                MissingDex = new PokedexPage(false);

                pullingData.IsRunning = false;
                loadingData = false;
            }
        }
예제 #6
0
        public PokeString(string chars, int size)
        {
            m_PokeChars = new ushort[size];

            for (int i = 0; i < chars.Length && i < size; i++)
            {
                m_PokeChars[i] = PokeData.FindPokeChar(chars[i]);
            }

            if (chars.Length < size)
            {
                m_PokeChars[chars.Length] = 0xFFFF;                 //ushort terminator
            }
        }
예제 #7
0
 async void Handle_Appearing(object sender, System.EventArgs e) {
     await PullData();
     if (!loadingData) {
         if (PokeData.AllCaught()) {
             catchButton.IsEnabled = true;
             releaseButton.IsEnabled = false;
         } else if (PokeData.AllMissing()) {
             releaseButton.IsEnabled = true;
             catchButton.IsEnabled = false;
         } else {
             catchButton.IsEnabled = true;
             releaseButton.IsEnabled = true;
         }
     }
 }
예제 #8
0
        private void X(StringBuilder text, GamePokeCreateTextRequest request)
        {
            var choice = request.Game;


            var pokeNames  = EventBot.Models.GoMap.Helper.PokeNames;
            var values     = this.getPokeBaseValuesQuery.Execute(new GetPokeBaseValuesRequest());
            var targetPoke = new PokeData {
                PokeMoveType = (ElementType)request.Game.TargetPokeMoveTyp, Values = values[request.Game.TargetPokeId]
            };
            var pokes = new PokeData[]
            {
                new PokeData {
                    PokeId = choice.Choice1PokeId, Name = pokeNames[choice.Choice1PokeId], PokeMoveType = (ElementType)choice.Choice1PokeMoveTyp, Values = values[choice.Choice1PokeId]
                },
                new PokeData {
                    PokeId = choice.Choice2PokeId, Name = pokeNames[choice.Choice2PokeId], PokeMoveType = (ElementType)choice.Choice2PokeMoveTyp, Values = values[choice.Choice2PokeId]
                },
                new PokeData {
                    PokeId = choice.Choice3PokeId, Name = pokeNames[choice.Choice3PokeId], PokeMoveType = (ElementType)choice.Choice3PokeMoveTyp, Values = values[choice.Choice3PokeId]
                },
                new PokeData {
                    PokeId = choice.Choice4PokeId, Name = pokeNames[choice.Choice4PokeId], PokeMoveType = (ElementType)choice.Choice4PokeMoveTyp, Values = values[choice.Choice4PokeId]
                },
            };

            var y       = pokes.Select(x => MatchOrder(targetPoke, x));
            var grouped = y.GroupBy(x => x.Points, x => x.PokeData).OrderByDescending(x => x.Key);

            foreach (var result in grouped)
            {
                text.AppendLine(PointsAsIcon(result.Key) + " (" + result.Key.ToString("0.000") + ")");
                foreach (var poke in result.OrderBy(x => x.Name))
                {
                    var textType = " (" + Translate(poke.Values.type1) + (poke.Values.type2 == null ? "" : ", " + Translate(poke.Values.type2.Value)) + ")";
                    text.AppendLine(" " + poke.Name + textType);
                }

                var currentPokes = result.Select(x => x.PokeId).ToArray();

                var orderedVotes = request.Votes.Where(x => currentPokes.Contains(x.Choice)).OrderBy(x => x.Created);
                foreach (var vote in orderedVotes)
                {
                    text.AppendLine("  " + vote.UserName);
                }
            }
        }
예제 #9
0
    static void SetPokeImagesFromFolder()
    {
        try
        {
            PokeData pokeData = (PokeData)AssetDatabase.LoadAssetAtPath(PokeDataObjPath, typeof(PokeData));

            for (int i = 0; i < pokeData.PokeInfos.Length; i++)
            {
                pokeData.PokeInfos[i].Image = (Sprite)AssetDatabase.LoadAssetAtPath(PokeImagesPath + i.ToString() + ".png", typeof(Sprite));
            }

            Debug.Log("Setting poke images from folder completed!");
        }
        catch (Exception)
        {
            Debug.LogError("Error while setting Pokes from folder");
            throw;
        }
    }
예제 #10
0
        void SetBadges()
        {
            string types = pokemon.Types[0].Type.Name;

            if (pokemon.Types.Count == 2)
            {
                types           = types + "," + pokemon.Types[1].Type.Name;
                Type2.IsEnabled = true;
            }
            string[] badges = PokeData.GetTypeBadge(types).Split(',');
            Type1.Source = badges[0];
            if (badges.Count() == 2)
            {
                Type1.Source = badges[1];
                Type2.Source = badges[0];
            }
            else
            {
                Type1.Source = badges[0];
            }
        }
예제 #11
0
        private async Task PullPokemonDetails()
        {
            pkmSprite.Source = dexEntry.Sprite;
            if (!pulledPreviously && await HasInternet())
            {
                pokemon = await PokeData.GetPokemon(dexEntry.DexNum);

                string type1 = pokemon.Types[0].Type.Name;

                var gamesCatchable = pokemon.GamesCatchable;
                gamesCatchable.Add("All Games");
                gamesCatchable.Sort();

                GameFilter.ItemsSource   = gamesCatchable;
                LocationList.ItemsSource = pokemon.Routes;
                pulledPreviously         = true;


                SetBadges();
            }
        }
예제 #12
0
        async Task SetAllCaughtStatus(bool caught)
        {
            string caughtString = caught.ToString().ToUpper();

            var changeSelected = await DisplayAlert("Are you sure?",
                                                    youAreAbout + caughtString + noUndo,
                                                    "Change",
                                                    "Cancel");

            if (changeSelected)
            {
                loading.IsRunning = true;
                await App.CaughtDatabaseInstance.PopulateDatabase(caught, true);

                loading.IsRunning = false;
                await DisplayAlert("Changed!", statusSet + caughtString, "Okay");

                checkAllCaught  = PokeData.AllCaught();
                checkAllMissing = PokeData.AllMissing();
            }
        }
예제 #13
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            for (int i = 0; i < m_PokeChars.Length; i++)
            {
                if (IsTerminatedAt(i))
                {
                    break;
                }
                else
                {
                    //Console.WriteLine( "Char: {0:X}", m_PokeChars[i] );
                    if (m_PokeChars[i] > 0)
                    {
                        builder.Append((char)PokeData.FindUniChar(m_PokeChars[i]));
                    }
                }
            }

            return(builder.ToString());
        }
예제 #14
0
 void Handle_Appearing(object sender, System.EventArgs e)
 {
     if (PokeData.AllCaught())
     {
         catchButton.IsEnabled = false;
         releaseButton.Text    = "Release 'em All";
         catchButton.Text      = "You got 'em all!";
     }
     else if (PokeData.AllMissing())
     {
         releaseButton.IsEnabled = false;
         catchButton.Text        = "Catch 'em All";
         releaseButton.Text      = "Better catch 'em all!";
     }
     else
     {
         catchButton.IsEnabled   = true;
         releaseButton.IsEnabled = true;
         releaseButton.Text      = "Release 'em All";
         catchButton.Text        = "Catch 'em All";
     }
 }
예제 #15
0
    static void LoadPokeImagesFromJson()
    {
        try
        {
            PokeData pokeData = (PokeData)AssetDatabase.LoadAssetAtPath(PokeDataObjPath, typeof(PokeData));

            TextAsset    pokemonsJsonString = (TextAsset)AssetDatabase.LoadAssetAtPath(JsonPath + PokemonsJsonName, typeof(TextAsset));
            PokeDataJson pokeDataJson       = JsonUtility.FromJson <PokeDataJson>(pokemonsJsonString.text);

            for (int i = 0; i < pokeDataJson.Pokemons.Length; i++)
            {
                string imgUrl   = pokeDataJson.Pokemons[i].ImageURL;
                string filePath = PokeImagesFullPath + i.ToString() + ".png";

                if (File.Exists(filePath))
                {
                    continue;
                }

                File.WriteAllBytes(filePath, LoadImageBytesFromUrl(imgUrl));
            }

            AssetDatabase.Refresh();

            for (int i = 0; i < pokeData.PokeInfos.Length; i++)
            {
                pokeData.PokeInfos[i].Image = (Sprite)AssetDatabase.LoadAssetAtPath(PokeImagesPath + i.ToString() + ".png", typeof(Sprite));
            }

            EditorUtility.SetDirty(pokeData);
            Debug.Log("Loading images complete!");
        }
        catch (Exception)
        {
            Debug.LogError("Error while loading data from json");
            throw;
        }
    }
예제 #16
0
 private static bool UpdatePokedex(PokedexEntry pokedex_entry)
 {
     Pokedex.Add(pokedex_entry);
     return(PokeData.WritePokedex(Pokedex) ? true : false);
 }
예제 #17
0
    static void LoadPokeInfoFromJson()
    {
        try
        {
            PokeData pokeData = (PokeData)AssetDatabase.LoadAssetAtPath(PokeDataObjPath, typeof(PokeData));

            #region Fill Type Chart
            TextAsset typeChartJsonString = (TextAsset)AssetDatabase.LoadAssetAtPath(JsonPath + TypeChartJsonName, typeof(TextAsset));

            PokeTypeChartJson typeChartJson = JsonUtility.FromJson <PokeTypeChartJson>(typeChartJsonString.text);
            TypeChart         typeChart     = pokeData.TypeChart = new TypeChart(typeChartJson.TypeChart.Length);

            for (int i = 0; i < typeChart.TypeParameters.Length; i++)
            {
                TypeParameter typeParam = typeChart.TypeParameters[i] = new TypeParameter();

                typeParam.BaseType = (PokeType)Enum.Parse(typeof(PokeType), typeChartJson.TypeChart[i].Type);

                if (!string.IsNullOrEmpty(typeChartJson.TypeChart[i].Strenghts))
                {
                    string[] strenghtsString = typeChartJson.TypeChart[i].Strenghts.Split(new[] { ", " }, StringSplitOptions.None);
                    typeParam.StrenghtsTypes = new PokeType[strenghtsString.Length];
                    for (int j = 0; j < typeParam.StrenghtsTypes.Length; j++)
                    {
                        typeParam.StrenghtsTypes[j] = (PokeType)Enum.Parse(typeof(PokeType), strenghtsString[j]);
                    }
                }

                if (!string.IsNullOrEmpty(typeChartJson.TypeChart[i].Weaknesses))
                {
                    string[] weaksString = typeChartJson.TypeChart[i].Weaknesses.Split(new[] { ", " }, StringSplitOptions.None);
                    typeParam.WeaknessesTypes = new PokeType[weaksString.Length];
                    for (int j = 0; j < typeParam.WeaknessesTypes.Length; j++)
                    {
                        typeParam.WeaknessesTypes[j] = (PokeType)Enum.Parse(typeof(PokeType), weaksString[j]);
                    }
                }
            }
            #endregion

            #region Load Primary Moves
            TextAsset            primaryMovesJsonString = (TextAsset)AssetDatabase.LoadAssetAtPath(JsonPath + PrimaryMovesJsonName, typeof(TextAsset));
            PrimaryMovesDataJson primaryMovesDataJson   = JsonUtility.FromJson <PrimaryMovesDataJson>(primaryMovesJsonString.text);

            pokeData.PrimaryMoves = new PrimaryMove[primaryMovesDataJson.PrimaryMoves.Length];
            for (int i = 0; i < primaryMovesDataJson.PrimaryMoves.Length; i++)
            {
                PrimaryMove      primaryMove      = pokeData.PrimaryMoves[i] = new PrimaryMove();
                PrimaryMovesJson primaryMovesJson = primaryMovesDataJson.PrimaryMoves[i];

                primaryMove.Name       = primaryMovesJson.Name;
                primaryMove.Type       = (PokeType)Enum.Parse(typeof(PokeType), primaryMovesJson.Type);
                primaryMove.Attack     = primaryMovesJson.Atk;
                primaryMove.Cooldown   = primaryMovesJson.Cooldown;
                primaryMove.Dps        = primaryMovesJson.DPS;
                primaryMove.EnergyGain = primaryMovesJson.EnergyGain;

                primaryMove.StrongAgaints = pokeData.TypeChart.GetStrenghts(primaryMove.Type);
                primaryMove.WeakAgains    = pokeData.TypeChart.GetWeaknesses(primaryMove.Type);
            }
            #endregion

            #region Load Secondary Moves
            TextAsset secondaryMovesJsonString            = (TextAsset)AssetDatabase.LoadAssetAtPath(JsonPath + SecondaryMovesJsonName, typeof(TextAsset));
            SecondaryMovesDataJson secondaryMovesDataJson = JsonUtility.FromJson <SecondaryMovesDataJson>(secondaryMovesJsonString.text);

            pokeData.SecondaryMoves = new SecondaryMove[secondaryMovesDataJson.SecondaryMoves.Length];
            for (int i = 0; i < secondaryMovesDataJson.SecondaryMoves.Length; i++)
            {
                SecondaryMove      secMove     = pokeData.SecondaryMoves[i] = new SecondaryMove();
                SecondaryMovesJson secMoveJson = secondaryMovesDataJson.SecondaryMoves[i];

                secMove.Name        = secMoveJson.Name;
                secMove.Type        = (PokeType)Enum.Parse(typeof(PokeType), secMoveJson.Type);
                secMove.ChargeCount = Mathf.Clamp(secMoveJson.ChargeCount, 1, 5);
                secMove.Attack      = secMoveJson.Atk;
                secMove.Cooldown    = secMoveJson.Cooldown;
                secMove.Dps         = secMoveJson.DPS;
                secMove.CritChance  = secMoveJson.CritChance;
                secMove.DidgeWindow = secMoveJson.DodgeWindow;

                secMove.StrongAgaints = pokeData.TypeChart.GetStrenghts(secMove.Type);
                secMove.WeakAgains    = pokeData.TypeChart.GetWeaknesses(secMove.Type);
            }
            #endregion

            #region Load Pokemons
            TextAsset    pokemonsJsonString = (TextAsset)AssetDatabase.LoadAssetAtPath(JsonPath + PokemonsJsonName, typeof(TextAsset));
            PokeDataJson pokeDataJson       = JsonUtility.FromJson <PokeDataJson>(pokemonsJsonString.text);

            pokeData.PokeInfos = new PokeInfo[pokeDataJson.Pokemons.Length];
            for (int i = 0; i < pokeDataJson.Pokemons.Length; i++)
            {
                PokeInfo     pokeInfo     = pokeData.PokeInfos[i] = new PokeInfo();
                PokeInfoJson pokeInfoJson = pokeDataJson.Pokemons[i];
                pokeInfoJson.Name = Regex.Replace(pokeInfoJson.Name, @"\p{Z}", "");

                pokeInfo.Name = pokeInfoJson.Name;
                pokeInfo.Id   = i + 1;

                #region Fill Type
                string[] pokeTypesJson = pokeInfoJson.Type.Split(new[] { ", " }, StringSplitOptions.None);
                pokeInfo.Type = new PokeType[pokeTypesJson.Length];

                for (int j = 0; j < pokeTypesJson.Length; j++)
                {
                    pokeTypesJson[j] = pokeTypesJson[j].Replace(" ", string.Empty);
                    pokeInfo.Type[j] = (PokeType)Enum.Parse(typeof(PokeType), pokeTypesJson[j]);
                }
                #endregion

                pokeInfo.Weight         = pokeInfoJson.Weight;
                pokeInfo.Height         = pokeInfoJson.Height;
                pokeInfo.MaxCp          = pokeInfoJson.MaxCp;
                pokeInfo.CpMultiFromEvo = pokeInfoJson.EvoCpMulti;
                pokeInfo.BaseAttack     = pokeInfoJson.BaseAttack;
                pokeInfo.BaseDefense    = pokeInfoJson.BaseDefense;
                pokeInfo.BaseStamina    = pokeInfoJson.BaseStamina;
                pokeInfo.BaseHp         = pokeInfoJson.BaseHP;
                pokeInfo.Rarity         = pokeInfoJson.Rarity;
                pokeInfo.CaptureRate    = pokeInfoJson.CaptureRate;
                pokeInfo.FleeRate       = pokeInfoJson.FleeRate;
                pokeInfo.Class          = (PokeClass)Enum.Parse(typeof(PokeClass), pokeInfoJson.Class);
                pokeInfo.CandyToEvolve  = pokeInfoJson.CandyToEvolve;

                int eggDistance = 0;
                if (int.TryParse(pokeInfoJson.EggDistanceToHatch.Replace("km", string.Empty), out eggDistance))
                {
                    pokeInfo.EggDistanceType = (EggType)eggDistance;
                }

                #region Fill Primary Moves
                string[] primaryMovesString = pokeInfoJson.PossiblePrimaryMoves.Split(new[] { ", " }, StringSplitOptions.None);

                pokeInfo.PrimaryMovesIds = new int[primaryMovesString.Length];
                for (int j = 0; j < pokeInfo.PrimaryMovesIds.Length; j++)
                {
                    pokeInfo.PrimaryMovesIds[j] = pokeData.GetPrimaryMoveId(primaryMovesString[j]);
                }
                #endregion

                #region Fill Secondary Moves
                string[] secondaryMovesString = pokeInfoJson.PossibleSecondaryMoves.Split(new[] { ", " }, StringSplitOptions.None);

                pokeInfo.SecondaryMovesIds = new int[secondaryMovesString.Length];
                for (int j = 0; j < pokeInfo.SecondaryMovesIds.Length; j++)
                {
                    pokeInfo.SecondaryMovesIds[j] = pokeData.GetSecondaryMoveId(secondaryMovesString[j]);
                }
                #endregion

                pokeInfo.Resistance = pokeData.TypeChart.GetResistance(pokeInfo.Type);
                pokeInfo.Weaknesses = pokeData.TypeChart.GetWeaknesses(pokeInfo.Type);
            }

            #region Fill Evo FromTo
            for (int i = 0; i < pokeData.PokeInfos.Length; i++)
            {
                PokeInfo     pokeInfo     = pokeData.PokeInfos[i];
                PokeInfoJson pokeInfoJson = pokeDataJson.Pokemons[i];

                if (!string.IsNullOrEmpty(pokeInfoJson.EvoFrom))
                {
                    pokeInfo.EvoFromId = pokeData.GetPokeInfoIdByName(Regex.Replace(pokeInfoJson.EvoFrom, @"\p{Z}", ""));
                }
                else
                {
                    pokeInfo.EvoFromId = -1;
                }
                if (!string.IsNullOrEmpty(pokeInfoJson.EvoTo))
                {
                    pokeInfo.EvoToId = pokeData.GetPokeInfoIdByName(Regex.Replace(pokeInfoJson.EvoTo, @"\p{Z}", ""));
                }
                else
                {
                    pokeInfo.EvoToId = -1;
                }
            }
            #endregion

            Debug.Log("Loading complete!");
            #endregion

            #region Fill Pokemon stats Rates
            Vector3 maxStatsRates = Vector3.zero; //x-Attack, y-Defense, z-Hp
            for (int i = 0; i < pokeData.PokeInfos.Length; i++)
            {
                PokeInfo pInfo = pokeData.PokeInfos[i];
                if (pInfo.BaseAttack > maxStatsRates.x)
                {
                    maxStatsRates.x = pInfo.BaseAttack;
                }
                if (pInfo.BaseDefense > maxStatsRates.y)
                {
                    maxStatsRates.y = pInfo.BaseDefense;
                }
                if (pInfo.BaseStamina > maxStatsRates.z)
                {
                    maxStatsRates.z = pInfo.BaseStamina;
                }
            }

            for (int i = 0; i < pokeData.PokeInfos.Length; i++)
            {
                PokeInfo pInfo = pokeData.PokeInfos[i];
                pInfo.AttackRate  = (float)pInfo.BaseAttack / maxStatsRates.x;
                pInfo.DefenseRate = (float)pInfo.BaseDefense / maxStatsRates.y;
                pInfo.StaminaRate = (float)pInfo.BaseStamina / maxStatsRates.z;
            }
            #endregion

            #region Fill Move stats Rates
            Vector3 maxMoveRates = Vector3.zero; //x-Attack, y-Cooldown, z-DPS

            //Primary
            for (int i = 0; i < pokeData.PrimaryMoves.Length; i++)
            {
                PrimaryMove move = pokeData.PrimaryMoves[i];
                if (move.Attack > maxMoveRates.x)
                {
                    maxMoveRates.x = move.Attack;
                }
                if (move.Cooldown > maxMoveRates.y)
                {
                    maxMoveRates.y = move.Cooldown;
                }
                if (move.Dps > maxMoveRates.z)
                {
                    maxMoveRates.z = move.Dps;
                }
            }

            for (int i = 0; i < pokeData.PrimaryMoves.Length; i++)
            {
                PrimaryMove move = pokeData.PrimaryMoves[i];
                move.AttackRate   = (float)move.Attack / maxMoveRates.x;
                move.CooldownRate = (float)move.Cooldown / maxMoveRates.y;
                move.DpsRate      = (float)move.Dps / maxMoveRates.z;
            }

            //Secondary
            maxMoveRates = Vector3.zero;
            for (int i = 0; i < pokeData.SecondaryMoves.Length; i++)
            {
                SecondaryMove move = pokeData.SecondaryMoves[i];
                if (move.Attack > maxMoveRates.x)
                {
                    maxMoveRates.x = move.Attack;
                }
                if (move.Cooldown > maxMoveRates.y)
                {
                    maxMoveRates.y = move.Cooldown;
                }
                if (move.Dps > maxMoveRates.z)
                {
                    maxMoveRates.z = move.Dps;
                }
            }

            for (int i = 0; i < pokeData.SecondaryMoves.Length; i++)
            {
                SecondaryMove move = pokeData.SecondaryMoves[i];
                move.AttackRate   = (float)move.Attack / maxMoveRates.x;
                move.CooldownRate = (float)move.Cooldown / maxMoveRates.y;
                move.DpsRate      = (float)move.Dps / maxMoveRates.z;
            }
            #endregion

            EditorUtility.SetDirty(pokeData);
            Debug.Log("Loading Poke info complete!");
        }
        catch (Exception)
        {
            Debug.LogError("Error while loading data from json");
            throw;
        }
    }