Пример #1
0
        public IMotherJumpOut AddTaskMotherJump(IDbConnection connection, int currentUserId, string guid)
        {
            var data = TmpCache.GetAndRemove <MapDistance>(guid);

            if (data == null)
            {
                throw new Exception(Error.NoData);
            }
            var curTime = UnixTime.UtcNow();

            if (data.StartCacheTime + CACHE_TIME_SEC_JUMP < curTime)
            {
                throw new Exception(Error.DataIsOldRepeatRequest);
            }
            var inserted = _motherJumpService.AddOrUpdate(connection, new UserMotherJumpDataModel {
                CancelJump   = false,
                Completed    = false,
                EndTime      = curTime + data.Sec,
                MotherId     = currentUserId,
                StartSystem  = data.Source.System,
                StartTime    = curTime,
                TargetSystem = data.Target.System
            });


            var result = _motherJumpService.GetJumpTaskModel(connection, inserted);

            return(result);
        }
Пример #2
0
 // todo  нужен таймер отмены на серверу
 public async Task <bool> JournalRemoveGuid(string guid)
 {
     return(await _makeAsync(() =>
     {
         TmpCache.Remove(guid);
         return true;
     }));
 }
Пример #3
0
        public static Dictionary <UnitType, Dictionary <BattleStatTypes, IBattleStatsDouble> > GetUnitStatsAndMods(
            int userId, BattleTeches userTechs, BattleTeches allianceTeches, IBattleStatsDouble officerBonus,
            IBattleStatsDouble boosertsSummaryMods)
        {
            var key       = _stringGetKey(userId);
            var existData = TmpCache.Get(key);

            if (existData != null)
            {
                return((Dictionary <UnitType, Dictionary <BattleStatTypes, IBattleStatsDouble> >)existData);
            }
            boosertsSummaryMods.ConvertPercentToMod();
            var dic                      = new Dictionary <UnitType, Dictionary <BattleStatTypes, IBattleStatsDouble> >();
            var unitsStats               = UnitHelper.CreateBaseUnitStats();
            var userBaseUnitStats        = userTechs.GetBaseResultStats();
            var userProfileUnitStats     = userTechs.GetProfileResultStats();
            var allianceBaseUnitStats    = allianceTeches.GetBaseResultStats();
            var allianceProfileUnitStats = allianceTeches.GetProfileResultStats();

            foreach (var unitStats in unitsStats)
            {
                var unitTechType         = BattleTeches.UnitTypeToTechType(unitStats.Key);
                var statTypes            = new Dictionary <BattleStatTypes, IBattleStatsDouble>();
                var userUnitTechStat     = userProfileUnitStats[unitTechType];
                var allianceUnitTechStat = allianceProfileUnitStats[unitTechType];

                var summaryMod = new BattleStatsDouble(0, 0);
                summaryMod.Add(userBaseUnitStats, false);
                summaryMod.Add(userUnitTechStat, false);
                summaryMod.Add(allianceBaseUnitStats, false);
                summaryMod.Add(allianceUnitTechStat, false);
                summaryMod.Add(officerBonus, false);
                summaryMod.Add(boosertsSummaryMods, true);

                statTypes.Add(BattleStatTypes.UnitStat, unitStats.Value.DoubleStats);
                statTypes.Add(BattleStatTypes.UserTechMod, userBaseUnitStats);
                statTypes.Add(BattleStatTypes.UserUnitProfileTechMod, userUnitTechStat);
                statTypes.Add(BattleStatTypes.AllianceTechMod, allianceBaseUnitStats);
                statTypes.Add(BattleStatTypes.AllianceUnitProfileTechMod, allianceUnitTechStat);
                statTypes.Add(BattleStatTypes.OfficerBonus, officerBonus);
                statTypes.Add(BattleStatTypes.BooserMod, boosertsSummaryMods);
                statTypes.Add(BattleStatTypes.SummaryMods, summaryMod);
                dic.Add(unitStats.Key, statTypes);
            }

            TmpCache.AddOrUpdate(key, dic, _chacheTime);
            return(dic);
        }
