File tree Expand file tree Collapse file tree 3 files changed +148
-0
lines changed Expand file tree Collapse file tree 3 files changed +148
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ lang : zh-cn
3
+ title : 编写新的TRPG规则
4
+ ---
5
+
6
+ # 编写新的TRPG规则
7
+
8
+ ::: info 本节内容
9
+
10
+ 本节将介绍如何添加一个新的TRPG游戏规则到海豹,主要涉及的部分是添加规则模板和指令编写。
11
+
12
+ :::
13
+
14
+ ## 规则模板是什么?有什么功能?
15
+
16
+ 这里假设我们创建了一个叫做摸鱼大赛的trpg规则,简称为fish规则。
17
+
18
+ 规则模板从早期的同义词模板发展而来,他能为我们的fish规则提供以下帮助:
19
+
20
+ 1 . 可以直接使用set fish ,然后对应的fish扩展会自动打开,默认骰子也变更为六面骰
21
+
22
+ 2 . st show的内容会改变,coc相关的几个主属性不会再强制排在最前
23
+
24
+ 3 . 角色属性可以摆脱coc同义词的影响,同样coc的默认值也不会再影响fish规则了
25
+
26
+ 4 . 可以自定义fish规则自己的同义词,包括简繁写法、缩写等内容
27
+
28
+ 5 . 可以影响sn指令,添加一条sn fish来标注对当前规则重要的属性在玩家名片上
29
+
30
+ 6 . fish规则人物卡会成为与内置的coc、dnd平级的专门卡片,有独立的技能默认值,以及二级属性计算等机制
31
+
32
+
33
+ ## 那么,要怎么做?
34
+
35
+ 我们已经写了一个比较完善的示例,可以参考这里,有大量的详细注释:
36
+
37
+ https://github.com/sealdice/javascript/blob/main/examples_ts/013.%E8%87%AA%E5%AE%9A%E4%B9%89TRPG%E6%B8%B8%E6%88%8F%E8%A7%84%E5%88%99.ts
38
+
39
+ 上面是TypeScript文件,可直接执行的js版本在这里:
40
+
41
+ https://github.com/sealdice/javascript/blob/main/examples/013.%E8%87%AA%E5%AE%9A%E4%B9%89TRPG%E6%B8%B8%E6%88%8F%E8%A7%84%E5%88%99.js
42
+
43
+ 大部分配置由代码中的数据文件来进行。
44
+
45
+ 关于指令编写的部分,可以参考js文档。
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ index: false
5
5
- [ 快速开始] ( ./quick-start.md )
6
6
- [ 迁移] ( ./transfer.md )
7
7
- [ 特色功能] ( ./special_feature.md )
8
+ - [ 数据库检查和修复] ( ./db-repair.md )
8
9
- 平台
9
10
- [ QQ] ( ./platform-qq.md )
10
11
- [ KOOK] ( ./platform-kook.md )
Original file line number Diff line number Diff line change
1
+ ---
2
+ lang : zh-cn
3
+ title : 数据库检查和修复
4
+ ---
5
+
6
+ # 数据库检查和修复
7
+
8
+ ::: info 本节内容
9
+
10
+ 本节内容描述了如何对海豹的数据库进行完整性检查,同时在遇到问题时如何进行修复。
11
+
12
+ 数据库损坏有时会在突发断电,或者硬盘受到物理损坏时发生。
13
+
14
+ :::
15
+
16
+ ## 确定问题
17
+
18
+ 如果你发现录卡会在重启海豹后丢失,数据库文件变得很大(通常在200MB以上),建议对数据库进行完整性检查。
19
+
20
+ 首先,通过托盘右键退出的方式,停止海豹的运行,然后稍作等待,以确保数据被写入硬盘。
21
+
22
+ 随后,使用命令行程序进入海豹的目录,执行(如果对使用命令行感到困难,后面有一个简化的替代方案):
23
+
24
+ ```
25
+ sealdice-core /db-check
26
+ ```
27
+
28
+ 输出结果如下:
29
+ ```
30
+ >sealdice-core /db-check
31
+ ok
32
+ ok
33
+ ok
34
+ 数据库检查结果:
35
+ data.db: true
36
+ data-logs.db: true
37
+ data-censor.db: true
38
+ ```
39
+
40
+ 这代表数据库是正常的,海豹的三个数据库文件:
41
+
42
+ data.db - 人物卡和群内临时卡
43
+ data-logs.db - 跑团日志
44
+ data-censor.db - 敏感词库
45
+
46
+ 如果你对使用命令行感到困难,可以这样做:
47
+
48
+ 打开记事本,将以下内容复制进去:
49
+ ```
50
+ sealdice-core /db-check
51
+ pause
52
+ ```
53
+
54
+ 然后保存为“检查.cmd”,或者“check.cmd”,保存在海豹的主程序所在目录,或者保存完复制过去。
55
+
56
+ 然后双击“检查.cmd”执行他,之后同上。
57
+
58
+
59
+ ## 修复数据库 - 通过回滚备份
60
+
61
+ 一般来说,首选的修复方式是通过备份,因为这样可以完美修复,同时损失的数据时间范围是确定的,发现得早可能就是一两天(默认会12小时自动备份一次)。
62
+
63
+ 当你做了完整性检查之后,现在你已经知道是哪个数据文件坏掉了。
64
+
65
+ 现在找出最近的几个备份,替换 data/defualt/ 目录下对应的 db 文件回之前的版本。
66
+
67
+ 因为不能确定什么时候开始出问题,在完成替换后建议再做一次完整性检查,如果还有问题就替换更早的版本。
68
+
69
+
70
+ ## 修复数据库 - 通过数据库修复指令
71
+
72
+ 这种办法有一定的操作难度,酌情进行使用。这里我们以windows系统为例,其他操作系统大同小异
73
+
74
+ 首先需要下载一个 sqlite.exe,可以从其官网 https://www.sqlite.org/download.html ,找到 Precompiled Binaries for Windows 进行下载
75
+
76
+ 下载完成后,找出sqlite.exe放到空目录备用,注意sqlite必须是3.40以上版本,不然没有.recover指令。
77
+
78
+ 接下来,将损坏的数据文件(如data.db)从海豹的data/defualt/目录中复制出来,放在和sqlite.exe同一个目录。
79
+
80
+ 再之后,使用命令行工具打开这个目录,在此目录下,执行下面的指令:
81
+
82
+ 导出数据:
83
+ ```
84
+ sqlite3.exe data.db
85
+ .output 1.sql
86
+ .recover
87
+ .exit
88
+ ```
89
+
90
+ 恢复数据到a.db
91
+ ```
92
+ sqlite3.exe a.db
93
+ .read 1.sql
94
+ delete from attrs_group where id is null;
95
+ delete from attrs_user where id is null;
96
+ delete from group_info where id is null;
97
+ delete from attrs_group_user where id is null;
98
+ delete from ban_info where id is null;
99
+ delete from group_player_info where id is null;
100
+ ```
101
+
102
+ 接下来这个a.db就是修好的数据库了,将其复制回海豹的原路径,并改名回data.db即可。
You can’t perform that action at this time.
0 commit comments