合并,暂时屏蔽其他功能

This commit is contained in:
dy 2023-12-15 10:46:47 +08:00
parent 24c2efdfa2
commit 9f151f182b
10 changed files with 21 additions and 428 deletions

View File

@ -1,46 +1,7 @@
import { ApiCall } from "tsrpc"; import { ApiCall } from "tsrpc";
import { ReqLiBao, ResLiBao } from "../../../shared/protocols/event/christmas/PtlLiBao"; import { ReqLiBao, ResLiBao } from "../../../shared/protocols/event/christmas/PtlLiBao";
import {Christmasfun} from "./fun";
import {PlayerFun} from "../../../public/player";
import {HongDianChange} from "../../hongdian/fun";
export default async function (call: ApiCall<ReqLiBao, ResLiBao>) { export default async function (call: ApiCall<ReqLiBao, ResLiBao>) {
let initCon = await Christmasfun.getCon(call) // TODO
let lbid = call.req.lbid; call.error('API Not Implemented');
let _con = initCon[call.req.hdid].data.libao[call.req.lbid];
if (!_con) {
// 礼包id 不存在
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
}
if (_con.payid) {
// 判断是否能购买
return call.error('', { code: -2, message: globalThis.lng.yangchengmubiao_2 })
}
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
let _buyNum = _mydata.libao[lbid] || 0
if (_buyNum >= _con.buynum) {
// 判断是否能购买
return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_2 })
}
const _select = _mydata.select[lbid] || {}
if (Object.keys(_select).length >= _con.dlz.length) {
// 判断是否选择奖励了
return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_2 })
}
let _prize: atn[] = _con.prize
for (let key in _select) {
_prize.push(_con.dlz[parseInt(key)][_select[key]])
}
let _setData = {}
_mydata.libao[lbid] = _buyNum + 1
_setData["libao"] = _mydata.libao
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData })
await PlayerFun.sendPrize(call, _prize);
let changedata = { mydata: _mydata, prize: _prize}
// 推送红点
HongDianChange.sendChangeKey(call.uid, ['huodonghd']);
call.succ(changedata);
} }

View File

@ -1,16 +1,7 @@
import { ApiCall } from "tsrpc"; import { ApiCall } from "tsrpc";
import { HuoDongFun } from "../../../public/huodongfun"; import { ReqOpen, ResOpen } from "../../../shared/protocols/event/christmas/PtlOpen";
import { ReqOpen, ResOpen } from "../../../shared/protocols/event/yangchengmubiao/PtlOpen";
import { Christmasfun } from "./fun";
export default async function (call: ApiCall<ReqOpen, ResOpen>) { export default async function (call: ApiCall<ReqOpen, ResOpen>) {
let _hdinfo = await HuoDongFun.getHdidInfo(call, call.req.hdid) // TODO
if (!_hdinfo || Object.keys(_hdinfo).length <= 0) { call.error('API Not Implemented');
// 无此活动 }
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
}
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
let changedata = { mydata: _mydata, hdinfo: _hdinfo }
call.succ(changedata);
}

View File

@ -1,38 +1,7 @@
import { ApiCall } from "tsrpc"; import { ApiCall } from "tsrpc";
import { ReqQianDao, ResQianDao } from "../../../shared/protocols/event/christmas/PtlQianDao"; import { ReqQianDao, ResQianDao } from "../../../shared/protocols/event/christmas/PtlQianDao";
import {Christmasfun} from "./fun";
import {PublicShared} from "../../../shared/public/public";
import {PlayerFun} from "../../../public/player";
import {HongDianChange} from "../../hongdian/fun";
export default async function (call: ApiCall<ReqQianDao, ResQianDao>) { export default async function (call: ApiCall<ReqQianDao, ResQianDao>) {
let initCon = await Christmasfun.getCon(call) // TODO
let _con = initCon[call.req.hdid].data.qiandao; call.error('API Not Implemented');
let _stime = initCon[call.req.hdid].stime
let _diff = PublicShared.getDiff(_stime)
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
// 循环判断是否有可以领取的
let _prize = []
for(let i = 0; i < _diff; i++) {
if (_mydata.qiandao.includes(i)) continue
_mydata.qiandao.push(i)
_prize.push(_con[i])
}
if (!_prize){
// 没有奖励可以领取
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
}
let _setData = {}
_setData["qiandao"] = _mydata.qiandao
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData })
await PlayerFun.sendPrize(call, _prize);
let changedata = { mydata: _mydata, prize: _prize}
// 推送红点
HongDianChange.sendChangeKey(call.uid, ['huodonghd']);
call.succ(changedata);
} }

