Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #256 from LazyImmortal/dev
Browse files Browse the repository at this point in the history
添加 新版行走路线(默认走:龙年祈福),开启后将屏蔽旧版行走路线“运动-开启宝箱”
  • Loading branch information
TKaxv-7S authored Jul 22, 2024
2 parents dce4352 + 284bebf commit 7e17151
Show file tree
Hide file tree
Showing 2 changed files with 179 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
import tkaxv7s.xposed.sesame.model.normal.base.BaseModel;
import tkaxv7s.xposed.sesame.util.*;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.List;

Expand All @@ -28,6 +30,8 @@ public class AntSports extends ModelTask {
private static final String TAG = AntSports.class.getSimpleName();

private int tmpStepCount = -1;
private BooleanModelField walkGo;
private String pathId = "p0002023122214520001";
private BooleanModelField openTreasureBox;
private BooleanModelField receiveCoinAsset;
private BooleanModelField donateCharityCoin;
Expand Down Expand Up @@ -55,6 +59,7 @@ public ModelGroup getGroup() {
@Override
public ModelFields getFields() {
ModelFields modelFields = new ModelFields();
modelFields.addField(walkGo = new BooleanModelField("walkGo", "行走路线", false));
modelFields.addField(openTreasureBox = new BooleanModelField("openTreasureBox", "开启宝箱", false));
modelFields.addField(sportsTasks = new BooleanModelField("sportsTasks", "开启运动任务", false));
modelFields.addField(receiveCoinAsset = new BooleanModelField("receiveCoinAsset", "收运动币", false));
Expand Down Expand Up @@ -121,7 +126,10 @@ public void run() {
sportsTasks();

ClassLoader loader = ApplicationHook.getClassLoader();
if (openTreasureBox.getValue())
if (walkGo.getValue()) {
walkGo(pathId);
}
if (openTreasureBox.getValue() && !walkGo.getValue())
queryMyHomePage(loader);

if (donateCharityCoin.getValue() && Status.canDonateCharityCoin())
Expand Down Expand Up @@ -242,6 +250,105 @@ private void receiveCoinAsset() {
}
}

private void walkGo(String pathId) {
try {
JSONObject user = new JSONObject(AntSportsRpcCall.queryUser());
if (!user.getBoolean("success")) {
return;
}
String joinedPathId = user.getJSONObject("data").getString("joinedPathId");
if (joinedPathId == null) {
joinPath(pathId);
return;
}
JSONObject path = queryPath(joinedPathId);
JSONObject userPathStep = path.getJSONObject("userPathStep");
if ("COMPLETED".equals(userPathStep.getString("pathCompleteStatus"))) {
Log.record("完成路线🚶🏻‍♂️[" + userPathStep.getString("pathName") + "]");
joinPath(pathId);
return;
}
int minGoStepCount = path.getJSONObject("path").getInt("minGoStepCount");
int pathStepCount = path.getJSONObject("path").getInt("pathStepCount");
int forwardStepCount = userPathStep.getInt("forwardStepCount");
int remainStepCount = userPathStep.getInt("remainStepCount");
int needStepCount = pathStepCount - forwardStepCount;
if (remainStepCount >= minGoStepCount) {
int useStepCount = Math.min(remainStepCount, needStepCount);
walkGo(userPathStep.getString("pathId"), useStepCount, userPathStep.getString("pathName"));
}
} catch (Throwable t) {
Log.i(TAG, "walkGo err:");
Log.printStackTrace(TAG, t);
}
}

private void walkGo(String pathId, int useStepCount, String pathName) {
try {
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
JSONObject jo = new JSONObject(AntSportsRpcCall.walkGo("202312191135", sdf.format(date), pathId, useStepCount));
if (jo.getBoolean("success")) {
Log.record("行走路线🚶🏻‍♂️[" + pathName + "]#前进了" + useStepCount + "步");
queryPath(pathId);
}
} catch (Throwable t) {
Log.i(TAG, "walkGo err:");
Log.printStackTrace(TAG, t);
}
}

private JSONObject queryPath(String pathId) {
JSONObject path = null;
try {
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
JSONObject jo = new JSONObject(AntSportsRpcCall.queryPath("202312191135", sdf.format(date), pathId));
if (jo.getBoolean("success")) {
path = jo.getJSONObject("data");
JSONArray ja = jo.getJSONObject("data").getJSONArray("treasureBoxList");
for (int i = 0; i < ja.length(); i++) {
JSONObject treasureBox = ja.getJSONObject(i);
receiveEvent(treasureBox.getString("boxNo"));
}
}
} catch (Throwable t) {
Log.i(TAG, "queryPath err:");
Log.printStackTrace(TAG, t);
}
return path;
}

private void receiveEvent(String eventBillNo) {
try {
JSONObject jo = new JSONObject(AntSportsRpcCall.receiveEvent(eventBillNo));
if (!jo.getBoolean("success")) {
return;
}
JSONArray ja = jo.getJSONObject("data").getJSONArray("rewards");
for (int i = 0; i < ja.length(); i++) {
jo = ja.getJSONObject(i);
Log.record("行走路线🎁开宝箱获得[" + jo.getString("rewardName") + "]*" + jo.getInt("count"));
}
} catch (Throwable t) {
Log.i(TAG, "receiveEvent err:");
Log.printStackTrace(TAG, t);
}
}

private void joinPath(String pathId) {
try {
JSONObject jo = new JSONObject(AntSportsRpcCall.joinPath(pathId));
if (jo.getBoolean("success")) {
JSONObject path = queryPath(pathId);
Log.record("加入路线🚶🏻‍♂️[" + path.getJSONObject("path").getString("name") + "]");
}
} catch (Throwable t) {
Log.i(TAG, "joinPath err:");
Log.printStackTrace(TAG, t);
}
}

private void queryMyHomePage(ClassLoader loader) {
try {
String s = AntSportsRpcCall.queryMyHomePage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,77 @@ public static String exchange(String actId, int count, String donateToken) {
+ timeZone + "\",\"ver\":0}]");
}


/*
* 新版 走路线
*/

// 查询用户
public static String queryUser() {
return ApplicationHook.requestString("com.alipay.sportsplay.biz.rpc.walk.queryUser",
"[{\"source\":\"ch_appcenter__chsub_9patch\",\"timeZone\":\"" + timeZone + "\"}]");
}

// 查询主题列表
public static String queryThemeList() {
return ApplicationHook.requestString("com.alipay.sportsplay.biz.rpc.walk.theme.queryThemeList",
"[{\"chInfo\":\"ch_appcenter__chsub_9patch\",\"clientOS\":\"android\","
+ "\"features\":[\"DAILY_STEPS_RANK_V2\",\"STEP_BATTLE\",\"CLUB_HOME_CARD\",\"NEW_HOME_PAGE_STATIC\",\"CLOUD_SDK_AUTH\",\"STAY_ON_COMPLETE\",\"EXTRA_TREASURE_BOX\",\"SUPPORT_AI\",\"SUPPORT_FLYRABBIT\",\"SUPPORT_NEW_MATCH\",\"EXTERNAL_ADVERTISEMENT_TASK\",\"PROP\",\"PROPV2\",\"ASIAN_GAMES\"]"
+ "}]");
}

// 查询世界地图
public static String queryWorldMap(String themeId) {
return ApplicationHook.requestString("com.alipay.sportsplay.biz.rpc.walk.queryWorldMap",
"[{\"chInfo\":\"ch_appcenter__chsub_9patch\",\"clientOS\":\"android\","
+ "\"features\":[\"DAILY_STEPS_RANK_V2\",\"STEP_BATTLE\",\"CLUB_HOME_CARD\",\"NEW_HOME_PAGE_STATIC\",\"CLOUD_SDK_AUTH\",\"STAY_ON_COMPLETE\",\"EXTRA_TREASURE_BOX\",\"SUPPORT_AI\",\"SUPPORT_FLYRABBIT\",\"SUPPORT_NEW_MATCH\",\"EXTERNAL_ADVERTISEMENT_TASK\",\"PROP\",\"PROPV2\",\"ASIAN_GAMES\"]"
+ ",\"themeId\":\"" + themeId + "\"}]");
}

// 查询城市路线
public static String queryCityPath(String cityId) {
return ApplicationHook.requestString("com.alipay.sportsplay.biz.rpc.walk.queryCityPath",
"[{\"chInfo\":\"ch_appcenter__chsub_9patch\",\"clientOS\":\"android\","
+ "\"features\":[\"DAILY_STEPS_RANK_V2\",\"STEP_BATTLE\",\"CLUB_HOME_CARD\",\"NEW_HOME_PAGE_STATIC\",\"CLOUD_SDK_AUTH\",\"STAY_ON_COMPLETE\",\"EXTRA_TREASURE_BOX\",\"SUPPORT_AI\",\"SUPPORT_FLYRABBIT\",\"SUPPORT_NEW_MATCH\",\"EXTERNAL_ADVERTISEMENT_TASK\",\"PROP\",\"PROPV2\",\"ASIAN_GAMES\"]"
+ ",\"cityId\":\"" + cityId + "\"}]");
}

// 查询路线
public static String queryPath(String appId, String date, String pathId) {
String wufuRewardType = "WUFU_CARD";
return ApplicationHook.requestString("com.alipay.sportsplay.biz.rpc.walk.queryPath",
"[{\"appId\":\"" + appId + "\",\"date\":\"" + date + "\",\"pathId\":\"" + pathId
+ "\",\"source\":\"ch_appcenter__chsub_9patch\",\"timeZone\":\"" + timeZone
+ "\",\"wufuRewardType\":\"" + wufuRewardType + "\"}]");
}

// 加入路线
public static String joinPath(String pathId) {
return ApplicationHook.requestString("com.alipay.sportsplay.biz.rpc.walk.joinPath",
"[{\"pathId\":\"" + pathId + "\",\"source\":\"ch_appcenter__chsub_9patch\"}]");
}

// 行走路线
public static String walkGo(String appId, String date, String pathId, int useStepCount) {
return ApplicationHook.requestString("com.alipay.sportsplay.biz.rpc.walk.go",
"[{\"appId\":\"" + appId + "\",\"date\":\"" + date + "\",\"pathId\":\"" + pathId
+ "\",\"source\":\"ch_appcenter__chsub_9patch\",\"timeZone\":\"" + timeZone
+ "\",\"useStepCount\":\"" + useStepCount + "\"}]");
}

// 开启宝箱
// eventBillNo = boxNo(WalkGo)
public static String receiveEvent(String eventBillNo) {
return ApplicationHook.requestString("com.alipay.sportsplay.biz.rpc.walk.receiveEvent",
"[{\"eventBillNo\":\"" + eventBillNo + "\"}]");
}

// 查询路线奖励
public static String queryPathReward(String appId, String pathId) {
return ApplicationHook.requestString("com.alipay.sportsplay.biz.rpc.walk.queryPathReward", "[{\"appId\":\""
+ appId + "\",\"pathId\":\"" + pathId + "\",\"source\":\"ch_appcenter__chsub_9patch\"}]");
}

/* 这个好像没用 */
public static String exchangeSuccess(String exchangeId) {
String args1 = "[{\"exchangeId\":\"" + exchangeId
Expand Down

0 comments on commit 7e17151

Please sign in to comment.