63 lines
1.9 KiB
C#
63 lines
1.9 KiB
C#
using System;
|
|
using asap.core;
|
|
using cfg;
|
|
using GameCore;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace Activity
|
|
{
|
|
public interface IEventData
|
|
{
|
|
public int EventID { get; set; }
|
|
public float InflationRate { get; set; }
|
|
public int VipLevel { get; set; }
|
|
public bool IsActive { get; }
|
|
TimeSpan RemainingTime { get; }
|
|
FishingEvent FishingEvent { get; set; }
|
|
}
|
|
|
|
public abstract class AEventData : IEventData
|
|
{
|
|
public int EventID { get; set; }
|
|
public float InflationRate { get; set; }
|
|
public int VipLevel { get; set; }
|
|
public virtual void RefreshCache()
|
|
{
|
|
}
|
|
|
|
#region jsonIgnore
|
|
|
|
[JsonIgnore] public virtual bool IsActive => EventID > 0 && RemainingTime.TotalSeconds > 0;
|
|
[JsonIgnore] private Tables _tables;
|
|
|
|
[JsonIgnore] public Tables Tables => _tables ??= GContext.container.Resolve<Tables>();
|
|
[JsonIgnore]
|
|
private FishingEvent _fishingEvent;
|
|
|
|
[JsonIgnore]
|
|
public FishingEvent FishingEvent
|
|
{
|
|
get =>_fishingEvent??=Tables.TbFishingEvent.GetOrDefault(EventID);
|
|
set=> _fishingEvent=value;
|
|
}
|
|
|
|
[JsonIgnore]
|
|
public FishingEventCycleItem CycleItem =>
|
|
Tables.TbFishingEventCycleItem.GetOrDefault(FishingEvent?.RedirectID ?? 0);
|
|
|
|
[JsonIgnore] public DateTime EndTime => GContext.container.Resolve<FishingEventData>().GetEventEndTime(EventID);
|
|
[JsonIgnore]
|
|
private DateTime StartTime
|
|
{
|
|
get
|
|
{
|
|
if (FishingEvent?.TimeDefinition is not LimitedTime limitedTime || string.IsNullOrEmpty(limitedTime.StartTime))
|
|
return DateTime.MinValue;
|
|
return GlobalUtils.TryParseDateTime(limitedTime.StartTime, DateTime.MinValue);
|
|
}
|
|
}
|
|
[JsonIgnore] public TimeSpan RemainingTime => EndTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
|
|
|
#endregion
|
|
}
|
|
} |