Ejemplo n.º 1
0
        void StopEvent()
        {
            if (RunningEvent == null)
            {
                return;
            }
            var eventHadHeader = RunningEvent.ScrollingHeader != "";

            Program.MainForm.LogAppend("Stopping event...");
            RunningEvent = null;
            GameServers.ForEach(x =>
            {
                x.Value.ResetRates();
                if (eventHadHeader)
                {
                    var p = new Packet(ISServerMessages.WSE_ChangeScrollingHeader);
                    p.WriteString("");
                    x.Value.ActiveServerConnection?.SendPacket(p);
                }
            });
        }
Ejemplo n.º 2
0
        public void CheckForEvents()
        {
            var currentDate = MasterThread.CurrentDate;

            if (RunningEvent != null)
            {
                // Not yet expired
                if (RunningEvent.EndTime >= currentDate)
                {
                    return;
                }

                StopEvent();
            }

            foreach (var @event in Events)
            {
                if (@event.StartTime <= currentDate && @event.EndTime >= currentDate)
                {
                    Program.MainForm.LogAppend("Starting event '{0}'", @event.Name);

                    GameServers.ForEach(x =>
                    {
                        x.Value.SetRates(@event.ExpRate, @event.DropRate, @event.MesoRate, true);

                        if (!string.IsNullOrEmpty(@event.ScrollingHeader))
                        {
                            var p = new Packet(ISServerMessages.WSE_ChangeScrollingHeader);
                            p.WriteString(@event.ScrollingHeader);
                            x.Value.ActiveServerConnection?.SendPacket(p);
                        }
                    });
                    RunningEvent = @event;

                    break;
                }
            }
        }