コード例 #1
0
        internal void BeginChallenge(ArenaInfo challenger, ArenaInfo target, int sign)
        {
            ChallengeInfo doing = GetDoingChallengeInfo(challenger.GetId());

            if (doing != null)
            {
                ChallengeResult(doing, false);
            }
            if (challenger.LeftFightCount <= 0)
            {
                return;
            }
            challenger.LeftFightCount -= 1;
            ChallengeInfo info = new ChallengeInfo();

            info.Sign                 = sign;
            info.Challenger           = CreateChallengeEntityInfo(challenger);
            info.Target               = CreateChallengeEntityInfo(target);
            info.IsChallengerSuccess  = false;
            info.IsDone               = false;
            info.ChallengeBeginTime   = DateTime.Now;
            info.BeginFightTime       = info.ChallengeBeginTime.AddMilliseconds(ArenaSystem.DEFAULT_READY_FIGHT_MS);
            info.ChallengeDeadLine    = info.BeginFightTime.AddMilliseconds(m_MaxFightTime + ArenaSystem.FIGHT_TIME_DEVIATION_MS);
            challenger.LastBattleTime = info.BeginFightTime.AddMilliseconds(m_MaxFightTime);
            m_DoingChallenges.Add(challenger.GetId(), info);
        }
コード例 #2
0
 internal void HandleQueryArenaInfo(ulong guid)
 {
     LogSys.Log(LOG_TYPE.DEBUG, "---got query arena info msg! id=" + guid);
     UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);
     if (user == null)
     {
         return;
     }
     JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.ArenaInfoResult);
     resultMsg.m_Guid = guid;
     ArkCrossEngineMessage.Msg_LC_ArenaInfoResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaInfoResult();
     ArenaInfo own_arena = m_ArenaSystem.GetArenaInfoById(guid);
     if (own_arena == null)
     {
         own_arena = m_ArenaSystem.CreateArenaInfo(user);
     }
     else if (own_arena.IsNeedUpdate(user))
     {
         own_arena.UpdateArenaInfo(user);
     }
     m_ArenaSystem.ResetArenaFightCount(own_arena);
     protoData.m_ArenaInfo = ArenaUtil.CreateArenaInfoMsg(own_arena, false);
     protoData.m_LeftBattleCount = own_arena.LeftFightCount;
     protoData.m_CurFightCountByTime = own_arena.FightCountBuyTime;
     long passed_time = (long)(DateTime.Now - own_arena.LastBattleTime).TotalMilliseconds;
     protoData.m_BattleLeftCDTime = m_ArenaSystem.BaseConfig.BattleCd - passed_time;
     resultMsg.m_ProtoData = protoData;
     JsonMessageDispatcher.SendDcoreMessage(user.NodeName, resultMsg);
     LogSys.Log(LOG_TYPE.DEBUG, "---send query arena info msg! id=" + guid);
 }
コード例 #3
0
 internal void HandleArenaBuyFightCount(ulong guid, int handle)
 {
     LogSys.Log(LOG_TYPE.DEBUG, "--handle arena buy fight count!");
     JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.ArenaBuyFightCountResult);
     resultMsg.m_Guid = guid;
     ArkCrossEngineMessage.Msg_LC_ArenaBuyFightCountResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaBuyFightCountResult();
     ArenaInfo own_arena = m_ArenaSystem.GetArenaInfoById(guid);
     UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);
     DataProcessScheduler scheduler = LobbyServer.Instance.DataProcessScheduler;
     protoData.CurBuyTime = 0;
     protoData.CurFightCount = 0;
     protoData.Result = (int)GeneralOperationResult.LC_Failure_Arena_NotFindTarget;
     if (own_arena != null && user != null && scheduler != null)
     {
         ArenaBuyFightCountConfig buy_config = ArenaConfigProvider.Instance.BuyFightCountConfig.GetDataById(own_arena.FightCountBuyTime + 1);
         if (user.Vip >= buy_config.RequireVipLevel && user.Gold >= buy_config.Cost)
         {
             if (own_arena.LeftFightCount < own_arena.MaxFightCount)
             {
                 own_arena.FightCountBuyTime += 1;
                 own_arena.LeftFightCount = own_arena.MaxFightCount;
                 protoData.Result = (int)GeneralOperationResult.LC_Succeed;
             }
             else
             {
                 protoData.Result = (int)GeneralOperationResult.LC_Failure_Full;
             }
             protoData.CurBuyTime = own_arena.FightCountBuyTime;
             protoData.CurFightCount = own_arena.LeftFightCount;
         }
     }
     resultMsg.m_ProtoData = protoData;
     JsonMessageDispatcher.SendDcoreMessage(handle, resultMsg);
     LogSys.Log(LOG_TYPE.DEBUG, "--send arena buy fight count result!");
 }
