using System; using asap.core; using cfg; using GameCore; using Newtonsoft.Json; namespace game { public interface IEventData { public int EventID { get; set; } public void SetData(IEventData data); public float InflationRate { get; set; } } public abstract class AEventData : IEventData { public int EventID { get; set; } public float InflationRate{get; set;} public virtual void SetData(IEventData data) { EventID = data.EventID; InflationRate=data.InflationRate; } public virtual void RefreshCache() { } #region jsonIgnore [JsonIgnore] public virtual bool IsActive => EventID > 0 && RemainingTime.TotalSeconds > 0&&StartTime<=ZZTimeHelper.UtcNow(); [JsonIgnore] private Tables _tables; [JsonIgnore] public Tables Tables => _tables ??= GContext.container.Resolve(); [JsonIgnore] public FishingEvent FishingEvent => Tables.TbFishingEvent.GetOrDefault(EventID); [JsonIgnore] public FishingEventCycleItem CycleItem => Tables.TbFishingEventCycleItem.GetOrDefault(FishingEvent?.RedirectID ?? 0); [JsonIgnore] public DateTime EndTime => GContext.container.Resolve().GetEventEndTime(EventID); [JsonIgnore] private DateTime StartTime => DateTime.Parse((FishingEvent.TimeDefinition as LimitedTime)?.StartTime); [JsonIgnore] public TimeSpan RemainingTime => EndTime - ZZTimeHelper.UtcNow().UtcNowOffset(); #endregion } }