Пример #4
0
        public MapDistance GetMotherJumpTime(IDbConnection connection, int currentUserId, int sourceSystemId, int targetSystemId)
        {
            var premium = _storeService.GetOrUpdatePremium(connection, currentUserId);

            if (sourceSystemId == targetSystemId)
            {
                throw new Exception(Error.JupmMotherIsCurrentSystem);
            }
            var curTask = _motherJumpService.GetActive(connection, currentUserId, i => i.Id);

            if (curTask != 0)
            {
                throw new Exception(Error.JumpMotherInProgress);
            }

            var dm = MapDistanceHelper.CalculateJumpTime(connection, sourceSystemId, targetSystemId, _mapAdressService,
                                                         !premium.Finished);

            dm.Guid           = Guid.NewGuid().ToString();
            dm.StartCacheTime = UnixTime.UtcNow();
            return((MapDistance)TmpCache.AddOrUpdate(dm.Guid, dm, CACHE_TIME_SEC_JUMP));
        }
        public Dictionary <string, object> Create(IDbConnection connection)
        {
            CachedPlanetCount = _gameRunner.GetPlanetIds(connection).Count;
            var resolver = _gameRunner.ServiceProvider;
            var hasWorld = resolver.GetService <IGGalaxyRepository>().HasItems(connection);

            var dic = new Dictionary <string, object>();

            dic.Add("GameConnectionName", DbProvider.AppConnectionName.ToString());
            dic.Add("WorldExists", hasWorld);
            dic.Add(nameof(CacheInitialized), CacheInitialized);
            dic.Add(nameof(NpcTaskRunnerRunned), NpcTaskRunnerRunned);
            dic.Add("SynchronizerDemonsStarted", Synchronizer.DemonsStarted);
            dic.Add(nameof(OnlineGameUsers), OnlineGameUsers);
            dic.Add(nameof(SkagryActivatedTaskCount), SkagryActivatedTaskCount);
            dic.Add(nameof(CachedPlanetCount), CachedPlanetCount);
            //demons

            dic.Add("________", "________");



            dic.Add(nameof(IAllianceLocalStorageCache), resolver.GetService <IAllianceLocalStorageCache>().GetCount());
            dic.Add(nameof(IAllianceFleetLocalStorageCache), resolver.GetService <IAllianceFleetLocalStorageCache>().GetCount());
            dic.Add(nameof(IAllianceRequestMessageLocalStorageCache), resolver.GetService <IAllianceRequestMessageLocalStorageCache>().GetCount());
            dic.Add(nameof(IAllianceRoleLocalStorageCache), resolver.GetService <IAllianceRoleLocalStorageCache>().GetCount());
            dic.Add(nameof(IAllianceTechLocalStorageCache), resolver.GetService <IAllianceTechLocalStorageCache>().GetCount());
            dic.Add(nameof(IAllianceUserLocalStorageCache), resolver.GetService <IAllianceUserLocalStorageCache>().GetCount());

            dic.Add(nameof(IGDetailMoonLocalStorageCache), resolver.GetService <IGDetailMoonLocalStorageCache>().GetCount());
            dic.Add(nameof(IGDetailPlanetLocalStorageCache), resolver.GetService <IGDetailPlanetLocalStorageCache>().GetCount());
            dic.Add(nameof(IGDetailSystemLocalStorageCache), resolver.GetService <IGDetailSystemLocalStorageCache>().GetCount());
            dic.Add(nameof(IGGalaxyLocalStorageCache), resolver.GetService <IGGalaxyLocalStorageCache>().GetCount());
            dic.Add(nameof(IGGameTypeLocalStorageCache), resolver.GetService <IGGameTypeLocalStorageCache>().GetCount());
            dic.Add(nameof(IGGeometryMoonLocalStorageCache), resolver.GetService <IGGeometryMoonLocalStorageCache>().GetCount());

            dic.Add(nameof(IGGeometryPlanetLocalStorageCache), resolver.GetService <IGGeometryPlanetLocalStorageCache>().GetCount());
            dic.Add(nameof(IGGeometryStarLocalStorageCache), resolver.GetService <IGGeometryStarLocalStorageCache>().GetCount());
            dic.Add(nameof(IGGeometrySystemLocalStorageCache), resolver.GetService <IGGeometrySystemLocalStorageCache>().GetCount());
            dic.Add(nameof(IGSectorsLocalStorageCache), resolver.GetService <IGSectorsLocalStorageCache>().GetCount());

            dic.Add(nameof(IGTextureTypeLocalStorageCache), resolver.GetService <IGTextureTypeLocalStorageCache>().GetCount());
            dic.Add(nameof(ICurrencyLocalStorageCache), resolver.GetService <ICurrencyLocalStorageCache>().GetCount());
            dic.Add(nameof(IProductStoreLocalStorageCache), resolver.GetService <IProductStoreLocalStorageCache>().GetCount());
            dic.Add(nameof(IProductTypeLocalStorageCache), resolver.GetService <IProductTypeLocalStorageCache>().GetCount());



            dic.Add(nameof(IUserBalanceCcLocalStorageCache), resolver.GetService <IUserBalanceCcLocalStorageCache>().GetCount());
            dic.Add(nameof(IUserBookmarkLocalStorageCache), resolver.GetService <IUserBookmarkLocalStorageCache>().GetCount());
            dic.Add(nameof(IJournalBuyLocalStorageCache), resolver.GetService <IJournalBuyLocalStorageCache>().GetCount());
            dic.Add(nameof(IPremiumLocalStorageCache), resolver.GetService <IPremiumLocalStorageCache>().GetCount());
            dic.Add(nameof(ITransicationCcLocalStorageCache), resolver.GetService <ITransicationCcLocalStorageCache>().GetCount());
            dic.Add(nameof(IUMotherJumpLocalStorageCache), resolver.GetService <IUMotherJumpLocalStorageCache>().GetCount());
            dic.Add(nameof(IUReportLocalStorageCache), resolver.GetService <IUReportLocalStorageCache>().GetCount());
            dic.Add(nameof(IUserChestLocalStorageCache), resolver.GetService <IUserChestLocalStorageCache>().GetCount());
            dic.Add(nameof(IUserLocalStorageCache), resolver.GetService <IUserLocalStorageCache>().GetCount());
            dic.Add(nameof(IUserMothershipLocalStorageCache), resolver.GetService <IUserMothershipLocalStorageCache>().GetCount());
            dic.Add(nameof(IUSpyLocalStorageCache), resolver.GetService <IUSpyLocalStorageCache>().GetCount());
            dic.Add(nameof(IUTaskLocalStorageCache), resolver.GetService <IUTaskLocalStorageCache>().GetCount());

            //advanced
            dic.Add("_________", "_________");
            dic.Add(nameof(TmpCache), TmpCache.GetCount());
            dic.Add(nameof(TimerExecutor), TimerExecutor.GetCount());
            dic.Add(nameof(IMainGameHubLocalStorageCache), resolver.GetService <IMainGameHubLocalStorageCache>().GetCount());
            dic.Add(nameof(IUserAuthToGameCache), resolver.GetService <IUserAuthToGameCache>().GetCount());
            dic.Add(nameof(IUserNameSercherPkCache), resolver.GetService <IUserNameSercherPkCache>().GetCount());
            dic.Add(nameof(IAlianceNameSercherPkCache), resolver.GetService <IAlianceNameSercherPkCache>().GetCount());
            dic.Add(nameof(IPlanetNameToPlanetIdPkCache), resolver.GetService <IPlanetNameToPlanetIdPkCache>().GetCount());
            dic.Add(nameof(ISystemNameSercherPkCache), resolver.GetService <ISystemNameSercherPkCache>().GetCount());



            return(dic);
        }
