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();
                }
            }
        }
Exemplo n.º 2
0
        public override void Execute()
        {
            this._site.Dynamic.BattleDungeonLevelTotalCount = 0;
            this._site.Dynamic.BattleDungeonLevelTotalExp   = 0;
            this._site.Dynamic.BattleDungeonLevelTotalWait  = 0;
            this._site.Dynamic.BattleDungeonLevelWinCount   = 0;
            CharacterDynamicCache.SaveDynamic(this._site.Dynamic);

            Response.WriteAsync(JsonUtil.Serialize(new { }));
        }
        public override void Execute()
        {
            var dynamicList = CharacterDynamicCache.LoadAllDynamics();

            foreach (var cd in dynamicList)
            {
                cd.ItemList = new Dictionary <string, Dictionary <string, MapItem> >();

                CharacterDynamicCache.SaveDynamic(cd);
            }

            Response.WriteAsync(JsonUtil.Serialize(new { }));
        }
Exemplo n.º 4
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();
        }
        public static List <Character> GetAllCharsBySpeed()
        {
            var cList  = GetAll();
            var cdList = CharacterDynamicCache.GetAll();

            foreach (var c in cList)
            {
                var cd = cdList.FirstOrDefault(x => x.CharId == c.Id);
                if (cd != null)
                {
                    c.EPM = cd.EPM;
                }
            }

            return(cList.OrderByDescending(p => p.EPM).ToList());
        }
        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);
                }
            }
        }
Exemplo n.º 7
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 { }));
        }
        private void UpdateCharDynamic(BattleResult battle, CharacterDynamic cd, string mapId, bool addExp = true)
        {
            cd.BattleTotalWait += battle.Wait;

            if (this._isDungeon)
            {
                cd.BattleDungeonTotalCount++;
                cd.BattleDungeonLevelTotalCount++;
                cd.BattleDungeonLevelTotalWait += battle.Wait;
            }
            else
            {
                cd.BattleTotalCount++;
                cd.BattleLevelTotalCount++;
                cd.BattleLevelTotalWait += battle.Wait;
            }

            if (addExp)
            {
                cd.BattleTotalExp += battle.DropExp;

                if (this.IsDungeon)
                {
                    cd.BattleDungeonLevelTotalExp += battle.DropExp;
                }
                else
                {
                    cd.BattleLevelTotalExp += battle.DropExp;
                }

                CharacterActivityCache.ClearCache(cd.CharId);

                if (battle.UpgradeLev == true)
                {
                    CharacterCache.ClearCache(cd.CharId);
                }
            }

            if (battle.Success == true)
            {
                if (this._isDungeon)
                {
                    cd.BattleDungeonWinCount++;
                    cd.BattleDungeonLevelWinCount++;
                }
                else
                {
                    cd.BattleWinCount++;
                    cd.BattleLevelWinCount++;
                }
            }

            if (battle.GameItemsList != null)
            {
                var allMaps = this._site.InitAllMaps();
                if (!string.IsNullOrEmpty(mapId))
                {
                    Map map = allMaps.FirstOrDefault(p => p.MapId == mapId);

                    foreach (var item in battle.GameItemsList)
                    {
                        MapItem mi = MapItem.FromItem(item);
                        cd.AppendItem(mapId, mi);

                        if (map != null)//&& !map.ItemsVoList.ContainsKey(mi.ItemId))
                        {
                            map.ItemsVoList[mi.ItemId] = mi;
                        }
                    }
                }
            }

            CharacterDynamicCache.SaveDynamic(cd);
        }