| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- from module.config.config import Config
- from module.device.device import Device
- from tasks.Component.SwitchAccount.assets import SwitchAccountAssets
- from tasks.Component.SwitchAccount.exit_game import ExitGame
- from tasks.Component.SwitchAccount.login_account import LoginAccount
- from tasks.Component.SwitchAccount.switch_account_config import AccountInfo
- from tasks.GameUi.game_ui import GameUi
- from tasks.GameUi.page import page_main, page_login
- from tasks.base_task import BaseTask
- from tasks.Restart.login import LoginHandler
- from module.logger import logger
- class SwitchAccount(LoginAccount, ExitGame, GameUi, SwitchAccountAssets):
- def __init__(self, config: Config, device: Device, to: AccountInfo, frm: AccountInfo = None):
- """
- @param config:
- @type config:
- @param device:
- @type device:
- @param to: 要登录的账号信息
- @type to:
- @param frm: 上一个账号信息 ,避免关键字from
- @type frm:
- """
- super().__init__(config, device)
- self.toAccountInfo = to
- self.fromAccountInfo = frm
- def switchAccount(self):
- logger.info("start switchAccount %s-%s", self.toAccountInfo.character, self.toAccountInfo.svr)
- # 判断所处界面
- curPage = self.ui_get_current_page()
- if curPage != page_login and curPage != page_main:
- self.ui_goto(page_main)
- curPage = self.ui_get_current_page()
- if curPage == page_main:
- self.exitGame()
- # 处于登录界面
- if not self.login(self.toAccountInfo):
- return False
- logger.info("%s login suc", self.toAccountInfo.character)
- # 处理位于登录界面各种奇葩弹窗
- login_handler = LoginHandler(config=self.config, device=self.device)
- login_handler.set_specific_usr(self.toAccountInfo.svr)
- login_handler.app_handle_login()
- return True
|