コード例 #4
0
 internal void HandleQueryArenaMatchGroup(ulong guid)
 {
     LogSys.Log(LOG_TYPE.DEBUG, "---got query match group msg! id=" + guid);
     UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);
     if (user == null)
     {
         return;
     }
     JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.ArenaMatchGroupResult);
     resultMsg.m_Guid = guid;
     int cur_user_rank = ArenaSystem.UNKNOWN_RANK;
     ArenaInfo arena_info = m_ArenaSystem.GetArenaInfoById(guid);
     if (arena_info != null)
     {
         cur_user_rank = arena_info.GetRank();
     };
     List<MatchGroup> match_groups = m_ArenaSystem.QueryMatchArena(cur_user_rank, 3);
     ArkCrossEngineMessage.Msg_LC_ArenaMatchGroupResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaMatchGroupResult();
     foreach (MatchGroup group in match_groups)
     {
         ArkCrossEngineMessage.Msg_LC_ArenaMatchGroupResult.MatchGroupData group_msg = new ArkCrossEngineMessage.Msg_LC_ArenaMatchGroupResult.MatchGroupData();
         group_msg.One = ArenaUtil.CreateArenaInfoMsg(group.One);
         group_msg.Two = ArenaUtil.CreateArenaInfoMsg(group.Two);
         group_msg.Three = ArenaUtil.CreateArenaInfoMsg(group.Three);
         if (group_msg.One == null || group_msg.Two == null || group_msg.Three == null)
         {
             continue;
         }
         protoData.m_MatchGroups.Add(group_msg);
     }
     resultMsg.m_ProtoData = protoData;
     JsonMessageDispatcher.SendDcoreMessage(user.NodeName, resultMsg);
     LogSys.Log(LOG_TYPE.DEBUG, "---send match group msg! id=" + guid);
 }
コード例 #5
0
ファイル: ArenaSystem.cs プロジェクト: myl2232/ArkCrossEngine
        internal bool StartChallenge(ulong challenger_guid, ulong target_guid, int sign)
        {
            ArenaInfo challenger = GetArenaInfoById(challenger_guid);

            if (challenger == null)
            {
                ErrorCode = GeneralOperationResult.LC_Failure_Arena_NotFindTarget;
                return(false);
            }
            if (challenger.IsInBattleCd())
            {
                ErrorCode = GeneralOperationResult.LC_Failure_InCd;
                return(false);
            }
            if (challenger.LeftFightCount <= 0)
            {
                ErrorCode = GeneralOperationResult.LC_Failure_NoFightCount;
                return(false);
            }
            ArenaInfo target_info = GetArenaInfoById(target_guid);

            if (target_info == null)
            {
                ErrorCode = GeneralOperationResult.LC_Failure_Arena_NotFindTarget;
                return(false);
            }
            if (challenger.GetId() == target_info.GetId())
            {
                ErrorCode = GeneralOperationResult.LC_Failure_Arena_NotFindTarget;
                return(false);
            }
            m_ChallengeManager.BeginChallenge(challenger, target_info, sign);
            return(true);
            //m_ArenaRank.ExchangeRank(cur_rank, target_info.GetRank());
        }
コード例 #6
0
        internal static int CalcTotalHp(ArenaInfo info, float coefficent)
        {
            int result = 0;

            if (info == null)
            {
                return(result);
            }
            UserArenaAttr user_attr = CalcArenaTargetAttr(info);

            if (user_attr != null)
            {
                user_attr.HpMax = (int)(user_attr.HpMax * coefficent);
                result         += user_attr.HpMax;
                //LogSys.Log(LOG_TYPE.INFO, "--user hp=" + user_attr.HpMax);
            }
            foreach (PartnerInfo partner in info.FightPartners)
            {
                UserArenaAttr partner_attr = CalcPartnerAttr(user_attr, partner);
                if (partner_attr != null)
                {
                    result += partner_attr.HpMax;
                    //LogSys.Log(LOG_TYPE.INFO, "--partner hp=" + partner_attr.HpMax);
                }
            }
            return(result);
        }
