koishi-plugin-ll-brick 1.0.11 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +11 -6
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -30,10 +30,10 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
30
30
|
reverse: koishi_1.Schema.number()
|
|
31
31
|
.default(10)
|
|
32
32
|
.max(100)
|
|
33
|
-
.description('
|
|
33
|
+
.description('反拍概率(%)默认值:被拍时按此概率反击,主动拍人时按此概率免疫对方反拍(双向生效)'),
|
|
34
34
|
specialUser: koishi_1.Schema.dict(Number)
|
|
35
35
|
.role('table')
|
|
36
|
-
.description('键为用户ID
|
|
36
|
+
.description('键为用户ID,值为该用户的反拍概率(%)<br/>被拍时按此概率反击;主动拍人时按此概率免疫对方反拍<br/>填 100 即「攻防无敌」,不设置则用默认值'),
|
|
37
37
|
adminUsers: koishi_1.Schema.array(koishi_1.Schema.string())
|
|
38
38
|
.default([])
|
|
39
39
|
.description('管理员 ID 列表(openid):被加入的 ID 可以使用「充值」等管理命令'),
|
|
@@ -244,11 +244,16 @@ async function apply(ctx, config) {
|
|
|
244
244
|
}], ["userId", "guildId"]);
|
|
245
245
|
const muteTime = koishi_1.Random.int(config.minMuteTime, config.maxMuteTime);
|
|
246
246
|
const muteTimeMs = muteTime * 1000;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
247
|
+
// 反拍概率双向生效:被拍者的反击率 × (1 - 攻击者自身的反拍能力)
|
|
248
|
+
// 反拍能力 100% = 攻防无敌(拍人必中、被杀必反)
|
|
249
|
+
const probOf = (uid) => {
|
|
250
|
+
const raw = config.specialUser[uid] !== undefined ? config.specialUser[uid] : config.reverse;
|
|
251
|
+
const v = Number(raw);
|
|
252
|
+
return Number.isFinite(v) ? Math.max(0, Math.min(1, v / 100)) : 0;
|
|
253
|
+
};
|
|
254
|
+
const counterChance = probOf(targetUserId) * (1 - probOf(session.userId));
|
|
250
255
|
const isQQ = session.platform === 'qq';
|
|
251
|
-
if (koishi_1.Random.bool(
|
|
256
|
+
if (koishi_1.Random.bool(counterChance)) {
|
|
252
257
|
const muteErr = await tryMute(session.userId);
|
|
253
258
|
const msg = mdCard([
|
|
254
259
|
`${atUser(session, targetUserId)} 夺过你的砖头,把你拍晕了 **${muteTime}** 秒`,
|