예제 #1
0
        private async Task HandleCommandAsync(SocketMessage s)
        {
            if (s is not SocketUserMessage msg)
            {
                return;
            }

            var context = new SocketCommandContext(_client, msg);

            if (context.User.IsBot)
            {
                return;
            }

            var argPos = 0;

            if (msg.HasStringPrefix(Config.Bot.CmdPrefix, ref argPos, StringComparison.InvariantCultureIgnoreCase) ||
                msg.HasMentionPrefix(_client.CurrentUser, ref argPos))
            {
                var result = await _service.ExecuteAsync(context, argPos, null);

                if (!result.IsSuccess && result.Error != CommandError.UnknownCommand)
                {
                    if (result is ExecuteResult execResult)
                    {
                        Console.WriteLine(execResult.Exception);
                    }
                    Console.WriteLine(result.ErrorReason);
                }

                _ = ServerGames.UserSentCommand(context.User, context.Channel);
            }
        }
예제 #2
0
        public async Task ClassInfo([Remainder] string name = "")
        {
            if (name == "")
            {
                return;
            }

            if (AdeptClassSeriesManager.TryGetClassSeries(name, out AdeptClassSeries series))
            {
                AdeptClass adeptClass = series.Classes.Where(c => c.Name.ToUpper() == name.ToUpper()).FirstOrDefault();
                var        embed      = new EmbedBuilder();
                embed.WithAuthor($"{adeptClass.Name} - {series.Archtype}");
                embed.WithColor(Colors.Get(series.Elements.Select(s => s.ToString()).ToArray()));
                var relevantMoves = AdeptClassSeriesManager.GetMoveset(adeptClass).Where(m => m is Psynergy).ToList().ConvertAll(m => (Psynergy)m).ConvertAll(p => $"{p.Emote} {p.Name} `{p.PPCost}`");
                embed.AddField("Description", series.Description ?? "-");
                embed.AddField("Stats", adeptClass.StatMultipliers, true);
                embed.AddField("Elemental Stats", series.Elstats.ToString(), true);
                embed.AddField("Movepool", string.Join(" - ", relevantMoves));
                embed.AddField($"Other Classes in {series.Name}", string.Join(", ", series.Classes.Select(s => s.Name)), true);
                embed.AddField("Elements", string.Join(", ", series.Elements.Select(e => e.ToString())), true);
                await Context.Channel.SendMessageAsync("", false, embed.Build());

                if (Context.User is SocketGuildUser sgu)
                {
                    _ = ServerGames.UserLookedUpClass(sgu, (SocketTextChannel)Context.Channel);
                }
            }
            else
            {
                return;
            }
        }
예제 #3
0
        private async Task HandleCommandAsync(SocketMessage s)
        {
            if (!(s is SocketUserMessage msg))
            {
                return;
            }

            var context = new SocketCommandContext(client, msg);

            if (context.User.IsBot)
            {
                return;
            }

            int argPos = 0;

            if (msg.HasStringPrefix(Config.bot.cmdPrefix, ref argPos, StringComparison.InvariantCultureIgnoreCase) || msg.HasMentionPrefix(client.CurrentUser, ref argPos))
            {
                var result = await service.ExecuteAsync(context, argPos, null);

                if (!result.IsSuccess && result.Error != CommandError.UnknownCommand)
                {
                    Console.WriteLine(result.ErrorReason);
                }

                await ServerGames.UserSentCommand((SocketGuildUser)context.User, (SocketTextChannel)context.Channel);
            }
        }
예제 #4
0
파일: Quotes.cs 프로젝트: dom426/IodemBot
        public async Task RandomQuote()
        {
            if (GetQuotesCount() == 0)
            {
                await NoQuotes();

                return;
            }

            var embed = new EmbedBuilder();

            embed.WithColor(Colors.Get("Iodem"));
            QuoteStruct q = quoteList[(new Random()).Next(0, quoteList.Count)];

            q.name = Utilities.ToCaps(q.name);
            embed.WithAuthor(q.name);
            embed.WithThumbnailUrl(Sprites.GetImageFromName(q.name));
            embed.WithDescription(q.quote);
            if (q.quote.Contains(@"#^@%!"))
            {
                var userAccount = UserAccounts.GetAccount(Context.User);
                userAccount.ServerStats.HasQuotedMatthew = true;
                UserAccounts.SaveAccounts();
                await ServerGames.UserHasCursed((SocketGuildUser)Context.User, (SocketTextChannel)Context.Channel);
            }

            await Context.Channel.SendMessageAsync("", false, embed.Build());

            //await embed.WithDescription(Utilities.GetAlert("quote"));
        }
