Sfoglia il codice sorgente

fix(Scheduler): ensure desktop client logged in before gameplay tasks

Auto-launched desktop client stays at login page (_desktop_login_done=False),
so force Restart to login first instead of running gameplay on a not-ready game.
User 1 mese fa
parent
commit
251cb1cdea
1 ha cambiato i file con 12 aggiunte e 0 eliminazioni
  1. 12 0
      script.py

+ 12 - 0
script.py

@@ -680,6 +680,18 @@ class Script:
             else:
                 _ = self.device
 
+            # 桌面模式:客户端刚被自动拉起时停在登录页(_desktop_login_done=False),
+            # 此时 app_is_running() 返回 False。若下一个任务是 gameplay,先强制走 Restart
+            # 登录流程把游戏带到庭院主界面,避免 gameplay 在登录页盲点后被迫重启。
+            # 注意:不能只靠 task_call('Restart') 排队,因为 get_next_task 按 next_run 取最早
+            # 到期的任务,Exploration 等的 next_run 是 2023 永远更优先,Restart 永远排不上去,
+            # 所以这里直接把 task 改写成 Restart 并落进下方 Run 分支执行。
+            if task != 'Restart' and getattr(self.device, 'is_desktop', False) \
+                    and not self.device.app_is_running():
+                logger.info('Desktop client not logged in, run `Restart` to login first')
+                task = 'Restart'
+                self.is_first_task = False
+
             # Run
             logger.info(f'Scheduler: Start task `{task}`')
             self.device.stuck_record_clear()