View File

@ -1,39 +1,7 @@
import { ApiCall } from "tsrpc"; import { ApiCall } from "tsrpc";
import { ReqSelect, ResSelect } from "../../../shared/protocols/event/christmas/PtlSelect"; import { ReqSelect, ResSelect } from "../../../shared/protocols/event/christmas/PtlSelect";
import {Christmasfun} from "./fun";
import {HongDianChange} from "../../hongdian/fun";
export default async function (call: ApiCall<ReqSelect, ResSelect>) { export default async function (call: ApiCall<ReqSelect, ResSelect>) {
let initCon = await Christmasfun.getCon(call) // TODO
let index = call.req.index; call.error('API Not Implemented');
let pid = call.req.pid;
let lbid = call.req.lbid;
let _con = initCon[call.req.hdid].data.libao[lbid];
if (!_con) {
// 礼包id 不存在
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
}
if (index >= _con.dlz.length){
// 礼包id 不存在
return call.error('', { code: -2, message: globalThis.lng.yangchengmubiao_2 })
}
if (index >= _con.dlz.length){
// 礼包id 不存在
return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_2 })
}
if (!_con.dlz[index][pid]){
// 礼包id 不存在
return call.error('', { code: -4, message: globalThis.lng.yangchengmubiao_2 })
}
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
let lb_select = _mydata.select[lbid] || {}
lb_select[index.toString()] = pid
_mydata.select[lbid] = lb_select
let _setData = {}
_setData["select"] = _mydata.select
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData })
let changedata = { mydata: _mydata}
// 推送红点
HongDianChange.sendChangeKey(call.uid, ['huodonghd']);
call.succ(changedata);
} }

View File

@ -1,37 +1,7 @@
import { ApiCall } from "tsrpc"; import { ApiCall } from "tsrpc";
import { ReqTaskRec, ResTaskRec } from "../../../shared/protocols/event/christmas/PtlTaskRec"; import { ReqTaskRec, ResTaskRec } from "../../../shared/protocols/event/christmas/PtlTaskRec";
import {Christmasfun} from "./fun";
import {HongDianChange} from "../../hongdian/fun";
import {PlayerFun} from "../../../public/player";
export default async function (call: ApiCall<ReqTaskRec, ResTaskRec>) { export default async function (call: ApiCall<ReqTaskRec, ResTaskRec>) {
let initCon = await Christmasfun.getCon(call) // TODO
let taskid = call.req.taskid; call.error('API Not Implemented');
let _con = initCon[call.req.hdid].data.task[taskid];
if (!_con) {
// 任务id 不存在
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
}
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
if (_mydata.taskval[taskid] < _con.pval) {
// 任务未完成
return call.error('', { code: -2, message: globalThis.lng.yangchengmubiao_3 })
}
if (_mydata.taskfinish.includes(taskid)) {
// 任务已领取
return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_4 })
}
_mydata.taskfinish.push(taskid)
let _setData = {}
_setData["taskfinish"] = _mydata.taskfinish
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData })
let _prize = _con.prize
await PlayerFun.sendPrize(call, _prize);
let changedata = { mydata: _mydata, prize: _prize}
// 推送红点
HongDianChange.sendChangeKey(call.uid, ['huodonghd']);
call.succ(changedata);
} }

View File