예제 #5
0
        private void InsertGame(GameInfo gameInfo)
        {
            var gameName = gameInfo.GameName;
            var length   = ServerGames.Count;

            var inserted = false;

            for (int i = 0; i < length; i++)
            {
                var comparison = ServerGames[i].GameName.CompareTo(gameName);
                if (comparison == 0)
                {
                    inserted = true;
                    break;
                }

                if (comparison > 0)
                {
                    ServerGames.Insert(i, gameInfo);
                    inserted = true;
                    break;
                }
            }

            if (!inserted)
            {
                ServerGames.Add(gameInfo);
            }
        }
예제 #6
0
파일: Colosso.cs 프로젝트: dom426/IodemBot
        public async Task ColossoTrain()
        {
            var embed = new EmbedBuilder();

            embed.WithColor(Colors.Get("Iodem"));

            Matchup m = GetRandomMatchup();

            embed.WithAuthor(GetTitle(Context.User, m.Enemy));
            embed.WithDescription(GetText(Context.User, m));

            lastMessageWasNuts = false;
            if (m.Result.Text.Contains("nuts"))
            {
                lastMessageWasNuts = true;
            }

            await Context.Channel.SendMessageAsync("", false, embed.Build());

            if (m.Result.IsWin)
            {
                ServerGames.UserWonColosso((SocketGuildUser)Context.User, (SocketTextChannel)Context.Channel);
            }
            else
            {
                ServerGames.UserLostColosso((SocketGuildUser)Context.User, (SocketTextChannel)Context.Channel);
            }
        }
예제 #7
0
        protected override async Task GameOver()
        {
            var winners = Battle.GetTeam(Battle.GetWinner());
            var losers  = winners.First().battle.GetTeam(winners.First().enemies);

            winners.ConvertAll(s => (PlayerFighter)s).ForEach(async p => await ServerGames.UserWonPvP(UserAccountProvider.GetById(p.Id), lobbyChannel, winners.Count, losers.Count));

            _ = WriteGameOver();
            await Task.CompletedTask;
        }
예제 #8
0
            public override async Task ReactAsync(SocketUserMessage msg)
            {
                await base.ReactAsync(msg);

                var userAccount = UserAccounts.GetAccount(msg.Author);

                userAccount.ServerStats.HasWrittenCurse = true;
                UserAccounts.SaveAccounts();
                await ServerGames.UserHasCursed((SocketGuildUser)msg.Author, (SocketTextChannel)msg.Channel);
            }
예제 #9
0
        protected override async Task GameOver()
        {
            var winners = Battle.GetTeam(Battle.GetWinner());
            var losers  = winners.First().battle.GetTeam(winners.First().enemies);

            winners.ConvertAll(s => (PlayerFighter)s).ForEach(async p => await ServerGames.UserWonBattle(p.avatar, 1, 0, p.battleStats, BattleDifficulty.Easy, lobbyChannel, winners, false));
            losers.ConvertAll(s => (PlayerFighter)s).ForEach(async p => await ServerGames.UserLostBattle(p.avatar, lobbyChannel));

            _ = WriteGameOver();
            await Task.CompletedTask;
        }
