Exemple #1
0
        //private string[] CreateRequestFromForm()
        //{
        //    Parser mm;
        //    try
        //    {
        //        mm =
        //            new Parser(
        //                mLoadSrc.Substring(mLoadSrc.IndexOf("<form"),
        //                                   mLoadSrc.IndexOf("</form>") - mLoadSrc.IndexOf("<form")));
        //    }
        //    catch (ArgumentOutOfRangeException)
        //    {
        //        mFinished = true;
        //        return null;
        //    }
        //    string[] ret = { mm.Parse("action=\"", "\""), "" };
        //    Parser tm;
        //    bool amp = false;
        //    string[] tokens = mm.MultiParse("<input type=\"", ">");
        //    for (int i = 0; i < tokens.Length - 1; i++)
        //    {
        //        string token = tokens[i];
        //        if (token.Contains("type=\"image\""))
        //            continue;
        //        tm = new Parser(token);
        //        if (amp)
        //            ret[1] += "&";
        //        else
        //            amp = true;
        //        ret[1] += tm.Parse("name=\"", "\"") + "=" + tm.Parse("value=\"", "\"");
        //    }
        //    return mRoom.Mover.Account.Ret == mRoom.Mover.Account.Name ? ret : null;
        //}
        private void EvaluateOutcome(string src)
        {
            // RESEND REQUEST
            if (src == "ERROR: Timeout"
                || src.Contains("operation has timed out"))
            {
                CoreUI.Instance.LogPanel.Log("Attack on " + mName + " failed - timed out by server");
                SendAttack();
                return;
            }
            if (src.Contains("an existing connection was forcibly closed by the remote host"))
            {
                CoreUI.Instance.LogPanel.Log("Attack on " + mName + " failed - connection forcibly closed by server");
                SendAttack();
                return;
            }
            if (src.Contains("underlying connection was closed"))
            {
                CoreUI.Instance.LogPanel.Log("Attack on " + mName + " failed - underlying connection closed by server");
                SendAttack();
                return;
            }

            // ALL GOOD

            // bookkeeping
            mAttacked = true;
            mRoom.Mover.MobsAttacked++;

            // spawn handling and logging
            if (src.Contains("steps out of the shadows"))
            {
                CoreUI.Instance.SpawnsPanel.Log(string.Format("{0} spawned a mob in room {1}", mRoom.Mover.Account.Name, mRoom.Id));

                if (CoreUI.Instance.Settings.AttackSpawns)
                {
                    // attack the spawn mob
                    CoreUI.Instance.SpawnsPanel.Log(string.Format("{0} attacking spawns in room {1}", mRoom.Mover.Account.Name, mRoom.Id));
                    if (mRoom.Load() != 0)
                    {
                        CoreUI.Instance.SpawnsPanel.Log(string.Format("{0} room {1} reload failed", mRoom.Mover.Account.Name, mRoom.Id));
                    }
                    else
                    {
                        mRoom.AttackSpawns();
                    }
                }
            }
            if (IsSpawn)
            {
                CoreUI.Instance.SpawnsPanel.Log(string.Format("{0} attacked {1}", mRoom.Mover.Account.Name, Name));
                CoreUI.Instance.SpawnsPanel.Attacked(mRoom.Id);
            }

            // other outcome handling
            if (src.Contains("has weakened"))
            {
                CoreUI.Instance.LogPanel.LogAttack(string.Format("{0} lost to {1}", mRoom.Mover.Account.Name, mName));
            }
            else if (src.Contains("You have won the battle!"))
            {
                Won = true;
                // quest kill count
                String killProgress = string.Empty;
                Regex killregex = new Regex(@"\d+/\d+ killed");
                Match m = killregex.Match(src);
                if (m.Groups.Count > 0)
                {
                    killProgress = m.Groups[0].Value;
                }

                // Build string to add to attack log.
                String attackLogString = "";
                if (src.Contains("has gained "))
                {
                    // xp gain
                    if (int.TryParse(Parser.Parse(src, "has gained ", " experience!"), out mExpGained))
                    {
                        Globals.ExpGained += mExpGained;
                        mRoom.Mover.ExpGained += mExpGained;
                        attackLogString = string.Format("{0} beat {1}, gained {2} exp", mRoom.Mover.Account.Name, mName, mExpGained);
                    }
                }
                else
                {
                    attackLogString = string.Format("{0} beat {1}", mRoom.Mover.Account.Name, mName);
                }
                attackLogString += killProgress;
                CoreUI.Instance.LogPanel.LogAttack(attackLogString);

                // Quest Kills
                // </b>14/60 killed<br>

                // item dropped
                if (src.Contains("Found "))
                {
                    //if (src.Contains("has no backpack space"))
                    //{
                    //    CoreUI.Instance.LogPanel.Log(string.Format("{0} found an item, but your backpack is full", mRoom.Mover.Account.Name));
                    //    // TODO what if we get one item, then the rest is full?
                    //}
                    //else
                    //{
                        string[] fs = Parser.MultiParse(src, "Found ", "</b>");
                        if (fs.Length > 1)
                        {
                            bool reported = false;  // flag to keep track of whether this bug has been reported
                            for (int i = 1; i < fs.Length; i++)
                            {
                                string f = fs[i];
                                if (f.Length < MAX_ITEM_LEN)
                                {
                                    CoreUI.Instance.LogPanel.LogAttack(string.Format("{0} found {1}", mRoom.Mover.Account.Name, f));
                                    if (IsSpawn)
                                    {
                                        CoreUI.Instance.SpawnsPanel.Log(string.Format("{0} found {1}", mRoom.Mover.Account.Name, f));
                                    }
                                }
                                else if (!reported)
                                {
                                    // temporary - report this so I can fix item errors!
                                    DCT.Util.BugReporter br = new DCT.Util.BugReporter();
                                    CoreUI.Instance.LogPanel.Log("Reporting item drop error...");
                                    br.ReportBug(string.Format("The following source code was autoreported (problem - item drop parse exceeded max length) - v.{0}:\n\n{1}",
                                        DCT.Security.Version.Full, src), "*****@*****.**");
                                    reported = true;
                                }
                            }
                        }
                    //}
                }
            }
            else if (src.Contains("looming over"))
            {
                CoreUI.Instance.LogPanel.LogAttack(string.Format("Someone is looming over {0}", this.Name));
            }
            else if (src.Contains("That mob is already dead!") || src.Contains("Someone has already killed this mob"))
            {
                CoreUI.Instance.LogPanel.LogAttack(string.Format("{0} is already dead", this.Name));
            }
            else if (src.Contains("to recover rage automatically"))
            {
                // not enough rage
                // TODO consider putting in a stop
                CoreUI.Instance.LogPanel.LogAttack(string.Format("{0} doesn't have rage to attack {1}", mRoom.Mover.Account.Name, this.Name));
            }
            else if (src.Contains("You are not in the room with that mob"))
            {
                CoreUI.Instance.LogPanel.LogAttack(string.Format("{0} is not in the room", this.Name));
            }
            else
            {
                //string tmp;
                if (src.StartsWith("ERROR"))
                {
                    CoreUI.Instance.LogPanel.LogAttack("Attack E occurred in Connection: " + src);
                }
                else
                {
                    CoreUI.Instance.LogPanel.LogAttack("Attack E (server-side)");
                }
            }

            mQuit = true;
            CoreUI.Instance.UpdateDisplay();
        }
