コード例 #1
0
        public override void Execute()
        {
            var army = this._site.InitArmyGroup();

            if (army != null)
            {
                bool isCaption = this._site.CheckIsGroupCaption();

                this._site.ArmyGroupLeave();

                foreach (var c in army.CharaInfoVoList)
                {
                    var gc = CharacterCache.GetCharByNo(c.CharaNo);
                    if (gc != null)
                    {
                        CharacterArmyGroupCache.ClearCache(gc.CharaId);
                        AllMapCache.ClearCache(gc.CharaId);
                    }
                }

                if (isCaption)
                {
                    CharacterConfigCache.CancelDungeonGuaji(this._site.Config);
                }
            }

            Response.WriteAsync(JsonUtil.Serialize(new { }));
        }
コード例 #2
0
        public override void Execute()
        {
            string aid = GetQuery("aid");

            this._site.ArmyGroupJoin(aid);

            CharacterConfigCache.CancelGuaji(this._site.Config);

            CharacterArmyGroupCache.ClearCache(this._site.CurrentCharId);
            var army = this._site.InitArmyGroup();

            if (army != null)
            {
                foreach (var c in army.CharaInfoVoList)
                {
                    var gc = CharacterCache.GetCharByNo(c.CharaNo);
                    if (gc != null && gc.CharaId != this._site.CurrentCharId)
                    {
                        CharacterArmyGroupCache.ClearCache(gc.CharaId);
                    }
                }
            }

            Response.WriteAsync(JsonUtil.Serialize(new { }));
        }
コード例 #3
0
        private void LoadFromCurrentChar()
        {
            this.Character        = this._site.CurrentChar;
            this.CharacterDynamic = this._site.Dynamic;
            this.CharEquipList    = this._site.InitCharEquips();
            this.AllSkillList     = this._site.InitCharSkills();
            this.MapList          = this._site.InitAllSingleMaps();
            this.DungeonMapList   = this._site.InitAllDungeonMaps();
            //this.MarketItems = this._site.InitMarket();
            this.ArmyGroup  = this._site.InitArmyGroup();
            this.RealmBonus = this._site.InitRealmBonus();

            this.CurrentMap = this.MapList.FirstOrDefault(p => p.MapId == this._site.Config.CurrentMapId);
            if (this.CurrentMap == null)
            {
                this.CurrentMap = this.MapList.FirstOrDefault();
                this.Site.Config.CurrentMapId = this.CurrentMap.MapId;
                CharacterConfigCache.SaveConfig(this.Site.Config);
            }

            this.CurrentDungeonMap = this.DungeonMapList.FirstOrDefault(p => p.MapId == this._site.Config.CurrentDungeonMapId);
            if (this.CurrentDungeonMap == null)
            {
                this.CurrentDungeonMap = this.DungeonMapList.FirstOrDefault();
                this.Site.Config.CurrentDungeonMapId = this.CurrentDungeonMap.MapId;
                CharacterConfigCache.SaveConfig(this.Site.Config);
            }
        }
コード例 #4
0
        public override void Execute()
        {
            this._site.Config.CurrentDungeonMapId = GetQuery("id");

            CharacterConfigCache.SaveConfig(this._site.Config);

            Response.WriteAsync(JsonUtil.Serialize(new { }));
        }
コード例 #5
0
        public override void Execute()
        {
            BattleScheduler.CancelChar(this._site.CurrentCharId);

            this._site.Config.IsDungeonGuaji = false;
            CharacterConfigCache.SaveConfig(this._site.Config);

            Response.WriteAsync(JsonUtil.Serialize(new { }));
        }
コード例 #6
0
        public override void Execute()
        {
            string name = GetQuery <string>("name");

            this._site.ArmyGroupCreate(name);

            CharacterArmyGroupCache.ClearCache(this._site.CurrentCharId);
            CharacterConfigCache.CancelGuaji(this._site.Config);

            Response.WriteAsync(JsonUtil.Serialize(new { }));
        }
コード例 #7
0
        /// <summary>
        ///
        /// </summary>
        private void InternalStart()
        {
            try
            {
                int tryTimes = 0;

                while (!_token.IsCancellationRequested) //直到人工取消/出错之前一直运行
                {
                    int sleepTime = 0;

                    try
                    {
                        sleepTime = InternalBattle();


                        //判断一下是否人工取消
                        _token.ThrowIfCancellationRequested();
                    }
                    catch (OperationCanceledException) { } //人工取消
                    catch (Exception ex)
                    {
                        Logger.Error(string.Format("CharNo={0},Name={1},MapId={2},Error={3}", this._site.CurrentChar.AccountId, this._site.CurrentChar.Name, this._site.Config.CurrentMapId, ex.Message));
                        this.OnError(this._charId, ex.Message);

                        if (tryTimes < 10)
                        {
                            sleepTime = 10 * (tryTimes + 1) * 1000; //等10秒重试,而不是简单地退出
                            tryTimes++;
                        }
                        else
                        {
                            throw;
                        }
                    }

                    if (sleepTime > 0) //如果是手动取消,这里是0
                    {
                        //SpinWait.SpinUntil(() => _token.IsCancellationRequested, sleepTime);
                        Thread.Sleep(sleepTime);
                    }
                }
            }
            catch (ThreadAbortException) { } //IIS关闭,强行中止线程
            catch (Exception ex)
            {
                Logger.Error(string.Format("CharNo={0},Name={1},MapId={2},Error={3}", this._site.CurrentChar.AccountId, this._site.CurrentChar.Name, this._site.Config.CurrentMapId, ex.ToString()));
                this.OnError(this._charId, ex.Message);

                BattleScheduler.CancelChar(this._charId);
                this._site.Config.IsGuaji = false;
                CharacterConfigCache.SaveConfig(this._site.Config);
            }
        }
コード例 #8
0
        public override void Execute()
        {
            if (string.IsNullOrEmpty(this._site.Config.CurrentMapId))
            {
                this._site.Config.CurrentMapId = this._site.InitAllSingleMaps().FirstOrDefault().MapId;
            }

            BattleScheduler.AddChar(this._site);

            this._site.Config.IsGuaji = true;
            CharacterConfigCache.SaveConfig(this._site.Config);

            Response.WriteAsync(JsonUtil.Serialize(new { }));
        }
コード例 #9
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();
        }
コード例 #10
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);
                }
            }
        }
コード例 #11
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 { }));
        }