コード例 #7
0
        private void RecordChallengeAction(ArenaInfo challenger, ArenaInfo target, bool IsSuccess)
        {
            DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;

            if (null == challenger && null == target)
            {
                return;
            }
            UserInfo user1 = dataProcess.GetUserInfo(challenger.GetId());
            UserInfo user2 = dataProcess.GetUserInfo(target.GetId());

            if (null == user1 || null == user2)
            {
                return;
            }
            AccountInfo challenger_acc = dataProcess.FindAccountInfoById(user1.AccountId);

            if (null != challenger_acc)
            {
                int c_ct          = challenger.FightPartners.Count;
                int c_partner_frt = 0 < c_ct ? challenger.FightPartners[0].Id : 0;
                int c_partner_scd = 1 < c_ct ? challenger.FightPartners[1].Id : 0;
                int c_partner_thd = 2 < c_ct ? challenger.FightPartners[2].Id : 0;
                int t_ct          = target.FightPartners.Count;
                int t_partner_frt = 0 < t_ct ? target.FightPartners[0].Id : 0;
                int t_partner_scd = 1 < t_ct ? target.FightPartners[1].Id : 0;
                int t_partner_thd = 2 < t_ct ? target.FightPartners[2].Id : 0;
                /// norm log
                LogSys.NormLog("arena", LobbyConfig.AppKeyStr, challenger_acc.ClientGameVersion, Module.arena,
                               LobbyConfig.LogNormVersionStr, "C0500", challenger_acc.LogicServerId,
                               user1.AccountId, user1.Guid, user1.Level, user1.HeroId, user1.FightingScore, c_partner_frt, c_partner_scd, c_partner_thd,
                               user2.AccountId, user2.Guid, user2.Level, user2.HeroId, user2.FightingScore, t_partner_frt, t_partner_scd, t_partner_thd,
                               challenger.GetRank(), IsSuccess ? 1 : 0);
            }
        }
コード例 #8
0
ファイル: ArenaSystem.cs プロジェクト: myl2232/ArkCrossEngine
        internal List <ArenaInfo> QueryRankList(int rank)
        {
            if (!m_ArenaRank.IsRankLegal(rank))
            {
                rank = m_ArenaRank.MaxRank + 1;
            }
            List <ArenaInfo> result = new List <ArenaInfo>();
            int top_rank            = m_BaseConfig.QueryTopRankCount;
            int front_rank          = rank - m_BaseConfig.QueryFrontRankCount;
            int behind_rank         = rank + m_BaseConfig.QueryBehindRankCount;

            if (top_rank > m_ArenaRank.MaxRank)
            {
                top_rank = m_ArenaRank.MaxRank;
            }
            if (front_rank < 1)
            {
                front_rank = 1;
            }
            if (front_rank < top_rank)
            {
                front_rank = top_rank + 1;
            }
            if (behind_rank < top_rank)
            {
                behind_rank = top_rank;
            }
            if (behind_rank > m_ArenaRank.MaxRank)
            {
                behind_rank = m_ArenaRank.MaxRank;
            }
            for (int i = 1; i <= top_rank; i++)
            {
                if (i == rank)
                {
                    continue;
                }
                ArenaInfo info = m_ArenaRank.GetRankEntity(i);
                if (info != null)
                {
                    result.Add(info);
                }
            }
            for (int i = front_rank; i <= behind_rank; i++)
            {
                if (i == rank)
                {
                    continue;
                }
                ArenaInfo info = m_ArenaRank.GetRankEntity(i);
                if (info != null)
                {
                    result.Add(info);
                }
            }
            return(result);
        }
コード例 #9
0
ファイル: ArenaSystem.cs プロジェクト: myl2232/ArkCrossEngine
 internal void ResetArenaFightCount(ArenaInfo info)
 {
     if (DateTime.Now > info.FightCountResetTime)
     {
         info.FightCountResetTime = GetNextExcuteDate(m_BaseConfig.BattleCountResetTime);
         info.LeftFightCount      = m_BaseConfig.MaxBattleCount;
         info.FightCountBuyTime   = 0;
     }
 }
コード例 #10
0
ファイル: ArenaSystem.cs プロジェクト: myl2232/ArkCrossEngine
 internal void AddArenaInfo(ArenaInfo arenaInfo)
 {
     if (arenaInfo != null)
     {
         arenaInfo.BattleCD      = m_BaseConfig.BattleCd;
         arenaInfo.MaxFightCount = m_BaseConfig.MaxBattleCount;
         m_ArenaRank.SetRankEntity(arenaInfo.GetRank(), arenaInfo);
     }
 }
コード例 #11
0
ファイル: ArenaSystem.cs プロジェクト: myl2232/ArkCrossEngine
        internal ArenaInfo CreateArenaInfo(UserInfo info)
        {
            ArenaInfo result = GetArenaInfoById(info.Guid);

            if (result == null)
            {
                int max_partner_count = GetMaxPartnerCount(info.Level);
                result = new ArenaInfo(info, max_partner_count, m_BaseConfig.MaxBattleCount, m_BaseConfig.BattleCd);
                result.FightCountResetTime = GetNextExcuteDate(m_BaseConfig.BattleCountResetTime);
                m_ArenaRank.AddUnRankEntity(result);
            }
            return(result);
        }
コード例 #12
0
 internal void SaveUserArena(ulong userGuid)
 {
     ArenaInfo arenaInfo = m_ArenaSystem.GetArenaInfoById(userGuid);
     if (arenaInfo != null && arenaInfo.GetRank() == ArenaSystem.UNKNOWN_RANK)
     {
         var dsThread = LobbyServer.Instance.DataStoreThread;
         if (dsThread.DataStoreAvailable)
         {
             List<ChallengeInfo> arenaRecordList = m_ArenaSystem.QueryHistory(userGuid);
             dsThread.DSPSaveUserArena(arenaInfo, arenaRecordList);
             m_ArenaSystem.RemoveUnRankEntity(userGuid);
         }
     }
 }
