koishi-plugin-smmcat-gensokyo 0.0.16 → 0.0.18
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/data/initProps.d.ts +4 -1
- package/lib/index.js +99 -22
- package/lib/props.d.ts +1 -0
- package/lib/users.d.ts +3 -1
- package/package.json +1 -1
package/lib/data/initProps.d.ts
CHANGED
|
@@ -10,7 +10,10 @@ export type propsTemplateData = {
|
|
|
10
10
|
type: PropType;
|
|
11
11
|
info: string;
|
|
12
12
|
price: number;
|
|
13
|
-
|
|
13
|
+
cooling?: number;
|
|
14
|
+
fn: (session: Session) => Promise<void | {
|
|
15
|
+
err: boolean;
|
|
16
|
+
}>;
|
|
14
17
|
};
|
|
15
18
|
};
|
|
16
19
|
export declare const propsData: propsTemplateData;
|
package/lib/index.js
CHANGED
|
@@ -202,7 +202,8 @@ var GensokyoMap = {
|
|
|
202
202
|
type: "冒险区" /* 冒险区 */,
|
|
203
203
|
needLv: 1,
|
|
204
204
|
top: "绿野平原一",
|
|
205
|
-
down: "野猪巢穴"
|
|
205
|
+
down: "野猪巢穴",
|
|
206
|
+
monster: [{ name: "琪露诺", lv: 10 }]
|
|
206
207
|
},
|
|
207
208
|
"绿野平原六": {
|
|
208
209
|
floor: 1,
|
|
@@ -450,7 +451,7 @@ var propsData = {
|
|
|
450
451
|
type: "消耗类" /* 消耗类 */,
|
|
451
452
|
info: "回复自身20HP",
|
|
452
453
|
price: 10,
|
|
453
|
-
fn: /* @__PURE__ */ __name(function(session) {
|
|
454
|
+
fn: /* @__PURE__ */ __name(async function(session) {
|
|
454
455
|
User.giveHPMP(session.userId, { hp: 20 }, async (val) => {
|
|
455
456
|
if (val.err) {
|
|
456
457
|
await session.send(val.err);
|
|
@@ -466,7 +467,7 @@ var propsData = {
|
|
|
466
467
|
type: "消耗类" /* 消耗类 */,
|
|
467
468
|
info: "回复自身20MP",
|
|
468
469
|
price: 10,
|
|
469
|
-
fn: /* @__PURE__ */ __name(function(session) {
|
|
470
|
+
fn: /* @__PURE__ */ __name(async function(session) {
|
|
470
471
|
User.giveHPMP(session.userId, { mp: 20 }, async (val) => {
|
|
471
472
|
if (val.err) {
|
|
472
473
|
await session.send(val.err);
|
|
@@ -482,7 +483,7 @@ var propsData = {
|
|
|
482
483
|
type: "消耗类" /* 消耗类 */,
|
|
483
484
|
info: "回复自身20MP和20HP",
|
|
484
485
|
price: 20,
|
|
485
|
-
fn: /* @__PURE__ */ __name(function(session) {
|
|
486
|
+
fn: /* @__PURE__ */ __name(async function(session) {
|
|
486
487
|
User.giveHPMP(session.userId, { hp: 20, mp: 20 }, async (val) => {
|
|
487
488
|
if (val.err) {
|
|
488
489
|
await session.send(val.err);
|
|
@@ -492,6 +493,23 @@ var propsData = {
|
|
|
492
493
|
await session.send(msg);
|
|
493
494
|
});
|
|
494
495
|
}, "fn")
|
|
496
|
+
},
|
|
497
|
+
"初级复活卷轴": {
|
|
498
|
+
name: "初级复活卷轴",
|
|
499
|
+
type: "消耗类" /* 消耗类 */,
|
|
500
|
+
info: "复活玩家,复活时保留 20% 血量。(该道具使用完需要冷却 6 分钟)",
|
|
501
|
+
price: 10,
|
|
502
|
+
cooling: 3600,
|
|
503
|
+
fn: /* @__PURE__ */ __name(async function(session) {
|
|
504
|
+
if (!User.isDie(session.userId)) {
|
|
505
|
+
session.send(`啊哈...你还没有阵亡,使用失败!`);
|
|
506
|
+
return { err: true };
|
|
507
|
+
}
|
|
508
|
+
const { maxHp } = User.getUserAttributeByUserId(session.userId);
|
|
509
|
+
User.giveLife(session.userId, Math.floor(maxHp * 0.2), async (val) => {
|
|
510
|
+
await session.send(`复活成功,当前血量:${val.currentHP}`);
|
|
511
|
+
});
|
|
512
|
+
}, "fn")
|
|
495
513
|
}
|
|
496
514
|
};
|
|
497
515
|
|
|
@@ -549,22 +567,44 @@ var Props = {
|
|
|
549
567
|
await Props.ctx.database.set("smm_gensokyo_user_props", { userId }, temp);
|
|
550
568
|
}
|
|
551
569
|
},
|
|
570
|
+
/** 使用指定道具 */
|
|
552
571
|
async userProps(session, propsName) {
|
|
553
|
-
const
|
|
572
|
+
const userId = session.userId;
|
|
573
|
+
const userPropsData = Props.userPorpsTemp[userId];
|
|
554
574
|
if (!userPropsData) return;
|
|
555
575
|
if (!userPropsData[propsName]) {
|
|
556
576
|
await session.send(`您似乎没有${propsName}这个道具...`);
|
|
557
577
|
return;
|
|
558
578
|
}
|
|
559
|
-
|
|
579
|
+
if (propsData[propsName].cooling) {
|
|
580
|
+
if (!coolingTemp[userId]) coolingTemp[userId] = {};
|
|
581
|
+
if (!coolingTemp[userId][propsName]) coolingTemp[userId][propsName] = 0;
|
|
582
|
+
const gapTime = Date.now() - coolingTemp[userId][propsName];
|
|
583
|
+
if (gapTime < propsData[propsName].cooling) {
|
|
584
|
+
await session.send(`该道具冷却还未结束,请等待${Math.ceil((coolingTemp[userId][propsName] - gapTime) / 60)}秒!`);
|
|
585
|
+
return;
|
|
586
|
+
} else {
|
|
587
|
+
coolingTemp[userId][propsName] = Date.now();
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
User.loseProps(userId, { name: propsName, val: 1 }, async (val) => {
|
|
560
591
|
if (val.err) {
|
|
561
592
|
await session.send(val.err);
|
|
562
593
|
return;
|
|
563
594
|
}
|
|
564
|
-
propsData[propsName].
|
|
595
|
+
if (propsData[propsName].cooling) {
|
|
596
|
+
coolingTemp[userId];
|
|
597
|
+
}
|
|
598
|
+
const result = await propsData[propsName].fn(session);
|
|
599
|
+
if (result && typeof result === "object" && "err" in result) {
|
|
600
|
+
if (result.err) {
|
|
601
|
+
await User.giveProps(userId, [{ name: propsName, val: 1 }]);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
565
604
|
});
|
|
566
605
|
}
|
|
567
606
|
};
|
|
607
|
+
var coolingTemp = {};
|
|
568
608
|
|
|
569
609
|
// src/monster.ts
|
|
570
610
|
var import_koishi = require("koishi");
|
|
@@ -585,7 +625,7 @@ var monsterData = {
|
|
|
585
625
|
chr: 50,
|
|
586
626
|
csr: 0,
|
|
587
627
|
evasion: 100,
|
|
588
|
-
hit:
|
|
628
|
+
hit: 0,
|
|
589
629
|
ghd: 1.2,
|
|
590
630
|
speed: 4,
|
|
591
631
|
giveExp: 10,
|
|
@@ -608,7 +648,7 @@ var monsterData = {
|
|
|
608
648
|
chr: 50,
|
|
609
649
|
csr: 0,
|
|
610
650
|
evasion: 150,
|
|
611
|
-
hit:
|
|
651
|
+
hit: 0,
|
|
612
652
|
ghd: 1.2,
|
|
613
653
|
speed: 4,
|
|
614
654
|
giveExp: 12,
|
|
@@ -631,7 +671,7 @@ var monsterData = {
|
|
|
631
671
|
chr: 200,
|
|
632
672
|
csr: 0,
|
|
633
673
|
evasion: 200,
|
|
634
|
-
hit:
|
|
674
|
+
hit: 0,
|
|
635
675
|
ghd: 1.2,
|
|
636
676
|
speed: 4,
|
|
637
677
|
giveExp: 15,
|
|
@@ -640,6 +680,29 @@ var monsterData = {
|
|
|
640
680
|
{ name: "蓝药", val: 3, radomVal: 30 },
|
|
641
681
|
{ name: "初级万能药", val: 2, radomVal: 90, const: true, lv: 5 }
|
|
642
682
|
]
|
|
683
|
+
},
|
|
684
|
+
"琪露诺": {
|
|
685
|
+
name: "琪露诺",
|
|
686
|
+
type: "野怪" /* 野怪 */,
|
|
687
|
+
info: "常常被称呼笨蛋的冰之妖精,有时也被叫⑨",
|
|
688
|
+
pic: "http://smmcat.cn/run/gensokyo/琪露诺.png",
|
|
689
|
+
hp: 100,
|
|
690
|
+
maxHp: 100,
|
|
691
|
+
mp: 40,
|
|
692
|
+
maxMp: 40,
|
|
693
|
+
atk: 22,
|
|
694
|
+
def: 5,
|
|
695
|
+
chr: 100,
|
|
696
|
+
csr: 0,
|
|
697
|
+
evasion: 100,
|
|
698
|
+
hit: -800,
|
|
699
|
+
ghd: 1.2,
|
|
700
|
+
speed: 4,
|
|
701
|
+
giveExp: 15,
|
|
702
|
+
giveMonetary: 3,
|
|
703
|
+
giveProps: [
|
|
704
|
+
{ name: "初级复活卷轴", val: 1, radomVal: 50 }
|
|
705
|
+
]
|
|
643
706
|
}
|
|
644
707
|
};
|
|
645
708
|
|
|
@@ -700,7 +763,18 @@ var Monster = {
|
|
|
700
763
|
Object.keys(monster).forEach((i) => {
|
|
701
764
|
temp[i] = monster[i];
|
|
702
765
|
if (useBenchmark[i]) {
|
|
703
|
-
|
|
766
|
+
const upVal = Math.floor(temp[i] * (useBenchmark[i] - 1) * (lv - 1));
|
|
767
|
+
if (upVal > 0) {
|
|
768
|
+
temp[i] += upVal;
|
|
769
|
+
} else {
|
|
770
|
+
switch (i) {
|
|
771
|
+
case "hit":
|
|
772
|
+
temp[i] += 20 * (lv - 1);
|
|
773
|
+
break;
|
|
774
|
+
default:
|
|
775
|
+
break;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
704
778
|
}
|
|
705
779
|
});
|
|
706
780
|
return temp;
|
|
@@ -717,8 +791,8 @@ var Monster = {
|
|
|
717
791
|
【攻击力】${atk}
|
|
718
792
|
【防御力】${def}
|
|
719
793
|
【闪避值】${evasion}
|
|
720
|
-
【命中值】${hit}
|
|
721
794
|
【速度值】${speed}
|
|
795
|
+
【命中率】${(hit / 10 + 100).toFixed(1)}%
|
|
722
796
|
【暴击率】${(chr / 10).toFixed(1)}%
|
|
723
797
|
【爆伤倍率】${(ghd * 100).toFixed(0)}%` + (propsList?.length ? `
|
|
724
798
|
【概率掉落道具】` + propsList.join("、") : "") + (info ? "\n\n" + info : "");
|
|
@@ -1335,7 +1409,7 @@ MP:${item.mp}/${item.maxMp + item.gain.maxMp}`);
|
|
|
1335
1409
|
props.length && await User.giveProps(agent.userId, props, async (val2) => {
|
|
1336
1410
|
const propsDict = {};
|
|
1337
1411
|
val2.currentProps.forEach((item) => {
|
|
1338
|
-
if (!propsDict[item.name]) propsDict[item.name] =
|
|
1412
|
+
if (!propsDict[item.name]) propsDict[item.name] = 0;
|
|
1339
1413
|
propsDict[item.name]++;
|
|
1340
1414
|
});
|
|
1341
1415
|
const msg2 = Object.keys(propsDict).map((item) => {
|
|
@@ -1692,7 +1766,7 @@ ${Object.keys(UserOccDict).map((i) => `【${i}】:${UserOccDict[i].info}`).join(
|
|
|
1692
1766
|
await User.setDatabaseUserAttribute(userId);
|
|
1693
1767
|
},
|
|
1694
1768
|
/** 给予玩家复活 */
|
|
1695
|
-
async giveLife(userId, val) {
|
|
1769
|
+
async giveLife(userId, val, fn) {
|
|
1696
1770
|
const userInfo = User.userTempData[userId];
|
|
1697
1771
|
if (!val) {
|
|
1698
1772
|
const { maxHp } = User.getUserAttributeByUserId(userId);
|
|
@@ -1701,6 +1775,7 @@ ${Object.keys(UserOccDict).map((i) => `【${i}】:${UserOccDict[i].info}`).join(
|
|
|
1701
1775
|
userInfo.hp = val;
|
|
1702
1776
|
}
|
|
1703
1777
|
await User.setDatabaseUserAttribute(userId);
|
|
1778
|
+
fn && await fn({ currentHP: userInfo.hp });
|
|
1704
1779
|
},
|
|
1705
1780
|
/** 给予玩家血量或者蓝量 */
|
|
1706
1781
|
async giveHPMP(userId, value, fn) {
|
|
@@ -1843,19 +1918,21 @@ ${Object.keys(UserOccDict).map((i) => `【${i}】:${UserOccDict[i].info}`).join(
|
|
|
1843
1918
|
const upProps = [];
|
|
1844
1919
|
for (const item of props) {
|
|
1845
1920
|
const propsItem = propsData[item.name];
|
|
1846
|
-
if (!
|
|
1847
|
-
userProps[item.name]
|
|
1848
|
-
name
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1921
|
+
if (!propsData[item.name]) continue;
|
|
1922
|
+
if (!userProps[item.name]) {
|
|
1923
|
+
userProps[item.name] = {
|
|
1924
|
+
name: propsItem.name,
|
|
1925
|
+
type: propsItem.type,
|
|
1926
|
+
value: 0
|
|
1927
|
+
};
|
|
1928
|
+
}
|
|
1852
1929
|
userProps[item.name].value += item.val || 1;
|
|
1853
1930
|
upProps.push({ name: item.name, val: userProps[item.name].value });
|
|
1854
1931
|
}
|
|
1932
|
+
await Props.setDatabasePropsData(userId);
|
|
1855
1933
|
fn && await fn({
|
|
1856
1934
|
currentProps: upProps
|
|
1857
1935
|
});
|
|
1858
|
-
await Props.setDatabasePropsData(userId);
|
|
1859
1936
|
},
|
|
1860
1937
|
/** 去除玩家指定道具 */
|
|
1861
1938
|
async loseProps(userId, props, fn) {
|
|
@@ -1885,10 +1962,10 @@ ${Object.keys(UserOccDict).map((i) => `【${i}】:${UserOccDict[i].info}`).join(
|
|
|
1885
1962
|
}
|
|
1886
1963
|
userProps[props.name].value -= props.val || 1;
|
|
1887
1964
|
if (userProps[props.name].value == 0) delete userProps[props.name];
|
|
1965
|
+
await Props.setDatabasePropsData(userId);
|
|
1888
1966
|
fn && await fn({
|
|
1889
1967
|
currentProps: { name: props.name, val: userProps[props.name]?.value || 0 }
|
|
1890
1968
|
});
|
|
1891
|
-
await Props.setDatabasePropsData(userId);
|
|
1892
1969
|
},
|
|
1893
1970
|
/** 目标是否死亡 */
|
|
1894
1971
|
isDie(userId) {
|
package/lib/props.d.ts
CHANGED
package/lib/users.d.ts
CHANGED
|
@@ -105,7 +105,9 @@ export declare const User: {
|
|
|
105
105
|
/** 给予玩家死亡 */
|
|
106
106
|
giveDie(userId: string): Promise<void>;
|
|
107
107
|
/** 给予玩家复活 */
|
|
108
|
-
giveLife(userId: string, val?: number
|
|
108
|
+
giveLife(userId: string, val?: number, fn?: (updata: {
|
|
109
|
+
currentHP: number;
|
|
110
|
+
}) => Promise<void>): Promise<void>;
|
|
109
111
|
/** 给予玩家血量或者蓝量 */
|
|
110
112
|
giveHPMP(userId: string, value: {
|
|
111
113
|
hp?: number;
|