예제 #10
0
        internal async Task GameOver()
        {
            var winners = Battle.GetTeam(Battle.GetWinner());

            if (Battle.SizeTeamB == 0)
            {
                Console.WriteLine("Game Over with no enemies existing.");
            }
            if (winners.First() is PlayerFighter)
            {
                winsInARow++;
                var wasMimic = Battle.TeamB.Any(e => e.name.Contains("Mimic"));
                winners.ConvertAll(s => (PlayerFighter)s).ForEach(async p => await ServerGames.UserWonBattle(p.avatar, winsInARow, LureCaps, p.battleStats, Diff, TextChannel, winners, wasMimic));
                if (!IsEndless)
                {
                    _ = WriteGameOver();
                }
                else
                {
                    Battle.TeamA.ForEach(p =>
                    {
                        p.PPrecovery += (winsInARow <= 8 * 4 && winsInARow % 4 == 0) ? 1 : 0;
                        p.RemoveNearlyAllConditions();
                        p.Buffs = new List <Buff>();
                        p.Heal((uint)(p.stats.HP * 5 / 100));
                    });

                    var text = $"{winners.First().name}'s Party wins Battle {winsInARow}! Battle will reset shortly";
                    await Task.Delay(2000);

                    await StatusMsg.ModifyAsync(m => { m.Content = text; m.Embed = null; });

                    await Task.Delay(2000);

                    Diff = (BattleDifficulty)Math.Min(4, 1 + winsInARow / stageLength);
                    SetRandomEnemies(ColossoBattle.Team.B);
                    Battle.turn = 0;
                    _           = StartBattle();
                }
            }
            else
            {
                if (IsEndless)
                {
                    Diff = BattleDifficulty.Easy;
                }

                var losers = winners.First().battle.GetTeam(winners.First().enemies);
                losers.ConvertAll(s => (PlayerFighter)s).ForEach(async p => await ServerGames.UserLostBattle(p.avatar, Diff, TextChannel));
                _ = WriteGameOver();
            }
        }
예제 #11
0
        protected override async Task GameOver()
        {
            var winners = Battle.GetTeam(Battle.GetWinner());

            if (Battle.SizeTeamB == 0)
            {
                Console.WriteLine("Game Over with no enemies existing.");
            }
            if (Battle.GetWinner() == ColossoBattle.Team.A)
            {
                winsInARow++;
                var RewardTables = Rewards;
                var chests       = chestTable[Difficulty];
                chests.RemoveAll(s => s is DefaultReward);
                if (!Battle.TeamB.Any(f => f.Name.Contains("Mimic")))
                {
                    chests.Add(new DefaultReward {
                        Weight = chests.Weight * (14 - 2 * LureCaps)
                    });
                }
                RewardTables.Add(chests);
                winners.OfType <PlayerFighter>().ToList().ForEach(async p => await ServerGames.UserWonBattle(p.avatar, RewardTables.GetRewards(), p.battleStats, lobbyChannel, BattleChannel, winsInARow, string.Join(", ", Battle.TeamA.Select(pl => pl.Name))));
                chests.RemoveAll(s => s is DefaultReward);

                Console.WriteLine("Winners rewarded.");
                Battle.TeamA.ForEach(p =>
                {
                    p.PPrecovery += (winsInARow <= 8 * 4 && winsInARow % 4 == 0) ? 1 : 0;
                    p.RemoveNearlyAllConditions();
                    p.Buffs = new List <Buff>();
                    p.Heal((uint)(p.Stats.HP * 5 / 100));
                });

                var text = $"{winners.First().Name}'s Party wins Battle {winsInARow}! Battle will reset shortly";
                await Task.Delay(2000);

                await StatusMessage.ModifyAsync(m => { m.Content = text; m.Embed = null; });

                await Task.Delay(2000);

                SetNextEnemy();
                Battle.turn = 0;
                _           = StartBattle();
            }
            else
            {
                var losers = winners.First().battle.GetTeam(winners.First().enemies);
                losers.ConvertAll(s => (PlayerFighter)s).ForEach(async p => await ServerGames.UserLostBattle(p.avatar, lobbyChannel));
                _ = WriteGameOver();
            }
        }
예제 #12
0
        public async Task MoveInfo([Remainder] string name = "")
        {
            if (name == "")
            {
                return;
            }

            Move m = PsynergyDatabase.GetMove(name);

            if (!(m is Psynergy psy))
            {
                return;
            }
            if (psy.Name.ToLower().Contains("not implemented"))
            {
                var failEmbed = new EmbedBuilder();
                failEmbed.WithColor(Colors.Get("Iodem"));
                failEmbed.WithDescription("I have never heard of that kind of Psynergy");
                await Context.Channel.SendMessageAsync("", false, failEmbed.Build());

                return;
            }
            var embed = new EmbedBuilder();

            embed.WithColor(Colors.Get(psy.Element.ToString()));
            embed.WithAuthor(psy.Name);
            embed.AddField("Emote", psy.Emote, true);
            embed.AddField("PP", psy.PPCost, true);
            embed.AddField("Description", $"{psy} {(psy.HasPriority ? "Always goes first." : "")}");

            if (psy.Effects.Count > 0)
            {
                var s = string.Join("\n", psy.Effects.Select(e => $"{e}"));
                embed.AddField("Effects", s);
            }

            var classWithMove = AdeptClassSeriesManager.allClasses.Where(d => d.Classes.Any(c => c.Movepool.Contains(psy.Name)));

            if (classWithMove.Count() > 0)
            {
                embed.AddField("Learned by", string.Join(", ", classWithMove.Select(c => c.Name)));
            }

            await Context.Channel.SendMessageAsync("", false, embed.Build());

            if (Context.User is SocketGuildUser sgu)
            {
                _ = ServerGames.UserLookedUpPsynergy(sgu, (SocketTextChannel)Context.Channel);
            }
        }