コード例 #13
0
ファイル: ArenaSystem.cs プロジェクト: myl2232/ArkCrossEngine
        private void PrintRank(int rank)
        {
            ArenaInfo rank_info = m_ArenaRank.GetRankEntity(rank);

            if (rank_info != null)
            {
                LogSys.Log(LOG_TYPE.DEBUG, "RankInfo: rank={0} guid={1} nickname={2}",
                           rank_info.GetRank(), rank_info.GetId(), rank_info.NickName);
            }
            else
            {
                LogSys.Log(LOG_TYPE.DEBUG, "RankInfo: rank {0} is not set to anybody!", rank);
            }
        }
コード例 #14
0
ファイル: ArenaSystem.cs プロジェクト: myl2232/ArkCrossEngine
 //private functions--------------------------------------
 private void InitRank()
 {
     for (int i = 1; i <= m_ArenaRank.MaxRank; i++)
     {
         ArenaRobotConfig robot = ArenaConfigProvider.Instance.RobotConfig.GetDataById(i);
         if (robot != null)
         {
             int       max_partner_count = GetMaxPartnerCount(robot.Level);
             ArenaInfo arena_info        = new ArenaInfo(LobbyServer.Instance.GlobalDataProcessThread.GenerateUserGuid(), robot, max_partner_count);
             m_ArenaRank.SetRankEntity(i, arena_info);
             //LogSys.Log(LOG_TYPE.DEBUG, "ArenaSetRobot: rank={0} Guid={1} NickName={2}", i, arena_info.GetId(), arena_info.NickName);
         }
     }
 }
コード例 #15
0
ファイル: ArenaSystem.cs プロジェクト: myl2232/ArkCrossEngine
        internal void BeginFight(ulong guid)
        {
            ArenaInfo     arena = GetArenaInfoById(guid);
            ChallengeInfo info  = GetDoingChallengeInfo(guid);

            if (info != null && arena != null && info.Challenger.Guid == guid)
            {
                if (info.ChallengeBeginTime <= DateTime.Now && DateTime.Now < info.BeginFightTime)
                {
                    info.BeginFightTime    = DateTime.Now;
                    info.ChallengeDeadLine = info.BeginFightTime.AddMilliseconds(m_BaseConfig.MaxFightTime + ArenaSystem.FIGHT_TIME_DEVIATION_MS);
                    arena.LastBattleTime   = info.BeginFightTime.AddMilliseconds(m_BaseConfig.MaxFightTime);
                }
            }
        }
コード例 #16
0
        internal void HandleArenaStartChallenge(ulong guid, ulong target_guid)
        {
            LogSys.Log(LOG_TYPE.DEBUG, "---got start challenge result msg! id=" + guid);
            UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);
            if (user == null)
            {
                return;
            }
            ArenaInfo target_arena_info = m_ArenaSystem.GetArenaInfoById(target_guid);

            JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.ArenaStartChallengeResult);
            resultMsg.m_Guid = guid;
            ArkCrossEngineMessage.Msg_LC_ArenaStartCallengeResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaStartCallengeResult();
            protoData.m_TargetGuid = target_guid;
            protoData.m_Sign = new Random().Next();
            if (target_arena_info != null && target_arena_info.IsNeedUpdate(user))
            {
                target_arena_info.UpdateArenaInfo(user);
            }
            bool start_ret = m_ArenaSystem.StartChallenge(guid, target_guid, protoData.m_Sign);
            if (target_arena_info == null)
            {
                protoData.m_ResultCode = (int)GeneralOperationResult.LC_Failure_Arena_NotFindTarget;
            }
            else if (!start_ret)
            {
                protoData.m_ResultCode = (int)m_ArenaSystem.ErrorCode;
            }
            else
            {
                user.UpdateGuideFlag((int)MatchSceneEnum.Arena);
                user.CurrentState = UserState.Pve;
                protoData.m_ResultCode = (int)GeneralOperationResult.LC_Succeed;
                ChallengeInfo challenge = m_ArenaSystem.GetDoingChallengeInfo(guid);
                if (challenge != null && challenge.Target != null)
                {
                    float coefficent = ChallengeChecker.CalcPvpCoefficient(user.Level, target_arena_info.Level);
                    int total_hp = ChallengeChecker.CalcPlayerHp(target_arena_info, coefficent);
                    challenge.Target.TotalHp = total_hp;
                    //LogSys.Log(LOG_TYPE.DEBUG, "challenge target totalhp={0}", total_hp);
                }
            }
            resultMsg.m_ProtoData = protoData;
            JsonMessageDispatcher.SendDcoreMessage(user.NodeName, resultMsg);
            LogSys.Log(LOG_TYPE.DEBUG, "---send start challenge result msg! id=" + guid);
        }
