feat(稷下学宫): 修改每周学分进度奖励

This commit is contained in:
zhangxk
2023-09-08 21:25:39 +08:00
parent 7faeeb10e1
commit 77d30f8722
11 changed files with 285 additions and 30 deletions

View File

@@ -13,11 +13,10 @@ import { DicRougeQuestionMarkPlan } from "../../pubUtils/dictionary/DicRougeQues
import { DicRougeRandomEventPlan } from "../../pubUtils/dictionary/DicRougeRandomEventPlan";
import * as util from 'util';
import { RougelikeCollectionModel, } from "../../db/RougelikeCollection";
import { RougelikeScoreModel } from "../../db/RougelikeScore";
import { RougelikeScoreModel, RougelikeScorePara } from "../../db/RougelikeScore";
import { getTechData } from "./rougeTechService";
import { getZeroPointOfTimeD } from "../../pubUtils/timeUtil";
import { sendMailByContent } from "../mailService";
import { DicRougeCharaCardPlan } from "../../pubUtils/DicRougeCharaCardPlan";
import { MAIL_TYPE, PUSH_ROUTE } from "../../consts";
import { sendMessageToUserWithSuc } from "../pushService";
import { RougeEffect, getAddChoosePassive, getAddPassiveWeight, getChooseQualityPassives, getShopDiscount } from "./rougeEffectService";
@@ -25,6 +24,7 @@ import { formateCharasOrCards } from "./rougeCollectService";
import { errlogger } from "../../util/logger";
import { RougelikeExtendModel } from "../../db/RougelikeExtend";
import { isDevelopEnv } from "../utilService";
import { DicRougeCharaCardPlan } from "../../pubUtils/dictionary/DicRougeCharaCardPlan";
export async function getRougeData(roleId: string) {
@@ -41,8 +41,8 @@ export async function getRougeData(roleId: string) {
const dbExtends = await RougelikeExtendModel.findByRoleId(roleId);
const limitIds = dbExtends.map(cur => cur.limitId);
return { isPlaying, gameCode, weeklyScore: dbScore?.score || 0, receivedScore: dbScore?.received || [], ...techData, collections, limitIds, takeoutRewardCnt: dbScore?.takeoutRewardCnt }
const lastMaxLv = await RougelikeRecordModel.getLastMaxLv(roleId);
return { isPlaying, gameCode, weeklyScore: dbScore?.score || 0, receivedScore: dbScore?.received || [], ...techData, collections, limitIds, takeoutRewardCnt: dbScore?.takeoutRewardCnt, lastMaxLv }
}
/*
@@ -899,19 +899,24 @@ export function getAuthorTypeCardNum(authorType: number, cards: Card[]) {
}
export async function repaireSendScoreReward() {
let maxNum = gameData.rougeScoreNum.num || 0;
let refTime = getZeroPointOfTimeD(Date.now() - 86400000, SHOP_REFRESH_TYPE.WEEKLY);
let allRewards = await RougelikeScoreModel.findByReceiveNum(refTime, maxNum);
let _ids: string[] = [];
for (let { roleId, received, _id, score } of allRewards) {
let refTime = new Date(getZeroPointOfTimeD(Date.now() - 86400000, SHOP_REFRESH_TYPE.WEEKLY).getTime() - (86400000 * 7));
let allRewards = await RougelikeScoreModel.findByRefTime(refTime);
let updateArr: RougelikeScorePara[] = [];
const roleIds = allRewards.map(cur => { return cur.roleId });
const lastMaxLvMap = await RougelikeRecordModel.getLastMaxLvMap(roleIds);
for (let { roleId, received, score, receiveNum } of allRewards) {
if (!lastMaxLvMap.has(roleId)) continue;
let goods: RewardInter[] = [];
for (let [index, { reward, score: targetScore }] of gameData.rougeScoreReward) {
if (score >= targetScore && !received.includes(index)) goods.push(...reward);
const rougeScoreRewardByLvData = gameData.rougeScoreRewardByLv.get(lastMaxLvMap.get(roleId));
if (receiveNum >= rougeScoreRewardByLvData.size) continue;
for (let [index, { reward, score: targetScore }] of rougeScoreRewardByLvData) {
if (score >= targetScore && !received.includes(index)) { goods.push(...reward); }
}
await sendMailByContent(MAIL_TYPE.ROUGE_SCORE_REPAIRE, roleId, { goods });
_ids.push(_id);
updateArr.push({ roleId, refTime, receiveNum: rougeScoreRewardByLvData.size });
}
await RougelikeScoreModel.receiveAll(_ids, maxNum + 1);
await RougelikeScoreModel.bulkWriteUpdate(updateArr);
}
/**