예제 #13
0
        protected override async Task GameOver()
        {
            var winners = Battle.GetTeam(Battle.GetWinner());

            if (Battle.GetWinner() == Team.A)
            {
                if (Battle.GetWinner() == Team.A)
                {
                    winners.OfType <PlayerFighter>().ToList().ForEach(async p => await ServerGames.UserWonBattle(p.avatar, matchup.RewardTables.GetRewards(), p.battleStats, lobbyChannel, BattleChannel));
                }

                Battle.TeamA.ForEach(p =>
                {
                    p.RemoveNearlyAllConditions();
                    p.Buffs = new List <Buff>();
                    p.Heal((uint)(p.Stats.HP * 5 / 100));
                });

                SetNextEnemy();

                if (!EndOfDungeon)
                {
                    await SummonsMessage.ModifyAsync(m => m.Content = matchup.FlavourText);

                    var text = $"{winners.First().Name}'s Party wins Battle!";
                    await Task.Delay(2000);

                    await StatusMessage.ModifyAsync(m => { m.Content = text; m.Embed = null; });

                    await Task.Delay(2000);

                    Battle.turn = 0;
                    _           = StartBattle();
                }
                else
                {
                    winners.OfType <PlayerFighter>().ToList().ForEach(async p => await ServerGames.UserWonDungeon(p.avatar, Dungeon, lobbyChannel));
                    _ = WriteGameOver();
                }
            }
            else
            {
                var losers = winners.First().battle.GetTeam(winners.First().enemies);

                losers.ConvertAll(s => (PlayerFighter)s).ForEach(async p => await ServerGames.UserLostBattle(p.avatar, lobbyChannel));

                _ = WriteGameOver();
            }
        }
예제 #14
0
        private void RecountGames()
        {
            var serverGames = ServerGames.ToArray();

            for (var i = 0; i < serverGames.Length; i++)
            {
                var item = serverGames[i];
                var game = ServerGamesCache.FirstOrDefault(sg => sg.GameID == item.GameID);
                if (game == null || !FilterGame(game))
                {
                    ServerGames.Remove(item);
                }
            }

            serverGames = ServerGames.ToArray();
            for (var i = 0; i < serverGames.Length; i++)
            {
                var item = serverGames[i];
                var game = ServerGamesCache.FirstOrDefault(sg => sg.GameID == item.GameID);
                if (game != null && game != item)
                {
                    ServerGames[i] = game;
                }
            }

            for (int i = 0; i < ServerGamesCache.Count; i++)
            {
                var item = ServerGamesCache[i];

                var game = ServerGames.FirstOrDefault(sg => sg.GameID == item.GameID);
                if (game == null && FilterGame(item))
                {
                    InsertGame(item);
                }
            }

            if (CurrentGame != null && !ServerGames.Contains(CurrentGame))
            {
                CurrentGame = null;
            }

            if (CurrentGame == null && ServerGames.Any())
            {
                CurrentGame = ServerGames[0];
            }
        }
