Compare commits
12 Commits
v0.2.0
..
7c33bd42c6
| Author | SHA1 | Date | |
|---|---|---|---|
|
7c33bd42c6
|
|||
|
8698fa20c2
|
|||
|
b426c6caac
|
|||
|
8d83ec1657
|
|||
|
7fcda15329
|
|||
|
54aa1bafb5
|
|||
|
d756b0dc3f
|
|||
|
e71118c09e
|
|||
|
44b6d5cdf8
|
|||
|
f92dba92c9
|
|||
|
86ce04cff9
|
|||
|
f2065507c2
|
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 6.8 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 6.3 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 8.7 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 6.7 KiB |
@@ -45,14 +45,12 @@
|
|||||||
"Touch": true,
|
"Touch": true,
|
||||||
"AutoAdjust": true,
|
"AutoAdjust": true,
|
||||||
"SecondCafe": true
|
"SecondCafe": true
|
||||||
}
|
},
|
||||||
},
|
"Invitation": {
|
||||||
"Mail": {
|
|
||||||
"Scheduler": {
|
|
||||||
"Enable": true,
|
"Enable": true,
|
||||||
"NextRun": "2020-01-01 00:00:00",
|
"Choice": "list_top",
|
||||||
"Command": "Mail",
|
"Name": null,
|
||||||
"ServerUpdate": "04:00"
|
"Substitute": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Circle": {
|
"Circle": {
|
||||||
@@ -63,6 +61,14 @@
|
|||||||
"ServerUpdate": "04:00"
|
"ServerUpdate": "04:00"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Mail": {
|
||||||
|
"Scheduler": {
|
||||||
|
"Enable": true,
|
||||||
|
"NextRun": "2020-01-01 00:00:00",
|
||||||
|
"Command": "Mail",
|
||||||
|
"ServerUpdate": "04:00"
|
||||||
|
}
|
||||||
|
},
|
||||||
"Bounty": {
|
"Bounty": {
|
||||||
"Scheduler": {
|
"Scheduler": {
|
||||||
"Enable": true,
|
"Enable": true,
|
||||||
|
|||||||
@@ -205,32 +205,27 @@
|
|||||||
"type": "checkbox",
|
"type": "checkbox",
|
||||||
"value": true
|
"value": true
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
"Invitation": {
|
||||||
"Mail": {
|
|
||||||
"Scheduler": {
|
|
||||||
"Enable": {
|
"Enable": {
|
||||||
"type": "checkbox",
|
"type": "checkbox",
|
||||||
"value": true,
|
"value": true
|
||||||
|
},
|
||||||
|
"Choice": {
|
||||||
|
"type": "select",
|
||||||
|
"value": "list_top",
|
||||||
"option": [
|
"option": [
|
||||||
true,
|
"list_top",
|
||||||
false
|
"by_name"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"NextRun": {
|
"Name": {
|
||||||
"type": "datetime",
|
"type": "textarea",
|
||||||
"value": "2020-01-01 00:00:00",
|
"value": null
|
||||||
"validate": "datetime"
|
|
||||||
},
|
},
|
||||||
"Command": {
|
"Substitute": {
|
||||||
"type": "input",
|
"type": "checkbox",
|
||||||
"value": "Mail",
|
"value": true
|
||||||
"display": "hide"
|
|
||||||
},
|
|
||||||
"ServerUpdate": {
|
|
||||||
"type": "input",
|
|
||||||
"value": "04:00",
|
|
||||||
"display": "hide"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -261,6 +256,33 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Mail": {
|
||||||
|
"Scheduler": {
|
||||||
|
"Enable": {
|
||||||
|
"type": "checkbox",
|
||||||
|
"value": true,
|
||||||
|
"option": [
|
||||||
|
true,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"NextRun": {
|
||||||
|
"type": "datetime",
|
||||||
|
"value": "2020-01-01 00:00:00",
|
||||||
|
"validate": "datetime"
|
||||||
|
},
|
||||||
|
"Command": {
|
||||||
|
"type": "input",
|
||||||
|
"value": "Mail",
|
||||||
|
"display": "hide"
|
||||||
|
},
|
||||||
|
"ServerUpdate": {
|
||||||
|
"type": "input",
|
||||||
|
"value": "04:00",
|
||||||
|
"display": "hide"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"Bounty": {
|
"Bounty": {
|
||||||
"Scheduler": {
|
"Scheduler": {
|
||||||
"Enable": {
|
"Enable": {
|
||||||
|
|||||||
@@ -80,6 +80,15 @@ 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:
|
||||||
|
|||||||
@@ -12,8 +12,8 @@
|
|||||||
"page": "setting",
|
"page": "setting",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
"Cafe",
|
"Cafe",
|
||||||
"Mail",
|
|
||||||
"Circle",
|
"Circle",
|
||||||
|
"Mail",
|
||||||
"Bounty",
|
"Bounty",
|
||||||
"Scrimmage",
|
"Scrimmage",
|
||||||
"TacticalChallenge",
|
"TacticalChallenge",
|
||||||
|
|||||||
@@ -25,10 +25,11 @@ Daily:
|
|||||||
Cafe:
|
Cafe:
|
||||||
- Scheduler
|
- Scheduler
|
||||||
- Cafe
|
- Cafe
|
||||||
Mail:
|
- Invitation
|
||||||
- Scheduler
|
|
||||||
Circle:
|
Circle:
|
||||||
- Scheduler
|
- Scheduler
|
||||||
|
Mail:
|
||||||
|
- Scheduler
|
||||||
Bounty:
|
Bounty:
|
||||||
- Scheduler
|
- Scheduler
|
||||||
- Bounty
|
- Bounty
|
||||||
|
|||||||
@@ -45,6 +45,12 @@ 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
|
||||||
|
|
||||||
|
|||||||
@@ -22,14 +22,14 @@
|
|||||||
"name": "Cafe",
|
"name": "Cafe",
|
||||||
"help": ""
|
"help": ""
|
||||||
},
|
},
|
||||||
"Mail": {
|
|
||||||
"name": "Mailbox",
|
|
||||||
"help": ""
|
|
||||||
},
|
|
||||||
"Circle": {
|
"Circle": {
|
||||||
"name": "Club",
|
"name": "Club",
|
||||||
"help": ""
|
"help": ""
|
||||||
},
|
},
|
||||||
|
"Mail": {
|
||||||
|
"name": "Mailbox",
|
||||||
|
"help": ""
|
||||||
|
},
|
||||||
"Bounty": {
|
"Bounty": {
|
||||||
"name": "Bounty",
|
"name": "Bounty",
|
||||||
"help": ""
|
"help": ""
|
||||||
@@ -221,6 +221,30 @@
|
|||||||
"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",
|
||||||
|
|||||||
@@ -22,14 +22,14 @@
|
|||||||
"name": "咖啡厅",
|
"name": "咖啡厅",
|
||||||
"help": ""
|
"help": ""
|
||||||
},
|
},
|
||||||
"Mail": {
|
|
||||||
"name": "邮箱",
|
|
||||||
"help": ""
|
|
||||||
},
|
|
||||||
"Circle": {
|
"Circle": {
|
||||||
"name": "公会",
|
"name": "公会",
|
||||||
"help": "社团 / 小组"
|
"help": "社团 / 小组"
|
||||||
},
|
},
|
||||||
|
"Mail": {
|
||||||
|
"name": "邮箱",
|
||||||
|
"help": ""
|
||||||
|
},
|
||||||
"Bounty": {
|
"Bounty": {
|
||||||
"name": "悬赏通缉",
|
"name": "悬赏通缉",
|
||||||
"help": ""
|
"help": ""
|
||||||
@@ -221,6 +221,30 @@
|
|||||||
"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": "悬赏通缉设置",
|
||||||
|
|||||||
@@ -75,17 +75,17 @@ OCR_TICKET = ButtonWrapper(
|
|||||||
name='OCR_TICKET',
|
name='OCR_TICKET',
|
||||||
jp=Button(
|
jp=Button(
|
||||||
file='./assets/jp/bounty/OCR_TICKET.png',
|
file='./assets/jp/bounty/OCR_TICKET.png',
|
||||||
area=(195, 85, 237, 113),
|
area=(196, 87, 258, 113),
|
||||||
search=(175, 65, 257, 133),
|
search=(176, 67, 278, 133),
|
||||||
color=(197, 206, 213),
|
color=(173, 197, 212),
|
||||||
button=(195, 85, 237, 113),
|
button=(196, 87, 258, 113),
|
||||||
),
|
),
|
||||||
en=Button(
|
en=Button(
|
||||||
file='./assets/en/bounty/OCR_TICKET.png',
|
file='./assets/en/bounty/OCR_TICKET.png',
|
||||||
area=(225, 85, 267, 114),
|
area=(229, 89, 285, 112),
|
||||||
search=(205, 65, 287, 134),
|
search=(209, 69, 305, 132),
|
||||||
color=(197, 206, 213),
|
color=(177, 194, 207),
|
||||||
button=(225, 85, 267, 114),
|
button=(229, 89, 285, 112),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
SELECT_DESERT_RAILROAD = ButtonWrapper(
|
SELECT_DESERT_RAILROAD = ButtonWrapper(
|
||||||
|
|||||||
@@ -41,8 +41,9 @@ class Bounty(BountyUI):
|
|||||||
if action == 'stop':
|
if action == 'stop':
|
||||||
raise RequestHumanTakeover
|
raise RequestHumanTakeover
|
||||||
elif action == 'skip':
|
elif action == 'skip':
|
||||||
self.config.task_delay(server_update=True)
|
with self.config.multi_set():
|
||||||
self.config.task_stop()
|
self.config.task_delay(server_update=True)
|
||||||
|
self.config.task_stop()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_ticket_enough(self) -> bool:
|
def is_ticket_enough(self) -> bool:
|
||||||
|
|||||||
@@ -40,6 +40,28 @@ 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(
|
||||||
@@ -91,6 +113,17 @@ 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(
|
||||||
@@ -186,6 +219,61 @@ 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(
|
||||||
@@ -203,6 +291,28 @@ 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(
|
||||||
@@ -220,6 +330,17 @@ 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,6 +6,7 @@ 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')
|
||||||
@@ -22,8 +23,9 @@ class CafeStatus(Enum):
|
|||||||
OCR = 1
|
OCR = 1
|
||||||
REWARD = 2
|
REWARD = 2
|
||||||
GOT = 3
|
GOT = 3
|
||||||
CLICK = 4
|
INVITATION = 4
|
||||||
CHECK = 5
|
CLICK = 5
|
||||||
|
CHECK = 6
|
||||||
FINISHED = -1
|
FINISHED = -1
|
||||||
|
|
||||||
|
|
||||||
@@ -63,6 +65,9 @@ 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))
|
||||||
|
|||||||
@@ -0,0 +1,298 @@
|
|||||||
|
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,21 +48,22 @@ 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)
|
self.device.swipe_vector(vector_down, 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_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)
|
self.device.swipe_vector(vector_up, box=BOX_CAFE.area, random_range=random_r, padding=5, name=name)
|
||||||
case 'left':
|
case 'left':
|
||||||
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)
|
self.device.swipe_vector(vector_left, box=BOX_CAFE.area, random_range=random_r, padding=5, name=name)
|
||||||
case 'right':
|
case 'right':
|
||||||
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)
|
self.device.swipe_vector(vector_right, box=BOX_CAFE.area, random_range=random_r, padding=5, name=name)
|
||||||
# solve too much swipe causing restart
|
# solve too much swipe causing restart
|
||||||
self.device.click_record_clear()
|
self.device.click_record_remove(name)
|
||||||
|
|
||||||
def cafe_additional(self) -> bool:
|
def cafe_additional(self) -> bool:
|
||||||
if self.appear_then_click(INVENTORY):
|
if self.appear_then_click(INVENTORY):
|
||||||
|
|||||||
@@ -12,7 +12,10 @@ class DataUpdate(UI):
|
|||||||
Page:
|
Page:
|
||||||
in: page_work
|
in: page_work
|
||||||
"""
|
"""
|
||||||
ap = DigitCounter(OCR_AP).ocr_single_line(self.device.image)
|
ap, _, ap_total = DigitCounter(OCR_AP).ocr_single_line(self.device.image)
|
||||||
|
if ap_total == 0:
|
||||||
|
logger.warning('Invalid AP')
|
||||||
|
return False
|
||||||
# Data for Credit and Pyroxene
|
# Data for Credit and Pyroxene
|
||||||
ocr = Digit(OCR_DATA)
|
ocr = Digit(OCR_DATA)
|
||||||
timeout = Timer(2, count=6).start()
|
timeout = Timer(2, count=6).start()
|
||||||
@@ -21,27 +24,28 @@ class DataUpdate(UI):
|
|||||||
if len(data) != 2:
|
if len(data) != 2:
|
||||||
data = [data[0], data[-1]]
|
data = [data[0], data[-1]]
|
||||||
logger.attr('Data', data)
|
logger.attr('Data', data)
|
||||||
credit, pyroxene = [int(''.join([v for v in d.ocr_text if v.isdigit()])) for d in data]
|
credit, pyroxene = [int(''.join(filter(lambda x: x.isdigit(), d.ocr_text))) for d in data]
|
||||||
if credit > 0 or pyroxene > 0:
|
if credit > 0 or pyroxene > 0:
|
||||||
break
|
break
|
||||||
|
|
||||||
logger.warning(f'Invalid credit and pyroxene: {data}')
|
logger.warning(f'Invalid credit and pyroxene: {data}')
|
||||||
if timeout.reached():
|
if timeout.reached():
|
||||||
logger.warning('Get data timeout')
|
logger.warning('Get data timeout')
|
||||||
break
|
return False
|
||||||
|
|
||||||
logger.attr('Credit', credit)
|
logger.attr('Credit', credit)
|
||||||
logger.attr('Pyroxene', pyroxene)
|
logger.attr('Pyroxene', pyroxene)
|
||||||
with self.config.multi_set():
|
with self.config.multi_set():
|
||||||
self.config.stored.AP.set(ap[0], ap[2])
|
self.config.stored.AP.set(ap, ap_total)
|
||||||
self.config.stored.Credit.value = credit
|
self.config.stored.Credit.value = credit
|
||||||
self.config.stored.Pyroxene.value = pyroxene
|
self.config.stored.Pyroxene.value = pyroxene
|
||||||
|
|
||||||
return ap, credit, pyroxene
|
return True
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.ui_ensure(page_work, acquire_lang_checked=False)
|
self.ui_ensure(page_work, acquire_lang_checked=False)
|
||||||
|
|
||||||
with self.config.multi_set():
|
if self._get_data():
|
||||||
self._get_data()
|
|
||||||
self.config.task_delay(server_update=True)
|
self.config.task_delay(server_update=True)
|
||||||
|
else:
|
||||||
|
self.config.task_delay(minute=1)
|
||||||
|
|||||||
@@ -75,17 +75,17 @@ OCR_TICKET = ButtonWrapper(
|
|||||||
name='OCR_TICKET',
|
name='OCR_TICKET',
|
||||||
jp=Button(
|
jp=Button(
|
||||||
file='./assets/jp/scrimmage/OCR_TICKET.png',
|
file='./assets/jp/scrimmage/OCR_TICKET.png',
|
||||||
area=(195, 85, 235, 113),
|
area=(194, 87, 258, 112),
|
||||||
search=(175, 65, 255, 133),
|
search=(174, 67, 278, 132),
|
||||||
color=(206, 211, 215),
|
color=(207, 213, 218),
|
||||||
button=(195, 85, 235, 113),
|
button=(194, 87, 258, 112),
|
||||||
),
|
),
|
||||||
en=Button(
|
en=Button(
|
||||||
file='./assets/en/scrimmage/OCR_TICKET.png',
|
file='./assets/en/scrimmage/OCR_TICKET.png',
|
||||||
area=(227, 84, 265, 115),
|
area=(229, 88, 289, 112),
|
||||||
search=(207, 64, 285, 135),
|
search=(209, 68, 309, 132),
|
||||||
color=(207, 212, 216),
|
color=(199, 206, 212),
|
||||||
button=(227, 84, 265, 115),
|
button=(229, 88, 289, 112),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
SELECT_GEHENNA = ButtonWrapper(
|
SELECT_GEHENNA = ButtonWrapper(
|
||||||
|
|||||||
@@ -42,8 +42,9 @@ class Scrimmage(ScrimmageUI):
|
|||||||
if action == 'stop':
|
if action == 'stop':
|
||||||
raise RequestHumanTakeover
|
raise RequestHumanTakeover
|
||||||
elif action == 'skip':
|
elif action == 'skip':
|
||||||
self.config.task_delay(server_update=True)
|
with self.config.multi_set():
|
||||||
self.config.task_stop()
|
self.config.task_delay(server_update=True)
|
||||||
|
self.config.task_stop()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_ticket_enough(self) -> bool:
|
def is_ticket_enough(self) -> bool:
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
import cv2
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from module.base.base import ModuleBase
|
from module.base.base import ModuleBase
|
||||||
from module.base.button import ClickButton, match_template
|
|
||||||
from module.base.timer import Timer
|
from module.base.timer import Timer
|
||||||
from module.base.utils import area_pad, area_size, area_offset, random_rectangle_vector_opted
|
from module.base.utils import area_pad, area_size, area_offset
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
from module.ocr.ocr import Ocr
|
from module.ocr.ocr import Ocr
|
||||||
from tasks.stage.assets.assets_stage_list import *
|
from tasks.stage.assets.assets_stage_list import *
|
||||||
|
|
||||||
|
|
||||||
class StageList:
|
class StageList:
|
||||||
drag_vector_range = (0.65, 0.85)
|
swipe_vector_range = (0.65, 0.85)
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@@ -21,7 +19,7 @@ class StageList:
|
|||||||
button_item: ButtonWrapper = None,
|
button_item: ButtonWrapper = None,
|
||||||
button_enter: ButtonWrapper = None,
|
button_enter: ButtonWrapper = None,
|
||||||
button_stars: ButtonWrapper = None,
|
button_stars: ButtonWrapper = None,
|
||||||
drag_direction: str = "down"
|
swipe_direction: str = "down"
|
||||||
):
|
):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.stage = button_list if button_list else STAGE_LIST
|
self.stage = button_list if button_list else STAGE_LIST
|
||||||
@@ -29,7 +27,7 @@ class StageList:
|
|||||||
self.stage_item = (button_item if button_item else STAGE_ITEM).button
|
self.stage_item = (button_item if button_item else STAGE_ITEM).button
|
||||||
self.enter = button_enter if button_enter else STAGE_ENTER
|
self.enter = button_enter if button_enter else STAGE_ENTER
|
||||||
self.sweepable = button_stars if button_stars else STAGE_STARS
|
self.sweepable = button_stars if button_stars else STAGE_STARS
|
||||||
self.drag_direction = drag_direction
|
self.swipe_direction = swipe_direction
|
||||||
|
|
||||||
self.current_index_min = 1
|
self.current_index_min = 1
|
||||||
self.current_index_max = 1
|
self.current_index_max = 1
|
||||||
@@ -63,7 +61,7 @@ class StageList:
|
|||||||
self.current_index_max = max(indexes)
|
self.current_index_max = max(indexes)
|
||||||
logger.attr(self.index_ocr.name, f'Index range: {self.current_index_min} - {self.current_index_max}')
|
logger.attr(self.index_ocr.name, f'Index range: {self.current_index_min} - {self.current_index_max}')
|
||||||
|
|
||||||
def drag_page(self, direction: str, main: ModuleBase, vector_range=None, reverse=False):
|
def swipe_page(self, direction: str, main: ModuleBase, vector_range=None, reverse=False):
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
direction: up, down
|
direction: up, down
|
||||||
@@ -72,7 +70,7 @@ class StageList:
|
|||||||
reverse (bool):
|
reverse (bool):
|
||||||
"""
|
"""
|
||||||
if vector_range is None:
|
if vector_range is None:
|
||||||
vector_range = self.drag_vector_range
|
vector_range = self.swipe_vector_range
|
||||||
vector = np.random.uniform(*vector_range)
|
vector = np.random.uniform(*vector_range)
|
||||||
width, height = area_size(self.stage.button)
|
width, height = area_size(self.stage.button)
|
||||||
if direction == 'up':
|
if direction == 'up':
|
||||||
@@ -80,13 +78,12 @@ class StageList:
|
|||||||
elif direction == 'down':
|
elif direction == 'down':
|
||||||
vector = (0, -vector * height)
|
vector = (0, -vector * height)
|
||||||
else:
|
else:
|
||||||
logger.warning(f'Unknown drag direction: {direction}')
|
logger.warning(f'Unknown swipe direction: {direction}')
|
||||||
return
|
return
|
||||||
|
|
||||||
if reverse:
|
if reverse:
|
||||||
vector = (-vector[0], -vector[1])
|
vector = (-vector[0], -vector[1])
|
||||||
p1, p2 = random_rectangle_vector_opted(vector, box=self.stage.button)
|
main.device.swipe_vector(vector, self.stage.button, name=f'{self.name}_SWIPE')
|
||||||
main.device.drag(p1, p2, name=f'{self.name}_DRAG')
|
|
||||||
|
|
||||||
def insight_index(self, index: int, main: ModuleBase, skip_first_screenshot=True) -> bool:
|
def insight_index(self, index: int, main: ModuleBase, skip_first_screenshot=True) -> bool:
|
||||||
"""
|
"""
|
||||||
@@ -110,18 +107,7 @@ class StageList:
|
|||||||
self.load_stage_indexes(main=main)
|
self.load_stage_indexes(main=main)
|
||||||
|
|
||||||
if self.current_index_min <= index <= self.current_index_max:
|
if self.current_index_min <= index <= self.current_index_max:
|
||||||
break
|
return True
|
||||||
|
|
||||||
if index < self.current_index_min:
|
|
||||||
self.drag_page(self.drag_direction, main, reverse=True)
|
|
||||||
elif index > self.current_index_max:
|
|
||||||
self.drag_page(self.drag_direction, main)
|
|
||||||
|
|
||||||
main.wait_until_stable(
|
|
||||||
self.stage.button,
|
|
||||||
timer=Timer(0, 0),
|
|
||||||
timeout=Timer(1.5, 5)
|
|
||||||
)
|
|
||||||
|
|
||||||
indexes = self._indexes
|
indexes = self._indexes
|
||||||
if indexes and last_indexes == set(indexes):
|
if indexes and last_indexes == set(indexes):
|
||||||
@@ -129,22 +115,16 @@ class StageList:
|
|||||||
return False
|
return False
|
||||||
last_indexes = set(indexes)
|
last_indexes = set(indexes)
|
||||||
|
|
||||||
return True
|
if index < self.current_index_min:
|
||||||
|
self.swipe_page(self.swipe_direction, main, reverse=True)
|
||||||
|
elif index > self.current_index_max:
|
||||||
|
self.swipe_page(self.swipe_direction, main)
|
||||||
|
|
||||||
@staticmethod
|
main.wait_until_stable(
|
||||||
def _match_clickable_points(image, template, threshold=0.85):
|
self.stage.button,
|
||||||
image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
|
timer=Timer(0, 0),
|
||||||
template = cv2.cvtColor(template, cv2.COLOR_RGB2GRAY)
|
timeout=Timer(1.5, 5)
|
||||||
|
)
|
||||||
res = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED)
|
|
||||||
loc = np.where(res >= threshold)
|
|
||||||
return [point for point in zip(*loc[::-1])]
|
|
||||||
|
|
||||||
def is_sweepable(self, image, main: ModuleBase, skip_first_screenshot=True) -> bool:
|
|
||||||
if not skip_first_screenshot:
|
|
||||||
main.device.screenshot()
|
|
||||||
|
|
||||||
return match_template(image, self.sweepable.matched_button.image)
|
|
||||||
|
|
||||||
def select_index_enter(
|
def select_index_enter(
|
||||||
self,
|
self,
|
||||||
@@ -182,23 +162,21 @@ class StageList:
|
|||||||
|
|
||||||
stage_item_box = area_pad((*offset, *area_size(self.stage_item)))
|
stage_item_box = area_pad((*offset, *area_size(self.stage_item)))
|
||||||
search_box = area_offset(stage_item_box, index_box.box[:2])
|
search_box = area_offset(stage_item_box, index_box.box[:2])
|
||||||
search_image = main.image_crop(search_box)
|
self.sweepable.load_search(search_box)
|
||||||
|
|
||||||
if sweepable and not self.is_sweepable(search_image, main, skip_first_screenshot):
|
if sweepable and not main.appear(self.sweepable):
|
||||||
logger.warning(f'Index {index} is not sweepable')
|
logger.warning(f'Index {index} is not sweepable')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
points = self._match_clickable_points(search_image, self.enter.matched_button.image)
|
self.enter.load_search(search_box)
|
||||||
|
click_button = self.enter.match_multi_template(main.device.image)
|
||||||
|
|
||||||
if not points:
|
if not click_button:
|
||||||
logger.warning(f'No clickable {self.enter.name}')
|
logger.warning(f'No clickable {self.enter.name}')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
point = area_offset((0, 0, *area_size(self.enter.button)), points[0])
|
|
||||||
click_button = ClickButton(area_offset(point, search_box[:2]), name=self.enter.name)
|
|
||||||
|
|
||||||
if click_interval.reached_and_reset():
|
if click_interval.reached_and_reset():
|
||||||
main.device.click(click_button)
|
main.device.click(click_button[0])
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if timeout.reached():
|
if timeout.reached():
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ class StageSweep:
|
|||||||
if not self.set_mode(mode, num):
|
if not self.set_mode(mode, num):
|
||||||
return False
|
return False
|
||||||
timer = Timer(0.5, 1)
|
timer = Timer(0.5, 1)
|
||||||
timer_stable = Timer(0.5, 1).start()
|
timer_stable = Timer(1, 1).start()
|
||||||
status = SweepStatus.SELECT
|
status = SweepStatus.SELECT
|
||||||
while 1:
|
while 1:
|
||||||
if not timer_stable.reached():
|
if not timer_stable.reached():
|
||||||
|
|||||||