koishi-plugin-smmcat-gensokyo 0.0.13 → 0.0.14

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.
@@ -0,0 +1,56 @@
1
+ /** 怪物等级增益算法 */
2
+ type MonsterBenchmark = {
3
+ [keys: number | string]: {
4
+ /** 血量 */
5
+ hp: number;
6
+ /** 最大血量 */
7
+ maxHp: number;
8
+ /** 蓝量 */
9
+ mp: number;
10
+ /** 最大蓝量 */
11
+ maxMp: number;
12
+ /** 攻击力 */
13
+ atk: number;
14
+ /** 防御力 */
15
+ def: number;
16
+ /** 暴击率 */
17
+ chr: number;
18
+ /** 暴击伤害 */
19
+ ghd: number;
20
+ /** 闪避值 */
21
+ evasion: number;
22
+ /** 命中值 */
23
+ hit: number;
24
+ /** 出手速度 */
25
+ speed: number;
26
+ };
27
+ };
28
+ export type UserBenchmark = {
29
+ [keys: number]: {
30
+ /** 最大经验 */
31
+ maxExp: number;
32
+ /** 最大血量 */
33
+ maxHp: number;
34
+ /** 最大蓝量 */
35
+ maxMp: number;
36
+ /** 攻击力 */
37
+ atk: number;
38
+ /** 防御力 */
39
+ def: number;
40
+ /** 暴击率 */
41
+ chr: number;
42
+ /** 暴击伤害 */
43
+ ghd: number;
44
+ /** 闪避值 */
45
+ evasion: number;
46
+ /** 命中值 */
47
+ hit: number;
48
+ /** 出手速度 */
49
+ speed: number;
50
+ };
51
+ };
52
+ /** 怪物等级公式 */
53
+ export declare const monsterBenchmark: MonsterBenchmark;
54
+ /** 玩家等级公式 */
55
+ export declare const userBenchmark: UserBenchmark;
56
+ export {};
@@ -1,63 +1,52 @@
1
+ /**
2
+ * 默认怪物集群
3
+ */
4
+ /** 怪物基础属性 */
5
+ export type MonsterBaseAttribute = {
6
+ /** 凭据ID */
7
+ id?: number;
8
+ /** 怪物名称 */
9
+ name: string;
10
+ /** 怪物说明 */
11
+ info?: string;
12
+ /** 怪物配图 */
13
+ pic?: string;
14
+ /** 类型 */
15
+ type: MonsterOccupation;
16
+ /** 血量 */
17
+ hp: number;
18
+ /** 最大血量 */
19
+ maxHp: number;
20
+ /** 蓝量 */
21
+ mp: number;
22
+ /** 最大蓝量 */
23
+ maxMp: number;
24
+ /** 攻击力 */
25
+ atk: number;
26
+ /** 防御力 */
27
+ def: number;
28
+ /** 暴击率 */
29
+ chr: number;
30
+ /** 暴击伤害 */
31
+ ghd: number;
32
+ /** 暴击抵抗 */
33
+ csr: number;
34
+ /** 闪避值 */
35
+ evasion: number;
36
+ /** 命中值 */
37
+ hit: number;
38
+ /** 出手速度 */
39
+ speed: number;
40
+ /** 获得经验 */
41
+ giveExp: number;
42
+ /** 获得货币 */
43
+ giveMonetary: number;
44
+ };
45
+ export type MonsterTempData = {
46
+ [keys: string]: MonsterBaseAttribute;
47
+ };
1
48
  export declare enum MonsterOccupation {
2
49
  野怪 = "\u91CE\u602A",
3
50
  BOSS = "BOSS"
4
51
  }