예제 #15
0
파일: Quotes.cs 프로젝트: dom426/IodemBot
        public async Task RandomQuote([Remainder] string name)
        {
            name = name.ToLower();
            if (GetQuotesCount() == 0)
            {
                await NoQuotes();

                return;
            }
            var embed = new EmbedBuilder();

            embed.WithColor(Colors.Get("Iodem"));

            //TODO: Optimize this. This is ugly.
            List <QuoteStruct> QuotesFromName = new List <QuoteStruct>();

            foreach (QuoteStruct q in quoteList)
            {
                if (q.name.Equals(name))
                {
                    QuotesFromName.Add(q);
                }
            }
            if (QuotesFromName.Count == 0)
            {
                embed.WithDescription(Utilities.GetAlert("No_Quote_From_Name"));
            }
            else
            {
                var quote = QuotesFromName[(new Random()).Next(0, QuotesFromName.Count)];
                embed.WithThumbnailUrl(Sprites.GetImageFromName(quote.name));
                embed.WithAuthor(Utilities.ToCaps(quote.name));

                embed.WithDescription(quote.quote);
                if (quote.quote.Contains(@"#^@%!"))
                {
                    var userAccount = UserAccounts.GetAccount(Context.User);
                    userAccount.ServerStats.HasQuotedMatthew = true;
                    UserAccounts.SaveAccounts();
                    await ServerGames.UserHasCursed((SocketGuildUser)Context.User, (SocketTextChannel)Context.Channel);
                }
            }
            await Context.Channel.SendMessageAsync("", false, embed.Build());
        }
예제 #16
0
        public static Embed ColossoTrain(SocketGuildUser user, IMessageChannel channel)
        {
            var embed = new EmbedBuilder();

            embed.WithColor(Colors.Get("Iodem"));

            Matchup m = GetRandomMatchup();

            embed.WithAuthor(GetTitle(user, m.Enemy));
            embed.WithDescription(GetText(user, m));

            if (m.Result.IsWin)
            {
                ServerGames.UserWonColosso(user, channel);
            }
            else
            {
                ServerGames.UserLostColosso(user, channel);
            }
            return(embed.Build());
        }
예제 #17
0
        public async Task RockPaperScissorsAsync([Remainder] RpsEnum choice)
        {
            string[] emotesPlayer = { "🤜", "🖐️", "✌️" };
            string[] emotesCPU    = { "🤛", "🖐️", "✌️" };

            var     avatar    = UserAccounts.GetAccount(Context.User);
            RpsEnum cpuChoice = (RpsEnum)((new Random()).Next(0, 1000) % 3);
            string  result    = "";

            switch ((int)choice - (int)cpuChoice)
            {
            case 1:
            case -2:
                result = "You read me like an open book! You win!";
                await ServerGames.UserWonRPS((SocketGuildUser)Context.User, (SocketTextChannel)Context.Channel);

                break;

            case 0:
                ServerGames.UserDidNotWinRPS((SocketGuildUser)Context.User);
                result = "I may not have the gift of Psynergy, but I can still match your strength!";
                break;

            case -1:
            case 2:
                ServerGames.UserDidNotWinRPS((SocketGuildUser)Context.User);
                result = "Ahah! I may forever remember the day I beat an Adept in a fair game!";
                break;
            }

            var embed = new EmbedBuilder();

            embed.WithColor(Colors.Get("Iodem"));
            embed.WithDescription($"{emotesPlayer[(int)choice]} vs {emotesCPU[(int)cpuChoice]}");
            embed.AddField("Result:", result);

            await Context.Channel.SendMessageAsync("", false, embed.Build());
        }
예제 #18
0
        public async Task MoveInfo([Remainder] string name = "")
        {
            if (name == "")
            {
                return;
            }

            Psynergy psy = PsynergyDatabase.GetPsynergy(name);

            if (psy.name.Contains("Not Implemented"))
            {
                var failEmbed = new EmbedBuilder();
                failEmbed.WithColor(Colors.Get("Iodem"));
                failEmbed.WithDescription("I have never heard of that kind of Psynergy");
                await Context.Channel.SendMessageAsync("", false, failEmbed.Build());

                return;
            }
            var embed = new EmbedBuilder();

            embed.WithColor(Colors.Get(psy.element.ToString()));
            embed.WithAuthor(psy.name);
            embed.AddField("Emote", psy.emote, true);
            embed.AddField("PP", psy.PPCost, true);
            //embed.AddField("Element", psy.element, true);
            embed.AddField("Description", $"{psy.ToString()} {(psy.hasPriority ? "Always goes first." : "")}");
            var s = "none";

            if (psy.effects.Count > 0)
            {
                s = string.Join("\n", psy.effects.Select(e => $"{e.ToString()}"));
            }

            embed.AddField("Effects", s);
            await Context.Channel.SendMessageAsync("", false, embed.Build());

            _ = ServerGames.UserLookedUpPsynergy((SocketGuildUser)Context.User, (SocketTextChannel)Context.Channel);
        }
