Fix: Refactor team select as having 9 teams now
Before Width: | Height: | Size: 8.6 KiB |
BIN
assets/share/combat/team/TEAM_1_CHECK.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
assets/share/combat/team/TEAM_1_CLICK.png
Normal file
After Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 9.7 KiB |
BIN
assets/share/combat/team/TEAM_2_CHECK.png
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
assets/share/combat/team/TEAM_2_CLICK.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 9.9 KiB |
BIN
assets/share/combat/team/TEAM_3_CHECK.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
assets/share/combat/team/TEAM_3_CLICK.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 9.0 KiB |
BIN
assets/share/combat/team/TEAM_4_CHECK.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
assets/share/combat/team/TEAM_4_CLICK.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 9.2 KiB |
BIN
assets/share/combat/team/TEAM_5_CHECK.png
Normal file
After Width: | Height: | Size: 7.3 KiB |
BIN
assets/share/combat/team/TEAM_5_CLICK.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 9.2 KiB |
BIN
assets/share/combat/team/TEAM_6_CHECK.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
assets/share/combat/team/TEAM_6_CLICK.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
assets/share/combat/team/TEAM_7_CHECK.png
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
assets/share/combat/team/TEAM_7_CLICK.png
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
assets/share/combat/team/TEAM_8_CHECK.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
assets/share/combat/team/TEAM_8_CLICK.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
assets/share/combat/team/TEAM_9_CHECK.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
assets/share/combat/team/TEAM_9_CLICK.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
BIN
assets/share/combat/team/TEAM_SEARCH.png
Normal file
After Width: | Height: | Size: 47 KiB |
@ -40,63 +40,193 @@ COMBAT_TEAM_SUPPORT = ButtonWrapper(
|
|||||||
button=(1123, 477, 1158, 503),
|
button=(1123, 477, 1158, 503),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
TEAM_1 = ButtonWrapper(
|
TEAM_1_CHECK = ButtonWrapper(
|
||||||
name='TEAM_1',
|
name='TEAM_1_CHECK',
|
||||||
share=Button(
|
share=Button(
|
||||||
file='./assets/share/combat/team/TEAM_1.png',
|
file='./assets/share/combat/team/TEAM_1_CHECK.png',
|
||||||
area=(365, 29, 411, 65),
|
area=(391, 29, 424, 56),
|
||||||
search=(345, 9, 431, 85),
|
search=(371, 9, 444, 76),
|
||||||
color=(113, 109, 117),
|
color=(147, 137, 129),
|
||||||
button=(365, 29, 411, 65),
|
button=(391, 29, 424, 56),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
TEAM_2 = ButtonWrapper(
|
TEAM_1_CLICK = ButtonWrapper(
|
||||||
name='TEAM_2',
|
name='TEAM_1_CLICK',
|
||||||
share=Button(
|
share=Button(
|
||||||
file='./assets/share/combat/team/TEAM_2.png',
|
file='./assets/share/combat/team/TEAM_1_CLICK.png',
|
||||||
area=(467, 29, 511, 65),
|
area=(395, 32, 421, 54),
|
||||||
search=(447, 9, 531, 85),
|
search=(375, 12, 441, 74),
|
||||||
color=(126, 124, 130),
|
color=(80, 79, 96),
|
||||||
button=(467, 29, 511, 65),
|
button=(395, 32, 421, 54),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
TEAM_3 = ButtonWrapper(
|
TEAM_2_CHECK = ButtonWrapper(
|
||||||
name='TEAM_3',
|
name='TEAM_2_CHECK',
|
||||||
share=Button(
|
share=Button(
|
||||||
file='./assets/share/combat/team/TEAM_3.png',
|
file='./assets/share/combat/team/TEAM_2_CHECK.png',
|
||||||
area=(567, 28, 614, 66),
|
area=(491, 29, 528, 56),
|
||||||
search=(547, 8, 634, 86),
|
search=(471, 9, 548, 76),
|
||||||
color=(115, 116, 123),
|
color=(151, 143, 135),
|
||||||
button=(567, 28, 614, 66),
|
button=(491, 29, 528, 56),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
TEAM_4 = ButtonWrapper(
|
TEAM_2_CLICK = ButtonWrapper(
|
||||||
name='TEAM_4',
|
name='TEAM_2_CLICK',
|
||||||
share=Button(
|
share=Button(
|
||||||
file='./assets/share/combat/team/TEAM_4.png',
|
file='./assets/share/combat/team/TEAM_2_CLICK.png',
|
||||||
area=(666, 29, 712, 63),
|
area=(512, 32, 525, 54),
|
||||||
search=(646, 9, 732, 83),
|
search=(492, 12, 545, 74),
|
||||||
color=(106, 103, 98),
|
color=(86, 89, 108),
|
||||||
button=(666, 29, 712, 63),
|
button=(512, 32, 525, 54),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
TEAM_5 = ButtonWrapper(
|
TEAM_3_CHECK = ButtonWrapper(
|
||||||
name='TEAM_5',
|
name='TEAM_3_CHECK',
|
||||||
share=Button(
|
share=Button(
|
||||||
file='./assets/share/combat/team/TEAM_5.png',
|
file='./assets/share/combat/team/TEAM_3_CHECK.png',
|
||||||
area=(767, 30, 816, 66),
|
area=(591, 29, 629, 56),
|
||||||
search=(747, 10, 836, 86),
|
search=(571, 9, 649, 76),
|
||||||
color=(106, 100, 96),
|
color=(145, 138, 128),
|
||||||
button=(767, 30, 816, 66),
|
button=(591, 29, 629, 56),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
TEAM_6 = ButtonWrapper(
|
TEAM_3_CLICK = ButtonWrapper(
|
||||||
name='TEAM_6',
|
name='TEAM_3_CLICK',
|
||||||
share=Button(
|
share=Button(
|
||||||
file='./assets/share/combat/team/TEAM_6.png',
|
file='./assets/share/combat/team/TEAM_3_CLICK.png',
|
||||||
area=(867, 29, 912, 63),
|
area=(612, 32, 625, 54),
|
||||||
search=(847, 9, 932, 83),
|
search=(592, 12, 645, 74),
|
||||||
color=(113, 106, 101),
|
color=(78, 82, 95),
|
||||||
button=(867, 29, 912, 63),
|
button=(612, 32, 625, 54),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
TEAM_4_CHECK = ButtonWrapper(
|
||||||
|
name='TEAM_4_CHECK',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/combat/team/TEAM_4_CHECK.png',
|
||||||
|
area=(691, 29, 730, 56),
|
||||||
|
search=(671, 9, 750, 76),
|
||||||
|
color=(136, 129, 117),
|
||||||
|
button=(691, 29, 730, 56),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
TEAM_4_CLICK = ButtonWrapper(
|
||||||
|
name='TEAM_4_CLICK',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/combat/team/TEAM_4_CLICK.png',
|
||||||
|
area=(712, 32, 726, 54),
|
||||||
|
search=(692, 12, 746, 74),
|
||||||
|
color=(67, 69, 82),
|
||||||
|
button=(712, 32, 726, 54),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
TEAM_5_CHECK = ButtonWrapper(
|
||||||
|
name='TEAM_5_CHECK',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/combat/team/TEAM_5_CHECK.png',
|
||||||
|
area=(791, 29, 829, 56),
|
||||||
|
search=(771, 9, 849, 76),
|
||||||
|
color=(145, 135, 121),
|
||||||
|
button=(791, 29, 829, 56),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
TEAM_5_CLICK = ButtonWrapper(
|
||||||
|
name='TEAM_5_CLICK',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/combat/team/TEAM_5_CLICK.png',
|
||||||
|
area=(813, 32, 825, 54),
|
||||||
|
search=(793, 12, 845, 74),
|
||||||
|
color=(83, 83, 93),
|
||||||
|
button=(813, 32, 825, 54),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
TEAM_6_CHECK = ButtonWrapper(
|
||||||
|
name='TEAM_6_CHECK',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/combat/team/TEAM_6_CHECK.png',
|
||||||
|
area=(551, 29, 589, 56),
|
||||||
|
search=(531, 9, 609, 76),
|
||||||
|
color=(150, 144, 135),
|
||||||
|
button=(551, 29, 589, 56),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
TEAM_6_CLICK = ButtonWrapper(
|
||||||
|
name='TEAM_6_CLICK',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/combat/team/TEAM_6_CLICK.png',
|
||||||
|
area=(572, 32, 586, 54),
|
||||||
|
search=(552, 12, 606, 74),
|
||||||
|
color=(86, 91, 109),
|
||||||
|
button=(572, 32, 586, 54),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
TEAM_7_CHECK = ButtonWrapper(
|
||||||
|
name='TEAM_7_CHECK',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/combat/team/TEAM_7_CHECK.png',
|
||||||
|
area=(651, 29, 689, 56),
|
||||||
|
search=(631, 9, 709, 76),
|
||||||
|
color=(133, 126, 115),
|
||||||
|
button=(651, 29, 689, 56),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
TEAM_7_CLICK = ButtonWrapper(
|
||||||
|
name='TEAM_7_CLICK',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/combat/team/TEAM_7_CLICK.png',
|
||||||
|
area=(673, 32, 685, 54),
|
||||||
|
search=(653, 12, 705, 74),
|
||||||
|
color=(63, 66, 76),
|
||||||
|
button=(673, 32, 685, 54),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
TEAM_8_CHECK = ButtonWrapper(
|
||||||
|
name='TEAM_8_CHECK',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/combat/team/TEAM_8_CHECK.png',
|
||||||
|
area=(751, 29, 789, 56),
|
||||||
|
search=(731, 9, 809, 76),
|
||||||
|
color=(156, 145, 129),
|
||||||
|
button=(751, 29, 789, 56),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
TEAM_8_CLICK = ButtonWrapper(
|
||||||
|
name='TEAM_8_CLICK',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/combat/team/TEAM_8_CLICK.png',
|
||||||
|
area=(772, 32, 786, 54),
|
||||||
|
search=(752, 12, 806, 74),
|
||||||
|
color=(92, 92, 100),
|
||||||
|
button=(772, 32, 786, 54),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
TEAM_9_CHECK = ButtonWrapper(
|
||||||
|
name='TEAM_9_CHECK',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/combat/team/TEAM_9_CHECK.png',
|
||||||
|
area=(851, 29, 889, 56),
|
||||||
|
search=(831, 9, 909, 76),
|
||||||
|
color=(143, 134, 120),
|
||||||
|
button=(851, 29, 889, 56),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
TEAM_9_CLICK = ButtonWrapper(
|
||||||
|
name='TEAM_9_CLICK',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/combat/team/TEAM_9_CLICK.png',
|
||||||
|
area=(872, 32, 886, 54),
|
||||||
|
search=(852, 12, 906, 74),
|
||||||
|
color=(73, 73, 83),
|
||||||
|
button=(872, 32, 886, 54),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
TEAM_SEARCH = ButtonWrapper(
|
||||||
|
name='TEAM_SEARCH',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/combat/team/TEAM_SEARCH.png',
|
||||||
|
area=(349, 12, 927, 72),
|
||||||
|
search=(329, 0, 947, 92),
|
||||||
|
color=(36, 40, 62),
|
||||||
|
button=(349, 12, 927, 72),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -1,48 +1,86 @@
|
|||||||
from module.base.button import ButtonWrapper
|
import re
|
||||||
|
|
||||||
from module.base.timer import Timer
|
from module.base.timer import Timer
|
||||||
|
from module.base.utils import random_rectangle_vector_opted
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
from tasks.base.ui import UI
|
from tasks.base.ui import UI
|
||||||
from tasks.combat.assets.assets_combat_team import (
|
from tasks.combat.assets.assets_combat_team import *
|
||||||
COMBAT_TEAM_PREPARE,
|
|
||||||
TEAM_1,
|
|
||||||
TEAM_2,
|
|
||||||
TEAM_3,
|
|
||||||
TEAM_4,
|
|
||||||
TEAM_5,
|
|
||||||
TEAM_6
|
|
||||||
)
|
|
||||||
|
|
||||||
TEAM_BUTTONS = {
|
|
||||||
1: TEAM_1,
|
def button_to_index(button: ButtonWrapper) -> int:
|
||||||
2: TEAM_2,
|
res = re.search(r'(\d)', button.name)
|
||||||
3: TEAM_3,
|
if res:
|
||||||
4: TEAM_4,
|
return int(res.group(1))
|
||||||
5: TEAM_5,
|
else:
|
||||||
6: TEAM_6,
|
logger.warning(f'Cannot convert team button to index: {button}')
|
||||||
}
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
def index_to_button(index: int) -> ButtonWrapper:
|
||||||
|
match index:
|
||||||
|
case 1:
|
||||||
|
return TEAM_1_CLICK
|
||||||
|
case 2:
|
||||||
|
return TEAM_2_CLICK
|
||||||
|
case 3:
|
||||||
|
return TEAM_3_CLICK
|
||||||
|
case 4:
|
||||||
|
return TEAM_4_CLICK
|
||||||
|
case 5:
|
||||||
|
return TEAM_5_CLICK
|
||||||
|
case 6:
|
||||||
|
return TEAM_6_CLICK
|
||||||
|
case 7:
|
||||||
|
return TEAM_7_CLICK
|
||||||
|
case 8:
|
||||||
|
return TEAM_8_CLICK
|
||||||
|
case 9:
|
||||||
|
return TEAM_9_CLICK
|
||||||
|
case _:
|
||||||
|
logger.warning(f'Invalid team index: {index}')
|
||||||
|
return TEAM_1_CLICK
|
||||||
|
|
||||||
|
|
||||||
class CombatTeam(UI):
|
class CombatTeam(UI):
|
||||||
@staticmethod
|
def _get_team(self) -> tuple[list[int], int]:
|
||||||
def _team_index_to_button(index: int) -> ButtonWrapper:
|
"""
|
||||||
try:
|
Returns:
|
||||||
return TEAM_BUTTONS[index]
|
list[str]: List of displayed team index.
|
||||||
except KeyError:
|
int: Current team index, or None if current team is not insight
|
||||||
logger.warning(f'Invalid team index: {index}, return team 1 instead')
|
"""
|
||||||
return TEAM_1
|
list_team = []
|
||||||
|
for button in [
|
||||||
|
TEAM_1_CLICK, TEAM_2_CLICK, TEAM_3_CLICK, TEAM_4_CLICK, TEAM_5_CLICK,
|
||||||
|
TEAM_6_CLICK, TEAM_7_CLICK, TEAM_8_CLICK, TEAM_9_CLICK
|
||||||
|
]:
|
||||||
|
button.load_search(TEAM_SEARCH.area)
|
||||||
|
if self.appear(button):
|
||||||
|
list_team.append(button_to_index(button))
|
||||||
|
current_team = None
|
||||||
|
for button in [
|
||||||
|
TEAM_1_CHECK, TEAM_2_CHECK, TEAM_3_CHECK, TEAM_4_CHECK, TEAM_5_CHECK,
|
||||||
|
TEAM_6_CHECK, TEAM_7_CHECK, TEAM_8_CHECK, TEAM_9_CHECK
|
||||||
|
]:
|
||||||
|
button.load_search(TEAM_SEARCH.area)
|
||||||
|
if self.appear(button):
|
||||||
|
current_team = button_to_index(button)
|
||||||
|
list_team.append(button_to_index(button))
|
||||||
|
list_team = list(sorted(list_team))
|
||||||
|
|
||||||
def _get_team_selected(self) -> int:
|
def show(index):
|
||||||
for index, button in TEAM_BUTTONS.items():
|
if index == current_team:
|
||||||
if self.image_color_count(button, color=(255, 234, 191), threshold=221, count=50):
|
return f'*0{index}*'
|
||||||
return index
|
else:
|
||||||
|
return f'0{index}'
|
||||||
|
|
||||||
# logger.warning(f'No team selected')
|
# [Team] 01 02 *03* 04 05 06
|
||||||
return 0
|
logger.attr('Team', ' '.join([show(i) for i in list_team]))
|
||||||
|
return list_team, current_team
|
||||||
|
|
||||||
def team_set(self, team: int = 1, skip_first_screenshot=True) -> bool:
|
def team_set(self, team: int = 1, skip_first_screenshot=True) -> bool:
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
team: Team index, 1 to 6.
|
team: Team index, 1 to 9.
|
||||||
skip_first_screenshot:
|
skip_first_screenshot:
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -53,6 +91,7 @@ class CombatTeam(UI):
|
|||||||
"""
|
"""
|
||||||
logger.info(f'Team set: {team}')
|
logger.info(f'Team set: {team}')
|
||||||
# Wait teams show up
|
# Wait teams show up
|
||||||
|
timeout = Timer(1, count=5).start()
|
||||||
while 1:
|
while 1:
|
||||||
if skip_first_screenshot:
|
if skip_first_screenshot:
|
||||||
skip_first_screenshot = False
|
skip_first_screenshot = False
|
||||||
@ -60,7 +99,10 @@ class CombatTeam(UI):
|
|||||||
self.device.screenshot()
|
self.device.screenshot()
|
||||||
|
|
||||||
# End
|
# End
|
||||||
current = self._get_team_selected()
|
if timeout.reached():
|
||||||
|
logger.warning('Wait current team timeout')
|
||||||
|
break
|
||||||
|
_, current = self._get_team()
|
||||||
if current:
|
if current:
|
||||||
if current == team:
|
if current == team:
|
||||||
logger.info(f'Selected to the correct team')
|
logger.info(f'Selected to the correct team')
|
||||||
@ -69,7 +111,8 @@ class CombatTeam(UI):
|
|||||||
break
|
break
|
||||||
|
|
||||||
# Set team
|
# Set team
|
||||||
interval = Timer(2)
|
click_interval = Timer(2)
|
||||||
|
swipe_interval = Timer(2)
|
||||||
skip_first_screenshot = True
|
skip_first_screenshot = True
|
||||||
while 1:
|
while 1:
|
||||||
if skip_first_screenshot:
|
if skip_first_screenshot:
|
||||||
@ -78,22 +121,39 @@ class CombatTeam(UI):
|
|||||||
self.device.screenshot()
|
self.device.screenshot()
|
||||||
|
|
||||||
# End
|
# End
|
||||||
current = self._get_team_selected()
|
list_team, current = self._get_team()
|
||||||
logger.attr('Team', current)
|
|
||||||
if current and current == team:
|
if current and current == team:
|
||||||
logger.info(f'Selected to the correct team')
|
logger.info(f'Selected to the correct team')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# Click
|
# Click
|
||||||
if interval.reached():
|
if team in list_team:
|
||||||
self.device.click(self._team_index_to_button(team))
|
if click_interval.reached():
|
||||||
interval.reset()
|
self.device.click(index_to_button(team))
|
||||||
continue
|
click_interval.reset()
|
||||||
|
continue
|
||||||
|
# At left
|
||||||
|
elif team < min(list_team):
|
||||||
|
if swipe_interval.reached():
|
||||||
|
p1, p2 = random_rectangle_vector_opted(
|
||||||
|
(350, 0), box=TEAM_SEARCH.area, random_range=(-20, -10, 20, 10))
|
||||||
|
self.device.drag(p1, p2, name=f'TEAM_DRAG')
|
||||||
|
swipe_interval.reset()
|
||||||
|
# At right
|
||||||
|
elif team > max(list_team):
|
||||||
|
if swipe_interval.reached():
|
||||||
|
p1, p2 = random_rectangle_vector_opted(
|
||||||
|
(-350, 0), box=TEAM_SEARCH.area, random_range=(-20, -10, 20, 10))
|
||||||
|
self.device.drag(p1, p2, name=f'TEAM_DRAG')
|
||||||
|
swipe_interval.reset()
|
||||||
|
|
||||||
def handle_combat_team_prepare(self, team: int = 1) -> bool:
|
def handle_combat_team_prepare(self, team: int = 1) -> bool:
|
||||||
"""
|
"""
|
||||||
Set team and click prepare before dungeon combat.
|
Set team and click prepare before dungeon combat.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
team: Team index, 1 to 9.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
int: If clicked
|
int: If clicked
|
||||||
"""
|
"""
|
||||||
|