예제 #1
0
        public void ResetAllMotherResources(IDbConnection connection)
        {
            var res     = StorageResources.InitMotherResources();
            var mothers = _mothershipService.GetAllMothers(connection);

            foreach (var mother in mothers)
            {
                mother.Resources = res;
            }
            _mothershipService.AddOrUpdate(connection, mothers);
        }
        public void PushDemon(IDbConnection connection, IMothershipService motherService, IUMotherJumpService motherJumpService, IStoreService storeService)
        {
            var curTime = UnixTime.UtcNow();

            if (curTime - LAST_DEMON_RUNTIME < MIN_DEMON_DELAY_SECOND)
            {
                return;
            }

            var minItemTime = curTime - MIN_DELAY_TO_UPDATE;

            LAST_DEMON_RUNTIME = curTime;
            var motherIds = motherService.GetAllMothers(connection).Where(i => i.Id > 1000 && i.LastUpgradeProductionTime < minItemTime).Select(i => i.Id).ToList();

            if (!motherIds.Any())
            {
                return;
            }
            foreach (var motherId in motherIds)
            {
                var mother = motherService.GetMother(connection, motherId);
                if (_needUpdate(mother))
                {
                    var prem = storeService.GetPremiumWorkModel(connection, motherId);
                    RunUser(connection, mother, prem, motherService, motherJumpService);
                }
            }

            //Console.WriteLine("_mothershipService.SaveMother");
        }