Skip to content

Commit

Permalink
Merge pull request #12 from Night-stars-1/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Night-stars-1 authored Apr 14, 2024
2 parents f79c2b5 + 4d0e9c0 commit b67e9b0
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"name": "Python 调试程序: 当前文件",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/test.py",
"program": "${workspaceFolder}/demo.py",
"console": "integratedTerminal"
}
]
Expand Down
4 changes: 2 additions & 2 deletions auto/run_business/buy.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-04 17:54:58
LastEditTime: 2024-04-12 22:55:38
LastEditTime: 2024-04-14 23:25:56
LastEditors: Night-stars-1 nujj1042633805@gmail.com
"""

Expand Down Expand Up @@ -61,7 +61,7 @@ def buy_good(good: str, book: int, max_book: int, again: bool = False):
if pos:
hsv = get_hsv(image, (564, 667 if pos[1] + 22 > 720 else pos[1] + 22))
logger.debug(f"是否进货检测: {hsv}")
if hsv[-1] >= 200:
if hsv[-1] >= 220:
if book < max_book:
use_book(pos, book)
return (
Expand Down
9 changes: 6 additions & 3 deletions auto/run_business/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-05 17:14:29
LastEditTime: 2024-04-14 23:11:11
LastEditTime: 2024-04-15 00:15:34
LastEditors: Night-stars-1 nujj1042633805@gmail.com
"""

Expand Down Expand Up @@ -75,7 +75,7 @@ def run(
)
else:
route = get_goods_info_srap(
city_book, skill_level, max_goods_num, station_level
city_book, skill_level, station_level, max_goods_num
)
city_name = get_city()
if route.city_data[0].sell_city_name == city_name:
Expand All @@ -90,7 +90,10 @@ def run(
click_station(city.buy_city_name).wait()
go_business("buy")
buy_business(
city.buy_goods + list(city.normal_goods.keys()), 20, max_book=city.book
[good_name for good in city.buy_goods for good_name in good]
+ list(city.normal_goods.keys()),
20,
max_book=city.book,
)
go_home()
click_station(city.sell_city_name).wait()
Expand Down
9 changes: 6 additions & 3 deletions core/goods/shop.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def get_pending_purchase(self, buy_city_name: str, sell_city_name: str, type_="g
all_profit = profit * num
# print(f"{buy_city_name}<=>{sell_city_name}:{name}=>{sell_price} {rate_price}")
if profit >= self.city_book["priceThreshold"] or good.isSpeciality:
target.buy_goods.append(name)
target.buy_goods.append({name: profit})
target.goods_data.setdefault(name, RouteModel.GoodsData())
target.goods_data[name].num += num
target.goods_data[name].buy_price += buy_price
Expand All @@ -329,8 +329,7 @@ def get_pending_purchase(self, buy_city_name: str, sell_city_name: str, type_="g
target.buy_price += buy_price * num
target.sell_price += sell_price * num
else:
target.normal_goods.setdefault(name, 0)
target.normal_goods[name] += all_profit
target.normal_goods.setdefault(name, profit)
target.tired_profit = round5(target.profit / city_tired)
target.book_profit = target.book and round5(target.profit / target.book)
return target
Expand Down Expand Up @@ -394,11 +393,15 @@ def get_optimal_route(self):
key=lambda item: item[1],
)
}
# 根据利润重新排序商品,避免高价值商品因为满载而无法购买
# optimal_route.city_data[0].buy_goods = sorted(optimal_route.city_data[0].buy_goods, key=lambda item: next(iter(item.values())), reverse=True)
optimal_route.city_data[1].normal_goods = {
k: v
for k, v in sorted(
optimal_route.city_data[1].normal_goods.items(),
key=lambda item: item[1],
)
}
# 根据利润重新排序商品,避免高价值商品因为满载而无法购买
# optimal_route.city_data[1].buy_goods = sorted(optimal_route.city_data[1].buy_goods, key=lambda item: next(iter(item.values())), reverse=True)
return optimal_route
2 changes: 1 addition & 1 deletion core/models/city_goods.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class GoodsData(BaseModel):
"""出售城市"""
goods_data: Dict[str, GoodsData] = {}
"""商品数据"""
buy_goods: List[str] = []
buy_goods: List[Dict[str, int]] = []
"""待购商品列表"""
normal_goods: Dict[str, int] = {}
"""低价值商品"""
Expand Down
14 changes: 5 additions & 9 deletions core/presets/presets.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-05 17:24:47
LastEditTime: 2024-04-12 22:14:42
LastEditTime: 2024-04-14 23:25:19
LastEditors: Night-stars-1 nujj1042633805@gmail.com
"""

Expand Down Expand Up @@ -197,15 +197,11 @@ def go_home():
"""
logger.info("返回主界面")

def wait_home():
while (
match_screenshot(screenshot(), "resources/main_map.png")["max_val"] < 0.95
):
time.sleep(1)
while (
match_screenshot(screenshot(), "resources/main_map.png")["max_val"] < 0.95
):
time.sleep(1)

input_tap((228, 27))
wait_home()
input_tap((228, 27))


def wait_fight_end():
Expand Down
2 changes: 2 additions & 0 deletions demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

if __name__ == "__main__":
run(
"127.0.0.1:7555",
"resources\\lib\\adb",
{
"7号自由港": 3,
"修格里城": 3,
Expand Down

0 comments on commit b67e9b0

Please sign in to comment.