CTT/Server/Hotfix/Game/Handler/Other/C2M_StartActiveHandler.cs

47 lines
1.5 KiB
C#
Raw Normal View History

2021-05-05 13:36:19 +08:00
using System;
using System.Collections.Generic;
using Cal.DataTable;
namespace ET
{
public class ActiveArgs
{
public Unit unit;
public string[] param;
}
[ActorMessageHandler]
2021-09-07 16:20:46 +08:00
public class C2M_StartActiveHandler: AMActorLocationRpcHandler<Unit, C2M_StartActive, M2C_StartActive>
2021-05-05 13:36:19 +08:00
{
protected override async ETTask Run(Unit unit, C2M_StartActive request, M2C_StartActive response, Action reply)
{
ActivePerDayConfig activePerDayConfig = ActivePerDayConfigCategory.Instance.Get(request.itemId);
if (activePerDayConfig == null)
{
Log.Error($"{unit.Id.GetPlayerFormatName()} 活动Id错误{request.itemId}");
response.Message = "系统错误";
reply();
return;
}
int weekDay = (int) DateTime.Today.DayOfWeek;
if (!activePerDayConfig.Day.As<IList<int>>().Contains(weekDay))
{
Log.Error($"{unit.Id.GetPlayerFormatName()} 活动日期错误:{activePerDayConfig.Day.ToCustomString()} today = {weekDay}");
response.Message = "系统错误";
reply();
return;
}
2021-09-07 16:20:46 +08:00
var ret = await GlobalMethodHelper.Call(activePerDayConfig.BattleMethod,
new ActiveArgs { unit = unit, param = activePerDayConfig.Params });
if (ret != null)
2021-05-05 13:36:19 +08:00
{
2021-09-07 16:20:46 +08:00
response.Message = ret;
}
2021-05-05 13:36:19 +08:00
reply();
await ETTask.CompletedTask;
}
}
2021-09-07 16:20:46 +08:00
}