|
| 1 | + |
| 2 | +import { IFuncOrigin, IFuncOperatorOrigin, IFuncOperator } from '@/interface/IFunc'; |
| 3 | +import { Script } from '@/system/script'; |
| 4 | + |
| 5 | +const center = 1; |
| 6 | +const right = 2; |
| 7 | + |
| 8 | +export class Func522 implements IFuncOrigin { |
| 9 | + id = 522; |
| 10 | + name = '自动招募'; |
| 11 | + desc = '自动点击招募成员界面中的10个+号,然后等待设定时间后点击换一批。建议开启OCR插件以获得最佳效果。'; |
| 12 | + config = [{ |
| 13 | + desc: '配置', |
| 14 | + config: [{ |
| 15 | + name: 'waitTime', |
| 16 | + desc: '点击10个后的等待时间(分钟)', |
| 17 | + type: 'list', |
| 18 | + data: ['1', '2', '3', '4', '5', '10'], |
| 19 | + default: '1', |
| 20 | + value: null, |
| 21 | + }] |
| 22 | + }]; |
| 23 | + operator: IFuncOperatorOrigin[] = [{ |
| 24 | + oper: [ |
| 25 | + [center, 1280, 720, 500, 20, 780, 80, 0], // 顶部标题区域 |
| 26 | + ] |
| 27 | + }, { |
| 28 | + oper: [ |
| 29 | + [right, 1280, 720, 1000, 620, 1200, 700, 0], // 右下角换一批区域 |
| 30 | + ] |
| 31 | + }, { |
| 32 | + oper: [ |
| 33 | + [center, 1280, 720, 783, 173, 784, 174, 0], // 向下滑动 |
| 34 | + [center, 1280, 720, 777, 534, 778, 535, 0], // 向下滑动 |
| 35 | + ] |
| 36 | + }, { |
| 37 | + oper: [ |
| 38 | + [center, 1280, 720, 777, 534, 778, 535, 0], // 向上滑动 |
| 39 | + [center, 1280, 720, 783, 173, 784, 174, 0], // 向上滑动 |
| 40 | + ] |
| 41 | + }]; |
| 42 | + |
| 43 | + operatorFunc(thisScript: Script, thisOperator: IFuncOperator[]): boolean { |
| 44 | + const thisConf = thisScript.scheme.config['522']; |
| 45 | + const waitTimeMs = parseInt(thisConf.waitTime as string) * 60 * 1000; |
| 46 | + const titleRes = thisScript.findText('招募成员', 0, thisOperator[0].oper[0].slice(0, 4), '包含'); |
| 47 | + if (titleRes.length === 0) { |
| 48 | + return false; |
| 49 | + } |
| 50 | + if (typeof thisScript.global.recruitCount === 'undefined') { |
| 51 | + thisScript.global.recruitCount = 0; |
| 52 | + } |
| 53 | + if (!thisScript.global.recruitClickedY) { |
| 54 | + thisScript.global.recruitClickedY = []; |
| 55 | + } |
| 56 | + if (typeof thisScript.global.recruitHasScrolled === 'undefined') { |
| 57 | + thisScript.global.recruitHasScrolled = false; |
| 58 | + } |
| 59 | + |
| 60 | + if (thisScript.global.recruitCount >= 10) { |
| 61 | + const now = new Date().getTime(); |
| 62 | + if (!thisScript.global.lastRecruitFinishTime) { |
| 63 | + thisScript.global.lastRecruitFinishTime = now; |
| 64 | + thisScript.myToast(`已完成 10/10 次点击,开始 ${thisConf.waitTime} 分钟倒计时...`); |
| 65 | + } |
| 66 | + |
| 67 | + const elapsedMs = now - thisScript.global.lastRecruitFinishTime; |
| 68 | + if (elapsedMs >= waitTimeMs) { |
| 69 | + const countdownRes = thisScript.findText('秒', 0, thisOperator[1].oper[0].slice(0, 4), '包含'); |
| 70 | + if (countdownRes.length > 0) { |
| 71 | + thisScript.myToast('游戏内按钮处于倒计时,等待中...'); |
| 72 | + return true; |
| 73 | + } |
| 74 | + |
| 75 | + const refreshRes = thisScript.findText('换一批', 0, thisOperator[1].oper[0].slice(0, 4), '包含'); |
| 76 | + const refreshColor = thisScript.findMultiColor('招募_换一批'); |
| 77 | + |
| 78 | + if (refreshRes.length > 0 || refreshColor) { |
| 79 | + thisScript.myToast('时间到,点击换一批'); |
| 80 | + if (refreshRes.length > 0) { |
| 81 | + thisScript.regionClick([[ |
| 82 | + refreshRes[0].points[0].x, |
| 83 | + refreshRes[0].points[0].y, |
| 84 | + refreshRes[0].points[2].x, |
| 85 | + refreshRes[0].points[2].y, |
| 86 | + 1200 |
| 87 | + ]]); |
| 88 | + } else { |
| 89 | + thisScript.regionClick([[ |
| 90 | + refreshColor.x - 50, |
| 91 | + refreshColor.y - 20, |
| 92 | + refreshColor.x + 50, |
| 93 | + refreshColor.y + 20, |
| 94 | + 1200 |
| 95 | + ]]); |
| 96 | + } |
| 97 | + } else { |
| 98 | + thisScript.myToast('未识别到换一批,使用固定坐标点击'); |
| 99 | + thisScript.regionClick([[1048 - 30, 627 - 20, 1048 + 30, 627 + 20, 1200]]); |
| 100 | + } |
| 101 | + |
| 102 | + // 重置计数器和状态 |
| 103 | + thisScript.global.recruitCount = 0; |
| 104 | + thisScript.global.recruitClickedY = []; |
| 105 | + thisScript.global.lastRecruitFinishTime = null; |
| 106 | + thisScript.global.recruitHasScrolled = false; |
| 107 | + |
| 108 | + // 滑动回顶部 |
| 109 | + thisScript.myToast('正在回滚到最顶部'); |
| 110 | + thisScript.regionSwipe(thisOperator[2].oper[0], thisOperator[2].oper[1], [800, 1000], 200); |
| 111 | + sleep(500); |
| 112 | + thisScript.regionSwipe(thisOperator[2].oper[0], thisOperator[2].oper[1], [800, 1000], 200); |
| 113 | + sleep(1000); |
| 114 | + |
| 115 | + return true; |
| 116 | + } else { |
| 117 | + const remainingSec = Math.ceil((waitTimeMs - elapsedMs) / 1000); |
| 118 | + const min = Math.floor(remainingSec / 60); |
| 119 | + const sec = remainingSec % 60; |
| 120 | + thisScript.myToast(`倒计时: ${min}分${sec}秒`); |
| 121 | + } |
| 122 | + return true; |
| 123 | + } |
| 124 | + |
| 125 | + let clickedInThisTurn = false; |
| 126 | + |
| 127 | + if (!thisScript.global.recruitHasScrolled && thisScript.global.recruitCount >= 5) { |
| 128 | + thisScript.myToast('正在滚动到后5个'); |
| 129 | + thisScript.regionSwipe(thisOperator[3].oper[0], thisOperator[3].oper[1], [800, 1000], 200); |
| 130 | + sleep(500); |
| 131 | + thisScript.regionSwipe(thisOperator[3].oper[0], thisOperator[3].oper[1], [800, 1000], 200); |
| 132 | + |
| 133 | + thisScript.global.recruitClickedY = []; |
| 134 | + thisScript.global.recruitHasScrolled = true; |
| 135 | + sleep(1500); |
| 136 | + return true; |
| 137 | + } |
| 138 | + |
| 139 | + |
| 140 | + const plusPoints = thisScript.findMultiColorEx('招募_加号'); |
| 141 | + if (plusPoints.length > 0) { |
| 142 | + for (const point of plusPoints) { |
| 143 | + const centerY = point.y; |
| 144 | + if (thisScript.global.recruitClickedY.some((y: number) => Math.abs(y - centerY) < 25)) { |
| 145 | + continue; |
| 146 | + } |
| 147 | + |
| 148 | + thisScript.global.recruitCount++; |
| 149 | + const prefix = thisScript.global.recruitHasScrolled ? '后' : '前'; |
| 150 | + const currentInPhase = thisScript.global.recruitHasScrolled ? (thisScript.global.recruitCount - 5) : thisScript.global.recruitCount; |
| 151 | + thisScript.myToast(`(${prefix}${currentInPhase}/5个)`); |
| 152 | + |
| 153 | + thisScript.regionClick([[point.x - 30, point.y - 30, point.x + 30, point.y + 30, 1200]]); |
| 154 | + thisScript.global.recruitClickedY.push(centerY); |
| 155 | + clickedInThisTurn = true; |
| 156 | + if (thisScript.global.recruitCount >= 10 || (!thisScript.global.recruitHasScrolled && thisScript.global.recruitCount >= 5)) break; |
| 157 | + } |
| 158 | + } |
| 159 | + |
| 160 | + if (!clickedInThisTurn && thisScript.global.recruitCount < 10) { |
| 161 | + const statusRes = thisScript.findText('在线|小时前|分钟前|昨天', 0, [880, 100, 1100, 620], '正则'); |
| 162 | + if (statusRes.length > 0) { |
| 163 | + for (const status of statusRes) { |
| 164 | + const centerY = (status.points[0].y + status.points[2].y) / 2; |
| 165 | + if (thisScript.global.recruitClickedY.some((y: number) => Math.abs(y - centerY) < 25)) { |
| 166 | + continue; |
| 167 | + } |
| 168 | + const clickX = 1118; |
| 169 | + const clickY = centerY; |
| 170 | + |
| 171 | + thisScript.global.recruitCount++; |
| 172 | + const prefix = thisScript.global.recruitHasScrolled ? '后' : '前'; |
| 173 | + const currentInPhase = thisScript.global.recruitHasScrolled ? (thisScript.global.recruitCount - 5) : thisScript.global.recruitCount; |
| 174 | + thisScript.myToast(`(${prefix}${currentInPhase}/5个)`); |
| 175 | + |
| 176 | + thisScript.regionClick([[clickX - 35, clickY - 35, clickX + 35, clickY + 35, 1200]]); |
| 177 | + thisScript.global.recruitClickedY.push(centerY); |
| 178 | + clickedInThisTurn = true; |
| 179 | + if (thisScript.global.recruitCount >= 10 || (!thisScript.global.recruitHasScrolled && thisScript.global.recruitCount >= 5)) break; |
| 180 | + } |
| 181 | + } |
| 182 | + } |
| 183 | + |
| 184 | + |
| 185 | + if (!clickedInThisTurn && thisScript.global.recruitCount < 10) { |
| 186 | + const currentCoords = thisScript.global.recruitHasScrolled |
| 187 | + ? [202, 283, 364, 445, 525] |
| 188 | + : [172, 254, 334, 415, 496]; |
| 189 | + |
| 190 | + for (const y of currentCoords) { |
| 191 | + if (thisScript.global.recruitClickedY.some((clickedY: number) => Math.abs(clickedY - y) < 25)) { |
| 192 | + continue; |
| 193 | + } |
| 194 | + thisScript.global.recruitCount++; |
| 195 | + const prefix = thisScript.global.recruitHasScrolled ? '后' : '前'; |
| 196 | + const currentInPhase = thisScript.global.recruitHasScrolled ? (thisScript.global.recruitCount - 5) : thisScript.global.recruitCount; |
| 197 | + thisScript.myToast(`(${prefix}${currentInPhase}/5个)`); |
| 198 | + |
| 199 | + thisScript.regionClick([[1118 - 35, y - 35, 1118 + 35, y + 35, 1200]]); |
| 200 | + thisScript.global.recruitClickedY.push(y); |
| 201 | + clickedInThisTurn = true; |
| 202 | + if (thisScript.global.recruitCount >= 10 || (!thisScript.global.recruitHasScrolled && thisScript.global.recruitCount >= 5)) break; |
| 203 | + } |
| 204 | + } |
| 205 | + |
| 206 | + return true; |
| 207 | + } |
| 208 | +} |
| 209 | + |
| 210 | +export default new Func522(); |
0 commit comments