Skip to content

Commit

Permalink
Merge pull request #39 from pur1fying/test
Browse files Browse the repository at this point in the history
fix: config problem
  • Loading branch information
Kiramei authored Dec 21, 2023
2 parents 1287dab + 04f27c5 commit 99bd8e9
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 39 deletions.
12 changes: 5 additions & 7 deletions core/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ def get_root_path():
def notify(title=None, body=None):
root_path = get_root_path()
_notify(
title=title,
body=body,
app_id='BlueArchiveAutoScript.exe',
icon=root_path + icon_path,
)


title=title,
body=body,
app_id='BlueArchiveAutoScript.exe',
icon=root_path + icon_path,
)
5 changes: 2 additions & 3 deletions gui/components/expand/exploreConfig.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import threading

from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QLabel, QVBoxLayout
from qfluentwidgets import ComboBox, LineEdit, PushButton
from PyQt5.QtWidgets import QHBoxLayout, QLabel
from qfluentwidgets import LineEdit, PushButton

import main
from .expandTemplate import TemplateLayout
from gui.util.config_set import ConfigSet


class Layout(TemplateLayout):
Expand Down
12 changes: 10 additions & 2 deletions gui/components/expand/serverConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def __init__(self, parent=None):
self.info_widget = self.parent().parent().parent()
self.folderLabel = QLabel('请选择您的服务器', self)
self.serverLabel = QLabel('请填写您的adb端口号', self)
self.port_note = QLabel('常用端口:MuMu:7555;蓝叠/雷电:5555;夜神:62001或59865;', self)
self.port_note_ = QLabel('Mumu12:16384;逍遥:21503;多开请自行查询端口。', self)
server_type = ['官服', 'B服', '国际服']
self.portBox = LineEdit(self)
self.combo = ComboBox(self)
Expand All @@ -28,12 +30,17 @@ def __init__(self, parent=None):
self.combo.currentTextChanged.connect(self._save_server)

self.vBoxLayout = QVBoxLayout(self)
self.vBoxLayout.setContentsMargins(48, 0, 60, 0)
self.setFixedHeight(120)
self.vBoxLayout.setContentsMargins(48, 10, 60, 10)


self.lay1 = QHBoxLayout(self.vBoxLayout.widget())
self.note = QVBoxLayout(self.vBoxLayout.widget())
self.lay2 = QHBoxLayout(self.vBoxLayout.widget())

self.note.addWidget(self.port_note, 0, Qt.AlignLeft)
self.note.addWidget(self.port_note_, 0, Qt.AlignLeft)
self.note.setAlignment(Qt.AlignVCenter)

self.lay1.addWidget(self.folderLabel, 17, Qt.AlignLeft)
self.lay1.addWidget(self.combo, 0, Qt.AlignRight)
self.lay1.setAlignment(Qt.AlignVCenter)
Expand All @@ -43,6 +50,7 @@ def __init__(self, parent=None):
self.lay2.setAlignment(Qt.AlignVCenter)

self.vBoxLayout.addLayout(self.lay1)
self.vBoxLayout.addLayout(self.note)
self.vBoxLayout.addLayout(self.lay2)

def _save_port(self):
Expand Down
5 changes: 5 additions & 0 deletions gui/util/config_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@

class ConfigSet:
def __init__(self):
super().__init__()
self._init_config()

def _init_config(self):
with open('./config/config.json', 'r', encoding='utf-8') as f:
self.config = json.load(f)

def get(self, key):
return self.config.get(key)

def set(self, key, value):
self._init_config()
self.config[key] = value
with open('./config/config.json', 'w', encoding='utf-8') as f:
json.dump(self.config, f, indent=4, ensure_ascii=False)
Expand Down
1 change: 1 addition & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ def init_package_name(self):
if __name__ == '__main__':
# # print(time.time())
t = Main()
t.solve('explore_normal_task')
t.flag_run = True
# t.solve('de_clothes')
# t.solve('common_shop')
Expand Down
1 change: 1 addition & 0 deletions module/explore_hard_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from module import explore_normal_task
import importlib


def implement(self):
if self.server == "CN":
explore_normal_task.implement(self)
Expand Down
5 changes: 3 additions & 2 deletions module/explore_normal_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@


