コード例 #1
0
        private void InternalProcessAllyRecord(int count, string mapId)
        {
            var group = this._site.InitArmyGroup();

            foreach (var gc in group.CharaInfoVoList)
            {
                var c = CharacterCache.GetCharByNo(gc.CharaNo);
                if (c != null && c.Id != this._site.CurrentCharId)
                {
                    var allyBattleList = this._site.BattleArmyRecord(gc.CharaNo);
                    for (var i = 0; i < count; i++)
                    {
                        BattleResult battle     = allyBattleList[i];
                        BattleResult prevBattle = i > 0 ? allyBattleList[i - 1] : null;
                        GenerateBattleChars(battle, true, prevBattle != null ? prevBattle.LifeAfter : null);
                        GenerateBattleTurns(battle, true);

                        var  cd     = CharacterDynamicCache.TryGetValue(c.Id, CharacterDynamicCache.LoadDynamic);
                        bool addExp = i == count - 1;
                        UpdateCharDynamic(battle, cd, mapId, addExp);

                        if (this.OnBattleComplete != null)
                        {
                            battle.TotalCount = cd.BattleLevelTotalCount;
                            battle.EPM        = cd.EPM;

                            this.OnBattleComplete(c.Id, battle);
                        }
                    }
                    BattleScheduler.ResultDic[c.Id] = allyBattleList.Take(count).ToList();
                }
            }
        }
コード例 #2
0
        public void Initialize()
        {
            this.charId = GetQuery <string>("id");

            if (!string.IsNullOrEmpty(this.charId) && this.charId != this._site.CurrentCharId)
            {
                this._site.CurrentCharId = this.charId;
                this._site.Config        = CharacterConfigCache.TryGetValue(this.charId, CharacterConfigCache.LoadConfig);
                this._site.Dynamic       = CharacterDynamicCache.TryGetValue(this.charId, CharacterDynamicCache.LoadDynamic);
                this.IsReadOnly          = true;
            }

            LoadFromCurrentChar();
        }
コード例 #3
0
        private void ParseCookies(IOwinRequest request)
        {
            var charId = request.Cookies["charaId"];

            if (!string.IsNullOrEmpty(charId))
            {
                _site.CurrentCharId = charId;
                _site.Config        = CharacterConfigCache.TryGetValue(charId, CharacterConfigCache.LoadConfig);
                _site.Dynamic       = CharacterDynamicCache.TryGetValue(charId, CharacterDynamicCache.LoadDynamic);
                _site.FilterConfig  = ItemFilterCache.TryGetValue(charId, ItemFilterCache.LoadConfig);

                string ip = GetRealIP();
                if (!_site.Config.IPList.Contains(ip))
                {
                    _site.Config.IPList.Add(ip);
                    CharacterConfigCache.SaveConfig(_site.Config);
                }
            }
        }
コード例 #4
0
        public override void Execute()
        {
            var allMaps     = this._site.InitAllMaps();
            var dynamicList = CharacterDynamicCache.LoadAllDynamics();

            foreach (var cd in dynamicList)
            {
                foreach (var mi in cd.ItemList)
                {
                    var map = allMaps.FirstOrDefault(p => p.MapId == mi.Key);
                    if (map != null)
                    {
                        foreach (var item in mi.Value)
                        {
                            if (!map.ItemsVoList.ContainsKey(item.Key))
                            {
                                map.ItemsVoList[item.Key] = item.Value;
                            }
                        }
                    }
                }
            }

            var cfgList = CharacterConfigCache.LoadAllConfigs();

            foreach (var cfg in cfgList)
            {
                InfinityServerSite site = new InfinityServerSite(this._site.Uri, this.Request, this.Response);
                site.CurrentCharId = cfg.CharId;
                site.Config        = CharacterConfigCache.TryGetValue(cfg.CharId, CharacterConfigCache.LoadConfig);
                site.Dynamic       = CharacterDynamicCache.TryGetValue(cfg.CharId, CharacterDynamicCache.LoadDynamic);
                site.FilterConfig  = ItemFilterCache.TryGetValue(cfg.CharId, ItemFilterCache.LoadConfig);
                try
                {
                    site.InitChar();

                    var group = site.InitArmyGroup();

                    if (cfg.IsGuaji)
                    {
                        if (group == null)
                        {
                            BattleScheduler.AddChar(site);
                        }
                        else
                        {
                            site.Config.IsGuaji = false;
                            CharacterConfigCache.SaveConfig(site.Config);
                        }
                    }
                    if (cfg.IsDungeonGuaji)
                    {
                        if (group != null)
                        {
                            if (site.CheckIsGroupCaption())
                            {
                                BattleScheduler.AddChar(site, true);
                            }
                            else
                            {
                                site.Config.IsDungeonGuaji = false;
                                CharacterConfigCache.SaveConfig(site.Config);
                            }
                        }
                    }
                }
                catch { }
            }

            Response.WriteAsync(JsonUtil.Serialize(new { }));
        }