@ -1,46 +1,7 @@
import { ApiCall } from "tsrpc"; import { ApiCall } from "tsrpc";
import { ReqZhanLingRec, ResZhanLingRec } from "../../../shared/protocols/event/christmas/PtlZhanLingRec"; import { ReqZhanLingRec, ResZhanLingRec } from "../../../shared/protocols/event/christmas/PtlZhanLingRec";
import {Christmasfun} from "./fun";
import {PlayerFun} from "../../../public/player";
import {HongDianChange} from "../../hongdian/fun";
export default async function (call: ApiCall<ReqZhanLingRec, ResZhanLingRec>) { export default async function (call: ApiCall<ReqZhanLingRec, ResZhanLingRec>) {
let initCon = await Christmasfun.getCon(call) // TODO
let index = call.req.index; call.error('API Not Implemented');
let _con = initCon[call.req.hdid].data.zhanling[index];
if (!_con) {
// 礼包id 不存在
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
}
let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
if (_mydata.val < _con.val) {
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
}
let _prize = []
if (!_mydata.pt.includes(index)){
// 如果普通奖励没有领取
_prize.push(_con.pt)
_mydata.pt.push(index)
}
if (_mydata.pay && !_mydata.gj.includes(index)){
// 如果普通奖励没有领取
_prize.push(_con.gj)
_mydata.gj.push(index)
}
if (!_prize) {
// 没有奖励可以领取
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
}
let _setData = {}
_setData["gj"] = _mydata.gj
_setData["pt"] = _mydata.pt
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData })
await PlayerFun.sendPrize(call, _prize);
let changedata = { mydata: _mydata, prize: _prize}
// 推送红点
HongDianChange.sendChangeKey(call.uid, ['huodonghd']);
call.succ(changedata);
} }

View File