Пример #6
0
        public bool ClearCaches()
        {
            if (_inProgress)
            {
                return(false);
            }
            if (!_cahceInitialized)
            {
                return(true);
            }
            _inProgress = true;
            ServiceProvider.GetService <IAllianceLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IAllianceFleetLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IAllianceRequestMessageLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IAllianceRoleLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IAllianceTechLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IAllianceUserLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IGDetailMoonLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IGDetailPlanetLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IGDetailSystemLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IGGalaxyLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IGGameTypeLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IGGeometryMoonLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IGGeometryPlanetLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IGGeometryStarLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IGGeometrySystemLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IGSectorsLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IGSystemLocalStorageCache>().ClearStorage(); // почему то нет в ините
            ServiceProvider.GetService <IGTextureTypeLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <ICurrencyLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IProductStoreLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IProductTypeLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IUserBalanceCcLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IUserBookmarkLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IJournalBuyLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IPremiumLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <ITransicationCcLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IUMotherJumpLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IUReportLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IUserChestLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IUserLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IUserMothershipLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IUSpyLocalStorageCache>().ClearStorage();
            ServiceProvider.GetService <IUTaskLocalStorageCache>().ClearStorage();

            //advanced


            ServiceProvider.GetService <IMainGameHubLocalStorageCache>().ClearStorage(); //hub
            ServiceProvider.GetService <IUserAuthToGameCache>().ClearStorage();
            ServiceProvider.GetService <IUserNameSercherPkCache>().ClearStorage();
            ServiceProvider.GetService <IAlianceNameSercherPkCache>().ClearStorage();
            ServiceProvider.GetService <IPlanetNameToPlanetIdPkCache>().ClearStorage();
            ServiceProvider.GetService <ISystemNameSercherPkCache>().ClearStorage();
            TmpCache.ClearStorage();
            _planetIds.Clear();
            _onlineUsers.Clear();
            _cahceInitialized = false;
            _inProgress       = false;
            return(true);
        }