Skip to content

Commit 1cceba0

Browse files
committed
修复bug,增加功能。合并来自cwj851的pr,收能量、能量雨、合种浇水rpc更新成可完成活力值任务,增加森林礼盒领取功能,新村任务优化,森林农场日常任务小优化,庄园日常任务优化。
1 parent 15c7074 commit 1cceba0

21 files changed

+666
-138
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,5 @@ fastlane/screenshots
5959
fastlane/test_output
6060
fastlane/readme.md
6161

62-
Xposed-Modules-Repo/
62+
Xposed-Modules-Repo/
63+
plugin/

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ android {
88
minSdk 21
99
//noinspection ExpiredTargetSdkVersion
1010
targetSdk 29
11-
versionCode 57
12-
versionName "1.1.6"
11+
versionCode 59
12+
versionName "1.1.7"
1313
}
1414
buildTypes {
1515
release {

app/src/main/java/pansong291/xposed/quickenergy/AntFarm.java

Lines changed: 105 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
import java.util.HashSet;
1010
import java.util.Set;
11+
import java.util.Iterator;
12+
import java.util.ArrayList;
13+
import java.util.List;
1114

1215
public class AntFarm {
1316
private static final String TAG = AntFarm.class.getCanonicalName();
@@ -95,9 +98,24 @@ private static class FarmTool {
9598

9699
private static FarmTool[] farmTools;
97100

101+
private static final List<String> bizKeyList;
102+
103+
static {
104+
bizKeyList = new ArrayList<>();
105+
bizKeyList.add("ADD_GONGGE_NEW");
106+
bizKeyList.add("USER_STARVE_PUSH");
107+
bizKeyList.add("HIRE_LOW_ACTIVITY");
108+
bizKeyList.add("HEART_DONATION_ADVANCED_FOOD_V2");
109+
bizKeyList.add("YEB_PURCHASE");
110+
bizKeyList.add("ONLINE_PAY");
111+
bizKeyList.add("DIANTAOHUANDUAN");
112+
}
113+
98114
public static void start() {
99115
if (!Config.enableFarm())
100116
return;
117+
118+
PluginUtils.invoke(AntFarm.class, PluginUtils.PluginAction.START);
101119
new Thread() {
102120

103121
@Override
@@ -220,6 +238,10 @@ public void run() {
220238
cook(userId);
221239
}
222240

241+
if (Config.chickenDiary()) {
242+
queryChickenDiaryList();
243+
}
244+
223245
if (Config.useNewEggTool()) {
224246
useFarmTool(ownerFarmId, ToolType.NEWEGGTOOL);
225247
syncAnimalStatus(ownerFarmId);
@@ -282,6 +304,8 @@ public void run() {
282304
}
283305
}
284306

307+
PluginUtils.invoke(AntFarm.class, PluginUtils.PluginAction.STOP);
308+
285309
} catch (Throwable t) {
286310
Log.i(TAG, "AntFarm.start.run err:");
287311
Log.printStackTrace(TAG, t);
@@ -687,42 +711,39 @@ private static void doFarmDailyTask() {
687711
for (int i = 0; i < jaFarmTaskList.length(); i++) {
688712
jo = jaFarmTaskList.getJSONObject(i);
689713
String title = null;
690-
String taskId = null;
691-
int awardCount = 0;
692-
if (!jo.has("taskMode"))
693-
continue;
694714
if (jo.has("title"))
695715
title = jo.getString("title");
696-
if ("VIEW".equals(jo.getString("taskMode")) && "TODO".equals(jo.getString("taskStatus"))) {
697-
taskId = jo.getString("taskId");
698-
awardCount = jo.getInt("awardCount");
699-
jo = new JSONObject(AntFarmRpcCall.doFarmTask(taskId));
700-
if ("SUCCESS".equals(jo.getString("memo"))) {
701-
Log.farm("庄园任务🧾[" + title + "]#获得饲料" + awardCount + "g");
702-
} else {
703-
Log.recordLog(jo.getString("memo"), jo.toString());
704-
}
705-
} else if ("庄园小视频".equals(title) && "TODO".equals(jo.getString("taskStatus"))) {
706-
awardCount = jo.getInt("awardCount");
707-
jo = new JSONObject(AntFarmRpcCall.queryTabVideoUrl());
708-
if ("SUCCESS".equals(jo.getString("memo"))) {
709-
String videoUrl = jo.getString("videoUrl");
710-
String contentId = videoUrl.substring(videoUrl.indexOf("&contentId=") + 1,
711-
videoUrl.indexOf("&refer"));
712-
jo = new JSONObject(AntFarmRpcCall.videoDeliverModule(contentId));
713-
if (jo.getBoolean("success")) {
714-
Thread.sleep(15100);
715-
jo = new JSONObject(AntFarmRpcCall.videoTrigger(contentId));
716+
if ("TODO".equals(jo.getString("taskStatus"))) {
717+
int awardCount = jo.optInt("awardCount");
718+
String bizKey = jo.getString("bizKey");
719+
if ("VIEW".equals(jo.optString("taskMode")) || bizKeyList.contains(bizKey)) {
720+
jo = new JSONObject(AntFarmRpcCall.doFarmTask(bizKey));
721+
if ("SUCCESS".equals(jo.getString("memo"))) {
722+
Log.farm("庄园任务🧾[" + title + "]#获得饲料" + awardCount + "g");
723+
} else {
724+
Log.recordLog(jo.getString("memo"), jo.toString());
725+
}
726+
} else if ("庄园小视频".equals(title)) {
727+
jo = new JSONObject(AntFarmRpcCall.queryTabVideoUrl());
728+
if ("SUCCESS".equals(jo.getString("memo"))) {
729+
String videoUrl = jo.getString("videoUrl");
730+
String contentId = videoUrl.substring(videoUrl.indexOf("&contentId=") + 1,
731+
videoUrl.indexOf("&refer"));
732+
jo = new JSONObject(AntFarmRpcCall.videoDeliverModule(contentId));
716733
if (jo.getBoolean("success")) {
717-
Log.farm("庄园任务🧾[" + title + "]#获得饲料" + awardCount + "g");
734+
Thread.sleep(15100);
735+
jo = new JSONObject(AntFarmRpcCall.videoTrigger(contentId));
736+
if (jo.getBoolean("success")) {
737+
Log.farm("庄园任务🧾[" + title + "]#获得饲料" + awardCount + "g");
738+
} else {
739+
Log.recordLog(jo.getString("resultMsg"), jo.toString());
740+
}
718741
} else {
719742
Log.recordLog(jo.getString("resultMsg"), jo.toString());
720743
}
721744
} else {
722-
Log.recordLog(jo.getString("resultMsg"), jo.toString());
745+
Log.recordLog(jo.getString("memo"), jo.toString());
723746
}
724-
} else {
725-
Log.recordLog(jo.getString("memo"), jo.toString());
726747
}
727748
}
728749
}
@@ -1366,4 +1387,60 @@ private static void acceptGift() {
13661387
}
13671388
}
13681389

1390+
private static void queryChickenDiary(String queryDayStr) {
1391+
try {
1392+
JSONObject jo = new JSONObject(AntFarmRpcCall.queryChickenDiary(queryDayStr));
1393+
if ("SUCCESS".equals(jo.getString("resultCode"))) {
1394+
JSONObject chickenDiary = jo.getJSONObject("data").getJSONObject("chickenDiary");
1395+
String diaryDateStr = chickenDiary.getString("diaryDateStr");
1396+
if (!chickenDiary.has("tietieStatus"))
1397+
return;
1398+
JSONObject tietieStatus = chickenDiary.getJSONObject("tietieStatus");
1399+
Iterator it = tietieStatus.keys();
1400+
while (it.hasNext()) {
1401+
String key = (String) it.next();
1402+
if (tietieStatus.optBoolean(key, false)) {
1403+
jo = new JSONObject(AntFarmRpcCall.diaryTietie(diaryDateStr, key));
1404+
if ("SUCCESS".equals(jo.getString("memo"))) {
1405+
String prizeType = jo.getString("prizeType");
1406+
int prizeNum = jo.optInt("prizeNum", 0);
1407+
Log.farm("贴贴小鸡💞[" + prizeType + "*" + prizeNum + "]");
1408+
} else {
1409+
Log.i(jo.getString("memo"), jo.toString());
1410+
}
1411+
}
1412+
}
1413+
} else {
1414+
Log.i(jo.getString("resultDesc"), jo.toString());
1415+
}
1416+
} catch (Throwable t) {
1417+
Log.i(TAG, "queryChickenDiary err:");
1418+
Log.printStackTrace(TAG, t);
1419+
}
1420+
}
1421+
1422+
private static void queryChickenDiaryList() {
1423+
try {
1424+
JSONObject jo = new JSONObject(AntFarmRpcCall.queryChickenDiaryList());
1425+
if ("SUCCESS".equals(jo.getString("resultCode"))) {
1426+
JSONArray chickenDiaryBriefList = jo.getJSONObject("data").optJSONArray("chickenDiaryBriefList");
1427+
if (chickenDiaryBriefList != null && chickenDiaryBriefList.length() > 0) {
1428+
for (int i = 0; i < chickenDiaryBriefList.length(); i++) {
1429+
jo = chickenDiaryBriefList.getJSONObject(i);
1430+
if (!jo.optBoolean("read", true)) {
1431+
String dateStr = jo.getString("dateStr");
1432+
queryChickenDiary(dateStr);
1433+
Thread.sleep(300);
1434+
}
1435+
}
1436+
}
1437+
} else {
1438+
Log.i(jo.getString("resultDesc"), jo.toString());
1439+
}
1440+
} catch (Throwable t) {
1441+
Log.i(TAG, "queryChickenDiaryList err:");
1442+
Log.printStackTrace(TAG, t);
1443+
}
1444+
}
1445+
13691446
}

0 commit comments

Comments
 (0)