Merge remote-tracking branch 'origin/feature/weiwang' into release

This commit is contained in:
xichaoyin 2024-01-04 22:30:14 +08:00
commit 3b3d61795e
16 changed files with 804 additions and 183 deletions

View File

@ -0,0 +1,17 @@
import { ApiCall } from "tsrpc";
import { ReqOpen, ResOpen } from "../../shared/protocols/weiwang/PtlOpen";
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
let data = await G.mongodb.collection("weiwang").findOne({ uid: call.uid });
if (!data) {
// 初始化威望数据
data = (await G.mongodb.collection("weiwang").findOneAndUpdate(
{ uid: call.uid },
{ $set: { hp: 0, atk: 0, def: 0 } },
{ upsert: true, returnDocument: "after" }
)).value;
}
call.succ({ lv: { hp: data.hp, atk: data.atk, def: data.def } });
}

View File

@ -0,0 +1,94 @@
import { ApiCall } from "tsrpc";
import { ReqUpLv, ResUpLv } from "../../shared/protocols/weiwang/PtlUpLv";
import { PlayerFun } from "../../public/player";
export default async function (call: ApiCall<ReqUpLv, ResUpLv>) {
let data = await G.mongodb.collection("weiwang").findOne({ uid: call.uid });
if (!data) {
// 初始化威望数据
data = (await G.mongodb.collection("weiwang").findOneAndUpdate(
{ uid: call.uid },
{ $set: { hp: 0, atk: 0, def: 0 } },
{ upsert: true, returnDocument: "after" }
)).value;
}
let cur_lv = data[call.req.type];
let min_lv = Math.min(data.atk, data.def, data.hp);
let ids = Object.keys(G.gc.renown_level).sort(
(a, b) => Number(a) - Number(b)
);
let config;
for (let id of ids) {
config = G.gc.renown_level[id];
if (min_lv < config.maxlevel) {
break;
}
}
// 超过档期威望的最大等级
if (cur_lv + call.req.lv > config.maxlevel) {
return call.error("", { code: -1, message: lng.weiwang_12 });
}
let need = [{ a: config.cost[0].a, t: config.cost[0].t, n: config.cost[0].n * call.req.lv }];
// 检测消耗是否足够
await PlayerFun.checkNeedIsMeet(call, need);
// 扣除消耗
await PlayerFun.cutNeed(call, need);
data[call.req.type] += call.req.lv;
// 重新计算buff
let buff = calc_weiwang_buff(data.atk, data.def, data.hp);
G.mongodb.collection("weiwang").updateOne({ uid: call.uid }, {
$set: { buff: buff },
$inc: { [call.req.type]: call.req.lv },
});
call.succ({ lv: { hp: data.hp, atk: data.atk, def: data.def } });
}
/**
* buff
*/
function calc_weiwang_buff(atk: number, def: number, hp: number) {
let buff: k_v<number> = {
"hp": 0, "def": 0, "atk": 0
};
let ids = Object.keys(G.gc.renown_level).sort(
(a, b) => Number(a) - Number(b)
);
for (let i = 0; i < ids.length; i++) {
let curr = G.gc.renown_level[ids[i]];
if (i == 0) {
buff["hp"] += curr.hp * Math.min(curr.maxlevel, hp);
buff["atk"] += curr.atk * Math.min(curr.maxlevel, atk);
buff["def"] += curr.def * Math.min(curr.maxlevel, def);
} else {
let prev = G.gc.renown_level[ids[i - 1]];
if (hp > prev.maxlevel) {
buff["hp"] += curr.hp * Math.min(hp - prev.maxlevel, curr.maxlevel - prev.maxlevel);
}
if (atk > prev.maxlevel) {
buff["atk"] += curr.atk * Math.min(atk - prev.maxlevel, curr.maxlevel - prev.maxlevel);
}
if (def > prev.maxlevel) {
buff["def"] += curr.def * Math.min(def - prev.maxlevel, curr.maxlevel - prev.maxlevel);
}
}
}
return buff;
}

View File

@ -1316,6 +1316,20 @@ export const serviceProto: ServiceProto<ServiceType> = {
}
},
"optional": true
},
{
"id": 38,
"name": "weiwangbuff",
"type": {
"type": "Interface",
"indexSignature": {
"keyType": "String",
"type": {
"type": "Number"
}
}
},
"optional": true
}
]
},

View File

