Exemple #1
0
        static ManagerInput BuildTransferManager(Guid managerId, bool isNpc)
        {
            LocalTransferManagerEntity localTransferManager = null;

            LocalManagerDic.TryGetValue(managerId, out localTransferManager);
            if (localTransferManager != null)
            {
                return(LocalManagerHelper.BuildTransfer(localTransferManager));
            }
            else
            {
                return(MatchTransferUtil.BuildTransferManager(new MatchManagerInfo(managerId, isNpc)));
            }
        }
        public static ManagerInput BuildTransfer(LocalTransferManagerEntity localManager)
        {
            var buffView = GetMemberView(localManager);

            var dstData = new ManagerInput();

            dstData.Mid       = LocalHelper.BuildLocalManagerId(localManager.Id);
            dstData.Logo      = "1";
            dstData.Name      = localManager.Name;
            dstData.FormId    = localManager.FormationId;
            dstData.FormLv    = localManager.FormationLevel;
            dstData.Skills    = buffView.LiveSkillList;
            dstData.SubSkills = buffView.SubSkills;

            MatchTransferUtil.BuildManagerData(dstData, buffView, 0, 100);

            return(dstData);
        }
Exemple #3
0
        void InitCache()
        {
            try
            {
                LogHelper.Insert("npc dic cache init start", LogType.Info);
                List <DicNpcEntity> list = null;
                if (ShareUtil.IsCross)
                {
                    list = DicNpcMgr.GetAllForCross();
                }
                else
                {
                    list = DicNpcMgr.GetAll();
                }
                _dicNpc              = new Dictionary <Guid, DicNpcEntity>();
                _transferManagerDic  = new Dictionary <Guid, ManagerInput>(list.Count);
                _fightManagerinfoDic = new Dictionary <Guid, Match_FightManagerinfo>(list.Count);
                _dicBuffView         = new Dictionary <Guid, DTOBuffMemberView>(list.Count);
                foreach (var entity in list)
                {
                    var buffView = NpcDataHelper.GetMemberView(entity);
                    _dicNpc.Add(entity.Idx, entity);
                    _dicBuffView.Add(entity.Idx, buffView);
                    _transferManagerDic.Add(entity.Idx, MatchTransferUtil.BuildTransferNpc(entity, buffView));
                    _fightManagerinfoDic.Add(entity.Idx, MatchDataHelper.GetFightinfo(entity, buffView, true));
                }

                _guidePlayers = new List <PlayerInput>();
                var guideConfig = CacheFactory.AppsettingCache.GetAppSetting(EnumAppsetting.TourGuidePlayers);
                var ssss        = guideConfig.Split('|');
                foreach (var ss in ssss)
                {
                    var s = ss.Split(',');
                    _guidePlayers.Add(MatchTransferUtil.BuildPlayerInputForGuide(Convert.ToInt32(s[0]), Convert.ToInt32(s[1]), s[2]));
                }
                LogHelper.Insert("npc dic cache init end", LogType.Info);
            }
            catch (Exception ex)
            {
                LogHelper.Insert(ex);
            }
        }
Exemple #4
0
        void HandleMatch(BaseMatchData matchData, MatchStateCallback callback, object matchState = null)
        {
            MatchInput transferMatchEntity = null;

            try
            {
                transferMatchEntity = MatchTransferUtil.BuildTransferMatch(matchData);
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("MatchCore:HandleSingle-TransferMatchDataModel", string.Format("MatchType:{0}", matchData.MatchType), ex);
                matchData.ErrorCode = (int)MessageCode.MatchCreateFail;
                return;
            }

            if (null == transferMatchEntity || null == transferMatchEntity.HomeManager || null == transferMatchEntity.AwayManager)
            {
                matchData.ErrorCode = (int)MessageCode.MatchCreateFail;
            }
            else
            {
                byte[] process = null;
                try
                {
                    if (matchData.Home.ManagerId == new Guid("BC214997-FB0B-41D3-A3AC-A58B00B092D8") || matchData.Away.ManagerId == new Guid("BC214997-FB0B-41D3-A3AC-A58B00B092D8"))
                    {
                        LogHelper.Insert("LeagueMatch Id1 " + matchData.MatchId, LogType.Info);
                    }

                    process = Exec(matchData, transferMatchEntity);
                }
                catch (Exception ex)
                {
                    SystemlogMgr.Error("MatchCore:HandleSingle-Exec", ex);
                }

                if (matchData.ErrorCode == (int)MessageCode.Success && process != null)
                {
                    try
                    {
                        MemcachedFactory.MatchClient.Set <BaseMatchData>(matchData.MatchId, matchData);
                        if (!s_noCacheMatchTypes.ContainsKey((EnumMatchType)matchData.MatchType))
                        {
                            MemcachedFactory.MatchProcessClient.Set <byte[]>(matchData.MatchId, process);
                        }
                        if (s_DbMatchTypes.ContainsKey((EnumMatchType)matchData.MatchType))
                        {
                            MatchDataCore.Instance.SaveProcess(matchData.MatchId, matchData.MatchType, process, matchData.RowTime);
                        }
                        if (callback != null)
                        {
                            matchData.ErrorCode = (int)callback(matchData, matchState);
                            if (matchData.ErrorCode != 0)
                            {
                                LogHelper.Insert(string.Format("match callback fail,matchId:{0},errorCode:{1},home:{2},away:{3}", matchData.MatchId, matchData.ErrorCode, matchData.Home.Name, matchData.Away.Name), LogType.Info);
                            }
                        }
                        //MatchReward
                        if (matchData.ErrorCode == 0 && ShareUtil.IsAppRXYC && CheckRewardMatchType(matchData.MatchType))
                        {
                            Guid   mid  = (matchData.Home.IsNpc || matchData.Home.IsBot) ? matchData.Away.ManagerId : matchData.Home.ManagerId;
                            string key  = string.Concat(mid, ".", matchData.MatchType).ToLower();
                            var    data = new DTOMatchRewardState()
                            {
                                MatchId = matchData.MatchId, Coin = -1, Point = -1
                            };
                            MemcachedFactory.MatchRewardClient.Set(key, data);
                        }
                        return;
                    }
                    catch (Exception ex)
                    {
                        SystemlogMgr.Error("MatchCore:HandleSingle-Save", ex);
                        matchData.ErrorCode = (int)MessageCode.MatchCreateFail;
                    }
                }
                else
                {
                    matchData.ErrorCode = (int)MessageCode.MatchCreateFail;
                }
            }
            MemcachedFactory.MatchClient.Set <BaseMatchData>(matchData.MatchId, matchData);
        }