Add: Prepare combat team
BIN
assets/cn/combat/team/COMBAT_TEAM_PREPARE.BUTTON.png
Normal file
After Width: | Height: | Size: 8.3 KiB |
BIN
assets/cn/combat/team/COMBAT_TEAM_PREPARE.png
Normal file
After Width: | Height: | Size: 8.0 KiB |
BIN
assets/share/combat/team/TEAM_1.png
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
assets/share/combat/team/TEAM_2.png
Normal file
After Width: | Height: | Size: 8.1 KiB |
BIN
assets/share/combat/team/TEAM_3.png
Normal file
After Width: | Height: | Size: 8.2 KiB |
BIN
assets/share/combat/team/TEAM_4.png
Normal file
After Width: | Height: | Size: 8.0 KiB |
BIN
assets/share/combat/team/TEAM_5.png
Normal file
After Width: | Height: | Size: 8.0 KiB |
BIN
assets/share/combat/team/TEAM_6.png
Normal file
After Width: | Height: | Size: 8.1 KiB |
75
tasks/combat/assets/assets_combat_team.py
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
from module.base.button import Button, ButtonWrapper
|
||||||
|
|
||||||
|
# This file was auto-generated, do not modify it manually. To generate:
|
||||||
|
# ``` python -m dev_tools.button_extract ```
|
||||||
|
|
||||||
|
COMBAT_TEAM_PREPARE = ButtonWrapper(
|
||||||
|
name='COMBAT_TEAM_PREPARE',
|
||||||
|
cn=Button(
|
||||||
|
file='./assets/cn/combat/team/COMBAT_TEAM_PREPARE.png',
|
||||||
|
area=(1037, 648, 1116, 667),
|
||||||
|
search=(1017, 628, 1136, 687),
|
||||||
|
color=(159, 159, 159),
|
||||||
|
button=(958, 641, 1193, 676),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
TEAM_1 = ButtonWrapper(
|
||||||
|
name='TEAM_1',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/combat/team/TEAM_1.png',
|
||||||
|
area=(432, 32, 467, 63),
|
||||||
|
search=(412, 12, 487, 83),
|
||||||
|
color=(142, 134, 127),
|
||||||
|
button=(432, 32, 467, 63),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
TEAM_2 = ButtonWrapper(
|
||||||
|
name='TEAM_2',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/combat/team/TEAM_2.png',
|
||||||
|
area=(531, 32, 572, 63),
|
||||||
|
search=(511, 12, 592, 83),
|
||||||
|
color=(142, 136, 129),
|
||||||
|
button=(531, 32, 572, 63),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
TEAM_3 = ButtonWrapper(
|
||||||
|
name='TEAM_3',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/combat/team/TEAM_3.png',
|
||||||
|
area=(631, 32, 673, 63),
|
||||||
|
search=(611, 12, 693, 83),
|
||||||
|
color=(135, 128, 117),
|
||||||
|
button=(631, 32, 673, 63),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
TEAM_4 = ButtonWrapper(
|
||||||
|
name='TEAM_4',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/combat/team/TEAM_4.png',
|
||||||
|
area=(731, 32, 774, 63),
|
||||||
|
search=(711, 12, 794, 83),
|
||||||
|
color=(129, 121, 113),
|
||||||
|
button=(731, 32, 774, 63),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
TEAM_5 = ButtonWrapper(
|
||||||
|
name='TEAM_5',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/combat/team/TEAM_5.png',
|
||||||
|
area=(831, 32, 873, 63),
|
||||||
|
search=(811, 12, 893, 83),
|
||||||
|
color=(139, 129, 117),
|
||||||
|
button=(831, 32, 873, 63),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
TEAM_6 = ButtonWrapper(
|
||||||
|
name='TEAM_6',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/combat/team/TEAM_6.png',
|
||||||
|
area=(931, 32, 973, 63),
|
||||||
|
search=(911, 12, 993, 83),
|
||||||
|
color=(133, 124, 113),
|
||||||
|
button=(931, 32, 973, 63),
|
||||||
|
),
|
||||||
|
)
|
84
tasks/combat/team.py
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
from module.base.button import ButtonWrapper
|
||||||
|
from module.base.timer import Timer
|
||||||
|
from module.logger import logger
|
||||||
|
from tasks.base.ui import UI
|
||||||
|
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,
|
||||||
|
2: TEAM_2,
|
||||||
|
3: TEAM_3,
|
||||||
|
4: TEAM_4,
|
||||||
|
5: TEAM_5,
|
||||||
|
6: TEAM_6,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class CombatTeam(UI):
|
||||||
|
@staticmethod
|
||||||
|
def _team_index_to_button(index: int) -> ButtonWrapper:
|
||||||
|
try:
|
||||||
|
return TEAM_BUTTONS[index]
|
||||||
|
except KeyError:
|
||||||
|
logger.warning(f'Invalid team index: {index}, return team 1 instead')
|
||||||
|
return TEAM_1
|
||||||
|
|
||||||
|
def _get_team_selected(self) -> int:
|
||||||
|
for index, button in TEAM_BUTTONS.items():
|
||||||
|
if self.image_color_count(button, color=(255, 234, 191), threshold=221, count=50):
|
||||||
|
return index
|
||||||
|
|
||||||
|
# logger.warning(f'No team selected')
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def team_set(self, team: int = 1, skip_first_screenshot=True):
|
||||||
|
"""
|
||||||
|
Args:
|
||||||
|
team: Team index, 1 to 6.
|
||||||
|
skip_first_screenshot:
|
||||||
|
|
||||||
|
Pages:
|
||||||
|
in: page_team
|
||||||
|
"""
|
||||||
|
logger.info(f'Team set: {team}')
|
||||||
|
interval = Timer(2)
|
||||||
|
while 1:
|
||||||
|
if skip_first_screenshot:
|
||||||
|
skip_first_screenshot = False
|
||||||
|
else:
|
||||||
|
self.device.screenshot()
|
||||||
|
|
||||||
|
# End
|
||||||
|
current = self._get_team_selected()
|
||||||
|
logger.attr('Team', current)
|
||||||
|
if current and current == team:
|
||||||
|
logger.info(f'Selected to the correct team')
|
||||||
|
break
|
||||||
|
|
||||||
|
# Click
|
||||||
|
if interval.reached():
|
||||||
|
self.device.click(self._team_index_to_button(team))
|
||||||
|
interval.reset()
|
||||||
|
continue
|
||||||
|
|
||||||
|
def handle_combat_team_prepare(self, team: int = 1) -> bool:
|
||||||
|
"""
|
||||||
|
Set team and click prepare before dungeon combat.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
int: If clicked
|
||||||
|
"""
|
||||||
|
if self.appear(COMBAT_TEAM_PREPARE, interval=5):
|
||||||
|
self.team_set(team)
|
||||||
|
self.device.click(COMBAT_TEAM_PREPARE)
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|