CTT/Server/Hotfix/Game/Handler/Battle/Pvp/C2M_GetPvpBoardInfoHandler.cs

45 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Net;
namespace ET
{
[ActorMessageHandler]
public class C2M_GetPvpBoardInfoHandler : AMActorLocationRpcHandler<Unit, C2M_GetPvpBoardInfo, M2C_GetPvpBoardInfo>
{
protected override async ETTask Run(Unit unit, C2M_GetPvpBoardInfo request, M2C_GetPvpBoardInfo response, Action reply)
{
try
{
UnitScene unitScene = unit.GetComponent<UnitScene>();
if (MapHelper.GetMapType(unitScene.MapId / 100) != UnitSceneType.PersonalPvp)
{
Log.Warning($"【{UserComponent.Instance.Get(unit.Id)?.NickName}({unit.Id})】获取pvpinfo 场景错误:{unitScene.MapId}");
response.Message = "场景错误";
reply();
return;
}
PlayerData data = unit.GetComponent<PlayerData>();
List<Unit> list = PvpMap.inatance.GetLevelType(data.personalScord) switch
{
PersonalPvpType.Cupper => PvpMap.inatance.matchCupperList,
PersonalPvpType.Sliver => PvpMap.inatance.matchSliverList,
PersonalPvpType.Gold => PvpMap.inatance.matchGoldList,
_ => throw new Exception($"{PvpMap.inatance.GetLevelType(data.personalScord)} 错误"),
};
response.battleCount = data.personalPvpCount;
response.scord = data.personalScord;
response.isMatch = list.Contains(unit);
response.matchCount = list.Count;
await PvpMap.inatance.GetRankList(response.rankList);
}
catch (Exception e)
{
Log.Error(e);
}
reply();
await ETTask.CompletedTask;
}
}
}