コード例 #17
0
        public bool HaveMail(ModuleMailInfo moduleMailInfo, UserInfo user)
        {
            DateTime  day        = moduleMailInfo.m_SendTime;
            ArenaInfo arena_info = m_Rank.GetRankEntityById(user.Guid);

            if (arena_info == null)
            {
                return(false);
            }
            int day_rank           = arena_info.GetDaysRank(day);
            ArenaPrizeConfig prize = GetFitPrize(day_rank);

            if (prize == null)
            {
                return(false);
            }
            return(true);
        }
コード例 #18
0
        internal static int CalcPlayerHp(ArenaInfo info, float coefficent)
        {
            int result = 0;

            if (info == null)
            {
                return(result);
            }
            UserArenaAttr user_attr = CalcArenaTargetAttr(info);

            if (user_attr != null)
            {
                user_attr.HpMax = (int)(user_attr.HpMax * coefficent);
                result         += user_attr.HpMax;
                LogSys.Log(LOG_TYPE.INFO, "--user hp=" + user_attr.HpMax);
            }
            return(result);
        }
コード例 #19
0
 internal void HandleArenaQueryRank(ulong guid, int handle)
 {
     JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.ArenaQueryRankResult);
     resultMsg.m_Guid = guid;
     ArkCrossEngineMessage.Msg_LC_ArenaQueryRankResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaQueryRankResult();
     ArenaInfo cur_info = m_ArenaSystem.GetArenaInfoById(guid);
     if (cur_info != null)
     {
         List<ArenaInfo> result = m_ArenaSystem.QueryRankList(cur_info.GetRank());
         for (int i = 0; i < result.Count; i++)
         {
             protoData.RankMsg.Add(ArenaUtil.CreateArenaInfoMsg(result[i]));
         }
     }
     resultMsg.m_ProtoData = protoData;
     JsonMessageDispatcher.SendDcoreMessage(handle, resultMsg);
     LogSys.Log(LOG_TYPE.DEBUG, "send query rank list!");
 }
コード例 #20
0
        public ArkCrossEngine.ArenaPrizeConfig GetDayPrize(ulong guid, DateTime date)
        {
            ArenaPrizeConfig result = null;

            if (date > m_NextPrizeDate)
            {
                return(null);
            }
            ArenaInfo arena_info = m_Rank.GetRankEntityById(guid);

            if (arena_info == null)
            {
                return(null);
            }
            int day_rank = arena_info.GetDaysRank(date);

            result = GetFitPrize(day_rank);
            return(result);
        }
コード例 #21
0
        internal static UserArenaAttr CalcArenaTargetAttr(ArenaInfo info)
        {
            if (info == null)
            {
                return(null);
            }
            UserArenaAttr attr = CalcBaseAttr(info.HeroId, info.Level);

            CalcItemsAddAttr(attr, info.EquipInfo, true);
            List <ItemInfo> legacy_seven = ConvertToItems(info.LegacyInfo);

            CalcItemsAddAttr(attr, legacy_seven, true);
            CalcItemsAddAttr(attr, CalcComplexAttr(legacy_seven), true);
            CalcItemsAddAttr(attr, ConvertToItems(info.XSoulInfo), true);
            UserArenaAttr partner_attr = CalcPartnerAddAttr(attr, info.ActivePartner);

            attr.Add(partner_attr);
            return(attr);
        }
コード例 #22
0
ファイル: ArenaSystem.cs プロジェクト: myl2232/ArkCrossEngine
        internal void Test()
        {
            int i = -1;
            List <MatchGroup> match_groups = QueryMatchArena(i, 3);

            LogSys.Log(LOG_TYPE.DEBUG, "query rank {0} match result:", i);
            foreach (MatchGroup group in match_groups)
            {
                LogSys.Log(LOG_TYPE.DEBUG, "one: {0} two: {1} three: {2}", group.One.GetId(), group.Two.GetId(), group.Three.GetId());
            }
            ArenaRobotConfig robot       = ArenaConfigProvider.Instance.RobotConfig.GetDataById(11);
            ArenaInfo        arena_info  = new ArenaInfo(LobbyServer.Instance.GlobalDataProcessThread.GenerateUserGuid(), robot, GetMaxPartnerCount(robot.Level));
            ArenaInfo        arena_info2 = new ArenaInfo(LobbyServer.Instance.GlobalDataProcessThread.GenerateUserGuid(), robot, GetMaxPartnerCount(robot.Level));

            m_ArenaRank.AddUnRankEntity(arena_info);
            m_ArenaRank.AddUnRankEntity(arena_info2);
            PrintAllRank();
            PrintUnRankedEntities();
        }
