Esempio n. 1
0
        /// <summary>
        /// When a BotTask doesn't have enough resources in the village, this method will add the
        /// BotTask to the village's UnfinishedTasks list. Bot will finish the task when village has enough resources
        /// </summary>
        /// <param name="acc">Account</param>
        /// <param name="vill">(target) Village</param>
        /// <param name="requiredRes">Resources required</param>
        /// <param name="task">Bot task that doesn't have enough resources</param>
        /// <param name="buildingTask">Potential building task</param>
        public static void NotEnoughRes(Account acc, Village vill, Resources requiredRes, BotTask task, BuildingTask buildingTask = null)
        {
            var enoughResAt = NewUnfinishedTask(acc, vill, requiredRes, task, buildingTask);

            if (enoughResAt == null)
            {
                return;
            }

            var nextRefresh = TimeHelper.RanDelay(acc, enoughResAt ?? DateTime.Now);

            if (nextRefresh < VillageHelper.GetNextRefresh(acc, vill))
            {
                VillageHelper.SetNextRefresh(acc, vill, nextRefresh);
            }
        }
        /// <summary>
        /// Gets time for next build event. This depends on how long the current building takes
        /// </summary>
        /// <param name="vill">Village</param>
        /// <returns>Time for next build</returns>
        private static DateTime GetNextBuildTime(Account acc, Village vill)
        {
            var dur = vill.Build.CurrentlyBuilding.First().Duration;

            return(TimeHelper.RanDelay(acc, dur, 20));
        }