Skip to content

Commit

Permalink
Merge pull request #83 from LmeSzinc/dev
Browse files Browse the repository at this point in the history
Bug fix
  • Loading branch information
LmeSzinc authored Sep 10, 2023
2 parents 2f845bd + d4bd437 commit 55a2575
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 108 deletions.
57 changes: 7 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,27 @@

# StarRailCopilot

Star Rail auto script | 星铁副驾驶,崩坏:星穹铁道脚本,基于下一代Alas框架。
Star Rail auto script | 星铁速溶茶,崩坏:星穹铁道脚本,基于下一代Alas框架。

## 安装

### 获取源码

SRC 还在开发中,暂时不提供自动安装包,需要以正常流程安装。
## 功能

Clone 这个项目。
- **打本**:每日副本,双倍活动副本。
- **收获**:尽量完成每日任务,委托,无名勋礼。
- **后台托管**:自动启动模拟器和游戏,后台托管清体力和每日。

```bash
git clone https://github.com/LmeSzinc/StarRailCopilot
```

进入项目目录。

```bash
cd StarRailCopilot
```
## 安装 [![](https://img.shields.io/github/downloads/LmeSzinc/StarRailCopilot/total?color=4e4c97)](https://github.com/LmeSzinc/StarRailCopilot/releases)

使用 conda 新建 python 3.10.10 环境,假设新环境的名字叫 `src`

> 注意:我们不维护更高或者更低版本的依赖,建议使用 3.10.10
```bash
conda create -n src python==3.10.10
```

激活刚刚创建的虚拟环境。

```bash
conda activate src
```

安装 requirements.txt 中的依赖。

```bash
pip install -r requirements.txt
```

### 安装模拟器

