Skip to content

Commit

Permalink
feat(nurturing): only update fan count from class detail
Browse files Browse the repository at this point in the history
fix #24
  • Loading branch information
NateScarlet committed Jun 6, 2021
1 parent a5f69a2 commit af4e93a
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 37 deletions.
1 change: 0 additions & 1 deletion auto_derby/imagetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import cv2.img_hash
import numpy as np
from PIL.Image import Image, fromarray
import PIL.Image


def md5(b_img: np.ndarray, *, save_path: Optional[Text] = None) -> Text:
Expand Down
9 changes: 2 additions & 7 deletions auto_derby/jobs/nurturing.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,8 @@ def _handle_race(ctx: Context):
_choose_running_style(ctx, race1)

_handle_race_result()
_, pos = action.wait_image(templates.SINGLE_MODE_RACE_NEXT_BUTTON)

with action.recover_cursor():
action.move((pos[0], pos[1]-100))
action.wheel(10)
ctx.update_by_race_result_scene(template.screenshot())
action.click(pos)
ctx.fan_count = 0 # request update in next turn
action.wait_click_image(templates.SINGLE_MODE_RACE_NEXT_BUTTON)


ALL_OPTIONS = [
Expand Down
4 changes: 0 additions & 4 deletions auto_derby/single_mode/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,6 @@ def update_by_command_scene(self, screenshot: Image) -> None:
self.wisdom = int(
ocr.text(PIL.ImageOps.invert(screenshot.crop(wisdom_bbox))))

def update_by_race_result_scene(self, screenshot: Image) -> None:
fan_count_bbox = (128, 698, 330, 716)
self.fan_count = _recognize_fan_count(screenshot.crop(fan_count_bbox))

def update_by_class_detail(self, screenshot: Image) -> None:
fan_count_bbox = (220, 523, 420, 540)
self.fan_count = _recognize_fan_count(screenshot.crop(fan_count_bbox))
Expand Down
25 changes: 0 additions & 25 deletions auto_derby/single_mode/context_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,31 +141,6 @@ def test_update_by_command_scene_issue17_2():
assert ctx.wisdom == 233, ctx.wisdom
assert ctx.mood == ctx.MOOD_VERY_GOOD, ctx.mood


def test_update_by_race_result_scene():
img = PIL.Image.open(
_TEST_DATA_PATH / "race_result_scene.png").convert("RGB")
ctx = Context()
ctx.update_by_race_result_scene(img)
assert ctx.fan_count == 1179


def test_update_by_race_result_scene_2():
img = PIL.Image.open(
_TEST_DATA_PATH / "race_result_scene_2.png").convert("RGB")
ctx = Context()
ctx.update_by_race_result_scene(img)
assert ctx.fan_count == 4073


def test_update_by_race_result_scene_3():
img = PIL.Image.open(
_TEST_DATA_PATH / "race_result_scene_3.png").convert("RGB")
ctx = Context()
ctx.update_by_race_result_scene(img)
assert ctx.fan_count == 134344, ctx.fan_count


def test_update_by_class_detail():
img = PIL.Image.open(
_TEST_DATA_PATH / "class_detail.png").convert("RGB")
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit af4e93a

Please sign in to comment.