Skip to content

Commit

Permalink
feat(single-mode): support aoharu final race
Browse files Browse the repository at this point in the history
close #172
  • Loading branch information
NateScarlet committed Sep 4, 2021
1 parent 2be8781 commit bbe4a81
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 19 deletions.
51 changes: 32 additions & 19 deletions auto_derby/jobs/nurturing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from ..scenes.single_mode import (
AoharuBattleConfirmScene,
AoharuCompetitorScene,
AoharuMainScene,
CommandScene,
RaceMenuScene,
RaceTurnsIncorrect,
Expand Down Expand Up @@ -133,31 +134,43 @@ def _func(ac: _ActionContext):


def _handle_aoharu_team_race(ac: _ActionContext):
rp = action.resize_proxy()
x, y = ac.pos
ctx = ac.ctx
action.tap((x, y + rp.vector(10, 540)))
scene = AoharuMainScene.enter(ctx)
scene.recognize()
scene.go_race()

for index in range(3):
scene = AoharuCompetitorScene.enter(ctx)
scene.choose_competitor(index)
if scene.is_final:
action.wait_tap_image(templates.SINGLE_MODE_AOHARU_FINAL_BATTLE_BUTTON)
action.wait_tap_image(templates.GREEN_BATTLE_BUTTON)
scene = AoharuBattleConfirmScene.enter(ctx)
scene.recognize_predictions()
if (
len(
tuple(
i
for i in scene.predictions.values()
if i in (RacePrediction.HONNMEI, RacePrediction.TAIKOU)
return
else:
for index in range(3):
scene = AoharuCompetitorScene.enter(ctx)
scene.choose_competitor(index)
action.wait_tap_image(templates.GREEN_BATTLE_BUTTON)
scene = AoharuBattleConfirmScene.enter(ctx)
scene.recognize_predictions()
if (
len(
tuple(
i
for i in scene.predictions.values()
if i in (RacePrediction.HONNMEI, RacePrediction.TAIKOU)
)
)
)
>= 3
):
break
>= 3
):
break

action.wait_tap_image(templates.GREEN_BATTLE_BUTTON)
action.wait_tap_image(templates.SINGLE_MODE_AOHARU_RACE_RESULT_BUTTON)
tmpl, pos = action.wait_image(
templates.SINGLE_MODE_AOHARU_RACE_RESULT_BUTTON,
templates.SINGLE_MODE_AOHARU_MAIN_RACE_BUTTON,
)
action.tap(pos)
if tmpl.name == templates.SINGLE_MODE_AOHARU_MAIN_RACE_BUTTON:
action.wait_tap_image(templates.GO_TO_RACE_BUTTON)
action.wait_tap_image(templates.RACE_START_BUTTON)

while True:
tmpl, pos = action.wait_image(
Expand Down
1 change: 1 addition & 0 deletions auto_derby/scenes/single_mode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
from .training import TrainingScene
from .aoharu_battle_confirm import AoharuBattleConfirmScene
from .aoharu_competitor import AoharuCompetitorScene
from .aoharu_main import AoharuMainScene
34 changes: 34 additions & 0 deletions auto_derby/scenes/single_mode/aoharu_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# pyright: strict

from __future__ import annotations


from ... import action, templates
from ...scenes import Scene
from ..scene import Scene, SceneHolder


class AoharuMainScene(Scene):
def __init__(self) -> None:
super().__init__()
self.is_final = False

@classmethod
def name(cls):
return "single-mode-aoharu-main"

@classmethod
def _enter(cls, ctx: SceneHolder) -> Scene:
if ctx.scene.name() == "single-mode-aoharu-competitor":
action.wait_tap_image(templates.RETURN_BUTTON)
action.wait_image(templates.SINGLE_MODE_AOHARU_FORMAL_RACE_BANNER)
return cls()

def go_race(self) -> None:
rp = action.resize_proxy()
action.tap(rp.vector2((265, 805), 540))

def recognize(self) -> None:
self.is_final = (
action.count_image(templates.SINGLE_MODE_AOHARU_FINAL_BANNER) > 0
)
8 changes: 8 additions & 0 deletions auto_derby/templates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
GO_HOME_BUTTON = "go_home_button.png"
GO_HOME_BUTTON_POS = "go_home_button.pos.png"
GO_TO_LIMITED_SALE = "go_to_limited_sale.png"
GO_TO_RACE_BUTTON = "go_to_race_button.png"
GREEN_BATTLE_BUTTON = "green_battle_button.png"
GREEN_NEXT_BUTTON = "green_next_button.png"
GREEN_OK_BUTTON = "green_ok_button.png"
Expand Down Expand Up @@ -93,10 +94,17 @@
SINGLE_MODE_AOHARU_CHOOSE_COMPETITOR_POS = (
"single_mode_aoharu_choose_competitor.pos.png"
)
SINGLE_MODE_AOHARU_FINAL_BANNER = "single_mode_aoharu_final_banner.png"
SINGLE_MODE_AOHARU_FINAL_BATTLE_BUTTON = "single_mode_aoharu_final_battle_button.png"
SINGLE_MODE_AOHARU_FINAL_BATTLE_BUTTON_POS = (
"single_mode_aoharu_final_battle_button.pos.png"
)
SINGLE_MODE_AOHARU_FORMAL_RACE_BANNER = "single_mode_aoharu_formal_race_banner.png"
SINGLE_MODE_AOHARU_FORMAL_RACE_BANNER_POS = (
"single_mode_aoharu_formal_race_banner.pos.png"
)
SINGLE_MODE_AOHARU_MAIN_RACE_BUTTON = "single_mode_aoharu_main_race_button.png"
SINGLE_MODE_AOHARU_MAIN_RACE_BUTTON_POS = "single_mode_aoharu_main_race_button.pos.png"
SINGLE_MODE_AOHARU_RACE_RESULT_BUTTON = "single_mode_aoharu_race_result_button.png"
SINGLE_MODE_AOHARU_RACE_RESULT_BUTTON_POS = (
"single_mode_aoharu_race_result_button.pos.png"
Expand Down
Binary file added auto_derby/templates/go_to_race_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bbe4a81

Please sign in to comment.