@ -13,7 +13,7 @@ import { ResLogin } from './shared/protocols/user/PtlLogin';
import { HeroShared, otherBuff } from './shared/public/hero';
import { PlayerShared } from './shared/public/player';
import { PublicShared } from './shared/public/public';
import {RankKfjs} from "./public/rank/rank_kfjs";
import { RankKfjs } from "./public/rank/rank_kfjs";
import { setGud } from './public/gud';
export function extendType() {
@ -51,7 +51,7 @@ declare module 'tsrpc' {
/**API 锁 */
apiLock: k_v<number>;
/**获取默认上阵战斗数据 */
getDefaultFightData(def?: k_v<string>): Promise<joinFightData>;
getDefaultFightData(def?: k_v<string>, ext_buff?: { [type: string]: k_v<number> }): Promise<joinFightData>;
/**刷新上阵英雄战力 */
refreshPower(): Promise<any>;
/**玩家计算在线时长时间戳 */
@ -124,7 +124,7 @@ Object.defineProperties(BaseConnection.prototype, {
},
});
BaseConnection.prototype.getDefaultFightData = async function (this: BaseConnection, def?: k_v<string>) {
BaseConnection.prototype.getDefaultFightData = async function (this: BaseConnection, def?: k_v<string>, ext_buff?: { [type: string]: k_v<number> }) {
let posObj = def || this.heroPos;
let roles: k_v<roleDataType> = {};
@ -143,7 +143,11 @@ BaseConnection.prototype.getDefaultFightData = async function (this: BaseConnect
roles[pos] = {
...hero,
attr: {
...HeroShared.getHeroBasicAttr(hero, { ...this.otherBuff, allBuff: HeroShared.getAllBuff(heros) }, Number(pos))
...HeroShared.getHeroBasicAttr(hero, {
...ext_buff,
...this.otherBuff,
allBuff: HeroShared.getAllBuff(heros)
}, Number(pos))
}
};
}
@ -188,40 +192,40 @@ BaseConnection.prototype.refreshPower = async function (this: BaseConnection<Ser
zj_zhishi: 0
}
// 主角等级属性获取
zjBuff.zj_atk += PublicShared.eval(G.gc.com.zjcz_atk.value as any as string, { lv: this.gud.lv })
zjBuff.zj_def += PublicShared.eval(G.gc.com.zjcz_def.value as any as string, { lv: this.gud.lv })
zjBuff.zj_liliang += PublicShared.eval(G.gc.com.zjcz_liliang.value as any as string, { lv: this.gud.lv })
zjBuff.zj_zhishi += PublicShared.eval(G.gc.com.zjcz_zhishi.value as any as string, { lv: this.gud.lv })
// 图鉴属性获取
for(let i = 1; i <= this.gud.tujianLv; i++) {
for (let i = 1; i <= this.gud.tujianLv; i++) {
let item = G.gc.tujian_jc[i]
if(item) {
if (item) {
// 各等级累加
for(let k in item.buff) {
for (let k in item.buff) {
zjBuff[k] += item.buff[k]
}
}
}
// 名望属性加成
if(this.gud.renown > 0) {
if (this.gud.renown > 0) {
let mwConf = G.gc.mw_dj
// 各等级累加
for(let i = 1; i <= this.gud.renown; i++) {
for (let i = 1; i <= this.gud.renown; i++) {
let mwData = mwConf[i]
for(let k in mwData.buff) {
for (let k in mwData.buff) {
zjBuff[k] += mwData.buff[k]
}
}
}
// 训练计划加成
let skillConf = G.gc.xunlianjihua
if(this.gud.skills) {
for(let i in this.gud.skills) {
if (this.gud.skills) {
for (let i in this.gud.skills) {
let item = skillConf[i]
for(let j in zjBuff) {
if((j + 'pro') == item.skill) {
zjBuff[j] += Math.floor(zjBuff[j] * PublicShared.eval(item.v, { slv: this.gud.skills[i]}))
for (let j in zjBuff) {
if ((j + 'pro') == item.skill) {
zjBuff[j] += Math.floor(zjBuff[j] * PublicShared.eval(item.v, { slv: this.gud.skills[i] }))
}
}
}
@ -238,15 +242,15 @@ BaseConnection.prototype.refreshPower = async function (this: BaseConnection<Ser
// console.log(zjBuff)
if (power != this.gud.power) {
let dbUpdate = { power: power };
if(power > this.gud?.maxpower){
if (power > this.gud?.maxpower) {
//记录历史最大战力
//this.gud.maxpower = power;
dbUpdate['maxpower'] = power;
}
//this.gud.power = power;
setGud(this.uid,dbUpdate);
setGud(this.uid, dbUpdate);
G.mongodb.collection('user').updateOne({ uid: this.uid }, { $set: dbUpdate });
this.sendMsg('msg_s2c/PlayerChange', dbUpdate);
@ -310,9 +314,9 @@ ApiCall.prototype.addEventMsg = function (this: ApiCall) {
if (!this.eventMsg[msgName][msgKey]) this.eventMsg[msgName][msgKey] = {};
PublicShared.mergeProperty(this.eventMsg[msgName][msgKey], msg);
} else {
if(doubleApi.includes(this.service?.name) && this.service?.type=='api'&& Object.keys(this.eventMsg[msgName])[0]==Object.keys(msgKey)[0]){
if (doubleApi.includes(this.service?.name) && this.service?.type == 'api' && Object.keys(this.eventMsg[msgName])[0] == Object.keys(msgKey)[0]) {
this.eventMsg[msgName] = msgKey
}else {
} else {
PublicShared.mergeProperty(this.eventMsg[msgName], msgKey);
}
}

View File

@ -3,7 +3,13 @@
"id": 1,
"renownlevel": 1,
"maxlevel": 250,
"cost": 5,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 5
}
],
"atk": 2,
"def": 1,
"hp": 8
@ -11,8 +17,14 @@
"2": {
"id": 2,
"renownlevel": 2,
"maxlevel": 500,
"cost": 6,
"maxlevel": 750,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 6
}
],
"atk": 2,
"def": 1,
"hp": 9
@ -20,8 +32,14 @@
"3": {
"id": 3,
"renownlevel": 3,
"maxlevel": 750,
"cost": 7,
"maxlevel": 1500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 7
}
],
"atk": 2,
"def": 1,
"hp": 10
@ -29,8 +47,14 @@
"4": {
"id": 4,
"renownlevel": 4,
"maxlevel": 1000,
"cost": 9,
"maxlevel": 2500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 9
}
],
"atk": 4,
"def": 2,
"hp": 11
@ -38,8 +62,14 @@
"5": {
"id": 5,
"renownlevel": 5,
"maxlevel": 1250,
"cost": 11,
"maxlevel": 3750,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 11
}
],
"atk": 4,
"def": 2,
"hp": 12
@ -47,8 +77,14 @@
"6": {
"id": 6,
"renownlevel": 6,
"maxlevel": 1500,
"cost": 13,
"maxlevel": 5250,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 13
}
],
"atk": 4,
"def": 2,
"hp": 13
@ -56,8 +92,14 @@
"7": {
"id": 7,
"renownlevel": 7,
"maxlevel": 1750,
"cost": 15,
"maxlevel": 7000,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 15
}
],
"atk": 6,
"def": 3,
"hp": 14
@ -65,8 +107,14 @@
"8": {
"id": 8,
"renownlevel": 8,
"maxlevel": 2000,
"cost": 17,
"maxlevel": 9000,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 17
}
],
"atk": 6,
"def": 3,
"hp": 15
@ -74,8 +122,14 @@
"9": {
"id": 9,
"renownlevel": 9,
"maxlevel": 2500,
"cost": 19,
"maxlevel": 11500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 19
}
],
"atk": 6,
"def": 3,
"hp": 16
@ -83,8 +137,14 @@
"10": {
"id": 10,
"renownlevel": 10,
"maxlevel": 3000,
"cost": 21,
"maxlevel": 14500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 21
}
],
"atk": 8,
"def": 4,
"hp": 17
@ -92,8 +152,14 @@
"11": {
"id": 11,
"renownlevel": 11,
"maxlevel": 3500,
"cost": 23,
"maxlevel": 18000,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 23
}
],
"atk": 8,
"def": 4,
"hp": 18
@ -101,8 +167,14 @@
"12": {
"id": 12,
"renownlevel": 12,
"maxlevel": 4000,
"cost": 25,
"maxlevel": 22000,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 25
}
],
"atk": 8,
"def": 4,
"hp": 19
@ -110,8 +182,14 @@
"13": {
"id": 13,
"renownlevel": 13,
"maxlevel": 4500,
"cost": 27,
"maxlevel": 26500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 27
}
],
"atk": 10,
"def": 5,
"hp": 20
@ -119,8 +197,14 @@
"14": {
"id": 14,
"renownlevel": 14,
"maxlevel": 5000,
"cost": 30,
"maxlevel": 31500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 30
}
],
"atk": 10,
"def": 5,
"hp": 21
@ -128,8 +212,14 @@
"15": {
"id": 15,
"renownlevel": 15,
"maxlevel": 5000,
"cost": 33,
"maxlevel": 36500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 33
}
],
"atk": 10,
"def": 5,
"hp": 21
@ -137,8 +227,14 @@
"16": {
"id": 16,
"renownlevel": 16,
"maxlevel": 5000,
"cost": 36,
"maxlevel": 41500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 36
}
],
"atk": 12,
"def": 6,
"hp": 22
@ -146,8 +242,14 @@
"17": {
"id": 17,
"renownlevel": 17,
"maxlevel": 5000,
"cost": 39,
"maxlevel": 46500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 39
}
],
"atk": 12,
"def": 6,
"hp": 22
@ -155,8 +257,14 @@
"18": {
"id": 18,
"renownlevel": 18,
"maxlevel": 5000,
"cost": 42,
"maxlevel": 51500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 42
}
],
"atk": 12,
"def": 6,
"hp": 22
@ -164,8 +272,14 @@
"19": {
"id": 19,
"renownlevel": 19,
"maxlevel": 5000,
"cost": 45,
"maxlevel": 56500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 45
}
],
"atk": 14,
"def": 7,
"hp": 23
@ -173,8 +287,14 @@
"20": {
"id": 20,
"renownlevel": 20,
"maxlevel": 5000,
"cost": 48,
"maxlevel": 61500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 48
}
],
"atk": 14,
"def": 7,
"hp": 23
@ -182,8 +302,14 @@
"21": {
"id": 21,
"renownlevel": 21,
"maxlevel": 5000,
"cost": 51,
"maxlevel": 66500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 51
}
],
"atk": 14,
"def": 7,
"hp": 23
@ -191,8 +317,14 @@
"22": {
"id": 22,
"renownlevel": 22,
"maxlevel": 5000,
"cost": 54,
"maxlevel": 71500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 54
}
],
"atk": 14,
"def": 7,
"hp": 23
@ -200,8 +332,14 @@
"23": {
"id": 23,
"renownlevel": 23,
"maxlevel": 5000,
"cost": 57,
"maxlevel": 76500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 57
}
],
"atk": 16,
"def": 8,
"hp": 24
@ -209,8 +347,14 @@
"24": {
"id": 24,
"renownlevel": 24,
"maxlevel": 5000,
"cost": 60,
"maxlevel": 81500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 60
}
],
"atk": 16,
"def": 8,
"hp": 24
@ -218,8 +362,14 @@
"25": {
"id": 25,
"renownlevel": 25,
"maxlevel": 5000,
"cost": 63,
"maxlevel": 86500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 63
}
],
"atk": 16,
"def": 8,
"hp": 24
@ -227,8 +377,14 @@
"26": {
"id": 26,
"renownlevel": 26,
"maxlevel": 5000,
"cost": 66,
"maxlevel": 91500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 66
}
],
"atk": 16,
"def": 8,
"hp": 24
@ -236,8 +392,14 @@
"27": {
"id": 27,
"renownlevel": 27,
"maxlevel": 5000,
"cost": 69,
"maxlevel": 96500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 69
}
],
"atk": 16,
"def": 8,
"hp": 24
@ -245,8 +407,14 @@
"28": {
"id": 28,
"renownlevel": 28,
"maxlevel": 5000,
"cost": 72,
"maxlevel": 101500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 72
}
],
"atk": 18,
"def": 9,
"hp": 25
@ -254,8 +422,14 @@
"29": {
"id": 29,
"renownlevel": 29,
"maxlevel": 5000,
"cost": 75,
"maxlevel": 106500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 75
}
],
"atk": 18,
"def": 9,
"hp": 25
@ -263,8 +437,14 @@
"30": {
"id": 30,
"renownlevel": 30,
"maxlevel": 5000,
"cost": 78,
"maxlevel": 111500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 78
}
],
"atk": 18,
"def": 9,
"hp": 25
@ -272,8 +452,14 @@
"31": {
"id": 31,
"renownlevel": 31,
"maxlevel": 5000,
"cost": 81,
"maxlevel": 116500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 81
}
],
"atk": 18,
"def": 9,
"hp": 25
@ -281,8 +467,14 @@
"32": {
"id": 32,
"renownlevel": 32,
"maxlevel": 5000,
"cost": 84,
"maxlevel": 121500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 84
}
],
"atk": 18,
"def": 9,
"hp": 25
@ -290,8 +482,14 @@
"33": {
"id": 33,
"renownlevel": 33,
"maxlevel": 5000,
"cost": 87,
"maxlevel": 126500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 87
}
],
"atk": 18,
"def": 10,
"hp": 25
@ -299,8 +497,14 @@
"34": {
"id": 34,
"renownlevel": 34,
"maxlevel": 5000,
"cost": 90,
"maxlevel": 131500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 90
}
],
"atk": 18,
"def": 10,
"hp": 25
@ -308,8 +512,14 @@
"35": {
"id": 35,
"renownlevel": 35,
"maxlevel": 5000,
"cost": 93,
"maxlevel": 136500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 93
}
],
"atk": 18,
"def": 10,
"hp": 25
@ -317,8 +527,14 @@
"36": {
"id": 36,
"renownlevel": 36,
"maxlevel": 5000,
"cost": 97,
"maxlevel": 141500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 97
}
],
"atk": 18,
"def": 10,
"hp": 25
@ -326,8 +542,14 @@
"37": {
"id": 37,
"renownlevel": 37,
"maxlevel": 5000,
"cost": 101,
"maxlevel": 146500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 101
}
],
"atk": 18,
"def": 10,
"hp": 25
@ -335,8 +557,14 @@
"38": {
"id": 38,
"renownlevel": 38,
"maxlevel": 5000,
"cost": 105,
"maxlevel": 151500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 105
}
],
"atk": 18,
"def": 10,
"hp": 25
@ -344,8 +572,14 @@
"39": {
"id": 39,
"renownlevel": 39,
"maxlevel": 5000,
"cost": 109,
"maxlevel": 156500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 109
}
],
"atk": 18,
"def": 10,
"hp": 25
@ -353,8 +587,14 @@
"40": {
"id": 40,
"renownlevel": 40,
"maxlevel": 5000,
"cost": 113,
"maxlevel": 161500,
"cost": [
{
"a": "attr",
"t": "weiwang",
"n": 113
}
],
"atk": 18,
"def": 10,
"hp": 25

View File

@ -106,6 +106,18 @@ type gc_clsl_com = {
"divide": { "day": [number, number], "group": number, [x: string]: any }[], "divideTime": number, "fightTime": [number, number], "prizeTime": number, "fightWinPrize": { "total": number, "prize": { "a": string, "t": string, "n": number, [x: string]: any }[], "star": number, [x: string]: any }[], "fightNum": number, "vipBuyFightNum": [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number], "buyFightNumNeed": { "a": string, "t": string, "n": number, [x: string]: any }[], "rankPrize": { "rank": [number, number], "prize": { "a": string, "t": string, "n": number, [x: string]: any }[], "title": string, [x: string]: any }[], "danPrize": { "star": number, "prize": { "a": string, "t": string, "n": number, [x: string]: any }[], [x: string]: any }[], "email_rank": { "title": string, "content": string, [x: string]: any }, "email_dan": { "title": string, "content": string, [x: string]: any }, [x: string]: any
}
type gc_renown_level = {
[id: string]: {
id: number,
renownlevel: number,
maxlevel: number,
cost: { "a": string, "t": string, "n": number, [x: string]: any }[],
atk: number,
def: number,
hp: number,
}
}
type gc_clsl_dan = k_v<{
/** 总星级 */
'allStar': number
@ -1946,7 +1958,7 @@ type gcType = {
kfcb_prize: gc_kfcb_prize
yuyuemail: gc_yuyuemail
tuisonglibao: gc_push_gift
renown_level: gc_renown_level
}
@ -1957,4 +1969,3 @@ declare global {
export function initGcType() {
}

View File

@ -352,7 +352,9 @@ class Lng {
huoqupaihang: "huoqupaihang";
wucigonghui: "wucigonghui";
nameyicunzai: "nameyicunzai";
ljlibaotips_8:"ljlibaotips_8";
ljlibaotips_8: "ljlibaotips_8";
weiwang_12: "weiwang_12";
"11111" = "globalThis.lng.chat_1"
// return call.error('', { code: -3, message: globalThis.lng.chat_2 });

View File

@ -0,0 +1,9 @@
export type CollectionWeiwang = {
uid: string;
hp: number;
atk: number;
def: number;
buff: k_v<number>;
}

View File

@ -60,6 +60,7 @@ import {CollectionRmbuse} from "./collection_rmbuse";
import {CollectionFightLog} from "./collection_fightLog";
import {CollectionShop} from "./collection_shop";
import {CollectionPushGift} from "./collection_pushgift";
import { CollectionWeiwang } from './collection_weiwang';
export type MongodbCollections = {
user: CollectionUser;
@ -136,4 +137,5 @@ export type MongodbCollections = {
pushgift:CollectionPushGift
huodong_user: CollectionUser;
weiwang: CollectionWeiwang;
};

View File

@ -2637,6 +2637,20 @@ export const serviceProto: ServiceProto<ServiceType> = {
}
},
"optional": true
},
{
"id": 38,
"name": "weiwangbuff",
"type": {
"type": "Interface",
"indexSignature": {
"keyType": "String",
"type": {
"type": "Number"
}
}
},
"optional": true
}
]
},

View File

@ -1,43 +1,43 @@
import {ApiCall, TsrpcError} from 'tsrpc';
import {FightControl} from '../shared/fightControl/fightCntrol';
import {formatNpcData} from '../shared/fightControl/fightFun';
import {fightResult, joinFightData, roleDataType} from '../shared/fightControl/fightType';
import {rankInfo} from '../shared/protocols/type';
import {HeroShared} from '../shared/public/hero';
import {PlayerShared} from '../shared/public/player';
import {HeroFun} from './hero';
import {UserFun} from './user';
import {re, string} from "mathjs";
import {getGud} from './gud';
import {PushGiftFun} from "./pushgift";
import { ApiCall, TsrpcError } from 'tsrpc';
import { FightControl } from '../shared/fightControl/fightCntrol';
import { formatNpcData } from '../shared/fightControl/fightFun';
import { fightResult, joinFightData, roleDataType } from '../shared/fightControl/fightType';
import { rankInfo } from '../shared/protocols/type';
import { HeroShared } from '../shared/public/hero';
import { PlayerShared } from '../shared/public/player';
import { HeroFun } from './hero';
import { UserFun } from './user';
import { re, string } from "mathjs";
import { getGud } from './gud';
import { PushGiftFun } from "./pushgift";
type fightType = 'tanxian' | 'pata' | 'jjc' | 'gbtx' | 'qjzzd' | 'meirishilian' | 'wzrycross';
let fights:{[key:string]:FightControl} = {
let fights: { [key: string]: FightControl } = {
};
function clearFights (){
function clearFights() {
//定时清理战斗
setInterval(()=>{
setInterval(() => {
let now = Date.now();
for (let key in fights){
if (now - fights[key].startTime > 30000){
console.log("清理战斗",key);
try{
for (let key in fights) {
if (now - fights[key].startTime > 30000) {
console.log("清理战斗", key);
try {
fights[key].release();
}catch(e){
} catch (e) {
console.error(e);
}
delete fights[key];
}
}
},5000);
}, 5000);
}
clearFights();
export class FightFun {
static fightIndex:number = 0;
static fightIndex: number = 0;
static fight(data: joinFightData[], maxRoundNums = 30, fightType: "pvp" | "pve" = 'pvp') {
this.fightIndex++;
@ -80,7 +80,7 @@ export class FightFun {
});
return {
player: {...player, buff: PlayerShared.getBuff(player)},
player: { ...player, buff: PlayerShared.getBuff(player) },
roles: roles
};
}
@ -101,8 +101,15 @@ export class FightFun {
/**挑战npc */
static async fightNpc(call: ApiCall, npcId: string | number, type: fightType, data?: joinFightData) {
let ext_buff = {};
let my = data || await call.conn.getDefaultFightData();
if (["tanxian"].indexOf(type) != -1) {
// 威望buff
let weiwang = await G.mongodb.collection("weiwang").findOne({ uid: call.uid });
ext_buff["weiwangbuff"] = weiwang?.buff ? weiwang.buff : { "atk": 0, "def": 0, "hp": 0 };
}
let my = data || await call.conn.getDefaultFightData(undefined, ext_buff);
if (Object.keys(my.roles).length < 1) {
throw new TsrpcError('至少需要上阵一个英雄');
@ -133,11 +140,11 @@ export class FightFun {
let writeList = ['ganhai', 'jjc', 'hbzbJfs', 'hbzbZbs', 'slzd', 'clsl']
if (uid.indexOf('npc') != -1 || !writeList.includes(type)) return;
G.mongodb.collection('fightLog').insertOne({uid, type, ...result})
G.mongodb.collection('fightLog').insertOne({ uid, type, ...result })
}
static async readLog(uid: string, type: string, len = 20) {
return await G.mongodb.collection('fightLog').find({uid, type}).limit(len).toArray() || []
return await G.mongodb.collection('fightLog').find({ uid, type }).limit(len).toArray() || []
}
}

View File

@ -330,10 +330,12 @@ import { ReqRenownBuy, ResRenownBuy } from './user/PtlRenownBuy';
import { ReqRenownGetPrize, ResRenownGetPrize } from './user/PtlRenownGetPrize';
import { ReqRenownOpen, ResRenownOpen } from './user/PtlRenownOpen';
import { ReqTujian, ResTujian } from './user/PtlTujian';
import { ReqOpen as ReqOpen_61, ResOpen as ResOpen_61 } from './weiwang/PtlOpen';
import { ReqUpLv, ResUpLv } from './weiwang/PtlUpLv';
import { ReqDecompose, ResDecompose } from './weixiuchang/PtlDecompose';
import { ReqExchange as ReqExchange_1, ResExchange as ResExchange_1 } from './weixiuchang/PtlExchange';
import { ReqOpen as ReqOpen_61, ResOpen as ResOpen_61 } from './weixiuchang/PtlOpen';
import { ReqUpLv, ResUpLv } from './weixiuchang/PtlUpLv';
import { ReqOpen as ReqOpen_62, ResOpen as ResOpen_62 } from './weixiuchang/PtlOpen';
import { ReqUpLv as ReqUpLv_1, ResUpLv as ResUpLv_1 } from './weixiuchang/PtlUpLv';
import { ReqUpStar, ResUpStar } from './weixiuchang/PtlUpStar';
import { ReqAutoBaoMing, ResAutoBaoMing } from './wzry/PtlAutoBaoMing';
import { ReqBaoMing, ResBaoMing } from './wzry/PtlBaoMing';
@ -343,7 +345,7 @@ import { ReqDldFight, ResDldFight } from './wzry/PtlDldFight';
import { ReqDldRefre, ResDldRefre } from './wzry/PtlDldRefre';
import { ReqJingCai, ResJingCai } from './wzry/PtlJingCai';
import { ReqJingCaiOpen, ResJingCaiOpen } from './wzry/PtlJingCaiOpen';
import { ReqOpen as ReqOpen_62, ResOpen as ResOpen_62 } from './wzry/PtlOpen';
import { ReqOpen as ReqOpen_63, ResOpen as ResOpen_63 } from './wzry/PtlOpen';
import { ReqUpdateFight, ResUpdateFight } from './wzry/PtlUpdateFight';
import { ReqWzzd, ResWzzd } from './wzry/PtlWzzd';
import { ReqZuanShiOpen, ResZuanShiOpen } from './wzry/PtlZuanShiOpen';
@ -351,7 +353,7 @@ import { ReqAllGet, ResAllGet } from './xstask/PtlAllGet';
import { ReqGet as ReqGet_3, ResGet as ResGet_3 } from './xstask/PtlGet';
import { ReqLvUp as ReqLvUp_4, ResLvUp as ResLvUp_4 } from './xstask/PtlLvUp';
import { ReqOnekeyReceive, ResOnekeyReceive } from './xstask/PtlOnekeyReceive';
import { ReqOpen as ReqOpen_63, ResOpen as ResOpen_63 } from './xstask/PtlOpen';
import { ReqOpen as ReqOpen_64, ResOpen as ResOpen_64 } from './xstask/PtlOpen';
import { ReqReceive as ReqReceive_10, ResReceive as ResReceive_10 } from './xstask/PtlReceive';
import { ReqRefresh as ReqRefresh_8, ResRefresh as ResRefresh_8 } from './xstask/PtlRefresh';
import { ReqHandle, ResHandle } from './yongbingzhuzhan/PtlHandle';
@ -1569,6 +1571,14 @@ export interface ServiceType {
req: ReqTujian,
res: ResTujian
},
"weiwang/Open": {
req: ReqOpen_61,
res: ResOpen_61
},
"weiwang/UpLv": {
req: ReqUpLv,
res: ResUpLv
},
"weixiuchang/Decompose": {
req: ReqDecompose,
res: ResDecompose
@ -1578,12 +1588,12 @@ export interface ServiceType {
res: ResExchange_1
},
"weixiuchang/Open": {
req: ReqOpen_61,
res: ResOpen_61
req: ReqOpen_62,
res: ResOpen_62
},
"weixiuchang/UpLv": {
req: ReqUpLv,
res: ResUpLv
req: ReqUpLv_1,
res: ResUpLv_1
},
"weixiuchang/UpStar": {
req: ReqUpStar,
@ -1622,8 +1632,8 @@ export interface ServiceType {
res: ResJingCaiOpen
},
"wzry/Open": {
req: ReqOpen_62,
res: ResOpen_62
req: ReqOpen_63,
res: ResOpen_63
},
"wzry/UpdateFight": {
req: ReqUpdateFight,
@ -1654,8 +1664,8 @@ export interface ServiceType {
res: ResOnekeyReceive
},
"xstask/Open": {
req: ReqOpen_63,
res: ResOpen_63
req: ReqOpen_64,
res: ResOpen_64
},
"xstask/Receive": {
req: ReqReceive_10,
@ -3488,141 +3498,151 @@ export const serviceProto: ServiceProto<ServiceType> = {
},
{
"id": 331,
"name": "weixiuchang/Decompose",
"name": "weiwang/Open",
"type": "api"
},
{
"id": 332,
"name": "weixiuchang/Exchange",
"name": "weiwang/UpLv",
"type": "api"
},
{
"id": 333,
"name": "weixiuchang/Open",
"name": "weixiuchang/Decompose",
"type": "api"
},
{
"id": 334,
"name": "weixiuchang/UpLv",
"name": "weixiuchang/Exchange",
"type": "api"
},
{
"id": 335,
"name": "weixiuchang/UpStar",
"name": "weixiuchang/Open",
"type": "api"
},
{
"id": 336,
"name": "wzry/AutoBaoMing",
"name": "weixiuchang/UpLv",
"type": "api"
},
{
"id": 337,
"name": "wzry/BaoMing",
"name": "weixiuchang/UpStar",
"type": "api"
},
{
"id": 338,
"name": "wzry/catFightLog",
"name": "wzry/AutoBaoMing",
"type": "api"
},
{
"id": 339,
"name": "wzry/CatGroup",
"name": "wzry/BaoMing",
"type": "api"
},
{
"id": 340,
"name": "wzry/DldFight",
"name": "wzry/catFightLog",
"type": "api"
},
{
"id": 341,
"name": "wzry/DldRefre",
"name": "wzry/CatGroup",
"type": "api"
},
{
"id": 342,
"name": "wzry/JingCai",
"name": "wzry/DldFight",
"type": "api"
},
{
"id": 343,
"name": "wzry/JingCaiOpen",
"name": "wzry/DldRefre",
"type": "api"
},
{
"id": 344,
"name": "wzry/Open",
"name": "wzry/JingCai",
"type": "api"
},
{
"id": 345,
"name": "wzry/UpdateFight",
"name": "wzry/JingCaiOpen",
"type": "api"
},
{
"id": 346,
"name": "wzry/Wzzd",
"name": "wzry/Open",
"type": "api"
},
{
"id": 347,
"name": "wzry/ZuanShiOpen",
"name": "wzry/UpdateFight",
"type": "api"
},
{
"id": 348,
"name": "xstask/AllGet",
"name": "wzry/Wzzd",
"type": "api"
},
{
"id": 349,
"name": "xstask/Get",
"name": "wzry/ZuanShiOpen",
"type": "api"
},
{
"id": 350,
"name": "xstask/LvUp",
"name": "xstask/AllGet",
"type": "api"
},
{
"id": 351,
"name": "xstask/OnekeyReceive",
"name": "xstask/Get",
"type": "api"
},
{
"id": 352,
"name": "xstask/Open",
"name": "xstask/LvUp",
"type": "api"
},
{
"id": 353,
"name": "xstask/Receive",
"name": "xstask/OnekeyReceive",
"type": "api"
},
{
"id": 354,
"name": "xstask/Refresh",
"name": "xstask/Open",
"type": "api"
},
{
"id": 355,
"name": "yongbingzhuzhan/Handle",
"name": "xstask/Receive",
"type": "api"
},
{
"id": 356,
"name": "zhanqianbushu/ChangePos",
"name": "xstask/Refresh",
"type": "api"
},
{
"id": 357,
"name": "zhanqianbushu/Select",
"name": "yongbingzhuzhan/Handle",
"type": "api"
},
{
"id": 358,
"name": "zhanqianbushu/ChangePos",
"type": "api"
},
{
"id": 359,
"name": "zhanqianbushu/Select",
"type": "api"
},
{
"id": 360,
"name": "zhanqianbushu/Up",
"type": "api"
}
@ -4565,6 +4585,20 @@ export const serviceProto: ServiceProto<ServiceType> = {
}
},
"optional": true
},
{
"id": 38,
"name": "weiwangbuff",
"type": {
"type": "Interface",
"indexSignature": {
"keyType": "String",
"type": {
"type": "Number"
}
}
},
"optional": true
}
]
},
@ -5809,6 +5843,20 @@ export const serviceProto: ServiceProto<ServiceType> = {
}
},
"optional": true
},
{
"id": 38,
"name": "weiwangbuff",
"type": {
"type": "Interface",
"indexSignature": {
"keyType": "String",
"type": {
"type": "Number"
}
}
},
"optional": true
}
]
},
@ -22088,6 +22136,121 @@ export const serviceProto: ServiceProto<ServiceType> = {
"user/PtlTujian/ResTujian": {
"type": "Interface"
},
"weiwang/PtlOpen/ReqOpen": {
"type": "Interface"
},
"weiwang/PtlOpen/ResOpen": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "lv",
"type": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "hp",
"type": {
"type": "Number"
}
},
{
"id": 1,
"name": "atk",
"type": {
"type": "Number"
}
},
{
"id": 2,
"name": "def",
"type": {
"type": "Number"
}
}
]
}
}
]
},
"weiwang/PtlUpLv/ReqUpLv": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "lv",
"type": {
"type": "Number"
}
},
{
"id": 1,
"name": "type",
"type": {
"type": "Union",
"members": [
{
"id": 0,
"type": {
"type": "Literal",
"literal": "hp"
}
},
{
"id": 1,
"type": {
"type": "Literal",
"literal": "atk"
}
},
{
"id": 2,
"type": {
"type": "Literal",
"literal": "def"
}
}
]
}
}
]
},
"weiwang/PtlUpLv/ResUpLv": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "lv",
"type": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "hp",
"type": {
"type": "Number"
}
},
{
"id": 1,
"name": "atk",
"type": {
"type": "Number"
}
},
{
"id": 2,
"name": "def",
"type": {
"type": "Number"
}
}
]
}
}
]
},
"weixiuchang/PtlDecompose/ReqDecompose": {
"type": "Interface",
"properties": [
@ -24281,6 +24444,20 @@ export const serviceProto: ServiceProto<ServiceType> = {
}
},
"optional": true
},
{
"id": 38,
"name": "weiwangbuff",
"type": {
"type": "Interface",
"indexSignature": {
"keyType": "String",
"type": {
"type": "Number"
}
}
},
"optional": true
}
]
},

