Ver código fonte

Merge pull request #106 from runhey/dev

Dev
huangrunheng 3 anos atrás
pai
commit
fc7b34f8fc
38 arquivos alterados com 181 adições e 97 exclusões
  1. 1 1
      script.py
  2. BIN
      tasks/ActivityShikigami/as/as_ap.png
  3. BIN
      tasks/ActivityShikigami/as/as_ap_activity.png
  4. BIN
      tasks/ActivityShikigami/as/as_back_green.png
  5. BIN
      tasks/ActivityShikigami/as/as_battle.png
  6. BIN
      tasks/ActivityShikigami/as/as_drum.png
  7. BIN
      tasks/ActivityShikigami/as/as_fire.png
  8. BIN
      tasks/ActivityShikigami/as/as_lock.png
  9. BIN
      tasks/ActivityShikigami/as/as_shi.png
  10. BIN
      tasks/ActivityShikigami/as/as_switch.png
  11. BIN
      tasks/ActivityShikigami/as/as_unlock.png
  12. 21 21
      tasks/ActivityShikigami/as/image.json
  13. 4 4
      tasks/ActivityShikigami/as/ocr.json
  14. 15 15
      tasks/ActivityShikigami/assets.py
  15. 1 1
      tasks/Component/GeneralBattle/assets.py
  16. BIN
      tasks/Component/GeneralBattle/gb/gb_greed_ghost.png
  17. 2 2
      tasks/Component/GeneralBattle/gb/img_supplement.json
  18. 2 2
      tasks/DailyTrifles/assets.py
  19. 3 3
      tasks/DailyTrifles/store/image.json
  20. BIN
      tasks/DailyTrifles/store/store_gift_sign.png
  21. BIN
      tasks/DailyTrifles/store/store_room_gift.png
  22. 6 0
      tasks/DemonEncounter/script_task.py
  23. 2 3
      tasks/Orochi/assets.py
  24. 4 4
      tasks/Orochi/o/image.json
  25. BIN
      tasks/Orochi/o/o_orochi_lock.png
  26. BIN
      tasks/Orochi/o/o_orochi_unlock.png
  27. 83 30
      tasks/Orochi/script_task.py
  28. 1 1
      tasks/RealmRaid/assets.py
  29. 1 1
      tasks/RealmRaid/res/image.json
  30. BIN
      tasks/RealmRaid/res/res_medal_0.png
  31. 6 2
      tasks/RichMan/mall/special.py
  32. 8 1
      tasks/RyouToppa/script_task.py
  33. 2 0
      tasks/Secret/assets.py
  34. 6 2
      tasks/Secret/script_task.py
  35. 9 0
      tasks/Secret/se/ocr.json
  36. 1 1
      tasks/WeeklyTrifles/assets.py
  37. 1 1
      tasks/WeeklyTrifles/script_task.py
  38. 2 2
      tasks/WeeklyTrifles/secret/image.json

+ 1 - 1
script.py

@@ -321,7 +321,7 @@ class Script:
                     if not self.wait_until(task.next_run):
                         del_cached_property(self, 'config')
                         continue
-                    self.run('start')
+                    self.run('Restart')
                 elif method == 'goto_main':
                     logger.info('Goto main page during wait')
                     self.run('GotoMain')

BIN
tasks/ActivityShikigami/as/as_ap.png


BIN
tasks/ActivityShikigami/as/as_ap_activity.png


BIN
tasks/ActivityShikigami/as/as_back_green.png


BIN
tasks/ActivityShikigami/as/as_battle.png


BIN
tasks/ActivityShikigami/as/as_drum.png


BIN
tasks/ActivityShikigami/as/as_fire.png


BIN
tasks/ActivityShikigami/as/as_lock.png


BIN
tasks/ActivityShikigami/as/as_shi.png


BIN
tasks/ActivityShikigami/as/as_switch.png


BIN
tasks/ActivityShikigami/as/as_unlock.png


+ 21 - 21
tasks/ActivityShikigami/as/image.json

