Skip to content

Commit

Permalink
Merge pull request #73 from Night-stars-1:dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Night-stars-1 committed Jul 22, 2024
2 parents 3f5657a + 8c692f1 commit 3c67d6b
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 26 deletions.
28 changes: 11 additions & 17 deletions auto/huashi/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Author: Night-stars-1 nujj1042633805@gmail.com
Date: 2024-04-08 19:51:16
LastEditTime: 2024-05-11 00:35:10
LastEditTime: 2024-07-10 18:16:02
LastEditors: Night-stars-1 nujj1042633805@gmail.com
"""

Expand All @@ -11,15 +11,15 @@
from loguru import logger

from core.model.config import config
from core.preset import (
click,
get_city,
go_home,
go_outlets,
ocr_click,
wait,
wait_time,
)
from core.preset import click, get_city, go_home, go_outlets, ocr_click, wait, wait_time

CITYS = [
"7号自由港",
"澄明数据中心",
"曼德矿场",
"修格里城",
"阿妮塔发射中心",
]


def join():
Expand All @@ -32,13 +32,7 @@ def start():
logger.info(f"开始购买桦石")
if time.time() - config.rest_area.huashi.runtime > 86400:
city = get_city()
if city in [
"七号自由港",
"澄明数据中心",
"曼德矿场",
"修格里城",
"阿妮塔发射中心",
]:
if city in CITYS:
join()

wait("rest_area/rest_area_logo.png", (918, 48), (1049, 153), 10)
Expand Down
2 changes: 1 addition & 1 deletion auto/run_business/buy.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def click_buy_button():
input_tap((1056, 647))
time.sleep(1)
image = screenshot()
bgr = get_bgr(image, (1177, 459))
bgr = get_bgr(image, (1177, 459), 5)
logger.debug(f"购买物品界面颜色检查: {bgr}")
if bgr != [2, 133, 253] and bgr != [251, 253, 253]:
return True
Expand Down
2 changes: 1 addition & 1 deletion auto/run_business/sell.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def click_sell_button():
input_tap((1056, 647))
time.sleep(1)
image = screenshot()
bgr = get_bgr(image, (1175, 470))
bgr = get_bgr(image, (1175, 470), 5)
logger.debug(f"出售物品界面颜色检查: {bgr}")
if bgr == [227, 131, 82]:
logger.info("检测到包含本地商品")
Expand Down
114 changes: 114 additions & 0 deletions commit_templates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{
"$schema": "https://bendera.github.io/vscode-commit-message-editor/schemas/config-v1.schema.json",
"configVersion": "1",
"staticTemplate": [
"feat: 简短描述",
"",
"消息正文",
"",
"消息页脚"
],
"dynamicTemplate": [
"{type}{scope}: {description}",
"",
"{body}",
"",
"{breaking_change}{footer}"
],
"tokens": [
{
"label": "类型",
"name": "type",
"type": "enum",
"options": [
{
"label": "---",
"value": ""
},
{
"label": "build",
"description": "影响构建系统或外部依赖的更改(示例范围:gulp, broccoli, npm)"
},
{
"label": "chore",
"description": "更新grunt任务等;没有生产代码变更"
},
{
"label": "ci",
"description": "对CI配置文件和脚本的更改(示例范围:Travis, Circle, BrowserStack, SauceLabs)"
},
{
"label": "docs",
"description": "仅文档更改"
},
{
"label": "feat",
"description": "新功能"
},
{
"label": "fix",
"description": "修复错误"
},
{
"label": "perf",
"description": "提高性能的代码更改"
},
{
"label": "refactor",
"description": "既不修复错误也不添加功能的代码更改"
},
{
"label": "revert"
},
{
"label": "style",
"description": "不影响代码含义的更改(空格、格式、缺少分号等)"
},
{
"label": "test",
"description": "添加缺失的测试或更正现有的测试"
}
],
"description": "更改类型"
},
{
"label": "范围",
"name": "scope",
"description": "一个范围可以为提交类型提供额外的上下文信息,并包含在括号内,例如,“feat(parser): 添加解析数组的功能”。",
"type": "text",
"multiline": false,
"prefix": "(",
"suffix": ")"
},
{
"label": "简短描述",
"name": "description",
"description": "主题行中的简短描述。",
"type": "text",
"multiline": false
},
{
"label": "正文",
"name": "body",
"description": "可选正文",
"type": "text",
"multiline": true,
"lines": 5,
"maxLines": 10
},
{
"label": "重大变更",
"name": "breaking_change",
"type": "boolean",
"value": "重大变更:",
"default": false
},
{
"label": "页脚",
"name": "footer",
"description": "可选页脚",
"type": "text",
"multiline": true
}
]
}
3 changes: 2 additions & 1 deletion core/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def get_bgr(
pos=(0, 0),
cropped_pos1: Tuple[int, int] = (0, 0),
cropped_pos2: Tuple[int, int] = (0, 0),
offset=0,
):
"""
说明:
Expand All @@ -94,7 +95,7 @@ def get_bgr(
]
pos = (pos[0] - cropped_pos1[0], pos[1] - cropped_pos1[1])
color = image[pos[1], pos[0]]
return BGR(*color, offset=0)
return BGR(*color, offset=offset)


def get_hsv(
Expand Down
9 changes: 7 additions & 2 deletions core/ocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pathlib import Path
from typing import Tuple, Union

from loguru import logger
import numpy as np
from cnocr import CnOcr
from PIL import Image
Expand Down Expand Up @@ -65,7 +66,9 @@ def predict(
cropped_pos1[1] : cropped_pos2[1], cropped_pos1[0] : cropped_pos2[0]
]
out = ocr.ocr(img_fp)
return ocrout2result(out, cropped_pos1)
result = ocrout2result(out, cropped_pos1)
logger.debug(result)
return result


def number_predict(
Expand All @@ -85,4 +88,6 @@ def number_predict(
cropped_pos1[1] : cropped_pos2[1], cropped_pos1[0] : cropped_pos2[0]
]
out = number_ocr.ocr(img_fp)
return ocrout2result(out, cropped_pos1)
result = ocrout2result(out, cropped_pos1)
logger.debug(result)
return result
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 11 additions & 4 deletions tests/tools/get_pos.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"""
Author: Night-stars-1 nujj1042633805@gmail.com
Date: 2024-04-25 23:03:03
LastEditors: Night-stars-1 nujj1042633805@gmail.com
LastEditTime: 2024-07-22 18:33:47
"""

"""
Author: Night-stars-1 nujj1042633805@gmail.com
Date: 2024-04-01 23:06:19
Expand All @@ -14,9 +21,9 @@

import cv2

from core.adb.adb import connect, screenshot
# from core.adb.adb import connect, screenshot

connect("127.0.0.1:16384")
# connect("127.0.0.1:16384")


# 澄明数据中心 (1049, 345) 7号自由港 (665, 577) 阿妮塔战备工厂 (832, 664) 阿妮塔发射中心 (164, 420+577) 阿妮塔能源研究所 (614, 454+577)
Expand All @@ -33,8 +40,8 @@ def click_event(event, x, y, flags, param):
print("Color (HSV): ", color_hsv.tolist())


image = screenshot()
# image = cv2.imread("resources/test/MuMu12-20240422-002758.png")
# image = screenshot()
image = cv2.imread("resources/test/ae930c5ab35cd1fcda946fe4e74f8896.png")
"""
Clicked at: (626, 273)
Color (BGR): [181, 199, 14]
Expand Down

0 comments on commit 3c67d6b

Please sign in to comment.