koishi-plugin-smmcat-gensokyo 0.0.5 → 0.0.6
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/battle.d.ts +11 -0
- package/lib/damage.d.ts +3 -1
- package/lib/data/initMonster.d.ts +57 -0
- package/lib/index.js +254 -75
- package/lib/monster.d.ts +3 -4
- package/lib/skillFn.d.ts +13 -5
- package/lib/test.d.ts +11 -3
- package/lib/users.d.ts +11 -0
- package/package.json +1 -1
package/lib/battle.d.ts
CHANGED
|
@@ -131,10 +131,21 @@ export declare const BattleData: {
|
|
|
131
131
|
}): {
|
|
132
132
|
over: boolean;
|
|
133
133
|
type: string;
|
|
134
|
+
win: string;
|
|
134
135
|
};
|
|
135
136
|
/** 清理战场 */
|
|
136
137
|
clearBattleData(session: Session): void;
|
|
137
138
|
play(session: Session, atkType: string, select?: string): Promise<void>;
|
|
139
|
+
/** 结算奖励 */
|
|
140
|
+
settlement(tempData: {
|
|
141
|
+
self: BattleAttribute[];
|
|
142
|
+
goal: BattleAttribute[];
|
|
143
|
+
isPK?: boolean;
|
|
144
|
+
}, overInfo: {
|
|
145
|
+
over: boolean;
|
|
146
|
+
type: string;
|
|
147
|
+
win: string;
|
|
148
|
+
}, session: Session): Promise<void>;
|
|
138
149
|
};
|
|
139
150
|
/** 获取阵容角色名 */
|
|
140
151
|
export declare function getLineupName(agent: BattleAttribute): string;
|
package/lib/damage.d.ts
CHANGED
|
@@ -48,6 +48,8 @@ declare class Damage {
|
|
|
48
48
|
}
|
|
49
49
|
/** 给予目标伤害 */
|
|
50
50
|
declare function giveDamage(self: BattleAttribute, goal: BattleAttribute, damage: DamageConfig): number;
|
|
51
|
+
/** 治疗目标 */
|
|
52
|
+
declare function giveCure(goal: BattleAttribute, val: number): number;
|
|
51
53
|
/** 伤害额外信息 */
|
|
52
54
|
export declare function moreDamageInfo(damage: DamageConfig): string;
|
|
53
|
-
export { Damage, giveDamage };
|
|
55
|
+
export { Damage, giveDamage, giveCure };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export declare enum MonsterOccupation {
|
|
2
|
+
野怪 = "\u91CE\u602A",
|
|
3
|
+
BOSS = "BOSS"
|
|
4
|
+
}
|
|
5
|
+
export declare const monsterData: {
|
|
6
|
+
小蜜蜂: {
|
|
7
|
+
name: string;
|
|
8
|
+
type: MonsterOccupation;
|
|
9
|
+
info: string;
|
|
10
|
+
hp: number;
|
|
11
|
+
maxHp: number;
|
|
12
|
+
mp: number;
|
|
13
|
+
maxMp: number;
|
|
14
|
+
atk: number;
|
|
15
|
+
def: number;
|
|
16
|
+
chr: number;
|
|
17
|
+
evasion: number;
|
|
18
|
+
hit: number;
|
|
19
|
+
ghd: number;
|
|
20
|
+
speed: number;
|
|
21
|
+
giveExp: number;
|
|
22
|
+
};
|
|
23
|
+
小蜘蛛: {
|
|
24
|
+
name: string;
|
|
25
|
+
type: MonsterOccupation;
|
|
26
|
+
info: string;
|
|
27
|
+
hp: number;
|
|
28
|
+
maxHp: number;
|
|
29
|
+
mp: number;
|
|
30
|
+
maxMp: number;
|
|
31
|
+
atk: number;
|
|
32
|
+
def: number;
|
|
33
|
+
chr: number;
|
|
34
|
+
evasion: number;
|
|
35
|
+
hit: number;
|
|
36
|
+
ghd: number;
|
|
37
|
+
speed: number;
|
|
38
|
+
giveExp: number;
|
|
39
|
+
};
|
|
40
|
+
dora: {
|
|
41
|
+
name: string;
|
|
42
|
+
type: MonsterOccupation;
|
|
43
|
+
info: string;
|
|
44
|
+
hp: number;
|
|
45
|
+
maxHp: number;
|
|
46
|
+
mp: number;
|
|
47
|
+
maxMp: number;
|
|
48
|
+
atk: number;
|
|
49
|
+
def: number;
|
|
50
|
+
chr: number;
|
|
51
|
+
evasion: number;
|
|
52
|
+
hit: number;
|
|
53
|
+
ghd: number;
|
|
54
|
+
speed: number;
|
|
55
|
+
giveExp: number;
|
|
56
|
+
};
|
|
57
|
+
};
|
package/lib/index.js
CHANGED
|
@@ -601,6 +601,103 @@ ${Object.keys(UserOccDict).map((i) => `【${i}】:${UserOccDict[i].info}`).join(
|
|
|
601
601
|
【闪避值】${temp.evasion} (+0)
|
|
602
602
|
【暴击率】${(temp.chr / 10).toFixed(1)}% (+0%)
|
|
603
603
|
【暴击伤害】${(temp.ghd * 100).toFixed(1)}% (+0%)`;
|
|
604
|
+
},
|
|
605
|
+
/** 写入用户数据到数据库 */
|
|
606
|
+
async setDatabaseUserAttribute(userId) {
|
|
607
|
+
const userInfo = User.userTempData[userId];
|
|
608
|
+
if (!userInfo) return;
|
|
609
|
+
const temp = {
|
|
610
|
+
playName: userInfo.playName.trim(),
|
|
611
|
+
hp: userInfo.hp,
|
|
612
|
+
pp: userInfo.pp,
|
|
613
|
+
mp: userInfo.mp,
|
|
614
|
+
lv: userInfo.lv,
|
|
615
|
+
exp: userInfo.exp
|
|
616
|
+
};
|
|
617
|
+
User.ctx.database.set("smm_gensokyo_user_attribute", { userId }, temp);
|
|
618
|
+
},
|
|
619
|
+
/** 给予玩家经验 */
|
|
620
|
+
async giveExp(userId, value, fn) {
|
|
621
|
+
const userInfo = User.userTempData[userId];
|
|
622
|
+
if (!userInfo) return;
|
|
623
|
+
const beforData = { ...User.getUserAttributeByUserId(userId) };
|
|
624
|
+
let isUp = false;
|
|
625
|
+
userInfo.exp += value;
|
|
626
|
+
while (true) {
|
|
627
|
+
const { maxExp } = User.getUserAttributeByUserId(userId);
|
|
628
|
+
if (userInfo.exp < maxExp) break;
|
|
629
|
+
userInfo.lv += 1;
|
|
630
|
+
userInfo.exp -= maxExp;
|
|
631
|
+
isUp = true;
|
|
632
|
+
}
|
|
633
|
+
if (isUp) {
|
|
634
|
+
const afterData = User.getUserAttributeByUserId(userId);
|
|
635
|
+
const upTemp = {
|
|
636
|
+
name: afterData.playName,
|
|
637
|
+
lv: afterData.lv,
|
|
638
|
+
maxHp: afterData.maxHp - beforData.maxHp,
|
|
639
|
+
maxMp: afterData.maxMp = beforData.maxMp,
|
|
640
|
+
atk: afterData.atk - beforData.atk,
|
|
641
|
+
def: afterData.def - beforData.def
|
|
642
|
+
};
|
|
643
|
+
fn && await fn(upTemp);
|
|
644
|
+
}
|
|
645
|
+
await User.setDatabaseUserAttribute(userId);
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
|
|
649
|
+
// src/data/initMonster.ts
|
|
650
|
+
var monsterData = {
|
|
651
|
+
"小蜜蜂": {
|
|
652
|
+
name: "小蜜蜂",
|
|
653
|
+
type: "野怪" /* 野怪 */,
|
|
654
|
+
info: "幻想乡一层常见的生物",
|
|
655
|
+
hp: 50,
|
|
656
|
+
maxHp: 50,
|
|
657
|
+
mp: 30,
|
|
658
|
+
maxMp: 30,
|
|
659
|
+
atk: 7,
|
|
660
|
+
def: 2,
|
|
661
|
+
chr: 50,
|
|
662
|
+
evasion: 100,
|
|
663
|
+
hit: 1e3,
|
|
664
|
+
ghd: 1.2,
|
|
665
|
+
speed: 4,
|
|
666
|
+
giveExp: 10
|
|
667
|
+
},
|
|
668
|
+
"小蜘蛛": {
|
|
669
|
+
name: "小蜘蛛",
|
|
670
|
+
type: "野怪" /* 野怪 */,
|
|
671
|
+
info: "幻想乡一层常见的生物",
|
|
672
|
+
hp: 55,
|
|
673
|
+
maxHp: 55,
|
|
674
|
+
mp: 30,
|
|
675
|
+
maxMp: 30,
|
|
676
|
+
atk: 10,
|
|
677
|
+
def: 3,
|
|
678
|
+
chr: 50,
|
|
679
|
+
evasion: 200,
|
|
680
|
+
hit: 1e3,
|
|
681
|
+
ghd: 1.2,
|
|
682
|
+
speed: 4,
|
|
683
|
+
giveExp: 12
|
|
684
|
+
},
|
|
685
|
+
"dora": {
|
|
686
|
+
name: "dora",
|
|
687
|
+
type: "野怪" /* 野怪 */,
|
|
688
|
+
info: "偶尔出没在一层世界的奇怪生物",
|
|
689
|
+
hp: 88,
|
|
690
|
+
maxHp: 88,
|
|
691
|
+
mp: 10,
|
|
692
|
+
maxMp: 10,
|
|
693
|
+
atk: 20,
|
|
694
|
+
def: 5,
|
|
695
|
+
chr: 200,
|
|
696
|
+
evasion: 300,
|
|
697
|
+
hit: 1e3,
|
|
698
|
+
ghd: 1.2,
|
|
699
|
+
speed: 4,
|
|
700
|
+
giveExp: 15
|
|
604
701
|
}
|
|
605
702
|
};
|
|
606
703
|
|
|
@@ -636,12 +733,12 @@ var Monster = {
|
|
|
636
733
|
autoInc: false
|
|
637
734
|
}
|
|
638
735
|
);
|
|
639
|
-
const
|
|
640
|
-
if (
|
|
736
|
+
const monsterData2 = await ctx.database.get("smm_gensokyo_monster_attribute", {});
|
|
737
|
+
if (monsterData2.length == 0) {
|
|
641
738
|
Monster.monsterTempData = Monster._createInitMonsterData();
|
|
642
739
|
} else {
|
|
643
740
|
const temp = {};
|
|
644
|
-
|
|
741
|
+
monsterData2.forEach((item) => {
|
|
645
742
|
temp[item.id] = item;
|
|
646
743
|
});
|
|
647
744
|
Monster.monsterTempData = temp;
|
|
@@ -649,56 +746,6 @@ var Monster = {
|
|
|
649
746
|
},
|
|
650
747
|
/** 赋予原始的怪物数据 */
|
|
651
748
|
_createInitMonsterData() {
|
|
652
|
-
const monsterData = {
|
|
653
|
-
"小蜜蜂": {
|
|
654
|
-
name: "小蜜蜂",
|
|
655
|
-
type: "野怪" /* 野怪 */,
|
|
656
|
-
info: "幻想乡一层常见的生物",
|
|
657
|
-
hp: 50,
|
|
658
|
-
maxHp: 50,
|
|
659
|
-
mp: 30,
|
|
660
|
-
maxMp: 30,
|
|
661
|
-
atk: 7,
|
|
662
|
-
def: 2,
|
|
663
|
-
chr: 50,
|
|
664
|
-
evasion: 100,
|
|
665
|
-
hit: 1e3,
|
|
666
|
-
ghd: 1.2,
|
|
667
|
-
speed: 4
|
|
668
|
-
},
|
|
669
|
-
"小蜘蛛": {
|
|
670
|
-
name: "小蜘蛛",
|
|
671
|
-
type: "野怪" /* 野怪 */,
|
|
672
|
-
info: "幻想乡一层常见的生物",
|
|
673
|
-
hp: 55,
|
|
674
|
-
maxHp: 55,
|
|
675
|
-
mp: 30,
|
|
676
|
-
maxMp: 30,
|
|
677
|
-
atk: 10,
|
|
678
|
-
def: 3,
|
|
679
|
-
chr: 50,
|
|
680
|
-
evasion: 200,
|
|
681
|
-
hit: 1e3,
|
|
682
|
-
ghd: 1.2,
|
|
683
|
-
speed: 4
|
|
684
|
-
},
|
|
685
|
-
"dora": {
|
|
686
|
-
name: "dora",
|
|
687
|
-
type: "野怪" /* 野怪 */,
|
|
688
|
-
info: "偶尔出没在一层世界的奇怪生物",
|
|
689
|
-
hp: 88,
|
|
690
|
-
maxHp: 88,
|
|
691
|
-
mp: 10,
|
|
692
|
-
maxMp: 10,
|
|
693
|
-
atk: 20,
|
|
694
|
-
def: 5,
|
|
695
|
-
chr: 200,
|
|
696
|
-
evasion: 300,
|
|
697
|
-
hit: 1e3,
|
|
698
|
-
ghd: 1.2,
|
|
699
|
-
speed: 4
|
|
700
|
-
}
|
|
701
|
-
};
|
|
702
749
|
return monsterData;
|
|
703
750
|
},
|
|
704
751
|
getMonsterAttributeData(monsterName, lv) {
|
|
@@ -826,7 +873,7 @@ var Damage = class {
|
|
|
826
873
|
const { self, goal } = this.config.agent;
|
|
827
874
|
if (this.config.isRealHarm) return this;
|
|
828
875
|
const lvSup = /* @__PURE__ */ __name(() => Math.floor((goal.lv - self.lv) / 5) * 20, "lvSup");
|
|
829
|
-
const evaVal = Math.min(95, (goal.evasion - (self.hit - 1e3) + lvSup()) / 10);
|
|
876
|
+
const evaVal = Math.min(95, (goal.evasion + goal.gain.evasion - (self.hit - 1e3) + lvSup()) / 10);
|
|
830
877
|
if (random(0, 100) <= evaVal) {
|
|
831
878
|
this.config.isEvasion = true;
|
|
832
879
|
fn && fn(this.config);
|
|
@@ -840,10 +887,10 @@ var Damage = class {
|
|
|
840
887
|
const { self, goal } = this.config.agent;
|
|
841
888
|
if (this.config.isRealHarm) return this;
|
|
842
889
|
if (this.config.isEvasion) return this;
|
|
843
|
-
const cspVal = (self.chr - goal.csr) / 10;
|
|
890
|
+
const cspVal = (self.chr + self.gain.chr - goal.csr) / 10;
|
|
844
891
|
if (random(0, 100) <= cspVal) {
|
|
845
892
|
this.config.isCsp = true;
|
|
846
|
-
this.config.harm = Math.floor(this.config.default_harm * self.ghd);
|
|
893
|
+
this.config.harm = Math.floor(this.config.default_harm * (self.ghd + self.gain.ghd));
|
|
847
894
|
fn && fn(this.config);
|
|
848
895
|
return this;
|
|
849
896
|
}
|
|
@@ -856,7 +903,7 @@ var Damage = class {
|
|
|
856
903
|
const { goal } = this.config.agent;
|
|
857
904
|
if (this.config.isRealHarm) return this;
|
|
858
905
|
if (this.config.isEvasion) return this;
|
|
859
|
-
const dpVal = goal.def;
|
|
906
|
+
const dpVal = goal.def + goal.gain.def;
|
|
860
907
|
fn && fn(this.config);
|
|
861
908
|
if (this.config.harm - dpVal > 0) {
|
|
862
909
|
this.config.harm -= dpVal;
|
|
@@ -892,6 +939,18 @@ function giveDamage(self, goal, damage) {
|
|
|
892
939
|
}
|
|
893
940
|
}
|
|
894
941
|
__name(giveDamage, "giveDamage");
|
|
942
|
+
function giveCure(goal, val) {
|
|
943
|
+
const upVal = goal.hp + val;
|
|
944
|
+
if (upVal < goal.maxHp + goal.gain.maxHp) {
|
|
945
|
+
goal.hp = upVal;
|
|
946
|
+
return val;
|
|
947
|
+
} else {
|
|
948
|
+
const abHp = goal.maxHp + goal.gain.maxHp - goal.hp;
|
|
949
|
+
goal.hp += abHp;
|
|
950
|
+
return abHp;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
__name(giveCure, "giveCure");
|
|
895
954
|
function moreDamageInfo(damage) {
|
|
896
955
|
return (damage.isCsp ? `(暴击!)` : "") + (damage.isEvasion ? `(闪避成功!)` : "") + (damage.isBadDef ? `(未破防!)` : "");
|
|
897
956
|
}
|
|
@@ -903,7 +962,9 @@ var skillFn = {
|
|
|
903
962
|
name: "重砍",
|
|
904
963
|
type: "伤害技" /* 伤害技 */,
|
|
905
964
|
info: "[伤害技]消耗10MP,对敌方一个单位造成基于攻击力1.2倍伤害。该次伤害无视敌方30%防御!(最低无视1防御)",
|
|
965
|
+
lv: 3,
|
|
906
966
|
mp: 10,
|
|
967
|
+
feature: ["剑士" /* 剑士 */],
|
|
907
968
|
fn: /* @__PURE__ */ __name(function(agent, agentList, fn) {
|
|
908
969
|
const damageData = new Damage(agent).result({
|
|
909
970
|
before: /* @__PURE__ */ __name((val) => {
|
|
@@ -920,10 +981,56 @@ var skillFn = {
|
|
|
920
981
|
return `${getLineupName(agent.self)} 释放重砍,对 ${getLineupName(agent.goal)} 造成 ${damageData.harm} 伤害。` + moreDamageInfo(damageData);
|
|
921
982
|
}, "fn")
|
|
922
983
|
},
|
|
984
|
+
"突刺": {
|
|
985
|
+
name: "突刺",
|
|
986
|
+
type: "伤害技" /* 伤害技 */,
|
|
987
|
+
info: "[伤害技]消耗10MP,对敌方一个单位造成基于攻击力1.2倍伤害,该伤害无视敌方闪避10%",
|
|
988
|
+
lv: 3,
|
|
989
|
+
mp: 10,
|
|
990
|
+
feature: ["刺客" /* 刺客 */],
|
|
991
|
+
fn: /* @__PURE__ */ __name(function(agent, agentList, fn) {
|
|
992
|
+
const damageData = new Damage(agent).result({
|
|
993
|
+
before: /* @__PURE__ */ __name((val) => {
|
|
994
|
+
val.default_harm += Math.floor(val.default_harm * 0.2);
|
|
995
|
+
val.agent.goal.evasion -= Math.floor((val.agent.goal.evasion + val.agent.goal.gain.evasion) * 0.1);
|
|
996
|
+
}, "before")
|
|
997
|
+
});
|
|
998
|
+
fn({
|
|
999
|
+
damage: damageData,
|
|
1000
|
+
type: this.type,
|
|
1001
|
+
target: [agent.goal],
|
|
1002
|
+
isNext: false
|
|
1003
|
+
});
|
|
1004
|
+
return `${getLineupName(agent.self)} 释放突刺,对 ${getLineupName(agent.goal)} 造成 ${damageData.harm} 伤害。` + moreDamageInfo(damageData);
|
|
1005
|
+
}, "fn")
|
|
1006
|
+
},
|
|
1007
|
+
"水炮": {
|
|
1008
|
+
name: "水炮",
|
|
1009
|
+
type: "伤害技" /* 伤害技 */,
|
|
1010
|
+
info: "[伤害技]消耗10MP,通过凝集魔力对敌方造成基于攻击力1.2倍伤害,该伤害基于当前剩余魔法值10%额外叠加伤害。",
|
|
1011
|
+
lv: 3,
|
|
1012
|
+
mp: 10,
|
|
1013
|
+
feature: ["法师" /* 法师 */],
|
|
1014
|
+
fn: /* @__PURE__ */ __name(function(agent, agentList, fn) {
|
|
1015
|
+
const damageData = new Damage(agent).result({
|
|
1016
|
+
before: /* @__PURE__ */ __name((val) => {
|
|
1017
|
+
val.default_harm += Math.floor(val.default_harm * 0.2) + Math.floor(val.agent.self.mp * 0.1);
|
|
1018
|
+
}, "before")
|
|
1019
|
+
});
|
|
1020
|
+
fn({
|
|
1021
|
+
damage: damageData,
|
|
1022
|
+
type: this.type,
|
|
1023
|
+
target: [agent.goal],
|
|
1024
|
+
isNext: false
|
|
1025
|
+
});
|
|
1026
|
+
return `${getLineupName(agent.self)} 释放水炮,对 ${getLineupName(agent.goal)} 造成 ${damageData.harm} 伤害。` + moreDamageInfo(damageData);
|
|
1027
|
+
}, "fn")
|
|
1028
|
+
},
|
|
923
1029
|
"濒死一击": {
|
|
924
1030
|
name: "濒死一击",
|
|
925
1031
|
type: "伤害技" /* 伤害技 */,
|
|
926
1032
|
info: "[伤害技]血量低于40%可释放,消耗20MP,对敌方一个单位造成基于攻击力2倍伤害。该次伤害暴击率提高20%",
|
|
1033
|
+
lv: 3,
|
|
927
1034
|
mp: 20,
|
|
928
1035
|
fn: /* @__PURE__ */ __name(function(agent, agentList, fn) {
|
|
929
1036
|
if (agent.self.hp / (agent.self.maxHp + agent.self.gain.maxHp) < 0.4) {
|
|
@@ -949,6 +1056,23 @@ var skillFn = {
|
|
|
949
1056
|
return ``;
|
|
950
1057
|
}
|
|
951
1058
|
}, "fn")
|
|
1059
|
+
},
|
|
1060
|
+
"初级治愈": {
|
|
1061
|
+
name: "初级治愈",
|
|
1062
|
+
type: "治疗技" /* 治疗技 */,
|
|
1063
|
+
info: "[治疗技]直接恢复自身或者目标 40HP",
|
|
1064
|
+
lv: 1,
|
|
1065
|
+
mp: 30,
|
|
1066
|
+
fn: /* @__PURE__ */ __name(function(agent, agentList, fn) {
|
|
1067
|
+
const selectGoal = agent.goal;
|
|
1068
|
+
fn({
|
|
1069
|
+
value: 40,
|
|
1070
|
+
target: [selectGoal],
|
|
1071
|
+
type: "治疗技" /* 治疗技 */,
|
|
1072
|
+
isNext: false
|
|
1073
|
+
});
|
|
1074
|
+
return `${getLineupName(agent.self)}释放初级治愈,${getLineupName(agent.goal)}恢复40HP`;
|
|
1075
|
+
}, "fn")
|
|
952
1076
|
}
|
|
953
1077
|
};
|
|
954
1078
|
|
|
@@ -1117,13 +1241,13 @@ MP:${item.mp}/${item.maxMp + item.gain.maxMp}`);
|
|
|
1117
1241
|
const self = team.self.every((item) => item.hp <= 0);
|
|
1118
1242
|
const goal = team.goal.every((item) => item.hp <= 0);
|
|
1119
1243
|
if (self && goal) {
|
|
1120
|
-
return { over: true, type: "平局" };
|
|
1244
|
+
return { over: true, type: "平局", win: "" };
|
|
1121
1245
|
} else if (self) {
|
|
1122
|
-
return { over: true, type: team.isPK ? "防御方赢" : "敌方赢" };
|
|
1246
|
+
return { over: true, type: team.isPK ? "防御方赢" : "敌方赢", win: "goal" };
|
|
1123
1247
|
} else if (goal) {
|
|
1124
|
-
return { over: true, type: team.isPK ? "攻击方赢" : "我方赢" };
|
|
1248
|
+
return { over: true, type: team.isPK ? "攻击方赢" : "我方赢", win: "self" };
|
|
1125
1249
|
}
|
|
1126
|
-
return { over: false, type: "未结束" };
|
|
1250
|
+
return { over: false, type: "未结束", win: "" };
|
|
1127
1251
|
},
|
|
1128
1252
|
/** 清理战场 */
|
|
1129
1253
|
clearBattleData(session) {
|
|
@@ -1182,6 +1306,9 @@ MP:${item.mp}/${item.maxMp + item.gain.maxMp}`);
|
|
|
1182
1306
|
noralAtk();
|
|
1183
1307
|
} else {
|
|
1184
1308
|
if (skillFn[atkType]) {
|
|
1309
|
+
if (["治疗技" /* 治疗技 */, "增益技" /* 增益技 */].includes(skillFn[atkType].type)) {
|
|
1310
|
+
selectGoal = lifeSelfList.find((item) => item.name == select) || agent;
|
|
1311
|
+
}
|
|
1185
1312
|
const selectFn = skillFn[atkType];
|
|
1186
1313
|
if (selectFn.mp == 0 || agent.mp - selectFn.mp >= 0) {
|
|
1187
1314
|
agent.mp -= selectFn.mp;
|
|
@@ -1196,6 +1323,11 @@ MP:${item.mp}/${item.maxMp + item.gain.maxMp}`);
|
|
|
1196
1323
|
giveDamage(agent, goal, val.damage);
|
|
1197
1324
|
});
|
|
1198
1325
|
break;
|
|
1326
|
+
case "治疗技" /* 治疗技 */:
|
|
1327
|
+
val.target.map((goal) => {
|
|
1328
|
+
giveCure(goal, val.value);
|
|
1329
|
+
});
|
|
1330
|
+
break;
|
|
1199
1331
|
case "释放失败" /* 释放失败 */:
|
|
1200
1332
|
val.err && session.send(val.err);
|
|
1201
1333
|
default:
|
|
@@ -1222,8 +1354,55 @@ MP:${item.mp}/${item.maxMp + item.gain.maxMp}`);
|
|
|
1222
1354
|
const result = BattleData.playOver(currentBattle);
|
|
1223
1355
|
if (result.over) {
|
|
1224
1356
|
await session.send(result.type);
|
|
1357
|
+
await BattleData.settlement(currentBattle, result, session);
|
|
1225
1358
|
BattleData.clearBattleData(session);
|
|
1226
1359
|
}
|
|
1360
|
+
},
|
|
1361
|
+
/** 结算奖励 */
|
|
1362
|
+
async settlement(tempData, overInfo, session) {
|
|
1363
|
+
const selfList = tempData.self.filter((item) => item.type == "玩家");
|
|
1364
|
+
const goalList = tempData.goal.filter((item) => item.type == "玩家");
|
|
1365
|
+
const msg = /* @__PURE__ */ __name(async (val) => {
|
|
1366
|
+
const msgTemp = `${val.name}[升级]${val.lv}级!
|
|
1367
|
+
` + (val.atk ? `攻击力↑ ${val.atk}
|
|
1368
|
+
` : "") + (val.def ? `防御力↑ ${val.def}
|
|
1369
|
+
` : "") + (val.maxHp ? `最大血量↑ ${val.maxHp}
|
|
1370
|
+
` : "") + (val.maxMp ? `最大蓝量↑ ${val.maxMp}` : "");
|
|
1371
|
+
await session.send(msgTemp);
|
|
1372
|
+
}, "msg");
|
|
1373
|
+
const aynchronize = /* @__PURE__ */ __name((agent) => {
|
|
1374
|
+
User.userTempData[agent.userId].hp = agent.hp;
|
|
1375
|
+
User.userTempData[agent.userId].mp = agent.mp;
|
|
1376
|
+
}, "aynchronize");
|
|
1377
|
+
if (tempData.isPK) {
|
|
1378
|
+
if (overInfo.win == "self") {
|
|
1379
|
+
await session.send("攻击方获得20EXP");
|
|
1380
|
+
for (const agent of selfList) {
|
|
1381
|
+
aynchronize(agent);
|
|
1382
|
+
await User.giveExp(agent.userId, 20, async (val) => await msg(val));
|
|
1383
|
+
}
|
|
1384
|
+
} else if (overInfo.win == "goal") {
|
|
1385
|
+
await session.send("防御方获得20EXP");
|
|
1386
|
+
for (const agent of goalList) {
|
|
1387
|
+
aynchronize(agent);
|
|
1388
|
+
await User.giveExp(agent.userId, 20, async (val) => await msg(val));
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
} else {
|
|
1392
|
+
let val = 0;
|
|
1393
|
+
const monsterName = tempData.goal.filter((item) => item.type == "怪物").map((i) => ({ name: i.name, lv: i.lv }));
|
|
1394
|
+
monsterName.forEach((item) => {
|
|
1395
|
+
const monster = Monster.monsterTempData[item.name];
|
|
1396
|
+
if (monster[item.name]) {
|
|
1397
|
+
val += monster[item.name].giveExp + monster[item.name].giveExp * (monster[item.name].lv - 1) * 0.2;
|
|
1398
|
+
}
|
|
1399
|
+
});
|
|
1400
|
+
for (const agent of selfList) {
|
|
1401
|
+
aynchronize(agent);
|
|
1402
|
+
await session.send(`小队获得${val}EXP`);
|
|
1403
|
+
await User.giveExp(agent.userId, val, async (val2) => await msg(val2));
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1227
1406
|
}
|
|
1228
1407
|
};
|
|
1229
1408
|
function getLineupName(agent) {
|
|
@@ -1266,23 +1445,23 @@ function initBattleAttribute(data) {
|
|
|
1266
1445
|
};
|
|
1267
1446
|
return temp;
|
|
1268
1447
|
} else {
|
|
1269
|
-
const
|
|
1448
|
+
const monsterData2 = data;
|
|
1270
1449
|
const temp = {
|
|
1271
|
-
name:
|
|
1450
|
+
name: monsterData2.name,
|
|
1272
1451
|
type: "怪物",
|
|
1273
|
-
lv:
|
|
1274
|
-
hp:
|
|
1275
|
-
maxHp:
|
|
1276
|
-
mp:
|
|
1277
|
-
maxMp:
|
|
1278
|
-
atk:
|
|
1279
|
-
def:
|
|
1280
|
-
chr:
|
|
1281
|
-
ghd:
|
|
1452
|
+
lv: monsterData2.lv,
|
|
1453
|
+
hp: monsterData2.hp,
|
|
1454
|
+
maxHp: monsterData2.maxHp,
|
|
1455
|
+
mp: monsterData2.mp,
|
|
1456
|
+
maxMp: monsterData2.maxMp,
|
|
1457
|
+
atk: monsterData2.atk,
|
|
1458
|
+
def: monsterData2.def,
|
|
1459
|
+
chr: monsterData2.chr,
|
|
1460
|
+
ghd: monsterData2.ghd,
|
|
1282
1461
|
csr: 0,
|
|
1283
|
-
evasion:
|
|
1284
|
-
hit:
|
|
1285
|
-
speed:
|
|
1462
|
+
evasion: monsterData2.evasion,
|
|
1463
|
+
hit: monsterData2.hit,
|
|
1464
|
+
speed: monsterData2.speed,
|
|
1286
1465
|
gain: {
|
|
1287
1466
|
maxHp: 0,
|
|
1288
1467
|
maxMp: 0,
|
package/lib/monster.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { Context } from "koishi";
|
|
2
2
|
import { Config } from ".";
|
|
3
|
+
import { MonsterOccupation } from "./data/initMonster";
|
|
3
4
|
declare module 'koishi' {
|
|
4
5
|
interface Tables {
|
|
5
6
|
smm_gensokyo_monster_attribute: MonsterBaseAttribute;
|
|
6
7
|
}
|
|
7
8
|
}
|
|
8
|
-
export declare enum MonsterOccupation {
|
|
9
|
-
野怪 = "\u91CE\u602A",
|
|
10
|
-
BOSS = "BOSS"
|
|
11
|
-
}
|
|
12
9
|
/** 怪物基础属性 */
|
|
13
10
|
export type MonsterBaseAttribute = {
|
|
14
11
|
/** 凭据ID */
|
|
@@ -41,6 +38,8 @@ export type MonsterBaseAttribute = {
|
|
|
41
38
|
hit: number;
|
|
42
39
|
/** 出手速度 */
|
|
43
40
|
speed: number;
|
|
41
|
+
/** 获得经验 */
|
|
42
|
+
giveExp: number;
|
|
44
43
|
};
|
|
45
44
|
type MonsterTempData = {
|
|
46
45
|
[keys: string]: MonsterBaseAttribute;
|
package/lib/skillFn.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BattleAttribute } from "./battle";
|
|
2
2
|
import { DamageConfig } from "./damage";
|
|
3
|
+
import { UserOccupation } from "./users";
|
|
3
4
|
export declare enum SkillType {
|
|
4
5
|
释放失败 = "\u91CA\u653E\u5931\u8D25",
|
|
5
6
|
伤害技 = "\u4F24\u5BB3\u6280",
|
|
@@ -17,6 +18,14 @@ interface DamageSkillParams {
|
|
|
17
18
|
/** 是否衔接普攻 */
|
|
18
19
|
isNext: boolean;
|
|
19
20
|
}
|
|
21
|
+
interface HealSkillParams {
|
|
22
|
+
type: SkillType.治疗技;
|
|
23
|
+
/** 是否衔接普攻 */
|
|
24
|
+
isNext: boolean;
|
|
25
|
+
/** 治疗量 */
|
|
26
|
+
value: number;
|
|
27
|
+
target: BattleAttribute[];
|
|
28
|
+
}
|
|
20
29
|
interface BuffSkillParams {
|
|
21
30
|
type: SkillType.增益技;
|
|
22
31
|
buffs: {
|
|
@@ -28,11 +37,6 @@ interface BuffSkillParams {
|
|
|
28
37
|
/** 是否衔接普攻 */
|
|
29
38
|
isNext: boolean;
|
|
30
39
|
}
|
|
31
|
-
interface HealSkillParams {
|
|
32
|
-
type: SkillType.治疗技;
|
|
33
|
-
/** 是否衔接普攻 */
|
|
34
|
-
isNext: boolean;
|
|
35
|
-
}
|
|
36
40
|
interface UltimateSkillParams {
|
|
37
41
|
type: SkillType.奥义;
|
|
38
42
|
/** 是否衔接普攻 */
|
|
@@ -53,8 +57,12 @@ interface SkillConfig<T extends SkillType = SkillType> {
|
|
|
53
57
|
type: T;
|
|
54
58
|
/** 技能说明 */
|
|
55
59
|
info: string;
|
|
60
|
+
/** 等级限制 */
|
|
61
|
+
lv: number;
|
|
56
62
|
/** 消耗MP */
|
|
57
63
|
mp: number;
|
|
64
|
+
/** 职业专属 */
|
|
65
|
+
feature?: UserOccupation[];
|
|
58
66
|
/** 技能函数 */
|
|
59
67
|
fn(agent: {
|
|
60
68
|
self: BattleAttribute;
|
package/lib/test.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
declare const nameList: {
|
|
2
|
-
张三: {
|
|
3
|
-
|
|
2
|
+
readonly 张三: {
|
|
3
|
+
readonly age: 25;
|
|
4
|
+
};
|
|
5
|
+
readonly 李四: {
|
|
6
|
+
readonly age: 30;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
declare const fn: (name: keyof typeof nameList) => {
|
|
10
|
+
readonly age: 25;
|
|
11
|
+
} | {
|
|
12
|
+
readonly age: 30;
|
|
4
13
|
};
|
|
5
|
-
declare const fn: (name: any) => any;
|
package/lib/users.d.ts
CHANGED
|
@@ -115,5 +115,16 @@ export declare const User: {
|
|
|
115
115
|
createPlayUser(session: Session): Promise<void>;
|
|
116
116
|
/** 信息格式化 */
|
|
117
117
|
userAttributeTextFormat(userId: string): string;
|
|
118
|
+
/** 写入用户数据到数据库 */
|
|
119
|
+
setDatabaseUserAttribute(userId: string): Promise<void>;
|
|
120
|
+
/** 给予玩家经验 */
|
|
121
|
+
giveExp(userId: string, value: number, fn?: (upData: {
|
|
122
|
+
maxHp: number;
|
|
123
|
+
maxMp: number;
|
|
124
|
+
atk: number;
|
|
125
|
+
def: number;
|
|
126
|
+
lv: number;
|
|
127
|
+
name: string;
|
|
128
|
+
}) => Promise<void>): Promise<void>;
|
|
118
129
|
};
|
|
119
130
|
export {};
|