コード例 #23
0
 internal void LoadUserArena(ulong userGuid)
 {
     ArenaInfo arenaInfo = m_ArenaSystem.GetArenaInfoById(userGuid);
     if (arenaInfo == null)
     {
         //玩家未上榜,从数据库中读取数据
         var dsThread = LobbyServer.Instance.DataStoreThread;
         if (dsThread.DataStoreAvailable)
         {
             dsThread.DSPLoadUserArena(userGuid, (DataStoreThread.DSPLoadUserArenaCB)((ret, ai, arenaRecordList) =>
             {
                 if (ret == DSLoadResult.Success)
                 {
                     m_ArenaSystem.AddArenaInfo(ai);
                     m_ArenaSystem.AddUserArenaChallenge(userGuid, arenaRecordList);
                 }
             }));
         }
     }
 }
コード例 #24
0
        internal void ChallengeResult(ChallengeInfo info, bool IsSuccess)
        {
            if (info.IsDone)
            {
                return;
            }
            ArenaInfo challenger = m_Rank.GetRankEntityById(info.Challenger.Guid);
            ArenaInfo target     = m_Rank.GetRankEntityById(info.Target.Guid);

            info.Challenger.Rank = challenger.GetRank();
            info.Target.Rank     = target.GetRank();
            if (IsSuccess && IsRankShouldChange(info.Challenger.Rank, info.Target.Rank))
            {
                m_Rank.ExchangeRank(challenger, target);
            }
            info.IsDone = true;
            info.IsChallengerSuccess = IsSuccess;
            if (IsChallengeOverTime(info))
            {
                info.ChallengeEndTime     = info.ChallengeDeadLine;
                challenger.LastBattleTime = info.ChallengeDeadLine;
            }
            else
            {
                info.ChallengeEndTime     = DateTime.Now;
                challenger.LastBattleTime = DateTime.Now;
            }
            m_DoingChallenges.Remove(challenger.GetId());
            AddChallengeHistory(info.Challenger.Guid, info);
            AddChallengeHistory(info.Target.Guid, info);
            UserInfo challenge_user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(info.Challenger.Guid);

            SendResultMsg(info, challenge_user);
            UserInfo target_user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(info.Target.Guid);

            SendResultMsg(info, target_user);
            LogSys.Log(LOG_TYPE.DEBUG, "-----send challenge result msg");
            ///
            RecordChallengeAction(challenger, target, IsSuccess);
        }
コード例 #25
0
        private ChallengeEntityInfo CreateChallengeEntityInfo(ArenaInfo arena)
        {
            ChallengeEntityInfo info = new ChallengeEntityInfo();

            info.Guid       = arena.GetId();
            info.HeroId     = arena.HeroId;
            info.Level      = arena.Level;
            info.FightScore = arena.FightScore;
            info.NickName   = arena.NickName;
            info.Rank       = arena.GetRank();
            info.UserDamage = 0;
            info.PartnerDamage.Clear();
            for (int i = 0; i < arena.FightPartners.Count; i++)
            {
                PartnerInfo partner      = arena.FightPartners[i];
                DamageInfo  damange_info = new DamageInfo();
                damange_info.OwnerId = partner.Id;
                damange_info.Damage  = 0;
                info.PartnerDamage.Add(damange_info);
            }
            return(info);
        }
コード例 #26
0
 internal void DoLastSaveGlobalData()
 {
     m_LastSaveFinished = false;
     m_NextGuidSaveCount = 0;
     m_NextMailSaveCount = 0;
     m_NextGowstarSaveCount = 0;
     m_NextArenaRankSaveCount = 0;
     m_NextArenaRecordSaveCount = 0;
     var dsThread = LobbyServer.Instance.DataStoreThread;
     if (dsThread.DataStoreAvailable)
     {
         dsThread.DSGSaveGuid(m_GuidSystem.GuidList, m_NextGuidSaveCount);
         dsThread.DSGSaveGowStar(m_GowSystem.GowStarList, m_NextGowstarSaveCount);
         dsThread.DSGSaveMail(m_MailSystem.TotalMailList, m_NextMailSaveCount);
         m_CurrentArenaRankSaveCountList.Clear();
         int rankPieceCount = dsThread.DSGSaveArenaRank(m_ArenaSystem.ArenaRankList, m_NextArenaRankSaveCount);
         m_CurrentArenaRankSaveCountList = new List<long>(rankPieceCount);
         for (int i = 0; i < rankPieceCount; ++i)
         {
             m_CurrentArenaRankSaveCountList.Add(-1);
         }
         m_CurrentArenaRecordSaveCountList.Clear();
         var challengeHistory = m_ArenaSystem.ArenaChallengeHistory;
         Dictionary<ulong, int> userRankDict = new Dictionary<ulong, int>();
         foreach (var userGuid in challengeHistory.Keys)
         {
             ArenaInfo ai = m_ArenaSystem.GetArenaInfoById(userGuid);
             userRankDict.Add(userGuid, ai.GetRank());
         }
         int recordPieceCount = dsThread.DSGSaveArenaRecord(challengeHistory, userRankDict, m_NextArenaRecordSaveCount);
         m_CurrentArenaRecordSaveCountList = new List<long>(recordPieceCount);
         for (int i = 0; i < recordPieceCount; ++i)
         {
             m_CurrentArenaRecordSaveCountList.Add(-1);
         }
     }
 }
