Files
hfb_price_tool/README.md
T
2026-10-25 15:02:41 +08:00

156 lines
4.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 哈夫币发布计算器
一个独立的 Go + Wails 桌面工具,只计算**号主到手价**。输入保险格数、账号状态、哈弗币数量和物品数量后立即出结果。
界面按「保险格数 + 特殊状态 + 哈弗币 + 物品清单 + 底部分结果」布局,规则支持本地配置和从线上同步。
## 计算口径
```text
参考比例 = 保险基础比例
+ 缺配惩罚(红皮/刀皮/砖皮/满体力/满负重,每缺一项 +1)
+ 大额币修正(>130M +1;>230M +2.5;>380M +4;>530M +5)
+ 每日损耗修正(10/20/30/40/50M → +0/+1/+2/+3/+4)
最终比例 = clamp(加速比例, 参考比例, 参考比例 + 加速上限)
纯币到手 = 哈弗币万数 ÷ 最终比例
物品到手 = Σ(数量 × 单价) // 免费项不计
合计到手 = 纯币到手 + 物品到手
```
注意:比例数字越大,号主到手越低。加速出售是主动把比例调高、降低价格。
默认规则与 `hfb_sys` 主站发布口径一致:
- 保险基础比例:`3*3=40`、`2*3=42`、`2*2=47`、`2*1=48`
- 缺配项:刀皮、角色红皮、满体力、满负重、武器皮肤
- 大额修正:130M / 230M / 380M / 530M 四档
- 每日损耗:10M 到 50M
- 物品单价:AWM 子弹、6 级子弹、6 级头盔、6 级护甲、巴雷特子弹、顶级保险卡、咖啡豆、子弹零件、45 格大红包
`3*3` 保险下「顶级保险卡 / 9 格体验卡」按主站规则禁用。
## 本地运行
```bash
wails dev
```
Wails 程序不能用 `go run .` 启动;直接运行会缺少 Wails 需要的构建标签。
## 构建
macOS:
```bash
wails build
```
Windows exe(在 macOS 上可直接交叉编译,文件名自动带版本号):
```bash
wails build -platform windows/amd64 -o hfb_price_tool-v1.0.1.exe
```
> 不要加 `-nopackage`。加上它会跳过 Windows 资源打包,导致 exe 没有自定义图标、版本属性和应用清单。
Windows 安装包:
```bash
wails build -platform windows/amd64 -nsis
```
生成物在 `build/bin/`。最终 Windows 文件名示例:`hfb_price_tool-v1.0.1.exe`。
图标文件:
- `build/appicon.png`:macOS / 通用图标源图
- `build/windows/icon.ico`:Windows exe 图标(包含 16/24/32/48/64/128/256 多尺寸)
- `build/windows/info.json`:Windows 版本属性
- `build/windows/wails.exe.manifest`:Windows 应用清单
## 规则配置
右上角「配置」可以编辑:
- 基础比例
- 缺配惩罚
- 大额修正
- 物品单价 / 单位 / 停用
- 每日损耗选项、加速上限
本地配置保存在:
- Windows:`%AppData%\hfb-price-tool\config.json`
- macOS:`~/Library/Application Support/hfb-price-tool/config.json`
配置弹窗支持导入、导出和打开配置目录。首次启动会自动写入一份默认规则。
## 线上同步
「线上同步」调用主站公开接口:
```text
GET {地址}/api/listing-publish-options
```
默认地址:`https://hao858.com`
同步只覆盖:
- `ratio_config.insurance_base_ratios`
- `ratio_config.config_items`
- `ratio_config.coin_corrections`
- `quantity_items`
每日损耗选项、加速上限、本地物品停用状态会保留。同步成功后自动保存到本地配置。
接口响应结构:
```json
{
"code": "ok",
"message": "ok",
"data": {
"ratio_config": {},
"quantity_items": []
}
}
```
## 验证
```bash
go test ./...
cd frontend && npm run build
```
关键用例:`226M + 9格 + 5 项特殊状态全未勾选 + 每日损耗 10M`
```text
比例 = 40 + 5 + 1 = 46
226M = 22600 万
22600 ÷ 46 = 491.304... → ¥491.30
```
该用例固定在 `internal/pricing/calc_test.go`。
## 版本号
版本号的唯一来源是 `wails.json` 的 `info.productVersion`:
- Windows exe 的版本资源由它生成
- 界面右上角的版本号由 `frontend/vite.config.js` 在构建时读取同一字段注入
升级版本时只改这一处,然后重新构建。
## 目录
```text
app.go Wails 绑定、本地配置、线上同步、导入导出
main.go 窗口入口
internal/pricing/ 定价核心与单测
frontend/src/main.js 界面与交互
frontend/src/style.css 样式
```