Ejemplo n.º 1
0
        private async Task <TaskResult> Process(List <DailyTaskWrapper> tasks)
        {
            if (tasks.Count == 0)
            {
                return(TaskResult.CanNotBeDone);
            }

            // Nhiệm vụ đang làm.
            var doingTask = tasks.FirstOrDefault(item => item.State == TaskState.Received);

            // Số sao ít nhất.
            var minQuality = tasks.Min(item => item.Quality);

            // Xét nhiệm vụ với số sao ít nhất và dễ nhất.
            var task = tasks
                       .Where(item => item.Quality == minQuality)
                       .MinBy(item => item.Difficulty);

            if (TaskDifficulty.CanDo(task.Difficulty))
            {
                return(await Process(doingTask, task));
            }


            // Xét nhiệm vụ nhiều sao hơn.
            var harderTasks = tasks.Where(item => item.Quality == minQuality + 1).ToList();

            if (harderTasks.Count > 0)
            {
                var harderTask = harderTasks.MinBy(item => item.Difficulty);
                return(await Process(doingTask, harderTask));
            }

            return(TaskResult.CanNotBeDone);
        }
Ejemplo n.º 2
0
        public int PredictDifficulty(int times)
        {
            var turns = mcu.Mcu;

            if (mcu.ExtraZhengzhan)
            {
                ++turns;
            }
            if (turns < times)
            {
                return(TaskDifficulty.AttackNpcLackTurns(times, times - turns));
            }
            return(TaskDifficulty.AttackNpcOk(times));
        }
Ejemplo n.º 3
0
        public int PredictDifficulty(int times)
        {
            // FIXME:
            // Cho mỗi lần cải tiến hết 800 chiến tích.
            const double ImproveCost = 800;

            var needed = ImproveCost * times;

            if (needed > info.Honor)
            {
                return(TaskDifficulty.ImproveNotOk());
            }

            return(TaskDifficulty.ImproveOk());
        }
Ejemplo n.º 4
0
        public int PredictDifficulty(int times)
        {
            if (impose.ImposeNum < times)
            {
                return(TaskDifficulty.ImposeNotOk());
            }

            var silverEachImpose = impose.Copper;

            if (info.Silver + silverEachImpose * times > info.MaxSilver)
            {
                // Tràn bạc.
                return(TaskDifficulty.ImposeOverSilver(times));
            }

            return(TaskDifficulty.ImposeOk(times));
        }
Ejemplo n.º 5
0
        private int PredictDifficulty(int times, int trades, double price, int food, int maxFood, int silver, int maxSilver)
        {
            if (times == 0)
            {
                // OK.
                return(TaskDifficulty.FoodOk());
            }
            if (trades <= 0)
            {
                // Chợ đen.
                // Chợ đen giá gấp đôi.
                var cost = (int)Math.Floor(price * 2);
                if (food + 1 <= maxFood && silver >= cost)
                {
                    // Đủ bạc và không tràn kho lúa.
                    return(PredictDifficulty(times - 1, trades, price, food + 1, maxFood, silver - cost, maxSilver));
                }
            }
            else
            {
                // Giao dịch thường.
                // Bán lúa trước.
                var cost = (int)Math.Floor(price);  // Cost = 0?
                if (food > 0 && silver + cost <= maxSilver)
                {
                    return(PredictDifficulty(times - 1, trades - 1, price, food - 1, maxFood, silver + cost, maxSilver));
                }

                // Mua lúa.
                if (food + 1 < maxFood && silver >= cost)
                {
                    return(PredictDifficulty(times - 1, trades - 1, price, food + 1, maxFood, silver - cost, maxSilver));
                }
            }

            // Không thể hoàn thành (bây giờ).
            return(TaskDifficulty.FoodNotOk());
        }
Ejemplo n.º 6
0
        public int PredictDifficulty(int times)
        {
            var weapon = upgrade.Equipments.FirstOrDefault(item => item.Quality == EquipmentQuality.Trang);

            if (weapon == null)
            {
                // Không có vũ khí trắng.
                return(TaskDifficulty.CanNotBeDone);
            }

            const int UpgradeCost = 1000;
            int       okTimes     = 0;
            var       silver      = info.Silver;

            while (okTimes < times && silver > UpgradeCost)
            {
                ++okTimes;
            }
            if (okTimes == times)
            {
                return(TaskDifficulty.UpgradeOk(times));
            }
            return(TaskDifficulty.UpgradeNotOk(okTimes, times - okTimes));
        }