View File

@ -1,4 +1,4 @@
import {gonghuiLevel} from '../gonghui/type';
import { gonghuiLevel } from '../gonghui/type';
/**
*
@ -193,4 +193,6 @@ export type playerAppend = {
chatFrames?: {
[id: string]: number;
};
/**威望额外属性*/
weiwangbuff?: { [k: string]: number };
};

View File

@ -0,0 +1,11 @@
export interface ReqOpen {
}
export interface ResOpen {
lv: {
hp: number
atk: number
def: number
}
}

View File

@ -0,0 +1,12 @@
export interface ReqUpLv {
lv: number
type: "hp" | "atk" | "def"
}
export interface ResUpLv {
lv: {
hp: number
atk: number
def: number
}
}

View File

@ -1,10 +1,10 @@
import {ResGetList} from '../protocols/hero/PtlGetList';
import {player} from '../protocols/user/type';
import {EquipShared} from './equip';
import {PeijianShared} from './peijian';
import {PlayerShared} from './player';
import {PublicShared} from './public';
import {ShiwuShared} from './shiwu';
import { ResGetList } from '../protocols/hero/PtlGetList';
import { player } from '../protocols/user/type';
import { EquipShared } from './equip';
import { PeijianShared } from './peijian';
import { PlayerShared } from './player';
import { PublicShared } from './public';
import { ShiwuShared } from './shiwu';
export type otherBuff = Partial<player & {
allBuff: k_v<number>;
@ -31,7 +31,7 @@ export class HeroShared {
*/
static getHeroBasicAttr(hero: heroDataType, otherBuff: otherBuff = G.otherBuff, pos = 0) {
let jiban = 0;
let buff: k_v<any> = {skillArr: []};
let buff: k_v<any> = { skillArr: [] };
let heroConf = G.gc.hero[hero.heroId];
let heroLv = G.gc.herolv[heroConf.lvup];
let heroGrow = G.gc.herogrow[heroConf.jjup]?.[hero.jieji];
@ -40,7 +40,7 @@ export class HeroShared {
for (let k in heroLv.buff) {
let val = heroLv.buff[k];
if (typeof val == 'number') buff[k] = val;
else buff[k] = PublicShared.eval(val, {lv: hero.lv});
else buff[k] = PublicShared.eval(val, { lv: hero.lv });
// else buff[k] = Math.floor(new Function(`let lv=${hero.lv}; return ${val}`)());
}
@ -135,7 +135,7 @@ export class HeroShared {
PublicShared.mergeProperty(buff, PeijianShared.getAttr(p));
let conf = G.gc.peijian[p.peijianId];
if (conf.suit) {
if (!suitObj[conf.suit]) suitObj[conf.suit] = {num: 0, minLv: 0};
if (!suitObj[conf.suit]) suitObj[conf.suit] = { num: 0, minLv: 0 };
suitObj[conf.suit].num++;
if (!suitObj[conf.suit].minLv || p.lv < suitObj[conf.suit].minLv) suitObj[conf.suit].minLv = p.lv;
}
@ -273,11 +273,16 @@ export class HeroShared {
if (otherBuff?.skills) {
for (let [id, lv] of Object.entries(otherBuff.skills)) {
if (lv && G.gc.xunlianjihua[id].use == 0) {
PublicShared.mergeProperty(buff, Object.fromEntries([G.gc.xunlianjihua[id].skill].map(k => [k, PublicShared.eval(G.gc.xunlianjihua[id].v[0], {slv: lv})])));
PublicShared.mergeProperty(buff, Object.fromEntries([G.gc.xunlianjihua[id].skill].map(k => [k, PublicShared.eval(G.gc.xunlianjihua[id].v[0], { slv: lv })])));
}
}
}
// 威望加成计算
if (otherBuff?.weiwangbuff) {
PublicShared.mergeProperty(buff, otherBuff?.weiwangbuff || {});
}
//最后进行加成属性计算
for (let k in buff) {
if (k.indexOf('pro') == -1) continue;
@ -368,8 +373,8 @@ export class HeroShared {
static getHeroLvUpNeed(id: string | number, lv = 1): atn[] {
return [
{a: 'item', t: '1', n: G.gc.herolvup[lv].expneed},
{a: 'attr', t: 'jinbi', n: G.gc.herolvup[lv].jinbineed}
{ a: 'item', t: '1', n: G.gc.herolvup[lv].expneed },
{ a: 'attr', t: 'jinbi', n: G.gc.herolvup[lv].jinbineed }
];
}