Exemplo n.º 1
0
        public static long[] SendResCapToStorage(Account acc, Resources resources)
        {
            var mainVill = AccountHelper.GetMainVillage(acc);
            var stored   = ResourcesHelper.ResourcesToArray(mainVill.Res.Stored.Resources);

            var resSend = ResourcesHelper.ResourcesToArray(resources);

            long[] ret = new long[4];
            for (int i = 0; i < 4; i++)
            {
                ret[i] = resSend[i] > stored[i] ? stored[i] : resSend[i];
            }
            return(ret);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Calculates how many resources should be sent to the main village based on configurable limit
        /// </summary>
        /// <param name="vill">Village</param>
        /// <returns>Resources to be sent</returns>
        public static long[] GetResToMainVillage(Village vill)
        {
            var ret   = new long[4];
            var res   = ResourcesHelper.ResourcesToArray(vill.Res.Stored.Resources);
            var limit = ResourcesHelper.ResourcesToArray(vill.Market.Settings.Configuration.SendResLimit);

            for (int i = 0; i < 4; i++)
            {
                // % into resource mode
                if (limit[i] < 100)
                {
                    var capacity = i == 3 ? vill.Res.Capacity.GranaryCapacity : vill.Res.Capacity.WarehouseCapacity;
                    limit[i] = (long)(limit[i] / 100.0 * capacity);
                }

                ret[i] = res[i] - limit[i];
                if (ret[i] < 0)
                {
                    ret[i] = 0;
                }
            }
            return(ret);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Used by BotTasks to insert resources/coordinates into the page.
        /// </summary>
        /// <param name="acc">Account</param>
        /// <param name="resources">Target resources</param>
        /// <param name="coordinates">Target coordinates</param>
        /// <returns>Time it will take for transit to complete</returns>
        public static async Task <TimeSpan?> MarketSendResource(Account acc, Resources resources, Village targetVillage, BotTask botTask)
        {
            var res = ResourcesHelper.ResourcesToArray(resources);

            return(await MarketSendResource(acc, res, targetVillage, botTask));
        }