예제 #1
0
        /// <summary>
        /// Ends the Capture The Flag game by awarding the winning team with .
        /// </summary>
        /// <param name="ctfBot">The <see cref="CaptureTheFlagBot"/> instance.</param>
        /// <param name="winningTeam">The team what won the game.</param>
        public void End(CaptureTheFlagBot ctfBot, Team winningTeam)
        {
            ctfBot.SayChatMessage($"Game over! Team {winningTeam.GetStringName()} has won the game.");

            int coinsWon = GetGameFundShare(ctfBot.JoinedWorld.Players, winningTeam);

            foreach (Player player in ctfBot.JoinedWorld.Players.Values)
            {
                PlayerData playerData = MySqlDatabase.GetRow(player.Username);

                if (playerData != null && player.IsPlayingGame)
                {
                    if (player.Team == winningTeam)
                    {
                        playerData.Statistics.TotalWins++;
                        playerData.Statistics.Coins += coinsWon;

                        ctfBot.SendPrivateMessage(player, $"You received {coinsWon} coin{(coinsWon == 1 ? "" : "s")} for winning!");
                    }
                    else
                    {
                        playerData.Statistics.TotalLosses++;
                    }
                }
            }

            ResetRoundStatistics();
            MySqlDatabase.Save();

            ctfBot.ResetLevel();
        }