Exemple #1
0
 private Mature GetMature(User _friendsInfo, int place)
 {
     JsonObject farmStatus = GetFUserInfo(_friendsInfo.userId, out dogJson);
     Land newLand = new Land(farmStatus.GetCollection()[place]);
     CropItem newCropItem = new CropItem(GetCropModel(newLand.a));
     string landStatus = "";
     string cropStatus = "";
     string dogId = "";
     string isHungry = "";
     dogId = dogJson.GetValue("dogId");
     isHungry = dogJson.GetValue("isHungry");
     Mature m = new Mature();
     m.userId = _friendsInfo.userId;
     m.userName = _friendsInfo.userName;
     m.place = place;
     landStatus = GetLandStatus(newLand, newCropItem);
     m.cName = landStatus;
     GetCropStatus(out cropStatus, newLand);
     m.cStatus = cropStatus;
     m.cId = newLand.a;
     m.cWeed = newLand.f;//f > 0有草
     m.cWorm = newLand.g;//g > 0有虫
     m.cDry = newLand.h.Equals("0") ? "Yes" : "No";// h = 0干旱
     m.hasDog = (dogId.Equals("0") || isHungry.Equals("1")) ? "No" : "Yes";
     //无狗或者无狗粮时等于没有狗
     m.cTime = Convert.ToInt64(newLand.q) + Convert.ToInt64(newCropItem.growthCycle) + Convert.ToInt64(newCropItem.growthCycleNext) * Convert.ToInt64(newLand.j);
     return m;
 }
Exemple #2
0
 private void GetMatureList()
 {
     _matureList.Clear();
     for (int i = 0; i < _friends.GetCollection().Count; i++)
     {
         User _friendsInfo = new User(_friends.GetCollection()[i]);
         toLog("正在侦查" + _friendsInfo.userName + "的农场");
         JsonObject farmStatus = GetFUserInfo(_friendsInfo.userId);
         for (int j = 0; j < farmStatus.GetCollection().Count; j++)
         {
             Mature matureStatus = new Mature();
             /*
             //JsonObject matureStatus = new JsonObject();
             Land newLand = new Land(farmStatus.GetCollection()[j]);
             ShopItem newShopItem = new ShopItem(GetShopModel(newLand.a));
             //matureStatus.Add("userId", _friendsInfo.userId);
             //matureStatus.Add("userName", _friendsInfo.userName);
             //matureStatus.Add("place", j.ToString());
             //matureStatus.Add("cName", newShopItem.cName);
             //matureStatus.Add("cStatus", newLand.m.Equals("0") ? "未成熟" : (newLand.m + "/" + newLand.k));
             //matureStatus.Add("cTime", (Convert.ToInt64(newLand.q) + Convert.ToInt64(newShopItem.growthCycle)).ToString());
             matureStatus.userId = _friendsInfo.userId;
             matureStatus.userName = _friendsInfo.userName;
             matureStatus.place = j;
             landStatus = GetLandStatus(newLand, newShopItem);
             matureStatus.cName = landStatus;
             GetCropStatus(out cropStatus, newLand);
             matureStatus.cStatus = cropStatus;
             matureStatus.cTime = Convert.ToInt64(newLand.q) + Convert.ToInt64(newShopItem.growthCycle);
              * */
             matureStatus = GetMature(_friendsInfo, j);
             MatureListDoWork(matureStatus);
             _matureList.Add(matureStatus);
         }
         toLog("完成侦查" + _friendsInfo.userName + "的农场");
         System.Threading.Thread.Sleep(timeInterval * 1000);
     }
 }
Exemple #3
0
 private void MatureListRefresh()
 {
     long seconds = TimeFormat.FormatTime(DateTime.Now);
     Mature m = new Mature();
     for (int i = 0; i < _matureList.Count; i++)
     {
         m = _matureList[i];
         if (m.cTime <= seconds)
         {
             //获取指定用户指定土地信息
             m = GetMature(new User(GetUserModel(m.userId)), Convert.ToInt32(m.place));
         }
         else
         {
             break;
         }
         _matureList[i] = m;
     }
 }
