private string GetLandStatus(Land newLand, CropItem newCropItem) { string landStatus; if (newLand.b.Equals("0")) { landStatus = "空地"; } else if (newLand.b.Equals("7")) { landStatus = "枯萎"; } else { landStatus = newCropItem.cName; } return landStatus; }
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; }
private void showFarmland(JsonObject farmStatus) { this.Invoke((MethodInvoker)delegate { listViewFarmland.Items.Clear(); }); string landStatus = ""; string cropStatus = ""; for (int i = 0; i < farmStatus.GetCollection().Count; i++) { ListViewItem lv = new ListViewItem(); lv.SubItems[0].Text = i.ToString(); Land newLand = new Land(farmStatus.GetCollection()[i]); CropItem newCropItem = new CropItem(GetCropModel(newLand.a)); //lv.SubItems.Add(newLand.b.Equals("0") ? "空地":newShopItem.cName); landStatus = GetLandStatus(newLand, newCropItem); lv.SubItems.Add(landStatus); lv.SubItems.Add(newLand.f.Equals("0") ? "无" : newLand.f); lv.SubItems.Add(newLand.g.Equals("0") ? "无" : newLand.g); lv.SubItems.Add(newLand.h.Equals("0") ? "是" : "否"); GetCropStatus(out cropStatus, newLand); lv.SubItems.Add(cropStatus); lv.SubItems.Add(TimeFormat.FormatTime((Convert.ToInt64(newLand.q) + Convert.ToInt64(newCropItem.growthCycle)).ToString())); this.Invoke((MethodInvoker)delegate { listViewFarmland.Items.Add(lv); }); } }
private void GetCropStatus(out string cropStatus, Land newLand) { if (newLand.b.Equals("7")) { cropStatus = "已枯萎"; } else if (newLand.b.Equals("0")) { cropStatus = "无"; } else if (newLand.m.Equals("0")) { cropStatus = "第" + (Convert.ToInt32(newLand.j) + 1).ToString() + "季"; } else if (newLand.n.Contains(uIdx)) { cropStatus = "已摘取"; } else { cropStatus = newLand.m.Equals(newLand.l) ? "已摘完" : (newLand.m + "/" + newLand.k); } }
private void LandWater(string userId, JsonObject theFarmStatus) { string dry = ""; string result = ""; User friendInfo = new User(GetUserModel(userId)); if (!userId.Equals("")) { for (int i = 0; i < theFarmStatus.GetCollection().Count; i++) { Land newLand = new Land(theFarmStatus.GetCollection()[i]); dry = newLand.h; if (dry.Equals("0"))//干旱 { result = Water(userId, i.ToString()); if (result.Contains("\"farmlandIndex\":" + i.ToString())) { toLog("对" + friendInfo.userName + "的农场的第" + i.ToString() + "号地浇水成功"); saveAch(1, 0, 0, "", "0"); } else { toLog("对" + friendInfo.userName + "的农场的第" + i.ToString() + "号地浇水失败"); } } } } }
private void LandSpraying(string userId, JsonObject theFarmStatus) { string worm = ""; string result = ""; User friendInfo = new User(GetUserModel(userId)); if (!userId.Equals("")) { for (int i = 0; i < theFarmStatus.GetCollection().Count; i++) { Land newLand = new Land(theFarmStatus.GetCollection()[i]); worm = newLand.g; if (!worm.Equals("0"))//有虫 { for (int j = 0; j < Convert.ToInt32(worm); j++) { result = Spraying(userId, i.ToString()); if (result.Contains("\"farmlandIndex\":" + i.ToString())) { toLog("除掉" + friendInfo.userName + "的农场的第" + i.ToString() + "号地的虫子成功"); saveAch(0, 0, 1, "", "0"); } else { toLog("除掉" + friendInfo.userName + "的农场的第" + i.ToString() + "号地的虫子失败"); } } } } } }
private void LandScaify(string userId, JsonObject theFarmStatus) { string kuwei = ""; string result = ""; User friendInfo = new User(GetUserModel(userId)); //需要判断枯萎时的变量 if (!userId.Equals("")) { for (int i = 0; i < theFarmStatus.GetCollection().Count; i++) { Land newLand = new Land(theFarmStatus.GetCollection()[i]); kuwei = newLand.b;//? if (kuwei.Equals("7"))//无植物? { result = Scarify(userId, i.ToString()); if (result.Contains("\"farmlandIndex\":" + i.ToString())) { toLog("锄掉" + friendInfo.userName + "的农场的第" + i.ToString() + "号地成功"); } else { toLog("锄掉" + friendInfo.userName + "的农场的第" + i.ToString() + "号地失败"); } System.Threading.Thread.Sleep(200); } } } }
private void LandPlant(string userId, JsonObject theFarmStatus) { string have = ""; string result = ""; User friendInfo = new User(GetUserModel(userId)); CropItem cropInfo = new CropItem(GetCropModel(cId)); if (!userId.Equals("")) { for (int i = 0; i < theFarmStatus.GetCollection().Count; i++) { Land newLand = new Land(theFarmStatus.GetCollection()[i]); have = newLand.b; if (have.Equals("0"))//无植物 { BagItem newBagItem = new BagItem(GetBagItemModel(cId)); if (_autoSeed && (Convert.ToInt32(newBagItem.amount) == 0)) { buySeed(cId, "1"); } else { } result = Plant(cId, userId, i.ToString()); if (result.Contains("\"farmlandIndex\":" + i.ToString()) && result.Contains("\"cId\":" + cId.ToString())) { toLog("往" + friendInfo.userName + "的农场的第" + i.ToString() + "号地种植" + cropInfo.cName + "成功"); } else { toLog("往" + friendInfo.userName + "的农场的第" + i.ToString() + "号地种植" + cropInfo.cName + "失败"); } } } } }
private void LandHarvest(string userId, JsonObject theFarmStatus) { string cropStatus = ""; string result = ""; User friendInfo = new User(GetUserModel(userId)); string dogId = ""; string isHungry = ""; dogId = dogJson.GetValue("dogId"); isHungry = dogJson.GetValue("isHungry"); if (!userId.Equals("")) { if (userId.Equals(uIdx)) { for (int i = 0; i < theFarmStatus.GetCollection().Count; i++) { Land newLand = new Land(theFarmStatus.GetCollection()[i]); bool landDogFlag = true; //true表示可偷,false表示不可偷 //自己的地尽管偷 //无狗 无狗粮 /* if (_autoDog) { landDogFlag = (dogId.Equals("0") || isHungry.Equals("1")); toLog(friendInfo.userName + "的农场有狗,不偷"); }*/ if (landDogFlag) { GetCropStatus(out cropStatus, newLand); if (cropStatus.Equals("无") || cropStatus.Equals("已枯萎") || regexMature.IsMatch(cropStatus) || cropStatus.Equals("已摘取")) { } else { result = Harvest(userId, i.ToString()); DoResult doResultItem = new DoResult(result); if (result.Contains("\"farmlandIndex\":" + i.ToString() + ",\"harvest\":")) { toLog("收获" + friendInfo.userName + "的农场的第" + i.ToString() + "号地的" + new CropItem(GetCropModel(newLand.a)).cName + "一共" + doResultItem.harvest + "个"); saveAch(0, 0, 0, newLand.a, doResultItem.harvest); } else { toLog("收获" + friendInfo.userName + "的农场的第" + i.ToString() + "号地失败"); } } } } } else { for (int i = 0; i < theFarmStatus.GetCollection().Count; i++) { Land newLand = new Land(theFarmStatus.GetCollection()[i]); bool landDogFlag = true; //true表示可偷,false表示不可偷 //无狗 无狗粮 if (_autoDog) { landDogFlag = (dogId.Equals("0") || isHungry.Equals("1")); toLog(friendInfo.userName + "的农场有狗,不偷"); } if (landDogFlag) { GetCropStatus(out cropStatus, newLand); if (cropStatus.Equals("无") || cropStatus.Equals("已枯萎") || regexMature.IsMatch(cropStatus) || cropStatus.Equals("已摘取")) { } else { result = Steal(userId, i.ToString()); DoResult doResultItem = new DoResult(result); if (result.Contains("\"farmlandIndex\":" + i.ToString() + ",\"harvest\":")) { toLog("摘取" + friendInfo.userName + "的农场的第" + i.ToString() + "号地的" + new CropItem(GetCropModel(newLand.a)).cName + "一共" + doResultItem.harvest + "个"); saveAch(0, 0, 0, newLand.a, doResultItem.harvest); } else { toLog("摘取" + friendInfo.userName + "的农场的第" + i.ToString() + "号地失败"); } } } } } } }