Merge branch 'feature/weiwang' into dev
This commit is contained in:
commit
abf47d251f
17
src/api_s2c/weiwang/ApiOpen.ts
Normal file
17
src/api_s2c/weiwang/ApiOpen.ts
Normal 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 } });
|
||||||
|
}
|
94
src/api_s2c/weiwang/ApiUpLv.ts
Normal file
94
src/api_s2c/weiwang/ApiUpLv.ts
Normal 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.renownlevel) {
|
||||||
|
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;
|
||||||
|
}
|
@ -14,7 +14,7 @@ import { ResLogin } from './shared/protocols/user/PtlLogin';
|
|||||||
import { HeroShared, otherBuff } from './shared/public/hero';
|
import { HeroShared, otherBuff } from './shared/public/hero';
|
||||||
import { PlayerShared } from './shared/public/player';
|
import { PlayerShared } from './shared/public/player';
|
||||||
import { PublicShared } from './shared/public/public';
|
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';
|
import { setGud } from './public/gud';
|
||||||
|
|
||||||
export function extendType() {
|
export function extendType() {
|
||||||
@ -52,7 +52,7 @@ declare module 'tsrpc' {
|
|||||||
/**API 锁 */
|
/**API 锁 */
|
||||||
apiLock: k_v<number>;
|
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>;
|
refreshPower(): Promise<any>;
|
||||||
/**玩家计算在线时长时间戳 */
|
/**玩家计算在线时长时间戳 */
|
||||||
@ -125,7 +125,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 posObj = def || this.heroPos;
|
||||||
let roles: k_v<roleDataType> = {};
|
let roles: k_v<roleDataType> = {};
|
||||||
|
|
||||||
@ -144,7 +144,11 @@ BaseConnection.prototype.getDefaultFightData = async function (this: BaseConnect
|
|||||||
roles[pos] = {
|
roles[pos] = {
|
||||||
...hero,
|
...hero,
|
||||||
attr: {
|
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))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -195,34 +199,34 @@ BaseConnection.prototype.refreshPower = async function (this: BaseConnection<Ser
|
|||||||
zjBuff.zj_liliang += PublicShared.eval(G.gc.com.zjcz_liliang.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 })
|
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]
|
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]
|
zjBuff[k] += item.buff[k]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 名望属性加成
|
// 名望属性加成
|
||||||
if(this.gud.renown > 0) {
|
if (this.gud.renown > 0) {
|
||||||
let mwConf = G.gc.mw_dj
|
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]
|
let mwData = mwConf[i]
|
||||||
for(let k in mwData.buff) {
|
for (let k in mwData.buff) {
|
||||||
zjBuff[k] += mwData.buff[k]
|
zjBuff[k] += mwData.buff[k]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 训练计划加成
|
// 训练计划加成
|
||||||
let skillConf = G.gc.xunlianjihua
|
let skillConf = G.gc.xunlianjihua
|
||||||
if(this.gud.skills) {
|
if (this.gud.skills) {
|
||||||
for(let i in this.gud.skills) {
|
for (let i in this.gud.skills) {
|
||||||
let item = skillConf[i]
|
let item = skillConf[i]
|
||||||
for(let j in zjBuff) {
|
for (let j in zjBuff) {
|
||||||
if((j + 'pro') == item.skill) {
|
if ((j + 'pro') == item.skill) {
|
||||||
zjBuff[j] += Math.floor(zjBuff[j] * PublicShared.eval(item.v, { slv: this.gud.skills[i]}))
|
zjBuff[j] += Math.floor(zjBuff[j] * PublicShared.eval(item.v, { slv: this.gud.skills[i] }))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -239,14 +243,14 @@ BaseConnection.prototype.refreshPower = async function (this: BaseConnection<Ser
|
|||||||
// console.log(zjBuff)
|
// console.log(zjBuff)
|
||||||
if (power != this.gud.power) {
|
if (power != this.gud.power) {
|
||||||
let dbUpdate = { power: power };
|
let dbUpdate = { power: power };
|
||||||
if(power > this.gud?.maxpower){
|
if (power > this.gud?.maxpower) {
|
||||||
//记录历史最大战力
|
//记录历史最大战力
|
||||||
//this.gud.maxpower = power;
|
//this.gud.maxpower = power;
|
||||||
dbUpdate['maxpower'] = power;
|
dbUpdate['maxpower'] = power;
|
||||||
}
|
}
|
||||||
|
|
||||||
//this.gud.power = power;
|
//this.gud.power = power;
|
||||||
setGud(this.uid,dbUpdate);
|
setGud(this.uid, dbUpdate);
|
||||||
|
|
||||||
G.mongodb.collection('user').updateOne({ uid: this.uid }, { $set: dbUpdate });
|
G.mongodb.collection('user').updateOne({ uid: this.uid }, { $set: dbUpdate });
|
||||||
this.sendMsg('msg_s2c/PlayerChange', dbUpdate);
|
this.sendMsg('msg_s2c/PlayerChange', dbUpdate);
|
||||||
@ -311,9 +315,9 @@ ApiCall.prototype.addEventMsg = function (this: ApiCall) {
|
|||||||
if (!this.eventMsg[msgName][msgKey]) this.eventMsg[msgName][msgKey] = {};
|
if (!this.eventMsg[msgName][msgKey]) this.eventMsg[msgName][msgKey] = {};
|
||||||
PublicShared.mergeProperty(this.eventMsg[msgName][msgKey], msg);
|
PublicShared.mergeProperty(this.eventMsg[msgName][msgKey], msg);
|
||||||
} else {
|
} 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
|
this.eventMsg[msgName] = msgKey
|
||||||
}else {
|
} else {
|
||||||
PublicShared.mergeProperty(this.eventMsg[msgName], msgKey);
|
PublicShared.mergeProperty(this.eventMsg[msgName], msgKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
"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<{
|
type gc_clsl_dan = k_v<{
|
||||||
/** 总星级 */
|
/** 总星级 */
|
||||||
'allStar': number
|
'allStar': number
|
||||||
@ -1946,7 +1958,7 @@ type gcType = {
|
|||||||
kfcb_prize: gc_kfcb_prize
|
kfcb_prize: gc_kfcb_prize
|
||||||
yuyuemail: gc_yuyuemail
|
yuyuemail: gc_yuyuemail
|
||||||
tuisonglibao: gc_push_gift
|
tuisonglibao: gc_push_gift
|
||||||
|
renown_level: gc_renown_level
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1957,4 +1969,3 @@ declare global {
|
|||||||
export function initGcType() {
|
export function initGcType() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -352,7 +352,9 @@ class Lng {
|
|||||||
huoqupaihang: "huoqupaihang";
|
huoqupaihang: "huoqupaihang";
|
||||||
wucigonghui: "wucigonghui";
|
wucigonghui: "wucigonghui";
|
||||||
nameyicunzai: "nameyicunzai";
|
nameyicunzai: "nameyicunzai";
|
||||||
ljlibaotips_8:"ljlibaotips_8";
|
ljlibaotips_8: "ljlibaotips_8";
|
||||||
|
|
||||||
|
weiwang_12: "weiwang_12";
|
||||||
|
|
||||||
"11111" = "globalThis.lng.chat_1"
|
"11111" = "globalThis.lng.chat_1"
|
||||||
// return call.error('', { code: -3, message: globalThis.lng.chat_2 });
|
// return call.error('', { code: -3, message: globalThis.lng.chat_2 });
|
||||||
|
9
src/module/collection_weiwang.ts
Normal file
9
src/module/collection_weiwang.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
export type CollectionWeiwang = {
|
||||||
|
uid: string;
|
||||||
|
|
||||||
|
hp: number;
|
||||||
|
atk: number;
|
||||||
|
def: number;
|
||||||
|
|
||||||
|
buff: k_v<number>;
|
||||||
|
}
|
@ -60,6 +60,7 @@ import {CollectionRmbuse} from "./collection_rmbuse";
|
|||||||
import {CollectionFightLog} from "./collection_fightLog";
|
import {CollectionFightLog} from "./collection_fightLog";
|
||||||
import {CollectionShop} from "./collection_shop";
|
import {CollectionShop} from "./collection_shop";
|
||||||
import {CollectionPushGift} from "./collection_pushgift";
|
import {CollectionPushGift} from "./collection_pushgift";
|
||||||
|
import { CollectionWeiwang } from './collection_weiwang';
|
||||||
|
|
||||||
export type MongodbCollections = {
|
export type MongodbCollections = {
|
||||||
user: CollectionUser;
|
user: CollectionUser;
|
||||||
@ -136,4 +137,5 @@ export type MongodbCollections = {
|
|||||||
pushgift:CollectionPushGift
|
pushgift:CollectionPushGift
|
||||||
|
|
||||||
huodong_user: CollectionUser;
|
huodong_user: CollectionUser;
|
||||||
|
weiwang: CollectionWeiwang;
|
||||||
};
|
};
|
@ -1,43 +1,43 @@
|
|||||||
import {ApiCall, TsrpcError} from 'tsrpc';
|
import { ApiCall, TsrpcError } from 'tsrpc';
|
||||||
import {FightControl} from '../shared/fightControl/fightCntrol';
|
import { FightControl } from '../shared/fightControl/fightCntrol';
|
||||||
import {formatNpcData} from '../shared/fightControl/fightFun';
|
import { formatNpcData } from '../shared/fightControl/fightFun';
|
||||||
import {fightResult, joinFightData, roleDataType} from '../shared/fightControl/fightType';
|
import { fightResult, joinFightData, roleDataType } from '../shared/fightControl/fightType';
|
||||||
import {rankInfo} from '../shared/protocols/type';
|
import { rankInfo } from '../shared/protocols/type';
|
||||||
import {HeroShared} from '../shared/public/hero';
|
import { HeroShared } from '../shared/public/hero';
|
||||||
import {PlayerShared} from '../shared/public/player';
|
import { PlayerShared } from '../shared/public/player';
|
||||||
import {HeroFun} from './hero';
|
import { HeroFun } from './hero';
|
||||||
import {UserFun} from './user';
|
import { UserFun } from './user';
|
||||||
import {re, string} from "mathjs";
|
import { re, string } from "mathjs";
|
||||||
import {getGud} from './gud';
|
import { getGud } from './gud';
|
||||||
import {PushGiftFun} from "./pushgift";
|
import { PushGiftFun } from "./pushgift";
|
||||||
|
|
||||||
type fightType = 'tanxian' | 'pata' | 'jjc' | 'gbtx' | 'qjzzd' | 'meirishilian' | 'wzrycross';
|
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();
|
let now = Date.now();
|
||||||
for (let key in fights){
|
for (let key in fights) {
|
||||||
if (now - fights[key].startTime > 30000){
|
if (now - fights[key].startTime > 30000) {
|
||||||
console.log("清理战斗",key);
|
console.log("清理战斗", key);
|
||||||
try{
|
try {
|
||||||
fights[key].release();
|
fights[key].release();
|
||||||
}catch(e){
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
delete fights[key];
|
delete fights[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},5000);
|
}, 5000);
|
||||||
}
|
}
|
||||||
clearFights();
|
clearFights();
|
||||||
|
|
||||||
export class FightFun {
|
export class FightFun {
|
||||||
static fightIndex:number = 0;
|
static fightIndex: number = 0;
|
||||||
|
|
||||||
static fight(data: joinFightData[], maxRoundNums = 30, fightType: "pvp" | "pve" = 'pvp') {
|
static fight(data: joinFightData[], maxRoundNums = 30, fightType: "pvp" | "pve" = 'pvp') {
|
||||||
this.fightIndex++;
|
this.fightIndex++;
|
||||||
@ -80,7 +80,7 @@ export class FightFun {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
player: {...player, buff: PlayerShared.getBuff(player)},
|
player: { ...player, buff: PlayerShared.getBuff(player) },
|
||||||
roles: roles
|
roles: roles
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -101,8 +101,15 @@ export class FightFun {
|
|||||||
|
|
||||||
/**挑战npc */
|
/**挑战npc */
|
||||||
static async fightNpc(call: ApiCall, npcId: string | number, type: fightType, data?: joinFightData) {
|
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["weiwang"] = 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) {
|
if (Object.keys(my.roles).length < 1) {
|
||||||
throw new TsrpcError('至少需要上阵一个英雄');
|
throw new TsrpcError('至少需要上阵一个英雄');
|
||||||
@ -133,11 +140,11 @@ export class FightFun {
|
|||||||
let writeList = ['ganhai', 'jjc', 'hbzbJfs', 'hbzbZbs', 'slzd', 'clsl']
|
let writeList = ['ganhai', 'jjc', 'hbzbJfs', 'hbzbZbs', 'slzd', 'clsl']
|
||||||
if (uid.indexOf('npc') != -1 || !writeList.includes(type)) return;
|
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) {
|
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() || []
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -330,10 +330,12 @@ import { ReqRenownBuy, ResRenownBuy } from './user/PtlRenownBuy';
|
|||||||
import { ReqRenownGetPrize, ResRenownGetPrize } from './user/PtlRenownGetPrize';
|
import { ReqRenownGetPrize, ResRenownGetPrize } from './user/PtlRenownGetPrize';
|
||||||
import { ReqRenownOpen, ResRenownOpen } from './user/PtlRenownOpen';
|
import { ReqRenownOpen, ResRenownOpen } from './user/PtlRenownOpen';
|
||||||
import { ReqTujian, ResTujian } from './user/PtlTujian';
|
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 { ReqDecompose, ResDecompose } from './weixiuchang/PtlDecompose';
|
||||||
import { ReqExchange as ReqExchange_1, ResExchange as ResExchange_1 } from './weixiuchang/PtlExchange';
|
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 { ReqOpen as ReqOpen_62, ResOpen as ResOpen_62 } from './weixiuchang/PtlOpen';
|
||||||
import { ReqUpLv, ResUpLv } from './weixiuchang/PtlUpLv';
|
import { ReqUpLv as ReqUpLv_1, ResUpLv as ResUpLv_1 } from './weixiuchang/PtlUpLv';
|
||||||
import { ReqUpStar, ResUpStar } from './weixiuchang/PtlUpStar';
|
import { ReqUpStar, ResUpStar } from './weixiuchang/PtlUpStar';
|
||||||
import { ReqAutoBaoMing, ResAutoBaoMing } from './wzry/PtlAutoBaoMing';
|
import { ReqAutoBaoMing, ResAutoBaoMing } from './wzry/PtlAutoBaoMing';
|
||||||
import { ReqBaoMing, ResBaoMing } from './wzry/PtlBaoMing';
|
import { ReqBaoMing, ResBaoMing } from './wzry/PtlBaoMing';
|
||||||
@ -343,7 +345,7 @@ import { ReqDldFight, ResDldFight } from './wzry/PtlDldFight';
|
|||||||
import { ReqDldRefre, ResDldRefre } from './wzry/PtlDldRefre';
|
import { ReqDldRefre, ResDldRefre } from './wzry/PtlDldRefre';
|
||||||
import { ReqJingCai, ResJingCai } from './wzry/PtlJingCai';
|
import { ReqJingCai, ResJingCai } from './wzry/PtlJingCai';
|
||||||
import { ReqJingCaiOpen, ResJingCaiOpen } from './wzry/PtlJingCaiOpen';
|
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 { ReqUpdateFight, ResUpdateFight } from './wzry/PtlUpdateFight';
|
||||||
import { ReqWzzd, ResWzzd } from './wzry/PtlWzzd';
|
import { ReqWzzd, ResWzzd } from './wzry/PtlWzzd';
|
||||||
import { ReqZuanShiOpen, ResZuanShiOpen } from './wzry/PtlZuanShiOpen';
|
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 { ReqGet as ReqGet_3, ResGet as ResGet_3 } from './xstask/PtlGet';
|
||||||
import { ReqLvUp as ReqLvUp_4, ResLvUp as ResLvUp_4 } from './xstask/PtlLvUp';
|
import { ReqLvUp as ReqLvUp_4, ResLvUp as ResLvUp_4 } from './xstask/PtlLvUp';
|
||||||
import { ReqOnekeyReceive, ResOnekeyReceive } from './xstask/PtlOnekeyReceive';
|
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 { ReqReceive as ReqReceive_10, ResReceive as ResReceive_10 } from './xstask/PtlReceive';
|
||||||
import { ReqRefresh as ReqRefresh_8, ResRefresh as ResRefresh_8 } from './xstask/PtlRefresh';
|
import { ReqRefresh as ReqRefresh_8, ResRefresh as ResRefresh_8 } from './xstask/PtlRefresh';
|
||||||
import { ReqHandle, ResHandle } from './yongbingzhuzhan/PtlHandle';
|
import { ReqHandle, ResHandle } from './yongbingzhuzhan/PtlHandle';
|
||||||
@ -1569,6 +1571,14 @@ export interface ServiceType {
|
|||||||
req: ReqTujian,
|
req: ReqTujian,
|
||||||
res: ResTujian
|
res: ResTujian
|
||||||
},
|
},
|
||||||
|
"weiwang/Open": {
|
||||||
|
req: ReqOpen_61,
|
||||||
|
res: ResOpen_61
|
||||||
|
},
|
||||||
|
"weiwang/UpLv": {
|
||||||
|
req: ReqUpLv,
|
||||||
|
res: ResUpLv
|
||||||
|
},
|
||||||
"weixiuchang/Decompose": {
|
"weixiuchang/Decompose": {
|
||||||
req: ReqDecompose,
|
req: ReqDecompose,
|
||||||
res: ResDecompose
|
res: ResDecompose
|
||||||
@ -1578,12 +1588,12 @@ export interface ServiceType {
|
|||||||
res: ResExchange_1
|
res: ResExchange_1
|
||||||
},
|
},
|
||||||
"weixiuchang/Open": {
|
"weixiuchang/Open": {
|
||||||
req: ReqOpen_61,
|
req: ReqOpen_62,
|
||||||
res: ResOpen_61
|
res: ResOpen_62
|
||||||
},
|
},
|
||||||
"weixiuchang/UpLv": {
|
"weixiuchang/UpLv": {
|
||||||
req: ReqUpLv,
|
req: ReqUpLv_1,
|
||||||
res: ResUpLv
|
res: ResUpLv_1
|
||||||
},
|
},
|
||||||
"weixiuchang/UpStar": {
|
"weixiuchang/UpStar": {
|
||||||
req: ReqUpStar,
|
req: ReqUpStar,
|
||||||
@ -1622,8 +1632,8 @@ export interface ServiceType {
|
|||||||
res: ResJingCaiOpen
|
res: ResJingCaiOpen
|
||||||
},
|
},
|
||||||
"wzry/Open": {
|
"wzry/Open": {
|
||||||
req: ReqOpen_62,
|
req: ReqOpen_63,
|
||||||
res: ResOpen_62
|
res: ResOpen_63
|
||||||
},
|
},
|
||||||
"wzry/UpdateFight": {
|
"wzry/UpdateFight": {
|
||||||
req: ReqUpdateFight,
|
req: ReqUpdateFight,
|
||||||
@ -1654,8 +1664,8 @@ export interface ServiceType {
|
|||||||
res: ResOnekeyReceive
|
res: ResOnekeyReceive
|
||||||
},
|
},
|
||||||
"xstask/Open": {
|
"xstask/Open": {
|
||||||
req: ReqOpen_63,
|
req: ReqOpen_64,
|
||||||
res: ResOpen_63
|
res: ResOpen_64
|
||||||
},
|
},
|
||||||
"xstask/Receive": {
|
"xstask/Receive": {
|
||||||
req: ReqReceive_10,
|
req: ReqReceive_10,
|
||||||
@ -3488,141 +3498,151 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 331,
|
"id": 331,
|
||||||
"name": "weixiuchang/Decompose",
|
"name": "weiwang/Open",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 332,
|
"id": 332,
|
||||||
"name": "weixiuchang/Exchange",
|
"name": "weiwang/UpLv",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 333,
|
"id": 333,
|
||||||
"name": "weixiuchang/Open",
|
"name": "weixiuchang/Decompose",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 334,
|
"id": 334,
|
||||||
"name": "weixiuchang/UpLv",
|
"name": "weixiuchang/Exchange",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 335,
|
"id": 335,
|
||||||
"name": "weixiuchang/UpStar",
|
"name": "weixiuchang/Open",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 336,
|
"id": 336,
|
||||||
"name": "wzry/AutoBaoMing",
|
"name": "weixiuchang/UpLv",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 337,
|
"id": 337,
|
||||||
"name": "wzry/BaoMing",
|
"name": "weixiuchang/UpStar",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 338,
|
"id": 338,
|
||||||
"name": "wzry/catFightLog",
|
"name": "wzry/AutoBaoMing",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 339,
|
"id": 339,
|
||||||
"name": "wzry/CatGroup",
|
"name": "wzry/BaoMing",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 340,
|
"id": 340,
|
||||||
"name": "wzry/DldFight",
|
"name": "wzry/catFightLog",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 341,
|
"id": 341,
|
||||||
"name": "wzry/DldRefre",
|
"name": "wzry/CatGroup",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 342,
|
"id": 342,
|
||||||
"name": "wzry/JingCai",
|
"name": "wzry/DldFight",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 343,
|
"id": 343,
|
||||||
"name": "wzry/JingCaiOpen",
|
"name": "wzry/DldRefre",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 344,
|
"id": 344,
|
||||||
"name": "wzry/Open",
|
"name": "wzry/JingCai",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 345,
|
"id": 345,
|
||||||
"name": "wzry/UpdateFight",
|
"name": "wzry/JingCaiOpen",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 346,
|
"id": 346,
|
||||||
"name": "wzry/Wzzd",
|
"name": "wzry/Open",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 347,
|
"id": 347,
|
||||||
"name": "wzry/ZuanShiOpen",
|
"name": "wzry/UpdateFight",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 348,
|
"id": 348,
|
||||||
"name": "xstask/AllGet",
|
"name": "wzry/Wzzd",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 349,
|
"id": 349,
|
||||||
"name": "xstask/Get",
|
"name": "wzry/ZuanShiOpen",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 350,
|
"id": 350,
|
||||||
"name": "xstask/LvUp",
|
"name": "xstask/AllGet",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 351,
|
"id": 351,
|
||||||
"name": "xstask/OnekeyReceive",
|
"name": "xstask/Get",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 352,
|
"id": 352,
|
||||||
"name": "xstask/Open",
|
"name": "xstask/LvUp",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 353,
|
"id": 353,
|
||||||
"name": "xstask/Receive",
|
"name": "xstask/OnekeyReceive",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 354,
|
"id": 354,
|
||||||
"name": "xstask/Refresh",
|
"name": "xstask/Open",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 355,
|
"id": 355,
|
||||||
"name": "yongbingzhuzhan/Handle",
|
"name": "xstask/Receive",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 356,
|
"id": 356,
|
||||||
"name": "zhanqianbushu/ChangePos",
|
"name": "xstask/Refresh",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 357,
|
"id": 357,
|
||||||
"name": "zhanqianbushu/Select",
|
"name": "yongbingzhuzhan/Handle",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 358,
|
"id": 358,
|
||||||
|
"name": "zhanqianbushu/ChangePos",
|
||||||
|
"type": "api"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 359,
|
||||||
|
"name": "zhanqianbushu/Select",
|
||||||
|
"type": "api"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 360,
|
||||||
"name": "zhanqianbushu/Up",
|
"name": "zhanqianbushu/Up",
|
||||||
"type": "api"
|
"type": "api"
|
||||||
}
|
}
|
||||||
@ -22052,6 +22072,121 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
|||||||
"user/PtlTujian/ResTujian": {
|
"user/PtlTujian/ResTujian": {
|
||||||
"type": "Interface"
|
"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": {
|
"weixiuchang/PtlDecompose/ReqDecompose": {
|
||||||
"type": "Interface",
|
"type": "Interface",
|
||||||
"properties": [
|
"properties": [
|
||||||
|
11
src/shared/protocols/weiwang/PtlOpen.ts
Normal file
11
src/shared/protocols/weiwang/PtlOpen.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
export interface ReqOpen {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ResOpen {
|
||||||
|
lv: {
|
||||||
|
hp: number
|
||||||
|
atk: number
|
||||||
|
def: number
|
||||||
|
}
|
||||||
|
}
|
12
src/shared/protocols/weiwang/PtlUpLv.ts
Normal file
12
src/shared/protocols/weiwang/PtlUpLv.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
export interface ReqUpLv {
|
||||||
|
lv: number
|
||||||
|
type: "hp" | "atk" | "def"
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ResUpLv {
|
||||||
|
lv: {
|
||||||
|
hp: number
|
||||||
|
atk: number
|
||||||
|
def: number
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user