@ -1,168 +0,0 @@
import { strict } from 'assert';
import { ApiCall } from 'tsrpc';
import { ReqAddHuoDong } from '../../../monopoly/protocols/PtlAddHuoDong';
import { HuoDongFun } from '../../../public/huodongfun';
import { TaskFun } from '../../../public/task';
import { christmas } from '../../../shared/protocols/event/christmas/PtlOpen';
import { PublicShared } from '../../../shared/public/public';
export class Christmasfun {
/**配置 */
static async getCon(call: ApiCall) {
let _con: { [id: string]: ReqAddHuoDong } = {}
let _hd = await HuoDongFun.gethdList(call, 8)
for (let index = 0; index < _hd.length; index++) {
const element = _hd[index];
if (element && element._id) delete element._id
_con[element.hdid] = element
}
return _con
}
/**获取所有符合时间的活动 */
static async gethdids(call: ApiCall) {
let _hdids = []
let _hd = await HuoDongFun.gethdList(call, 8)
for (let index = 0; index < _hd.length; index++) {
const element = _hd[index];
_hdids.push(element.hdid)
}
return _hdids
}
/**获取我的数据 */
static async getMyData(call: ApiCall, hdid: number) {
let db: any = await G.mongodb.cEvent(`christmas${hdid}`).findOne({ uid: call.uid, type: `christmas${hdid}`, hdid: hdid });
if (!db) {
db = await this.initData(call, hdid)
await G.mongodb.cEvent(`christmas${hdid}`).updateOne(
{ uid: call.uid, type: `christmas${hdid}`, hdid: hdid },
{ $set: db },
{ upsert: true }
)
}
let { _id, ..._myData } = db
if (!PublicShared.chkSameDate(_myData.refresh, G.time)) {
// 刷新每日任务
_myData = await this.refreTask(call, _myData, hdid)
}
return _myData
}
/**初始数据 */
static async initData(call: ApiCall, hdid: number) {
let _initCon = await this.getCon(call)
let _con = _initCon[hdid]
let _r: christmas = {
type: `christmas${hdid}`,
uid: call.uid,
hdid: hdid,
taskval: await this.getTaskVal(call, hdid),
taskfinish: [],
refresh: G.time,
pt: [],
gj: [],
pay: false,
select:{},
val: 0,
qiandao: [],
libao:{}
}
return _r
}
/**设置数据 */
static async setMyData(uid: string, hdid: number, set: {}) {
await G.mongodb.cEvent(`christmas${hdid}`).updateOne(
{ uid: uid, type: `christmas${hdid}`, hdid: hdid },
set
)
}
/**获取所有taskid 及对应的值 */
static async getTaskVal(call: ApiCall, hdid: number) {
let _initCon = await this.getCon(call)
let _tasks = _initCon[hdid].data.task
let _res = {}
for (let index = 0; index < Object.keys(_tasks).length; index++) {
const element = Object.keys(_tasks)[index];
let _tmp = _tasks[element]
_tmp["id"] = element
// 每日登录直接完成
if (element == "1"){
_res[element] = 1
}
else{
_res[element] = 0
}
}
return _res
}
/**刷新每日任务 */
static async refreTask(call: ApiCall, mydata: christmas, hdid: number) {
let _initCon = await this.getCon(call)
let _con = _initCon[hdid].data.task
if (!_con) return mydata
mydata.taskfinish = []
mydata.taskval = await this.getTaskVal(call, hdid)
mydata.refresh = G.time
await this.setMyData(call.uid, hdid, { $set: { refresh: mydata.refresh, taskfinish: mydata.taskfinish, taskval: mydata.taskval } })
return mydata
}
/**设置任务 */
static async setTaskVal(call: ApiCall, stype: number, val: number, chkCall: Function, chkval: number = 0, isinc: number = 0, alchangeVal: Function, arg) {
let hdids = await this.gethdids(call)
if (hdids.length <= 0) return // 活动过期,不计数
let _initCon = await this.getCon(call)
for (let index = 0; index < hdids.length; index++) {
const hdid = hdids[index];
let _mydata = await Christmasfun.getMyData(call, hdid)
let _tasks = _initCon[hdid].data.task
let _setData = {
$inc: {},
$set: {}
}
let isset = 0
for (let indextask = 0; indextask < Object.keys(_tasks).length; indextask++) {
const ele = Object.keys(_tasks)[indextask];
// 具体任务配置
let _taskCon = _tasks[ele]
if (_taskCon.stype != stype) continue
let _pval = _taskCon.pval
// 不符合任务要求
if (!(await chkCall(_taskCon["cond"], chkval, arg))) continue
// 根据需求改写
val = await alchangeVal(call, _taskCon, val, arg)
isset = 1
if (isinc == 1) { // 累加
_setData["$inc"][`taskval.${ele}`] = val
} else {
_setData["$set"][`taskval.${ele}`] = val
}
}
// 设置任务
if (isset == 1) {
await G.mongodb.collection('event').updateMany(
{ uid: call.uid, type: { $regex: "christmas" }, hdid: parseInt(hdid) },
_setData
)
}
}
}
}

View File

