Example #1
0
        public void LoadBalls(PKM pkm)
        {
            var legal = BallApplicator.GetLegalBalls(pkm).ToArray();
            var poss  = ((Ball[])Enum.GetValues(typeof(Ball))).Skip(1)
                        .TakeWhile(z => (int)z <= pkm.MaxBallID).ToArray();
            var names = GameInfo.BallDataSource;

            LoadBalls(poss, legal, names);
        }
Example #2
0
        public async Task EggRollAsync()
        {
            if (!Info.Hub.Config.Trade.EggRollChannels.Contains(Context.Channel.Id.ToString()) && !Info.Hub.Config.Trade.EggRollChannels.Equals(""))
            {
                await ReplyAsync($"You're typing the command in the wrong channel!").ConfigureAwait(false);

                return;
            }

            if (Info.Hub.Config.Trade.EggRollCooldown < 0)
            {
                Info.Hub.Config.Trade.EggRollCooldown = default;
            }

            var id   = Context.User.Id.ToString();
            var line = TradeExtensions.EggRollCooldown.FirstOrDefault(z => z.Contains(id));

            System.DateTime.TryParse(line != null ? line.Split(',')[1] : string.Empty, out System.DateTime time);
            var timer         = time.AddHours(Info.Hub.Config.Trade.EggRollCooldown);
            var timeRemaining = timer - System.DateTime.Now;

            if (System.DateTime.Now < timer)
            {
                await ReplyAsync($"{Context.User.Mention}, please try again in {timeRemaining.Hours:N0}h : {timeRemaining.Minutes:N0}m : {timeRemaining.Seconds:N0}s!").ConfigureAwait(false);

                return;
            }

            var code       = Info.GetRandomTradeCode();
            var rng        = new System.Random();
            int shinyRng   = rng.Next(0, TradeExtensions.shinyOdds.Length);
            int abilityRng = rng.Next(0, TradeExtensions.abilityIndex.Length);
            var set        = new ShowdownSet($"Egg({SpeciesName.GetSpeciesName((int)TradeExtensions.validEgg.GetValue(rng.Next(0, TradeExtensions.validEgg.Length)), 2)})");
            var template   = AutoLegalityWrapper.GetTemplate(set);
            var sav        = AutoLegalityWrapper.GetTrainerInfo(8);
            var pkm        = (PK8)sav.GetLegal(template, out _);

            if (TradeExtensions.regional.ToList().Contains(pkm.Species))
            {
                int formRng  = rng.Next(0, TradeExtensions.formIndex1.Length);
                int formRng2 = rng.Next(0, TradeExtensions.formIndex2.Length);

                if (pkm.Species != 52)
                {
                    pkm.SetAltForm(TradeExtensions.formIndex1[formRng]);
                }
                else
                {
                    pkm.SetAltForm(TradeExtensions.formIndex2[formRng2]);
                }

                if (pkm.AltForm != 0)
                {
                    switch (pkm.Species)
                    {
                    case 27: pkm.RelearnMove3 = 10; break;

                    case 37: pkm.RelearnMove4 = 39; break;

                    case 52: pkm.RelearnMove2 = 252; pkm.RelearnMove3 = 45; break;

                    case 83: pkm.RelearnMove1 = 64; pkm.RelearnMove4 = 28; break;

                    case 222: pkm.RelearnMove1 = 33; break;

                    case 263: pkm.RelearnMove2 = 43; pkm.RelearnMove3 = 0; pkm.RelearnMove4 = 0; break;
                    }
                    ;
                }
            }

            TradeExtensions.EggTrade(pkm);
            pkm.Nature     = rng.Next(0, 24);
            pkm.StatNature = pkm.Nature;
            pkm.SetAbilityIndex(TradeExtensions.abilityIndex[abilityRng]);
            pkm.IVs = pkm.SetRandomIVs(3);
            BallApplicator.ApplyBallLegalRandom(pkm);

            switch (TradeExtensions.shinyOdds[shinyRng])
            {
            case 3: CommonEdits.SetShiny(pkm, Shiny.Never); pkm.SetUnshiny(); break;

            case 5: CommonEdits.SetShiny(pkm, Shiny.AlwaysStar); break;

            case 6: CommonEdits.SetShiny(pkm, Shiny.AlwaysSquare); break;
            }
            ;

            var la      = new LegalityAnalysis(pkm);
            var spec    = GameInfo.Strings.Species[template.Species];
            var invalid = !(pkm is PK8) || (!la.Valid && SysCordInstance.Self.Hub.Config.Legality.VerifyLegality);

            if (invalid)
            {
                var imsg = $"Oops! I scrambled your egg! Don't tell Ramsay! Here's my best attempt for that {spec}!";
                await Context.Channel.SendPKMAsync(pkm, imsg).ConfigureAwait(false);

                return;
            }

            pkm.ResetPartyStats();
            var sudo = Context.User.GetIsSudo();
            await Context.AddToQueueAsync(code, Context.User.Username, sudo, pkm, PokeRoutineType.EggRoll, PokeTradeType.EggRoll).ConfigureAwait(false);
        }
