Compare commits
No commits in common. "7c33bd42c64de3ea6a98d0c754995549bd21ce52" and "7fcda153297edb241c6aca55865909241ddaa235" have entirely different histories.
7c33bd42c6
...
7fcda15329
|
Before Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 23 KiB |
@ -45,12 +45,6 @@
|
|||||||
"Touch": true,
|
"Touch": true,
|
||||||
"AutoAdjust": true,
|
"AutoAdjust": true,
|
||||||
"SecondCafe": true
|
"SecondCafe": true
|
||||||
},
|
|
||||||
"Invitation": {
|
|
||||||
"Enable": true,
|
|
||||||
"Choice": "list_top",
|
|
||||||
"Name": null,
|
|
||||||
"Substitute": true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Circle": {
|
"Circle": {
|
||||||
|
|||||||
@ -205,28 +205,6 @@
|
|||||||
"type": "checkbox",
|
"type": "checkbox",
|
||||||
"value": true
|
"value": true
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"Invitation": {
|
|
||||||
"Enable": {
|
|
||||||
"type": "checkbox",
|
|
||||||
"value": true
|
|
||||||
},
|
|
||||||
"Choice": {
|
|
||||||
"type": "select",
|
|
||||||
"value": "list_top",
|
|
||||||
"option": [
|
|
||||||
"list_top",
|
|
||||||
"by_name"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"Name": {
|
|
||||||
"type": "textarea",
|
|
||||||
"value": null
|
|
||||||
},
|
|
||||||
"Substitute": {
|
|
||||||
"type": "checkbox",
|
|
||||||
"value": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Circle": {
|
"Circle": {
|
||||||
|
|||||||
@ -80,15 +80,6 @@ Cafe:
|
|||||||
Touch: true
|
Touch: true
|
||||||
AutoAdjust: true
|
AutoAdjust: true
|
||||||
SecondCafe: true
|
SecondCafe: true
|
||||||
Invitation:
|
|
||||||
Enable: true
|
|
||||||
Choice:
|
|
||||||
value: list_top
|
|
||||||
option: [ list_top, by_name ]
|
|
||||||
Name:
|
|
||||||
value: null
|
|
||||||
type: textarea
|
|
||||||
Substitute: true
|
|
||||||
|
|
||||||
Bounty:
|
Bounty:
|
||||||
OnError:
|
OnError:
|
||||||
|
|||||||
@ -25,7 +25,6 @@ Daily:
|
|||||||
Cafe:
|
Cafe:
|
||||||
- Scheduler
|
- Scheduler
|
||||||
- Cafe
|
- Cafe
|
||||||
- Invitation
|
|
||||||
Circle:
|
Circle:
|
||||||
- Scheduler
|
- Scheduler
|
||||||
Mail:
|
Mail:
|
||||||
|
|||||||
@ -45,12 +45,6 @@ class GeneratedConfig:
|
|||||||
Cafe_AutoAdjust = True
|
Cafe_AutoAdjust = True
|
||||||
Cafe_SecondCafe = True
|
Cafe_SecondCafe = True
|
||||||
|
|
||||||
# Group `Invitation`
|
|
||||||
Invitation_Enable = True
|
|
||||||
Invitation_Choice = 'list_top' # list_top, by_name
|
|
||||||
Invitation_Name = None
|
|
||||||
Invitation_Substitute = True
|
|
||||||
|
|
||||||
# Group `Bounty`
|
# Group `Bounty`
|
||||||
Bounty_OnError = 'skip' # stop, skip
|
Bounty_OnError = 'skip' # stop, skip
|
||||||
|
|
||||||
|
|||||||
@ -221,30 +221,6 @@
|
|||||||
"help": "JP server only\nEnable auto switch to second floor and perform interaction"
|
"help": "JP server only\nEnable auto switch to second floor and perform interaction"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Invitation": {
|
|
||||||
"_info": {
|
|
||||||
"name": "Invitation Settings",
|
|
||||||
"help": ""
|
|
||||||
},
|
|
||||||
"Enable": {
|
|
||||||
"name": "Enable",
|
|
||||||
"help": ""
|
|
||||||
},
|
|
||||||
"Choice": {
|
|
||||||
"name": "Choose Inviting Student",
|
|
||||||
"help": "",
|
|
||||||
"list_top": "Top first student of list",
|
|
||||||
"by_name": "By name"
|
|
||||||
},
|
|
||||||
"Name": {
|
|
||||||
"name": "Invited Student Name",
|
|
||||||
"help": "Fill in the name of the student to be invited. Use in-game text language. Use > to connect multiple students. Example:\nJP: ホシノ(水着) > 御坂美琴 > ユズ\nOVERSEA: Hoshino(Swimsuit) > Yuuka > Kayoko(New Year)"
|
|
||||||
},
|
|
||||||
"Substitute": {
|
|
||||||
"name": "Replace existing student",
|
|
||||||
"help": "!TO BE CHANGED!Whether to replace the existing student with another costume.\nIf not, try to match the next student"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Bounty": {
|
"Bounty": {
|
||||||
"_info": {
|
"_info": {
|
||||||
"name": "Bounty Settings",
|
"name": "Bounty Settings",
|
||||||
|
|||||||
@ -221,30 +221,6 @@
|
|||||||
"help": "仅支持日服\n自动切换第二咖啡厅进行互动点击"
|
"help": "仅支持日服\n自动切换第二咖啡厅进行互动点击"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Invitation": {
|
|
||||||
"_info": {
|
|
||||||
"name": "邀请设置",
|
|
||||||
"help": ""
|
|
||||||
},
|
|
||||||
"Enable": {
|
|
||||||
"name": "启用",
|
|
||||||
"help": ""
|
|
||||||
},
|
|
||||||
"Choice": {
|
|
||||||
"name": "选择被邀请学生",
|
|
||||||
"help": "",
|
|
||||||
"list_top": "按列表第一个",
|
|
||||||
"by_name": "按名字"
|
|
||||||
},
|
|
||||||
"Name": {
|
|
||||||
"name": "邀请学生名",
|
|
||||||
"help": "填写要邀请的学生的名字,使用游戏内语言填写,多个学生使用 > 连接。例:\n日服:ホシノ(水着) > 御坂美琴 > ユズ\n国际服:Hoshino(Swimsuit) > Yuuka > Kayoko(New Year)"
|
|
||||||
},
|
|
||||||
"Substitute": {
|
|
||||||
"name": "是否替换已存在学生",
|
|
||||||
"help": "若咖啡厅已存在所邀请学生的不同服装,选择是否替换该学生\n若不替换,则尝试匹配下一位学生"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Bounty": {
|
"Bounty": {
|
||||||
"_info": {
|
"_info": {
|
||||||
"name": "悬赏通缉设置",
|
"name": "悬赏通缉设置",
|
||||||
|
|||||||
@ -40,28 +40,6 @@ CAFE_FIRST = ButtonWrapper(
|
|||||||
button=(82, 152, 136, 175),
|
button=(82, 152, 136, 175),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
CAFE_INVITE = ButtonWrapper(
|
|
||||||
name='CAFE_INVITE',
|
|
||||||
jp=Button(
|
|
||||||
file='./assets/jp/cafe/CAFE_INVITE.png',
|
|
||||||
area=(816, 635, 845, 655),
|
|
||||||
search=(796, 615, 865, 675),
|
|
||||||
color=(173, 182, 192),
|
|
||||||
button=(816, 635, 845, 655),
|
|
||||||
),
|
|
||||||
en=None,
|
|
||||||
)
|
|
||||||
CAFE_INVITED = ButtonWrapper(
|
|
||||||
name='CAFE_INVITED',
|
|
||||||
jp=Button(
|
|
||||||
file='./assets/jp/cafe/CAFE_INVITED.png',
|
|
||||||
area=(815, 633, 847, 657),
|
|
||||||
search=(795, 613, 867, 677),
|
|
||||||
color=(144, 144, 146),
|
|
||||||
button=(815, 633, 847, 657),
|
|
||||||
),
|
|
||||||
en=None,
|
|
||||||
)
|
|
||||||
CAFE_SECOND = ButtonWrapper(
|
CAFE_SECOND = ButtonWrapper(
|
||||||
name='CAFE_SECOND',
|
name='CAFE_SECOND',
|
||||||
jp=Button(
|
jp=Button(
|
||||||
@ -113,17 +91,6 @@ CHANGE_CAFE_SELECTED = ButtonWrapper(
|
|||||||
button=(40, 87, 191, 112),
|
button=(40, 87, 191, 112),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
CHECK_MOMOTALK = ButtonWrapper(
|
|
||||||
name='CHECK_MOMOTALK',
|
|
||||||
jp=Button(
|
|
||||||
file='./assets/jp/cafe/CHECK_MOMOTALK.png',
|
|
||||||
area=(421, 83, 447, 108),
|
|
||||||
search=(401, 63, 467, 128),
|
|
||||||
color=(253, 203, 212),
|
|
||||||
button=(421, 83, 447, 108),
|
|
||||||
),
|
|
||||||
en=None,
|
|
||||||
)
|
|
||||||
CHECK_REWARD = ButtonWrapper(
|
CHECK_REWARD = ButtonWrapper(
|
||||||
name='CHECK_REWARD',
|
name='CHECK_REWARD',
|
||||||
jp=Button(
|
jp=Button(
|
||||||
@ -219,61 +186,6 @@ INVENTORY = ButtonWrapper(
|
|||||||
button=(1123, 90, 1165, 130),
|
button=(1123, 90, 1165, 130),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
INVITE_CONFIRM = ButtonWrapper(
|
|
||||||
name='INVITE_CONFIRM',
|
|
||||||
jp=Button(
|
|
||||||
file='./assets/jp/cafe/INVITE_CONFIRM.png',
|
|
||||||
area=(609, 147, 671, 178),
|
|
||||||
search=(589, 127, 691, 198),
|
|
||||||
color=(152, 164, 177),
|
|
||||||
button=(665, 471, 870, 533),
|
|
||||||
),
|
|
||||||
en=None,
|
|
||||||
)
|
|
||||||
INVITE_IN_SECOND = ButtonWrapper(
|
|
||||||
name='INVITE_IN_SECOND',
|
|
||||||
jp=Button(
|
|
||||||
file='./assets/jp/cafe/INVITE_IN_SECOND.png',
|
|
||||||
area=(482, 147, 799, 177),
|
|
||||||
search=(462, 127, 819, 197),
|
|
||||||
color=(166, 177, 188),
|
|
||||||
button=(482, 147, 799, 177),
|
|
||||||
),
|
|
||||||
en=None,
|
|
||||||
)
|
|
||||||
INVITE_IN_SECOND_CLOSE = ButtonWrapper(
|
|
||||||
name='INVITE_IN_SECOND_CLOSE',
|
|
||||||
jp=Button(
|
|
||||||
file='./assets/jp/cafe/INVITE_IN_SECOND_CLOSE.png',
|
|
||||||
area=(874, 150, 900, 176),
|
|
||||||
search=(854, 130, 920, 196),
|
|
||||||
color=(180, 189, 198),
|
|
||||||
button=(874, 150, 900, 176),
|
|
||||||
),
|
|
||||||
en=None,
|
|
||||||
)
|
|
||||||
INVITE_SUBSTITUTE = ButtonWrapper(
|
|
||||||
name='INVITE_SUBSTITUTE',
|
|
||||||
jp=Button(
|
|
||||||
file='./assets/jp/cafe/INVITE_SUBSTITUTE.png',
|
|
||||||
area=(582, 154, 698, 184),
|
|
||||||
search=(562, 134, 718, 204),
|
|
||||||
color=(154, 166, 179),
|
|
||||||
button=(673, 478, 858, 541),
|
|
||||||
),
|
|
||||||
en=None,
|
|
||||||
)
|
|
||||||
INVITE_SUBSTITUTE_CLOSE = ButtonWrapper(
|
|
||||||
name='INVITE_SUBSTITUTE_CLOSE',
|
|
||||||
jp=Button(
|
|
||||||
file='./assets/jp/cafe/INVITE_SUBSTITUTE_CLOSE.png',
|
|
||||||
area=(867, 158, 893, 184),
|
|
||||||
search=(847, 138, 913, 204),
|
|
||||||
color=(180, 189, 199),
|
|
||||||
button=(867, 158, 893, 184),
|
|
||||||
),
|
|
||||||
en=None,
|
|
||||||
)
|
|
||||||
MOMOTALK_CLOSE = ButtonWrapper(
|
MOMOTALK_CLOSE = ButtonWrapper(
|
||||||
name='MOMOTALK_CLOSE',
|
name='MOMOTALK_CLOSE',
|
||||||
jp=Button(
|
jp=Button(
|
||||||
@ -291,28 +203,6 @@ MOMOTALK_CLOSE = ButtonWrapper(
|
|||||||
button=(824, 82, 850, 108),
|
button=(824, 82, 850, 108),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
MOMOTALK_INVITE = ButtonWrapper(
|
|
||||||
name='MOMOTALK_INVITE',
|
|
||||||
jp=Button(
|
|
||||||
file='./assets/jp/cafe/MOMOTALK_INVITE.png',
|
|
||||||
area=(764, 211, 809, 234),
|
|
||||||
search=(744, 191, 829, 254),
|
|
||||||
color=(90, 163, 195),
|
|
||||||
button=(764, 211, 809, 234),
|
|
||||||
),
|
|
||||||
en=None,
|
|
||||||
)
|
|
||||||
MOMOTALK_ITEM = ButtonWrapper(
|
|
||||||
name='MOMOTALK_ITEM',
|
|
||||||
jp=Button(
|
|
||||||
file='./assets/jp/cafe/MOMOTALK_ITEM.png',
|
|
||||||
area=(489, 193, 864, 259),
|
|
||||||
search=(469, 173, 884, 279),
|
|
||||||
color=(203, 230, 240),
|
|
||||||
button=(489, 193, 864, 259),
|
|
||||||
),
|
|
||||||
en=None,
|
|
||||||
)
|
|
||||||
OCR_CAFE = ButtonWrapper(
|
OCR_CAFE = ButtonWrapper(
|
||||||
name='OCR_CAFE',
|
name='OCR_CAFE',
|
||||||
jp=Button(
|
jp=Button(
|
||||||
@ -330,17 +220,6 @@ OCR_CAFE = ButtonWrapper(
|
|||||||
button=(1105, 639, 1195, 674),
|
button=(1105, 639, 1195, 674),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
OCR_NAME = ButtonWrapper(
|
|
||||||
name='OCR_NAME',
|
|
||||||
jp=Button(
|
|
||||||
file='./assets/jp/cafe/OCR_NAME.png',
|
|
||||||
area=(488, 194, 704, 588),
|
|
||||||
search=(468, 174, 724, 608),
|
|
||||||
color=(237, 239, 241),
|
|
||||||
button=(488, 194, 704, 588),
|
|
||||||
),
|
|
||||||
en=None,
|
|
||||||
)
|
|
||||||
STUDENT_LIST = ButtonWrapper(
|
STUDENT_LIST = ButtonWrapper(
|
||||||
name='STUDENT_LIST',
|
name='STUDENT_LIST',
|
||||||
jp=Button(
|
jp=Button(
|
||||||
|
|||||||
@ -6,7 +6,6 @@ from module.logger import logger
|
|||||||
from module.ui.switch import Switch
|
from module.ui.switch import Switch
|
||||||
from tasks.base.page import page_cafe
|
from tasks.base.page import page_cafe
|
||||||
from tasks.cafe.assets.assets_cafe import *
|
from tasks.cafe.assets.assets_cafe import *
|
||||||
from tasks.cafe.invitation import handle_invitation
|
|
||||||
from tasks.cafe.ui import CafeUI
|
from tasks.cafe.ui import CafeUI
|
||||||
|
|
||||||
SWITCH_CAFE = Switch('Cafe_switch')
|
SWITCH_CAFE = Switch('Cafe_switch')
|
||||||
@ -23,9 +22,8 @@ class CafeStatus(Enum):
|
|||||||
OCR = 1
|
OCR = 1
|
||||||
REWARD = 2
|
REWARD = 2
|
||||||
GOT = 3
|
GOT = 3
|
||||||
INVITATION = 4
|
CLICK = 4
|
||||||
CLICK = 5
|
CHECK = 5
|
||||||
CHECK = 6
|
|
||||||
FINISHED = -1
|
FINISHED = -1
|
||||||
|
|
||||||
|
|
||||||
@ -65,9 +63,6 @@ class Cafe(CafeUI):
|
|||||||
logger.info('Cafe reward have been got')
|
logger.info('Cafe reward have been got')
|
||||||
self.appear_then_click(GET_REWARD_CLOSE)
|
self.appear_then_click(GET_REWARD_CLOSE)
|
||||||
if not self.appear(GET_REWARD_CLOSE):
|
if not self.appear(GET_REWARD_CLOSE):
|
||||||
return CafeStatus.INVITATION
|
|
||||||
case CafeStatus.INVITATION:
|
|
||||||
if handle_invitation(self):
|
|
||||||
return CafeStatus.CLICK
|
return CafeStatus.CLICK
|
||||||
case CafeStatus.CLICK:
|
case CafeStatus.CLICK:
|
||||||
buttons = self.get_clickable_buttons(offset=(45, 10))
|
buttons = self.get_clickable_buttons(offset=(45, 10))
|
||||||
|
|||||||
@ -1,298 +0,0 @@
|
|||||||
import re
|
|
||||||
from enum import Enum
|
|
||||||
|
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
from module.base.base import ModuleBase
|
|
||||||
from module.base.timer import Timer
|
|
||||||
from module.base.utils import area_size, area_offset
|
|
||||||
from module.logger import logger
|
|
||||||
from module.ocr.ocr import Ocr
|
|
||||||
from tasks.cafe.assets.assets_cafe import *
|
|
||||||
|
|
||||||
|
|
||||||
class InvitationOcr(Ocr):
|
|
||||||
def after_process(self, result):
|
|
||||||
result = super().after_process(result)
|
|
||||||
result = result.replace('モI', 'モエ')
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
class InvitationStatus(Enum):
|
|
||||||
MOMOTALK = 0
|
|
||||||
OCR = 1
|
|
||||||
SELECT = 2
|
|
||||||
CONFIRM = 3
|
|
||||||
SUBSTITUTE = 4
|
|
||||||
IN_SECOND = 5
|
|
||||||
INVITED = 6
|
|
||||||
FAILED = 7
|
|
||||||
FINISHED = -1
|
|
||||||
|
|
||||||
|
|
||||||
class Invitation:
|
|
||||||
swipe_vector_range = (0.65, 0.85)
|
|
||||||
|
|
||||||
def __init__(self, name: str):
|
|
||||||
self.name = name
|
|
||||||
self.ocr = InvitationOcr(OCR_NAME)
|
|
||||||
self.list = OCR_NAME
|
|
||||||
self.item = MOMOTALK_ITEM
|
|
||||||
self.invite = MOMOTALK_INVITE
|
|
||||||
|
|
||||||
self.target_names = []
|
|
||||||
self.substitute = None
|
|
||||||
self.choice = None
|
|
||||||
|
|
||||||
self.invited = []
|
|
||||||
self.current_names = []
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return f'Invitation({self.name})'
|
|
||||||
|
|
||||||
__repr__ = __str__
|
|
||||||
|
|
||||||
def __eq__(self, other):
|
|
||||||
return str(self) == str(other)
|
|
||||||
|
|
||||||
def __hash__(self):
|
|
||||||
return hash(self.name)
|
|
||||||
|
|
||||||
def swipe_page(self, main: ModuleBase, vector_range=None, reverse=False):
|
|
||||||
"""
|
|
||||||
Args:
|
|
||||||
main:
|
|
||||||
vector_range (tuple[float, float]):
|
|
||||||
reverse (bool):
|
|
||||||
"""
|
|
||||||
if vector_range is None:
|
|
||||||
vector_range = self.swipe_vector_range
|
|
||||||
vector = np.random.uniform(*vector_range)
|
|
||||||
width, height = area_size(self.list.button)
|
|
||||||
vector = (0, -vector * height)
|
|
||||||
|
|
||||||
if reverse:
|
|
||||||
vector = (-vector[0], -vector[1])
|
|
||||||
name = f'{self.name}_SWIPE'
|
|
||||||
main.device.swipe_vector(vector, self.list.button, name=name)
|
|
||||||
main.device.click_record_remove(name)
|
|
||||||
|
|
||||||
def load_names(self, main: ModuleBase):
|
|
||||||
names = self.ocr.detect_and_ocr(main.device.image)
|
|
||||||
if not names:
|
|
||||||
logger.warning(f'No valid names in {self.ocr.name}')
|
|
||||||
return
|
|
||||||
self.current_names = []
|
|
||||||
for name_ in names:
|
|
||||||
name: str = name_.ocr_text.replace(' ', '')
|
|
||||||
if name.isdigit():
|
|
||||||
continue
|
|
||||||
if name.startswith('('):
|
|
||||||
if not self.current_names:
|
|
||||||
continue
|
|
||||||
n = self.current_names.pop(len(self.current_names) - 1)
|
|
||||||
self.current_names.append((n[0] + name, n[1]))
|
|
||||||
continue
|
|
||||||
self.current_names.append((name, name_.box))
|
|
||||||
|
|
||||||
@property
|
|
||||||
def names(self):
|
|
||||||
return list(map(lambda x: x[0], self.current_names))
|
|
||||||
|
|
||||||
@property
|
|
||||||
def target_name(self):
|
|
||||||
return self.target_names[0] if self.target_names else None
|
|
||||||
|
|
||||||
def on_success(self):
|
|
||||||
logger.info(f'Invited {self.target_name}')
|
|
||||||
self.invited.append(self.target_name)
|
|
||||||
self.target_names.pop(0)
|
|
||||||
|
|
||||||
def on_failed(self):
|
|
||||||
logger.warning(f'Failed to invite {self.target_name}')
|
|
||||||
self.target_names.pop(0)
|
|
||||||
|
|
||||||
def insight_name(self, name: str, main: ModuleBase, skip_first_screenshot=True) -> bool:
|
|
||||||
"""
|
|
||||||
Args:
|
|
||||||
name:
|
|
||||||
main:
|
|
||||||
skip_first_screenshot:
|
|
||||||
"""
|
|
||||||
logger.info(f'Insight name: {name}')
|
|
||||||
last_names: set[str] = set()
|
|
||||||
|
|
||||||
while 1:
|
|
||||||
if skip_first_screenshot:
|
|
||||||
skip_first_screenshot = False
|
|
||||||
else:
|
|
||||||
main.device.screenshot()
|
|
||||||
|
|
||||||
self.load_names(main)
|
|
||||||
|
|
||||||
if name in self.names:
|
|
||||||
return True
|
|
||||||
|
|
||||||
names = self.names
|
|
||||||
if names and last_names == set(names):
|
|
||||||
logger.warning(f'Name not found: {name}')
|
|
||||||
return False
|
|
||||||
last_names = set(names)
|
|
||||||
|
|
||||||
self.swipe_page(main)
|
|
||||||
|
|
||||||
main.wait_until_stable(
|
|
||||||
self.list.button,
|
|
||||||
timer=Timer(0, 0),
|
|
||||||
timeout=Timer(1.5, 5)
|
|
||||||
)
|
|
||||||
|
|
||||||
def select_name_invite(
|
|
||||||
self,
|
|
||||||
main: ModuleBase,
|
|
||||||
name: str = None,
|
|
||||||
insight: bool = True,
|
|
||||||
skip_first_screenshot: bool = True
|
|
||||||
) -> bool:
|
|
||||||
"""
|
|
||||||
Args:
|
|
||||||
main:
|
|
||||||
name:
|
|
||||||
insight:
|
|
||||||
skip_first_screenshot:
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
If success
|
|
||||||
"""
|
|
||||||
if name is None:
|
|
||||||
if not self.target_name:
|
|
||||||
return False
|
|
||||||
name = self.target_name
|
|
||||||
if insight and not self.insight_name(name, main, skip_first_screenshot):
|
|
||||||
return False
|
|
||||||
|
|
||||||
logger.info(f'Select name: {name}')
|
|
||||||
click_interval = Timer(1, 2)
|
|
||||||
load_names_interval = Timer(1, 5)
|
|
||||||
timeout = Timer(10, 10).start()
|
|
||||||
while 1:
|
|
||||||
if skip_first_screenshot:
|
|
||||||
skip_first_screenshot = False
|
|
||||||
else:
|
|
||||||
main.device.screenshot()
|
|
||||||
|
|
||||||
if load_names_interval.reached_and_reset() and not insight:
|
|
||||||
self.load_names(main)
|
|
||||||
|
|
||||||
name_box = next(filter(lambda x: x[0] == name, self.current_names), None)
|
|
||||||
if name_box is None:
|
|
||||||
logger.warning(f'No name {name} in {self.ocr.name}')
|
|
||||||
continue
|
|
||||||
|
|
||||||
search_box = area_offset((0, 0, *area_size(self.item.area)), name_box[1][:2])
|
|
||||||
self.invite.load_search(search_box)
|
|
||||||
click_button = self.invite.match_multi_template(main.device.image)
|
|
||||||
|
|
||||||
if not click_button:
|
|
||||||
logger.warning(f'No clickable {self.invite.name}')
|
|
||||||
continue
|
|
||||||
|
|
||||||
if click_interval.reached_and_reset():
|
|
||||||
main.device.click(click_button[0])
|
|
||||||
return True
|
|
||||||
|
|
||||||
if timeout.reached():
|
|
||||||
logger.warning(f'No clickable {self.invite.name}')
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
invitation = Invitation('test')
|
|
||||||
|
|
||||||
|
|
||||||
def handle_invitation_status(status: InvitationStatus, main: ModuleBase) -> InvitationStatus:
|
|
||||||
match status:
|
|
||||||
case InvitationStatus.MOMOTALK:
|
|
||||||
if main.appear(CAFE_INVITED):
|
|
||||||
logger.info('Invitation in cooldown')
|
|
||||||
return InvitationStatus.FINISHED
|
|
||||||
if invitation.target_name is None:
|
|
||||||
logger.warning('No student to be invited or all invitations failed')
|
|
||||||
return InvitationStatus.FINISHED
|
|
||||||
if main.appear(CHECK_MOMOTALK):
|
|
||||||
return InvitationStatus.OCR
|
|
||||||
main.appear_then_click(CAFE_INVITE)
|
|
||||||
case InvitationStatus.OCR:
|
|
||||||
if invitation.choice == 'list_top':
|
|
||||||
invitation.load_names(main)
|
|
||||||
invitation.target_names = invitation.names
|
|
||||||
invitation.choice = 'list'
|
|
||||||
if invitation.select_name_invite(main):
|
|
||||||
return InvitationStatus.SELECT
|
|
||||||
return InvitationStatus.FAILED
|
|
||||||
case InvitationStatus.SELECT:
|
|
||||||
if main.appear(INVITE_CONFIRM):
|
|
||||||
return InvitationStatus.CONFIRM
|
|
||||||
if main.config.Emulator_GameLanguage == 'jp' and main.appear(INVITE_IN_SECOND):
|
|
||||||
return InvitationStatus.IN_SECOND
|
|
||||||
if main.appear(INVITE_SUBSTITUTE):
|
|
||||||
return InvitationStatus.SUBSTITUTE
|
|
||||||
case InvitationStatus.CONFIRM:
|
|
||||||
main.appear_then_click(INVITE_CONFIRM)
|
|
||||||
if not main.appear(INVITE_CONFIRM):
|
|
||||||
invitation.on_success()
|
|
||||||
return InvitationStatus.INVITED
|
|
||||||
case InvitationStatus.IN_SECOND:
|
|
||||||
main.appear_then_click(INVITE_IN_SECOND_CLOSE)
|
|
||||||
return InvitationStatus.FAILED
|
|
||||||
case InvitationStatus.SUBSTITUTE:
|
|
||||||
if not invitation.substitute:
|
|
||||||
main.appear_then_click(INVITE_SUBSTITUTE_CLOSE)
|
|
||||||
return InvitationStatus.FAILED
|
|
||||||
else:
|
|
||||||
main.appear_then_click(INVITE_SUBSTITUTE)
|
|
||||||
if not main.appear(INVITE_SUBSTITUTE):
|
|
||||||
return InvitationStatus.INVITED
|
|
||||||
case InvitationStatus.INVITED:
|
|
||||||
main.appear_then_click(MOMOTALK_CLOSE)
|
|
||||||
if not main.appear(MOMOTALK_CLOSE):
|
|
||||||
return InvitationStatus.FINISHED
|
|
||||||
case InvitationStatus.FAILED:
|
|
||||||
main.appear_then_click(MOMOTALK_CLOSE)
|
|
||||||
if not main.appear(CHECK_MOMOTALK):
|
|
||||||
invitation.on_failed()
|
|
||||||
return InvitationStatus.MOMOTALK
|
|
||||||
case InvitationStatus.FINISHED:
|
|
||||||
pass
|
|
||||||
case _:
|
|
||||||
logger.warning(f'Invalid status: {status}')
|
|
||||||
return status
|
|
||||||
|
|
||||||
|
|
||||||
def handle_invitation(main: ModuleBase):
|
|
||||||
if not main.config.Invitation_Enable:
|
|
||||||
logger.info('Invitation disabled')
|
|
||||||
return
|
|
||||||
invitation.choice = main.config.Invitation_Choice
|
|
||||||
invitation.substitute = main.config.Invitation_Substitute
|
|
||||||
if invitation.choice == 'by_name' and not invitation.target_names:
|
|
||||||
name = main.config.Invitation_Name
|
|
||||||
name = re.sub(r'[ \t\r\n]', '', name)
|
|
||||||
name = re.sub(r'[>﹥›˃ᐳ❯]', '>', name)
|
|
||||||
name = re.sub(r'(', '(', name)
|
|
||||||
name = re.sub(r')', ')', name)
|
|
||||||
invitation.target_names = name.split('>')
|
|
||||||
status = InvitationStatus.MOMOTALK
|
|
||||||
action_timer = Timer(1, 1)
|
|
||||||
loading_timer = Timer(1, 1)
|
|
||||||
while 1:
|
|
||||||
main.device.screenshot()
|
|
||||||
|
|
||||||
if not loading_timer.reached():
|
|
||||||
continue
|
|
||||||
|
|
||||||
if action_timer.reached_and_reset():
|
|
||||||
logger.attr('Status', status)
|
|
||||||
status = handle_invitation_status(status, main)
|
|
||||||
|
|
||||||
if status == InvitationStatus.FINISHED:
|
|
||||||
return True
|
|
||||||
@ -48,22 +48,21 @@ class CafeUI(UI):
|
|||||||
vector_left = (-width * r, 0)
|
vector_left = (-width * r, 0)
|
||||||
vector_right = (width * r, 0)
|
vector_right = (width * r, 0)
|
||||||
random_r = (-5, -5, 5, 5)
|
random_r = (-5, -5, 5, 5)
|
||||||
name = 'CAFE_SWIPE'
|
|
||||||
match direction:
|
match direction:
|
||||||
case 'init':
|
case 'init':
|
||||||
self.device.pinch()
|
self.device.pinch()
|
||||||
self.device.swipe_vector(vector_down, box=BOX_CAFE.area, random_range=random_r, padding=5, name=name)
|
self.device.swipe_vector(vector_down, box=BOX_CAFE.area, random_range=random_r, padding=5)
|
||||||
self.device.swipe_vector(vector_right, box=BOX_CAFE.area, random_range=random_r, padding=5, name=name)
|
self.device.swipe_vector(vector_right, box=BOX_CAFE.area, random_range=random_r, padding=5)
|
||||||
self.device.swipe_vector(vector_up, box=BOX_CAFE.area, random_range=random_r, padding=5, name=name)
|
self.device.swipe_vector(vector_up, box=BOX_CAFE.area, random_range=random_r, padding=5)
|
||||||
self.device.swipe_vector(vector_up, box=BOX_CAFE.area, random_range=random_r, padding=5, name=name)
|
self.device.swipe_vector(vector_up, box=BOX_CAFE.area, random_range=random_r, padding=5)
|
||||||
case 'left':
|
case 'left':
|
||||||
self.device.swipe_vector(vector_left, box=BOX_CAFE.area, random_range=random_r, padding=5, name=name)
|
self.device.swipe_vector(vector_left, box=BOX_CAFE.area, random_range=random_r, padding=5)
|
||||||
self.device.swipe_vector(vector_left, box=BOX_CAFE.area, random_range=random_r, padding=5, name=name)
|
self.device.swipe_vector(vector_left, box=BOX_CAFE.area, random_range=random_r, padding=5)
|
||||||
case 'right':
|
case 'right':
|
||||||
self.device.swipe_vector(vector_right, box=BOX_CAFE.area, random_range=random_r, padding=5, name=name)
|
self.device.swipe_vector(vector_right, box=BOX_CAFE.area, random_range=random_r, padding=5)
|
||||||
self.device.swipe_vector(vector_right, box=BOX_CAFE.area, random_range=random_r, padding=5, name=name)
|
self.device.swipe_vector(vector_right, box=BOX_CAFE.area, random_range=random_r, padding=5)
|
||||||
# solve too much swipe causing restart
|
# solve too much swipe causing restart
|
||||||
self.device.click_record_remove(name)
|
self.device.click_record_clear()
|
||||||
|
|
||||||
def cafe_additional(self) -> bool:
|
def cafe_additional(self) -> bool:
|
||||||
if self.appear_then_click(INVENTORY):
|
if self.appear_then_click(INVENTORY):
|
||||||
|
|||||||