@@ -4,7 +4,10 @@ const duration = 1000; // 默认点击等待延时
44
55const storePath = "data/store.json"
66const runJS = settings . runJS || false ;
7+ const achievementMode = settings . achievementMode || true ;
8+ const starMode = settings . starMode || false ;
79const roomID = settings . room || "37135473336" ;
10+ const starRoomName = settings . starRoomName || "碰碰墙" ;
811const userAttempts = Number ( settings . thisAttempts || "0" ) ;
912const useFixedAttempts = userAttempts > 0 ;
1013const weekMaxExp = Number ( settings . weekMaxExp || "4000" ) ;
@@ -131,21 +134,23 @@ async function findImageAndClick(path, x, y, w, h, imgAttempts = attempts) {
131134
132135// 清除游玩数据
133136async function deleteSource ( ) {
134- await sleep ( duration ) ;
135- await genshin . returnMainUi ( ) ;
136- log . info ( "开始清除地图数据" ) ;
137- await sleep ( duration ) ;
138- keyPress ( "VK_B" ) ;
139- await sleep ( duration ) ;
140- await findTextAndClick ( "管理关卡" , 960 , 0 , 960 , 100 ) ;
141- await findTextAndClick ( "管理" , 960 , 980 , 960 , 100 ) ;
142- await findImageAndClick ( "check_box" , 0 , 0 , 1480 , 340 ) ;
143- await findTextAndClick ( "删除" , 960 , 980 , 960 , 100 ) ;
144- await findTextAndClick ( "确认" , 960 , 600 , 960 , 400 ) ;
145- await findTextAndClick ( "确认" , 960 , 600 , 960 , 400 ) ;
146- log . info ( "数据清除完成" ) ;
147- await sleep ( duration ) ;
148- await genshin . returnMainUi ( ) ;
137+ if ( achievementMode ) {
138+ await sleep ( duration ) ;
139+ await genshin . returnMainUi ( ) ;
140+ log . info ( "开始清除地图数据" ) ;
141+ await sleep ( duration ) ;
142+ keyPress ( "VK_B" ) ;
143+ await sleep ( duration ) ;
144+ await findTextAndClick ( "管理关卡" , 960 , 0 , 960 , 100 ) ;
145+ await findTextAndClick ( "管理" , 960 , 980 , 960 , 100 ) ;
146+ await findImageAndClick ( "check_box" , 0 , 0 , 1480 , 340 ) ;
147+ await findTextAndClick ( "删除" , 960 , 980 , 960 , 100 ) ;
148+ await findTextAndClick ( "确认" , 960 , 600 , 960 , 400 ) ;
149+ await findTextAndClick ( "确认" , 960 , 600 , 960 , 400 ) ;
150+ log . info ( "数据清除完成" ) ;
151+ await sleep ( duration ) ;
152+ await genshin . returnMainUi ( ) ;
153+ }
149154}
150155
151156// 进入千星奇域的全部奇域页面
@@ -166,6 +171,26 @@ async function enterSourcePage() {
166171 await sleep ( duration ) ;
167172}
168173
174+ // 进入千星奇域的收藏奇域页面
175+ async function enterStarSourcePage ( ) {
176+ // 1. 检测是否在房间内,在则退出
177+ const inRoom = await findText ( "房间" , 1500 , 0 , 420 , 500 , 5 ) ;
178+ if ( inRoom ) {
179+ keyPress ( "VK_P" ) ;
180+ await sleep ( duration ) ;
181+ await findImageAndClick ( "exit_room" , 960 , 0 , 960 , 540 ) ;
182+ await findTextAndClick ( "确认" , 960 , 600 , 960 , 400 ) ;
183+ await genshin . returnMainUi ( ) ;
184+ keyPress ( "VK_B" ) ;
185+ } else {
186+ keyPress ( "VK_F6" ) ;
187+ await sleep ( duration ) ;
188+ await findTextAndClick ( "收藏" , 0 , 850 , 300 , 230 ) ;
189+ }
190+
191+ await sleep ( duration ) ;
192+ }
193+
169194// 创建关卡
170195async function createMap ( ) {
171196 await findTextAndClick ( "全部" , 1320 , 0 , 600 , 95 ) ;
@@ -196,12 +221,47 @@ async function createMap() {
196221 await sleep ( duration ) ;
197222}
198223
224+ // 从收藏创建关卡
225+ async function createStarMap ( ) {
226+ await findTextAndClick ( "搜索" , 0 , 0 , 1920 , 120 ) ;
227+ inputText ( starRoomName ) ;
228+ await sleep ( 1000 ) ;
229+ await findTextAndClick ( "搜索" , 0 , 0 , 1920 , 120 ) ;
230+ await sleep ( duration ) ;
231+ click ( 420 , 830 ) ;
232+ await sleep ( duration ) ;
233+ while ( true ) {
234+ const result = await findText ( "房间" , 960 , 100 , 960 , 200 , 2 ) ;
235+ if ( result ) {
236+ await sleep ( duration ) ;
237+ result . click ( ) ;
238+ await sleep ( duration ) ;
239+ break ;
240+ } else {
241+ const result2 = await findText ( "大厅" , 960 , 600 , 960 , 400 , 2 ) ;
242+ if ( result2 ) {
243+ result2 . click ( ) ;
244+ await sleep ( duration ) ;
245+ }
246+ }
247+ }
248+ await findText ( "开始游戏" , 960 , 540 , 960 , 540 ) ;
249+ click ( 770 , 275 ) ;
250+ await sleep ( duration ) ;
251+ }
252+
199253// 游玩关卡
200254async function playMap ( ) {
201255 const stored = loadWeekData ( ) ;
202256 const leave = stored ? stored . weekTotal : weekTotal ;
203257 const total = useFixedAttempts ? userAttempts : leave ;
204- await createMap ( ) ;
258+
259+ if ( starMode ) {
260+ await createStarMap ( ) ;
261+ } else {
262+ await createMap ( ) ;
263+ }
264+
205265 while ( true ) {
206266 await sleep ( duration ) ;
207267 const result = await findText ( "开始游戏" , 960 , 540 , 960 , 540 , 5 ) ;
@@ -217,6 +277,12 @@ async function playMap() {
217277 }
218278 let firstOutputCount = 0 ;
219279 while ( true ) {
280+ const whiteText = await findText ( "空白处" , 610 , 950 , 700 , 60 , 1 ) ;
281+ if ( whiteText ) {
282+ await sleep ( duration ) ;
283+ click ( 610 , 950 ) ;
284+ }
285+
220286 const result = await findText ( "返回大厅" , 960 , 540 , 960 , 540 , 1 ) ;
221287 if ( result ) {
222288 await sleep ( duration ) ;
@@ -262,6 +328,11 @@ async function playMap() {
262328 }
263329 let outputCount = 0 ;
264330 while ( true ) {
331+ const whiteText = await findText ( "空白处" , 610 , 950 , 700 , 60 , 1 ) ;
332+ if ( whiteText ) {
333+ await sleep ( duration ) ;
334+ click ( 610 , 950 ) ;
335+ }
265336 const result = await findText ( "返回大厅" , 960 , 540 , 960 , 540 , 1 ) ;
266337 if ( result ) {
267338 await sleep ( duration ) ;
@@ -328,7 +399,12 @@ async function exitToTeyvat() {
328399 ) ;
329400 }
330401
331- await enterSourcePage ( ) ;
402+ if ( starMode ) {
403+ log . info ( "已使用收藏模式" ) ;
404+ await enterStarSourcePage ( ) ;
405+ } else {
406+ await enterSourcePage ( ) ;
407+ }
332408 await playMap ( ) ;
333409 await exitToTeyvat ( ) ;
334410} ) ( ) ;
0 commit comments