page.py 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. import random
  2. import traceback
  3. from module.atom.click import RuleClick
  4. from tasks.GameUi.assets import GameUiAssets as G
  5. from tasks.base_task import BaseTask as BT
  6. from tasks.RyouToppa.assets import RyouToppaAssets
  7. class Page:
  8. def __init__(self, check_button, links=None):
  9. if links is None:
  10. links = {}
  11. self.check_button = check_button
  12. self.links = links
  13. self.additional: list = None # 附加按钮或者是ocr检测按钮
  14. (filename, line_number, function_name, text) = traceback.extract_stack()[-2]
  15. self.name = text[:text.find('=')].strip()
  16. def __eq__(self, other):
  17. return self.name == other.name
  18. def __hash__(self):
  19. return hash(self.name)
  20. def __str__(self):
  21. return self.name
  22. def link(self, button, destination):
  23. self.links[destination] = button
  24. #登录login
  25. page_login = Page(G.I_CHECK_LOGIN_FORM)
  26. # Main Home 主页
  27. page_main = Page(G.I_CHECK_MAIN)
  28. page_main.additional = [G.I_AD_CLOSE_RED, G.I_BACK_FRIENDS]
  29. # 召唤summon
  30. page_summon = Page(G.I_CHECK_SUMMON)
  31. page_summon.link(button=G.I_SUMMON_GOTO_MAIN, destination=page_main)
  32. page_main.link(button=G.I_MAIN_GOTO_SUMMON, destination=page_summon)
  33. # 探索exploration
  34. page_exploration = Page(G.I_CHECK_EXPLORATION)
  35. page_exploration.link(button=G.I_BACK_BLUE, destination=page_main)
  36. page_main.link(button=G.I_MAIN_GOTO_EXPLORATION, destination=page_exploration)
  37. # 町中town
  38. page_town = Page(G.I_CHECK_TOWN)
  39. page_town.link(button=G.I_TOWN_GOTO_MAIN, destination=page_main)
  40. page_main.link(button=G.I_MAIN_GOTO_TOWN, destination=page_town)
  41. # Unknown
  42. # page_unknown = Page(None)
  43. # page_unknown.link(button=G.I_CHECK_MAIN, destination=page_main)
  44. # ************************************* 探索部分 *****************************************#
  45. # 觉醒 awake zones
  46. page_awake_zones = Page(G.I_CHECK_AWAKE)
  47. page_awake_zones.link(button=G.I_BACK_BLUE, destination=page_exploration)
  48. page_exploration.link(button=G.I_EXPLORATION_GOTO_AWAKE_ZONE, destination=page_awake_zones)
  49. # 御魂 soul zones
  50. page_soul_zones = Page(G.I_CHECK_SOUL_ZONES)
  51. page_soul_zones.link(button=G.I_BACK_BLUE, destination=page_exploration)
  52. page_exploration.link(button=G.I_EXPLORATION_GOTO_SOUL_ZONE, destination=page_soul_zones)
  53. # 结界突破 realm raid
  54. page_realm_raid = Page(G.I_CHECK_REALM_RAID)
  55. page_realm_raid.link(button=G.I_REALM_RAID_GOTO_EXPLORATION, destination=page_exploration)
  56. page_exploration.link(button=G.I_EXPLORATION_GOTO_REALM_RAID, destination=page_realm_raid)
  57. # 寮结界突破右上角 kekkai toppa
  58. page_kekkai_toppa = Page(G.I_KEKKAI_TOPPA)
  59. page_kekkai_toppa.link(button=G.I_REALM_RAID_GOTO_EXPLORATION, destination=page_exploration)
  60. page_realm_raid.link(button=RyouToppaAssets.I_RYOU_TOPPA, destination=page_kekkai_toppa)
  61. page_kekkai_toppa.link(button=G.I_RYOUTOPPA_GOTO_REALMRAID, destination=page_realm_raid)
  62. # 御灵 goryou realm
  63. page_goryou_realm = Page(G.I_CHECK_GORYOU)
  64. page_goryou_realm.link(button=G.I_BACK_BLUE, destination=page_exploration)
  65. page_exploration.link(button=G.I_EXPLORATION_GOTO_GORYOU_REALM, destination=page_goryou_realm)
  66. # 委派 delegation
  67. page_delegation = Page(G.I_CHECK_DELEGATION)
  68. page_delegation.link(button=G.I_BACK_BLUE, destination=page_exploration)
  69. page_exploration.link(button=G.I_EXPLORATION_GOTO_DELEGATION, destination=page_delegation)
  70. # 秘闻副本 SECRET zones
  71. page_secret_zones = Page(G.I_CHECK_SECRET_ZONES)
  72. page_secret_zones.link(button=G.I_BACK_BLUE, destination=page_exploration)
  73. page_exploration.link(button=G.I_EXPLORATION_GOTO_SECRET_ZONES, destination=page_secret_zones)
  74. # 地域鬼王 area boss
  75. page_area_boss = Page(G.I_CHECK_AREA_BOSS)
  76. page_area_boss.link(button=G.I_BACK_BLUE, destination=page_exploration)
  77. page_exploration.link(button=G.I_EXPLORATION_GOTO_AREA_BOSS, destination=page_area_boss)
  78. # 平安奇谭 heian kitan
  79. page_heian_kitan = Page(G.I_CHECK_HEIAN_KITAN)
  80. page_heian_kitan.link(button=G.I_CHECK_HEIAN_KITAN, destination=page_exploration)
  81. page_exploration.link(button=G.I_EXPLORATION_GOTO_HEIAN_KITAN, destination=page_heian_kitan)
  82. # 六道之门 six gates
  83. page_six_gates = Page(G.I_CHECK_SIX_GATES)
  84. page_six_gates.link(button=G.I_SIX_GATES_GOTO_EXPLORATION, destination=page_exploration)
  85. page_exploration.link(button=G.I_EXPLORATION_GOTO_SIX_GATES, destination=page_six_gates)
  86. # 契灵之境 bondling fairyland
  87. page_bondling_fairyland = Page(G.I_CHECK_BONDLING_FAIRYLAND)
  88. page_bondling_fairyland.link(button=G.I_BACK_YOLLOW, destination=page_exploration)
  89. page_exploration.link(button=G.I_EXPLORATION_GOTO_BONDLING_FAIRYLAND, destination=page_bondling_fairyland)
  90. # ************************************* 町中部分 *****************************************#
  91. # 斗技 duel
  92. page_duel = Page(G.I_CHECK_DUEL)
  93. page_duel.link(button=G.I_BACK_YOLLOW, destination=page_town)
  94. page_town.link(button=G.I_TOWN_GOTO_DUEL, destination=page_duel)
  95. # 逢魔之时 demon_encounter
  96. page_demon_encounter = Page(G.I_CHECK_DEMON_ENCOUNTER)
  97. page_demon_encounter.link(button=G.I_DEMON_ENCOUNTER_GOTO_TOWN, destination=page_town)
  98. page_town.link(button=G.I_TOWN_GOTO_DEMON_ENCOUNTER, destination=page_demon_encounter)
  99. # 狩猎战 hunt
  100. page_hunt = Page(G.I_CHECK_HUNT)
  101. page_hunt.link(button=G.I_BACK_BL, destination=page_town)
  102. page_town.link(button=G.I_TOWN_GOTO_HUNT, destination=page_hunt)
  103. # 狩猎战麒麟 hunt_kirin
  104. page_hunt_kirin = Page(G.I_CHECK_HUNT_KIRIN)
  105. page_hunt_kirin.link(button=G.I_BACK_YOLLOW, destination=page_town)
  106. page_town.link(button=G.I_TOWN_GOTO_HUNT, destination=page_hunt_kirin)
  107. # 协同斗技 draft_duel
  108. page_draft_duel = Page(G.I_CHECK_DRAFT_DUEL)
  109. page_draft_duel.link(button=G.I_BACK_YOLLOW, destination=page_town)
  110. page_town.link(button=G.I_TOWN_GOTO_DRAFT_DUEL, destination=page_draft_duel)
  111. # 百鬼弈 hyakkisen
  112. page_hyakkisen = Page(G.I_CHECK_HYAKKISEN)
  113. page_hyakkisen.link(button=G.I_BACK_YOLLOW, destination=page_town)
  114. page_town.link(button=G.I_TOWN_GOTO_HYAKKISEN, destination=page_hyakkisen)
  115. # 百鬼夜行
  116. page_hyakkiyakou = Page(G.I_CHECK_KYAKKIYAKOU)
  117. page_hyakkiyakou.link(button=G.I_HYAKKIYAKOU_CLOSE, destination=page_town)
  118. page_town.link(button=G.I_TOWN_GOTO_HYAKKIYAKOU, destination=page_hyakkiyakou)
  119. # ************************************* 庭院部分 *****************************************#
  120. # 式神录 shikigami_records
  121. page_shikigami_records = Page(G.I_CHECK_RECORDS)
  122. page_shikigami_records.additional = [G.I_AD_DISAPPEAR, G.I_RECORDS_CLOSE]
  123. page_shikigami_records.link(button=G.I_BACK_Y, destination=page_main)
  124. page_main.link(button=G.I_MAIN_GOTO_SHIKIGAMI_RECORDS, destination=page_shikigami_records)
  125. # 阴阳术 onmyodo
  126. page_onmyodo = Page(G.I_CHECK_ONMYODO)
  127. page_onmyodo.link(button=G.I_BACK_Y, destination=page_main)
  128. page_main.link(button=G.I_MAIN_GOTO_ONMYODO, destination=page_onmyodo)
  129. # 好友 friends
  130. page_friends = Page(G.I_CHECK_FRIENDS)
  131. page_friends.link(button=G.I_BACK_Y, destination=page_main)
  132. page_main.link(button=G.I_MAIN_GOTO_FRIENDS, destination=page_friends)
  133. # 花合战 daily
  134. page_daily = Page(G.I_CHECK_DAILY)
  135. # page_daily.additional = [G.O_CLICK_CLOSE_1, G.O_CLICK_CLOSE_2]
  136. page_daily.link(button=G.I_BACK_Y, destination=page_main)
  137. page_main.link(button=G.I_MAIN_GOTO_DAILY, destination=page_daily)
  138. from tasks.DailyTrifles.assets import DailyTriflesAssets
  139. # 商店 mall
  140. page_mall = Page(check_button=[G.I_CHECK_MALL, DailyTriflesAssets.I_ROOM_GIFT])
  141. page_mall.additional = [G.I_AD_CLOSE_RED, G.I_BACK_Y, G.I_DLC_CLOSE]
  142. page_mall.link(button=G.I_BACK_BLUE, destination=page_main)
  143. page_main.link(button=G.I_MAIN_GOTO_MALL, destination=page_mall)
  144. # 阴阳寮 guild
  145. page_guild = Page(G.I_CHECK_GUILD)
  146. page_guild.link(button=G.I_BACK_Y, destination=page_main)
  147. page_main.link(button=G.I_MAIN_GOTO_GUILD, destination=page_guild)
  148. # 组队 team
  149. page_team = Page(G.I_CHECK_TEAM)
  150. page_team.link(button=G.I_BACK_Y, destination=page_main)
  151. page_main.link(button=G.I_MAIN_GOTO_TEAM, destination=page_team)
  152. # 收集 collection
  153. page_collection = Page(G.I_CHECK_COLLECTION)
  154. page_collection.link(button=G.I_BACK_Y, destination=page_main)
  155. page_main.link(button=G.I_MAIN_GOTO_COLLECTION, destination=page_collection)
  156. # 珍旅居
  157. page_travel = Page(G.I_CHECK_TRAVEL)
  158. page_travel.link(button=G.I_BACK_Y, destination=page_main)
  159. page_main.link(button=G.I_MAIN_GOTO_TRAVEL, destination=page_travel)
  160. # 活动列表页 act_list
  161. page_act_list = Page(G.I_CHECK_ACT_LIST)
  162. page_act_list.additional = [G.I_PAPER_DOLL_CLOSE]
  163. page_act_list.link(button=G.I_BACK_ACT_LIST, destination=page_main)
  164. page_main.link(button=G.I_ACT_LIST_EXPAND, destination=page_act_list)
  165. # 道馆
  166. from tasks.Component.GeneralBattle.assets import GeneralBattleAssets
  167. from tasks.Dokan.assets import DokanAssets
  168. page_dokan = Page(DokanAssets.I_RYOU_DOKAN_CHECK)
  169. page_dokan.additional = [GeneralBattleAssets.I_EXIT, DokanAssets.I_RYOU_DOKAN_EXIT_ENSURE, G.I_BACK_BLUE]
  170. page_dokan.link(button=G.I_BACK_Y, destination=page_main)
  171. # ************************************* 活动部分 *****************************************#
  172. from tasks.ActivityShikigami.assets import ActivityShikigamiAssets as asa
  173. from tasks.GlobalGame.assets import GlobalGameAssets as gga
  174. # 活动列表页爬塔活动
  175. page_act_list_climb_act = Page(asa.I_CHECK_ACT_LIST_CLIMB_ACT)
  176. page_act_list.link(button=G.L_ACT_LIST_OCR, destination=page_act_list_climb_act)
  177. page_act_list_climb_act.link(button=G.I_BACK_ACT_LIST, destination=page_main)
  178. # 爬塔活动界面
  179. page_climb_act = Page(asa.I_BATTLE)
  180. page_climb_act.additional = [gga.I_UI_REWARD, asa.I_SKIP_BUTTON, asa.I_RED_EXIT, asa.I_RED_EXIT_2]
  181. page_climb_act.link(button=G.I_BACK_Y, destination=page_main)
  182. page_act_list_climb_act.link(button=G.I_ACT_LIST_GOTO_ACT, destination=page_climb_act)
  183. # 爬塔活动副界面
  184. page_climb_act_2 = Page(asa.I_CHECK_BATTLE_2)
  185. page_climb_act_2.additional = [asa.I_ACT_MAP_SWITCH, asa.I_PASS_ACT_LOCAT, asa.I_SKIP_BUTTON, asa.I_RED_EXIT,
  186. asa.I_RED_EXIT_2]
  187. page_climb_act_2.link(button=G.I_BACK_BATTLE, destination=page_climb_act)
  188. page_climb_act.link(button=asa.I_BATTLE, destination=page_climb_act_2)
  189. # 门票爬塔活动界面
  190. page_climb_act_pass = Page(asa.I_AP_ACTIVITY)
  191. page_climb_act_pass.additional = [asa.I_SKIP_BUTTON, gga.I_UI_REWARD, asa.I_RED_EXIT, ]
  192. page_climb_act_pass.link(button=G.I_BACK_Y, destination=page_climb_act_2)
  193. page_climb_act_2.link(button=asa.I_ENTRY_ACTIVITY, destination=page_climb_act_pass)
  194. # 体力爬塔活动界面
  195. page_climb_act_ap = Page(asa.I_AP)
  196. page_climb_act_ap.additional = [asa.O_ENTRY_ACTIVITY, asa.I_SKIP_BUTTON, asa.I_TOGGLE_BUTTON, gga.I_UI_REWARD,
  197. asa.I_RED_EXIT]
  198. page_climb_act_ap.link(button=G.I_BACK_Y, destination=page_climb_act_2)
  199. page_climb_act_2.link(button=asa.O_ENTRY_ACTIVITY, destination=page_climb_act_ap)
  200. # 体力, 门票互相跳转
  201. # page_climb_act_ap.link(button=asa.I_SWITCH, destination=page_climb_act_pass)
  202. # page_climb_act_pass.link(button=asa.I_SWITCH, destination=page_climb_act_ap)
  203. # 100体爬塔活动界面
  204. page_climb_act_ap100 = Page(asa.I_CHECK_AP100)
  205. page_climb_act_2.link(button=asa.O_ENTER_AP100, destination=page_climb_act_ap100)
  206. page_climb_act_ap100.link(button=G.I_BACK_Y, destination=page_climb_act_2)
  207. # 爬塔活动boss战界面
  208. page_climb_act_boss = Page(asa.I_CHECK_BOSS)
  209. page_climb_act_boss.additional = [BT.I_UI_BACK_RED, asa.I_SKIP_BUTTON]
  210. page_climb_act_boss.link(button=G.I_BACK_Y, destination=page_climb_act)
  211. page_climb_act.link(button=asa.I_BOSS, destination=page_climb_act_boss)
  212. # 爬塔活动加成界面
  213. page_climb_act_buff = Page(asa.I_CHECK_BUFF)
  214. page_climb_act_buff.additional = [BT.I_UI_BACK_RED, asa.I_SKIP_BUTTON]
  215. page_climb_act_buff.link(button=G.I_BACK_Y, destination=page_climb_act)
  216. page_climb_act.link(button=asa.I_BUFF_CHANGE_BUTTON, destination=page_climb_act_buff)
  217. # ************************************* 战斗部分 *****************************************#
  218. # 战斗界面
  219. page_battle_auto = Page(G.O_BATTLE_AUTO)
  220. page_battle_hand = Page(G.O_BATTLE_HAND)
  221. page_battle_auto.link(button=G.O_BATTLE_AUTO, destination=page_battle_hand)
  222. page_battle_hand.link(button=G.O_BATTLE_HAND, destination=page_battle_auto)
  223. def random_click(low: int = None, high: int = None) -> RuleClick | list[RuleClick]:
  224. """
  225. 随机生成RuleClick, 不传入参数则返回1个RuleClick, 传入参数则生成范围内的click数组
  226. :return: RuleClick或者RuleClick的数组
  227. """
  228. click = random.choice([asa.C_RANDOM_LEFT, asa.C_RANDOM_RIGHT, asa.C_RANDOM_TOP])
  229. click.name = "BATTLE_RANDOM"
  230. if low is None or high is None:
  231. return click
  232. return [click for _ in range(random.randint(low, high))]
  233. # 奖励界面
  234. page_reward = Page(check_button=[GeneralBattleAssets.I_REWARD_PURPLE_SNAKE_SKIN, GeneralBattleAssets.I_REWARD,
  235. GeneralBattleAssets.I_REWARD_EXP_SOUL_4, GeneralBattleAssets.I_WIN,
  236. GeneralBattleAssets.I_REWARD_GOLD, GeneralBattleAssets.I_REWARD_GOLD_SNAKE_SKIN,
  237. GeneralBattleAssets.I_REWARD_SOUL_5, GeneralBattleAssets.I_REWARD_SOUL_6,
  238. gga.I_UI_REWARD, ],
  239. links={page_climb_act_pass: random_click(), page_climb_act_ap: random_click(),
  240. page_area_boss: random_click()})
  241. page_reward.additional = [random_click()]
  242. # 失败界面
  243. page_failed = Page(check_button=GeneralBattleAssets.I_FALSE,
  244. links={page_climb_act_pass: random_click(), page_climb_act_ap: random_click(),
  245. page_area_boss: random_click()})
  246. page_failed.additional = [random_click()]