Skip to content

Commit

Permalink
update activity sweep method
Browse files Browse the repository at this point in the history
  • Loading branch information
pur1fying committed Mar 5, 2024
1 parent a9ae803 commit 8ddd549
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 45 deletions.
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ def operate_item(self, item):
tt.init_all_data()
tt.ocr = t.ocr
# tt.solve("refresh_uiautomator2")
tt.solve("explore_activity_challenge")
# tt.solve("activity_sweep")
# tt.solve("explore_activity_challenge")
tt.solve("activity_sweep")
# tt.solve("explore_activity_mission")
# tt.solve("explore_activity_story")
# tt.solve("common_shop")
Expand Down
128 changes: 87 additions & 41 deletions module/activities/reckless_nun_and_the_witch_in_the_old_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,60 @@


def implement(self):
times = self.config["activity_sweep_times"]
if times > 0:
return sweep(self, self.config["activity_sweep_task_number"], times)
times = preprocess_activity_sweep_times(self.config["activity_sweep_times"])
region = preprocess_activity_region(self.config["activity_sweep_task_number"])
self.logger.info("activity sweep task number : " + str(region))
self.logger.info("activity sweep times : " + str(times))
if len(times) > 0:
return sweep(self, region, times)
else:
return True


def preprocess_activity_region(region):
if type(region) is int:
return [region]
if type(region) is str:
region = region.split(",")
for i in range(0, len(region)):
region[i] = int(region[i])
return region
if type(region) is list:
for i in range(0, len(region)):
if type(region[i]) is int:
continue
region[i] = int(region[i])
return region


def preprocess_activity_sweep_times(times):
if type(times) is int:
return [times]
if type(times) is float:
return [times]
if type(times) is str:
times = times.split(",")
for i in range(0, len(times)):
if '.' in times[i]:
times[i] = min(float(times[i]), 1.0)
elif '/' in times[i]:
temp = times[i].split("/")
times[i] = min(int(temp[0]) / int(temp[1]), 1.0)
else:
times[i] = int(times[i])
return times
if type(times) is list:
for i in range(0, len(times)):
if type(times[i]) is int:
continue
if '.' in times[i]:
times[i] = min(float(times[i]), 1.0)
elif '/' in times[i]:
temp = times[i].split("/")
times[i] = min(int(temp[0]) / int(temp[1]), 1.0)
return times


def get_stage_data():
module_path = 'src.explore_task_data.activities.reckless_nun_and_the_witch_in_the_old_library'
stage_module = importlib.import_module(module_path)
Expand All @@ -22,38 +69,37 @@ def get_stage_data():

def sweep(self, number, times):
self.quick_method_to_main_page()
to_activity(self, "mission", True)
self.swipe(919, 136, 943, 720, duration=0.05)
time.sleep(0.5)
self.swipe(919, 136, 943, 720, duration=0.05)
time.sleep(0.5)
to_activity(self, "mission", True, True)
ap = self.get_ap()
sweep_one_time_ap = [0, 10, 10,10,10, 15, 15, 15, 15,20,20,20,20]
sweep_times = times
click_times = sweep_times
duration = 1
if sweep_times > 50:
sweep_times = int(ap / sweep_one_time_ap[number])
click_times = int(sweep_times / 2) + 1
duration = 0.3
if sweep_times <= 0:
self.logger.warning("inadequate ap")
return True
self.logger.info("Start sweep task " + str(number) + " :" + str(sweep_times) + " times")
to_mission_task_info(self, number)
res = check_sweep_availability(self)
if res == "sss":
self.click(1032, 299, count=click_times, duration=duration, wait_over=True)
res = start_sweep(self, True)
if res == "inadequate_ap":
sweep_one_time_ap = [0, 10, 10, 10, 10, 15, 15, 15, 15, 20, 20, 20, 20]
for i in range(0, min(len(number), len(times))):
sweep_times = times[i]
if type(sweep_times) is float:
sweep_times = int(ap * sweep_times / sweep_one_time_ap[number[i]])
click_times = sweep_times
duration = 1
if sweep_times > 50:
sweep_times = int(ap / sweep_one_time_ap[number[i]])
click_times = int(sweep_times / 2) + 1
duration = 0.3
if sweep_times <= 0:
self.logger.warning("inadequate ap")
return True
elif res == "sweep_complete":
self.logger.info("sweep task" + str(number) + " finished")
return True
elif res == "pass" or res == "no-pass":
self.logger.warning("task not sss, sweep unavailable")
return True
continue
self.logger.info("Start sweep task " + str(number[i]) + " :" + str(sweep_times) + " times")
to_mission_task_info(self, number[i])
res = check_sweep_availability(self)
if res == "sss":
self.click(1032, 299, count=click_times, duration=duration, wait_over=True)
res = start_sweep(self, True)
if res == "inadequate_ap":
self.logger.warning("inadequate ap")
return True
elif res == "sweep_complete":
self.logger.info("Current sweep task " + str(number[i]) + " :" + str(sweep_times) + " times complete")
to_activity(self, "mission", True, True)
elif res == "pass" or res == "no-pass":
self.logger.warning("task not sss, sweep unavailable")
continue