5
- export declare const monsterData: {
6
- 小蜜蜂: {
7
- name: string;
8
- type: MonsterOccupation;
9
- info: string;
10
- pic: string;
11
- hp: number;
12
- maxHp: number;
13
- mp: number;
14
- maxMp: number;
15
- atk: number;
16
- def: number;
17
- chr: number;
18
- csr: number;
19
- evasion: number;
20
- hit: number;
21
- ghd: number;
22
- speed: number;
23
- giveExp: number;
24
- };
25
- 小蜘蛛: {
26
- name: string;
27
- type: MonsterOccupation;
28
- info: string;
29
- pic: string;
30
- hp: number;
31
- maxHp: number;
32
- mp: number;
33
- maxMp: number;
34
- atk: number;
35
- def: number;
36
- chr: number;
37
- csr: number;
38
- evasion: number;
39
- hit: number;
40
- ghd: number;
41
- speed: number;
42
- giveExp: number;
43
- };
44
- dora: {
45
- name: string;
46
- type: MonsterOccupation;
47
- info: string;
48
- pic: string;
49
- hp: number;
50
- maxHp: number;
51
- mp: number;
52
- maxMp: number;
53
- atk: number;
54
- def: number;
55
- chr: number;
56
- csr: number;
57
- evasion: number;
58
- hit: number;
59
- ghd: number;
60
- speed: number;
61
- giveExp: number;
62
- };
63
- };
52
+ export declare const monsterData: MonsterTempData;
@@ -0,0 +1,15 @@
1
+ import { DatabaseUserAttribute } from "../users";
2
+ export declare enum PropType {
3
+ 消耗类 = "\u6D88\u8017\u7C7B",
4
+ 礼包类 = "\u793C\u5305\u7C7B",
5
+ 任务道具 = "\u4EFB\u52A1\u9053\u5177"
6
+ }
7
+ export type propsTemplateData = {
8
+ [keys: string]: {
9
+ name: string;
10
+ type: PropType;
11
+ info: string;
12
+ price: number;
13
+ fn: (user: DatabaseUserAttribute) => void;
14
+ };
15
+ };
package/lib/index.js CHANGED
@@ -361,6 +361,132 @@ var GensokyoMap = {
361
361
  }
362
362
  };
363
363
 
