Skip to content

Commit

Permalink
增加欢乐揍小鸡,增加小鸡使用特殊食品开关(默认关),修复切换账号/下次循环的时候不会自动加载配置的问题(#487)
Browse files Browse the repository at this point in the history
  • Loading branch information
constanline committed Feb 18, 2024
1 parent c1d60b7 commit d730d03
Show file tree
Hide file tree
Showing 14 changed files with 94 additions and 20 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ jobs:
buildToolsVersion: 31.0.0

- name: Upload to Release Action
uses: Shopify/upload-to-release@v1.0.1
uses: termux/upload-release[email protected]
with:
name: xqe-sesame-${{ github.event.release.tag_name }}.apk
path: ${{ steps.sign_app.outputs.signedFile }}
repo-token: ${{ github.token }}
content-type: application/zip
asset_name: xqe-sesame-${{ github.event.release.tag_name }}.apk
file: ${{ steps.sign_app.outputs.signedFile }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
overwrite: true
checksums: sha256
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
//noinspection ExpiredTargetSdkVersion
targetSdk 29
versionCode 71
versionName "1.2.3-beta12"
versionName "1.2.3-beta14"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.json.JSONArray;
import org.json.JSONObject;
import pansong291.xposed.quickenergy.data.RuntimeInfo;
import pansong291.xposed.quickenergy.hook.AntBookReadRpcCall;
import pansong291.xposed.quickenergy.util.Config;
import pansong291.xposed.quickenergy.util.Log;
Expand All @@ -15,6 +16,12 @@ public static void start() {
if (!Config.antBookRead())
return;

long executeTime = RuntimeInfo.getInstance().getLong("consumeGold", 0);

This comment has been minimized.

Copy link
@acooler15

acooler15 Feb 24, 2024

Contributor

大佬,这里使用了消费金的key

if (System.currentTimeMillis() - executeTime < 21600000) {
return;
}
RuntimeInfo.getInstance().put("consumeGold", System.currentTimeMillis());

new Thread() {
@Override
public void run() {
Expand Down
25 changes: 16 additions & 9 deletions app/src/main/java/pansong291/xposed/quickenergy/AntFarm.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public CharSequence nickName() {
}

public enum GameType {
starGame, jumpGame, flyGame;
starGame, jumpGame, flyGame, hitGame;

public static final CharSequence[] gameNames = { "星星球", "登山赛", "飞行赛" };
public static final CharSequence[] gameNames = { "星星球", "登山赛", "飞行赛", "欢乐揍小鸡" };

public CharSequence gameName() {
return gameNames[ordinal()];
Expand Down Expand Up @@ -140,9 +140,13 @@ public void run() {
harvestBenevolenceScore = joFarmVO.getDouble("harvestBenevolenceScore");
parseSyncAnimalStatusResponse(joFarmVO.toString());
userId = joFarmVO.getJSONObject("masterUserInfoVO").getString("userId");
JSONArray cuisineList = jo.getJSONArray("cuisineList");
if (!AnimalFeedStatus.SLEEPY.name().equals(ownerAnimal.animalFeedStatus))
useFarmFood(cuisineList);

if (Config.useSpecialFood()) {
JSONArray cuisineList = jo.getJSONArray("cuisineList");
if (!AnimalFeedStatus.SLEEPY.name().equals(ownerAnimal.animalFeedStatus))
useFarmFood(cuisineList);
}

if (jo.has("lotteryPlusInfo")) {
drawLotteryPlus(jo.getJSONObject("lotteryPlusInfo"));
}
Expand Down Expand Up @@ -234,6 +238,7 @@ public void run() {
recordFarmGame(GameType.starGame);
recordFarmGame(GameType.jumpGame);
recordFarmGame(GameType.flyGame);
recordFarmGame(GameType.hitGame);
}

if (Config.kitchen()) {
Expand Down Expand Up @@ -695,8 +700,8 @@ private static void recordFarmGame(GameType gameType) {
JSONArray awardInfos = jo.getJSONArray("awardInfos");
StringBuilder award = new StringBuilder();
for (int i = 0; i < awardInfos.length(); i++) {
jo = awardInfos.getJSONObject(i);
award.append(jo.getString("awardName")).append("*").append(jo.getInt("awardCount"));
JSONObject awardInfo = awardInfos.getJSONObject(i);
award.append(awardInfo.getString("awardName")).append("*").append(awardInfo.getInt("awardCount"));
}
if (jo.has("receiveFoodCount")) {
award.append(";肥料*").append(jo.getString("receiveFoodCount"));
Expand Down Expand Up @@ -799,8 +804,10 @@ private static void receiveFarmTaskAward() {
jo = new JSONObject(s);
memo = jo.getString("memo");
if ("SUCCESS".equals(memo)) {
foodStock = jo.getInt("foodStock");
Log.farm("领取奖励🎖️[" + taskTitle + "]#" + jo.getInt("haveAddFoodStock") + "g");
if (jo.has("foodStock")) {
foodStock = jo.getInt("foodStock");
Log.farm("领取奖励🎖️[" + taskTitle + "]#" + jo.getInt("haveAddFoodStock") + "g");
}
if (unreceiveTaskAward > 0)
unreceiveTaskAward--;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.json.JSONArray;
import org.json.JSONObject;
import pansong291.xposed.quickenergy.data.RuntimeInfo;
import pansong291.xposed.quickenergy.hook.ConsumeGoldRpcCall;
import pansong291.xposed.quickenergy.util.Config;
import pansong291.xposed.quickenergy.util.Log;
Expand All @@ -16,6 +17,12 @@ public static void start() {
if (!Config.consumeGold())
return;

long executeTime = RuntimeInfo.getInstance().getLong("consumeGold", 0);
if (System.currentTimeMillis() - executeTime < 21600000) {
return;
}
RuntimeInfo.getInstance().put("consumeGold", System.currentTimeMillis());

new Thread() {
@Override
public void run() {
Expand Down
19 changes: 15 additions & 4 deletions app/src/main/java/pansong291/xposed/quickenergy/OmegakoiTown.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.json.JSONArray;
import org.json.JSONObject;
import pansong291.xposed.quickenergy.data.RuntimeInfo;
import pansong291.xposed.quickenergy.hook.OmegakoiTownRpcCall;
import pansong291.xposed.quickenergy.util.Config;
import pansong291.xposed.quickenergy.util.Log;
Expand Down Expand Up @@ -48,6 +49,12 @@ public static void start() {
if (!Config.omegakoiTown())
return;

long executeTime = RuntimeInfo.getInstance().getLong("omegakoiTown", 0);
if (System.currentTimeMillis() - executeTime < 21600000) {
return;
}
RuntimeInfo.getInstance().put("omegakoiTown", System.currentTimeMillis());

new Thread() {
@Override
public void run() {
Expand Down Expand Up @@ -82,10 +89,14 @@ private static void getUserTasks() {
continue;
int amount = task.getJSONObject("reward").getInt("amount");
String itemId = task.getJSONObject("reward").getString("itemId");
RewardType rewardType = RewardType.valueOf(itemId);
jo = new JSONObject(OmegakoiTownRpcCall.triggerTaskReward(taskId));
if (jo.getBoolean("success")) {
Log.other("小镇任务🌇[" + name + "]#" + amount + "[" + rewardType.rewardName() + "]");
try {
RewardType rewardType = RewardType.valueOf(itemId);
jo = new JSONObject(OmegakoiTownRpcCall.triggerTaskReward(taskId));
if (jo.getBoolean("success")) {
Log.other("小镇任务🌇[" + name + "]#" + amount + "[" + rewardType.rewardName() + "]");
}
} catch (Throwable th) {
Log.i(TAG, "spec RewardType:" + itemId + ";未知的类型");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ public static int RandomScore(String str) {
return RandomUtils.nextInt(150, 170) * 10;
} else if ("flyGame".equals(str)) {
return RandomUtils.nextInt(5000, 8000);
} else if ("hitGame".equals(str)) {
return RandomUtils.nextInt(60, 100);
} else {
return 210;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public void run() {
String targetUid = RpcUtil.getUserId(XposedHook.classLoader);
if (targetUid != null) {
FriendIdMap.setCurrentUid(targetUid);
Config.shouldReload = true;

Statistics.resetToday();
AntForest.checkEnergyRanking(XposedHook.classLoader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class SettingsActivity extends Activity {
sw_enableStall, sw_stallAutoClose, sw_stallAutoOpen, sw_stallAutoTask, sw_stallReceiveAward,
sw_stallOpenType, sw_stallDonate, sw_chickenDiary, sw_collectGiftBox, sw_stallInviteRegister,
sw_stallThrowManure, sw_greenFinance, sw_totalCertCount, sw_batchRobEnergy, sw_antBookRead, sw_consumeGold,
sw_omegakoiTown, sw_language_simplified_chinese;
sw_omegakoiTown, sw_language_simplified_chinese, sw_special_food;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -186,6 +186,7 @@ private void initSwitch() {
sw_receiveFarmToolReward = findViewById(R.id.sw_receiveFarmToolReward);
sw_recordFarmGame = findViewById(R.id.sw_recordFarmGame);
sw_kitchen = findViewById(R.id.sw_kitchen);
sw_special_food = findViewById(R.id.sw_special_food);
sw_useNewEggTool = findViewById(R.id.sw_useNewEggTool);
sw_harvestProduce = findViewById(R.id.sw_harvestProduce);
sw_donation = findViewById(R.id.sw_donation);
Expand Down Expand Up @@ -265,6 +266,7 @@ protected void onResume() {
sw_receiveFarmToolReward.setChecked(Config.receiveFarmToolReward());
sw_recordFarmGame.setChecked(Config.recordFarmGame());
sw_kitchen.setChecked(Config.kitchen());
sw_special_food.setChecked(Config.useSpecialFood());
sw_useNewEggTool.setChecked(Config.useNewEggTool());
sw_harvestProduce.setChecked(Config.harvestProduce());
sw_donation.setChecked(Config.donation());
Expand Down Expand Up @@ -437,6 +439,10 @@ public void onClick(View v) {
Config.setKitchen(sw.isChecked());
break;

case R.id.sw_special_food:
Config.setUseSpecialFood(sw.isChecked());
break;

case R.id.sw_useNewEggTool:
Config.setUseNewEggTool(sw.isChecked());
break;
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/pansong291/xposed/quickenergy/util/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public CharSequence nickName() {
public static final String jn_receiveFarmToolReward = "receiveFarmToolReward";
public static final String jn_recordFarmGame = "recordFarmGame";
public static final String jn_kitchen = "kitchen";

public static final String jn_useSpecialFood = "useSpecialFood";
public static final String jn_useNewEggTool = "useNewEggTool";
public static final String jn_harvestProduce = "harvestProduce";
public static final String jn_donation = "donation";
Expand Down Expand Up @@ -234,6 +236,7 @@ public CharSequence nickName() {
private boolean receiveFarmToolReward;
private boolean recordFarmGame;
private boolean kitchen;
private boolean useSpecialFood;
private boolean useNewEggTool;
private boolean harvestProduce;
private boolean donation;
Expand Down Expand Up @@ -869,6 +872,15 @@ public static boolean kitchen() {
return getConfig().kitchen;
}

public static void setUseSpecialFood(boolean b) {
getConfig().useSpecialFood = b;
hasChanged = true;
}

public static boolean useSpecialFood() {
return getConfig().useSpecialFood;
}

public static void setUseNewEggTool(boolean b) {
getConfig().useNewEggTool = b;
hasChanged = true;
Expand Down Expand Up @@ -1451,6 +1463,7 @@ public static Config defInit() {
c.receiveFarmToolReward = true;
c.recordFarmGame = true;
c.kitchen = true;
c.useSpecialFood = false;
c.useNewEggTool = true;
c.harvestProduce = true;
c.donation = true;
Expand Down Expand Up @@ -1807,6 +1820,8 @@ public static Config json2Config(String json) {
config.kitchen = jo.optBoolean(jn_kitchen, true);
//Log.i(TAG, jn_kitchen + ":" + config.kitchen);

config.useSpecialFood = jo.optBoolean(jn_useSpecialFood, false);

config.useNewEggTool = jo.optBoolean(jn_useNewEggTool, true);
//Log.i(TAG, jn_useNewEggTool + ":" + config.useNewEggTool);

Expand Down Expand Up @@ -2223,6 +2238,8 @@ public static String config2Json(Config config) {

jo.put(jn_kitchen, config.kitchen);

jo.put(jn_useSpecialFood, config.useSpecialFood);

jo.put(jn_useNewEggTool, config.useNewEggTool);

jo.put(jn_harvestProduce, config.harvestProduce);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pansong291.xposed.quickenergy.util;

import pansong291.xposed.quickenergy.AntFarm;
import pansong291.xposed.quickenergy.hook.FriendManager;
import pansong291.xposed.quickenergy.hook.XposedHook;

Expand All @@ -23,6 +24,7 @@ public static void setCurrentUid(String uid) {
if (currentUid == null || !currentUid.equals(uid)) {
currentUid = uid;
FriendManager.fillUser(XposedHook.classLoader);
PluginUtils.invoke(FriendIdMap.class, PluginUtils.PluginAction.INIT);
}
}

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,16 @@
android:minHeight="50dp"
android:id="@+id/sw_kitchen" />

<Switch
android:paddingStart="@dimen/setting_item_padding"
android:paddingEnd="@dimen/setting_item_padding"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/use_special_food"
android:onClick="onClick"
android:minHeight="50dp"
android:id="@+id/sw_special_food" />

<Switch
android:paddingStart="@dimen/setting_item_padding"
android:paddingEnd="@dimen/setting_item_padding"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,6 @@
<string name="ant_book_read">读书听书</string>
<string name="omegakoi_town">支小镇</string>
<string name="consume_gold">支付宝消费金</string>
<string name="use_special_food">使用特殊食品</string>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,6 @@
<string name="ant_book_read">Ant book Read</string>
<string name="omegakoi_town">Omegakoi Town</string>
<string name="consume_gold">Consume Gold</string>
<string name="use_special_food">Use Special Food</string>

</resources>

0 comments on commit d730d03

Please sign in to comment.