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

46 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using Cal.DataTable;
namespace ET
{
public class ActiveArgs
{
public Unit unit;
public string[] param;
}
[ActorMessageHandler]
public class C2M_StartActiveHandler : AMActorLocationRpcHandler<Unit, C2M_StartActive, M2C_StartActive>
{
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;
}
await GlobalMethodHelper.Call(activePerDayConfig.BattleMethod,new ActiveArgs
{
unit = unit,param = activePerDayConfig.Params
});
reply();
await ETTask.CompletedTask;
}
}
}