public static void StartEvent() { if (ActiveEvent == null) { return; } foreach (var registeredClient in EventManager.GetRegisteredClients()) { Story story = new Story(Guid.NewGuid().ToString()); StoryBuilderSegment segment = StoryBuilder.BuildStory(); StoryBuilder.AppendSaySegment(segment, $"This event is... {ActiveEvent.Name}!", -1, 0, 0); StoryBuilder.AppendSaySegment(segment, ActiveEvent.IntroductionMessage, -1, 0, 0); foreach (var rule in ActiveEvent.Rules) { StoryBuilder.AppendSaySegment(segment, rule, -1, 0, 0); } if (ActiveEvent.Duration.HasValue) { StoryBuilder.AppendSaySegment(segment, $"The event will end in {ActiveEvent.Duration.Value.TotalMinutes} minutes.", -1, 0, 0); } if (Main.IsTestingEvent) { StoryBuilder.AppendSaySegment(segment, $"This event is currently being tested and winners will not receive any prizes.", -1, 0, 0); } else if (!string.IsNullOrEmpty(ActiveEvent.RewardMessage)) { StoryBuilder.AppendSaySegment(segment, ActiveEvent.RewardMessage, -1, 0, 0); } StoryBuilder.AppendSaySegment(segment, "The event has now begun!", -1, 0, 0); segment.AppendToStory(story); StoryManager.PlayStory(registeredClient, story); } ActiveEvent.Start(); var eventStartMessage = new StringBuilder(); if (Main.IsTestingEvent) { eventStartMessage.Append("[Testing] "); } eventStartMessage.Append($"{ActiveEvent.Name} has started!"); Task.Run(() => DiscordManager.Instance.SendAnnouncement(eventStartMessage.ToString())); Messenger.SendAnnouncement("Weekly Event", eventStartMessage.ToString()); if (ActiveEvent.Duration.HasValue) { var endTime = DateTime.UtcNow.Add(ActiveEvent.Duration.Value); SetGlobalCountdown(new Countdown("The event ends in...", endTime)); TimedEventManager.CreateTimer("endevent", endTime, null); } }
public static void FinishEvent() { if (ActiveEvent != null) { ActiveEvent.AnnounceWinner(); ActiveEvent = null; EventManager.ActiveEventIdentifier = null; TimedEventManager.CreateTimer("eventdeschedule", DateTime.UtcNow.AddDays(1), null); } EventManager.RegisteredCharacters.Clear(); }