364
+ // src/data/benchmark.ts
365
+ var monsterBenchmark = {
366
+ 10: {
367
+ hp: 1.4,
368
+ maxHp: 1.4,
369
+ mp: 1.2,
370
+ maxMp: 1.2,
371
+ atk: 1.2,
372
+ def: 1.1,
373
+ chr: 1.1,
374
+ evasion: 1.1,
375
+ hit: 1.1,
376
+ ghd: 1,
377
+ speed: 1.05
378
+ },
379
+ 20: {
380
+ hp: 1.35,
381
+ maxHp: 1.35,
382
+ mp: 1.1,
383
+ maxMp: 1.1,
384
+ atk: 1.1,
385
+ def: 1.1,
386
+ chr: 1.08,
387
+ evasion: 1.08,
388
+ hit: 1.08,
389
+ ghd: 1,
390
+ speed: 1.05
391
+ },
392
+ 40: {
393
+ hp: 1.2,
394
+ maxHp: 1.2,
395
+ mp: 1.05,
396
+ maxMp: 1.05,
397
+ atk: 1.1,
398
+ def: 1.05,
399
+ chr: 1.05,
400
+ evasion: 1.05,
401
+ hit: 1.05,
402
+ ghd: 1.05,
403
+ speed: 1.05
404
+ }
405
+ };
406
+ var userBenchmark = {
407
+ 10: {
408
+ maxExp: 2,
409
+ maxHp: 1.2,
410
+ maxMp: 1.1,
411
+ atk: 1.12,
412
+ def: 1.1,
413
+ chr: 1.08,
414
+ evasion: 1.08,
415
+ hit: 1.08,
416
+ ghd: 1,
417
+ speed: 1.05
418
+ },
419
+ 20: {
420
+ maxExp: 1.8,
421
+ maxHp: 1.15,
422
+ maxMp: 1.1,
423
+ atk: 1.1,
424
+ def: 1.1,
425
+ chr: 1.04,
426
+ evasion: 1.04,
427
+ hit: 1.04,
428
+ ghd: 1,
429
+ speed: 1.05
430
+ },
431
+ 40: {
432
+ maxExp: 1.5,
433
+ maxHp: 1.1,
434
+ maxMp: 1.05,
435
+ atk: 1.1,
436
+ def: 1.05,
437
+ chr: 1.03,
438
+ evasion: 1.03,
439
+ hit: 1.03,
440
+ ghd: 1.05,
441
+ speed: 1.05
442
+ }
443
+ };
444
+
445
+ // src/props.ts
446
+ var Props = {
447
+ config: {},
448
+ ctx: {},
449
+ userPorpsTemp: {},
450
+ async init(config, ctx) {
451
+ Props.config = config;
452
+ Props.ctx = ctx;
453
+ ctx.database.extend("smm_gensokyo_user_props", {
454
+ userId: "string",
455
+ props: "json"
456
+ }, {
457
+ primary: "userId",
458
+ autoInc: false
459
+ });
460
+ const temp = {};
461
+ const propsList = await ctx.database.get("smm_gensokyo_user_props", {});
462
+ propsList.forEach((item) => {
463
+ temp[item.userId] = item.props;
464
+ });
465
+ Props.userPorpsTemp = temp;
466
+ },
467
+ /** 创建本地数据 */
468
+ async initUserPropsData(userId) {
469
+ if (!Props.userPorpsTemp[userId]) {
470
+ Props.userPorpsTemp[userId] = {};
471
+ const temp = {
472
+ userId,
473
+ props: {}
474
+ };
475
+ await Props.ctx.database.create("smm_gensokyo_user_props", temp);
476
+ }
477
+ },
478
+ /** 更新本地数据库对应数据 */
479
+ async setDatabasePropsData(userId) {
480
+ const propsData = Props.userPorpsTemp[userId];
481
+ if (propsData) {
482
+ const temp = {
483
+ props: propsData
484
+ };
485
+ await Props.ctx.database.set("smm_gensokyo_user_props", { userId }, temp);
486
+ }
487
+ }
488
+ };
489
+
364
490
  // src/users.ts
