Example #1
0
        private SeedInfo GetOwnFarmSeed(GardenInfo garden)
        {
            int seedid = 0;
            string seedname = "";
            SeedInfo seed = null;
            //if (Task.SowMySeedsFirst && _myseedsList != null && _myseedsList.Count != 0)
            //{
            //    foreach (SeedInfo seedunit in _myseedsList)
            //    {
            //        //爱情果,友谊花
            //        if (seedunit.SeedId == 39 || seedunit.SeedId == 61 || seedunit.Num < 1)
            //            continue;
            //        //人参
            //        if (seedunit.SeedId == 21)
            //        {
            //            //人参最多同时可种2块地
            //            if (garden.PanaxCount >= 2)
            //                continue;
            //        }
            //        //人参(有人参娃娃)
            //        else if (seedunit.SeedId == 25)
            //        {
            //            //人参(有人参娃娃)最多同时可种2块地
            //            if (garden.PanaxBabyCount >= 2)
            //                continue;
            //        }
            //        //曼珠沙华
            //        else if (seedunit.SeedId == 104)
            //        {
            //            //曼珠沙华最多同时可种1块地
            //            if (garden.ClowningCount >= 1)
            //                continue;
                    
            //        }
            //        //曼陀罗
            //        else if (seedunit.SeedId == 114)
            //        {
            //            //该种子最多同时可种2块地
            //            if (garden.StramoniumCount >= 2)
            //                continue;
            //        }
            //        //摇钱树
            //        else if (seedunit.SeedId == 102)
            //        {
            //            //该种子最多同时可种1块地
            //            if (garden.YaoqianCount >= 1)
            //                continue;
            //        }
                        
            //        else
            //        {
            //            seed = seedunit;
            //            break;
            //        }
            //    }
            //}

            if (seed == null)
            {
                if (Task.ExpensiveFarmSelf)
                {
                    RankSeedInfo rankseed = GetOwnSeedByRank(garden.Rank, garden.PanaxCount, garden.PanaxBabyCount, garden.ClowningCount, garden.StramoniumCount);
                    if (rankseed != null)
                    {
                        seedid = rankseed.SeedId;
                        seedname = rankseed.Name;
                        SetMessage(" 你可以播种的最贵的种子:" + rankseed.Name);
                    }
                    else
                    {
                        LogHelper.Write("GetOwnFarmSeed", " 无法取得等级" + garden.Rank + "的种子", LogSeverity.Warn);
                        SetMessage(" 无法取得等级" + garden.Rank + "的种子");
                        return null;
                        //return FarmStatus.Continue;
                    }
                }
                else
                {
                    SeedInfo seed1 = GetSeedById(Task.CustomFarmSelf);
                    if (seed1 != null)
                    {
                        seedid = seed1.SeedId;
                        seedname = seed1.Name;
                        SetMessage(" 你设定的播种种子:" + seed1.Name);
                    }
                    else
                    {
                        LogHelper.Write("GetOwnFarmSeed", " 无法取得自定义的种子:" + Task.CustomFarmSelf.ToString(), LogSeverity.Warn);
                        SetMessage(" 无法取得自定义的种子:" + Task.CustomFarmSelf.ToString());
                        return null;
                        //return FarmStatus.Continue;
                    }
                }
                seed = GetFarmSeedById(seedid);
                if (seed == null)
                {
                    SetMessage(string.Format(" 没有{0}的种子", seedname));
                    if (_outofmoney)
                    {
                        SetMessage(" 现金不够,不能购买,播种失败");
                        //return FarmStatus.OutOfMoney;
                    }
                    if (Task.BuySeed)
                    {
                        if (BuySeed(seedid))
                        {
                            ReadMySeeds(garden);
                            seed = GetFarmSeedById(seedid);
                        }
                        //else
                        //    return FarmStatus.Continue;
                    }
                }
            }

            return seed;
        }
Example #2
0
        public static GardenInfo GetGarden(string strxml)
        {
            try
            {
                if (String.IsNullOrEmpty(strxml))
                    return null;

                XmlDocument objXmlDoc = new XmlDocument();
                objXmlDoc.LoadXml(strxml);
                if (objXmlDoc == null)
                    return null;

                GardenInfo garden = new GardenInfo();

                //garden
                XmlNode objNode = objXmlDoc.SelectSingleNode(Constants.GARDEN_ROOT + Constants.CHAR_SLASH + Constants.GARDEN_ACCOUNT);
                if (objNode == null)
                    return null;

                garden.Rank = DataConvert.GetInt32(objNode.SelectSingleNode(Constants.GARDEN_RANK).InnerText);
                garden.RankTip = objNode.SelectSingleNode(Constants.GARDEN_RANKTIP).InnerText;
                garden.Name = objNode.SelectSingleNode(Constants.GARDEN_NAME).InnerText;
                garden.CashTip = objNode.SelectSingleNode(Constants.GARDEN_CASHTIP).InnerText;
                garden.Cash = GetCash(garden.CashTip);
                garden.TCharms = DataConvert.GetInt32(objNode.SelectSingleNode(Constants.GARDEN_TCHARMS).InnerText);
                if (objNode.SelectSingleNode(Constants.GARDEN_CAREURL) == null)
                    garden.HasMonitor = false;
                else if (!String.IsNullOrEmpty(objNode.SelectSingleNode(Constants.GARDEN_CAREURL).InnerText))
                    garden.HasMonitor = true;
                else
                    garden.HasMonitor = false;

                //plots
                DataView dv = GetData(objXmlDoc, Constants.GARDEN_ROOT + Constants.CHAR_SLASH + Constants.GARDEN_GARDEN);

                Collection<PlotInfo> plots = new Collection<PlotInfo>();

                for (int ix = 0; ix < dv.Table.Rows.Count; ix++)
                {
                    PlotInfo plot = new PlotInfo();
                    plot.Water = DataConvert.GetInt32(dv.Table.Rows[ix]["water"]);
                    plot.FarmNum = DataConvert.GetInt32(dv.Table.Rows[ix]["farmnum"]);
                    plot.Vermin = DataConvert.GetInt32(dv.Table.Rows[ix]["vermin"]);
                    plot.CropsId = DataConvert.GetInt64(dv.Table.Rows[ix]["cropsid"]);
                    plot.Fuid = DataConvert.GetInt32(dv.Table.Rows[ix]["fuid"]);
                    plot.Status = DataConvert.GetInt32(dv.Table.Rows[ix]["status"]);
                    plot.Grass = DataConvert.GetInt32(dv.Table.Rows[ix]["grass"]);
                    plot.Shared = DataConvert.GetInt32(dv.Table.Rows[ix]["shared"]);
                    if (dv.Table.Columns.Contains("cropsstatus"))
                        plot.CropsStatus = DataConvert.GetInt32(dv.Table.Rows[ix]["cropsstatus"]);
                    else
                        plot.CropsStatus = -2;
                    if (dv.Table.Columns.Contains("seedid"))
                        plot.SeedId = DataConvert.GetInt32(dv.Table.Rows[ix]["seedid"]);
                    else
                        plot.SeedId = 0;
                    if (dv.Table.Columns.Contains("crops"))
                        plot.Crops = JsonHelper.FiltrateHtmlTags(dv.Table.Rows[ix]["crops"].ToString());
                    else
                        plot.Crops = "";
                    if (dv.Table.Columns.Contains("farm"))
                        plot.Farm = JsonHelper.FiltrateHtmlTags(dv.Table.Rows[ix]["farm"].ToString());
                    else
                        plot.Farm = "";
                    plots.Add(plot);
                }

                garden.Plots = plots;

                return garden;
            }
            catch (Exception ex)
            {
                LogHelper.Write("ConfigCtrl.GetGarden", strxml, ex, LogSeverity.Error);
                return null;
            }
        }
Example #3
0
        private bool SowPlot(GardenInfo garden, SeedInfo seed, PlotInfo plot)
        {
            SetMessage(" 尝试播种" + seed.Name + "...");
            HH.DelayedTime = Constants.DELAY_2SECONDS;
            string content = HH.Post("http://www.kaixin001.com/house/garden/farmseed.php", string.Format("fuid=0&farmnum={0}&verify={1}&seedid={2}&r=0%2E012194405309855938", plot.FarmNum, this._verifyCode, seed.SeedId));
            if (GetFarmFeedback(content))
            {
                //人参
                if (seed.SeedId == 21)
                    garden.PanaxCount++;
                //人参(有人参娃娃)
                if (seed.SeedId == 25)
                    garden.PanaxBabyCount++;
                seed.Num--;
                return true;
            }
            else
            {
                if (content.Contains("该种子最多同时可种"))
                    seed.Valid = false;
                return false;
            }

        }
Example #4
0
        private void FarmGarden(GardenInfo garden)
        {
            try
            {
                SetMessageLn("开始自家耕作...");

                if (garden == null)
                    return;

                string content = "";

                if (garden.Plots != null)
                {
                    _outofmoney = false;
                    _feedlimited = false;

                    foreach (PlotInfo plot in garden.Plots)
                    {
                        try
                        {
                            if (plot.Status != 1)
                                continue;

                            if ((plot.SeedId == 102 && plot.Crops.IndexOf("点击可摇钱") > -1) ||
                                plot.Water != 5 ||
                                plot.Vermin == 1 ||
                                plot.Grass == 1 ||
                                plot.CropsStatus == 2 ||
                                plot.Shared == 0 && (plot.CropsStatus == 3 && String.IsNullOrEmpty(plot.Crops) && String.IsNullOrEmpty(plot.Farm) || plot.CropsStatus == -1) ||
                                plot.CropsId == 0 && plot.Shared == 0)
                            {
                                if (plot.Shared == 0)
                                    SetMessageLn(string.Format("=>第{0}个地块:", plot.FarmNum));
                                else
                                    SetMessageLn(string.Format("=>第{0}个爱心地块:", plot.FarmNum));
                            }

                            //摇钱树
                            if (plot.SeedId == 102 && plot.Crops.IndexOf("点击可摇钱") > -1)
                            {
                                //<crops>生长阶段:85%&lt;br&gt;&lt;font size='12' color='#666666'&gt;再过18小时26分成熟(不可摇钱)&lt;/font&gt;&lt;br&gt;距离收获:18小时26分&lt;font size='12' color='#666666'&gt;,点击可摇钱&lt;/font&gt;</crops>
                                //<crops>生长阶段:85%&lt;br&gt;&lt;font size='12' color='#666666'&gt;再过18小时14分成熟(不可摇钱)&lt;/font&gt;&lt;br&gt;距离收获:18小时14分</crops>
                                //http://www.kaixin001.com/!house/!garden/yaoqianshu.php?r=0%2E1238307012245059&fuid=0&verify=6194153%5F1062%5F6194153%5F1253607483%5F14f6afef57593e63f22fda3adc9a5685
                                SetMessage("可以摇钱:");
                                HH.DelayedTime = Constants.DELAY_2SECONDS;
                                content = HH.Get(string.Format("http://www.kaixin001.com/!house/!garden/yaoqianshu.php?r=0%2E1238307012245059&fuid={0}&verify={1}", "0", this._verifyCode));
                                GetYaoQianFeedback(content);
                            }

                            if (plot.Water != 5)
                            {
                                //浇水
                                SetMessage("需要浇水:");
                                HH.DelayedTime = Constants.DELAY_2SECONDS;
                                content = HH.Post("http://www.kaixin001.com/house/garden/water.php", string.Format("fuid=0&farmnum={0}&verify={1}&seedid=0&r=0%2E6590517126023769", plot.FarmNum, this._verifyCode));
                                GetFarmFeedback(content);
                            }

                            if (plot.Vermin == 1)
                            {
                                //捉虫
                                SetMessage("需要捉虫:");
                                HH.DelayedTime = Constants.DELAY_2SECONDS;
                                content = HH.Get(string.Format("http://www.kaixin001.com/house/garden/antivermin.php?verify={0}&seedid=0&r=0%2E3779320823960006&fuid=0&farmnum={1}", this._verifyCode, plot.FarmNum));
                                GetFarmFeedback(content);
                            }

                            if (plot.Grass == 1)
                            {
                                //除草
                                SetMessage("需要除草:");
                                HH.DelayedTime = Constants.DELAY_2SECONDS;
                                content = HH.Get(string.Format("http://www.kaixin001.com/house/garden/antigrass.php?farmnum={0}&verify={1}&seedid=0&r=0%2E8164945561438799&fuid=0", plot.FarmNum, this._verifyCode));
                                GetFarmFeedback(content);
                            }

                            if (plot.CropsStatus == 2)
                            {
                                //收获
                                SetMessage("可以收获:");
                                if (Task.HarvestFruit)
                                {
                                    HH.DelayedTime = Constants.DELAY_3SECONDS;                                    
                                    //content = HH.Post("http://www.kaixin001.com/house/garden/havest.php", string.Format("fuid=0&farmnum={0}&verify={1}&seedid=0&r=0%2E44418928399682045", plot.FarmNum, this._verifyCode));
                                    //http://www.kaixin001.com/!house/!garden/havest.php?r=0%2E39583466947078705&fuid=0&seedid=0&farmnum=14&verify=6194153%5F1062%5F6194153%5F1247533515%5F6f718b35e6908e970099b0ab9a9237a3
                                    content = HH.Get(string.Format("http://www.kaixin001.com/!house/!garden/havest.php?r=0%2E39583466947078705&fuid=0&seedid=0&farmnum={0}&verify={1}", plot.FarmNum, this._verifyCode));
                                    if (GetFarmFeedback(content))
                                    {
                                        plot.CropsStatus = 3;
                                        plot.Crops = null;
                                        plot.Farm = null;

                                        //人参
                                        if (plot.SeedId == 21)
                                            garden.PanaxCount--;
                                        //人参(有人参娃娃)
                                        if (plot.SeedId == 25)
                                            garden.PanaxBabyCount--;
                                    }
                                }
                            }

                            if (plot.Shared == 0 &&
                                (plot.CropsStatus == 3 && String.IsNullOrEmpty(plot.Crops) && String.IsNullOrEmpty(plot.Farm) ||
                                plot.CropsStatus == -1))
                            {
                                //犁地
                                SetMessage("需要犁地:");
                                HH.DelayedTime = Constants.DELAY_2SECONDS;
                                content = HH.Get(string.Format("http://www.kaixin001.com/house/garden/plough.php?verify={0}&seedid=0&r=0%2E018698612228035927&fuid=0&farmnum={1}", this._verifyCode, plot.FarmNum));
                                if (GetFarmFeedback(content))
                                    plot.CropsId = 0;
                            }

                            if (plot.CropsId == 0 && plot.Shared == 0)
                            {
                                //播种
                                SetMessage("可以播种:");
                                bool issowed = false;
                                if (Task.SowMySeedsFirst && _myseedsList != null && _myseedsList.Count != 0)
                                {
                                    foreach (SeedInfo myseed in _myseedsList)
                                    {
                                        //爱情果,友谊花
                                        if (myseed.SeedId == 39 || myseed.SeedId == 61 || myseed.Num < 1 || myseed.Valid == false)
                                            continue;

                                        if (SowPlot(garden, myseed, plot))
                                        {
                                            issowed = true;
                                            break;
                                        }
                                    }
                                }
                                if (issowed)
                                    continue;
                                SeedInfo seed = GetOwnFarmSeed(garden);
                                if (seed != null)
                                {
                                    SowPlot(garden, seed, plot);
                                }
                                if (_outofmoney)
                                    return;
                            }
                        }
                        catch (ThreadAbortException)
                        {
                            throw;
                        }
                        catch (ThreadInterruptedException)
                        {
                            throw;
                        }
                        catch (Exception ex)
                        {
                            LogHelper.Write("GameGarden.FarmGarden", "自家耕作失败", ex, LogSeverity.Error);
                            SetMessage(ex.Message);
                            continue;
                        }
                    }
                }
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (ThreadInterruptedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                LogHelper.Write("GameGarden.FarmGarden", ex, LogSeverity.Error);
                SetMessage(" 自家耕作失败!错误:" + ex.Message);
            }
        }
Example #5
0
        private void ReadMySeeds(GardenInfo garden)
        {
            SetMessageLn("我的种子:");
            string content = RequestMySeedList(1);
            int totalpage = 0;
            _myseedsList = ConfigCtrl.GetMySeeds(content, ref totalpage);

            if (_myseedsList == null)
            {
                SetMessage("无法读取我的种子信息!");
                return;
            }

            if (totalpage > 1)
            {
                for (int ix = 2; ix <= totalpage; ix++)
                {
                    content = RequestMySeedList(ix);
                    int pagenum = 0;
                    Collection<SeedInfo> nextseeds = ConfigCtrl.GetMySeeds(content, ref pagenum);
                    foreach (SeedInfo seed in nextseeds)
                    {
                        if (seed != null && !String.IsNullOrEmpty(seed.Name))
                            _myseedsList.Add(seed);
                    }
                }
            }

            int num = 0;
            foreach (SeedInfo seed in _myseedsList)
            {
                ++num;
                if (num == _myseedsList.Count)
                    SetMessage(seed.Name + "(" + seed.Num.ToString() + ")");
                else
                    SetMessage(seed.Name + "(" + seed.Num.ToString() + "),");
            }
        }
Example #6
0
        private void SellFruit(GardenInfo garden)
        {
            try
            {
                SetMessageLn("开始出售果实...");
                if (Task.LowCash)
                {
                    if (garden.Cash > Task.LowCashLimit * 10000)
                    {
                        SetMessageLn(string.Format("还有{0}元现金,无须出售。", garden.Cash));
                        return;
                    }
                }

                if (Task.SellAllFruit)
                {
                    //http://www.kaixin001.com/house/garden/sellfruit.php?seedid=7&num=3&all=0&verify=8125598%5F1062%5F8125598%5F1239430307%5Fc9ffe05915837c4411a43fc9a3fdd3a6
                    //http://www.kaixin001.com/house/garden/sellfruit.php?seedid=4&num=3&all=1&verify=8125598%5F1062%5F8125598%5F1239430307%5Fc9ffe05915837c4411a43fc9a3fdd3a6
                    string content = HH.Get(string.Format("http://www.kaixin001.com/house/garden/sellfruit.php?seedid=4&num=3&all=1&verify={0}", this._verifyCode));
                    long fruitvalue = 0;
                    GetSellFeedback(content, ref fruitvalue);
                }
                else
                {
                    string content = RequestMyWarehouse();
                    Collection<FruitInfo> fruits = ConfigCtrl.GetMyGardenWarehouse(content);
                    if (fruits == null || fruits.Count == 0)
                    {
                        SetMessage("仓库里没有任何果实");
                        return;
                    }

                    //计算价值
                    long soldvalue = 0;
                    long fruitvalue = 0;
                    foreach (FruitInfo myfruit in fruits)
                    {
                        if (Task.SellForbiddennFruitsList.Contains(myfruit.FruitId))
                        {
                            SetMessageLn(string.Format("{0}在出售的禁止列表中,跳过", myfruit.Name));
                            continue;
                        }
                        fruitvalue = 0;
                        if (soldvalue >= Task.MaxSellLimit * 10000)
                        {
                            SetMessageLn(string.Format("已出售的果实总价值已经超过{0}万,停止出售。", Task.MaxSellLimit));
                            break;
                        }

                        int seedprice = GetFruitSellPriceById(myfruit.FruitId);
                        if (seedprice <= 0)
                        {
                            SetMessageLn(string.Format("未知果实{0}-{1},跳过", myfruit.Name));
                            continue;
                        }
                        double temp = (Task.MaxSellLimit * 10000 - soldvalue) / seedprice;
                        int sellnum = Math.Min(DataConvert.GetInt32(Math.Ceiling(temp)), myfruit.Num);
                        HH.DelayedTime = Constants.DELAY_1SECONDS;
                        content = HH.Get(string.Format("http://www.kaixin001.com/house/garden/sellfruit.php?seedid={0}&num={1}&all=0&verify={2}", myfruit.FruitId, sellnum, this._verifyCode));
                        if (GetSellFeedback(content, ref fruitvalue))
                        {
                            soldvalue += fruitvalue;
                            SetMessage(string.Format("已出售的果实总价值:{0}元", soldvalue));
                        }
                        if (sellnum < myfruit.Num)
                            break;
                    }
                }
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (ThreadInterruptedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                LogHelper.Write("GameGarden.SellFruit", ex, LogSeverity.Error);
                SetMessage("出售果实失败!错误:" + ex.Message);
            }
        }
Example #7
0
        private SeedInfo GetSharedFarmSeed(GardenInfo garden, string fuid)
        {
            int seedid = 0;
            string seedname = "";
            SeedInfo seed = null;
            //if (Task.SowMySeedsFirst && _myseedsList != null && _myseedsList.Count != 0)
            //{
            //    foreach (SeedInfo seedunit in _myseedsList)
            //    {
            //        //无效,比如:该种子最多同时可种1块地
            //        if (!seedunit.Valid)
            //            continue;
            //        //人参不能种在爱心地块
            //        if (seedunit.SeedId == 21)
            //            continue;
            //        //曼珠沙华不能种在爱心地块
            //        if (seedunit.SeedId == 104)
            //            continue;
            //        //摇钱树不能种在爱心地里
            //        if (seedunit.SeedId == 102)
            //            continue;
            //        //曼陀罗不能种在爱心地里
            //        if (seedunit.SeedId == 114)
            //            continue;
            //        //翡翠曼陀罗不能种在爱心地里
            //        if (seedunit.SeedId == 116)
            //            continue;
            //        //种完了,没有种子了
            //        if (seedunit.Num < 1)
            //            continue;
            //        //爱情果
            //        if (seedunit.SeedId == 39)
            //        {
            //            //尝试播种爱情果...该种子只能种在异性的爱心地 失败!
            //            FriendInfo friend = GetFriendById(fuid);
            //            if (friend != null)
            //            {
            //                if (!(CurrentAccount.Gender ^ friend.Gender))
            //                    continue;
            //            }
            //        }
            //        else
            //        {
            //            seed = seedunit;
            //            break;
            //        }
            //    }
            //}
            if (seed == null)
            {
                if (Task.ExpensiveFarmShared)
                {
                    RankSeedInfo rankseed = GetSharedSeedByRank(this._myRank, fuid);
                    if (rankseed != null)
                    {
                        seedid = rankseed.SeedId;
                        seedname = rankseed.Name;
                        SetMessage(" 你可以播种的最贵的种子:" + rankseed.Name);
                    }
                    else
                    {
                        LogHelper.Write("GetSharedFarmSeed", " 无法取得等级" + this._myRank + "的种子", LogSeverity.Warn);
                        SetMessage(" 无法取得等级" + this._myRank + "的种子");
                        return null;
                    }
                }
                else
                {
                    SeedInfo seed1 = GetSeedById(Task.CustomFarmShared);
                    if (seed1 != null)
                    {
                        seedid = seed1.SeedId;
                        seedname = seed1.Name;
                        SetMessage(" 你设定的播种种子:" + seed1.Name);
                    }
                    else
                    {
                        LogHelper.Write("GetSharedFarmSeed", " 无法取得自定义的种子:" + Task.CustomFarmShared.ToString(), LogSeverity.Warn);
                        SetMessage(" 无法取得自定义的种子:" + Task.CustomFarmShared.ToString());
                        return null;
                    }
                }
                
                seed = GetFarmSeedById(seedid);
                if (seed == null)
                {
                    SetMessage("没有" + seedname + "的种子");
                    if (_outofmoney)
                    {
                        SetMessage(" 现金不够,不能购买");
                        return null;
                    }
                    if (Task.BuySeed)
                    {
                        if (BuySeed(seedid))
                        {
                            ReadMySeeds(garden);
                            seed = GetFarmSeedById(seedid);
                        }
                    }
                }
            }

            return seed;
        }