예제 #19
0
        public async Task RockPaperScissorsAsync([Remainder] RpsEnum choice)
        {
            string[] emotesPlayer = { "🤜", ":hand_splayed:", ":v:" };
            string[] emotesCpu    = { "🤛", ":hand_splayed:", ":v:" };

            var cpuChoice = Enum.GetValues <RpsEnum>().Random();
            var result    = "";

            switch ((int)choice - (int)cpuChoice)
            {
            case 1:
            case -2:
                result = "You read me like an open book! You win!";
                _      = ServerGames.UserWonRps((SocketGuildUser)Context.User, (SocketTextChannel)Context.Channel);
                break;

            case 0:
                ServerGames.UserDidNotWinRps((SocketGuildUser)Context.User);
                result = "I may not have the gift of Psynergy, but I can still match your strength!";
                break;

            case -1:
            case 2:
                ServerGames.UserDidNotWinRps((SocketGuildUser)Context.User);
                result = "Ahah! I may forever remember the day I beat an Adept in a fair game!";
                break;
            }

            var embed = new EmbedBuilder();

            embed.WithColor(Colors.Get("Iodem"));
            embed.WithDescription($"{emotesPlayer[(int)choice]} vs {emotesCpu[(int)cpuChoice]}");
            embed.AddField("Result:", result);

            _ = Context.Channel.SendMessageAsync("", false, embed.Build());
            await Task.CompletedTask;
        }
예제 #20
0
        protected override async Task GameOver()
        {
            var winners = Battle.GetTeam(Battle.GetWinner());

            if (Battle.SizeTeamB == 0)
            {
                Console.WriteLine("Game Over with no enemies existing.");
            }
            if (Battle.GetWinner() == ColossoBattle.Team.A)
            {
                var RewardTables = Rewards;
                // Get the appropiate chest rewards table
                var chests = chestTable[Difficulty];
                chests.RemoveAll(s => s is DefaultReward);

                // If there was *no* mimic, add a counter weight
                if (!Battle.TeamB.Any(f => f.Name.Contains("Mimic")))
                {
                    chests.Add(new DefaultReward {
                        Weight = chests.Weight * (14 - 2 * LureCaps - Battle.SizeTeamA)
                    });
                }
                RewardTables.Add(chests);
                winners.OfType <PlayerFighter>().ToList().ForEach(async p => await ServerGames.UserWonBattle(p.avatar, RewardTables.GetRewards(), p.battleStats, lobbyChannel, BattleChannel));
                chests.RemoveAll(s => s is DefaultReward);
                _ = WriteGameOver();
            }
            else
            {
                var losers = winners.First().battle.GetTeam(winners.First().enemies);
                losers.ConvertAll(s => (PlayerFighter)s).ForEach(async p => await ServerGames.UserLostBattle(p.avatar, lobbyChannel));
                _ = WriteGameOver();
            }
            LureCaps = 0;
            await Task.CompletedTask;
        }