365
491
  var UserOccDict = {
366
492
  ["剑士" /* 剑士 */]: {
@@ -456,7 +582,8 @@ var User = {
456
582
  lv: "integer",
457
583
  hp: "integer",
458
584
  mp: "integer",
459
- pp: "integer"
585
+ pp: "integer",
586
+ isDie: "boolean"
460
587
  },
461
588
  {
462
589
  primary: "userId",
@@ -493,47 +620,9 @@ var User = {
493
620
  userId: UserDict.userId
494
621
  };
495
622
  const lv = UserData.lv;
496
- const benchmark = {
497
- 10: {
498
- maxExp: 2,
499
- maxHp: 1.2,
500
- maxMp: 1.1,
501
- atk: 1.12,
502
- def: 1.1,
503
- chr: 1.08,
504
- evasion: 1.08,
505
- hit: 1.08,
506
- ghd: 1,
507
- speed: 1.05
508
- },
509
- 20: {
510
- maxExp: 1.8,
511
- maxHp: 1.15,
512
- maxMp: 1.1,
513
- atk: 1.1,
514
- def: 1.1,
515
- chr: 1.04,
516
- evasion: 1.04,
517
- hit: 1.04,
518
- ghd: 1,
519
- speed: 1.05
520
- },
521
- 40: {
522
- maxExp: 1.5,
523
- maxHp: 1.1,
524
- maxMp: 1.05,
525
- atk: 1.1,
526
- def: 1.05,
527
- chr: 1.03,
528
- evasion: 1.03,
529
- hit: 1.03,
530
- ghd: 1.05,
531
- speed: 1.05
532
- }
533
- };
534
623
  const temp = {};
535
- const lvScope = Object.keys(benchmark).reverse().find((item) => Number(item) < lv) || 10;
536
- const useBenchmark = benchmark[lvScope];
624
+ const lvScope = Object.keys(userBenchmark).reverse().find((item) => Number(item) < lv) || 10;
625
+ const useBenchmark = userBenchmark[lvScope];
537
626
  Object.keys(UserData).forEach((i) => {
538
627
  temp[i] = UserData[i];
539
628
  if (useBenchmark[i]) {
@@ -585,10 +674,12 @@ ${Object.keys(UserOccDict).map((i) => `【${i}】:${UserOccDict[i].info}`).join(
585
674
  pp: UserOccDict[jobType].initStatus.pp,
586
675
  mp: UserOccDict[jobType].initStatus.mp,
587
676
  lv: 1,
588
- exp: 0
677
+ exp: 0,
678
+ isDie: false
589
679
  };
590
680
  User.ctx.database.create("smm_gensokyo_user_attribute", temp);
591
681
  User.userTempData[session.userId] = temp;
682
+ await Props.initUserPropsData(session.userId);
592
683
  await session.send("创建成功!\n" + User.userAttributeTextFormat(session.userId));
593
684
  },
594
685
  /** 信息格式化 */
@@ -656,9 +747,100 @@ ${Object.keys(UserOccDict).map((i) => `【${i}】:${UserOccDict[i].info}`).join(
656
747
  }
657
748
  await User.setDatabaseUserAttribute(userId);
658
749
  },
750
+ /** 给予玩家死亡 */
751
+ async giveDie(userId) {
752
+ const userInfo = User.userTempData[userId];
753
+ userInfo.hp = 0;
754
+ userInfo.isDie = true;
755
+ await User.setDatabaseUserAttribute(userId);
756
+ },
757
+ /** 给予玩家恢复 */
758
+ async giveLife(userId, val) {
759
+ const userInfo = User.userTempData[userId];
760
+ if (!val) {
761
+ const { maxHp } = User.getUserAttributeByUserId(userId);
762
+ userInfo.hp = maxHp;
763
+ } else {
764
+ userInfo.hp = val;
765
+ }
766
+ await User.setDatabaseUserAttribute(userId);
767
+ },
768
+ /** 给予玩家血量或者蓝量 */
769
+ async giveHPMP(userId, value, fn) {
770
+ const userInfo = User.userTempData[userId];
771
+ if (!userInfo) return;
772
+ if (userInfo.isDie) {
773
+ fn && await fn({
774
+ currentHP: 0,
775
+ currentMP: 0,
776
+ err: "角色已死亡,无法使用恢复道具。"
777
+ });
778
+ return;
779
+ }
780
+ const { maxHp, maxMp } = User.getUserAttributeByUserId(userId);
781
+ if (userInfo.hp + (value.hp || 0) < maxHp) {
782
+ userInfo.hp += value.hp || 0;
783
+ } else {
784
+ userInfo.hp = maxHp;
785
+ }
786
+ if (userInfo.mp + (value.mp || 0) < maxHp) {
787
+ userInfo.mp += value.mp || 0;
788
+ } else {
789
+ userInfo.mp = maxMp;
790
+ }
791
+ fn && await fn({
792
+ currentHP: userInfo.hp,
793
+ currentMP: userInfo.mp
794
+ });
795
+ await User.setDatabaseUserAttribute(userId);
796
+ },
797
+ /** 给予玩家PP值 */
798
+ async givePP(userId, value, fn) {
799
+ const userInfo = User.userTempData[userId];
800
+ if (!userInfo) return;
801
+ const { maxPp } = User.getUserAttributeByUserId(userId);
802
+ if (userInfo.pp + value < maxPp) {
803
+ userInfo.pp += value;
804
+ } else {
805
+ userInfo.pp = maxPp;
806
+ }
807
+ fn && await fn({
808
+ currentPP: userInfo.pp
809
+ });
810
+ await User.setDatabaseUserAttribute(userId);
811
+ },
812
+ /** 给予玩家货币 */
813
+ async giveMonetary(userId, val, fn) {
814
+ const [bindData] = await User.ctx.database.get("binding", { pid: userId });
815
+ if (bindData && val) {
816
+ const [currentM] = await User.ctx.database.get("monetary", { uid: bindData.aid });
817
+ await User.ctx.monetary.gain(bindData.aid, val);
818
+ fn && fn({ val, currentVal: currentM.value += val });
819
+ }
820
+ },
821
+ /** 收取玩家货币 */
822
+ async lostMonetary(userId, val, fn) {
823
+ const [bindData] = await User.ctx.database.get("binding", { pid: userId });
824
+ if (bindData && val) {
825
+ const [currentM] = await User.ctx.database.get("monetary", { uid: bindData.aid });
826
+ if (currentM.value - val < 0) {
827
+ fn && fn({
828
+ val: Math.abs(val),
829
+ currentVal: currentM.value,
830
+ err: "余额不足!"
831
+ });
832
+ return;
833
+ }
834
+ await User.ctx.monetary.cost(bindData.aid, val);
835
+ fn && fn({
836
+ val: Math.abs(val),
837
+ currentVal: currentM.value - val
838
+ });
839
+ }
840
+ },
659
841
  /** 目标是否死亡 */
660
842
  isDie(userId) {
661
- return User.userTempData[userId]?.hp <= 0;
843
+ return User.userTempData[userId]?.isDie;
662
844
  }
663
845
  };
664
846
 
@@ -684,7 +866,8 @@ var monsterData = {
684
866
  hit: 1e3,
685
867
  ghd: 1.2,
686
868
  speed: 4,
687
- giveExp: 10
869
+ giveExp: 10,
870
+ giveMonetary: 2
688
871
  },
689
872
  "小蜘蛛": {
690
873
  name: "小蜘蛛",
@@ -703,7 +886,8 @@ var monsterData = {
703
886
  hit: 1e3,
704
887
  ghd: 1.2,
705
888
  speed: 4,
706
- giveExp: 12
889
+ giveExp: 12,
890
+ giveMonetary: 2
707
891
  },
708
892
  "dora": {
709
893
  name: "dora",
@@ -722,7 +906,8 @@ var monsterData = {
722
906
  hit: 1e3,
723
907
  ghd: 1.2,
724
908
  speed: 4,
725
- giveExp: 15
909
+ giveExp: 15,
910
+ giveMonetary: 3
726
911
  }
727
912
  };
728
913
 
@@ -776,50 +961,9 @@ var Monster = {
776
961
  getMonsterAttributeData(monsterName, lv) {
777
962
  const monster = Monster.monsterTempData[monsterName];
778
963
  if (!monster) return null;
779
- const benchmark = {
780
- 10: {
781
- hp: 1.4,
782
- maxHp: 1.4,
783
- mp: 1.2,
784
- maxMp: 1.2,
785
- atk: 1.2,
786
- def: 1.1,
787
- chr: 1.1,
788
- evasion: 1.1,
789
- hit: 1.1,
790
- ghd: 1,
791
- speed: 1.05
792
- },
793
- 20: {
794
- hp: 1.35,
795
- maxHp: 1.35,
796
- mp: 1.1,
797
- maxMp: 1.1,
798
- atk: 1.1,
799
- def: 1.1,
800
- chr: 1.08,
801
- evasion: 1.08,
802
- hit: 1.08,
803
- ghd: 1,
804
- speed: 1.05
805
- },
806
- 40: {
807
- hp: 1.2,
808
- maxHp: 1.2,
809
- mp: 1.05,
810
- maxMp: 1.05,
811
- atk: 1.1,
812
- def: 1.05,
813
- chr: 1.05,
814
- evasion: 1.05,
815
- hit: 1.05,
816
- ghd: 1.05,
817
- speed: 1.05
818
- }
819
- };
820
964
  const temp = { lv };
821
- const lvScope = Object.keys(benchmark).reverse().find((item) => Number(item) < lv) || 10;
822
- const useBenchmark = benchmark[lvScope];
965
+ const lvScope = Object.keys(monsterBenchmark).reverse().find((item) => Number(item) < lv) || 10;
966
+ const useBenchmark = monsterBenchmark[lvScope];
823
967
  console.log(useBenchmark);
824
968
  Object.keys(monster).forEach((i) => {
825
969
  temp[i] = monster[i];
@@ -1398,36 +1542,49 @@ MP:${item.mp}/${item.maxMp + item.gain.maxMp}`);
1398
1542
  }, "aynchronize");
1399
1543
  if (tempData.isPK) {
1400
1544
  if (overInfo.win == "self") {
1401
- await session.send("攻击方获得20EXP");
1545
+ await session.send("攻击方获得20EXP、5货币");
1402
1546
  for (const agent of allList) {
1403
1547
  aynchronize(agent);
1404
1548
  if (agent.for == "self") {
1549
+ if (agent.hp <= 0) {
1550
+ User.userTempData[agent.userId].hp = 0;
1551
+ User.userTempData[agent.userId].isDie = true;
1552
+ }
1405
1553
  await User.giveExp(agent.userId, 20, async (val) => await msg(val));
1554
+ await User.giveMonetary(agent.userId, 5);
1406
1555
  }
1407
1556
  }
1408
1557
  } else if (overInfo.win == "goal") {
1409
- await session.send("防御方获得20EXP");
1558
+ await session.send("防御方获得20EXP、5货币");
1410
1559
  for (const agent of allList) {
1411
1560
  aynchronize(agent);
1412
1561
  if (agent.for == "goal") {
1562
+ if (agent.hp <= 0) {
1563
+ User.userTempData[agent.userId].hp = 0;
1564
+ User.userTempData[agent.userId].isDie = true;
1565
+ }
1413
1566
  await User.giveExp(agent.userId, 20, async (val) => await msg(val));
1567
+ await User.giveMonetary(agent.userId, 5);
1414
1568
  }
1415
1569
  }
1416
1570
  }
1417
1571
  } else {
1418
1572
  let val = 0;
1573
+ let monetary = 0;
1419
1574
  const monsterName = tempData.goal.filter((item) => item.type == "怪物").map((i) => ({ name: i.name, lv: i.lv }));
1420
1575
  monsterName.forEach((item) => {
1421
1576
  const monster = Monster.monsterTempData[item.name];
1422
1577
  if (monster) {
1423
1578
  val += Math.floor(monster.giveExp + monster.giveExp * (item.lv - 1) * 0.2);
1579
+ monetary += Math.floor(monster.giveMonetary + monster.giveExp * (item.lv - 1) * 0.1);
1424
1580
  }
1425
1581
  });
1582
+ await session.send(`小队获得${val}EXP、${monetary}货币!`);
1426
1583
  for (const agent of selfList) {
1427
1584
  aynchronize(agent);
1428
1585
  if (overInfo.win == "self") {
1429
- await session.send(`小队获得${val}EXP`);
1430
1586
  await User.giveExp(agent.userId, val, async (val2) => await msg(val2));
1587
+ await User.giveMonetary(agent.userId, monetary);
1431
1588
  }
1432
1589
  }
1433
1590
  }
@@ -1520,6 +1677,7 @@ function apply(ctx, config) {
1520
1677
  GensokyoMap.init(config, ctx);
1521
1678
  User.init(config, ctx);
1522
1679
  Monster.init(config, ctx);
1680
+ Props.init(config, ctx);
1523
1681
  });
1524
1682
  ctx.command("幻想乡");
1525
1683
  ctx.command("幻想乡/移动.上").action(async ({ session }) => {
@@ -1631,6 +1789,10 @@ function apply(ctx, config) {
1631
1789
  return `您的属性如下:
1632
1790
  ` + User.userAttributeTextFormat(session.userId);
1633
1791
  });
1792
+ ctx.command("幻想乡/个人信息").userFields(["id"]).action(async ({ session }) => {
1793
+ const [data] = await ctx.database.get("monetary", { uid: session.user.id });
1794
+ return `[${User.userTempData[session.userId].playName}]:您当前货币为:${data?.value || 0}个`;
1795
+ });
1634
1796
  ctx.command("幻想乡/开始注册").action(async ({ session }) => {
1635
1797
  await User.createPlayUser(session);
1636
1798
  });
@@ -1722,6 +1884,7 @@ function apply(ctx, config) {
1722
1884
  console.log(maxMp);
1723
1885
  User.userTempData[session.userId].hp = maxHp;
1724
1886
  User.userTempData[session.userId].mp = maxMp;
1887
+ User.userTempData[session.userId].isDie = false;
1725
1888
  console.log(User.userTempData[session.userId]);
1726
1889
  await User.setDatabaseUserAttribute(session.userId);
1727
1890
  return playName + `通过补给,目前已恢复HP和MP`;
package/lib/monster.d.ts CHANGED
@@ -1,53 +1,11 @@
1
1
  import { Context } from "koishi";
2
2
  import { Config } from ".";
3
- import { MonsterOccupation } from "./data/initMonster";
3
+ import { MonsterBaseAttribute, MonsterTempData } from "./data/initMonster";
4
4
  declare module 'koishi' {
5
5
  interface Tables {
6
6
  smm_gensokyo_monster_attribute: MonsterBaseAttribute;
7
7
  }
8
8
  }
9
- /** 怪物基础属性 */
10
- export type MonsterBaseAttribute = {
11
- /** 凭据ID */
12
- id?: number;
13
- /** 怪物名称 */
14
- name: string;
15
- /** 怪物说明 */
16
- info?: string;
17
- /** 怪物配图 */
18
- pic?: string;
19
- /** 类型 */
20
- type: MonsterOccupation;
21
- /** 血量 */
22
- hp: number;
23
- /** 最大血量 */
24
- maxHp: number;
25
- /** 蓝量 */
26
- mp: number;
27
- /** 最大蓝量 */
28
- maxMp: number;
29
- /** 攻击力 */
30
- atk: number;
31
- /** 防御力 */
32
- def: number;
33
- /** 暴击率 */
34
- chr: number;
35
- /** 暴击伤害 */
36
- ghd: number;
37
- /** 暴击抵抗 */
38
- csr: number;
39
- /** 闪避值 */
40
- evasion: number;
41
- /** 命中值 */
42
- hit: number;
43
- /** 出手速度 */
44
- speed: number;
45
- /** 获得经验 */
46
- giveExp: number;
47
- };
48
- type MonsterTempData = {
49
- [keys: string]: MonsterBaseAttribute;
50
- };
51
9
  export declare const Monster: {
52
10
  config: Config;
53
11
  ctx: Context;
@@ -63,4 +21,3 @@ export declare const Monster: {
63
21
  lv: number;
64
22
  }): string;
65
23
  };
66
- export {};
package/lib/props.d.ts ADDED
@@ -0,0 +1,34 @@
1
+ import { Context } from "koishi";
2
+ import { Config } from ".";
3
+ /** 道具信息 */
4
+ export type UserPropItem = {
5
+ name: string;
6
+ type: string;
7
+ value: number;
8
+ };
9
+ export type UserPropsList = {
10
+ [keys: string]: UserPropItem;
11
+ };
12
+ export type UserPrposTemp = {
13
+ [keys: string]: UserPropsList;
14
+ };
15
+ /** 数据库存放的数据 */
16
+ export type UserDatabaseProps = {
17
+ userId?: string;
18
+ props: UserPropsList;
19
+ };
20
+ declare module 'koishi' {
21
+ interface Tables {
22
+ smm_gensokyo_user_props: UserDatabaseProps;
23
+ }
24
+ }
25
+ export declare const Props: {
26
+ config: Config;
27
+ ctx: Context;
28
+ userPorpsTemp: UserPrposTemp;
29
+ init(config: Config, ctx: Context): Promise<void>;
30
+ /** 创建本地数据 */
31
+ initUserPropsData(userId: string): Promise<void>;
32
+ /** 更新本地数据库对应数据 */
33
+ setDatabasePropsData(userId: string): Promise<void>;
34
+ };
package/lib/users.d.ts CHANGED
@@ -53,30 +53,6 @@ export type UserBaseAttribute = {
53
53
  /** 出手速度 */
54
54
  speed: number;
55
55
  };
56
- export type UserBenchmark = {
57
- [keys: number]: {
58
- /** 最大经验 */
59
- maxExp: number;
60
- /** 最大血量 */
61
- maxHp: number;
62
- /** 最大蓝量 */
63
- maxMp: number;
64
- /** 攻击力 */
65
- atk: number;
66
- /** 防御力 */
67
- def: number;
68
- /** 暴击率 */
69
- chr: number;
70
- /** 暴击伤害 */
71
- ghd: number;
72
- /** 闪避值 */
73
- evasion: number;
74
- /** 命中值 */
75
- hit: number;
76
- /** 出手速度 */
77
- speed: number;
78
- };
79
- };
80
56
  export type DatabaseUserAttribute = {
81
57
  /** 凭据ID */
82
58
  userId: string;
@@ -94,6 +70,8 @@ export type DatabaseUserAttribute = {
94
70
  mp: number;
95
71
  /** 活力 */
96
72
  pp: number;
73
+ /** 是否死亡 */
74
+ isDie: boolean;
97
75
  };
98
76
  type UserTempData = {
99
77
  [keys: string]: DatabaseUserAttribute;
@@ -128,6 +106,35 @@ export declare const User: {
128
106
  lv: number;
129
107
  name: string;
130
108
  }) => Promise<void>): Promise<void>;
109
+ /** 给予玩家死亡 */
110
+ giveDie(userId: string): Promise<void>;
111
+ /** 给予玩家恢复 */
112
+ giveLife(userId: string, val?: number): Promise<void>;
113
+ /** 给予玩家血量或者蓝量 */
114
+ giveHPMP(userId: string, value: {
115
+ hp: number;
116
+ mp: number;
117
+ }, fn?: (upData: {
118
+ currentHP: number;
119
+ currentMP: number;
120
+ err?: string;
121
+ }) => Promise<void>): Promise<void>;
122
+ /** 给予玩家PP值 */
123
+ givePP(userId: string, value: number, fn?: (upData: {
124
+ currentPP: number;
125
+ }) => Promise<void>): Promise<void>;
126
+ /** 给予玩家货币 */
127
+ giveMonetary(userId: string, val: number, fn?: (upData: {
128
+ val: number;
129
+ currentVal: number;
130
+ err?: string;
131
+ }) => Promise<void>): Promise<void>;
132
+ /** 收取玩家货币 */
133
+ lostMonetary(userId: string, val: number, fn?: (upData: {
134
+ val: number;
135
+ currentVal: number;
136
+ err?: string;
137
+ }) => Promise<void>): Promise<void>;
131
138
  /** 目标是否死亡 */
132
139
  isDie(userId: string): boolean;
133
140
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-smmcat-gensokyo",
3
3
  "description": "名为《幻想乡》的文字冒险游戏",
4
- "version": "0.0.13",
4
+ "version": "0.0.14",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [