Skip to content

Commit

Permalink
update cafe
Browse files Browse the repository at this point in the history
  • Loading branch information
pur1fying committed Feb 18, 2024
1 parent 1bef95a commit 9de58c0
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 24 deletions.
4 changes: 1 addition & 3 deletions core/Baas_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def thread_starter(self):
try:
self.logger.info("-------------- Start Scheduler ----------------")
while self.flag_run:
print(1)
if self.first_start:
self.solve('restart')
next_func_name = self.scheduler.heartbeat()
Expand Down Expand Up @@ -311,17 +312,14 @@ def init_rgb(self):

def init_config(self):
try:
self.logger.info("Start Reading Config")
self.config = self.operate_dict(self.config_set.config)
self.logger.info("SUCCESS")
return True
except Exception as e:
self.logger.error("Config initialization failed")
self.logger.error(e)
return False

def init_server(self):
self.logger.info("Start Detecting Server")
server = self.config['server']
if server == '官服' or server == 'B服':
self.server = 'CN'
Expand Down
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def operate_item(self, item):
tt.init_all_data()
tt.ocr = t.ocr
# tt.thread_starter()
tt.solve("common_shop")
tt.solve("total_assault")
# tt.solve("common_shop")
# tt.solve("total_assault")
tt.solve("cafe_reward")
tt.solve("momo_talk")
tt.solve("explore_normal_task")
Expand Down
50 changes: 33 additions & 17 deletions module/cafe_reward.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def interaction_for_cafe_solve_method3(self):
continue
self.logger.info("totally find " + str(len(res)) + " interactions")
for j in range(0, len(res)):
self.click(res[j][0], min(res[j][1], 591), wait_over=True)
self.click(res[j][0], min(res[j][1], 591), wait_over=True)

if i != max_times - 1:
time.sleep(2)
Expand All @@ -141,7 +141,6 @@ def to_invitation_ticket(self, skip_first_screenshot=False):
return picture.co_detect(self, None, None, img_end, img_possible, skip_first_screenshot)



def get_student_name(self):
current_server_student_name_list = []
target = self.server + "_name"
Expand All @@ -163,15 +162,37 @@ def invite_lowest_affection(self):
if not image.compare_image(self, 'cafe_invitation-ticket-order-affection', threshold=0.9):
self.logger.info("Switch to affection order")
self.click(704, 152, wait_over=True, duration=0.5)
self.click(relationship_order_button_location[self.server][0], relationship_order_button_location[self.server][1], wait_over=True, duration=0.5)
self.click(relationship_order_button_location[self.server][0],
relationship_order_button_location[self.server][1], wait_over=True, duration=0.5)
self.click(627, 390, wait_over=True, duration=0.5)
self.latest_img_array = self.get_screenshot_array()
if not image.compare_image(self, 'cafe_invitation-ticket-order-up', threshold=0.9):
self.logger.info("Switch to lowest affection order")
self.click(812, 153, wait_over=True, duration=0.5)
self.click(785, 226, wait_over=True, duration=0.5)
self.click(767, 514, wait_over=True)
to_cafe(self, True)
to_confirm_invite(self, (785, 226))
confirm_invite(self)


def to_confirm_invite(self, lo):
img_possibles = {
'cafe_invitation-ticket': lo,
}
img_ends = [
"cafe_confirm-invite",
"cafe_switch-clothes-notice",
]
picture.co_detect(self, None, None, img_ends, img_possibles, True)


def confirm_invite(self):
img_possibles = {
"cafe_confirm-invite": (767, 514),
"cafe_duplicate-invite": (767, 514),
'cafe_invitation-ticket': (835, 97),
'cafe_switch-clothes-notice': (764, 501),
}
img_ends = "cafe_menu"
picture.co_detect(self, None, None, img_ends, img_possibles, True)