コード例 #27
0
 internal void HandleArenaChangePartners(ulong guid, int handle, List<int> partners)
 {
     //TODO: refresh user info to arenainfo
     JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.ArenaChangePartnersResult);
     resultMsg.m_Guid = guid;
     ArkCrossEngineMessage.Msg_LC_ArenaChangePartnerResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaChangePartnerResult();
     UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);
     if (user == null)
     {
         protoData.Result = (int)GeneralOperationResult.LC_Failure_NotFinduser;
     }
     else
     {
         ArenaInfo cur_info = m_ArenaSystem.GetArenaInfoById(guid);
         int count = m_ArenaSystem.GetMaxPartnerCount(user.Level);
         if (partners.Count > count)
         {
             protoData.Result = (int)GeneralOperationResult.LC_Failure_LevelError;
         }
         else
         {
             cur_info.FightPartners.Clear();
             for (int i = 0; i < partners.Count; i++)
             {
                 int partnerid = partners[i];
                 PartnerInfo partner = user.PartnerStateInfo.GetPartnerInfoById(partnerid);
                 cur_info.FightPartners.Add(partner);
                 protoData.Partners.Add(partnerid);
             }
             protoData.Result = (int)GeneralOperationResult.LC_Succeed;
         }
     }
     resultMsg.m_ProtoData = protoData;
     JsonMessageDispatcher.SendDcoreMessage(handle, resultMsg);
     LogSys.Log(LOG_TYPE.DEBUG, "send change partners result!");
 }
コード例 #28
0
        internal static ArkCrossEngineMessage.ArenaInfoMsg CreateArenaInfoMsg(ArenaInfo entity, bool is_detail = true)
        {
            if (null == entity)
            {
                return(null);
            }
            ArkCrossEngineMessage.ArenaInfoMsg info_msg = new ArkCrossEngineMessage.ArenaInfoMsg();
            info_msg.Guid       = entity.GetId();
            info_msg.HeroId     = entity.HeroId;
            info_msg.Level      = entity.Level;
            info_msg.NickName   = entity.NickName;
            info_msg.Rank       = entity.GetRank();
            info_msg.FightScore = entity.FightScore;

            foreach (PartnerInfo partner in entity.FightPartners)
            {
                ArkCrossEngineMessage.PartnerDataMsg partner_msg = new ArkCrossEngineMessage.PartnerDataMsg();
                partner_msg.Id            = partner.Id;
                partner_msg.AdditionLevel = partner.CurAdditionLevel;
                partner_msg.SkillStage    = partner.CurSkillStage;
                info_msg.FightParters.Add(partner_msg);
            }
            if (!is_detail)
            {
                return(info_msg);
            }
            if (entity.ActivePartner != null)
            {
                ArkCrossEngineMessage.PartnerDataMsg active_partner_msg = new ArkCrossEngineMessage.PartnerDataMsg();
                active_partner_msg.Id            = entity.ActivePartner.Id;
                active_partner_msg.AdditionLevel = entity.ActivePartner.CurAdditionLevel;
                active_partner_msg.SkillStage    = entity.ActivePartner.CurSkillStage;
                info_msg.ActivePartner           = active_partner_msg;
            }

            foreach (ItemInfo item in entity.EquipInfo)
            {
                ArkCrossEngineMessage.ItemDataMsg equip = new ArkCrossEngineMessage.ItemDataMsg();
                equip.ItemId = item.ItemId;
                equip.Level  = item.Level;
                equip.Num    = item.ItemNum;
                info_msg.EquipInfo.Add(equip);
            }
            foreach (SkillDataInfo skill in entity.SkillDataInfo)
            {
                ArkCrossEngineMessage.SkillDataInfo skill_msg = new ArkCrossEngineMessage.SkillDataInfo();
                skill_msg.ID       = skill.ID;
                skill_msg.Level    = skill.Level;
                skill_msg.Postions = (int)skill.Postions.Presets[0];
                info_msg.ActiveSkills.Add(skill_msg);
            }
            foreach (ArenaItemInfo legacy in entity.LegacyInfo)
            {
                ArkCrossEngineMessage.LegacyDataMsg legacy_msg = new ArkCrossEngineMessage.LegacyDataMsg();
                legacy_msg.ItemId         = legacy.ItemId;
                legacy_msg.Level          = legacy.Level;
                legacy_msg.AppendProperty = legacy.AppendProperty;
                legacy_msg.IsUnlock       = legacy.IsUnlocked;
                info_msg.LegacyAttr.Add(legacy_msg);
            }
            foreach (ArenaXSoulInfo xsoul in entity.XSoulInfo)
            {
                ArkCrossEngineMessage.XSoulDataMsg msg = new ArkCrossEngineMessage.XSoulDataMsg();
                msg.ItemId     = xsoul.ItemId;
                msg.Level      = xsoul.Level;
                msg.Experience = xsoul.Experience;
                msg.ModelLevel = xsoul.ModelLevel;
                info_msg.XSouls.Add(msg);
            }
            return(info_msg);
        }