def implement(self):
# test_(self)
if self.server == 'CN':
possible = {
'main_page_home-feature': (1195, 576, 3),
Expand Down Expand Up @@ -80,7 +81,7 @@ def start_fight(self, region):
self.click(1194, 601)
start_action(self, mission, self.stage_data)
main_story.auto_fight(self)
if self.config['manual_boss']:
if self.config['manual_boss'] and mission != 'SUB':
self.click(1235, 41)

normal_task.to_normal_event(self)
Expand Down Expand Up @@ -412,7 +413,7 @@ def test_(self):
normal_task.to_normal_event(self)
choose_region(self, region)
self.stage_data = get_stage_data(region)
for i in range(4, 6):
for i in range(1, 6):
self.swipe(917, 220, 917, 552, duration=0.1)
time.sleep(1)
to_mission_info(self)
Expand Down
59 changes: 34 additions & 25 deletions module/momo_talk.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ def global_implement(self):
unread_location = []
while location_y <= 630:
if np.array_equal(self.latest_img_array[location_y][location_x], red_dot) and \
np.array_equal(self.latest_img_array[location_y + dy][location_x], red_dot):
np.array_equal(self.latest_img_array[location_y + dy][location_x], red_dot):
unread_location.append([location_x, location_y + dy / 2])
location_y += 60
else:
location_y += 1
length = len(unread_location)
self.logger.info("find " + str(length) + " unread message")
self.logger.info("find " + str(length) + " unread message(s)")
if length == 0:
if main_to_momotalk:
self.logger.info("momo_talk task finished")
Expand Down Expand Up @@ -159,33 +159,42 @@ def to_momotalk2(self):


def common_solve_affection_story_method(self):
fail_cnt = 0
self.connection.swipe(924, 330, 924, 230, duration=0.1)
self.click(924, 330, wait=False)
while fail_cnt <= 5:
self.latest_img_array = self.get_screenshot_array()
res = get_reply_position(self.latest_img_array)
if res[0] == 'end':
self.connection.swipe(924, 330, 924, 230, duration=0.1)
self.click(924, 330, wait=False)
start_time = time.time()
while time.time() <= start_time + 10:
img = self.get_screenshot_array()
i = 156
while i < 657:
if color.judge_rgb_range(img, 786, i, 29, 49, 143, 163, 219, 239):
fail_cnt = 0
self.click(826, min(i + 65, 625), wait=False)
break
elif color.judge_rgb_range(img, 862, i, 245, 255, 227, 247, 230, 250) and \
color.judge_rgb_range(img, 862, i + 10, 245, 255, 125, 155, 145, 175):
self.logger.info("ENTER affection story")
self.click(826, min(625, i + 30), wait=False)
time.sleep(0.5)
common_skip_plot_method(self)
to_momotalk2(self)
return
else:
i += 1
time.sleep(2)
fail_cnt += 1
self.logger.info("can't find target button cnt = " + str(fail_cnt))
res = get_reply_position(img)
if res[0] == 'reply':
self.logger.info("reply")
self.click(826, res[1], wait=False)
start_time = time.time()
time.sleep(1)
elif res[0] == 'affection':
self.logger.info("ENTER affection story")
self.click(826, res[1], wait=False)
time.sleep(0.5)
common_skip_plot_method(self)
to_momotalk2(self)
return
time.sleep(self.screenshot_interval)
self.logger.info("current conversation over")


def get_reply_position(img):
i = 156
while i < 657:
if color.judge_rgb_range(img, 786, i, 29, 49, 143, 163, 219, 239):
return 'reply', min(i + 65, 625)
elif color.judge_rgb_range(img, 862, i, 245, 255, 227, 247, 230, 250) and \
color.judge_rgb_range(img, 862, i + 10, 245, 255, 125, 155, 145, 175):
return 'affection', min(625, i + 30)
else:
i += 1
return 'end', 0
def pd_menu_bright(img_array):
if color.judge_rgb_range(img_array, 1165, 45, 230, 255, 230, 255, 230, 255) and color.judge_rgb_range(img_array,
1238, 45, 230,
Expand Down

0 comments on commit 99bd8e9

Please sign in to comment.