Beispiel #1
0
        public static void SetOngoing(OngoingEvent value, bool save = true)
        {
            Ongoing = value;

            Ongoing.eventinfo = Ongoing.eventinfo ?? Database.LoadRecord("EventInfos", MongoDatabase.FilterEqual <EventInfo, string>("_id", Ongoing.name));
            if (Ongoing.eventinfo == null)
            {
                _       = Handlers.UniqueChannels.Instance.SendToLog($"{Ongoing.name} event canceled due to event info data not found");
                Ongoing = null;
            }

            if (Ongoing != null)
            {
                if (save)
                {
                    Database.UpdateRecord("Events", MongoDatabase.FilterEqual <OngoingEvent, string>("_id", "ongoing"), Ongoing);
                }

                _ = GameMaster.SendToSubscribed($"Event {Ongoing.name} has started", Ongoing.EmbedInfo());
            }
        }
Beispiel #2
0
        public static void LoadOngoing()
        {
            if (Ongoing != null)
            {
                return;
            }

            Ongoing = Database.LoadRecord("Events", MongoDatabase.FilterEqual <OngoingEvent, string>("_id", "ongoing"));

            if (Ongoing == null)
            {
                return;
            }

            Ongoing.eventinfo = Ongoing.eventinfo ?? Database.LoadRecord("EventInfos", MongoDatabase.FilterEqual <EventInfo, string>("_id", Ongoing.name));
            if (Ongoing.eventinfo == null)
            {
                _       = Handlers.UniqueChannels.Instance.SendToLog($"{Ongoing.name} event canceled due to event info data not found");
                Ongoing = null;
            }
        }
Beispiel #3
0
        static async Task EndOngoing()
        {
            if (Ongoing == null)
            {
                return;
            }

            //End the wait time
            awaitEvent?.Cancel();


            Ongoing.eventinfo.End();

            await Database.DeleteRecord <OngoingEvent>("Events", Ongoing._id);

            DateTime now = DateTime.UtcNow;

            Ongoing._id = $"Expired_{Ongoing.name}_{now.Year}/{now.Month}/{now.Day}";

            Database.SaveRecord("Events", Ongoing);

            _       = GameMaster.SendToSubscribed("Event Ended", Ongoing.EmbedInfo());
            Ongoing = null;
        }