1. 下载 [ADB](https://developer.android.com/tools/releases/platform-tools) 并配置到环境变量中。
1. 在模拟器里安装游戏,而不是桌面端,建议使用最牛批的 MuMu 12,次选蓝叠模拟器。
[中文安装教程](https://github.com/LmeSzinc/StarRailCopilot/wiki/Installation_cn),包含自动安装教程,使用教程,手动安装教程。

> **为什么使用模拟器?** 如果你用桌面端来运行脚本的话,游戏窗口必须保持在前台,我猜你也不想运行脚本的时候不能动鼠标键盘像个傻宝一样坐在那吧,所以用模拟器。
> **模拟器的性能表现如何?** Lme 的 8700k+1080ti 使用 MuMu 12 模拟器画质设置非常高是有 40fps 的,如果你的配置稍微新一点的话,特效最高 60fps 不是问题。
## 使用

还是在刚才的虚拟环境中,启动 GUI 后端(默认开在 22367 端口)。

```bash
python gui.py
```

在浏览器访问 `127.0.0.1:22367`

`SRC设置` - `模拟器设置` - `模拟器Serial` 中按照帮助文本填写。

进入 `总览` 界面,点击 `启动` 按钮。(SRC 将自动启动模拟器和游戏,如果它们没在运行的话,模拟器启动目前只支持 MuMu 系和夜神系模拟器)

保持脚本运行,SRC 将在体力恢复的时候自动登录清体力。建议将 `SRC设置` - `优化设置` - `当任务队列清空后` 设置为 `关闭游戏` 以节省资源。

## 开发

Expand Down
57 changes: 7 additions & 50 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +2,27 @@

# StarRailCopilot

Star Rail Copilot, a bot for Honkai: Star Rail, based on the next generation ALAS framework.
Star Rail Instant Tea, a bot for Honkai: Star Rail, based on the next generation of ALAS framework.

# Install

### Get source code

SRC is still in development, does not have an auto-installer yet, requires classic python project deployment.
## Features

Clone this repository.
- **Dungeons**: Dungeons, dungeons at double event
- **Rewards**: Complete daily quests if possible, Assignment, Nameless Hourner.
- **AFK Auto Farming**: Automatically launch emulators and games, do dungeons and quests in the background.

```bash
git clone https://github.com/LmeSzinc/StarRailCopilot
```

Enter project directory.

```bash
cd StarRailCopilot
```
## Install [![](https://img.shields.io/github/downloads/LmeSzinc/StarRailCopilot/total?color=4e4c97)](https://github.com/LmeSzinc/StarRailCopilot/releases)

Create a python 3.10.10 environment using conda. Let's say the new environment is named `src`.

>Note that we don't maintain requirements for lower or higher python versions, 3.10.10 is recommended.
```bash
conda create -n src python==3.10.10
```

Activate the environment just created.

```bash
conda activate src
```

Install requirements.

```
pip install -r requirements.txt
```

### Install an Emulator

1. Download [ADB](https://developer.android.com/tools/releases/platform-tools) and configure it into environment variables.
2. Install the game client in emulator, not the desktop client. BlueStacks is recommented.
Refers to [Installation tutorial](https://github.com/LmeSzinc/StarRailCopilot/wiki/Installation_cn), including easy-installer manual, use manual, manual installation tutorial.

> **Why use emulators?** If you run a bot on the desktop client, game windows must stay at front. I guess you don't wanna baby-sit there without being able to move the mouse and keyboard while running the bot, so use the emulators.
> **How's the performance?** Lme's 8700k+1080ti using MuMu12 emulator with graphic settings very high gets 40 fps. It shouldn't be a problem to run with maximum graphic settings and 60 fps if you have newer PC specs.
## Usage

Still in the environment just now, launch the GUI backend. (running on port 22367 by default)

```bash
python gui.py
```

Access `127.0.0.1:22367` in browser.

Goto `SRC settings` - `Emulator Settings` - `Serial`, fill it according to help texts.

Goto `Overview` page, click `Run` button. (SRC will auto launch emulator and game client if they are not running. Emulator launch only supports MuMu family and Nox Player family for now)

Keep the bot running, SRC will auto login and empty trailblaze power when it's recovered. To save resources, set `SRC Settings` - `Optimazation Settings` - `When Task Queue is Empty` to `Close Game`.

## Development

Expand Down
8 changes: 4 additions & 4 deletions deploy/Windows/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ def git_repository_init(
self.execute(f'"{self.git}" --no-pager log --no-merges -1')
Progress.GitShowVersion()

def git_over_cdn(self):
@property
def goc_client(self):
client = GitOverCdnClient(
url='https://vip.123pan.cn/1815343254/pack/LmeSzinc_StarRailCopilot_master',
folder=self.root_filepath,
)
client.logger = logger
_ = client.update(keep_changes=self.KeepLocalChanges)
return _
return client

def git_install(self):
logger.hr('Update Alas', 0)
Expand All @@ -146,7 +146,7 @@ def git_install(self):
return

if self.GitOverCdn:
if self.git_over_cdn():
if self.goc_client.update(keep_changes=self.KeepLocalChanges):
return

self.git_repository_init(
Expand Down
17 changes: 17 additions & 0 deletions deploy/git_over_cdn/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,23 @@ def git_reset(self, keep_changes=False):
else:
self.git_command('reset', '--hard', f'{self.source}/{self.branch}')

def is_uptodate(self):
"""
Returns:
bool: If repo is up-to-date
"""
_ = self.current_commit
_ = self.latest_commit
if not self.current_commit:
self.logger.error('Failed to get current commit')
return False
if not self.latest_commit:
self.logger.error('Failed to get latest commit')
return False
if self.current_commit == self.latest_commit:
self.logger.info('Already up to date')
return True

def update(self, keep_changes=False):
"""
Args:
Expand Down
2 changes: 1 addition & 1 deletion module/ocr/ocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import timedelta

import cv2
from ppocronnx.predict_system import BoxedResult
from pponnxcr.predict_system import BoxedResult

import module.config.server as server
from module.base.button import ButtonWrapper
Expand Down
5 changes: 4 additions & 1 deletion module/ocr/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import itertools

from ppocronnx.predict_system import BoxedResult
from pponnxcr.predict_system import BoxedResult

from module.base.utils import area_in_area, area_offset

Expand Down Expand Up @@ -45,6 +45,9 @@ def merge_buttons(buttons: list[BoxedResult], thres_x=20, thres_y=20) -> list[Bo
Returns:
"""
if thres_x <= 0 and thres_y <= 0:
return buttons

dic_button = {button.box: button for button in buttons}
set_merged = set()
for left, right in itertools.combinations(dic_button.items(), 2):
Expand Down
2 changes: 1 addition & 1 deletion module/webui/process_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def run_process(
if State.electron:
# https://github.com/LmeSzinc/AzurLaneAutoScript/issues/2051
logger.info("Electron detected, remove log output to stdout")
from module.logger import console_hdlr
from module.logger.logger import console_hdlr
logger.removeHandler(console_hdlr)
set_func_logger(func=q.put)

Expand Down
9 changes: 9 additions & 0 deletions module/webui/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ def get_commit(self, revision="", n=1, short_sha1=False) -> Tuple:

def _check_update(self) -> bool:
self.state = "checking"

if State.deploy_config.GitOverCdn:
if self.goc_client.is_uptodate():
logger.info(f"No update")
return False
else:
logger.info(f"New update available")
return True

source = "origin"
for _ in range(3):
if self.execute(
Expand Down
2 changes: 1 addition & 1 deletion tasks/forgotten_hall/ui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cv2
import numpy as np
from ppocronnx.predict_system import BoxedResult
from pponnxcr.predict_system import BoxedResult

from module.base.base import ModuleBase
from module.base.timer import Timer
Expand Down

0 comments on commit 55a2575

Please sign in to comment.