Skip to content

Commit

Permalink
添加农场活动判断
Browse files Browse the repository at this point in the history
  • Loading branch information
constanline committed Aug 17, 2023
1 parent 801499a commit f407358
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
40 changes: 24 additions & 16 deletions app/src/main/java/pansong291/xposed/quickenergy/AntOrchard.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ public void run() {
private static String[] wuaList;
private static String getWua() {
if (wuaList == null) {
String content = FileUtils.readFromFile(FileUtils.getWuaFile());
wuaList = content.split("\n");
try {
String content = FileUtils.readFromFile(FileUtils.getWuaFile());
wuaList = content.split("\n");
} catch (Throwable ignored) {
wuaList = new String[0];
}
}
if (wuaList.length > 0) {
return wuaList[RandomUtils.nextInt(0, wuaList.length - 1)];
Expand All @@ -87,17 +91,19 @@ private static void orchardSpreadManure() {
try {
JSONObject jo = new JSONObject(AntOrchardRpcCall.orchardIndex());
if ("100".equals(jo.getString("resultCode"))) {
JSONObject spreadManureStage = jo.getJSONObject("spreadManureActivity")
.getJSONObject("spreadManureStage");
if ("FINISHED".equals(spreadManureStage.getString("status"))) {
String sceneCode = spreadManureStage.getString("sceneCode");
String taskType = spreadManureStage.getString("taskType");
int awardCount = spreadManureStage.getInt("awardCount");
JSONObject joo = new JSONObject(AntOrchardRpcCall.receiveTaskAward(sceneCode, taskType));
if (joo.getBoolean("success")) {
Log.farm("丰收礼包🎁[肥料*" + awardCount + "]");
} else {
Log.recordLog(joo.getString("desc"), joo.toString());
if (jo.has("spreadManureActivity")) {
JSONObject spreadManureStage = jo.getJSONObject("spreadManureActivity")
.getJSONObject("spreadManureStage");
if ("FINISHED".equals(spreadManureStage.getString("status"))) {
String sceneCode = spreadManureStage.getString("sceneCode");
String taskType = spreadManureStage.getString("taskType");
int awardCount = spreadManureStage.getInt("awardCount");
JSONObject joo = new JSONObject(AntOrchardRpcCall.receiveTaskAward(sceneCode, taskType));
if (joo.getBoolean("success")) {
Log.farm("丰收礼包🎁[肥料*" + awardCount + "]");
} else {
Log.recordLog(joo.getString("desc"), joo.toString());
}
}
}
String taobaoData = jo.getString("taobaoData");
Expand Down Expand Up @@ -174,7 +180,7 @@ private static void drawLotteryPlus(JSONObject lotteryPlusInfo) {
int awardCount = jo.optInt("awardCount", 1);
jo = new JSONObject(AntOrchardRpcCall.drawLottery());
if ("100".equals(jo.getString("resultCode"))) {
Log.farm("七日礼包🎁[" + (singleDesc != null ? singleDesc + "随机礼包" : "肥料") + "*" + awardCount
Log.farm("七日礼包🎁[" + singleDesc + "随机礼包" + "*" + awardCount
+ "]");
} else {
Log.i(jo.getString("resultDesc"), jo.toString());
Expand All @@ -196,8 +202,10 @@ private static void doOrchardDailyTask(String userId) {
String s = AntOrchardRpcCall.orchardListTask();
JSONObject jo = new JSONObject(s);
if ("100".equals(jo.getString("resultCode"))) {
JSONObject signTaskInfo = jo.getJSONObject("signTaskInfo");
orchardSign(signTaskInfo);
if (jo.has("signTaskInfo")) {
JSONObject signTaskInfo = jo.getJSONObject("signTaskInfo");
orchardSign(signTaskInfo);
}
JSONArray jaTaskList = jo.getJSONArray("taskList");
for (int i = 0; i < jaTaskList.length(); i++) {
jo = jaTaskList.getJSONObject(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public static int delay() {
}

public static int nextInt(int min, int max) {
if (min >= max) return min;
return rnd.nextInt(max - min) + min;
}

Expand Down

0 comments on commit f407358

Please sign in to comment.