def explore_story(self):
Expand All @@ -80,7 +126,6 @@ def explore_story(self):
to_activity(self, "story", True)



def start_story(self):
img_possibles = {
"normal_task_task-info": (940, 538),
Expand Down Expand Up @@ -109,7 +154,7 @@ def start_fight(self, i):

def explore_mission(self):
self.quick_method_to_main_page()
to_activity(self, "mission", True)
to_activity(self, "mission", True, True)
last_target_mission = 1
total_missions = 12
characteristic = [
Expand All @@ -127,10 +172,6 @@ def explore_mission(self):
'burst1',
]
while last_target_mission <= total_missions and self.flag_run:
self.swipe(919, 136, 943, 720, duration=0.05)
time.sleep(0.5)
self.swipe(919, 136, 943, 720, duration=0.05)
time.sleep(0.5)
to_mission_task_info(self, last_target_mission)
res = check_sweep_availability(self)
while res == "sss" and last_target_mission <= total_missions - 1 and self.flag_run:
Expand All @@ -148,7 +189,7 @@ def explore_mission(self):
start_fight(self, number)
main_story.auto_fight(self)
to_activity(self, "story")
to_activity(self, "mission", True)
to_activity(self, "mission", True, True)


def explore_challenge(self):
Expand Down Expand Up @@ -186,7 +227,7 @@ def explore_challenge(self):
to_activity(self, "challenge", True)


def to_activity(self, region, skip_first_screenshot=False):
def to_activity(self, region, skip_first_screenshot=False, need_swipe=False):
img_possibles = {
"activity_enter1": (1196, 195),
"activity_enter2": (100, 149),
Expand Down Expand Up @@ -232,6 +273,11 @@ def to_activity(self, region, skip_first_screenshot=False):
time.sleep(self.screenshot_interval)
self.latest_img_array = self.get_screenshot_array()
else:
if region == "mission" and need_swipe:
self.swipe(919, 136, 943, 720, duration=0.05)
time.sleep(0.5)
self.swipe(919, 136, 943, 720, duration=0.05)
time.sleep(0.5)
return True


Expand Down
6 changes: 4 additions & 2 deletions module/activities/sakura_flowing_chaos_in_the_gala.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@


def implement(self):
self.quick_method_to_main_page()
region = self.config["activity_sweep_task_number"]
times = self.config["activity_sweep_times"]
if times > 0:
return sweep(self, self.config["activity_sweep_task_number"], times)
return sweep(self, region, times)
else:
return True

Expand All @@ -21,12 +23,12 @@ def get_stage_data():


def sweep(self, number, times):
self.quick_method_to_main_page()
to_activity(self, "mission", True)
self.swipe(919, 136, 943, 720, duration=0.05)
time.sleep(0.5)
ap = self.get_ap()
sweep_one_time_ap = [0, 10, 10, 15, 15, 15, 15]

sweep_times = times
click_times = sweep_times
duration = 1
Expand Down
26 changes: 26 additions & 0 deletions src/descriptions/活动扫荡填写说明.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>活动图扫荡填写说明:</p>
<p><span style="background-color: #f1c40f;"><strong>扫荡一关</strong></span></p>
<p>活动关卡扫荡关卡填写:1 - 最高难度 间一个 <strong>整数</strong></p>
<p>扫荡次数:</p>
<p>1. <strong>整数</strong> 表示扫荡次数</p>
<p>2. <strong>小数</strong> 0.5 表示使用当前 体力*0.5 的 体力扫荡该关卡</p>
<p>3. <strong>分数</strong> 1/3 表示使用当前体力的1/3扫荡该关卡</p>
<p><span style="background-color: #f1c40f;"><strong>扫荡多关</strong></span></p>
<p>将多个扫荡一关的关卡和次数用 ',' 隔开,表示依次扫荡这些关卡</p>
<p>例:</p>
<p>扫荡关卡:</p>
<p>9,10,11</p>
<p>扫荡次数:</p>
<p>0.5,3,1/3</p>
<p>体力: 999</p>
<p>表示依次扫荡</p>
<p>第9关 (999 * 0.5) / 20 = 25次</p>
<p>第10关 3 次</p>
<p>第11关 (999 * 1/3)/ 20 = 16次</p>
</body>
</html>

0 comments on commit 8ddd549

Please sign in to comment.