Пример #1
0
        private static async Task <bool> SelectClosestFate()
        {
            if (!await OracleFateManager.AnyViableFates())
            {
                return(false);
            }

            var fateDistances = await GetFateDistances();

            var closestFates = fateDistances.OrderBy(kvp => kvp.Value).Where(fate => OracleFateManager.FateFilter(fate.Key)).ToArray();

            foreach (var fate in closestFates)
            {
                if (fate.Value > 0)
                {
                    Logger.SendDebugLog("Found FATE '" + fate.Key.Name + "'. Distance to it is " + Math.Round(fate.Value, 2) + " yalms.");
                }
                else
                {
                    Logger.SendDebugLog("Found FATE '" + fate.Key.Name + "'. Distance to it is 0 yalms.");
                }
            }

            if (!closestFates.Any())
            {
                return(false);
            }

            Logger.SendLog("Selecting closest viable FATE.");
            var closestFate = closestFates.FirstOrDefault().Key;

            Logger.SendLog("Selected FATE: " + closestFate.Name + ".");
            Logger.SendDebugLog("Location of FATE: " + closestFate.Location);
            OracleFateManager.CurrentFateId = closestFate.Id;
            Poi.Current = new Poi(closestFate, PoiType.Fate);

            return(true);
        }