Example #1
0
 private void OnChannelMessageEvent(BotShell bot, ChannelMessageArgs e)
 {
     if (e.Type != ChannelType.Organization)
     {
         return;
     }
     if (!e.IsDescrambled)
     {
         return;
     }
     if (e.Descrambled.CategoryID != 1001)
     {
         return;
     }
     switch (e.Descrambled.EntryID)
     {
     case 1:     // %s turned the cloaking device in your city %s.
         this._time     = DateTime.Now;
         this._username = e.Descrambled.Arguments[0].Text;
         //this._sentAnnounce = false;
         //this._sentPreAnnounce = false;
         //this._sentPostAnnounce = false;
         this._reminders = VhCityRemindState.Waiting;
         if (e.Descrambled.Arguments[1].Text.Equals("on", StringComparison.CurrentCultureIgnoreCase))
         {
             this._state = VhCityState.Enabled;
             this.SendMessage(bot, HTML.CreateColorString(bot.ColorHeaderHex, this._username) + " has " + HTML.CreateColorString(RichTextWindow.ColorGreen, "enabled") + " the city cloaking device");
         }
         else if (e.Descrambled.Arguments[1].Text.Equals("off", StringComparison.CurrentCultureIgnoreCase))
         {
             this._state = VhCityState.Disabled;
             this.SendMessage(bot, HTML.CreateColorString(bot.ColorHeaderHex, this._username) + " has " + HTML.CreateColorString(RichTextWindow.ColorRed, "disabled") + " the city cloaking device");
         }
         else
         {
             this._state = VhCityState.Unknown;
         }
         break;
     }
 }
Example #2
0
        private void OnMinute(object sender, EventArgs e)
        {
            //if (this._state == VhCityState.Unknown) return;
            if (this._reminders == VhCityRemindState.Unknown)
            {
                return;
            }
            TimeSpan span    = this.TimeExpired;
            int      minutes = 30;

            if (this._reminders == VhCityRemindState.FiveMinutes)
            {
                minutes += 25;
            }
            else if (this._reminders == VhCityRemindState.Halfway)
            {
                minutes += 15;
            }
            else if (this._reminders == VhCityRemindState.PostAnnounce)
            {
                minutes += 60;
            }
            else if (this._reminders == VhCityRemindState.Announced)
            {
                minutes += 45;
            }
            switch (this._reminders)
            {
            case VhCityRemindState.FiveMinutes:
            case VhCityRemindState.Halfway:
            case VhCityRemindState.Waiting:
                if (span.TotalMinutes >= minutes)
                {
                    string state;
                    if (this._state == VhCityState.Enabled)
                    {
                        state = HTML.CreateColorString(RichTextWindow.ColorGreen, "enabled");
                    }
                    else
                    {
                        state = HTML.CreateColorString(RichTextWindow.ColorRed, "disabled");
                    }
                    this.SendMessage(this._bot, HTML.CreateColorString(this._bot.ColorHeaderHex, minutes.ToString()) + " minutes have passed since " + HTML.CreateColorString(this._bot.ColorHeaderHex, this._username) + " has " + state + " the city cloaking device");
                    if (this._reminders == VhCityRemindState.Waiting)
                    {
                        this._reminders = VhCityRemindState.Halfway;
                    }
                    else if (this._reminders == VhCityRemindState.Halfway)
                    {
                        this._reminders = VhCityRemindState.FiveMinutes;
                    }
                    else
                    {
                        this._reminders = VhCityRemindState.PreAnnounce;
                    }
                }
                break;

            case VhCityRemindState.PreAnnounce:
                if (span.TotalMinutes >= 60)
                {
                    if (this._state == VhCityState.Disabled)
                    {
                        this.SendMessage(this._bot, "The city cloaking device has fully recovered from the alien attack. Please enable the city cloaking device");
                    }
                    else
                    {
                        this.SendMessage(this._bot, "The city cloaking device has finished charging. New alien attacks can now be initiated");
                    }
                    this._reminders = VhCityRemindState.Announced;
                }
                break;

            case VhCityRemindState.PostAnnounce:
            case VhCityRemindState.Announced:
                if (span.TotalMinutes >= minutes && this._state == VhCityState.Disabled)
                {
                    minutes -= 60;
                    this.SendMessage(this._bot, HTML.CreateColorString(this._bot.ColorHeaderHex, minutes.ToString()) + " minutes have passed since the city cloaking device has fully recovered. Please enable the city cloaking device");
                    if (this._reminders == VhCityRemindState.Announced)
                    {
                        this._reminders = VhCityRemindState.PostAnnounce;
                    }
                    else
                    {
                        this._reminders = VhCityRemindState.Unknown;
                    }
                }
                break;
            }
        }