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