Beispiel #1
0
        /// <summary>
        /// Handles the QLRanks Elo update if necessary.
        /// </summary>
        /// <param name="player">The player.</param>
        private async Task HandleEloUpdate(string player)
        {
            PlayerInfo p;

            if (!_sst.ServerInfo.CurrentPlayers.TryGetValue(player, out p))
            {
                return;
            }
            if (_qlRanksHelper.DoesCachedEloExist(player))
            {
                if (!_qlRanksHelper.IsCachedEloDataOutdated(player))
                {
                    _qlRanksHelper.SetCachedEloData(_sst.ServerInfo.CurrentPlayers, player);
                }
                else
                {
                    Log.Write(
                        string.Format("Outdated cached Elo data found in database for {0}. Will update.",
                                      player), _logClassType, _logPrefix);

                    _qlRanksHelper.CreateNewPlayerEloData(_sst.ServerInfo.CurrentPlayers, player);
                    await
                    _qlRanksHelper.RetrieveEloDataFromApiAsync(_sst.ServerInfo.CurrentPlayers, player);
                }
            }
            else
            {
                _qlRanksHelper.CreateNewPlayerEloData(_sst.ServerInfo.CurrentPlayers, player);
                await
                _qlRanksHelper.RetrieveEloDataFromApiAsync(_sst.ServerInfo.CurrentPlayers, player);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Handles the setting or updating of Elo from the players command text.
        /// </summary>
        /// <param name="qlranksHelper">The QLRanks helper.</param>
        /// <param name="player">The player.</param>
        private void HandleEloFromPlayersText(QlRanksHelper qlranksHelper, string player)
        {
            // Set cached Elo or update
            if (qlranksHelper.DoesCachedEloExist(player))
            {
                if (!qlranksHelper.IsCachedEloDataOutdated(player))
                {
                    qlranksHelper.SetCachedEloData(
                        _sst.ServerInfo.CurrentPlayers, player);

                    Log.Write(string.Format(
                                  "Setting non-expired cached Elo result for {0} from database",
                                  player), _logClassType, _logPrefix);
                }
                else
                {
                    qlranksHelper.CreateNewPlayerEloData(
                        _sst.ServerInfo.CurrentPlayers, player);
                    _qlranksToUpdateFromPlayers.Add(player);

                    Log.Write(string.Format(
                                  "Outdated cached elo data found in DB for {0}. Adding to queue to update.",
                                  player), _logClassType, _logPrefix);
                }
            }
            else
            {
                qlranksHelper.CreateNewPlayerEloData(
                    _sst.ServerInfo.CurrentPlayers, player);
                _qlranksToUpdateFromPlayers.Add(player);
            }
        }