mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-22 08:37:42 +00:00
Merge branch 'bug_fix' into dev
# Conflicts: # module/base/button.py # tasks/base/popup.py # tasks/freebies/support_reward.py
This commit is contained in:
commit
6b212a1c69
BIN
assets/share/base/popup/GET_REWARD.2.png
Normal file
BIN
assets/share/base/popup/GET_REWARD.2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 2.3 KiB |
@ -179,20 +179,29 @@ def iter_assets():
|
||||
if image.attr != '':
|
||||
row = deep_get(data, keys=[image.module, image.assets, image.server, image.frame])
|
||||
row.load_image(image)
|
||||
# Apply `search` of the first frame to all
|
||||
# Set `search`
|
||||
for path, frames in deep_iter(data, depth=3):
|
||||
print(path, frames)
|
||||
# If `search` attribute is set in the first frame, apply to all
|
||||
first = frames[1]
|
||||
search = first.search if first.search else DataAssets.area_to_search(first.area)
|
||||
for frame in frames.values():
|
||||
frame.search = search
|
||||
if first.search:
|
||||
for frame in frames.values():
|
||||
frame.search = first.search
|
||||
else:
|
||||
for frame in frames.values():
|
||||
if frame.search:
|
||||
# Follow frame specific `search`
|
||||
pass
|
||||
else:
|
||||
# Generate `search` from `area`
|
||||
frame.search = DataAssets.area_to_search(frame.area)
|
||||
|
||||
return data
|
||||
|
||||
|
||||
def generate_code():
|
||||
all = iter_assets()
|
||||
for module, module_data in all.items():
|
||||
all_assets = iter_assets()
|
||||
for module, module_data in all_assets.items():
|
||||
path = os.path.join(AzurLaneConfig.ASSETS_MODULE, module.split('/', maxsplit=1)[0])
|
||||
output = os.path.join(path, 'assets.py')
|
||||
if os.path.exists(output):
|
||||
@ -204,7 +213,7 @@ def generate_code():
|
||||
continue
|
||||
os.remove(prev)
|
||||
|
||||
for module, module_data in all.items():
|
||||
for module, module_data in all_assets.items():
|
||||
path = os.path.join(AzurLaneConfig.ASSETS_MODULE, module.split('/', maxsplit=1)[0])
|
||||
output = os.path.join(path, 'assets')
|
||||
gen = CodeGenerator()
|
||||
|
@ -23,7 +23,7 @@ CHARACTER_MATERIALS_CHECK = ButtonWrapper(
|
||||
Button(
|
||||
file='./assets/en/assignment/ui/CHARACTER_MATERIALS_CHECK.2.png',
|
||||
area=(142, 98, 234, 119),
|
||||
search=(319, 68, 449, 146),
|
||||
search=(122, 78, 254, 139),
|
||||
color=(203, 202, 199),
|
||||
button=(142, 98, 234, 119),
|
||||
),
|
||||
@ -49,7 +49,7 @@ CHARACTER_MATERIALS_CLICK = ButtonWrapper(
|
||||
Button(
|
||||
file='./assets/en/assignment/ui/CHARACTER_MATERIALS_CLICK.2.png',
|
||||
area=(143, 98, 234, 120),
|
||||
search=(319, 68, 449, 147),
|
||||
search=(123, 78, 254, 140),
|
||||
color=(61, 59, 57),
|
||||
button=(143, 98, 234, 120),
|
||||
),
|
||||
@ -102,7 +102,7 @@ EXP_MATERIALS_CREDITS_CHECK = ButtonWrapper(
|
||||
Button(
|
||||
file='./assets/en/assignment/ui/EXP_MATERIALS_CREDITS_CHECK.2.png',
|
||||
area=(373, 98, 458, 119),
|
||||
search=(509, 68, 619, 146),
|
||||
search=(353, 78, 478, 139),
|
||||
color=(191, 190, 187),
|
||||
button=(373, 98, 458, 119),
|
||||
),
|
||||
@ -128,7 +128,7 @@ EXP_MATERIALS_CREDITS_CLICK = ButtonWrapper(
|
||||
Button(
|
||||
file='./assets/en/assignment/ui/EXP_MATERIALS_CREDITS_CLICK.2.png',
|
||||
area=(374, 98, 459, 119),
|
||||
search=(508, 68, 619, 147),
|
||||
search=(354, 78, 479, 139),
|
||||
color=(49, 49, 49),
|
||||
button=(374, 98, 459, 119),
|
||||
),
|
||||
@ -245,7 +245,7 @@ SYNTHESIS_MATERIALS_CHECK = ButtonWrapper(
|
||||
Button(
|
||||
file='./assets/en/assignment/ui/SYNTHESIS_MATERIALS_CHECK.2.png',
|
||||
area=(624, 97, 715, 119),
|
||||
search=(683, 68, 810, 146),
|
||||
search=(604, 77, 735, 139),
|
||||
color=(197, 196, 193),
|
||||
button=(624, 97, 715, 119),
|
||||
),
|
||||
@ -271,7 +271,7 @@ SYNTHESIS_MATERIALS_CLICK = ButtonWrapper(
|
||||
Button(
|
||||
file='./assets/en/assignment/ui/SYNTHESIS_MATERIALS_CLICK.2.png',
|
||||
area=(624, 97, 715, 119),
|
||||
search=(682, 68, 810, 146),
|
||||
search=(604, 77, 735, 139),
|
||||
color=(51, 50, 49),
|
||||
button=(624, 97, 715, 119),
|
||||
),
|
||||
|
@ -96,7 +96,7 @@ GACHA_CHECK = ButtonWrapper(
|
||||
Button(
|
||||
file='./assets/share/base/page/GACHA_CHECK.2.png',
|
||||
area=(41, 21, 74, 54),
|
||||
search=(20, 0, 94, 74),
|
||||
search=(21, 1, 94, 74),
|
||||
color=(188, 167, 142),
|
||||
button=(41, 21, 74, 54),
|
||||
),
|
||||
|
@ -49,13 +49,22 @@ GET_LIGHT_CONE = ButtonWrapper(
|
||||
)
|
||||
GET_REWARD = ButtonWrapper(
|
||||
name='GET_REWARD',
|
||||
share=Button(
|
||||
file='./assets/share/base/popup/GET_REWARD.png',
|
||||
area=(623, 95, 657, 119),
|
||||
search=(603, 75, 677, 139),
|
||||
color=(145, 131, 99),
|
||||
button=(741, 495, 1071, 644),
|
||||
),
|
||||
share=[
|
||||
Button(
|
||||
file='./assets/share/base/popup/GET_REWARD.png',
|
||||
area=(625, 95, 655, 119),
|
||||
search=(605, 75, 675, 139),
|
||||
color=(213, 0, 0),
|
||||
button=(741, 495, 1071, 644),
|
||||
),
|
||||
Button(
|
||||
file='./assets/share/base/popup/GET_REWARD.2.png',
|
||||
area=(625, 144, 655, 168),
|
||||
search=(605, 124, 675, 188),
|
||||
color=(226, 0, 0),
|
||||
button=(625, 144, 655, 168),
|
||||
),
|
||||
],
|
||||
)
|
||||
MONTHLY_CARD_GET_ITEM = ButtonWrapper(
|
||||
name='MONTHLY_CARD_GET_ITEM',
|
||||
|
@ -12,7 +12,6 @@ from module.ocr.utils import split_and_pair_buttons
|
||||
from module.ui.scroll import Scroll
|
||||
from module.ui.switch import Switch
|
||||
from tasks.base.assets.assets_base_page import BATTLE_PASS_CHECK, MAIN_GOTO_BATTLE_PASS
|
||||
from tasks.base.assets.assets_base_popup import GET_REWARD
|
||||
from tasks.base.page import page_battle_pass, page_main
|
||||
from tasks.base.ui import UI
|
||||
from tasks.battle_pass.assets.assets_battle_pass import *
|
||||
@ -187,7 +186,7 @@ class BattlePassUI(UI):
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
if self.appear(GET_REWARD):
|
||||
if self.reward_appear():
|
||||
logger.info('Get reward')
|
||||
break
|
||||
if self.appear(CLOSE_CHOOSE_GIFT):
|
||||
|
@ -1,11 +1,9 @@
|
||||
from module.ocr.ocr import *
|
||||
from module.ui.scroll import Scroll
|
||||
from tasks.base.assets.assets_base_page import MENU_CHECK, SYNTHESIZE_CHECK
|
||||
from tasks.base.assets.assets_base_popup import GET_REWARD
|
||||
from tasks.base.assets.assets_base_page import MENU_CHECK, MENU_SCROLL, SYNTHESIZE_CHECK
|
||||
from tasks.base.assets.assets_base_popup import POPUP_CONFIRM
|
||||
from tasks.base.page import Page, page_menu, page_synthesize
|
||||
from tasks.base.ui import UI
|
||||
from tasks.base.assets.assets_base_page import MENU_SCROLL
|
||||
from tasks.base.assets.assets_base_popup import POPUP_CONFIRM
|
||||
from tasks.daily.assets.assets_daily_synthesize_consumable import *
|
||||
from tasks.daily.assets.assets_daily_synthesize_material import *
|
||||
|
||||
@ -157,7 +155,7 @@ class SynthesizeUI(UI):
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
if self.appear(GET_REWARD):
|
||||
if self.reward_appear():
|
||||
logger.info('Synthesize consumable completed')
|
||||
break
|
||||
# Synthesize confirm
|
||||
@ -175,7 +173,7 @@ class SynthesizeUI(UI):
|
||||
logger.info('Synthesize consumables page appear')
|
||||
break
|
||||
# Go back to the previous page
|
||||
if self.appear_then_click(GET_REWARD):
|
||||
if self.handle_reward(interval=2):
|
||||
logger.info('Click on the blank space to back to synthesize page')
|
||||
continue
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
from module.base.timer import Timer
|
||||
from module.logger import logger
|
||||
from tasks.base.assets.assets_base_page import MENU_CHECK
|
||||
from tasks.base.assets.assets_base_popup import GET_REWARD
|
||||
from tasks.base.page import page_menu
|
||||
from tasks.base.ui import UI
|
||||
from tasks.freebies.assets.assets_freebies_support_reward import (
|
||||
@ -53,7 +52,7 @@ class SupportReward(UI):
|
||||
"""
|
||||
Pages:
|
||||
in: PROFILE
|
||||
out: GET_REWARD
|
||||
out: reward_appear()
|
||||
"""
|
||||
logger.info('Getting reward')
|
||||
claimed = False
|
||||
@ -68,7 +67,7 @@ class SupportReward(UI):
|
||||
if not claimed and empty.reached():
|
||||
logger.info('No reward')
|
||||
break
|
||||
if self.appear(GET_REWARD):
|
||||
if self.reward_appear():
|
||||
logger.info('Got reward')
|
||||
break
|
||||
if timeout.reached():
|
||||
@ -83,7 +82,7 @@ class SupportReward(UI):
|
||||
def _goto_menu(self):
|
||||
"""
|
||||
Pages:
|
||||
in: PROFILE or GET_REWARD
|
||||
in: PROFILE or reward_appear
|
||||
out: MENU
|
||||
"""
|
||||
skip_first_screenshot = False
|
||||
|
@ -1,7 +1,6 @@
|
||||
from module.base.timer import Timer
|
||||
from module.logger import logger
|
||||
from tasks.base.assets.assets_base_page import CLOSE
|
||||
from tasks.base.assets.assets_base_popup import GET_REWARD
|
||||
from tasks.item.assets.assets_item_relics import *
|
||||
from tasks.item.keywords import KEYWORD_ITEM_TAB
|
||||
from tasks.item.ui import ItemUI
|
||||
@ -96,7 +95,7 @@ class RelicsUI(ItemUI):
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
if self.appear(GET_REWARD):
|
||||
if self.reward_appear():
|
||||
logger.info("Relic salvaged")
|
||||
break
|
||||
if self.appear_then_click(SALVAGE, interval=2):
|
||||
|
@ -187,7 +187,7 @@ class Aim:
|
||||
draw_circle(draw, self.circle_enemy, points)
|
||||
if self.debug:
|
||||
self.draw_enemy = cv2.multiply(draw, 4)
|
||||
subtract_blur(draw, 3)
|
||||
draw = subtract_blur(draw, 3)
|
||||
|
||||
# Find peaks
|
||||
points = inrange(draw, lower=36)
|
||||
@ -230,7 +230,6 @@ class Aim:
|
||||
draw_circle(draw, self.circle_item, points)
|
||||
if self.debug:
|
||||
self.draw_item = cv2.multiply(draw, 2)
|
||||
subtract_blur(draw, 7)
|
||||
|
||||
# Find peaks
|
||||
points = inrange(draw, lower=64)
|
||||
|
@ -265,7 +265,7 @@ class Minimap(MapResource):
|
||||
scale = self.DIRECTION_ROTATION_SCALE * self.DIRECTION_SEARCH_SCALE
|
||||
mapping = cv2.resize(image, None, fx=scale, fy=scale, interpolation=cv2.INTER_NEAREST)
|
||||
result = cv2.matchTemplate(self.ArrowRotateMap, mapping, cv2.TM_CCOEFF_NORMED)
|
||||
subtract_blur(result, 5)
|
||||
result = subtract_blur(result, 5)
|
||||
_, sim, _, loca = cv2.minMaxLoc(result)
|
||||
loca = np.array(loca) / self.DIRECTION_SEARCH_SCALE // (self.DIRECTION_RADIUS * 2)
|
||||
degree = int((loca[0] + loca[1] * 8) * 5)
|
||||
@ -282,7 +282,7 @@ class Minimap(MapResource):
|
||||
|
||||
precise_map = self.ArrowRotateMapAll[row[0]:row[1], :]
|
||||
result = cv2.matchTemplate(precise_map, mapping, cv2.TM_CCOEFF_NORMED)
|
||||
subtract_blur(result, 5)
|
||||
result = subtract_blur(result, 5)
|
||||
|
||||
def to_map(x):
|
||||
return int((x * self.DIRECTION_RADIUS * 2) * self.POSITION_SEARCH_SCALE)
|
||||
|
Loading…
Reference in New Issue
Block a user