예제 #21
0
        protected override async Task GameOver()
        {
            var winners = Battle.GetTeam(Battle.GetWinner());

            if (Battle.SizeTeamB == 0)
            {
                Console.WriteLine("Game Over with no enemies existing.");
            }
            if (Battle.GetWinner() == Team.A)
            {
                var RewardTables = Rewards;
                // Get the appropiate chest rewards table
                var chests = chestTable[Difficulty];
                chests.RemoveAll(s => s is DefaultReward d && !d.HasChest);

                // If there was *no* mimic, add a counter weight
                var lurCapBonus = new[] { 16, 12, 10, 9, 8 };
                if (!Battle.TeamB.Any(f => f.Name.Contains("Mimic")))
                {
                    chests.Add(new DefaultReward()
                    {
                        Weight = chests.Weight * lurCapBonus[LureCaps]
                    });
                }
                RewardTables.Add(chests);

                if (Battle.TeamB.Any(f => f.Name.Contains("Djinn")))
                {
                    var djinnTable  = new RewardTable();
                    var djinnWeight = (int)Difficulty;
                    if (Battle.TeamB.Any(f => f.Name.Contains("enus Djinn")))
                    {
                        djinnTable.Add(new DefaultReward()
                        {
                            Djinn = "Venus", Weight = 1
                        });
                    }
                    if (Battle.TeamB.Any(f => f.Name.Contains("ars Djinn")))
                    {
                        djinnTable.Add(new DefaultReward()
                        {
                            Djinn = "Mars", Weight = 1
                        });
                    }
                    if (Battle.TeamB.Any(f => f.Name.Contains("upiter Djinn")))
                    {
                        djinnTable.Add(new DefaultReward()
                        {
                            Djinn = "Jupiter", Weight = 1
                        });
                    }
                    if (Battle.TeamB.Any(f => f.Name.Contains("ercury Djinn")))
                    {
                        djinnTable.Add(new DefaultReward()
                        {
                            Djinn = "Mercury", Weight = 1
                        });
                    }
                    djinnTable.Add(new DefaultReward()
                    {
                        Weight = djinnTable.Weight * (10 - (int)Difficulty) * 3 - djinnTable.Weight
                    });
                    RewardTables.Add(djinnTable);
                }

                winners.OfType <PlayerFighter>().ToList().ForEach(async p => await ServerGames.UserWonBattle(UserAccountProvider.GetById(p.Id), RewardTables.GetRewards(), p.battleStats, lobbyChannel, BattleChannel));
                winners.OfType <PlayerFighter>().ToList().ForEach(async p => await ServerGames.UserWonSingleBattle(UserAccountProvider.GetById(p.Id), lobbyChannel, Difficulty));

                chests.RemoveAll(s => s is DefaultReward d && !d.HasChest);
                _ = WriteGameOver();
            }
            else
            {
                var losers = winners.First().battle.GetTeam(winners.First().enemies);
                losers.ForEach(p => p.Moves.OfType <Djinn>().ToList().ForEach(d => { d.Summon(p); d.CoolDown = 0; }));
                losers.ConvertAll(s => (PlayerFighter)s).ForEach(async p => await ServerGames.UserLostBattle(UserAccountProvider.GetById(p.Id), lobbyChannel));
                _ = WriteGameOver();
            }

            await Task.CompletedTask;
        }
예제 #22
0
        protected override async Task GameOver()
        {
            var winners = Battle.GetTeam(Battle.GetWinner());

            if (Battle.GetWinner() == Team.A)
            {
                if (Battle.GetWinner() == Team.A)
                {
                    winners.OfType <PlayerFighter>().ToList().ForEach(async p => await ServerGames.UserWonBattle(UserAccountProvider.GetById(p.Id), matchup.RewardTables.GetRewards(), p.battleStats, lobbyChannel, BattleChannel));
                }

                Battle.TeamA.ForEach(p =>
                {
                    p.RemoveNearlyAllConditions();
                    p.Buffs = new List <Buff>();
                    p.Heal((uint)(p.Stats.HP * 5 / 100));
                });

                SetNextEnemy();

                if (!EndOfDungeon)
                {
                    await SummonsMessage.ModifyAsync(m => m.Content = matchup.FlavourText);

                    var text = $"{winners.First().Name}'s Party wins Battle!";
                    await Task.Delay(2000);

                    await StatusMessage.ModifyAsync(m => { m.Content = text; m.Embed = null; });

                    await Task.Delay(2000);

                    Battle.turn = 0;
                    _           = StartBattle();
                }
                else
                {
                    winners.OfType <PlayerFighter>().ToList().ForEach(async p => await ServerGames.UserWonDungeon(UserAccountProvider.GetById(p.Id), Dungeon, lobbyChannel));

                    if (DateTime.Now <= new DateTime(2020, 11, 8) && Global.Random.Next(4) == 0)
                    {
                        var r = new List <Rewardable>()
                        {
                            new DefaultReward()
                            {
                                Dungeon = "Halloween Special"
                            }
                        };
                        winners.OfType <PlayerFighter>().ToList().ForEach(async p => await ServerGames.UserWonBattle(UserAccountProvider.GetById(p.Id), r, new BattleStats(), lobbyChannel, BattleChannel));
                    }

                    _ = WriteGameOver();
                }
            }
            else
            {
                var losers = winners.First().battle.GetTeam(winners.First().enemies);


                losers.ConvertAll(s => (PlayerFighter)s).ForEach(async p => await ServerGames.UserLostBattle(UserAccountProvider.GetById(p.Id), lobbyChannel));

                _ = WriteGameOver();
            }
        }