@@ -2,7 +2,7 @@
   {
     "itemName": "shi",
     "imageName": "as_shi.png",
-    "roiFront": "136,237,59,42",
+    "roiFront": "1014.3333333333333,206.66666666666652,49,39",
     "roiBack": "85,170,1029,142",
     "method": "Template matching",
     "threshold": 0.7,
@@ -11,7 +11,7 @@
   {
     "itemName": "back_green",
     "imageName": "as_back_green.png",
-    "roiFront": "13,18,49,49",
+    "roiFront": "13,18,44,44",
     "roiBack": "13,18,49,49",
     "method": "Template matching",
     "threshold": 0.8,
@@ -20,8 +20,8 @@
   {
     "itemName": "battle",
     "imageName": "as_battle.png",
-    "roiFront": "150,312,52,177",
-    "roiBack": "150,312,52,177",
+    "roiFront": "1010,189,47,172",
+    "roiBack": "1010,189,52,177",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "进入爬塔"
@@ -29,8 +29,8 @@
   {
     "itemName": "drum",
     "imageName": "as_drum.png",
-    "roiFront": "902,379,41,43",
-    "roiBack": "902,379,41,43",
+    "roiFront": "1011,114,29,31",
+    "roiBack": "1011,114,29,31",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "归鹿之途"
@@ -38,8 +38,8 @@
   {
     "itemName": "lock",
     "imageName": "as_lock.png",
-    "roiFront": "793,654,30,32",
-    "roiBack": "793,654,30,32",
+    "roiFront": "795,654,25,32",
+    "roiBack": "795,654,25,32",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "上锁图标"
@@ -47,8 +47,8 @@
   {
     "itemName": "unlock",
     "imageName": "as_unlock.png",
-    "roiFront": "795,650,27,35",
-    "roiBack": "795,650,27,35",
+    "roiFront": "1135,483,27,27",
+    "roiBack": "795,654,27,27",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "还未上锁图片"
@@ -56,8 +56,8 @@
   {
     "itemName": "fire",
     "imageName": "as_fire.png",
-    "roiFront": "1123,563,106,116",
-    "roiBack": "1123,563,106,116",
+    "roiFront": "1135,483,22,22",
+    "roiBack": "1104,551,138,130",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "点击战斗"
@@ -65,8 +65,8 @@
   {
     "itemName": "ap",
     "imageName": "as_ap.png",
-    "roiFront": "1116,498,27,37",
-    "roiBack": "1116,498,27,37",
+    "roiFront": "1136,488,20,22",
+    "roiBack": "1133,481,27,37",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "体力按钮"
@@ -74,8 +74,8 @@
   {
     "itemName": "ap_activity",
     "imageName": "as_ap_activity.png",
-    "roiFront": "1120,510,27,27",
-    "roiBack": "1120,510,27,27",
+    "roiFront": "1132,485,27,31",
+    "roiBack": "1127,479,37,44",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "活动体力"
@@ -83,8 +83,8 @@
   {
     "itemName": "switch",
     "imageName": "as_switch.png",
-    "roiFront": "1207,505,33,30",
-    "roiBack": "1207,505,33,30",
+    "roiFront": "1211,486,33,30",
+    "roiBack": "1211,486,33,30",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "切换按键"
@@ -92,7 +92,7 @@
   {
     "itemName": "buy_jade",
     "imageName": "as_buy_jade.png",
-    "roiFront": "836,619,38,42",
+    "roiFront": "1004,192,38,42",
     "roiBack": "836,619,38,42",
     "method": "Template matching",
     "threshold": 0.8,
@@ -101,7 +101,7 @@
   {
     "itemName": "add_max",
     "imageName": "as_add_max.png",
-    "roiFront": "974,524,57,54",
+    "roiFront": "17,24,33,37",
     "roiBack": "974,524,57,54",
     "method": "Template matching",
     "threshold": 0.8,
@@ -110,7 +110,7 @@
   {
     "itemName": "new",
     "imageName": "as_new.png",
-    "roiFront": "0,0,100,100",
+    "roiFront": "1004,192,65,52",
     "roiBack": "0,0,100,100",
     "method": "Template matching",
     "threshold": 0.8,

+ 4 - 4
tasks/ActivityShikigami/as/ocr.json

@@ -1,8 +1,8 @@
 [
   {
     "itemName": "remain_ap",
-    "roiFront": "1126,690,87,28",
-    "roiBack": "1126,690,87,28",
+    "roiFront": "1096,26,116,28",
+    "roiBack": "1092,23,121,33",
     "mode": "DigitCounter",
     "method": "Default",
     "keyword": "",
@@ -10,8 +10,8 @@
   },
   {
     "itemName": "remain_ap_activity",
-    "roiFront": "884,20,106,34",
-    "roiBack": "884,20,106,34",
+    "roiFront": "707,24,106,34",
+    "roiBack": "707,24,106,34",
     "mode": "DigitCounter",
     "method": "Default",
     "keyword": "",

+ 15 - 15
tasks/ActivityShikigami/assets.py

@@ -12,38 +12,38 @@ class ActivityShikigamiAssets:
 
 	# Image Rule Assets
 	# 进入活动 
-	I_SHI = RuleImage(roi_front=(136,237,59,42), roi_back=(85,170,1029,142), threshold=0.7, method="Template matching", file="./tasks/ActivityShikigami/as/as_shi.png")
+	I_SHI = RuleImage(roi_front=(1014.3333333333333,206.66666666666652,49,39), roi_back=(85,170,1029,142), threshold=0.7, method="Template matching", file="./tasks/ActivityShikigami/as/as_shi.png")
 	# 左上角返回 
-	I_BACK_GREEN = RuleImage(roi_front=(13,18,49,49), roi_back=(13,18,49,49), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_back_green.png")
+	I_BACK_GREEN = RuleImage(roi_front=(13,18,44,44), roi_back=(13,18,49,49), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_back_green.png")
 	# 进入爬塔 
-	I_BATTLE = RuleImage(roi_front=(150,312,52,177), roi_back=(150,312,52,177), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_battle.png")
+	I_BATTLE = RuleImage(roi_front=(1010,189,47,172), roi_back=(1010,189,52,177), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_battle.png")
 	# 归鹿之途 
-	I_DRUM = RuleImage(roi_front=(902,379,41,43), roi_back=(902,379,41,43), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_drum.png")
+	I_DRUM = RuleImage(roi_front=(1011,114,29,31), roi_back=(1011,114,29,31), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_drum.png")
 	# 上锁图标 
-	I_LOCK = RuleImage(roi_front=(793,654,30,32), roi_back=(793,654,30,32), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_lock.png")
+	I_LOCK = RuleImage(roi_front=(795,654,25,32), roi_back=(795,654,25,32), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_lock.png")
 	# 还未上锁图片 
-	I_UNLOCK = RuleImage(roi_front=(795,650,27,35), roi_back=(795,650,27,35), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_unlock.png")
+	I_UNLOCK = RuleImage(roi_front=(1135,483,27,27), roi_back=(795,654,27,27), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_unlock.png")
 	# 点击战斗 
-	I_FIRE = RuleImage(roi_front=(1123,563,106,116), roi_back=(1123,563,106,116), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_fire.png")
+	I_FIRE = RuleImage(roi_front=(1135,483,22,22), roi_back=(1104,551,138,130), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_fire.png")
 	# 体力按钮 
-	I_AP = RuleImage(roi_front=(1116,498,27,37), roi_back=(1116,498,27,37), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_ap.png")
+	I_AP = RuleImage(roi_front=(1136,488,20,22), roi_back=(1133,481,27,37), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_ap.png")
 	# 活动体力 
-	I_AP_ACTIVITY = RuleImage(roi_front=(1120,510,27,27), roi_back=(1120,510,27,27), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_ap_activity.png")
+	I_AP_ACTIVITY = RuleImage(roi_front=(1132,485,27,31), roi_back=(1127,479,37,44), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_ap_activity.png")
 	# 切换按键 
-	I_SWITCH = RuleImage(roi_front=(1207,505,33,30), roi_back=(1207,505,33,30), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_switch.png")
+	I_SWITCH = RuleImage(roi_front=(1211,486,33,30), roi_back=(1211,486,33,30), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_switch.png")
 	# 购买活动的体力 
-	I_BUY_JADE = RuleImage(roi_front=(836,619,38,42), roi_back=(836,619,38,42), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_buy_jade.png")
+	I_BUY_JADE = RuleImage(roi_front=(1004,192,38,42), roi_back=(836,619,38,42), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_buy_jade.png")
 	# 增加到最大 
-	I_ADD_MAX = RuleImage(roi_front=(974,524,57,54), roi_back=(974,524,57,54), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_add_max.png")
+	I_ADD_MAX = RuleImage(roi_front=(17,24,33,37), roi_back=(974,524,57,54), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_add_max.png")
 	# description 
-	I_NEW = RuleImage(roi_front=(0,0,100,100), roi_back=(0,0,100,100), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_new.png")
+	I_NEW = RuleImage(roi_front=(1004,192,65,52), roi_back=(0,0,100,100), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_new.png")
 
 
 	# Ocr Rule Assets
 	# 体力的数量检测 
-	O_REMAIN_AP = RuleOcr(roi=(1126,690,87,28), area=(1126,690,87,28), mode="DigitCounter", method="Default", keyword="", name="remain_ap")
+	O_REMAIN_AP = RuleOcr(roi=(1096,26,116,28), area=(1092,23,121,33), mode="DigitCounter", method="Default", keyword="", name="remain_ap")
 	# 活动体力的剩余检测 
-	O_REMAIN_AP_ACTIVITY = RuleOcr(roi=(884,20,106,34), area=(884,20,106,34), mode="DigitCounter", method="Default", keyword="", name="remain_ap_activity")
+	O_REMAIN_AP_ACTIVITY = RuleOcr(roi=(707,24,106,34), area=(707,24,106,34), mode="DigitCounter", method="Default", keyword="", name="remain_ap_activity")
 	# 还有多少次购买体力的机会 
 	O_REMAIN_BUY = RuleOcr(roi=(808,531,39,42), area=(808,531,39,42), mode="DigitCounter", method="Default", keyword="", name="remain_buy")
 

+ 1 - 1
tasks/Component/GeneralBattle/assets.py

@@ -117,7 +117,7 @@ class GeneralBattleAssets:
 
 	# Image Rule Assets
 	# description 
-	I_GREED_GHOST = RuleImage(roi_front=(49,29,56,65), roi_back=(49,29,56,65), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_greed_ghost.png")
+	I_GREED_GHOST = RuleImage(roi_front=(56,40,45,45), roi_back=(56,40,45,45), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_greed_ghost.png")
 
 
 	# Swipe Rule Assets

BIN
tasks/Component/GeneralBattle/gb/gb_greed_ghost.png


+ 2 - 2
tasks/Component/GeneralBattle/gb/img_supplement.json

@@ -2,8 +2,8 @@
   {
     "itemName": "greed_ghost",
     "imageName": "gb_greed_ghost.png",
-    "roiFront": "49,29,56,65",
-    "roiBack": "49,29,56,65",
+    "roiFront": "56,40,45,45",
+    "roiBack": "56,40,45,45",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"

+ 2 - 2
tasks/DailyTrifles/assets.py

@@ -21,10 +21,10 @@ class DailyTriflesAssets:
 
 	# Image Rule Assets
 	# 礼包屋 
-	I_ROOM_GIFT = RuleImage(roi_front=(1142,629,69,64), roi_back=(1127,611,103,94), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_room_gift.png")
+	I_ROOM_GIFT = RuleImage(roi_front=(1142,638,62,55), roi_back=(1127,611,103,94), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_room_gift.png")
 	# description 
 	I_GIFT_RECOMMEND = RuleImage(roi_front=(1186,98,53,64), roi_back=(1172,83,83,214), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_gift_recommend.png")
 	# 免费一抽 
-	I_GIFT_SIGN = RuleImage(roi_front=(201,207,100,143), roi_back=(201,207,100,143), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_gift_sign.png")
+	I_GIFT_SIGN = RuleImage(roi_front=(236,129,306,218), roi_back=(236,129,306,218), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_gift_sign.png")
 
 

+ 3 - 3
tasks/DailyTrifles/store/image.json

@@ -2,7 +2,7 @@
   {
     "itemName": "room_gift",
     "imageName": "store_room_gift.png",
-    "roiFront": "1142,629,69,64",
+    "roiFront": "1142,638,62,55",
     "roiBack": "1127,611,103,94",
     "method": "Template matching",
     "threshold": 0.8,
@@ -20,8 +20,8 @@
   {
     "itemName": "gift_sign",
     "imageName": "store_gift_sign.png",
-    "roiFront": "201,207,100,143",
-    "roiBack": "201,207,100,143",
+    "roiFront": "236,129,306,218",
+    "roiBack": "236,129,306,218",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "免费一抽"

BIN
tasks/DailyTrifles/store/store_gift_sign.png


BIN
tasks/DailyTrifles/store/store_room_gift.png


+ 6 - 0
tasks/DemonEncounter/script_task.py

@@ -83,6 +83,7 @@ class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets):
                 continue
         logger.info('Boss battle start')
         # 点击集结挑战
+        boss_fire_count = 0  # 五次没点到就意味着今天已经挑战过了
         while 1:
             self.screenshot()
             if self.appear(self.I_BOSS_CONFIRM):
@@ -91,7 +92,12 @@ class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets):
                 break
             if self.appear(self.I_BOSS_GATHER):
                 break
+            if boss_fire_count >= 5:
+                logger.warning('Boss battle already done')
+                self.ui_click_until_disappear(self.I_UI_BACK_RED)
+                return
             if self.appear_then_click(self.I_BOSS_FIRE, interval=1):
+                boss_fire_count += 1
                 continue
         logger.info('Boss battle confirm and enter')
         # 等待挑战, 5秒也是等

+ 2 - 3
tasks/Orochi/assets.py

@@ -16,12 +16,11 @@ class OrochiAssets:
 	# 组队 
 	I_FORM_TEAM = RuleImage(roi_front=(937,591,100,100), roi_back=(937,591,100,100), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_form_team.png")
 	# description 
-	I_OROCHI_LOCK = RuleImage(roi_front=(573,559,31,32), roi_back=(548,554,65,54), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_orochi_lock.png")
+	I_OROCHI_LOCK = RuleImage(roi_front=(557,563,31,32), roi_back=(548,554,101,54), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_orochi_lock.png")
 	# description 
-	I_OROCHI_UNLOCK = RuleImage(roi_front=(575,558,26,29), roi_back=(560,553,56,40), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_orochi_unlock.png")
+	I_OROCHI_UNLOCK = RuleImage(roi_front=(562,564,26,29), roi_back=(550,553,100,51), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_orochi_unlock.png")
 	# 点击挑战 
 	I_OROCHI_FIRE = RuleImage(roi_front=(1095,577,131,124), roi_back=(1095,577,131,124), threshold=0.6, method="Template matching", file="./tasks/Orochi/o/o_orochi_fire.png")
-	I_OROCHI_WILD_FIRE = RuleImage(roi_front=(1179,602,81,87), roi_back=(1179,602,81,87), threshold=0.6, method="Template matching", file="./tasks/Orochi/o/o_orochi_wild_fire.png")
 	# 式神录 
 	I_SHI_RECORDS = RuleImage(roi_front=(821,638,48,45), roi_back=(821,638,48,45), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_shi_records.png")
 	# description 

+ 4 - 4
tasks/Orochi/o/image.json

@@ -20,8 +20,8 @@
   {
     "itemName": "orochi_lock",
     "imageName": "o_orochi_lock.png",
-    "roiFront": "573,559,31,32",
-    "roiBack": "548,554,65,54",
+    "roiFront": "557,563,31,32",
+    "roiBack": "548,554,101,54",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -29,8 +29,8 @@
   {
     "itemName": "orochi_unlock",
     "imageName": "o_orochi_unlock.png",
-    "roiFront": "575,558,26,29",
-    "roiBack": "560,553,56,40",
+    "roiFront": "562,564,26,29",
+    "roiBack": "550,553,100,51",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"

BIN
tasks/Orochi/o/o_orochi_lock.png


BIN
tasks/Orochi/o/o_orochi_unlock.png


+ 83 - 30
tasks/Orochi/script_task.py

@@ -1,6 +1,7 @@
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # github https://github.com/runhey
+import random
 from time import sleep
 from datetime import time, datetime, timedelta
 
@@ -52,7 +53,7 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
             case UserStatus.LEADER: success = self.run_leader()
             case UserStatus.MEMBER: success = self.run_member()
             case UserStatus.ALONE: self.run_alone()
-            case UserStatus.WILD: self.run_wild()
+            case UserStatus.WILD: success = self.run_wild()
             case _: logger.error('Unknown user status')
 
         # 记得关掉
@@ -121,11 +122,6 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
 
 
 
-
-
-
-
-
     def run_leader(self):
         logger.info('Start run leader')
         self.ui_get_current_page()
@@ -176,15 +172,10 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
 
             # 如果没有进入房间那就不需要后面的邀请
             if not self.is_in_room():
-                # 如果在探索界面或者是出现在组队界面, 那就是可能房间死了
-                # 要结束任务
-                sleep(0.5)
-                if self.appear(self.I_MATCHING) or self.appear(self.I_CHECK_EXPLORATION):
-                    sleep(0.5)
-                    if self.appear(self.I_MATCHING) or self.appear(self.I_CHECK_EXPLORATION):
-                        logger.warning('Orochi task failed')
-                        success = False
-                        break
+                if self.is_room_dead():
+                    logger.warning('Orochi task failed')
+                    success = False
+                    break
                 continue
 
             # 点击挑战
@@ -326,8 +317,6 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
         self.ui_current = page_soul_zones
         self.ui_goto(page_main)
 
-
-
     def run_wild(self):
         logger.info('Start run wild')
 
@@ -352,6 +341,7 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
             self.ensure_public()
             self.create_ensure()
 
+        success = True
         while 1:
             self.screenshot()
             # 无论胜利与否, 都会出现是否邀请一次队友
@@ -374,14 +364,10 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
                     break
 
             if not self.is_in_room():
-                # 如果在探索界面或者是出现在组队界面,那就是可能房间死了,要结束任务
-                sleep(0.5)
-                if self.appear(self.I_MATCHING) or self.appear(self.I_CHECK_EXPLORATION):
-                    sleep(0.5)
-                    if self.appear(self.I_MATCHING) or self.appear(self.I_CHECK_EXPLORATION):
-                        logger.warning('Orochi task failed')
-                        success = False
-                        break
+                if self.is_room_dead():
+                    logger.warning('Orochi task failed')
+                    success = False
+                    break
                 continue
 
             # 点击挑战
@@ -391,9 +377,11 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
                 # 在进入战斗前必然会出现挑战界面,因此点击失败必须重复点击,防止卡在挑战界面,
                 # 点击成功后如果网络卡顿,导致没有进入战斗,则无法进入 run_general_battle 流程,
                 # 所以如果判断是在战斗中,则执行通用战斗流程
-                if not (self.appear_then_click(self.I_OROCHI_WILD_FIRE, interval=0.5, threshold=0.8)
-                         or self.is_in_battle(False)):
-                    continue
+                if not self.is_in_battle(False):
+                    if not self.is_in_room() and self.is_room_dead():
+                        break
+                    if not self.appear_then_click(self.I_OROCHI_WILD_FIRE, interval=1, threshold=0.8):
+                        continue
 
                 self.screenshot()
                 if not self.appear(self.I_OROCHI_WILD_FIRE, threshold=0.8):
@@ -415,8 +403,73 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
             return False
         return True
 
+    def is_room_dead(self) -> bool:
+        # 如果在探索界面或者是出现在组队界面,那就是可能房间死了
+        sleep(0.5)
+        if self.appear(self.I_MATCHING) or self.appear(self.I_CHECK_EXPLORATION):
+            sleep(0.5)
+            if self.appear(self.I_MATCHING) or self.appear(self.I_CHECK_EXPLORATION):
+                return True
+        return False
+
+    def battle_wait(self, random_click_swipt_enable: bool) -> bool:
+        """
+        重写战斗等待
+        # https://github.com/runhey/OnmyojiAutoScript/issues/95
+        :param random_click_swipt_enable:
+        :return:
+        """
+        # 重写
+        self.device.stuck_record_add('BATTLE_STATUS_S')
+        self.device.click_record_clear()
+        self.C_REWARD_1.name = 'C_REWARD'
+        self.C_REWARD_2.name = 'C_REWARD'
+        self.C_REWARD_3.name = 'C_REWARD'
+        # 战斗过程 随机点击和滑动 防封
+        logger.info("Start battle process")
+        while 1:
+            self.screenshot()
+            action_click = random.choice([self.C_WIN_1, self.C_WIN_2, self.C_WIN_3])
+            if self.appear_then_click(self.I_WIN, action=action_click ,interval=0.8):
+                # 赢的那个鼓
+                continue
+            if self.appear(self.I_GREED_GHOST):
+                # 贪吃鬼
+                logger.info('Win battle')
+                self.wait_until_appear(self.I_REWARD, wait_time=1.5)
+                self.screenshot()
+                if not self.appear(self.I_GREED_GHOST):
+                    logger.warning('Greedy ghost disappear. Maybe it is a false battle')
+                    continue
+                while 1:
+                    self.screenshot()
+                    action_click = random.choice([self.C_REWARD_1, self.C_REWARD_2, self.C_REWARD_3])
+                    if not self.appear(self.I_GREED_GHOST):
+                        break
+                    if self.click(action_click, interval=1.5):
+                        continue
+                return True
+            if self.appear(self.I_REWARD):
+                # 魂
+                logger.info('Win battle')
+                appear_greed_ghost = self.appear(self.I_GREED_GHOST)
+                while 1:
+                    self.screenshot()
+                    action_click = random.choice([self.C_REWARD_1, self.C_REWARD_2, self.C_REWARD_3])
+                    if self.appear_then_click(self.I_REWARD, action=action_click, interval=1.5):
+                        continue
+                    if not self.appear(self.I_REWARD):
+                        break
+                return True
 
+            if self.appear(self.I_FALSE):
+                logger.warning('False battle')
+                self.ui_click_until_disappear(self.I_FALSE)
+                return False
 
+            # 如果开启战斗过程随机滑动
+            if random_click_swipt_enable:
+                self.random_click_swipt()
 
 
 
@@ -424,11 +477,11 @@ if __name__ == '__main__':
     from module.config.config import Config
     from module.device.device import Device
     from memory_profiler import profile
-    c = Config('oas1')
+    c = Config('test')
     d = Device(c)
     t = ScriptTask(c, d)
 
-    # t.run()
+    t.run()
 
     # t.check_layer('悲')
 

+ 1 - 1
tasks/RealmRaid/assets.py

@@ -24,7 +24,7 @@ class RealmRaidAssets:
 	# description 
 	I_MEDAL_1 = RuleImage(roi_front=(570,206,199,52), roi_back=(237,198,892,336), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_medal_1.png")
 	# 没有勋章的 
-	I_MEDAL_0 = RuleImage(roi_front=(510,336,202,51), roi_back=(231,200,898,336), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_medal_0.png")
+	I_MEDAL_0 = RuleImage(roi_front=(536,336,176,51), roi_back=(231,200,898,336), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_medal_0.png")
 	# 右上角红色的关闭 
 	I_BACK_RED = RuleImage(roi_front=(1178,101,57,64), roi_back=(1178,101,57,64), threshold=0.7, method="Template matching", file="./tasks/RealmRaid/res/res_back_red.png")
 	# 没有锁的状态图标 

+ 1 - 1
tasks/RealmRaid/res/image.json

@@ -56,7 +56,7 @@
   {
     "itemName": "medal_0",
     "imageName": "res_medal_0.png",
-    "roiFront": "510,336,202,51",
+    "roiFront": "536,336,176,51",
     "roiBack": "231,200,898,336",
     "method": "Template matching",
     "threshold": 0.8,

BIN
tasks/RealmRaid/res/res_medal_0.png


+ 6 - 2
tasks/RichMan/mall/special.py

@@ -163,8 +163,12 @@ class Special(Buy, MallNavbar):
         result = self.O_SP_RES_NUMBER.ocr(self.device.image)
         result = result.replace('?', '2').replace('?', '2').replace(':', ';')
         try:
-            result = re.findall(r'剩余购买次数:(\d+)', result)[0]
-            result = int(result)
+            if ':' in result:
+                result = re.findall(r'剩余购买次数:(\d+)', result)[0]
+                result = int(result)
+            else:
+                result = re.findall(r'剩余购买次数(\d+)', result)[0]
+                result = int(result)
         except:
             result = 0
         logger.info(f'Remain [{result}]')

+ 8 - 1
tasks/RyouToppa/script_task.py

@@ -42,6 +42,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RyouToppaAssets):
         self.ui_get_current_page()
         self.ui_goto(page_kekkai_toppa)
         ryou_toppa_start_flag = True
+        ryou_toppa_success_penetration = False
         # 点击突破
         while 1:
             self.screenshot()
@@ -55,6 +56,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RyouToppaAssets):
             # 攻破阴阳寮,说明寮突已开,则退出
             elif self.appear(self.I_SUCCESS_PENETRATION, threshold=0.8):
                 ryou_toppa_start_flag = True
+                ryou_toppa_success_penetration = True
                 break
             # 出现选择寮突说明寮突未开
             elif self.appear(self.I_SELECT_RYOU_BUTTON, threshold=0.8):
@@ -70,6 +72,11 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RyouToppaAssets):
             # 开寮突
             self.start_ryou_toppa()
 
+        # 100% 攻破, 第二天再执行
+        if ryou_toppa_success_penetration:
+            self.set_next_run(task='RyouToppa', finish=True, success=True)
+            raise TaskEnd
+
         # 开始突破
         while 1:
             if self.execute_round():
@@ -81,7 +88,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RyouToppaAssets):
         # self.ui_current = page_ryou_toppa
         # self.ui_goto(page_main)
 
-        self.set_next_run(task='RyouToppa', finish=True, success=True)
+        self.set_next_run(task='RyouToppa', finish=True, server=False, success=True)
         raise TaskEnd
 
     def start_ryou_toppa(self):

+ 2 - 0
tasks/Secret/assets.py

@@ -47,6 +47,8 @@ class SecretAssets:
 	O_SE_NO_PASS_LAST = RuleOcr(roi=(429,381,180,234), area=(429,381,180,234), mode="Full", method="Default", keyword="未通关", name="se_no_pass_last")
 	# 勾玉 
 	O_SE_JADE = RuleOcr(roi=(327,230,23,24), area=(327,230,23,24), mode="Digit", method="Default", keyword="", name="se_jade")
+	# 金币 
+	O_SE_GOLD = RuleOcr(roi=(363,226,48,21), area=(363,226,48,21), mode="Digit", method="Default", keyword="", name="se_gold")
 
 
 	# Swipe Rule Assets

+ 6 - 2
tasks/Secret/script_task.py

@@ -163,7 +163,7 @@ class ScriptTask(GameUi, GeneralBattle, SwitchSoul, SecretAssets):
             :param roi:
             :return:
             """
-            ocr_target.roi[0] = int(roi[0]) - 115
+            ocr_target.roi[0] = int(roi[0]) - 118
             ocr_target.roi[1] = int(roi[1]) + 37
             print(f'检测到的未通过ROI: {roi}')
             print(f'检测到的勾玉数量ROI: {ocr_target.roi}')
@@ -175,7 +175,11 @@ class ScriptTask(GameUi, GeneralBattle, SwitchSoul, SecretAssets):
                 logger.warning(f'OCR failed, try again {jade_num}')
                 return None
             if jade_num < 7:
-                logger.warning(f'OCR failed, try again {jade_num}')
+                # 第一个的时候可能是没有检测到
+                gold_number = self.O_SE_GOLD.ocr(self.device.image)
+                if isinstance(gold_number, int) and gold_number == 10000:
+                    logger.info(f'No find jade number, but find gold number {gold_number}')
+                    return 1
                 return None
             elif jade_num > 70:
                 logger.warning(f'OCR failed, try again {jade_num}')

+ 9 - 0
tasks/Secret/se/ocr.json

@@ -61,5 +61,14 @@
     "method": "Default",
     "keyword": "",
     "description": "勾玉"
+  },
+  {
+    "itemName": "se_gold",
+    "roiFront": "363,226,48,21",
+    "roiBack": "363,226,48,21",
+    "mode": "Digit",
+    "method": "Default",
+    "keyword": "",
+    "description": "金币"
   }
 ]

+ 1 - 1
tasks/WeeklyTrifles/assets.py

@@ -76,6 +76,6 @@ class WeeklyTriflesAssets:
 	# 勾玉 
 	I_WT_SE_JADE = RuleImage(roi_front=(1129,529,35,39), roi_back=(1129,529,35,39), threshold=0.8, method="Template matching", file="./tasks/WeeklyTrifles/secret/secret_wt_se_jade.png")
 	# 排行 
-	I_WT_SE_RANK = RuleImage(roi_front=(1013,571,45,44), roi_back=(1013,571,45,44), threshold=0.8, method="Template matching", file="./tasks/WeeklyTrifles/secret/secret_wt_se_rank.png")
+	I_WT_SE_RANK = RuleImage(roi_front=(1017,572,45,44), roi_back=(989,556,103,81), threshold=0.8, method="Template matching", file="./tasks/WeeklyTrifles/secret/secret_wt_se_rank.png")
 
 

+ 1 - 1
tasks/WeeklyTrifles/script_task.py

@@ -267,6 +267,6 @@ if __name__ == '__main__':
     t = ScriptTask(c, d)
     t.screenshot()
 
-    t._share_collect()
+    t._share_secret()
 
 

+ 2 - 2
tasks/WeeklyTrifles/secret/image.json

@@ -38,8 +38,8 @@
   {
     "itemName": "wt_se_rank",
     "imageName": "secret_wt_se_rank.png",
-    "roiFront": "1013,571,45,44",
-    "roiBack": "1013,571,45,44",
+    "roiFront": "1017,572,45,44",
+    "roiBack": "989,556,103,81",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "排行"