This commit is contained in:
xichaoyin 2024-01-10 14:29:20 +08:00
commit 6d4851930f
7 changed files with 210 additions and 142 deletions

View File

@ -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()
}

View 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();

View File

@ -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[]

View File

@ -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}`)
}
}

View File

@ -19,7 +19,9 @@ 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数量
*/
@ -136,7 +173,6 @@ 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})
@ -146,8 +182,7 @@ export class PlayerFun {
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;
@ -593,30 +628,6 @@ 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);
}
}
/**
*
*/

View File

@ -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});

View File

@ -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);