@ -20,7 +20,6 @@ import {PlayerFun} from "../../public/player";
import kfjsFun from "../../public/kaifujingsai"; import kfjsFun from "../../public/kaifujingsai";
import {RankKfjs} from "../../public/rank/rank_kfjs"; import {RankKfjs} from "../../public/rank/rank_kfjs";
import {ShopFun} from "../../public/shop"; import {ShopFun} from "../../public/shop";
import {Christmasfun} from '../event/christmas/fun';
export class HongDianFun { export class HongDianFun {
/**黑榜争霸红点 */ /**黑榜争霸红点 */
@ -690,68 +689,6 @@ export class HuoDongHongDianFun {
return _res; return _res;
} }
/**圣诞节活动红点 */
static async christmasHongDian(call: ApiCall, hdCon: ReqAddHuoDong) {
let _res: hongdianVal = {
show: false,
};
let _hdCon = hdCon.data;
let stime = hdCon.stime
let _mydata = await Christmasfun.getMyData(call, hdCon.hdid);
let _tasks = hdCon.data.task; // 所有任务 taskid 为key
for (let indextask = 0; indextask < Object.keys(_tasks).length; indextask++) {
const elementtask = Object.keys(_tasks)[indextask];
let _tmp = _tasks[elementtask];
if (_tmp.pval <= (_mydata.taskval[elementtask] || 0) && !_mydata.taskfinsih.includes(elementtask)) {
// 任务完成且没有领取
_res.show = true;
return _res;
}
}
let libaos = _hdCon.libao
for (let indexlibao = 0; indexlibao < Object.keys(libaos).length; indexlibao++) {
const elementlibao = Object.keys(libaos)[indexlibao];
let _tmp = _tasks[elementlibao];
if (_tmp.payid) continue
let _buyNum = _mydata.libao[elementlibao] || 0
if (_buyNum < _tmp.buynum) {
_res.show = true;
return _res;
}
}
let _diff = PublicShared.getDiff(stime)
// 循环判断是否有可以领取的
for (let i = 0; i < _diff; i++) {
if (_mydata.qiandao.includes(i)) continue
_res.show = true;
return _res;
}
let need = _hdCon.gameneed;
// 判断消耗是否满足
let meet = await PlayerFun.checkNeedIsMeet(call, need, false);
if (meet.isOk == true) {
_res.show = true;
return _res;
}
let zhanling = _hdCon.zhanling
for (let indexzhanling = 0; indexzhanling < zhanling.length; indexzhanling++) {
if (!_mydata.pt.includes(indexzhanling)) {
_res.show = true;
return _res;
}
if (_mydata.pay && !_mydata.gj.includes(indexzhanling)) {
_res.show = true;
return _res;
}
}
return _res;
}
/**养成目标红点 */ /**养成目标红点 */
static async yangchengmubiaoHongDian(call: ApiCall, hdCon: ReqAddHuoDong) { static async yangchengmubiaoHongDian(call: ApiCall, hdCon: ReqAddHuoDong) {
let _res: hongdianVal = { let _res: hongdianVal = {

View File

@ -0,0 +1,7 @@
import { ApiCall } from "tsrpc";
import { ReqOpen, ResOpen } from "../../shared/protocols/pushgift/PtlOpen";
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
// TODO
call.error('API Not Implemented');
}

View File

@ -1,6 +1,5 @@
import {ApiCall} from "tsrpc" import {ApiCall} from "tsrpc"
import {YangChengMuBiaofun} from "../api_s2c/event/yangchengmubiao/fun" import {YangChengMuBiaofun} from "../api_s2c/event/yangchengmubiao/fun"
import {Christmasfun} from "../api_s2c/event/christmas/fun"
// import { YangChengMuBiaofun } from "../api_s2c/event/yangchengmubiao/fun" // import { YangChengMuBiaofun } from "../api_s2c/event/yangchengmubiao/fun"
import {Wjjl} from "../module/collection_wjjl" import {Wjjl} from "../module/collection_wjjl"
import {PublicShared} from "../shared/public/public" import {PublicShared} from "../shared/public/public"
@ -73,8 +72,6 @@ export module manager {
TaskFun.setTaskVal(call, this.stype, val, this.chkCall, chkval, this.isinc, this.alchangeVal, arg) TaskFun.setTaskVal(call, this.stype, val, this.chkCall, chkval, this.isinc, this.alchangeVal, arg)
// 养成目标任务计数 // 养成目标任务计数
YangChengMuBiaofun.setTaskVal(call, this.stype, val, this.chkCall, chkval, this.isinc, this.alchangeVal, arg) YangChengMuBiaofun.setTaskVal(call, this.stype, val, this.chkCall, chkval, this.isinc, this.alchangeVal, arg)
// 圣诞任务计数
Christmasfun.setTaskVal(call, this.stype, val, this.chkCall, chkval, this.isinc, this.alchangeVal, arg)
} }
// 任务数值, 和检测值,看情况需要上层复写 // 任务数值, 和检测值,看情况需要上层复写