コード例 #29
0
        protected override void OnTick()
        {
            long curTime = TimeUtility.GetServerMilliseconds();
            if (m_LastLogTime + 60000 < curTime)
            {
                m_LastLogTime = curTime;

                DebugPoolCount((string msg) =>
                {
                    LogSys.Log(LOG_TYPE.INFO, "GlobalDataProcessThread.ActionQueue {0}", msg);
                });
            }

            m_ActivitySystem.Tick();
            m_MailSystem.Tick();
            m_GowSystem.Tick();
            m_ArenaSystem.Tick();

            //全局数据存储
            var dsThread = LobbyServer.Instance.DataStoreThread;
            if (dsThread.DataStoreAvailable)
            {
                if (curTime - m_LastGuidSaveTime > s_GuidSaveInterval && m_NextGuidSaveCount != 0)
                {
                    dsThread.DSGSaveGuid(m_GuidSystem.GuidList, m_NextGuidSaveCount);
                    m_LastGuidSaveTime = curTime;
                    m_NextGuidSaveCount++;
                }
                if (curTime - m_LastMailSaveTime > s_MailSaveInterval && m_NextMailSaveCount != 0)
                {
                    dsThread.DSGSaveMail(m_MailSystem.TotalMailList, m_NextMailSaveCount);
                    m_LastMailSaveTime = curTime;
                    m_NextMailSaveCount++;
                }
                if (curTime - m_LastGowstarSaveTime > s_GowstarSaveInterval && m_NextGowstarSaveCount != 0)
                {
                    dsThread.DSGSaveGowStar(m_GowSystem.GowStarList, m_NextGowstarSaveCount);
                    m_LastGowstarSaveTime = curTime;
                    m_NextGowstarSaveCount++;
                }
                if (curTime - m_LastArenaRankSaveTime > s_ArenaRankSaveInterval && m_NextArenaRankSaveCount != 0)
                {
                    m_CurrentArenaRankSaveCountList.Clear();
                    int pieceCount = dsThread.DSGSaveArenaRank(m_ArenaSystem.ArenaRankList, m_NextArenaRankSaveCount);
                    m_CurrentArenaRankSaveCountList = new List<long>(pieceCount);
                    for (int i = 0; i < pieceCount; ++i)
                    {
                        m_CurrentArenaRankSaveCountList.Add(-1);
                    }
                    m_LastArenaRankSaveTime = curTime;
                    m_NextArenaRankSaveCount++;
                }
                if (curTime - m_LastArenaRecordSaveTime > s_ArenaRecordSaveInterval && m_NextArenaRecordSaveCount != 0)
                {
                    m_CurrentArenaRecordSaveCountList.Clear();
                    var challengeHistory = m_ArenaSystem.ArenaChallengeHistory;
                    Dictionary<ulong, int> userRankDict = new Dictionary<ulong, int>();
                    foreach (var userGuid in challengeHistory.Keys)
                    {
                        ArenaInfo ai = m_ArenaSystem.GetArenaInfoById(userGuid);
                        userRankDict.Add(userGuid, ai.GetRank());
                    }
                    int pieceCount = dsThread.DSGSaveArenaRecord(challengeHistory, userRankDict, m_NextArenaRecordSaveCount);
                    m_CurrentArenaRecordSaveCountList = new List<long>(pieceCount);
                    for (int i = 0; i < pieceCount; ++i)
                    {
                        m_CurrentArenaRecordSaveCountList.Add(-1);
                    }
                    m_LastArenaRecordSaveTime = curTime;
                    m_NextArenaRecordSaveCount++;
                }
                if (m_CurrentGuidSaveCount == 0 && m_CurrentMailSaveCount == 0 && m_CurrentGowstarSaveCount == 0
                  && CheckLastSaveArenaRankDone() && CheckLastSaveArenaRecordDone())
                {
                    if (m_LastSaveFinished == false)
                    {
                        //全局数据(Guid、战神赛排行榜,邮件,竞技场排行榜,竞技场战斗记录)存储完成 
                        LogSys.Log(LOG_TYPE.MONITOR, "GlobalDataProcessThread DoLastSaveGlobalData Done!");
                        m_LastSaveFinished = true;
                    }
                }
            }
        }