Ejemplo n.º 1
0
        //DateTime CooldownResetSince = DateTime.MinValue;

        public override void Initialize(PlayerTimersGroup parentGroup, string player, string timerId, WurmServer.ServerInfo.ServerGroup serverGroup, string compactId)
        {
            base.Initialize(parentGroup, player, timerId, serverGroup, compactId);
            TimerDisplay.SetCooldown(SermonPreacherCooldown);

            PerformAsyncInits();
        }
Ejemplo n.º 2
0
 public override void Initialize(PlayerTimersGroup parentGroup, string player, string timerId,
     WurmServer.ServerInfo.ServerGroup serverGroup, string compactId)
 {
     base.Initialize(parentGroup, player, timerId, serverGroup, compactId);
     Settings = new PersistentObject<JunkSaleTimerSettings>(new JunkSaleTimerSettings());
     Settings.SetFilePathAndLoad(SettingsSavePath);
     TimerDisplay.ShowSkill = true;
     VerifyMoneyAmountAgainstCd();
     UpdateMoneyCounter();
     InitCompleted = true;
 }
Ejemplo n.º 3
0
 public string GetCurrentServerForGroup(WurmServer.ServerInfo.ServerGroup sg)
 {
     lock (_locker)
     {
         SgInfo info;
         if (_groupToServerMap.TryGetValue(sg, out info))
         {
             return info.ServerName;
         }
         else return null;
     }
 }
Ejemplo n.º 4
0
 public void Update(WurmServer.ServerInfo.ServerGroup serverGroup, DateTime stamp, string serverName)
 {
     lock (_locker)
     {
         SgInfo info;
         if (_groupToServerMap.TryGetValue(serverGroup, out info))
         {
             if (stamp < info.Stamp) return;
         }
         _groupToServerMap[serverGroup] = new SgInfo {Stamp = stamp, ServerName = serverName};
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// returns null if no skill data available yet
        /// </summary>
        /// <param name="serverGroup"></param>
        /// <returns></returns>
        public float? GetAhSkill(WurmServer.ServerInfo.ServerGroup serverGroup)
        {
            if (!_skillObtainedFlag) return null;

            if (serverGroup == WurmServer.ServerInfo.ServerGroup.Epic)
                return AhEpicSkill;
            else if (serverGroup == WurmServer.ServerInfo.ServerGroup.Freedom)
                return AhFreedomSkill;
            else
            {
                Logger.LogDebug("unknown server group for ah skill request, returning null, player: " + PlayerName, this);
                return null;
            }
        }
Ejemplo n.º 6
0
        private async Task<float> ObtainAhSkill(WurmServer.ServerInfo.ServerGroup serverGroup, Dictionary<WurmServer.ServerInfo.ServerGroup, float> searchResults)
        {
            var skillId = new LogFeedManager.CachedAHSkillID(serverGroup, PlayerName);
            float result = 0;
            // first try to find result in the last X days
            if (searchResults.TryGetValue(serverGroup, out result) == false)
            {
                // if nothing, try get a value saved in settings
                var obtained = _parentModule.Settings.Value.TryGetAHSkill(skillId, out result);
                if (!obtained || result == 0)
                {
                    // obtained value of 0 may indicate that longer search is needed
                    // get the last check date and push another search from that date
                    DateTime checkDate = DateTime.MinValue;
                    _parentModule.Settings.Value.TryGetAHCheckDate(skillId, out checkDate);
                    if (checkDate < DateTime.Now - TimeSpan.FromDays(10))
                    {
                        // if indeed last check was late, we need to search since then
                        var daysToSearch = (int)((DateTime.Now - checkDate).TotalDays);
                        var resultLongSearch = await WurmLogSearcherAPI.GetSkillsForPlayerAsync(
                            PlayerName,
                            daysToSearch > 365 ? 356 : daysToSearch,
                            "Animal husbandry");
                        resultLongSearch.TryGetValue(serverGroup, out result);
                    }
                    else
                    {
                        // this is weird, no result but check date is not so long ago
                        // maybe settings bugged? lets do a half year search just to be safe!
                        // note: this can trigger for server groups player doesn't care about
                        const int daysToSearch = 180;
                        var resultLongSearch = await WurmLogSearcherAPI.GetSkillsForPlayerAsync(
                            PlayerName,
                            daysToSearch,
                            "Animal husbandry");
                        resultLongSearch.TryGetValue(serverGroup, out result);
                    }
                }
            }
            _parentModule.Settings.Value.SetAHCheckDate(skillId, DateTime.Now);

            return result;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Null if there is no data for this group
        /// </summary>
        /// <param name="playerName"></param>
        /// <param name="group"></param>
        /// <returns></returns>
        public static async Task<string> GetServerNameForGroup(string playerName, WurmServer.ServerInfo.ServerGroup group)
        {
            await _initializedTcs.Task;

            var result = await _settings.Value.GetStatusForServerGroupAsync(playerName, group);

            if (_settings.Value.NeedSaving)
            {
                _settings.Value.NeedSaving = false;
                _settings.Save();
            }

            return result;
        }
Ejemplo n.º 8
0
            internal async Task<string> GetStatusForServerGroupAsync(string playerName, WurmServer.ServerInfo.ServerGroup sg)
            {
                StateInfo stateInfo;
                lock (_locker)
                {
                    if (!_playerToServerMap.TryGetValue(playerName, out stateInfo))
                    {
                        stateInfo = new StateInfo(playerName);
                        _playerToServerMap.Add(playerName, stateInfo);
                    }

                    if (stateInfo.LogSearchFinished)
                    {
                        return stateInfo.ServerGroupsManager.GetCurrentServerForGroup(sg);
                    }
                    else
                    {
                        try
                        {
                            stateInfo.LogSearchingTask.Start();
                        }
                        catch (InvalidOperationException)
                        {
                            // is already started
                        }
                    }
                }

                await stateInfo.LogSearchingTask;

                if (stateInfo.NeedSaving) this.NeedSaving = true;

                return stateInfo.ServerGroupsManager.GetCurrentServerForGroup(sg);
            }
Ejemplo n.º 9
0
        private HorseEntity[] GetHorseToUpdate(string horseName, WurmServer.ServerInfo.ServerGroup serverGroup)
        {
            bool isEpic;
            if (serverGroup == WurmServer.ServerInfo.ServerGroup.Epic) isEpic = true;
            else if (serverGroup == WurmServer.ServerInfo.ServerGroup.Freedom) isEpic = false;
            else return new HorseEntity[0];

            IEnumerable<HerdEntity> query = _context.Herds;
            if (_parentModule.Settings.Value.DoNotBlockDataUpdateUnlessMultiplesInEntireDb == false)
            {
                query = query.Where(x => x.Selected);
            }
            var herdsToCheck = query.Select(x => x.HerdID).ToArray();
            //var step0 = _context.Horses.ToArray();
            //var step1 = step0.Where(x => x.Name == horseName).ToArray();
            //var step2 = step1.Where(x => selectedHerds.Contains(x.Herd)).ToArray();
            //var step3 = step2.Where(x => x.EpicCurve == isEpic).ToArray();
            var foundHorses = _context.Horses.Where(x => x.Name == horseName && herdsToCheck.Contains(x.Herd) && (x.EpicCurve ?? false) == isEpic).ToArray();
            return foundHorses;
        }
Ejemplo n.º 10
0
 public ServerGroupEventArgs(WurmServer.ServerInfo.ServerGroup currentGroup)
 {
     this.CurrentGroup = currentGroup;
 }