def invite_girl(self, no=1):
Expand All @@ -185,15 +206,14 @@ def invite_girl(self, no=1):
target_name_list = self.config['favorStudent2']
student_name.sort(key=len, reverse=True)
self.logger.info("INVITING : " + str(target_name_list))
f = True
for i in range(0, len(target_name_list)):
to_invitation_ticket(self, skip_first_screenshot=True)
target_name = target_name_list[i]
self.logger.info("Begin Find Student " + target_name)
target_name = operate_name(target_name, self.server)
stop_flag = False
last_student_name = None
while not stop_flag:
while not stop_flag and self.flag_run:
region = {
'CN': (489, 185, 709, 604),
'Global': (489, 185, 709, 604),
Expand All @@ -212,7 +232,7 @@ def invite_girl(self, no=1):
detected_name.append("千世")
else:
detected_name.append(student_name[j])
location.append((out[k]['position'][0][1]/self.ratio) + 210)
location.append((out[k]['position'][0][1] / self.ratio) + 210)
if len(detected_name) == 5:
break

Expand All @@ -233,19 +253,15 @@ def invite_girl(self, no=1):
for s in range(0, len(detected_name)):
if detected_name[s] == target_name:
self.logger.info("find student " + target_name + " at " + str(location[s]))
stop_flag = True
f = False
self.click(784, location[s], duration=0.7, wait_over=True)
self.click(770, 500, wait_over=True)
break
to_confirm_invite(self, (785, location[s]))
confirm_invite(self)
return True
if not stop_flag:
self.logger.info("didn't find target student swipe to next page")
self.swipe(412, 580, 412, 150, duration=0.3)
self.click(412, 500, wait_over=True)
self.click(412, 500, wait_over=True)
self.latest_img_array = self.get_screenshot_array()
to_cafe(self)
if not f:
break


def collect(self):
Expand Down
3 changes: 2 additions & 1 deletion module/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def implement(self):
break
need_acc_collect = True
self.config['alreadyCreateTime'] += 1
# self.config_set.set("alreadyCreateTime", self.config['alreadyCreateTime'])
self.config_set.set("alreadyCreateTime", self.config['alreadyCreateTime'])
self.logger.info("today total create times: " + str(self.config['alreadyCreateTime']))
if self.config['alreadyCreateTime'] >= self.config['createTime']:
create_flag = False
Expand All @@ -54,6 +54,7 @@ def implement(self):

def common_create_judge(self):
pri = self.config['createPriority']
self.logger.info("create priority: " + str(pri))
for i in range(0, len(pri)):
pri[i] = preprocess_node_info(pri[i], self.server)
node_x = [839, 508, 416, 302, 174]
Expand Down
2 changes: 2 additions & 0 deletions module/explore_hard_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ def start_action(self, actions):
self.set_screenshot_interval(1)
self.logger.info("Start Actions total : " + str(len(actions)))
for i, act in enumerate(actions):
if not self.flag_run:
return
desc = "start " + str(i + 1) + " operation : "
if 'desc' in act:
desc += act['desc']
Expand Down
2 changes: 2 additions & 0 deletions module/explore_normal_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ def start_action(self, actions, will_fight=False):
self.set_screenshot_interval(1)
self.logger.info("Start Actions total : " + str(len(actions)))
for i, act in enumerate(actions):
if not self.flag_run:
return
desc = "start " + str(i + 1) + " operation : "
if 'desc' in act:
desc += act['desc']
Expand Down
Binary file added src/images/CN/cafe/confirm-invite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/CN/cafe/switch-clothes-notice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/images/CN/x_y_range/cafe.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
'invitation-ticket-invalid': (397, 299, 880, 365),
'invitation-ticket-order-affection': (662, 138, 748, 165),
'invitation-ticket-order-up': (827, 138, 841, 164),
'confirm-invite': (543, 139, 735, 177),
'switch-clothes-notice': (572, 150, 710, 189)
}
Binary file added src/images/Global/cafe/confirm-invite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/Global/cafe/switch-clothes-notice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/images/Global/x_y_range/cafe.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
'invitation-ticket-invalid': (397, 299, 880, 365),
'invitation-ticket-order-affection': (642, 138, 768, 165),
'invitation-ticket-order-up': (827, 138, 841, 164),
'confirm-invite': (400, 230, 888, 400),
'switch-clothes-notice': (500, 150, 780, 189)
}
Binary file added src/images/JP/cafe/confirm-invite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/JP/cafe/duplicate-invite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion src/images/JP/x_y_range/cafe.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
'menu': (107, 9, 340, 36),
'0.0': (1114, 642, 1160, 668),
'students-arrived': (550, 240, 726, 269),
'cafe-reward-status': (518,132, 760,165),
'cafe-reward-status': (518, 132, 760, 165),
'invitation-ticket': (421, 78, 451, 111),
'quick-home': (1215, 5, 1255, 42),
'invitation-ticket-order-affection': (662, 138, 748, 165),
'invitation-ticket-order-up': (827, 138, 841, 164),
'confirm-invite': (400, 230, 888, 400),
'duplicate-invite': (400, 220, 888, 270),
}

0 comments on commit 9de58c0

Please sign in to comment.