예제 #23
0
        protected override async Task GameOver()
        {
            var winners = Battle.GetTeam(Battle.GetWinner());

            if (Battle.SizeTeamB == 0)
            {
                Console.WriteLine("Game Over with no enemies existing.");
            }
            if (Battle.GetWinner() == Team.A)
            {
                winsInARow++;
                var RewardTables = Rewards;
                var chests       = chestTable[Difficulty];
                chests.RemoveAll(s => s is DefaultReward d && !d.HasChest);
                var lurCapBonus = new[] { 16, 12, 10, 9, 8 };
                if (!Battle.TeamB.Any(f => f.Name.Contains("Mimic")))
                {
                    chests.Add(new DefaultReward {
                        Weight = chests.Weight * lurCapBonus[LureCaps]
                    });
                }
                RewardTables.Add(chests);

                if (Battle.TeamB.Any(f => f.Name.Contains("Djinn")))
                {
                    var djinnTable  = new RewardTable();
                    var djinnWeight = (int)Difficulty;
                    if (Battle.TeamB.Any(f => f.Name.Contains("Venus Djinn")))
                    {
                        djinnTable.Add(new DefaultReward()
                        {
                            Djinn = "Venus", Weight = 1
                        });
                    }
                    if (Battle.TeamB.Any(f => f.Name.Contains("Mars Djinn")))
                    {
                        djinnTable.Add(new DefaultReward()
                        {
                            Djinn = "Mars", Weight = 1
                        });
                    }
                    if (Battle.TeamB.Any(f => f.Name.Contains("Jupiter Djinn")))
                    {
                        djinnTable.Add(new DefaultReward()
                        {
                            Djinn = "Jupiter", Weight = 1
                        });
                    }
                    if (Battle.TeamB.Any(f => f.Name.Contains("Mercury Djinn")))
                    {
                        djinnTable.Add(new DefaultReward()
                        {
                            Djinn = "Mercury", Weight = 1
                        });
                    }
                    djinnTable.Add(new DefaultReward()
                    {
                        Weight = djinnTable.Weight * (10 - (int)Difficulty) * 2 - djinnTable.Weight
                    });
                    RewardTables.Add(djinnTable);
                }

                winners.OfType <PlayerFighter>().ToList().ForEach(async p => await ServerGames.UserWonBattle(p.avatar, RewardTables.GetRewards(), p.battleStats, lobbyChannel, BattleChannel));
                winners.OfType <PlayerFighter>().ToList().ForEach(async p => await ServerGames.UserWonEndless(p.avatar, lobbyChannel, winsInARow, mode, p.battleStats.TotalTeamMates + 1, string.Join(", ", Battle.TeamA.Select(pl => pl.Name))));

                chests.RemoveAll(s => s is DefaultReward d && !d.HasChest);

                Battle.TeamA.ForEach(p =>
                {
                    p.PPrecovery += (winsInARow <= 8 * 4 && winsInARow % 4 == 0) ? 1 : 0;
                    p.RemoveNearlyAllConditions();
                    p.Buffs = new List <Buff>();
                    p.Heal((uint)(p.Stats.HP * 5 / 100));
                });

                var text = $"{winners.First().Name}'s Party wins Battle {winsInARow}! Battle will reset shortly.";
                await Task.Delay(3000);

                await StatusMessage.ModifyAsync(m => { m.Content = text; m.Embed = null; });

                await Task.Delay(3000);

                SetNextEnemy();
                Battle.turn = 0;
                _           = StartBattle();
            }
            else
            {
                var losers = winners.First().battle.GetTeam(winners.First().enemies);
                losers.ConvertAll(s => (PlayerFighter)s).ForEach(async p => await ServerGames.UserLostBattle(p.avatar, lobbyChannel));
                winners.OfType <PlayerFighter>().ToList().ForEach(async p => await ServerGames.UserFinishedEndless(p.avatar, lobbyChannel, winsInARow, mode));
                _ = WriteGameOver();
            }
        }