Example #3
0
 /// <summary>
 /// Set matching colored pokeballs based on the color API in personal table
 /// </summary>
 /// <param name="pk">Return PKM</param>
 public static void SetMatchingBall(this PKM pk) => BallApplicator.ApplyBallLegalByColor(pk);
Example #4
0
        public async Task EggRaffleAsync()
        {
            if (!Info.Hub.Config.Trade.EggRaffle)
            {
                await ReplyAsync($"EggRaffle is currently disabled!").ConfigureAwait(false);

                return;
            }
            else if (!Info.Hub.Config.Trade.EggRaffleChannels.Contains(Context.Channel.Id.ToString()) && !Info.Hub.Config.Trade.EggRaffleChannels.Equals(""))
            {
                await ReplyAsync($"You're typing the command in the wrong channel!").ConfigureAwait(false);

                return;
            }

            if (Info.Hub.Config.Trade.EggRaffleCooldown < 0)
            {
                Info.Hub.Config.Trade.EggRaffleCooldown = default;
            }

            if (!System.IO.File.Exists("EggRngBlacklist.txt"))
            {
                System.IO.File.Create("EggRngBlacklist.txt").Close();
            }

            System.IO.StreamReader reader = new System.IO.StreamReader("EggRngBlacklist.txt");
            var content = reader.ReadToEnd();

            reader.Close();

            var id    = $"{Context.Message.Author.Id}";
            var parse = System.Text.RegularExpressions.Regex.Match(content, @"(" + id + @") - (\S*\ \S*\ \w*)", System.Text.RegularExpressions.RegexOptions.Multiline);

            if (content.Contains($"{Context.Message.Author.Id}"))
            {
                var timer         = System.DateTime.Parse(parse.Groups[2].Value).AddHours(Info.Hub.Config.Trade.EggRaffleCooldown);
                var timeremaining = timer - System.DateTime.Now;
                if (System.DateTime.Now >= timer)
                {
                    content = content.Replace(parse.Groups[0].Value, $"{id} - {System.DateTime.Now}").TrimEnd();
                    System.IO.StreamWriter writer = new System.IO.StreamWriter("EggRngBlacklist.txt");
                    writer.WriteLine(content);
                    writer.Close();
                }
                else
                {
                    await ReplyAsync($"{Context.User.Mention}, please try again in {timeremaining.Hours:N0}h : {timeremaining.Minutes:N0}m : {timeremaining.Seconds:N0}s!").ConfigureAwait(false);

                    return;
                }
            }
            else
            {
                System.IO.File.AppendAllText("EggRngBlacklist.txt", $"{Context.Message.Author.Id} - {System.DateTime.Now}{System.Environment.NewLine}");
            }

            var code = Info.GetRandomTradeCode();

            int[] validEgg = { 1,     4,   7,  10,  27,  37,  43,  50,  52,  54,  58,  60,  63,  66,  72,
                               77,   79,  81,  83,  90,  92,  95,  98, 102, 104, 108, 109, 111, 114, 115,
                               116, 118, 120, 122, 123, 127, 128, 129, 131, 133, 137, 163, 170, 172, 173,
                               174, 175, 177, 194, 206, 211, 213, 214, 215, 220, 222, 223, 225, 227, 236,
                               241, 246, 263, 270, 273, 278, 280, 290, 293, 298, 302, 303, 309, 318, 320,
                               324, 328, 337, 338, 339, 341, 343, 349, 355, 360, 361, 403, 406, 415, 420,
                               422, 425, 427, 434, 436, 438, 439, 440, 446, 447, 449, 451, 453, 458, 459,
                               479, 506, 509, 517, 519, 524, 527, 529, 532, 535, 538, 539, 543, 546, 548,
                               550, 551, 554, 556, 557, 559, 561, 562, 568, 570, 572, 574, 577, 582, 587,
                               588, 590, 592, 595, 597, 599, 605, 606, 607, 610, 613, 616, 618, 619, 621,
                               622, 624, 626, 627, 629, 631, 632, 633, 636, 659, 661, 674, 677, 679, 682,
                               684, 686, 688, 690, 692, 694, 701, 702, 704, 707, 708, 710, 712, 714, 722,
                               725, 728, 736, 742, 744, 746, 747, 749, 751, 753, 755, 757, 759, 761, 764,
                               765, 766, 767, 769, 771, 776, 777, 778, 780, 781, 782, 810, 813, 816, 819,
                               821, 824, 827, 829, 831, 833, 835, 837, 840, 843, 845, 846, 848, 850, 852,
                               854, 856, 859, 868, 870, 871, 872, 874, 875, 876, 877, 878, 884, 885 };

            int[] regional = { 27, 37, 50, 52, 77, 79, 83, 122, 222, 263, 554, 562, 618 };

            int[] shinyOdds = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
                                3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
                                3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
                                5, 5, 5, 5, 5, 5, 5, 6, 6, 6 };

            int[] abilityIndex = { 0, 1, 2 };
            int[] formIndex1   = { 0, 1 };
            int[] formIndex2   = { 0, 1, 2 };

            var rng        = new System.Random();
            int shinyRng   = rng.Next(0, shinyOdds.Length);
            int abilityRng = rng.Next(0, abilityIndex.Length);
            var set        = new ShowdownSet($"Egg({SpeciesName.GetSpeciesName(rng.Next(new Zukan8Index(Zukan8Type.None, 1).Index, GameUtil.GetMaxSpeciesID(GameVersion.SWSH)), 2)})");

            while (!validEgg.ToList().Contains(set.Species))
            {
                set = new ShowdownSet($"Egg({SpeciesName.GetSpeciesName(rng.Next(new Zukan8Index(Zukan8Type.None, 1).Index, GameUtil.GetMaxSpeciesID(GameVersion.SWSH)), 2)})");
            }

            var template = AutoLegalityWrapper.GetTemplate(set);
            var sav      = AutoLegalityWrapper.GetTrainerInfo(8);
            var pkm      = (PK8)sav.GetLegal(template, out _);

            if (regional.ToList().Contains(pkm.Species))
            {
                int formRng  = rng.Next(0, formIndex1.Length);
                int formRng2 = rng.Next(0, formIndex2.Length);

                if (pkm.Species != 52)
                {
                    pkm.SetAltForm(formIndex1[formRng]);
                }
                else
                {
                    pkm.SetAltForm(formIndex2[formRng2]);
                }

                if (pkm.AltForm != 0)
                {
                    if (pkm.Species == 27)
                    {
                        pkm.RelearnMove3 = 10;
                    }
                    else if (pkm.Species == 37)
                    {
                        pkm.RelearnMove4 = 39;
                    }
                    else if (pkm.Species == 52)
                    {
                        pkm.RelearnMove2 = 252;
                        pkm.RelearnMove3 = 45;
                    }
                    else if (pkm.Species == 83)
                    {
                        pkm.RelearnMove1 = 64;
                        pkm.RelearnMove4 = 28;
                    }
                    else if (pkm.Species == 222)
                    {
                        pkm.RelearnMove1 = 33;
                    }
                    else if (pkm.Species == 263)
                    {
                        pkm.RelearnMove2 = 43;
                        pkm.RelearnMove3 = 0;
                        pkm.RelearnMove4 = 0;
                    }
                }
            }

            EggTrade(pkm);
            pkm.Nature     = rng.Next(0, 24);
            pkm.StatNature = pkm.Nature;
            pkm.SetAbilityIndex(abilityIndex[abilityRng]);
            pkm.IVs = pkm.SetRandomIVs(3);
            BallApplicator.ApplyBallLegalRandom(pkm);

            if (shinyOdds[shinyRng] == 3)
            {
                CommonEdits.SetShiny(pkm, Shiny.Never);
                pkm.SetUnshiny();
            }
            else if (shinyOdds[shinyRng] == 5)
            {
                CommonEdits.SetShiny(pkm, Shiny.AlwaysStar);
            }
            else
            {
                CommonEdits.SetShiny(pkm, Shiny.AlwaysSquare);
            }

            var la      = new LegalityAnalysis(pkm);
            var spec    = GameInfo.Strings.Species[template.Species];
            var invalid = !(pkm is PK8) || (!la.Valid && SysCordInstance.Self.Hub.Config.Legality.VerifyLegality);

            if (invalid)
            {
                var imsg = $"Oops! I scrambled your egg! Don't tell Ramsay! Here's my best attempt for that {spec}!";
                await Context.Channel.SendPKMAsync(pkm, imsg).ConfigureAwait(false);

                return;
            }

            pkm.ResetPartyStats();
            var sudo = Context.User.GetIsSudo();

            await AddTradeToQueueAsync(code, Context.User.Username, pkm, sudo).ConfigureAwait(false);
        }