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); }
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); }