Merge branch 'dev' of http://git.legu.cc/qixin/HJ_Server into dev
This commit is contained in:
commit
6d4851930f
@ -30,6 +30,6 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||
});
|
||||
|
||||
UserFun.activeHeadFrame(call.uid, 'jjc_rank', data["rank"] + 1);
|
||||
JJCFun.checkUpdatePlayer()
|
||||
//JJCFun.checkUpdatePlayer()
|
||||
|
||||
}
|
51
src/fix_patch/patch_20240110.ts
Normal file
51
src/fix_patch/patch_20240110.ts
Normal file
@ -0,0 +1,51 @@
|
||||
import { patchInit } from "../patch";
|
||||
|
||||
|
||||
class Path {
|
||||
|
||||
async fun1(a: any) {
|
||||
let taskType = 2;
|
||||
let users = await G.mongodb.collection('user').find({ loginTime: { $gte: 1704643200 } }).toArray();
|
||||
for (let i = 0; i < users.length; i++) {
|
||||
let user = users[i];
|
||||
let unFinishTask = (await G.mongodb.collection('task').find({
|
||||
uid: user.uid, type: taskType, finish: 0
|
||||
}, { projection: { taskid: 1 } }).toArray()).map(i => i.taskid);
|
||||
|
||||
if (unFinishTask.length >= 2) {
|
||||
for (let taskid of unFinishTask) {
|
||||
let con = G.gc.task[taskType][taskid];
|
||||
if (!con) {
|
||||
await G.mongodb.collection("task").deleteOne({
|
||||
uid: user.uid, taskid: taskid
|
||||
});
|
||||
console.log(`删除玩家${user.uid}任务:${taskid}`);
|
||||
}
|
||||
if (unFinishTask.includes(con.pretask)) {
|
||||
await G.mongodb.collection("task").deleteOne({
|
||||
uid: user.uid, taskid: taskid
|
||||
});
|
||||
console.log(`删除玩家${user.uid}任务:${taskid}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async run() {
|
||||
await this.fun1(1);
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
await patchInit()
|
||||
let patch = new Path();
|
||||
await patch.run();
|
||||
console.log("逻辑执行完成,等待退出");
|
||||
setTimeout(function () {
|
||||
console.log('结束程序');
|
||||
process.exit();
|
||||
}, 3000);
|
||||
}
|
||||
main();
|
@ -94,37 +94,37 @@ export class JJCFun {
|
||||
* @param uTimeOffset
|
||||
* @param isUpdate 是否更新数据
|
||||
*/
|
||||
static async checkUpdatePlayer(min: number = 0, max: number = 1000, uTimeOffset: number = 600, isUpdate: boolean = true) {
|
||||
// 获取指定排名用户uid
|
||||
let sortInfo = await this.getRankListUid(min, max)
|
||||
if (!sortInfo.length) return []
|
||||
let updateArr = []
|
||||
// static async checkUpdatePlayer(min: number = 0, max: number = 1000, uTimeOffset: number = 600, isUpdate: boolean = true) {
|
||||
// // 获取指定排名用户uid
|
||||
// let sortInfo = await this.getRankListUid(min, max)
|
||||
// if (!sortInfo.length) return []
|
||||
// let updateArr = []
|
||||
|
||||
let users = await G.redis.hGetAll('rank:jjc:data')
|
||||
// let users = await G.redis.hGetAll('rank:jjc:data')
|
||||
|
||||
for (let i = 0; i < sortInfo.length; i++) {
|
||||
let uid = sortInfo[i]
|
||||
let rankInfo = users[uid]
|
||||
if (!rankInfo?.player) continue
|
||||
// 比对utime,判断是否更新数据
|
||||
if (!rankInfo.player.isNpc) {
|
||||
if (!rankInfo.utime || (rankInfo.utime && rankInfo.utime < (G.time - uTimeOffset))) {
|
||||
updateArr.push(rankInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 更新数据
|
||||
if (isUpdate && updateArr.length > 0) {
|
||||
let playerArrInfo = await G.mongodb.collection("user").find({uid: {$in: updateArr.map(i => i.uid)}}).toArray()
|
||||
for (let i = 0; i < playerArrInfo.length; i++) {
|
||||
let playerInfo = playerArrInfo[i]
|
||||
let index = updateArr.findIndex(x => x.player.uid == playerInfo.uid)
|
||||
updateArr[index].player = playerInfo
|
||||
updateArr[index].utime = G.time
|
||||
this.updatePlayerData(playerInfo.uid, updateArr[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// for (let i = 0; i < sortInfo.length; i++) {
|
||||
// let uid = sortInfo[i]
|
||||
// let rankInfo = users[uid]
|
||||
// if (!rankInfo?.player) continue
|
||||
// // 比对utime,判断是否更新数据
|
||||
// if (!rankInfo.player.isNpc) {
|
||||
// if (!rankInfo.utime || (rankInfo.utime && rankInfo.utime < (G.time - uTimeOffset))) {
|
||||
// updateArr.push(rankInfo)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// // 更新数据
|
||||
// if (isUpdate && updateArr.length > 0) {
|
||||
// let playerArrInfo = await G.mongodb.collection("user").find({uid: {$in: updateArr.map(i => i.uid)}}).toArray()
|
||||
// for (let i = 0; i < playerArrInfo.length; i++) {
|
||||
// let playerInfo = playerArrInfo[i]
|
||||
// let index = updateArr.findIndex(x => x.player.uid == playerInfo.uid)
|
||||
// updateArr[index].player = playerInfo
|
||||
// updateArr[index].utime = G.time
|
||||
// this.updatePlayerData(playerInfo.uid, updateArr[index]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取指定范围排名的用户,仅返回uid[]
|
||||
|
@ -260,7 +260,10 @@ export class PayFun {
|
||||
let selectPrize = await G.ioredis.get(`pay:${payId}:${player.uid}`);
|
||||
if (selectPrize) {
|
||||
prize.push(...JSON.parse(selectPrize))
|
||||
G.ioredis.del(`pay:${payId}:${player.uid}`)
|
||||
//支付A check -> 玩家支付 -> 网络延迟
|
||||
//支付B check -> 玩家支付 -> pay -> del
|
||||
//支付A -> pay 时,这里可能被清了,导致给玩家发放了空的奖励,因此,这里不清除
|
||||
//G.ioredis.del(`pay:${payId}:${player.uid}`)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,25 +1,27 @@
|
||||
import { ObjectId, OptionalId } from 'mongodb';
|
||||
import { ApiCall, BaseConnection, TsrpcError } from 'tsrpc';
|
||||
import { checkPlayerGift } from '../api_s2c/event/xianshilibao/fun';
|
||||
import { md_redPoint_check } from '../api_s2c/gongyu/mingdao/ApiOpen';
|
||||
import { CollectionPeiJian } from '../module/collection_peijian';
|
||||
import { Wjjl } from '../module/collection_wjjl';
|
||||
import { MongodbCollections } from '../module/mongodb';
|
||||
import { G123 } from '../sdk/G123';
|
||||
import { ResGetList } from '../shared/protocols/item/PtlGetList';
|
||||
import { ResLogin } from '../shared/protocols/user/PtlLogin';
|
||||
import { player } from '../shared/protocols/user/type';
|
||||
import { HeroShared, otherBuff } from '../shared/public/hero';
|
||||
import { PublicShared } from '../shared/public/public';
|
||||
import { HeroFun } from './hero';
|
||||
import { ShiwuFun } from './shiwu';
|
||||
import { UserFun } from './user';
|
||||
import { getItemByItemId, getItemNum } from './item';
|
||||
import { getGud, setGud } from './gud';
|
||||
import { addGameLog } from "../gameLog";
|
||||
import { PushGiftFun } from "./pushgift";
|
||||
import {ObjectId, OptionalId} from 'mongodb';
|
||||
import {ApiCall, BaseConnection, TsrpcError} from 'tsrpc';
|
||||
import {checkPlayerGift} from '../api_s2c/event/xianshilibao/fun';
|
||||
import {md_redPoint_check} from '../api_s2c/gongyu/mingdao/ApiOpen';
|
||||
import {CollectionPeiJian} from '../module/collection_peijian';
|
||||
import {Wjjl} from '../module/collection_wjjl';
|
||||
import {MongodbCollections} from '../module/mongodb';
|
||||
import {G123} from '../sdk/G123';
|
||||
import {ResGetList} from '../shared/protocols/item/PtlGetList';
|
||||
import {ResLogin} from '../shared/protocols/user/PtlLogin';
|
||||
import {player} from '../shared/protocols/user/type';
|
||||
import {HeroShared, otherBuff} from '../shared/public/hero';
|
||||
import {PublicShared} from '../shared/public/public';
|
||||
import {HeroFun} from './hero';
|
||||
import {ShiwuFun} from './shiwu';
|
||||
import {UserFun} from './user';
|
||||
import {getItemByItemId, getItemNum} from './item';
|
||||
import {getGud, setGud} from './gud';
|
||||
import {addGameLog} from "../gameLog";
|
||||
import {PushGiftFun} from "./pushgift";
|
||||
import { ActionLog } from './actionLog/actionLog';
|
||||
import HeroSkinFun from './heroskin';
|
||||
import { roleDataType } from '../shared/fightControl/fightType';
|
||||
import { PlayerShared } from '../shared/public/player';
|
||||
|
||||
|
||||
export type call = {
|
||||
get otherBuff(): otherBuff;
|
||||
@ -41,6 +43,41 @@ export type call = {
|
||||
};
|
||||
|
||||
export class PlayerFun {
|
||||
/**
|
||||
* 通过uid获取战斗数据
|
||||
* @param uid
|
||||
* @returns
|
||||
*/
|
||||
static async getDefaultFightDataByUid(uid:string){
|
||||
let gud = await getGud(uid);
|
||||
let posObj = gud.heroPos;
|
||||
let roles: k_v<roleDataType> = {};
|
||||
if (gud.selectMatrix && gud.matrixPos) {
|
||||
posObj = gud.matrixPos[gud.selectMatrix];
|
||||
}
|
||||
let heros = await HeroFun.getHeros({uid:uid}, Object.values(posObj).filter(_id => _id != '') as string[]);
|
||||
let otherBuff = UserFun.getOtherBuff(gud)
|
||||
|
||||
Object.entries(posObj).forEach(obj => {
|
||||
let pos = obj[0];
|
||||
let _id = obj[1];
|
||||
let hero = heros.filter(h => h._id == _id)[0];
|
||||
|
||||
if (hero) {
|
||||
roles[pos] = {
|
||||
...hero,
|
||||
attr: {
|
||||
...HeroShared.getHeroBasicAttr(hero, { ...otherBuff, allBuff: HeroShared.getAllBuff(heros) }, Number(pos))
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
player: { ...gud, buff: PlayerShared.getBuff(gud) },
|
||||
roles: roles
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 获取玩家atn数量
|
||||
*/
|
||||
@ -70,13 +107,13 @@ export class PlayerFun {
|
||||
if (err) {
|
||||
// 消耗不足 触发推送礼包
|
||||
PushGiftFun.chkItemGift(call.uid, atn)
|
||||
throw new TsrpcError('', { code: -104, atn: atn });
|
||||
throw new TsrpcError('', {code: -104, atn: atn});
|
||||
} else {
|
||||
return { isOk: false, atn: atn };
|
||||
return {isOk: false, atn: atn};
|
||||
}
|
||||
}
|
||||
}
|
||||
return { isOk: true, atn: null };
|
||||
return {isOk: true, atn: null};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,7 +131,7 @@ export class PlayerFun {
|
||||
atn: need
|
||||
};
|
||||
if (args.length < 1) {
|
||||
throw new TsrpcError('', { code: -104, atn: meet.atn });
|
||||
throw new TsrpcError('', {code: -104, atn: meet.atn});
|
||||
}
|
||||
return await this.checkNeedByArgs(call, ...args);
|
||||
}
|
||||
@ -117,10 +154,10 @@ export class PlayerFun {
|
||||
all.push(this.addItem(call, item));
|
||||
}
|
||||
// 记录消耗
|
||||
addGameLog(call.uid, call.service.name, call.req, { need: val })
|
||||
addGameLog(call.uid, call.service.name, call.req, {need: val})
|
||||
await Promise.all(all);
|
||||
G.emit('USE_ITEM', call.conn.gud, needArr.map(need => {
|
||||
return { ...need, n: Math.abs(need.n) };
|
||||
return {...need, n: Math.abs(need.n)};
|
||||
}));
|
||||
}
|
||||
|
||||
@ -136,18 +173,16 @@ export class PlayerFun {
|
||||
let equip = prizeList.filter(atn => atn.a == 'equip' && atn.n != 0);
|
||||
let shiwu = prizeList.filter(atn => atn.a == 'shiwu' && atn.n != 0);
|
||||
let peijian = prizeList.filter(atn => atn.a == 'peijian' && atn.n != 0);
|
||||
let heroskin = prizeList.filter(atn => atn.a == 'heroskin' && atn.n != 0);
|
||||
|
||||
// 记录获得
|
||||
addGameLog(call.uid, call.service.name, call.req, { prize: prizeList })
|
||||
addGameLog(call.uid, call.service.name, call.req, {prize: prizeList})
|
||||
await Promise.all([
|
||||
attr.length > 0 && this.addAttr(call, attr),
|
||||
item.length > 0 && this.addItem(call, item),
|
||||
hero.length > 0 && this.addHero(call, hero),
|
||||
equip.length > 0 && this.addEquip(call, equip),
|
||||
shiwu.length > 0 && this.addShiwu(call, shiwu),
|
||||
peijian.length > 0 && this.addPeijian(call, peijian),
|
||||
heroskin.length > 0 && this.addHeroskin(call, heroskin),
|
||||
peijian.length > 0 && this.addPeijian(call, peijian)
|
||||
]);
|
||||
|
||||
return prizeList;
|
||||
@ -182,9 +217,9 @@ export class PlayerFun {
|
||||
}
|
||||
}
|
||||
|
||||
if ((atn.t == 'rmbmoney' || atn.t == 'jinbi') && atn.n > 0) {
|
||||
if( (atn.t == 'rmbmoney' || atn.t == 'jinbi') && atn.n > 0 ){
|
||||
//统计今日获取的金币和钻石
|
||||
ActionLog.addDayLog(call.conn.uid, { key: 'got_' + atn.t, val: atn.n });
|
||||
ActionLog.addDayLog(call.conn.uid, { key: 'got_'+atn.t, val: atn.n });
|
||||
}
|
||||
|
||||
// 增加vip经验的任务监听
|
||||
@ -192,7 +227,7 @@ export class PlayerFun {
|
||||
G.emit("Class_task_157", 'Class_task_157', call, atn.n, 0);
|
||||
}
|
||||
all.push(this.changeAttr(call.conn.uid, change));
|
||||
all.push(this.upAttr(call, { ...atn, n: change[atn.t] }));
|
||||
all.push(this.upAttr(call, {...atn, n: change[atn.t]}));
|
||||
//await this.changeAttr(call.conn.uid, change);
|
||||
//await this.upAttr(call, {...atn, n: change[atn.t]});
|
||||
}
|
||||
@ -235,17 +270,17 @@ export class PlayerFun {
|
||||
G.mongodb.collection('rmbuse').insertOne(data);
|
||||
// 消费竞赛开启时写入跨服数据库
|
||||
if (G.huodong.xfjs && !data.isAdd && typeof data.change == 'number') {
|
||||
G.crossmongodb.collection('rmbuse').updateOne({ uid: data.uid, type: `xfjs_${G.huodong.xfjsId}` }, {
|
||||
$set: { time: G.time },
|
||||
$inc: { change: data.change }
|
||||
}, { upsert: true });
|
||||
G.crossmongodb.collection('rmbuse').updateOne({uid: data.uid, type: `xfjs_${G.huodong.xfjsId}`}, {
|
||||
$set: {time: G.time},
|
||||
$inc: {change: data.change}
|
||||
}, {upsert: true});
|
||||
}
|
||||
}
|
||||
|
||||
static async changeAttr(uid: string, change: Partial<player>) {
|
||||
setGud(uid, change);
|
||||
|
||||
G.mongodb.collection('user').updateOne({ uid: uid }, { $set: change });
|
||||
G.mongodb.collection('user').updateOne({uid: uid}, {$set: change});
|
||||
|
||||
if (G.server.uid_connections[uid]) {
|
||||
checkPlayerGift(G.server.uid_connections[uid].gud, change);
|
||||
@ -267,9 +302,9 @@ export class PlayerFun {
|
||||
const curLv = call.conn.gud.lv;
|
||||
while (conf[curLv + addLv + 1] && atn.n >= conf[curLv + addLv + 1].need) {
|
||||
addLv++;
|
||||
G123.sendUserLevelUp({ ...call.conn.gud, lv: curLv + addLv, nexp: atn.n });
|
||||
G123.sendUserLevelUp({...call.conn.gud, lv: curLv + addLv, nexp: atn.n});
|
||||
}
|
||||
addLv && await this.addAttr(call, { lv: curLv + addLv });
|
||||
addLv && await this.addAttr(call, {lv: curLv + addLv});
|
||||
break;
|
||||
case 'payExp':
|
||||
let addVip = 0;
|
||||
@ -278,7 +313,7 @@ export class PlayerFun {
|
||||
while (vipConf[curVip + addVip + 1] && atn.n >= vipConf[curVip + addVip + 1].exp) {
|
||||
addVip++;
|
||||
}
|
||||
addVip && await this.addAttr(call, { vip: curVip + addVip });
|
||||
addVip && await this.addAttr(call, {vip: curVip + addVip});
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -289,7 +324,7 @@ export class PlayerFun {
|
||||
static async addItem(call: call, val: atn[]) {
|
||||
for (let atn of val) {
|
||||
let upObj = {
|
||||
filter: { uid: call.uid, itemId: atn.t },
|
||||
filter: {uid: call.uid, itemId: atn.t},
|
||||
update: {
|
||||
$setOnInsert: {
|
||||
firstTime: G.time,
|
||||
@ -321,7 +356,7 @@ export class PlayerFun {
|
||||
};
|
||||
G.mongodb.collection('item').updateOne(upObj.filter, upObj.update, upObj.options);
|
||||
call.addEventMsg('msg_s2c/ItemChange', atn.t, data);
|
||||
addGameLog(call.uid, "_itemChange", { "additem": 1 }, {
|
||||
addGameLog(call.uid, "_itemChange", {"additem": 1}, {
|
||||
"filter": upObj.filter,
|
||||
"update": upObj.update,
|
||||
"options": upObj.options
|
||||
@ -329,10 +364,10 @@ export class PlayerFun {
|
||||
} else {
|
||||
if (item.num + atn.n <= 0) {
|
||||
await Promise.all([
|
||||
G.mongodb.collection('item').deleteOne({ uid: call.uid, itemId: atn.t })
|
||||
G.mongodb.collection('item').deleteOne({uid: call.uid, itemId: atn.t})
|
||||
]);
|
||||
call.addEventMsg('msg_s2c/ItemChange', atn.t, { num: 0 });
|
||||
addGameLog(call.uid, "_itemChange", { "delitem": 1 }, { "itemId": atn.t })
|
||||
call.addEventMsg('msg_s2c/ItemChange', atn.t, {num: 0});
|
||||
addGameLog(call.uid, "_itemChange", {"delitem": 1}, {"itemId": atn.t})
|
||||
} else {
|
||||
await Promise.all([
|
||||
G.mongodb.collection('item').updateOne(upObj.filter, upObj.update, upObj.options)
|
||||
@ -341,7 +376,7 @@ export class PlayerFun {
|
||||
num: item.num + atn.n,
|
||||
lastTime: upObj.update.$set.lastTime
|
||||
});
|
||||
addGameLog(call.uid, "_itemChange", { "attritem": 1 }, {
|
||||
addGameLog(call.uid, "_itemChange", {"attritem": 1}, {
|
||||
"filter": upObj.filter,
|
||||
"update": upObj.update,
|
||||
"options": upObj.options,
|
||||
@ -376,7 +411,7 @@ export class PlayerFun {
|
||||
|
||||
insertData.forEach((v, key) => {
|
||||
let id = result.insertedIds[key].toHexString();
|
||||
let { _id, ...ops } = v;
|
||||
let {_id, ...ops} = v;
|
||||
|
||||
Wjjl.setVal(call.uid, `has_equip_color_${G.gc.equip[ops.equipId].colour}`, 1, false);
|
||||
|
||||
@ -410,10 +445,10 @@ export class PlayerFun {
|
||||
*/
|
||||
static async cutEquip(call: call, _idArr: string[]) {
|
||||
for (let _id of _idArr) {
|
||||
G.mongodb.collection('equip').deleteOne({ uid: call.uid, _id: new ObjectId(_id) });
|
||||
call.addEventMsg('msg_s2c/EquipChange', _id, { num: 0 });
|
||||
G.mongodb.collection('equip').deleteOne({uid: call.uid, _id: new ObjectId(_id)});
|
||||
call.addEventMsg('msg_s2c/EquipChange', _id, {num: 0});
|
||||
|
||||
addGameLog(call.uid, "_cutEquip", {}, { _id: _id })
|
||||
addGameLog(call.uid, "_cutEquip", {}, {_id: _id})
|
||||
}
|
||||
}
|
||||
|
||||
@ -447,7 +482,7 @@ export class PlayerFun {
|
||||
let v = insertData[key]
|
||||
|
||||
let id = result.insertedIds[key].toHexString();
|
||||
let { _id, ...ops } = v;
|
||||
let {_id, ...ops} = v;
|
||||
|
||||
call.addEventMsg('msg_s2c/HeroChange', id, {
|
||||
_id: id,
|
||||
@ -480,9 +515,9 @@ export class PlayerFun {
|
||||
static async cutHero(call: call, _idArr: string[]) {
|
||||
for (let _id of _idArr) {
|
||||
await HeroFun.delHero(call, _id);
|
||||
G.mongodb.collection('hero').deleteOne({ uid: call.uid, _id: new ObjectId(_id) });
|
||||
call.addEventMsg('msg_s2c/HeroChange', _id, { num: 0 });
|
||||
addGameLog(call.uid, "_cutHero", {}, { _id: _id })
|
||||
G.mongodb.collection('hero').deleteOne({uid: call.uid, _id: new ObjectId(_id)});
|
||||
call.addEventMsg('msg_s2c/HeroChange', _id, {num: 0});
|
||||
addGameLog(call.uid, "_cutHero", {}, {_id: _id})
|
||||
}
|
||||
}
|
||||
|
||||
@ -497,7 +532,7 @@ export class PlayerFun {
|
||||
colour: v.colour,
|
||||
wearId: '',
|
||||
shiwuId: v.t,
|
||||
jichu: ShiwuFun.randomJichu({ colour: v.colour, shiwuId: v.t }),
|
||||
jichu: ShiwuFun.randomJichu({colour: v.colour, shiwuId: v.t}),
|
||||
fujia: []
|
||||
};
|
||||
if (v.shiwuBuff) {
|
||||
@ -517,7 +552,7 @@ export class PlayerFun {
|
||||
|
||||
insertData.forEach((v, key) => {
|
||||
let id = result.insertedIds[key].toHexString();
|
||||
let { _id, ...ops } = v;
|
||||
let {_id, ...ops} = v;
|
||||
call.addEventMsg('msg_s2c/ShiwuChange', id, {
|
||||
_id: id,
|
||||
...ops
|
||||
@ -536,9 +571,9 @@ export class PlayerFun {
|
||||
*/
|
||||
static async cutShiwu(call: call, _idArr: string[]) {
|
||||
for (let _id of _idArr) {
|
||||
G.mongodb.collection('shiwu').deleteOne({ uid: call.uid, _id: new ObjectId(_id) });
|
||||
call.addEventMsg('msg_s2c/ShiwuChange', _id, { num: 0 });
|
||||
addGameLog(call.uid, "_cutShiwu", {}, { _id: _id })
|
||||
G.mongodb.collection('shiwu').deleteOne({uid: call.uid, _id: new ObjectId(_id)});
|
||||
call.addEventMsg('msg_s2c/ShiwuChange', _id, {num: 0});
|
||||
addGameLog(call.uid, "_cutShiwu", {}, {_id: _id})
|
||||
}
|
||||
}
|
||||
|
||||
@ -563,7 +598,7 @@ export class PlayerFun {
|
||||
addGameLog(call.uid, "_addPeiJian", {}, insertData)
|
||||
|
||||
insertData.forEach((v, key) => {
|
||||
let { _id, uid, ...ops } = v;
|
||||
let {_id, uid, ...ops} = v;
|
||||
let id = _id.toHexString();
|
||||
|
||||
if (G.gc.peijian[v.peijianId].colour != 5) {
|
||||
@ -571,8 +606,8 @@ export class PlayerFun {
|
||||
lshd[v.peijianId]++;
|
||||
}
|
||||
|
||||
G.redis.set('peijian', call.uid, id, { _id: id, ...ops });
|
||||
call.addEventMsg('msg_s2c/PeijianChange', id, { _id: id, ...ops });
|
||||
G.redis.set('peijian', call.uid, id, {_id: id, ...ops});
|
||||
call.addEventMsg('msg_s2c/PeijianChange', id, {_id: id, ...ops});
|
||||
});
|
||||
|
||||
G.mongodb.collection('playerInfo', 'lshd_peijian').updateOne(
|
||||
@ -593,39 +628,15 @@ export class PlayerFun {
|
||||
return Object.values(result.insertedIds).map(v => G.mongodb.conversionId(v));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加皮肤
|
||||
* */
|
||||
static async addHeroskin(call: call, val: atn[]) {
|
||||
let prize = [];
|
||||
let upskin = {};
|
||||
let heroskin = HeroSkinFun.getHeroSkin(call);
|
||||
for (let p of val) {
|
||||
if (!heroskin[p.t]) {
|
||||
upskin[p.t] = 1;
|
||||
} else {
|
||||
prize.concat(G.gc.heroSkin[p.t].zhuanhuan);
|
||||
}
|
||||
}
|
||||
if (Object.keys(upskin).length > 0) {
|
||||
this.addAttr(call, { heroskin: Object.assign(heroskin, upskin) });
|
||||
}
|
||||
|
||||
// 皮肤存在转换为其他奖励
|
||||
if (prize.length > 0) {
|
||||
this.sendPrize(call, prize);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除配件
|
||||
*/
|
||||
static async cutPeijian(call: call, _idArr: string[]) {
|
||||
for (let _id of _idArr) {
|
||||
G.redis.del('peijian', call.uid, _id);
|
||||
G.mongodb.collection('peijian').deleteOne({ uid: call.uid, _id: new ObjectId(_id) });
|
||||
call.addEventMsg('msg_s2c/PeijianChange', _id, { num: 0 });
|
||||
addGameLog(call.uid, "_cutPeijian", {}, { _id: _id })
|
||||
G.mongodb.collection('peijian').deleteOne({uid: call.uid, _id: new ObjectId(_id)});
|
||||
call.addEventMsg('msg_s2c/PeijianChange', _id, {num: 0});
|
||||
addGameLog(call.uid, "_cutPeijian", {}, {_id: _id})
|
||||
}
|
||||
}
|
||||
|
||||
@ -634,7 +645,7 @@ export class PlayerFun {
|
||||
*/
|
||||
static async getAttr(uid: string, where: { ctype: string; }) {
|
||||
let _w = where;
|
||||
Object.assign(_w, { uid: uid });
|
||||
Object.assign(_w, {uid: uid});
|
||||
const _res = await G.mongodb.collection('playattr').find(_w).toArray();
|
||||
_res.forEach(v => {
|
||||
if (v._id) {
|
||||
@ -649,7 +660,7 @@ export class PlayerFun {
|
||||
*/
|
||||
static async getAttrOne(uid: string, where: { ctype: string; }) {
|
||||
let _w = where;
|
||||
Object.assign(_w, { uid: uid });
|
||||
Object.assign(_w, {uid: uid});
|
||||
const _res = await G.mongodb.collection('playattr').findOne(_w);
|
||||
if (_res) {
|
||||
delete _res['_id'];
|
||||
@ -665,10 +676,10 @@ export class PlayerFun {
|
||||
time = G.time;
|
||||
}
|
||||
let _zeroTime = PublicShared.getToDayZeroTime(time);
|
||||
let _tmp = { lasttime: { $gte: _zeroTime, $lte: _zeroTime + 24 * 60 * 60 - 1 } };
|
||||
let _tmp = {lasttime: {$gte: _zeroTime, $lte: _zeroTime + 24 * 60 * 60 - 1}};
|
||||
|
||||
let _w = where;
|
||||
Object.assign(_w, { uid: uid, ..._tmp });
|
||||
Object.assign(_w, {uid: uid, ..._tmp});
|
||||
const _res = await G.mongodb.collection('playattr').find(_w).toArray();
|
||||
_res.forEach(v => {
|
||||
if (v._id) {
|
||||
@ -683,7 +694,7 @@ export class PlayerFun {
|
||||
*/
|
||||
static async setAttr(uid: string, where: { ctype: string; }, data: {}, islasttime = 1) {
|
||||
let _w = where;
|
||||
Object.assign(_w, { uid: uid });
|
||||
Object.assign(_w, {uid: uid});
|
||||
|
||||
if (islasttime == 1) {
|
||||
data["lasttime"] = G.time;
|
||||
@ -694,7 +705,7 @@ export class PlayerFun {
|
||||
// 加入创建数据时间
|
||||
data["ctime"] = G.time;
|
||||
}
|
||||
let _res = await G.mongodb.collection('playattr').updateMany(_w, { $set: data }, { upsert: true });
|
||||
let _res = await G.mongodb.collection('playattr').updateMany(_w, {$set: data}, {upsert: true});
|
||||
return _res;
|
||||
}
|
||||
}
|
@ -305,8 +305,11 @@ export class UserFun {
|
||||
gud.headFrames[conf.id] += val * v;
|
||||
}
|
||||
}
|
||||
else if(conf?.cond?.[0] == "jjc_rank") {
|
||||
change = true;
|
||||
gud.headFrames[conf.id] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (change) {
|
||||
PlayerFun.changeAttr(uid, {headFrames: gud.headFrames});
|
||||
G.server.sendMsgByUid(uid, 'msg_s2c/PlayerChange', {headFrames: gud.headFrames});
|
||||
|
@ -151,25 +151,25 @@ export class FightControl {
|
||||
beforeSkill() {
|
||||
this.eachLiveRoles((role) => {
|
||||
let heroId = role.roleData.heroId;
|
||||
let shiwu = role.roleData?.shiwu || {};
|
||||
let talent = role.roleData?.talent || {};
|
||||
// let shiwu = role.roleData?.shiwu || {};
|
||||
// let talent = role.roleData?.talent || {};
|
||||
let skills = G.gc.heroskill[heroId][role.roleData.jieji || 0].bdskill || [];
|
||||
skills = skills.concat(role.roleData.attr.skillArr);
|
||||
|
||||
for (let key in shiwu) {
|
||||
let zhushuan = shiwu[key]?.zhuanshu;
|
||||
if (!zhushuan) continue;
|
||||
if (zhushuan.skill) skills.push(zhushuan.skill);
|
||||
};
|
||||
const hero_tf = G.gc.hero_tf;
|
||||
for (let key in talent) {
|
||||
let cdata = hero_tf[key][talent[key]];
|
||||
if (cdata && cdata.skill_effect) skills.push(cdata.skill_effect);
|
||||
}
|
||||
// for (let key in shiwu) {
|
||||
// let zhushuan = shiwu[key]?.zhuanshu;
|
||||
// if (!zhushuan) continue;
|
||||
// if (zhushuan.skill) skills.push(zhushuan.skill);
|
||||
// };
|
||||
// const hero_tf = G.gc.hero_tf;
|
||||
// for (let key in talent) {
|
||||
// let cdata = hero_tf[key][talent[key]];
|
||||
// if (cdata && cdata.skill_effect) skills.push(cdata.skill_effect);
|
||||
// }
|
||||
|
||||
// skills.push('tx06309');
|
||||
|
||||
if (!skills) return;
|
||||
//if (!skills) return;
|
||||
skills.forEach(_skill => {
|
||||
let askillconf = getSkillConf(_skill);
|
||||
if (!askillconf) return console.log('没有技能配置-->', _skill);
|
||||
|
Loading…
Reference in New Issue
Block a user