Add files via upload

This commit is contained in:
Sahik authored and GitHub committed 2026-02-24 05:15:23 +08:00
1 parent fb96cf6c73
commit 9eb509371c
5 files changed
+777 -1

No files matched your search

+211
View File
@@ -0,0 +1,211 @@
/**
* 專案名稱: AutoCatAndSoup
* Copyright (C) 2026 Sthkm3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
"ui";
importClass(android.provider.Settings);
// 基本設定
const STORAGE = storages.create("AutoCatAndSoupConfig");
// 設定資料
let config = {
sellProduct: STORAGE.get("sellProduct", false),
upgradeFacility: STORAGE.get("upgradeFacility", false),
upgradeRecipe: STORAGE.get("upgradeRecipe", false),
Photo: STORAGE.get("Photo", false),
Gift: STORAGE.get("Gift", false),
Play: STORAGE.get("Play", false),
receiveAFK: STORAGE.get("receiveAFK", false),
receiveJar: STORAGE.get("receiveJar", false),
receiveMerchant: STORAGE.get("receiveMerchant", false),
receiveButterfly: STORAGE.get("receiveButterfly", false),
receiveFrog: STORAGE.get("receiveFrog", false),
receiveMail: STORAGE.get("receiveMail", false),
receiveAchievement: STORAGE.get("receiveAchievement", false)
};
// 無障礙檢查
function checkAccessibility() {
if (!auto.service) {
toast("請啟用無障礙服務");
app.startActivity({
action: Settings.ACTION_ACCESSIBILITY_SETTINGS
});
return false;
}
return true;
}
// UI
ui.layout(
<vertical>
<text text="Auto CatAndSoup 設定" textSize="20sp" textColor="#000000" gravity="center_horizontal" padding="16"/>
<scroll layout_weight="1">
<vertical padding="24">
<text text="── 基本 ──" textColor="#888888"/>
<checkbox id="cbSell" text="販賣商品"/>
<checkbox id="cbUpgrade" text="設施升級"/>
<checkbox id="cbUpgrade2" text="食譜升級"/>
<checkbox id="cbBuild" text="設施建設(未開發)"/>
<space h="16"/>
<text text="── 領取 ──" textColor="#888888"/>
<checkbox id="cbReceive" text="掛機獎勵"/>
<checkbox id="cbReceive2" text="罐子精靈獎勵"/>
<checkbox id="cbReceive3" text="商人獎勵"/>
<checkbox id="cbReceive4" text="黃金蝴蝶獎勵"/>
<checkbox id="cbReceive5" text="青蛙王子獎勵"/>
<checkbox id="cbReceive6" text="信箱"/>
<checkbox id="cbReceive7" text="成就"/>
<space h="16"/>
<text text="─ 隨機任務 ─" textColor="#888888"/>
<checkbox id="cbPhoto" text="拍攝照片"/>
<checkbox id="cbGift" text="禮物"/>
<checkbox id="cbPlay" text="玩耍"/>
<checkbox id="cbTravel" text="旅行(未開發)"/>
<space h="16"/>
<text text="─ 每日任務 ─" textColor="#888888"/>
<checkbox id="cbFishing" text="釣魚(未開發)"/>
<checkbox id="cbGacha" text="扭蛋(未開發)"/>
<checkbox id="cbShooting" text="投籃(未開發)"/>
</vertical>
</scroll>
<button id="btnStart" text="啟動" textSize="18sp" layout_gravity="center_horizontal" margin="16"/>
</vertical>
);
// 初始化狀態
ui.cbSell.checked = config.sellProduct;
ui.cbUpgrade.checked = config.upgradeFacility;
ui.cbUpgrade2.checked = config.upgradeRecipe;
ui.cbPhoto.checked = config.Photo;
ui.cbGift.checked = config.Gift;
ui.cbPlay.checked = config.Play;
ui.cbReceive.checked = config.receiveAFK;
ui.cbReceive2.checked = config.receiveJar;
ui.cbReceive3.checked = config.receiveMerchant;
ui.cbReceive4.checked = config.receiveButterfly;
ui.cbReceive5.checked = config.receiveFrog;
ui.cbReceive6.checked = config.receiveMail;
ui.cbReceive7.checked = config.receiveAchievement;
// 未開發功能鎖定
ui.cbBuild.enabled = false;
ui.cbTravel.enabled = false;
ui.cbFishing.enabled = false;
ui.cbGacha.enabled = false;
ui.cbShooting.enabled = false;
// 勾選監聽
ui.cbSell.on("check", checked => {
config.sellProduct = checked;
STORAGE.put("sellProduct", checked);
});
ui.cbUpgrade.on("check", checked => {
config.upgradeFacility = checked;
STORAGE.put("upgradeFacility", checked);
});
ui.cbUpgrade2.on("check", checked => {
config.upgradeRecipe = checked;
STORAGE.put("upgradeRecipe", checked);
});
ui.cbPhoto.on("check", checked => {
config.Photo = checked;
STORAGE.put("Photo", checked);
});
ui.cbGift.on("check", checked => {
config.Gift = checked;
STORAGE.put("Gift", checked);
});
ui.cbPlay.on("check", checked => {
config.Play = checked;
STORAGE.put("Play", checked);
});
ui.cbReceive.on("check", checked => {
config.receiveAFK = checked;
STORAGE.put("receiveAFK", checked);
});
ui.cbReceive2.on("check", checked => {
config.receiveJar = checked;
STORAGE.put("receiveJar", checked);
});
ui.cbReceive3.on("check", checked => {
config.receiveMerchant = checked;
STORAGE.put("receiveMerchant", checked);
});
ui.cbReceive4.on("check", checked => {
config.receiveButterfly = checked;
STORAGE.put("receiveButterfly", checked);
});
ui.cbReceive5.on("check", checked => {
config.receiveFrog = checked;
STORAGE.put("receiveFrog", checked);
});
ui.cbReceive6.on("check", checked => {
config.receiveMail = checked;
STORAGE.put("receiveMail", checked);
});
ui.cbReceive7.on("check", checked => {
config.receiveAchievement = checked;
STORAGE.put("receiveAchievement", checked);
});
// 啟動
ui.btnStart.on("click", () => {
if (!checkAccessibility()) return;
STORAGE.put("sellProduct", config.sellProduct);
STORAGE.put("upgradeFacility", config.upgradeFacility);
STORAGE.put("upgradeRecipe", config.upgradeRecipe);
STORAGE.put("Photo", config.Photo);
STORAGE.put("Gift", config.Gift);
STORAGE.put("Play", config.Play);
STORAGE.put("receiveAFK", config.receiveAFK);
STORAGE.put("receiveJar", config.receiveJar);
STORAGE.put("receiveMerchant", config.receiveMerchant);
STORAGE.put("receiveButterfly", config.receiveButterfly);
STORAGE.put("receiveFrog", config.receiveFrog);
STORAGE.put("receiveMail", config.receiveMail);
STORAGE.put("receiveAchievement", config.receiveAchievement);
ui.finish();
engines.execScriptFile("run.js");
});
// 啟動時提醒無障礙
setTimeout(() => {
checkAccessibility();
}, 300);
+273
View File
@@ -0,0 +1,273 @@
/**
* 專案名稱: AutoCatAndSoup
* Copyright (C) 2026 Sthkm3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
"auto";
const STORAGE = storages.create("AutoCatAndSoupConfig");
const SCREEN_W = 720;
const SCREEN_H = 1280;
// 讀取
let config = {
sellProduct: STORAGE.get("sellProduct", false),
upgradeFacility: STORAGE.get("upgradeFacility", false),
upgradeRecipe: STORAGE.get("upgradeRecipe", false),
Photo: STORAGE.get("Photo", false),
Gift: STORAGE.get("Gift", false),
Play: STORAGE.get("Play", false),
receiveAFK: STORAGE.get("receiveAFK", false),
receiveJar: STORAGE.get("receiveJar", false),
receiveMerchant: STORAGE.get("receiveMerchant", false),
receiveButterfly: STORAGE.get("receiveButterfly", false),
receiveFrog: STORAGE.get("receiveFrog", false),
receiveMail: STORAGE.get("receiveMail", false),
receiveAchievement: STORAGE.get("receiveAchievement", false)
};
// 小視窗
let isPaused = false;
let win = floaty.rawWindow(
<vertical bg="#AA000000" padding="6">
<text text="Auto CatAndSoup" textColor="#FFFFFF" textSize="12sp"/>
<button id="btnPause" text="暫停"/>
</vertical>
);
win.setPosition(0, (SCREEN_H / 2) - 80);
win.setSize(160, -2); win.btnPause.click(() => { isPaused = !isPaused;
win.btnPause.setText(isPaused ? "啟動" : "暫停");
toast(isPaused ? "已暫停" : "已啟動"); });
// 主循環
while (true) {
var img = captureScreen();
var pkg = currentPackage();
// 判斷應用
if (pkg != "com.hidea.cat" && !isPaused) {
app.launchPackage("com.hidea.cat");
sleep(1000);
continue;
}
// 販賣商品
if (config.sellProduct && !isPaused) {
if (
!images.detectsColor(img, "#B38282", 35, 1264) &&
!images.detectsColor(img, "#DCAB82", 35, 1264)
) {
let x = random(30, 90);
let y = random(1200, 1240);
click(x, y);
sleep(200);
}
}
// 設施升級
if (config.upgradeFacility && !isPaused) {
if (images.detectsColor(img, "#70FE7F", 95, 1024)) {
click(31, 1044);
sleep(200);
}
}
// 食譜升級
if (config.upgradeRecipe && !isPaused) {
if (images.detectsColor(img, "#FD7171", 581, 1081)) {
click(550, 1101);
sleep(500);
var img = captureScreen();
while (images.detectsColor(img, "#8EE3D3", 458, 1037)){
click(458, 1081);
sleep(100);
var img = captureScreen();
}
//back();
sleep(3000);
}
}
// 拍照
if (config.Photo && !isPaused) {
if (images.detectsColor(img, "#B5B5C6", 648, 813)){
click(660, 815);
sleep(1000);
click(362, 1026);
sleep(1000);
back();
sleep(500); //images.detectsColor(img, "#FF6F6F", 681, 796)
}
}
// 禮物
if (config.Gift && !isPaused) {
if (images.detectsColor(img, "#FFFFFF", 680, 725) && images.detectsColor(img, "#FFFFFF", 680, 715)) {
click(662, 745);
var img = captureScreen();
while (!images.detectsColor(img, "#FFFFFF", 250, 825)){
sleep(100);
var img = captureScreen();
}
sleep(500);
click(360, 760);
sleep(500);
back();
sleep(2000);
var img = captureScreen();
if (images.detectsColor(img, "#FFFFFF", 250, 830)){
click(360, 735);
sleep(3000);
back();
}
sleep(500);
}
}
// 玩耍
if (config.Play && !isPaused) {
if (images.detectsColor(img, "#F9DBDC", 673, 737)) {
click(645, 739);
sleep(3000);
click(360, 800);
sleep(500);
swipe(360, 560, 360, 900, 1000);
sleep(100);
var img = captureScreen();
while(images.detectsColor(img, "#F2B1B1", 501, 858) && !isPaused){
swipe(360, 800, 360, 200, 3000);
sleep(100);
swipe(360, 300, 360, 900, 3000);
sleep(100);
var img = captureScreen();
}
click(415, 923);
sleep(1000);
}
}
// 掛機獎勵
if (config.receiveAFK && !isPaused) {
if (images.detectsColor(img, "#E3C5AE", 371, 1092)) {
click(360, 1130);
sleep(500);
click(420, 809);
sleep(500);
}
}
// 罐子精靈獎勵
if (config.receiveJar && !isPaused) {
if (images.detectsColor(img, "#AAAAAA", 433, 1132)) {
click(360, 1130);
sleep(500);
click(420, 844);
sleep(500);
}
}
// 商人獎勵
if (config.receiveMerchant && !isPaused) {
if (images.detectsColor(img, "#DB937D", 351, 1152)) {
click(360, 1130);
sleep(500);
click(420, 755);
sleep(500);
}
}
// 黃金蝴蝶獎勵
if (config.receiveButterfly && !isPaused) {
if (images.detectsColor(img, "#FBE771", 71, 280)) {
click(71, 280);
sleep(2000);
click(360, 650);
sleep(300);
click(423, 724);
sleep(500);
}
}
// 青蛙王子獎勵
if (config.receiveFrog && !isPaused) {
if (images.detectsColor(img, "#D8E0B7", 55, 291) && images.detectsColor(img, "#D8E0B7", 49, 291)) {
click(71, 280);
sleep(2000);
click(360, 650);
sleep(300);
click(423, 724);
sleep(500);
}
}
// 信箱
if (config.receiveMail && !isPaused) {
if (images.detectsColor(img, "#FFFFFF", 376, 199) && images.detectsColor(img, "#F2DFC7", 356, 234)) {
click(360, 208);
sleep(1000);
var img = captureScreen();
while (images.detectsColor(img, "#8EE3D3", 570, 380) && !isPaused) {
click(484, 398);
sleep(500);
var img = captureScreen();
if (images.detectsColor(img, "#E5D8CA", 489, 632)) {
click(400, 720);
var img = captureScreen();
}
sleep(500);
var img = captureScreen();
}
back();
sleep(500);
}
}
// 成就與任務
if (config.receiveAchievement && !isPaused) {
if (images.detectsColor(img, "#FF6F6E", 680, 243)) {
click(662, 263);
sleep(500);
var img = captureScreen();
if (images.detectsColor(img, "#FF6F6E", 307, 234)) {
click(225, 250);
sleep(1000);
while (images.detectsColor(img, "#8EE3D3", 520, 460) && !isPaused) {
click(520, 470);
sleep(100);
var img = captureScreen();
}
}
else {
click(495, 250);
sleep(1000);
while (images.detectsColor(img, "#8EE3D3", 520, 344) && !isPaused) {
click(520, 344);
sleep(100);
var img = captureScreen();
}
}
back();
sleep(500);
}
}
img.recycle();
}