Example #1
0
 public void Challenge(CheckEntry e)
 {
     e.expire = DateTime.Now + TimeSpan.FromMinutes(5);
     e.param  = 0;
     e.state  = CheckState.Challenged;
     //Challenge
     e.m.SendGump(new AFKGump(e));
 }
Example #2
0
        private static void Reconnected(PlayerMobile pm)
        {
            CheckEntry e = new CheckEntry(pm);

            e.state = CheckState.Reconnected;
            if (Inst.checks.ContainsKey(pm))
            {
                Inst.checks[pm] = e;
            }
            else
            {
                Inst.checks.Add(pm, e);
            }
        }
Example #3
0
        private static void EventSink_Login(LoginEventArgs args)
        {
            PlayerMobile pm = args.Mobile as PlayerMobile;
            Account      a  = pm.Account as Account;

            if (pm != null && a != null)
            {
                //Check for disconnected flag
                if (a.GetTag("AFKTag-Selected") != null)
                {
                    Reconnected(pm);
                }
                else
                {
                    String failedTime = a.GetTag("AFKTag-FailedTime");
                    if (failedTime != null)
                    {
                        pm.SendMessage(0x21, "Please confirm you are not a bot.");
                        CheckEntry e = new CheckEntry(pm);
                        e.state = CheckState.BotCheck;
                        if (Inst.checks.ContainsKey(pm))
                        {
                            Inst.checks[pm] = e;
                        }
                        else
                        {
                            Inst.checks.Add(pm, e);
                        }

                        /*if(Utility.GetDateTime( failedTime, DateTime.MinValue ) > DateTime.Now + TimeSpan.FromMinutes(30))
                         * {
                         *      pm.SendMessage(0x21, "You have reconnected in the AFK grace period. Please authenticate now.");
                         *      Reconnected(pm);
                         *      //Grace time
                         * } else
                         * {
                         *      pm.SendMessage(0x21, "Your account has been flagged by the AFK detection system.");
                         *      IncrementFlag(pm);
                         *      a.RemoveTag("AFKTag-FailedTime");
                         *      //Too bad
                         * }*/
                    }
                }
            }
        }
Example #4
0
        public void BadAnswer(CheckEntry e)
        {
            if (e == null)
            {
                return;
            }

            e.param++;
            if (e.param > 1)
            {
                SayToGM(e.m, "I got AFK wrong too many times. I'm being kicked.");
                e.m.SendMessage("Too many wrong selections. Kicking.");
                checks.Remove(e.m);
                Kick(e.m);

                Account a = e.m.Account as Account;
                if (a == null)
                {
                    return;
                }

                if (e.state == CheckState.BotChallenge)
                {
                    //Increment flag
                    IncrementFlag(e.m);
                }
                else
                {
                    a.RemoveTag("AFKTag-Selected");
                    if (a.GetTag("AFKTag-FailedTime") == null)
                    {
                        a.AddTag("AFKTag-FailedTime", XmlConvert.ToString(DateTime.Now, XmlDateTimeSerializationMode.Local));
                    }
                }
            }
            else
            {
                SayToGM(e.m, String.Format("I answered AFK incorrectly ({1}). {0:F2} minutes left.", e.expire.Subtract(DateTime.Now).TotalMinutes, e.param));
                e.m.SendGump(new AFKGump(e));
                e.m.SendMessage("Wrong selection. Please try again.");
            }
        }
Example #5
0
        public void Challenge(PlayerMobile m, TimeSpan length)
        {
            if (m == null)
            {
                return;
            }

            if (checks.ContainsKey(m))
            {
                return;
            }

            CheckEntry e = new CheckEntry(m);

            e.expire = DateTime.Now + length;
            e.param  = 0;
            e.state  = CheckState.Challenged;
            checks.Add(m, e);
            m.SendGump(new AFKGump(e));
        }
Example #6
0
        public AFKGump(CheckEntry e) : base(100, 20)
        {
            m_entry = e;

            Closable = false;


            int answer      = Utility.Random(12);
            int spellAnswer = Utility.Random(64);

            if (e != null)
            {
                e.answer = answer;
            }

            AddPage(0);

            AddBackground(0, 0, 400, 400, 2600);

            AddHtml(10, 20, 390, 20, Color(Center("Click this spell from the 12 below."), 0xFFFFFF), false, false);
            AddImage(165, 45, 7000 + spellAnswer);

            for (int i = 0; i < 12; i++)
            {
                int spell;
                if (i == answer)
                {
                    spell = spellAnswer;
                }
                else
                {
                    do
                    {
                        spell = Utility.Random(64);
                    } while(spell == spellAnswer);
                }
                AddButton(m_initX + (i % 4) * m_incrX, m_initY + (i / 4) * m_incrY, 7000 + spell, 7000 + spell, i, GumpButtonType.Reply, 0);
            }
        }
Example #7
0
        public void GoodAnswer(CheckEntry e)
        {
            if (e == null)
            {
                return;
            }

            SayToGM(e.m, String.Format("I answered the AFK with {0:F2} minutes to spare", e.expire.Subtract(DateTime.Now).TotalMinutes));

            checks.Remove(e.m);
            Account a = e.m.Account as Account;

            if (a == null)
            {
                return;
            }

            a.RemoveTag("AFKTag-Selected");
            a.SetTag("AFKTag-LastChecked", XmlConvert.ToString(DateTime.Now, XmlDateTimeSerializationMode.Local));
            a.RemoveTag("AFKTag-FailedTime");
            e.m.SendMessage("Confirmed. Thank you.");
        }
Example #8
0
 public void ChallengeNow(CommandEventArgs e)
 {
     if (e.Mobile is PlayerMobile)
     {
         PlayerMobile pm = (PlayerMobile)e.Mobile;
         if (checks.ContainsKey(pm))
         {
             CheckEntry entry = checks[pm];
             if (entry.state == CheckState.Notified)
             {
                 Challenge(entry);
             }
             else
             {
                 pm.SendMessage("This is the wrong time to send this command.");
             }
         }
         else
         {
             pm.SendMessage("You are not selected for AFK testing");
         }
     }
 }