mirror of
https://github.com/LmeSzinc/AzurLaneAutoScript.git
synced 2025-01-08 12:47:32 +08:00
Fix: Detection of beacon data collected today
This commit is contained in:
parent
af4cb88ff5
commit
9e6028685f
BIN
assets/cn/os_ash/ASH_DAILY_STATUS.png
Normal file
BIN
assets/cn/os_ash/ASH_DAILY_STATUS.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.9 KiB |
BIN
assets/en/os_ash/ASH_DAILY_STATUS.png
Normal file
BIN
assets/en/os_ash/ASH_DAILY_STATUS.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.9 KiB |
BIN
assets/jp/os_ash/ASH_DAILY_STATUS.png
Normal file
BIN
assets/jp/os_ash/ASH_DAILY_STATUS.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.9 KiB |
BIN
assets/tw/os_ash/ASH_DAILY_STATUS.png
Normal file
BIN
assets/tw/os_ash/ASH_DAILY_STATUS.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.9 KiB |
@ -654,6 +654,29 @@ def color_mapping(image, max_multiply=2):
|
||||
return image.astype(np.uint8)
|
||||
|
||||
|
||||
def image_left_strip(image, threshold, length):
|
||||
"""
|
||||
In `DAILY:200/200` strip `DAILY:` and leave `200/200`
|
||||
|
||||
Args:
|
||||
image (np.ndarray): (height, width)
|
||||
threshold (int):
|
||||
0-255
|
||||
The first column with brightness lower than this
|
||||
will be considered as left edge.
|
||||
length (int):
|
||||
Strip this length of image after the left edge
|
||||
|
||||
Returns:
|
||||
np.ndarray:
|
||||
"""
|
||||
brightness = np.mean(image, axis=0)
|
||||
match = np.where(brightness < threshold)[0]
|
||||
if len(match):
|
||||
image = image[:, match[0] + length:]
|
||||
return image
|
||||
|
||||
|
||||
def red_overlay_transparency(color1, color2, red=247):
|
||||
"""Calculate the transparency of red overlay.
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
import numpy as np
|
||||
|
||||
from module.base.button import ButtonGrid
|
||||
from module.base.utils import image_left_strip
|
||||
from module.exercise.assets import *
|
||||
from module.logger import logger
|
||||
from module.ocr.ocr import Digit
|
||||
@ -19,10 +20,7 @@ PWR_FACTOR = 100
|
||||
class Level(Digit):
|
||||
def pre_process(self, image):
|
||||
image = super().pre_process(image)
|
||||
letter_l = np.where(np.mean(image, axis=0) < 85)[0]
|
||||
if len(letter_l):
|
||||
letter_l = letter_l[0] + 22
|
||||
image = image[:, letter_l:]
|
||||
image = image_left_strip(image, threshold=85, length=22)
|
||||
|
||||
image = np.pad(image, ((5, 6), (0, 5)), mode='constant', constant_values=255)
|
||||
return image.astype(np.uint8)
|
||||
|
@ -1,5 +1,5 @@
|
||||
from module.base.timer import Timer
|
||||
from module.base.utils import color_bar_percentage
|
||||
from module.base.utils import color_bar_percentage, image_left_strip
|
||||
from module.combat.combat import BATTLE_PREPARATION, GET_ITEMS_1, Combat
|
||||
from module.logger import logger
|
||||
from module.ocr.ocr import Digit, DigitCounter
|
||||
@ -12,10 +12,20 @@ from module.ui.page import page_os
|
||||
from module.ui.switch import Switch
|
||||
from module.ui.ui import UI
|
||||
|
||||
|
||||
class DailyDigitCounter(DigitCounter):
|
||||
def pre_process(self, image):
|
||||
image = super().pre_process(image)
|
||||
image = image_left_strip(image, threshold=120, length=35)
|
||||
return image
|
||||
|
||||
|
||||
OCR_BEACON_REMAIN = DigitCounter(BEACON_REMAIN, threshold=256, name='OCR_ASH_REMAIN')
|
||||
OCR_BEACON_TIER = Digit(BEACON_TIER, name='OCR_ASH_TIER')
|
||||
OCR_ASH_COLLECT_STATUS = DigitCounter(
|
||||
ASH_COLLECT_STATUS, letter=(235, 235, 235), threshold=160, name='OCR_ASH_COLLECT_STATUS')
|
||||
OCR_ASH_DAILY_STATUS = DailyDigitCounter(
|
||||
ASH_DAILY_STATUS, letter=(235, 235, 235), threshold=160, name='OCR_ASH_DAILY_STATUS')
|
||||
|
||||
SWITCH_BEACON = Switch(name='Beacon', offset=(20, 20))
|
||||
SWITCH_BEACON.add_status('mine', BEACON_LIST)
|
||||
@ -200,20 +210,19 @@ class OSAsh(UI, MapEventHandler):
|
||||
if self._ash_fully_collected:
|
||||
return 0
|
||||
if not self.image_color_count(ASH_COLLECT_STATUS, color=(235, 235, 235), threshold=221, count=20):
|
||||
if self.image_color_count(ASH_COLLECT_STATUS, color=(82, 85, 82), threshold=235, count=50):
|
||||
logger.info('Ash beacon fully collected today')
|
||||
self._ash_fully_collected = True
|
||||
return 0
|
||||
else:
|
||||
# If OS daily mission received or finished, the popup will cover beacon status.
|
||||
logger.info('Ash beacon status is covered, will check next time')
|
||||
return 0
|
||||
# If OS daily mission received or finished, the popup will cover beacon status.
|
||||
logger.info('Ash beacon status is covered, will check next time')
|
||||
return 0
|
||||
|
||||
status, _, _ = OCR_ASH_COLLECT_STATUS.ocr(self.device.image)
|
||||
daily, _, _ = OCR_ASH_DAILY_STATUS.ocr(self.device.image)
|
||||
|
||||
if daily >= 200:
|
||||
logger.info('Ash beacon fully collected today')
|
||||
self._ash_fully_collected = True
|
||||
|
||||
if status < 0:
|
||||
status = 0
|
||||
if status > 100:
|
||||
status = 100
|
||||
return status
|
||||
|
||||
def _ash_mine_enter_from_map(self, skip_first_screenshot=True):
|
||||
|
@ -6,6 +6,7 @@ from module.base.template import Template
|
||||
|
||||
ASH_CHECK = Button(area={'cn': (921, 20, 1028, 53), 'en': (922, 21, 1028, 54), 'jp': (940, 24, 1013, 45), 'tw': (921, 20, 1028, 54)}, color={'cn': (116, 87, 87), 'en': (125, 84, 83), 'jp': (166, 132, 132), 'tw': (120, 84, 84)}, button={'cn': (921, 20, 1028, 53), 'en': (922, 21, 1028, 54), 'jp': (940, 24, 1013, 45), 'tw': (921, 20, 1028, 54)}, file={'cn': './assets/cn/os_ash/ASH_CHECK.png', 'en': './assets/en/os_ash/ASH_CHECK.png', 'jp': './assets/jp/os_ash/ASH_CHECK.png', 'tw': './assets/tw/os_ash/ASH_CHECK.png'})
|
||||
ASH_COLLECT_STATUS = Button(area={'cn': (640, 27, 720, 49), 'en': (640, 27, 720, 49), 'jp': (640, 27, 720, 49), 'tw': (640, 27, 720, 49)}, color={'cn': (82, 92, 99), 'en': (82, 92, 99), 'jp': (82, 92, 99), 'tw': (82, 92, 99)}, button={'cn': (640, 27, 720, 49), 'en': (640, 27, 720, 49), 'jp': (640, 27, 720, 49), 'tw': (640, 27, 720, 49)}, file={'cn': './assets/cn/os_ash/ASH_COLLECT_STATUS.png', 'en': './assets/en/os_ash/ASH_COLLECT_STATUS.png', 'jp': './assets/jp/os_ash/ASH_COLLECT_STATUS.png', 'tw': './assets/tw/os_ash/ASH_COLLECT_STATUS.png'})
|
||||
ASH_DAILY_STATUS = Button(area={'cn': (637, 0, 741, 19), 'en': (637, 0, 741, 19), 'jp': (637, 0, 741, 19), 'tw': (637, 0, 741, 19)}, color={'cn': (104, 112, 121), 'en': (104, 112, 121), 'jp': (104, 112, 121), 'tw': (104, 112, 121)}, button={'cn': (637, 0, 741, 19), 'en': (637, 0, 741, 19), 'jp': (637, 0, 741, 19), 'tw': (637, 0, 741, 19)}, file={'cn': './assets/cn/os_ash/ASH_DAILY_STATUS.png', 'en': './assets/en/os_ash/ASH_DAILY_STATUS.png', 'jp': './assets/jp/os_ash/ASH_DAILY_STATUS.png', 'tw': './assets/tw/os_ash/ASH_DAILY_STATUS.png'})
|
||||
ASH_ENTER_CONFIRM = Button(area={'cn': (554, 482, 726, 539), 'en': (560, 487, 720, 534), 'jp': (553, 482, 727, 539), 'tw': (554, 482, 726, 539)}, color={'cn': (109, 153, 209), 'en': (106, 151, 207), 'jp': (111, 154, 207), 'tw': (109, 153, 209)}, button={'cn': (554, 482, 726, 539), 'en': (560, 487, 720, 534), 'jp': (553, 482, 727, 539), 'tw': (554, 482, 726, 539)}, file={'cn': './assets/cn/os_ash/ASH_ENTER_CONFIRM.png', 'en': './assets/en/os_ash/ASH_ENTER_CONFIRM.png', 'jp': './assets/jp/os_ash/ASH_ENTER_CONFIRM.png', 'tw': './assets/tw/os_ash/ASH_ENTER_CONFIRM.png'})
|
||||
ASH_ENTRANCE = Button(area={'cn': (935, 671, 1002, 689), 'en': (938, 676, 995, 690), 'jp': (934, 658, 1026, 689), 'tw': (934, 670, 1000, 689)}, color={'cn': (53, 57, 58), 'en': (73, 74, 75), 'jp': (50, 58, 62), 'tw': (60, 63, 65)}, button={'cn': (932, 631, 1078, 692), 'en': (932, 631, 1078, 692), 'jp': (934, 629, 1079, 693), 'tw': (930, 629, 1080, 693)}, file={'cn': './assets/cn/os_ash/ASH_ENTRANCE.png', 'en': './assets/en/os_ash/ASH_ENTRANCE.png', 'jp': './assets/jp/os_ash/ASH_ENTRANCE.png', 'tw': './assets/tw/os_ash/ASH_ENTRANCE.png'})
|
||||
ASH_QUIT = Button(area={'cn': (29, 25, 59, 49), 'en': (29, 25, 59, 49), 'jp': (22, 25, 54, 48), 'tw': (29, 25, 59, 49)}, color={'cn': (115, 63, 68), 'en': (115, 63, 68), 'jp': (114, 61, 67), 'tw': (115, 63, 68)}, button={'cn': (29, 25, 59, 49), 'en': (29, 25, 59, 49), 'jp': (22, 25, 54, 48), 'tw': (29, 25, 59, 49)}, file={'cn': './assets/cn/os_ash/ASH_QUIT.png', 'en': './assets/en/os_ash/ASH_QUIT.png', 'jp': './assets/jp/os_ash/ASH_QUIT.png', 'tw': './assets/tw/os_ash/ASH_QUIT.png'})
|
||||
|
Loading…
Reference in New Issue
Block a user