This repository has been archived by the owner on Dec 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path属性公示.js
90 lines (84 loc) · 3.51 KB
/
属性公示.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// ==UserScript==
// @name 属性公示
// @author 简律纯
// @version 1.0.3
// @description .d atk <属性值>//录入攻击属性\n.d def <属性值>//录入防御属性\n.d wit <属性值>//录入防御属性\n.d show //[权限]公开属性\n.d clear //[权限]清空属性列表
// 2023-04-03
// @license by-nc-sa 4.0
// @homepageURL https://github.com/HsiangNianian/sealdice
// ==/UserScript==
let ext = seal.ext.find('adw');
if (!ext) {
ext = seal.ext.new('adw', '简律纯', '1.0.3');
seal.ext.register(ext);
}
// 在模块顶部定义 data 变量
let data = {
atk: {},
def: {},
wit: {}
};
const adw = seal.ext.newCmdItemInfo();
adw.name = 'adw';
adw.help = '.d atk <属性值>//录入攻击属性\n.d def <属性值>//录入防御属性\n.d wit <属性值>//录入防御属性\n.d show //[权限]公开属性\n.d clear //[权限]清空属性列表';
adw.solve = (ctx, msg, cmdArgs) => {
const match = msg.message.trim().split(/\s+/)
const type = match[1]; // 指令类型
const value = parseInt(match[2]); // 数据值
if (value !== value) {
switch (type) {
case 'show':
if (ctx.privilegeLevel === 100) {
let output = '攻击\n';
for (const [name, value] of Object.entries(data.atk)) {
output += `<${name}>: ${value}\n`;
}
output += '\n防御\n';
for (const [name, value] of Object.entries(data.def)) {
output += `<${name}>: ${value}\n`;
}
output += '\n见证\n';
for (const [name, value] of Object.entries(data.wit)) {
output += `<${name}>: ${value}\n`;
}
seal.replyToSender(ctx, msg, `${output}`);// 发送到主群
return seal.ext.newCmdExecuteResult(true);
} else {
seal.replyToSender(ctx, msg, `你不是我的Master!`);
return seal.ext.newCmdExecuteResult(true);
}
case 'clear':
if (ctx.privilegeLevel === 100) {
data.atk = {};
data.def = {};
data.wit = {};
seal.replyToSender(ctx, msg, `已清空√`);
return seal.ext.newCmdExecuteResult(true);
} else {
seal.replyToSender(ctx, msg, `你不是我的Master!`);
return seal.ext.newCmdExecuteResult(true);
}
default:
seal.replyToSender(ctx, msg, adw.help);
}
} else {
switch (type) {
case 'atk':
data[type][`${msg.sender.nickname}`] = value; // 保存数据
seal.replyToSender(ctx, msg, `已录入攻击值√`);
break;
case 'def':
data[type][`${msg.sender.nickname}`] = value; // 保存数据
seal.replyToSender(ctx, msg, `已录入防御值√`);
break;
case 'wit':
data[type][`${msg.sender.nickname}`] = value; // 保存数据
seal.replyToSender(ctx, msg, `已录入见证值√`);
break;
default:
seal.replyToSender(ctx, msg, adw.help);
}
}
}
// 将指令添加到命令映射中
ext.cmdMap['d'] = adw;