Exemple #2
0
        //private string[] CreateRequestFromForm()
        //{
        //    Parser mm;
        //    try
        //    {
        //        mm =
        //            new Parser(
        //                mLoadSrc.Substring(mLoadSrc.IndexOf("<form"),
        //                                   mLoadSrc.IndexOf("</form>") - mLoadSrc.IndexOf("<form")));
        //    }
        //    catch (ArgumentOutOfRangeException)
        //    {
        //        mFinished = true;
        //        return null;
        //    }
        //    string[] ret = { mm.Parse("action=\"", "\""), "" };

        //    Parser tm;
        //    bool amp = false;

        //    string[] tokens = mm.MultiParse("<input type=\"", ">");

        //    for (int i = 0; i < tokens.Length - 1; i++)
        //    {
        //        string token = tokens[i];

        //        if (token.Contains("type=\"image\""))
        //            continue;

        //        tm = new Parser(token);

        //        if (amp)
        //            ret[1] += "&";
        //        else
        //            amp = true;

        //        ret[1] += tm.Parse("name=\"", "\"") + "=" + tm.Parse("value=\"", "\"");
        //    }

        //    return mRoom.Mover.Account.Ret == mRoom.Mover.Account.Name ? ret : null;
        //}

        private void EvaluateOutcome(string src)
        {
            // RESEND REQUEST
            if (src == "ERROR: Timeout" ||
                src.Contains("operation has timed out"))
            {
                CoreUI.Instance.LogPanel.Log("Attack on " + mName + " failed - timed out by server");
                SendAttack();
                return;
            }
            if (src.Contains("an existing connection was forcibly closed by the remote host"))
            {
                CoreUI.Instance.LogPanel.Log("Attack on " + mName + " failed - connection forcibly closed by server");
                SendAttack();
                return;
            }
            if (src.Contains("underlying connection was closed"))
            {
                CoreUI.Instance.LogPanel.Log("Attack on " + mName + " failed - underlying connection closed by server");
                SendAttack();
                return;
            }

            // ALL GOOD

            // bookkeeping
            mAttacked = true;
            mRoom.Mover.MobsAttacked++;

            // spawn handling and logging
            if (src.Contains("steps out of the shadows"))
            {
                CoreUI.Instance.SpawnsPanel.Log(string.Format("{0} spawned a mob in room {1}", mRoom.Mover.Account.Name, mRoom.Id));

                if (CoreUI.Instance.Settings.AttackSpawns)
                {
                    // attack the spawn mob
                    CoreUI.Instance.SpawnsPanel.Log(string.Format("{0} attacking spawns in room {1}", mRoom.Mover.Account.Name, mRoom.Id));
                    if (mRoom.Load() != 0)
                    {
                        CoreUI.Instance.SpawnsPanel.Log(string.Format("{0} room {1} reload failed", mRoom.Mover.Account.Name, mRoom.Id));
                    }
                    else
                    {
                        mRoom.AttackSpawns();
                    }
                }
            }
            if (IsSpawn)
            {
                CoreUI.Instance.SpawnsPanel.Log(string.Format("{0} attacked {1}", mRoom.Mover.Account.Name, Name));
                CoreUI.Instance.SpawnsPanel.Attacked(mRoom.Id);
            }

            // other outcome handling
            if (src.Contains("has weakened"))
            {
                CoreUI.Instance.LogPanel.LogAttack(string.Format("{0} lost to {1}", mRoom.Mover.Account.Name, mName));
            }
            else if (src.Contains("var battle_result"))
            {
                // quest kill count
                String killProgress = string.Empty;
                Regex  killregex    = new Regex(@"\d+/\d+ killed");
                Match  m            = killregex.Match(src);
                if (m.Groups.Count > 0)
                {
                    killProgress = m.Groups[0].Value;
                }

                // Build string to add to attack log.
                String attackLogString = "";
                if (src.Contains("has gained "))
                {
                    // xp gain
                    if (int.TryParse(Parser.Parse(src, "has gained ", " experience!"), out mExpGained))
                    {
                        Globals.ExpGained     += mExpGained;
                        mRoom.Mover.ExpGained += mExpGained;
                        attackLogString        = string.Format("{0} beat {1}, gained {2} exp", mRoom.Mover.Account.Name, mName, mExpGained);
                    }
                }
                else
                {
                    attackLogString = string.Format("{0} beat {1}", mRoom.Mover.Account.Name, mName);
                }
                attackLogString += killProgress;
                CoreUI.Instance.LogPanel.LogAttack(attackLogString);

                // item dropped
                if (src.Contains("Found "))
                {
                    //if (src.Contains("has no backpack space"))
                    //{
                    //    CoreUI.Instance.LogPanel.Log(string.Format("{0} found an item, but your backpack is full", mRoom.Mover.Account.Name));
                    //    // TODO what if we get one item, then the rest is full?
                    //}
                    //else
                    //{
                    string[] fs = Parser.MultiParse(src, "Found ", "</b>");
                    if (fs.Length > 1)
                    {
                        bool reported = false;      // flag to keep track of whether this bug has been reported
                        for (int i = 1; i < fs.Length; i++)
                        {
                            string f = fs[i];
                            if (f.Length < MAX_ITEM_LEN)
                            {
                                CoreUI.Instance.LogPanel.LogAttack(string.Format("{0} found {1}", mRoom.Mover.Account.Name, f));
                                if (IsSpawn)
                                {
                                    CoreUI.Instance.SpawnsPanel.Log(string.Format("{0} found {1}", mRoom.Mover.Account.Name, f));
                                }
                            }
                            else if (!reported)
                            {
                                // temporary - report this so I can fix item errors!
                                DCT.Util.BugReporter br = new DCT.Util.BugReporter();
                                CoreUI.Instance.LogPanel.Log("Reporting item drop error...");
                                br.ReportBug(string.Format("The following source code was autoreported (problem - item drop parse exceeded max length) - v.{0}:\n\n{1}",
                                                           DCT.Security.Version.Full, src), "*****@*****.**");
                                reported = true;
                            }
                        }
                    }
                    //}
                }
            }
            else if (src.Contains("looming over"))
            {
                CoreUI.Instance.LogPanel.LogAttack(string.Format("Someone is looming over {0}", this.Name));
            }
            else if (src.Contains("That mob is already dead!") || src.Contains("Someone has already killed this mob"))
            {
                CoreUI.Instance.LogPanel.LogAttack(string.Format("{0} is already dead", this.Name));
            }
            else if (src.Contains("to recover rage automatically"))
            {
                // not enough rage
                // TODO consider putting in a stop
                CoreUI.Instance.LogPanel.LogAttack(string.Format("{0} doesn't have rage to attack {1}", mRoom.Mover.Account.Name, this.Name));
            }
            else if (src.Contains("You are not in the room with that mob"))
            {
                CoreUI.Instance.LogPanel.LogAttack(string.Format("{0} is not in the room", this.Name));
            }
            else
            {
                //string tmp;
                if (src.StartsWith("ERROR"))
                {
                    CoreUI.Instance.LogPanel.LogAttack("Attack E occurred in Connection: " + src);
                }
                else
                {
                    CoreUI.Instance.LogPanel.LogAttack("Attack E (server-side)");
                }
            }

            mQuit = true;
            CoreUI.Instance.UpdateDisplay();
        }