Exemple #4
0
 private void MatureListPick()
 {
     long sec = TimeFormat.FormatTime(DateTime.Now);
     if (_matureList.Count == 0)
     {
         MessageBox.Show("请先获取成熟列表");
     }
     else
     {
         Mature temp = new Mature();
         string result = "";
         for (int i = 0; i < _matureList.Count; i++)
         {
             temp = _matureList[i];
             if (temp.cTime <= sec)
             {
                 //判断是否已经摘完
                 //判断是否为空
                 //判断是否已经摘取过
                 if (!_autoSteal || temp.cStatus.Equals("无") || temp.cStatus.Equals("已枯萎") || temp.cStatus.Equals("已摘完") || regexMature.IsMatch(temp.cStatus) || temp.cStatus.Equals("已摘取"))
                 {
                     continue;
                 }//_autoSteal 自动偷
                 else
                 {
                     result = Steal(temp.userId, temp.place.ToString());
                     DoResult doResultItem = new DoResult(result);
                     if (result.Contains("\"farmlandIndex\":" + temp.place.ToString() + ",\"harvest\":"))
                     {
                         toLog("摘取" + temp.userName + "的农场的第" + temp.place.ToString() + "号地" + temp.cName + "共" + doResultItem.harvest + "个");
                         saveAch(0, 0, 0, temp.cId, doResultItem.harvest);
                     }
                     else
                     {
                         toLog("摘取" + temp.userName + "的农场的第" + temp.place.ToString() + "号地" + temp.cName + "失败");
                     }
                     _matureList.RemoveAt(i);
                     i--;
                 }
             }
             else
             {
                 break;
             }
         }
     }
 }
Exemple #5
0
 private void MatureListDoWork(Mature m)
 {
     int numWeed = Convert.ToInt32(m.cWeed);
     int numWorm = Convert.ToInt32(m.cWorm);
     string isDry = m.cDry;
     string result = "";
     if (_autoWeed && (numWeed > 0))
     {
         for (int i = 0; i < numWeed; i++)
         {
             result = ClearWeed(m.userId, m.place.ToString());
             if (result.Contains("\"farmlandIndex\":" + m.place.ToString()))
             {
                 toLog("除掉" + m.userName + "的农场的第" + m.place.ToString() + "号地的草成功");
                 saveAch(0, 1, 0, m.cId, "0");
             }
             else
             {
                 toLog("除掉" + m.userName + "的农场的第" + m.place.ToString() + "号地的草失败");
             }
         }
     }
     if (_autoWorm && (numWorm > 0))
     {
         for (int i = 0; i < numWorm; i++)
         {
             result = Spraying(m.userId, m.place.ToString());
             if (result.Contains("\"farmlandIndex\":" + m.place.ToString()))
             {
                 toLog("除掉" + m.userName + "的农场的第" + m.place.ToString() + "号地的虫子成功");
                 saveAch(0, 0, 1, m.cId, "0");
             }
             else
             {
                 toLog("除掉" + m.userName + "的农场的第" + m.place.ToString() + "号地的虫子失败");
             }
         }
     }
     if (_autoWater && isDry.Equals("Yes"))
     {
         result = Water(m.userId, m.place.ToString());
         if (result.Contains("\"farmlandIndex\":" + m.place.ToString()))
         {
             toLog("对" + m.userName + "的农场的第" + m.place.ToString() + "号地浇水成功");
             saveAch(1, 0, 0, m.cId, "0");
         }
         else
         {
             toLog("对" + m.userName + "的农场的第" + m.place.ToString() + "号地浇水失败");
         }
     }
 }
Exemple #6
0
        //处理成熟列表中已经摘完或者土地为空的信息根据配置处理掉有狗
        private void MatureListDeal()
        {
            long sec = TimeFormat.FormatTime(DateTime.Now);
            List<Mature> _matureListTemp = new List<Mature>();
            Mature temp = new Mature();
            for (int i = 0; i < _matureList.Count; i++)
            {
                temp = _matureList[i];
                if (temp.userId.Equals(uIdx))
                {
                    continue;
                }
                else if (temp.cTime <= sec)
                {
                    //判断是否已经摘完
                    //判断是否为空

                    if (temp.cStatus.Equals("无") || temp.cStatus.Equals("已枯萎") || temp.cStatus.Equals("已摘完") || regexMature.IsMatch(temp.cStatus) || temp.cStatus.Equals("已摘取"))
                    {
                        continue;
                    }
                    else if (_autoDog && temp.hasDog.Equals("Yes"))//设置自动防狗的话
                    {
                        continue;
                    }
                    else
                    {
                        _matureListTemp.Add(temp);
                    }
                }
                else
                {
                    _matureListTemp.Add(temp);
                }
            }
            _matureList = _matureListTemp;
        }
Exemple #7
0
 private static int Compare(Mature v1, Mature v2)
 {
     if (v1 != null && v2 != null)
     {
         return v1.cTime.CompareTo(v2.cTime);
     }
     return 0;
 }