This project is read-only.
Project Description
Yes, it is a robot built for browser game named Travian by German.
I support core functions sush as login, get ting base info, mapping world map, upgrade action,resources trade and so on.
I hope it could be a good class library for you to create a custom utility.

Sample Codes

    public class GetLoginPageAction : TravianAction<GetLoginPageInput, GetLoginPageResult>
    {
        private static XPathExpression XPATH_FORM = XPathExpression.Compile("//form[1]/@action");
        private static  XPathExpression XPATH_INPUTS = XPathExpression.Compile("//form[1]//input");

        public override void DoAction()
        {
            IEClient client = new IEClient();
            this.ActionResult.RawHtml = client.GetResponseString(this.Input.LoginUrl);
            LoginAction nextAction = this.NextAction as LoginAction;
            
            XPathNodeIterator iterator;
            XPathNavigator nav;
            nav = GetSgmlDOM(this.ActionResult.RawHtml);
            iterator = nav.Select(XPATH_FORM);
            if(iterator.Count > 0)
            {
                iterator.MoveNext();
                this.ActionResult.TagetResult.PostUrl = new Uri(IEClient.GetUri(this.Input.LoginUrl, null), iterator.Current.Value);;
            }
            else 
                goto Error;

            iterator = nav.Select(XPATH_INPUTS);
            if (iterator.Count > 0)
            {
                foreach (XPathNavigator navigator in iterator)
                {
                    navigator.MoveToAttribute("name", "");
                    string name = navigator.Value;
                    navigator.MoveToParent();
                    navigator.MoveToAttribute("value", "");
                    string value = navigator.Value;
                    this.ActionResult.TagetResult.LoginArguments.Add(name, value);
                }
            }
            else 
                goto Error;


            Error: {   }

        }
    }
    public class GetLoginPageInput
    {
        public string LoginUrl;

    }

    public class GetLoginPageResult
    {
        public IDictionary<string, string> LoginArguments = new Dictionary<string, string>();
        public Uri PostUrl;
    }

    public class LoginTask : TravianTask
    {
        public string LoginUrl;
        protected override void Init()
        {
            GetLoginPageAction action1 = new GetLoginPageAction();
            LoginAction action2 = new LoginAction();
            action1.NextAction = action2;
            action1.Input.LoginUrl = LoginUrl;
            this.FirstAction = action1;
        }
    }


        void Test()
        {
            LoginTask task = new LoginTask();
            task.LoginUrl = "s2.travian.cn";
            task.Execute();
        }





Hope U Join!

Last edited Jun 27, 2007 at 3:05 PM by alex_zero, version 7