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.
Files changed (2) hide show
  1. package/lib/index.js +11 -6
  2. 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,值为被拍时的反击概率(%)<br/>不设置则使用默认概率'),
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
- const probability = config.specialUser[targetUserId] !== undefined
248
- ? config.specialUser[targetUserId] / 100
249
- : config.reverse / 100;
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(probability)) {
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}** 秒`,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-ll-brick",
3
3
  "description": "砖头拍人插件(克隆自 koishi-plugin-brick),非管理员时会提示",
4
- "version": "1.0.11",
4
+ "version": "1.0.12",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [