This commit is contained in:
xichaoyin 2024-01-10 18:07:13 +08:00
commit 6895a14d04
40 changed files with 3026 additions and 724 deletions

View File

@ -35,7 +35,7 @@ function dockerLogin() {
const region = 'ap-northeast-1';
const instanceId = 'cri-fe5eqsg73zl4vd4m';
const version = '2018-12-01';
const command = `aliyun cr GetAuthorizationToken --profile dev --region ${region} --InstanceId ${instanceId} --version ${version} --force`;
const command = `aliyun cr GetAuthorizationToken --profile heijiao-dev --region ${region} --InstanceId ${instanceId} --version ${version} --force`;
const output = execSync(command, { encoding: 'utf8' });
const result = JSON.parse(output);
const password = result.AuthorizationToken.replace(/"/g, '');

View File

@ -35,7 +35,7 @@ function dockerLogin() {
const region = 'ap-northeast-1';
const instanceId = 'cri-azy285s79zw3ti5v';
const version = '2018-12-01';
const command = `aliyun cr GetAuthorizationToken --profile prod --region ${region} --InstanceId ${instanceId} --version ${version} --force`;
const command = `aliyun cr GetAuthorizationToken --profile heijiao-prod --region ${region} --InstanceId ${instanceId} --version ${version} --force`;
const output = execSync(command, { encoding: 'utf8' });
const result = JSON.parse(output);
const password = result.AuthorizationToken.replace(/"/g, '');

View File

@ -0,0 +1,41 @@
import HQJGFun from "./fun";
import { ApiCall } from "tsrpc";
import { PlayerFun } from "../../../public/player";
import { ReqDuiHuan, ResDuiHuan } from "../../../shared/protocols/event/huangqijiuguan/PtlDuiHuan";
export default async function (call: ApiCall<ReqDuiHuan, ResDuiHuan>) {
let hd = await HQJGFun.HdInfo(call, call.req.hdid);
if (!hd || Object.keys(hd).length <= 0) {
// 无此活动
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
}
let need = [];
let prize = [];
let mydata = await HQJGFun.getMydata(call, call.req.hdid);
for (let id in call.req.dh) {
let con = hd.data.duihuan.filter(x => x.id == Number(id))[0];
if ((mydata.duihuan[id] || 0) + call.req.dh[id] > con.buyNum) {
return call.error("", { code: -2, message: globalThis.lng.hqjgtips_28 })
}
for (let i = 0; i < call.req.dh[id]; i++) {
need.push(...con.need);
prize.push(...con.prize);
}
mydata.duihuan[id] = (mydata.duihuan[id] || 0) + call.req.dh[id];
}
// 检查消耗
await PlayerFun.checkNeedIsMeet(call, need);
// 发送奖励
await PlayerFun.sendPrize(call, prize);
// 记录兑换次数
await HQJGFun.setMyData(call.uid, hd.hdid, { duihuan: mydata.duihuan });
call.succ({ prize: prize, data: mydata })
}

View File

@ -0,0 +1,40 @@
import { ApiCall } from "tsrpc";
import { ReqFight, ResFight } from "../../../shared/protocols/event/huangqijiuguan/PtlFight";
import { HuoDongFun } from "../../../public/huodongfun";
import HQJGFun from "./fun";
import { fightResult } from "../../../shared/fightControl/fightType";
import { FightFun } from "../../../public/fight";
export default async function (call: ApiCall<ReqFight, ResFight>) {
let hd = await HQJGFun.HdInfo(call, call.req.hdid);
if (!hd) {
// 无此活动
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
}
// 个人活动信息
let mydata = await HQJGFun.getMydata(call, call.req.hdid);
// 开始战斗
let result: fightResult = await FightFun.fightNpc(call, hd.data.bossId, 'hqjg');
let up = false;
let today = HQJGFun.today(hd);
// 历史最大伤害
if (result.totalDamage[0] > mydata.bossres.maxdps) {
up = true;
mydata.bossres.maxdps = result.totalDamage[0];
}
// 今日最大伤害
if (result.totalDamage[0] > (mydata.bossres.todaydps[today] || 0)) {
up = true;
mydata.bossres.todaydps[today] = result.totalDamage[0];
}
// 更新伤害数据
up && await HQJGFun.setMyData(call.uid, call.req.hdid, { bossres: mydata.bossres });
call.succ({ data: mydata, result: result });
}

View File

@ -0,0 +1,15 @@
import HQJGFun from "./fun";
import { ApiCall } from "tsrpc";
import { ReqOpen, ResOpen } from "../../../shared/protocols/event/huangqijiuguan/PtlOpen";
export default async (call: ApiCall<ReqOpen, ResOpen>) => {
let hd = await HQJGFun.HdInfo(call, call.req.hdid);
if (!hd || Object.keys(hd).length <= 0) {
// 无此活动
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
}
let mydata = await HQJGFun.getMydata(call, call.req.hdid);
call.succ({ data: mydata })
}

View File

@ -0,0 +1,7 @@
import { ApiCall } from "tsrpc";
import { ReqRankList, ResRankList } from "../../../shared/protocols/event/huangqijiuguan/PtlRankList";
import HQJGFun from "./fun";
export default async function (call: ApiCall<ReqRankList, ResRankList>) {
HQJGFun.getRankList(call.req.hdid).then(data => call.succ({ rankList: data }));
}

View File

@ -0,0 +1,46 @@
import { ApiCall } from "tsrpc";
import HQJGFun, { Data } from "./fun";
import { ReqRecDpsPrize, ResRecDpsPrize } from "../../../shared/protocols/event/huangqijiuguan/PtlRecDpsPrize";
import { PlayerFun } from "../../../public/player";
export default async function (call: ApiCall<ReqRecDpsPrize, ResRecDpsPrize>) {
let hd = await HQJGFun.HdInfo(call, call.req.hdid);
if (!hd) {
// 无此活动
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
}
let data = hd.data as Data
// 个人活动信息
let mydata = await HQJGFun.getMydata(call, call.req.hdid);
// 领取伤害奖励
let prize = [];
for (let rec of call.req.recid) {
let con = data.bossTask.filter(x => x.id == rec)[0];
if (mydata.bossres.recdpstask.includes(con.id)) {
continue
}
if (con.need > (mydata.bossres.maxdps || 0)) {
continue
}
mydata.bossres.recdpstask.push(con.id);
prize = prize.concat(con.prize);
}
if (prize.length <= 0) {
call.error("", { code: -2, message: lng.hqjgtips_27 });
} else {
// 发送奖励
await PlayerFun.sendPrize(call, prize);
// 设置领奖记录
await HQJGFun.setMyData(call.uid, call.req.hdid, { bossres: mydata.bossres });
}
call.succ({ data: mydata, prize: prize })
}

View File

@ -0,0 +1,52 @@
import HQJGFun from "./fun";
import { ApiCall } from "tsrpc";
import { ReqTaskRec, ResTaskRec } from "../../../shared/protocols/event/huangqijiuguan/PtlTaskRec";
import { PlayerFun } from "../../../public/player";
export default async function (call: ApiCall<ReqTaskRec, ResTaskRec>) {
let hd = await HQJGFun.HdInfo(call, call.req.hdid);
if (!hd || Object.keys(hd).length <= 0) {
// 无此活动
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
}
let today = HQJGFun.today(hd);
if (today < call.req.day) {
// 未到领取时间
return call.error('', { code: -1, message: globalThis.lng.hqjgtips_29 })
}
let prize = [];
let taskday = `day${call.req.day}`
let mydata = await HQJGFun.getMydata(call, call.req.hdid);
for (let id of call.req.taskid) {
let con = hd.data.task[taskday][id];
if (!con) {
continue
}
if (mydata.task.rec[taskday] && mydata.task.rec[taskday].includes(id)) {
continue
}
if (!mydata.task.val[taskday] || (mydata.task.val[taskday][id] || 0) < con.pval) {
continue
}
prize = prize.concat(con.prize);
mydata.task.rec[taskday] = (mydata.task.rec[taskday] || []).push(id)
}
if (prize.length <= 0) {
return call.error("", { code: -2, message: globalThis.lng.hqjgtips_28 })
}
// 发送奖励
await PlayerFun.sendPrize(call, prize);
// 设置领取记录
await HQJGFun.setMyData(call.uid, call.req.hdid, mydata);
call.succ({ data: mydata, prize: prize });
}

View File

@ -0,0 +1,48 @@
import { ApiCall } from "tsrpc";
import { ReqZhaoMu, ResZhaoMu } from "../../../shared/protocols/event/huangqijiuguan/PtlZhaoMu";
import HQJGFun from "./fun";
import { PlayerFun } from "../../../public/player";
import { PublicShared } from "../../../shared/public/public";
export default async function (call: ApiCall<ReqZhaoMu, ResZhaoMu>) {
let hd = await HQJGFun.HdInfo(call, call.req.hdid);
if (!hd || Object.keys(hd).length <= 0) {
// 无此活动
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
}
let need = [{ a: hd.data.huobi.a, t: hd.data.huobi.t, n: hd.data.huobi.n * call.req.num }];
// 检测消耗
await PlayerFun.checkNeedIsMeet(call, need);
let prize = [];
let mydata = await HQJGFun.getMydata(call, call.req.hdid);
for (let n = 1; n <= call.req.num; n++) {
let num = mydata.zhaomu.num + n;
let baodi = hd.data.baodi.filter(x => x.num == num);
if (baodi.length > 0) {
// 触发保底
prize = prize.concat(baodi[0].prize);
} else {
// 常规掉落
let temp = PublicShared.randomDropAny<{
a: string, t: string, n: number, p: number
}>(
hd.data.chouka.filter(x => x.cishu <= num)
);
prize.push({ a: temp.a, t: temp.t, n: temp.n });
}
mydata.zhaomu.num = num;
}
// 扣除消耗
await PlayerFun.cutNeed(call, need);
// 发送奖励
await PlayerFun.sendPrize(call, prize);
// 设置抽卡数据
await HQJGFun.setMyData(call.uid, call.req.hdid, { zhaomu: mydata.zhaomu });
call.succ({ data: mydata, prize: prize })
}

View File

@ -0,0 +1,42 @@
import { ApiCall } from "tsrpc";
import { ReqZhaoMuPrizeRec, ResZhaoMuPrizeRec } from "../../../shared/protocols/event/huangqijiuguan/PtlZhaoMuPrizeRec";
import HQJGFun from "./fun";
import { PlayerFun } from "../../../public/player";
export default async function (call: ApiCall<ReqZhaoMuPrizeRec, ResZhaoMuPrizeRec>) {
let hd = await HQJGFun.HdInfo(call, call.req.hdid);
if (!hd || Object.keys(hd).length <= 0) {
// 无此活动
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
}
let prize = [];
let mydata = await HQJGFun.getMydata(call, call.req.hdid);
for (let rec of call.req.recid) {
let con = hd.data.choukajiangli[rec.idx];
if (con.num > mydata.zhaomu.num || mydata.zhaomu.prize.includes(rec.idx)) {
continue
}
if (con.dlz) {
prize.push(con.dlz[rec.sec]);
} else {
prize = prize.concat(con.prize);
}
mydata.zhaomu.prize.push(rec.idx);
}
if (prize.length <= 0) {
return call.error('', { code: -2, message: globalThis.lng.hqjgtips_28 })
}
// 发送奖励
await PlayerFun.sendPrize(call, prize);
// 设置领取数据
await HQJGFun.setMyData(call.uid, call.req.hdid, { zhaomu: mydata.zhaomu });
call.succ({ prize: prize, data: mydata })
}

View File

@ -0,0 +1,334 @@
import { ApiCall } from "tsrpc"
import { ReqAddHuoDong } from "../../../monopoly/protocols/PtlAddHuoDong"
import { HuoDongFun } from "../../../public/huodongfun"
import { PublicShared } from "../../../shared/public/public"
import { EmailFun } from "../../../public/email"
// hddata.data
export interface Data {
show: 1
task: {
[k: `day${number}`]: {
[k: string]: { pval: number, stype: string, cond: string[], tiaozhuan: number, prize: atn[], des: string }
}
}
huobi: atn // 抽卡货币
bossId: number // boss表的ID
// boss排行邮件
bossRank_des: string
bossRank_title: string
// boss挑战等级奖励邮
bossLvReward_des: string
bossLvReward_title: string
chouka: { a: string, t: string, n: number, p: number, gailv: number, cishu: number }[]
choukajiangli: { num: number, prize?: any[], dlz: { [k: string]: atn } }[]
baodi: { num: number, prize: any[] }[]
gift: { id: number, free: boolean, payId: string, buynum: number, prize: atn[] }[]
duihuan: { id: number, need: atn[], prize: atn[], buyNum: number }[]
bossLvReward: { lv: number, need: number, prize: atn[] }[]
bossTask: { id: number, need: number, prize: atn[] }[]
bossRank: { id: string, rank: [number, number], prize: atn[] }
}
export interface PlayerData {
// 招募数据
zhaomu: {
// 招募次数
num: number
// 次数奖励领取记录
prize: number[]
};
// 任务计数
task: {
rec: { [k: `day${number}`]: number[] }
val: { [k: `day${number}`]: { [id: string]: number } }
},
// 礼包购买记录
giftbuy: { [id: string]: { num: number, select: number[] } }
// 兑换次数记录
duihuan: { [id: string]: number }
// boss挑战数据
bossres: {
// 历史最大伤害
maxdps: number
// 今日最大伤害
todaydps: {
[k: string]: number
}
// 今日奖励领取记录
recdpstask: number[]
}
// 最后修改数据时间
lasttime: number
}
export default class HQJGFun {
static get htype() {
return 15
};
static rankkey(hdid: number) {
return `rank:huangqijiuguan_${hdid}`
}
/** 默认数据 */
static get defaultData() {
return {
zhaomu: {
num: 0,
prize: []
},
task: {
val: {},
rec: {}
},
giftbuy: {},
duihuan: {},
bossres: {
maxdps: 0,
zhanli: 0,
todaydps: {},
recdpstask: []
},
lasttime: 0
}
}
static today(hdinfo: ReqAddHuoDong) {
/**
* 1
*/
return PublicShared.getDiff(hdinfo.stime, G.time)
}
/**
*
*/
static async getRankList(hdid: number) {
let uids = await G.mongodb.collection("event").find(
{ type: this.dataType(hdid) },
{
sort: { "bossres.maxdps": -1, "bossres.zhanli": -1 },
projection: { uid: 1, bossres: 1 }
}
).limit(50).toArray();
let userinfo = await G.mongodb.collection('user').find(
{ uid: { $in: uids.map(v => v.uid) } },
).toArray();
let res = [];
for (let rank = 1; rank <= uids.length; rank++) {
let uid = uids[rank - 1].uid;
let user = userinfo.find(v => v.uid == uid);
if (user) {
res.push({ rank, ...user, valArr: [uids[rank - 1].bossres.maxdps] });
}
}
return res
}
/** 数据类型 */
static dataType(hdid: number) {
return `huangqijiuguan_${hdid}` as `huangqijiuguan_${number}`
}
/** 获取活动数据 */
static async HdInfo(call: ApiCall, hdid?: number): Promise<ReqAddHuoDong & { data: Data }> {
if (!hdid) {
let hdlist = await HuoDongFun.gethdList(
call, this.htype
);
return hdlist.length > 0 ? hdlist[0] : null
} else {
return await HuoDongFun.getHdidInfo(call, hdid) as any as ReqAddHuoDong & { data: Data }
}
}
/** 获取我的数据 */
static async getMydata(call: ApiCall, hdid?: number) {
if (!hdid) {
hdid = (await HQJGFun.HdInfo(call)).hdid;
}
let data = await G.mongodb.cEvent(this.dataType(hdid)).findOne({
uid: call.uid, type: this.dataType(hdid)
}, { projection: { _id: 0 } });
if (!data) {
data = (await G.mongodb.cEvent(this.dataType(hdid)).findOneAndUpdate({
uid: call.uid, type: this.dataType(hdid)
}, {
$set: this.defaultData
}, { upsert: true, returnDocument: 'after', projection: { _id: 0 } })).value;
}
return data
}
/** 设置我的数据 */
static async setMyData(uid: string, hdid: number, update: { [k in keyof Partial<PlayerData>]: PlayerData[k] }) {
if (!update.lasttime) {
update.lasttime = G.time;
}
let res = await G.mongodb.cEvent(this.dataType(hdid)).updateOne(
{ uid: uid, type: this.dataType(hdid) }, { $set: update }
);
if (res.upsertedCount <= 0) {
await G.mongodb.cEvent(this.dataType(hdid)).updateOne(
{ uid: uid, type: this.dataType(hdid) }, { $set: Object.assign(this.defaultData, update) }
);
}
}
static async buy(call: ApiCall, payId: string) {
let hddata = await this.HdInfo(call);
if (!hddata) { // 活动不存在
return
}
let mydata = await this.getMydata(call);
await this.setMyData(call.uid, (await this.HdInfo(call)).hdid, mydata);
}
/**
*
*/
static async dayDpsLvPrize(time: number) {
console.log(
"黄旗酒馆 每日伤害等级奖励结算 开始执行。。。"
)
// 取stime小于当前时间的最后一条数据
let hdinfo = await G.mongodb.collection("hdinfo").find({
htype: this.htype, stime: { $lte: time }
}, { sort: { stime: -1 } }).limit(1).toArray();
// 没有活动数
if (hdinfo.length <= 0) {
return
}
let hd = hdinfo[0];
let hdid = hdinfo[0].hdid;
// 活动结束
if (hd.etime < G.time - 300) {
return
}
let today = PublicShared.getDiff(hd.stime, G.time - 300);
G.mongodb.collection("event").find({ type: `huangqijiuguan_${hdid}` }).toArray().then(datas => {
let hddata = hd.data as Data;
for (let i = 0; i < datas.length; i++) {
let data = datas[i];
let lvprize: { lv: number; need?: number; prize?: atn[] };
let dps = data.bossres.todaydps[today] || 0;
for (let lvinfo of hddata.bossLvReward) {
if (dps < lvinfo.need) {
continue;
}
if (!lvprize || lvprize.lv < lvinfo.lv) {
lvprize = lvinfo;
}
}
if (!lvprize) continue
let title = hddata.bossLvReward_title;
let content = hddata.bossLvReward_des;
EmailFun.addEmail({
uid: data.uid,
title: title,
type: "system",
content: content,
prize: lvprize.prize,
contentInsertArr: [lvprize.lv],
})
}
console.log(
"黄旗酒馆 每日伤害等级奖励结算 执行完成!!!"
)
})
}
/**
*
*/
static async endDpsRankPrize(time: number) {
console.log(
"黄旗酒馆 最大伤害排行奖励结算 开始执行。。。"
)
let today = PublicShared.getToDayZeroTime(time + 300);
let yesterday = PublicShared.getToDayZeroTime(time - 300);
// 查询昨天23:59:00或者今天00:00:00结束的活动
let hdinfo = await G.mongodb.collection("hdinfo").find({
htype: this.htype, rtime: { $gt: yesterday, $lte: today }
}).toArray();
// 没有活动数
if (hdinfo.length <= 0) {
return
}
let hd = hdinfo[0];
let hdid = hdinfo[0].hdid;
if (hd.data.sendrank) {
return
}
let uids = await G.mongodb.collection("event").find(
{ type: this.dataType(hdid) },
{
sort: { "bossres.maxdps": -1, "bossres.zhanli": -1 },
projection: { uid: 1, bossres: 1 }
}
).toArray();
for (let rank = 1; rank <= uids.length; rank++) {
let con = hd.data.bossRank.filter(
(x: { rank: number[] }) => rank >= x.rank[0] && rank <= x.rank[1]
)[0];
if (!con) continue;
// 发送排名奖励
await EmailFun.addEmail({
uid: uids[rank - 1].uid,
title: hd.data.bossRank_title,
type: "system",
content: hd.data.bossRank_des,
prize: con.prize,
contentInsertArr: [rank],
})
}
// 标记已发送
await G.mongodb.collection("hdinfo").updateOne(
{ hdid: hdid }, { $set: { "data.sendrank": true } }
);
console.log(
"黄旗酒馆 最大伤害排行奖励结算 执行结束!!!"
)
}
}
G.on("NEW_DAY", HQJGFun.dayDpsLvPrize.bind(HQJGFun));
G.on("NEW_DAY", HQJGFun.endDpsRankPrize.bind(HQJGFun));

View File

@ -24,7 +24,10 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
await PayFun.delPayLog(
call.uid, { payId: G.gc.zhanling.payId, val: [] }
);
// 战令重置的时候需要删除所有的任务进度,但是每天的任务进度不做处理,因为每天会自然重置,怕玩家会刷
// ZhanLingTasks.clearLog(call.uid, 'day');
ZhanLingTasks.clearLog(call.uid, 'week');
ZhanLingTasks.clearLog(call.uid, 'round');
data = (await G.mongodb.cEvent('zhanling').findOneAndUpdate({
uid: call.uid,
type: 'zhanling'

View File

@ -18,6 +18,8 @@ export default async function (call: ApiCall<ReqUplv, ResUplv>) {
need = need.concat(
G.gc.heroSkinLv[skinconf.colour][cur_lv + i].need
)
let conf = G.gc.heroSkin[call.req.skid];
need.push({ a: "item", "t": conf.heroId, "n": G.gc.heroSkinLv[skinconf.colour][cur_lv + i].suipian });
}
// 检测消耗

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,119 @@
import { patchFun, patchInit } from "../patch";
import { PublicShared } from "../shared/public/public";
import { JJCFun } from "../public/jjc";
function getRankPrize(rank: number, conf?: typeof G.gc.jjc_ph['']) {
if (!conf) {
conf = Object.values(G.gc.jjc_ph).filter(v => rank >= v.ph[0] && rank <= v.ph[1])[0];
}
if (conf) {
return [...conf.prize, { a: 'item', t: '11', n: typeof conf.rongyuprize == 'number' ? conf.rongyuprize : PublicShared.eval(conf.rongyuprize, { a: rank }) }];
} else {
return [];
}
}
class Path {
async addEmail(email, isCross = false) {
let { prize, uid, ...e } = email;
let lng = await G.redis.rawGet(`user:lng:${uid}`);
let sendEmail = {
_id: null,
uid: uid,
type: e.type,
title: e.lngTitle ? (e.lngTitle[lng] || e.lngTitle['ja']) : e.title,
content: e.lngContent ? (e.lngContent[lng] || e.lngContent['ja']) : e.content,
createTime: e.createTime || G.time,
contentInsertArr: e.contentInsertArr || []
} as any;
/**跨服邮件给sid标识*/
// if (isCross) {
// sendEmail.sid = uid.split('_')[0];
// }
if ((prize === null || prize === void 0 ? void 0 : prize.length) > 0) {
sendEmail.prizeData = {
prize: email.prize,
isGet: false
};
}
if (email.g123log && Object.keys(email.g123log).length > 0)
sendEmail.g123log = email.g123log;
if (email.lngTitle) {
sendEmail.lngTitle = email.lngTitle;
sendEmail.lngContent = email.lngContent;
}
//太亏了换其他清理机制getAllEmail是性能消耗大户
//todo.. 换其他清理机制
// if (!isCross) {
// let emailList = await this.getAllEmail(uid);
// if (emailList.length >= 50) {
// emailList.sort((a, b) => {
// let noPrizeA = a.prizeData == undefined ? 0 : 1;
// let noPrizeB = b.prizeData == undefined ? 0 : 1;
// let getA = a.prizeData?.isGet == true ? 0 : 1;
// let getB = b.prizeData?.isGet == true ? 0 : 1;
// if (noPrizeA != noPrizeB) {
// return noPrizeA - noPrizeB;
// } else if (getA != getB) {
// return getA - getB;
// }
// return a.createTime - b.createTime;
// });
// this.removeEmail(uid, emailList[0]._id);
// G.server.sendMsgByUid(uid, 'msg_s2c/EmailDel', emailList[0]._id);
// }
// }
//@ts-ignore
await G.mongodb.collection('email').insertOne({
ttl: new Date(), ...G.mongodb.conversionIdObj(sendEmail)
})
}
async sendEmail(uid: string, rank: number, prize: atn[]) {
if (uid.indexOf('npc_') != -1) return;
await this.addEmail({
uid: uid,
type: 'system',
title: G.gc.jjc_com.email.titel,
content: G.gc.jjc_com.email.content,
prize: prize,
contentInsertArr: [rank]
});
}
async fun1(a: any) {
for (let conf of Object.values(G.gc.jjc_ph)) {
let players = await JJCFun.getRankListUid(conf.ph[0] - 1, conf.ph[1]);
for (let index = 0; index < players.length; index++) {
let uid = players[index];
await this.sendEmail(uid, conf.ph[0] + index, getRankPrize(conf.ph[0] + index, conf));
console.log("sendEmail", uid, conf.ph[0] + index)
}
}
return "sucess!!!"
}
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

@ -0,0 +1,684 @@
import { patchFun, patchInit } from "../patch";
class Path {
async fun1(a: any) {
const con = {
"16_6575db20f6ef8b7da5c8f1fd": {
"item": {
"1": 55400000,
"12": 10600,
"2": 223000,
"6": 690
},
"attr": {
"rmbmoney": 30500,
"jinbi": 2850000000
}
},
"15_6575a14b2f930bd5e51ccde9": {
"item": {
"1": 137200000,
"12": 16600,
"2": 273700,
"6": 1735
},
"attr": {
"rmbmoney": 35200,
"jinbi": 3420000000
}
},
"10_6573c51480a92f081d78e1d9": {
"item": {
"1": 35600000,
"12": 13000,
"2": 67800,
"6": 1180
},
"attr": {
"rmbmoney": 12400,
"jinbi": 630000000
}
},
"10_6573ecd9a884822d24482a1a": {
"item": {
"1": 103200000,
"18": 9490,
"12": 28000,
"2": 421600,
"6": 1300
},
"attr": {
"rmbmoney": 53400,
"jinbi": 5210000000
}
},
"11_657412487fe3541fe7241a60": {
"item": {
"1": 35000000,
"12": 99300,
"2": 110900,
"6": 460
},
"attr": {
"rmbmoney": 19200,
"jinbi": 1830000000
}
},
"11_657436eb3bc021c4e335f356": {
"item": {
"1": 197200000,
"12": 243700,
"2": 597200,
"6": 2475
},
"attr": {
"rmbmoney": 97400,
"jinbi": 9930000000
}
},
"11_657428e87fe3541fe7245b75": {
"item": {
"1": 71200000,
"12": 64300,
"2": 219300,
"6": 910
},
"attr": {
"rmbmoney": 37300,
"jinbi": 3630000000
}
},
"10_6573aeb2602e0a72e8279b54": {
"item": {
"1": 17800000,
"12": 22300,
"2": 58100,
"6": 240
},
"attr": {
"rmbmoney": 10500,
"jinbi": 940000000
}
},
"11_657447453bc021c4e3362403": {
"item": {
"1": 322000000,
"18": 31290,
"12": 134800,
"2": 1297200,
"6": 4035
},
"attr": {
"rmbmoney": 162900,
"jinbi": 16160000000
}
},
"11_657405957b27be6c2f4cac11": {
"item": {
"1": 18600000,
"18": 1050,
"12": 74500,
"2": 79900,
"6": 245
},
"attr": {
"rmbmoney": 12000,
"jinbi": 980000000
}
},
"14_6575004f7aecd430eb86fbb5": {
"item": {
"1": 44000000,
"18": 3440,
"12": 104800,
"2": 182600,
"6": 545
},
"attr": {
"rmbmoney": 25300,
"jinbi": 2270000000
}
},
"16_6575d6ac2e4ba33a00a04cbc": {
"item": {
"1": 36600000,
"12": 13000,
"2": 108200,
"6": 470
},
"attr": {
"rmbmoney": 19100,
"jinbi": 1870000000
}
},
"12_6574823b27bd4264da470583": {
"item": {
"1": 8800000,
"12": 123000,
"2": 37500,
"6": 115
},
"attr": {
"rmbmoney": 7300,
"jinbi": 530000000
}
},
"16_6575b61caff1b610d8bc6c96": {
"item": {
"24": 6,
"10": 200,
"12": 55000,
"600": 20,
"18": 1400,
"1": 16200000,
"2": 64900,
"6": 180,
"9": 3500
},
"attr": {
"rmbmoney": 14400,
"jinbi": 840000000
}
},
"14_6574f2e66c7af0fe3713b718": {
"item": {
"1": 48800000,
"12": 12700,
"2": 90900,
"6": 655
},
"attr": {
"rmbmoney": 12400,
"jinbi": 1100000000
}
},
"11_65740da4deb68620911e96ef": {
"item": {
"1": 64200000,
"18": 5580,
"12": 28300,
"2": 265400,
"6": 820
},
"attr": {
"rmbmoney": 33800,
"jinbi": 3270000000
}
},
"15_657594c3a7981612a8ea7e0e": {
"item": {
"1": 96800000,
"18": 8870,
"12": 3700,
"2": 397200,
"6": 1230
},
"attr": {
"rmbmoney": 50400,
"jinbi": 4920000000
}
},
"11_657434f8290f4393568f16fe": {
"item": {
"1": 129000000,
"12": 198300,
"2": 392100,
"6": 1630
},
"attr": {
"jinbi": 6500000000
}
},
"14_657512ee7aecd430eb872b5d": {
"item": {
"1": 121800000,
"12": 36400,
"2": 363400,
"6": 1530
},
"attr": {
"rmbmoney": 31500,
"jinbi": 6150000000
}
},
"11_657454089beef4c060edab88": {
"item": {
"1": 96600000,
"18": 8660,
"12": 149200,
"2": 392900,
"6": 1215
},
"attr": {
"rmbmoney": 49800,
"jinbi": 4890000000
}
},
"10_6573e8aa80a92f081d7930b4": {
"item": {
"1": 242400000,
"18": 16210,
"12": 84100,
"2": 978800,
"6": 3040
},
"attr": {
"rmbmoney": 123100,
"jinbi": 12180000000
}
},
"11_6573fd7a08e89e5a6859446e": {
"item": {
"1": 178200000,
"18": 16230,
"12": 10900,
"2": 717000,
"6": 2225
},
"attr": {
"rmbmoney": 92000,
"jinbi": 8990000000
}
},
"11_65744fe2d0256beb85eed193": {
"item": {
"1": 262800000,
"18": 25540,
"12": 55800,
"2": 1057600,
"6": 3275
},
"attr": {
"rmbmoney": 134000,
"jinbi": 13190000000
}
},
"11_657440e7ee44bd9935bbbd7c": {
"item": {
"1": 83000000,
"18": 7160,
"12": 250900,
"2": 341800,
"6": 1055
},
"attr": {
"rmbmoney": 43300,
"jinbi": 4220000000
}
},
"11_657420932dd070117eb15e92": {
"item": {
"1": 307400000,
"18": 29210,
"12": 50200,
"2": 1239200,
"6": 3880
},
"attr": {
"jinbi": 15470000000
}
},
"14_65750da36439ef15582d6e6d": {
"item": {
"1": 105000000,
"12": 93900,
"2": 361000,
"6": 1335
},
"attr": {
"rmbmoney": 54100,
"jinbi": 5310000000
}
},
"12_6574762427bd4264da46ce63": {
"item": {
"1": 44400000,
"18": 3390,
"12": 15900,
"2": 185000,
"6": 555
},
"attr": {
"rmbmoney": 25000,
"jinbi": 2290000000
}
},
"16_6575e1625685671e63fe001f": {
"item": {
"1": 12600000,
"2": 51400,
"6": 155
},
"attr": {
"rmbmoney": 9200,
"jinbi": 710000000
}
},
"10_6573e236a884822d244816a0": {
"item": {
"1": 76200000,
"18": 6760,
"12": 79600,
"2": 310200,
"6": 945
},
"attr": {
"rmbmoney": 40700,
"jinbi": 3870000000
}
},
"10_6573a17268053554fe606611": {
"item": {
"1": 109200000,
"18": 9410,
"12": 58000,
"2": 428000,
"6": 2365
},
"attr": {
"rmbmoney": 55000,
"jinbi": 5240000000
}
},
"15_657595a3a7981612a8ea8009": {
"item": {
"1": 19200000,
"18": 830,
"12": 74800,
"2": 84100,
"6": 1115
},
"attr": {
"rmbmoney": 11300,
"jinbi": 990000000
}
},
"11_657438a83bc021c4e335f86e": {
"item": {
"1": 71200000,
"18": 6300,
"12": 55600,
"2": 292500,
"6": 905
},
"attr": {
"rmbmoney": 37200,
"jinbi": 3600000000
}
},
"10_6573e0395fe4caaf29a9b83c": {
"item": {
"1": 9000000,
"12": 184000,
"2": 45800,
"6": 135
},
"attr": {
"rmbmoney": 6400,
"jinbi": 530000000
}
},
"10_6573e596dc05fa03150d7db1": {
"item": {
"1": 12800000,
"18": 410,
"12": 15400,
"2": 60000,
"6": 175
},
"attr": {
"rmbmoney": 8200,
"jinbi": 690000000
}
},
"14_65752c79c85dd4cf1a874893": {
"item": {
"1": 14200000,
"12": 33700,
"2": 64500,
"6": 185
},
"attr": {
"rmbmoney": 8900,
"jinbi": 790000000
}
},
"12_657455ed6b804f4a6d4b53a2": {
"item": {
"1": 160800000,
"18": 14900,
"12": 4800,
"2": 650900,
"6": 2025
},
"attr": {
"rmbmoney": 82000,
"jinbi": 8080000000
}
},
"12_657481316ad7b8861da8a914": {
"item": {
"1": 5600000,
"18": 450,
"12": 34600,
"2": 25500,
"6": 65
},
"attr": {
"rmbmoney": 7800,
"jinbi": 300000000
}
},
"4_6571c11bb0b5337a4d3a63a0": {
"item": {
"24": 7,
"10": 400,
"12": 15600,
"600": 50,
"18": 190,
"1": 5200000,
"2": 16300,
"6": 10,
"9": 8500
},
"attr": {
"rmbmoney": 8800,
"jinbi": 310000000
}
},
"10_6573714bc7069a58e96ba077": {
"item": {
"1": 14400000,
"18": 610,
"12": 11800,
"2": 66400,
"6": 190
},
"attr": {
"rmbmoney": 9000,
"jinbi": 770000000
}
},
"11_65744ba29beef4c060ed803c": {
"item": {
"1": 331800000,
"12": 14800,
"2": 1001400,
"6": 4155
},
"attr": {
"rmbmoney": 167500,
"jinbi": 16670000000
}
},
"16_6575d57c5685671e63fdb6ee": {
"item": {
"1": 13600000,
"12": 42700,
"2": 44500,
"6": 420
},
"attr": {
"rmbmoney": 7000,
"jinbi": 430000000
}
},
"11_65743bb09beef4c060ed46e7": {
"item": {
"10": 300,
"12": 8100,
"600": 30,
"18": 920,
"1": 18400000,
"2": 69600,
"6": 170,
"9": 4500
},
"attr": {
"rmbmoney": 13700,
"jinbi": 950000000
}
},
"10_6573bb4b68053554fe60940c": {
"item": {
"1": 19400000,
"18": 1080,
"12": 63000,
"2": 83100,
"6": 235
},
"attr": {
"rmbmoney": 12300,
"jinbi": 1010000000
}
},
"16_6575d97df2211cd2ff29ba12": {
"item": {
"1": 3400000,
"12": 11100,
"2": 16700,
"6": 50
},
"attr": {
"rmbmoney": 5000,
"jinbi": 250000000
}
},
"11_657434c6d0256beb85ee6fae": {
"item": {
"1": 80600000,
"18": 7360,
"12": 232000,
"2": 332200,
"6": 1025
},
"attr": {
"rmbmoney": 42100,
"jinbi": 4090000000
}
},
"16_6575b6d0f6ef8b7da5c84bf0": {
"item": {
"1": 70600000,
"12": 29700,
"2": 218200,
"6": 900
},
"attr": {
"rmbmoney": 36000,
"jinbi": 3610000000
}
},
"10_6587fbf00c11d852663c5bbb": {
"item": {
"1": 26800000,
"18": 1940,
"12": 168000,
"2": 118300,
"6": 350
},
"attr": {
"rmbmoney": 15300,
"jinbi": 1410000000
}
},
"10_657397c2f31ed0c046ef3730": {
"item": {
"1": 220800000,
"18": 1900,
"12": 8800,
"2": 701400,
"6": 2780
},
"attr": {
"rmbmoney": 112100,
"jinbi": 11100000000
}
}
}
const uids = Object.keys(con);
let _users = await G.mongodb.find('user', { uid: { $in: uids } })
for (let i = 0; i < _users.length; i++) {
let user = _users[i]
const uid = user.uid
const _delattr = con[uid]["attr"]
const _delitem = con[uid]["item"]
let _setUserData = {}
let _dellog = { "attr": {}, "item": {} }
for (let t in _delattr) {
if (t == "rmbmoney") {
let v = user.rmbmoney - _delattr[t]
if (v < 0) { v = 0 }
_setUserData[t] = v
_dellog["attr"][t] = { "old": user.rmbmoney, "new": v }
}
else if (t == "jinbi") {
let v = user.jinbi - _delattr[t]
if (v < 0) { v = 0 }
_setUserData[t] = v
_dellog["attr"][t] = { "old": user.jinbi, "new": v }
}
}
const itemIds = Object.keys(_delitem);
// 删除item
let _itemlist = await G.mongodb.collection('item').find({ "uid": uid, "itemId": { "$in": itemIds } }).toArray();
for (let i = 0; i < _itemlist.length; i++) {
const _item = _itemlist[i]
const _itemid = _item.itemId
const del = _delitem[_itemid] || 0
let v = _item.num - del
if (v < 0) { v = 0 }
let _setItemData = {}
_setItemData["num"] = v
_dellog["item"][_itemid] = { "old": _item.num, "new": v }
await G.mongodb.collection('item').updateOne({ "uid": uid, "itemId": _itemid }, { "$set": _setItemData });
}
await G.mongodb.collection('user').updateOne({ "uid": uid }, { "$set": _setUserData });
// 输出日志
console.log(uid, ":", _dellog);
}
return "sucess!!!"
}
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

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

@ -15,13 +15,14 @@ import { ZhanLingTasks } from './public/zhanling';
import { player } from './shared/protocols/user/type';
import { PublicShared } from './shared/public/public';
import { setGud } from './public/gud';
import {checkResetBuyLog} from "./api_s2c/event/zhoumolibao/ApiOpen";
import {Christmasfun} from "./api_s2c/event/christmas/fun";
import {PushGiftFun} from "./public/pushgift";
import {LeiChongLiBaoBuyGift} from "./api_s2c/event/leichonglibao/ApiReceive";
import { checkResetBuyLog } from "./api_s2c/event/zhoumolibao/ApiOpen";
import { PushGiftFun } from "./public/pushgift";
import { LeiChongLiBaoBuyGift } from "./api_s2c/event/leichonglibao/ApiReceive";
import { HongDianChange } from './api_s2c/hongdian/fun';
export type gEventType = {
/**新的一天 */
NEW_DAY: (time: number) => void;
/**玩家断开连接 */
PLAYER_DISCONNECT: (uid: string) => void;
/**玩家修改名字 */
@ -165,7 +166,7 @@ export function addListener() {
XstaskFun.uidTask[uid] = null;
delete XstaskFun.uidTask[uid];
}
setGud(uid,{ logoutTime: G.time });
setGud(uid, { logoutTime: G.time });
G.mongodb.collection('user').updateOne({ uid: uid }, { $set: { logoutTime: G.time } });
});
@ -177,7 +178,7 @@ export function addListener() {
}
});
G.on('PLAYER_PAY', async (player, payId, payArgs,call) => {
G.on('PLAYER_PAY', async (player, payId, payArgs, call) => {
let conf: any = await PayFun.getConf(payId, payArgs);
ActionLog.addDayLog(player.uid, { key: 'pay', val: conf.payExp[0].n });
ActionLog.addRetainLog(player.uid, { key: 'pay', val: conf.payExp[0].n });

View File

@ -1825,6 +1825,7 @@ type gc_hero_skin = {
type gc_hero_skin_lv = {
[colour: string]: {
[lv: string]: {
suipian: number
buff: { [k: string]: number }
need: { a: string, t: string, n: number }[];
}

View File

@ -359,6 +359,10 @@ class Lng {
weiwang_12: "weiwang_12";
hqjgtips_27: "hqjgtips_27";
hqjgtips_28: "hqjgtips_28";
hqjgtips_29: "hqjgtips_29";
"11111" = "globalThis.lng.chat_1"
// return call.error('', { code: -3, message: globalThis.lng.chat_2 });
}

View File

@ -24,6 +24,7 @@ import {ResOpen as ResOpenZhoumolibao} from '../shared/protocols/event/zhoumolib
import {ResOpen as ResOpenPobinglibao} from '../shared/protocols/event/pobinglibao/PtlOpen';
import {ResOpen as ResOpenLeiChongLiBao} from '../shared/protocols/event/leichonglibao/PtlOpen';
import {event as ResOpenYuandan} from '../shared/protocols/event/yuandan/PtlOpen';
import {PlayerData} from "../api_s2c/event/huangqijiuguan/fun";
export type eventType = {
shouchong: {
@ -74,6 +75,7 @@ export type eventType = {
[k: `leichonglibao${number}`]: ResOpenLeiChongLiBao & { opentime: number };
[k: `yuandan${number}`]: ResOpenYuandan;
[k: `pobinglibao${number}`]: ResOpenPobinglibao;
[k: `huangqijiuguan_${number}`]: PlayerData;
};
export type CollectionEvent<T extends keyof eventType> = {

View File

@ -1,4 +1,4 @@
import {fightResult} from '../shared/fightControl/fightType';
export type CollectionFightLog = fightResult & { uid: string, type: string };
export type CollectionFightLog = fightResult & { uid: string, type: string, ttl: Date};

View File

@ -11,7 +11,7 @@ import { re, string } from "mathjs";
import { getGud } from './gud';
import { PushGiftFun } from "./pushgift";
type fightType = 'tanxian' | 'pata' | 'jjc' | 'gbtx' | 'qjzzd' | 'meirishilian' | 'wzrycross';
type fightType = 'tanxian' | 'pata' | 'jjc' | 'gbtx' | 'qjzzd' | 'meirishilian' | 'wzrycross' | 'hqjg';
let fights: { [key: string]: FightControl } = {
@ -87,9 +87,13 @@ export class FightFun {
/**挑战竞技场 */
static async fightJJc(call: ApiCall, rankInfo: rankInfo) {
if (rankInfo.player.uid.indexOf('npc_') != -1) return await this.fightNpc(call, G.gc.jjc_npc[rankInfo.player.uid].npcId, 'jjc', await this.getPlayerFightData(call.conn.uid));
let result;
let result = this.fight([await this.getPlayerFightData(call.conn.uid), await this.getPlayerFightData(rankInfo.player.uid)]);
if (rankInfo.player.uid.indexOf('npc_') != -1) {
result = await this.fightNpc(call, G.gc.jjc_npc[rankInfo.player.uid].npcId, 'jjc', await this.getPlayerFightData(call.conn.uid));
} else {
result = this.fight([await this.getPlayerFightData(call.conn.uid), await this.getPlayerFightData(rankInfo.player.uid)]);
}
// 竞技场 战败触发推送礼包
if (result.winSide != 0) {
@ -140,11 +144,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, ttl: new Date() })
}
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).sort({ _id: -1 }).toArray() || []
}
}

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

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

View File

@ -59,6 +59,9 @@ export class SchedulerNewDayLocalCtor extends Scheduler {
}
}
})()
// 转点刷新事件
G.emit('NEW_DAY', G.time);
})
let users = Object.values(G.server.uid_connections)

View File

@ -1,5 +1,5 @@
import {PublicShared} from '../../shared/public/public';
import {Scheduler, schedulerType} from './scheduler';
import { PublicShared } from '../../shared/public/public';
import { Scheduler, schedulerType } from './scheduler';
export class SchedulerZhanLing extends Scheduler {
@ -12,12 +12,12 @@ export class SchedulerZhanLing extends Scheduler {
this.isReady = false;
return
}
let data = await this.db.findOne({type: this.id});
let data = await this.db.findOne({ type: this.id });
if (!data) {
// 开服时间整除战令周期
let round = Math.floor(PublicShared.getOpenServerDay() / G.gc.zhanling.eventOpen.day)
let round = Math.floor((PublicShared.getOpenServerDay() - 1) / G.gc.zhanling.eventOpen.day)
let prev_run_time = PublicShared.getToDayZeroTime(G.openTime) + round * G.gc.zhanling.eventOpen.day * 86400
this.db.updateOne({type: this.id}, {$set: {lastRunTime: prev_run_time, round: round}}, {upsert: true});
this.db.updateOne({ type: this.id }, { $set: { lastRunTime: prev_run_time, round: round } }, { upsert: true });
}
if (!data || G.time > PublicShared.getToDayZeroTime(data.lastRunTime) + 24 * 3600 * G.gc.zhanling.eventOpen.day) {
@ -33,11 +33,11 @@ export class SchedulerZhanLing extends Scheduler {
// 开服时间整除战令周期
let round = Math.floor(PublicShared.getOpenServerDay() / G.gc.zhanling.eventOpen.day)
// lastRunTime仅储存最大值问题记录: 本地多人启动服务时,有调用此定时器的情况下,时间会混乱。
await this.db.updateOne({type: this.id}, {$set: {round: round}, $max: {lastRunTime: G.time}}, {upsert: true});
await this.db.updateOne({ type: this.id }, { $set: { round: round }, $max: { lastRunTime: G.time } }, { upsert: true });
this.startTime = PublicShared.getToDayZeroTime() + 24 * 3600 * G.gc.zhanling.eventOpen.day;
this.isStart = false;
G.mongodb.collection('zhanling').updateMany({type: 'round'}, {$set: {data: {}}});
G.mongodb.collection('zhanling').updateMany({ type: 'round' }, { $set: { data: {} } });
}
}

View File

@ -1,9 +1,10 @@
import {ApiCall, ApiReturn} from "tsrpc";
import {HongDianChange} from "../api_s2c/hongdian/fun";
import {taskType} from "../shared/protocols/task/type";
import {PublicShared} from "../shared/public/public";
import {PeijianFun} from "./peijian";
import {manager} from "./taskclass";
import { ApiCall, ApiReturn } from "tsrpc";
import { HongDianChange } from "../api_s2c/hongdian/fun";
import { taskType } from "../shared/protocols/task/type";
import { PublicShared } from "../shared/public/public";
import { PeijianFun } from "./peijian";
import { manager } from "./taskclass";
import ApiRecTask from "../api_s2c/event/zhanling/ApiRecTask";
let taskDict = {};
const SHUJUKU = "task";
@ -114,7 +115,7 @@ export class TaskFun {
let _taskCon = await this.getTaskConByType(_task["type"], _task["taskid"]);
if (!_taskCon || Object.keys(_taskCon).length == 0) {
// 策划改了任务 找不到 自动删除任务
await G.mongodb.collection(SHUJUKU).deleteMany({uid: call.uid, taskid: _task["taskid"]});
await G.mongodb.collection(SHUJUKU).deleteMany({ uid: call.uid, taskid: _task["taskid"] });
continue
}
@ -142,12 +143,12 @@ export class TaskFun {
// 任务值上限检测
_resVal = _resVal > _pval ? _pval : _resVal;
// 设置任务
let _setData = {nval: _resVal};
let _where = {taskid: _task["taskid"]};
let _setData = { nval: _resVal };
let _where = { taskid: _task["taskid"] };
await this.setTask(uid, _where, _setData);
if (_resVal == _pval) {
G.server.sendMsgByUid(call.uid, 'msg_s2c/TaskChange', {..._task, nval: _resVal})
G.server.sendMsgByUid(call.uid, 'msg_s2c/TaskChange', { ..._task, nval: _resVal })
}
}
}
@ -187,7 +188,7 @@ export class TaskFun {
// 重置每日任务
if (ttype == 1 || ttype == 4) {
let _zero = PublicShared.getToDayZeroTime(G.time);
let _where = {retime: {$gte: _zero, $lte: _zero + 24 * 60 * 60 - 1}, type: ttype};
let _where = { retime: { $gte: _zero, $lte: _zero + 24 * 60 * 60 - 1 }, type: ttype };
let _tmp = await this.getUserTaksList(call.uid, _where);
if (_tmp.length == 0) await this.resetDailyTask(call, ttype);
}
@ -197,7 +198,7 @@ export class TaskFun {
*
*/
static async resetDailyTask(call: ApiCall, type: number = 1) {
await this.delTasks(call.uid, {type: type});
await this.delTasks(call.uid, { type: type });
// 该限制改到红点检测判断,避免此处注释后,红点检测与账号创建初始化任务并发。
// if (PublicShared.chkSameDate(call.conn.gud.cTime, G.time)) return;
let _taskCons = await this.getTaskConsByType(type);
@ -236,7 +237,7 @@ export class TaskFun {
static async getFinishByStype(call: ApiCall, stype: number, where: {}) {
// 任务刷新
await this.refreshTask(call);
Object.assign(where, {stype: stype});
Object.assign(where, { stype: stype });
let _r = await this.getUserTaksList(call.uid, where);
return _r;
}
@ -255,11 +256,33 @@ export class TaskFun {
// Object.assign(where, { type: { $in: ttype } })
for (let index = 0; index < ttype.length; index++) {
const _type = ttype[index];
Object.assign(_w, {type: _type, ...where});
Object.assign(_w, { type: _type, ...where });
if (_finishType.indexOf(_type) != -1) {
delete _w["finish"];
}
let _tmp = await this.getUserTaksList(call.uid, _w);
// 没有未完成任务
// 检测是否有新加任务
if (_tmp.length == 0) {
let rectask = (await G.mongodb.collection('task').find(
{ uid: call.uid, type: _type }, { projection: { taskid: 1, _id: 0 } }
).toArray()).map(e => e.taskid);
for (let taskid of rectask) {
let conf = G.gc.task[_type][taskid];
// 配置不存在
// 没有后续任务
// 后续任务已完成
if (!conf || !conf.followtask || rectask.includes(conf.followtask)) {
continue
}
// 生成后续任务
await this.setTaskInfo(call, conf.followtask, { type: _type });
break;
}
_tmp = await this.getUserTaksList(call.uid, _w);
}
_r[_type] = _tmp;
}
return _r;
@ -313,7 +336,7 @@ export class TaskFun {
* @param call
*/
static async updateMainTask(call: ApiCall) {
let data = await G.mongodb.collection(SHUJUKU).findOne({uid: call.uid, type: 2, finish: 0});
let data = await G.mongodb.collection(SHUJUKU).findOne({ uid: call.uid, type: 2, finish: 0 });
let _ftaskCon = await TaskFun.getTaskConByType(2, data.taskid);
// @ts-ignore
@ -324,14 +347,14 @@ export class TaskFun {
type: 2,
finish: 0,
taskid: data.taskid
}, {$set: {...newTask, nval: data.nval || newTask.nval, retime: data.retime,}}, {upsert: true})
}, { $set: { ...newTask, nval: data.nval || newTask.nval, retime: data.retime, } }, { upsert: true })
}
/**
*
*/
static async generateAllTask(call: ApiCall) {
let _r = await G.mongodb.collection(SHUJUKU).count({uid: call.uid});
let _r = await G.mongodb.collection(SHUJUKU).count({ uid: call.uid });
if (_r > 0) return;
let _taskInfo = [];
let _con = G.gc.task;
@ -352,7 +375,7 @@ export class TaskFun {
/**生成指定类型任务-初始化 */
static async reInitTask(call: ApiCall, type: string) {
// 查询类型任务是否存在
let _r = await G.mongodb.collection(SHUJUKU).count({uid: call.uid, type: ~~type});
let _r = await G.mongodb.collection(SHUJUKU).count({ uid: call.uid, type: ~~type });
let _taskInfo = [];
if (_r == 0) {
let _con = G.gc.task;
@ -374,7 +397,7 @@ export class TaskFun {
*/
static async getUserTaksList(uid: string, where: {}) {
// type : 1 主线 2 成就 3 每日
Object.assign(where, {uid: uid});
Object.assign(where, { uid: uid });
let _taskInfo = await G.mongodb.collection(SHUJUKU).find(where).toArray();
_taskInfo.forEach(e => {
if (e._id) delete e._id;
@ -386,7 +409,7 @@ export class TaskFun {
*
*/
static async delTasks(uid: string, where: { type: number; }) {
Object.assign(where, {uid: uid});
Object.assign(where, { uid: uid });
await G.mongodb.collection(SHUJUKU).deleteMany(where);
}
@ -420,8 +443,8 @@ export class TaskFun {
if (Object.keys(setData).length == 0) {
return;
}
Object.assign(where, {uid});
setData = {$set: setData};
Object.assign(where, { uid });
setData = { $set: setData };
await G.mongodb.collection(SHUJUKU).updateOne(where, setData);
}
@ -445,7 +468,7 @@ export class TaskFun {
if ((element == "1" || element == "3") && call.conn.gud.lv < 7) continue;
let _values: number[] = _ttype[element];
let _where: {} = {
uid: call.uid, type: {$in: _values}, finish: 0, '$expr': {
uid: call.uid, type: { $in: _values }, finish: 0, '$expr': {
$lte: ["$pval", "$nval"]
}
};
@ -534,10 +557,10 @@ export class TaskAllEmitFun {
});
if (_val > (usertasklog?.maxherolv | 0)) {
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
uid: node.call.conn.uid,
type: 'usertasklog'
},
{$set: {maxherolv: _val}});
uid: node.call.conn.uid,
type: 'usertasklog'
},
{ $set: { maxherolv: _val } });
}
// 干部等级达到 n 级
G.emit("Class_task_106", 'Class_task_106', node.call, _val, 0);
@ -580,10 +603,10 @@ export class TaskAllEmitFun {
});
if (_val > (usertasklog?.maxequiplv | 0)) {
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
uid: node.call.conn.uid,
type: 'usertasklog'
},
{$set: {maxequiplv: _val}});
uid: node.call.conn.uid,
type: 'usertasklog'
},
{ $set: { maxequiplv: _val } });
}
G.emit("Class_task_112", 'Class_task_112', node.call, _val, 0);
// 有 n 件强化 配置 等级装备 后面复写正确值
@ -604,10 +627,10 @@ export class TaskAllEmitFun {
});
if (_val > (usertasklog?.maxequiplv | 0)) {
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
uid: node.call.conn.uid,
type: 'usertasklog'
},
{$set: {maxequiplv: _val}});
uid: node.call.conn.uid,
type: 'usertasklog'
},
{ $set: { maxequiplv: _val } });
}
// 有 n 件强化 配置 等级装备 后面复写正确值
G.emit("Class_task_113", 'Class_task_113', node.call, 0, 0);
@ -622,10 +645,10 @@ export class TaskAllEmitFun {
let _color = G.gc.hero[element.heroId].colour;
G.emit("Class_task_114", 'Class_task_114', node.call, 1, _color);
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
uid: node.call.conn.uid,
type: 'usertasklog'
},
{$inc: G.mongodb.createTreeObj({key: `herocolor.${_color}`, val: 1})});
uid: node.call.conn.uid,
type: 'usertasklog'
},
{ $inc: G.mongodb.createTreeObj({ key: `herocolor.${_color}`, val: 1 }) });
}
}
}
@ -651,7 +674,7 @@ export class TaskAllEmitFun {
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
uid: node.call.uid,
type: 'usertasklog'
}, {$set: {equipcolor: usertasklog.equipcolor}})
}, { $set: { equipcolor: usertasklog.equipcolor } })
}
// if (node.call.service.name == 'chongzhi/Open' && node.return.isSucc) {
// // 累计充值 n 钻石 数量后面复写
@ -690,10 +713,10 @@ export class TaskAllEmitFun {
}
_val = _val + usertasklog.friendAsk + usertasklog.sendGift
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
uid: node.call.conn.uid,
type: 'usertasklog'
},
{$set: {friendAsk: _val}});
uid: node.call.conn.uid,
type: 'usertasklog'
},
{ $set: { friendAsk: _val } });
G.emit("Class_task_144", 'Class_task_144', node.call, 1, 0);
}
if (node.call.service.name == 'tanxian/FastGuaJi' && node.return.isSucc) {
@ -852,7 +875,7 @@ export class TaskAllEmitFun {
uid: node.call.conn.uid,
type: 'usertasklog'
});
let _setData = {$set: {}}; // 更新配件记录
let _setData = { $set: {} }; // 更新配件记录
let peijianCon = G.gc.peijian;
let _lv = 0;
@ -881,9 +904,9 @@ export class TaskAllEmitFun {
// 配件升级到 xx 级
if (_setData["$set"]["maxpeijianlv"]) G.emit("Class_task_139", 'Class_task_139', node.call, _lv, 0);
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({
uid: node.call.conn.uid,
type: 'usertasklog'
},
uid: node.call.conn.uid,
type: 'usertasklog'
},
_setData);
}
}

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

@ -152,7 +152,7 @@ export class FightControl {
this.eachLiveRoles((role) => {
let heroId = role.roleData.heroId;
// let shiwu = role.roleData?.shiwu || {};
// let talent = role.roleData?.talent || {};
let talent = role.roleData?.talent || {};
let skills = G.gc.heroskill[heroId][role.roleData.jieji || 0].bdskill || [];
skills = skills.concat(role.roleData.attr.skillArr);
@ -161,15 +161,15 @@ export class FightControl {
// 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);
// }
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);

View File

@ -0,0 +1,11 @@
import { PlayerData } from "../../../../api_s2c/event/huangqijiuguan/fun"
export interface ReqDuiHuan {
hdid: number
dh: { [id: number]: number }
}
export interface ResDuiHuan {
data: PlayerData
prize: { a: string, t: string, n: number }[]
}

View File

@ -0,0 +1,11 @@
import { PlayerData } from "../../../../api_s2c/event/huangqijiuguan/fun";
import { fightResult } from "../../../fightControl/fightType";
export interface ReqFight {
hdid: number
}
export interface ResFight {
data: PlayerData
result: fightResult;
}

View File

@ -0,0 +1,9 @@
import { PlayerData } from "../../../../api_s2c/event/huangqijiuguan/fun"
export interface ReqOpen {
hdid: number
}
export interface ResOpen {
data: PlayerData
}

View File

@ -0,0 +1,7 @@
export interface ReqRankList {
hdid: number
}
export interface ResRankList {
rankList: any[]
}

View File

@ -0,0 +1,11 @@
import { PlayerData } from "../../../../api_s2c/event/huangqijiuguan/fun"
export interface ReqRecDpsPrize {
hdid: number
recid: number[]
}
export interface ResRecDpsPrize {
data: PlayerData,
prize: { a: string, t: string, n: number }[]
}

View File

@ -0,0 +1,13 @@
import { PlayerData } from "../../../../api_s2c/event/huangqijiuguan/fun"
export interface ReqTaskRec {
day: number
hdid: number
taskid: number[]
}
export interface ResTaskRec {
data: PlayerData
prize: { a: string, t: string, n: number }[]
}

View File

@ -0,0 +1,12 @@
import { PlayerData } from "../../../../api_s2c/event/huangqijiuguan/fun"
export interface ReqZhaoMu {
num: number
hdid: number
}
export interface ResZhaoMu {
data: PlayerData
prize: { a: string, t: string, n: number }[]
}

View File

@ -0,0 +1,11 @@
import { PlayerData } from "../../../../api_s2c/event/huangqijiuguan/fun"
export interface ReqZhaoMuPrizeRec {
hdid: number
recid: { idx: number, sec: string }[]
}
export interface ResZhaoMuPrizeRec {
data: PlayerData
prize: { a: string, t: string, n: number }[]
}

File diff suppressed because it is too large Load Diff