Example #1
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();
            }
        }