活动:月卡权限

This commit is contained in:
luying
2022-03-09 19:47:20 +08:00
parent dafc77954b
commit f440ef2ebe
22 changed files with 295 additions and 220 deletions
@@ -1,4 +1,4 @@
import { ACTIVITY_TYPE, ITEM_CHANGE_REASON, MAIL_TYPE, STATUS } from '../../consts';
import { ACTIVITY_TYPE, HANG_UP_CONSTS, ITEM_CHANGE_REASON, MAIL_TYPE, STATUS } from '../../consts';
import { ActivityModel, ActivityModelType } from '../../db/Activity';
import { ActivityMonthlyTicketModel, ActivityMonthlyTicketModelType } from '../../db/ActivityMonthlyTicket';
import { RewardParam } from '../../domain/activityField/rewardField';
@@ -7,8 +7,12 @@ import { addReward, stringToRewardInter, stringToRewardParam } from './giftPacka
import moment = require('moment');
import { ServerlistModel } from '../../db/Serverlist';
import { sendMailByContent } from './../mailService';
import { RoleModel } from '../../db/Role';
import { RoleModel, RoleType } from '../../db/Role';
import { getActivityById } from './activityService';
import { RewardInter } from '../../pubUtils/interface';
import { getGoldId } from '../../pubUtils/itemUtils';
import { DUNGEON_CONST, PVP, VIP } from '../../pubUtils/dicParam';
import { cal } from '../../pubUtils/util';
/**
* 获取活动数据
@@ -115,10 +119,10 @@ export async function makeMonthlyTicketReward(roleId: string, roleName: string,
let { createTime } = await RoleModel.findByRoleId(roleId);
let playerData = new MonthlyTicketData(activityData, createTime);
let endTime = moment(new Date()).startOf('d').add(playerData.days, 'day').toDate();
let endTime = playerData.isForever? moment(new Date()).startOf('d').add(playerData.days, 'day').toDate(): null;
console.log('endTime', moment(new Date()).startOf('d'), endTime, playerData.days)
await ActivityMonthlyTicketModel.buyMonthlyTicket(serverId, roleId, activityId, activityData.type, endTime)
await ActivityMonthlyTicketModel.buyMonthlyTicket(serverId, roleId, activityId, activityData.type, endTime, playerData.isForever)
await RoleModel.buyForeverTicket(roleId);
let firstReward = playerData.firstReward;
let rewardParamArr: Array<RewardParam> = stringToRewardParam(firstReward);
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr, ITEM_CHANGE_REASON.MONTHLY_TICKET_FIRST)
@@ -127,3 +131,75 @@ export async function makeMonthlyTicketReward(roleId: string, roleName: string,
data: Object.assign(result, { item: { isOpen: true, todayIndex: 1 }, activityId: activityData.activityId })
}
}
// 月卡权限
// 军团捐献消耗
export function getVipDonateConsume(originConsume: RewardInter, vipStartTime: number) {
if(vipStartTime > 0) {
if(originConsume.id == getGoldId()) {
return [{ id: originConsume.id, count: Math.floor(originConsume.count * VIP.VIP_GUILD_DONATE_COST_GOLD_RATIO) }];
} else {
return [originConsume];
}
} else {
return [originConsume];
}
}
export function getVipHungupReward(startTime: number, endTime: number, baseReward: RewardInter[], notReceivedGoods: {gid: number, count: number}[], vipStartTime: number) {
let multi = Math.floor((endTime - startTime) / HANG_UP_CONSTS.UNIT_TIME);
if(vipStartTime > 0) {
if(vipStartTime > startTime) { // 开始挂机之后买的月卡
let isNotVipNum = Math.floor((vipStartTime - startTime) / HANG_UP_CONSTS.UNIT_TIME); // 不是vip的时间段数
let isVipNum = multi - isNotVipNum; // 是vip的时间段数
multi = cal.add(isNotVipNum, cal.mul(isVipNum, VIP.VIP_TOWER_HUNG_UP_RATIO));
} else {
multi = cal.mul(multi, VIP.VIP_TOWER_HUNG_UP_RATIO);
}
}
let needReceiveGoods: {gid: number, count: number}[] = [];// 由于小数,未能领取的奖励
let timeReward: {id: number, count: number}[] = []; // 本次奖励
for (let { id, count } of baseReward) {
let newCount = cal.mul(count, multi);
let oldGoods = notReceivedGoods.find(cur => cur.gid == id);
if (oldGoods) newCount = cal.add(newCount, oldGoods.count);
let roundCount = Math.floor(newCount);
if (newCount > roundCount) {
needReceiveGoods.push({ gid: id, count: cal.sub(newCount, roundCount) });
}
if (roundCount > 0) {
timeReward.push({ id, count: roundCount })
}
}
return { needReceiveGoods, timeReward }
}
export async function getVipPvpChallengeMaxCnt(roleId: string, vipStartTime?: number) {
if(vipStartTime == undefined) {
let role = await RoleModel.findByRoleId(roleId, 'vipStartTime');
vipStartTime = role.vipStartTime;
}
let count = PVP.PVP_CHALLENGE_COUNTS;
if(vipStartTime > 0) {
count += VIP.VIP_PVP_CHALLENGE_COUNTS_ADD;
}
return count;
}
export function getVipDailyCnt(timesPerDay: number, role: RoleType) {
let vipStartTime = role.vipStartTime;
if(vipStartTime > 0) {
timesPerDay += VIP.VIP_DAILY_TIMERS_PER_DAY_ADD;
}
return timesPerDay
}
export function getVipDungeonCnt(vipStartTime: number) {
let count = DUNGEON_CONST.DUNGEON_CONST_FREE;
if(vipStartTime > 0) {
count += VIP.VIP_DUNGEON_CONST_FREE_ADD;
}
return count
}
+40 -80
View File
@@ -17,6 +17,7 @@ import { ComRoleStatusHero } from '../db/ComBattleTeam';
import { sendMailByContent } from './mailService';
import { DicTowerTask } from '../pubUtils/dictionary/DicTowerTask';
import * as dicParam from '../pubUtils/dicParam';
import { getVipHungupReward } from './activity/monthlyTicketService';
/**
* 获取当前镇念塔状态
@@ -53,26 +54,20 @@ export async function getTowerStatus(role: RoleType) {
* 获取镇念塔挂机收益
* @param roleId
*/
export async function getHungupRewards(roleId: string) {
const result = await calcuHangUpReward(roleId);
if(result.status == -1) {
return result;
}
let {timeReward, startTime, deltaTime} = result.data;
let {hangUpSpdUpCnt = 0, lastSpdUpTime} = await RoleModel.findByRoleId(roleId);
export async function getHungupRewards(roleId: string, role?: RoleType) {
if(!role) role = await RoleModel.findByRoleId(roleId);
const result = await calcuHangUpReward(role);
if(!result) return false;
let { hangUpSpdUpCnt = 0, lastSpdUpTime } = role;
let {timeReward, startTime, deltaTime} = result;
let curTime = new Date();
if (shouldRefresh(lastSpdUpTime, curTime)) {
hangUpSpdUpCnt = 0;
}
let nextCostGold = getManyHangSpdUpCostGold(hangUpSpdUpCnt, 1);
return {
status: 0,
resResult: null,
data: {
startTime, hangUpPassTime: Math.floor(deltaTime/1000), hangUpSpdUpCnt: dicParam.TOWER_BOOST.TOWER_BOOSTTIME - hangUpSpdUpCnt, nextCostGold, rewards: timeReward
}
}
return { startTime, hangUpPassTime: Math.floor(deltaTime/1000), hangUpSpdUpCnt: dicParam.TOWER_BOOST.TOWER_BOOSTTIME - hangUpSpdUpCnt, nextCostGold, rewards: timeReward }
}
/**
@@ -265,43 +260,21 @@ async function startHangUp(roleId: string, roleName: string) {
await HangUpRecordModel.initRecord(roleId, roleName);
}
export async function checkHangUpSpdUpCnt(roleId: string, cnt: number, curTime: Date) {
const role = await RoleModel.findByRoleId(roleId);
let { hangUpSpdUpCnt, gold, lastSpdUpTime } = role;
if (shouldRefresh(lastSpdUpTime, curTime)) {
hangUpSpdUpCnt = 0;
}
if (cnt + hangUpSpdUpCnt > dicParam.TOWER_BOOST.TOWER_BOOSTTIME) {
return { status: -1, resResult: resResult(STATUS.TOWER_NOT_ENOUGH_HANG_UP_TIME) }
}
return { status: 0, data: { hangUpSpdUpCnt, gold, lastSpdUpTime } }
}
export async function calcuHangUpReward(roleId: string, speedUp = false, speedUpCnt = 1, curTime = new Date()) {
let { towerLv = 1, hangUpSpdUpCnt = 0, lastSpdUpTime } = await RoleModel.findByRoleId(roleId);
export async function calcuHangUpReward(role: RoleType, speedUp = false, speedUpCnt = 1, curTime = new Date()) {
let { roleId, towerLv = 1, hangUpSpdUpCnt = 0, lastSpdUpTime, vipStartTime } = role;
if (towerLv - 1 < dicParam.TOWER_HANG_UP.TOWER_HANG_UP_ENABLE_LV) {
return { status: -1, resResult: resResult(STATUS.TOWER_HANG_UP_NOT_START) }
return false
}
let towerInfo = gameData.tower.get(towerLv - 1); // towerLv 是当前层,奖励计算按照已经通过的层,即上一层
let timeReward = []; // 奖励
let needReceiveGoods = []; // 由于小数,未能领取的奖励
let baseReward = towerInfo.rewardOfcollect;
let { startTime } = await HangUpRecordModel.getCurRec(roleId);
let endTime = curTime; // 挂机结束时间,现在到开始时间,经历了10的倍数的时间
let deltaTime = curTime.getTime() - startTime.getTime(); // 累计的挂机时间,受最大时间限制
if (deltaTime > HANG_UP_CONSTS.MAX_TIME) {
deltaTime = HANG_UP_CONSTS.MAX_TIME;
endTime = curTime; // 累积到超过24小时,那么结束时间和下一次开启时间就取整了
} else {
let multiReal = Math.floor(deltaTime / HANG_UP_CONSTS.UNIT_TIME);// 距开始挂机实际过去的时间单位
endTime = new Date(startTime.getTime() + multiReal * HANG_UP_CONSTS.UNIT_TIME)
}
if (speedUp) { // 加速,直接收取6小时收益,小数的累积和普通收取独立
if (hangUpSpdUpCnt + speedUpCnt <= dicParam.TOWER_BOOST.TOWER_BOOSTTIME || !lastSpdUpTime || shouldRefresh(lastSpdUpTime, new Date)) { // 可加速
let multi = Math.floor(HANG_UP_CONSTS.SPD_UP_REC_TIME / HANG_UP_CONSTS.UNIT_TIME);
let startTime = curTime;
let endTime = new Date(curTime.getTime() + HANG_UP_CONSTS.SPD_UP_REC_TIME);
let deltaTime = endTime.getTime() - startTime.getTime(); // 累计的挂机时间,受最大时间限制
let spdUpRec = await HangUpSpdUpRecModel.getSpdUpRec(roleId, towerLv - 1);
let goods = [];
if (spdUpRec) {
@@ -309,50 +282,37 @@ export async function calcuHangUpReward(roleId: string, speedUp = false, speedUp
let notReceivedGoods = notReceivedGoodsList.find(cur => cur.cnt == cnt);
goods = notReceivedGoods ? notReceivedGoods.goods : [];
}
for (let { id, count } of baseReward) {
let newCount = cal.mul(count, multi);
let oldGoods = goods.find(cur => cur.gid == id);
if (oldGoods) newCount = cal.add(newCount, oldGoods.count);
let roundCount = Math.floor(newCount);
if (newCount > roundCount) {
needReceiveGoods.push({ gid: id, count: cal.sub(newCount, roundCount) });
}
if (roundCount > 0) {
timeReward.push({ id, count: roundCount })
}
}
let { timeReward, needReceiveGoods } = getVipHungupReward(startTime.getTime(), endTime.getTime(), baseReward, goods, vipStartTime);
return {
endLv: towerLv, startTime, deltaTime, endTime, timeReward, needReceiveGoods
};
} else {
return false
}
} else {
let { startTime } = await HangUpRecordModel.getCurRec(roleId);
let endTime = curTime; // 挂机结束时间,现在到开始时间,经历了10的倍数的时间
let deltaTime = curTime.getTime() - startTime.getTime(); // 累计的挂机时间,受最大时间限制
if (deltaTime > HANG_UP_CONSTS.MAX_TIME) {
deltaTime = HANG_UP_CONSTS.MAX_TIME;
startTime = new Date(curTime.getTime() - deltaTime);
endTime = curTime; // 累积到超过24小时,那么结束时间和下一次开启时间就取整了
} else {
let multiReal = Math.floor(deltaTime / HANG_UP_CONSTS.UNIT_TIME);// 距开始挂机实际过去的时间单位
endTime = new Date(startTime.getTime() + multiReal * HANG_UP_CONSTS.UNIT_TIME)
}
let lastRec = await HangUpRecordModel.getLastRec(roleId);
let notReceivedGoods = lastRec ? lastRec.notReceivedGoods : [];
let multi = Math.floor(deltaTime / HANG_UP_CONSTS.UNIT_TIME); // 结算奖励的倍数,受最大时间限制
let { timeReward, needReceiveGoods } = getVipHungupReward(startTime.getTime(), endTime.getTime(), baseReward, notReceivedGoods, vipStartTime);
// console.log(deltaTime, multi, baseReward);
for (let { id, count } of baseReward) {
let newCount = cal.mul(count, multi);
let oldGoods = notReceivedGoods.find(cur => cur.gid == id);
if (oldGoods) newCount = cal.add(newCount, oldGoods.count);
let roundCount = Math.floor(newCount);
if (newCount > roundCount) {
needReceiveGoods.push({ gid: id, count: cal.sub(newCount, roundCount) });
}
if (roundCount > 0) {
timeReward.push({ id, count: roundCount })
}
}
return {
endLv: towerLv, startTime, deltaTime, endTime, timeReward, needReceiveGoods
};
}
return {
status: 0,
data: {
endLv: towerLv - 1,
startTime,
deltaTime,
endTime,
timeReward,
needReceiveGoods
}
};
}
function checkCond(heroes: TaskHero[], type: number, param: number, cnt: number) {
+3 -3
View File
@@ -187,10 +187,10 @@ async function getTowerEntryData(role: RoleType) {
const status = await getTowerStatus(role);
const hungUp = await getHungupRewards(roleId);
const tasks = await getTasks(role);
if (hungUp.status == -1) {
if (!hungUp) {
return { status, hungUp: {}, tasks }
} else {
return { status, hungUp: hungUp.data, tasks }
return { status, hungUp: hungUp, tasks }
}
}
@@ -202,7 +202,7 @@ async function getPvpEntryData(roleId: string) {
let pvpDefense = await PvpDefenseModel.findByRoleId(roleId);
if (pvpDefense) {
let seasonEndTime = pinus.app.get('pvpSeasonEndTime');
let refChallengeObj = refChallengeCnt(pvpDefense.challengeCnt, pvpDefense.challengeRefTime, seasonEndTime);
let refChallengeObj = await refChallengeCnt(pvpDefense.challengeCnt, pvpDefense.challengeRefTime, seasonEndTime, roleId);
let { challengeCnt } = refChallengeObj;
let { receivedBox, score, hisScore } = pvpDefense;
+12 -12
View File
@@ -11,6 +11,7 @@ import { DicWar } from '../pubUtils/dictionary/DicWar';
import { WarStar } from '../domain/dbGeneral';
import * as dicParam from '../pubUtils/dicParam';
import { calculateWarStar } from './normalBattleService';
import { getVipDailyCnt } from './activity/monthlyTicketService';
/**
* 获取全部每日关卡列表
@@ -29,7 +30,7 @@ export async function getDailyBattleList(role: RoleType) {
let war = getDailyWarStatus(dic, warStar);
wars.push(war);
}
let checkDailyResult = await getDailyNum(refreshResult, timesPerDay, timesCanBuy);
let checkDailyResult = await getDailyNum(refreshResult, role);
result.push({
type, name, ...checkDailyResult,
wars
@@ -75,7 +76,7 @@ export async function checkDaily(roleId: string, battleId: number, inc: number)
if(count + inc > curDaily.timesPerDay + buyCount ) {
return { status: -1, resResult: resResult(STATUS.DAILY_TIMES_LACK) }
}
let checkDailyResult = await getDailyNum(dailyRecord, curDaily.timesPerDay, curDaily.timesCanBuy);
let checkDailyResult = await getDailyNum(dailyRecord);
return {status: 1, data: {type, ...checkDailyResult }};
}
@@ -109,21 +110,20 @@ export async function checkDailyAndIncrease(roleId: string, warStar: WarStar[],
return { status: -1, resResult: resResult(STATUS.DAILY_TIMES_LACK) }
}
let result = await DailyRecordModel.increseDailyCount(roleId, type, inc);
let checkDailyResult = await getDailyNum(result, curDaily.timesPerDay, curDaily.timesCanBuy);
let checkDailyResult = await getDailyNum(result);
return {status: 1, data: {type, ...checkDailyResult, war}};
}
export async function getDailyNum(dailyRecord: DailyRecord, timesPerDay?: number, timesCanBuy?: number) {
export async function getDailyNum(dailyRecord: DailyRecord, role?: RoleType) {
let {roleId, type, count = 0, buyCount = 0} = dailyRecord;
if(!timesPerDay || !timesCanBuy) {
const curDaily = gameData.daily.find(cur => cur.dailyType == type);
timesPerDay = curDaily.timesPerDay;
timesCanBuy = curDaily.timesCanBuy;
}
let {vLv} = await RoleModel.findByRoleId(roleId);
if(vLv > 0) {
timesCanBuy += 0; // 暂留,用于处理vip等级增加最大购买次数
const curDaily = gameData.daily.find(cur => cur.dailyType == type);
let {timesPerDay, timesCanBuy} = curDaily;
if(!role) {
role = await RoleModel.findByRoleId(roleId, 'vipStartTime');
}
timesPerDay = getVipDailyCnt(timesPerDay, role);
return {count: timesPerDay - count + buyCount, buyCount: timesCanBuy - buyCount}
}
+11 -7
View File
@@ -11,6 +11,7 @@ import { BattleRecordType } from '../db/BattleRecord';
import { gameData } from '../pubUtils/data';
import { DungeonFirstModel } from '../db/DungeonFirst';
import { nowSeconds } from '../pubUtils/timeUtil';
import { getVipDungeonCnt } from './activity/monthlyTicketService';
/**
* 获取秘境本数据
@@ -24,29 +25,31 @@ export async function getDungeonData(role: RoleType) {
}
let nextCostGold = getDungeonBuyCountCost(dungeonBuyCnt + 1);
let freeCount = getVipDungeonCnt(role.vipStartTime);
return {
nextCostGold,
dungeonHeroes,
battleCount: dicParam.DUNGEON_CONST.DUNGEON_CONST_FREE + dungeonBuyCnt - dungeonCnt,
battleCount: freeCount + dungeonBuyCnt - dungeonCnt,
buyCount: dicParam.DUNGEON_CONST.DUNGEON_CONST_BUY - dungeonBuyCnt
}
}
// 检查秘境本次数checkBattle使用
export async function checkDungeonNum(roleId: string, inc: number) {
let { dungeonCnt = 0, dungeonBuyCnt = 0, dungeonRefTime } = await RoleModel.findByRoleId(roleId);
let { dungeonCnt = 0, dungeonBuyCnt = 0, dungeonRefTime, vipStartTime } = await RoleModel.findByRoleId(roleId);
let curTime = new Date();
let needRefresh = shouldRefresh(dungeonRefTime, curTime);
if(needRefresh) {
dungeonCnt = 0; dungeonBuyCnt = 0;
}
if(dungeonCnt + inc > dicParam.DUNGEON_CONST.DUNGEON_CONST_FREE + dungeonBuyCnt) {
let freeCount = getVipDungeonCnt(vipStartTime);
if(dungeonCnt + inc > freeCount + dungeonBuyCnt) {
return {status: -1, resResult: resResult(STATUS.DUNGEON_TIMES_LACK)}
}
await RoleModel.increaseDungeonCnt(roleId, needRefresh, 0, curTime);
return { status: 0, data: {
battleCount: dicParam.DUNGEON_CONST.DUNGEON_CONST_FREE + dungeonBuyCnt - dungeonCnt,
battleCount: freeCount + dungeonBuyCnt - dungeonCnt,
buyCount: dicParam.DUNGEON_CONST.DUNGEON_CONST_BUY - dungeonBuyCnt
}};
}
@@ -60,21 +63,22 @@ export async function checkDungeonNum(roleId: string, inc: number) {
export async function checkDungeonAndIncrease(roleId: string, inc: number, isRef: boolean) {
let { dungeonCnt = 0, dungeonBuyCnt = 0, dungeonRefTime } = await RoleModel.findByRoleId(roleId);
let { dungeonCnt = 0, dungeonBuyCnt = 0, dungeonRefTime, vipStartTime } = await RoleModel.findByRoleId(roleId);
let curTime = new Date();
let needRefresh = isRef && shouldRefresh(dungeonRefTime, curTime);
if(needRefresh) {
dungeonCnt = 0; dungeonBuyCnt = 0;
}
let freeCount = getVipDungeonCnt(vipStartTime);
if(dungeonCnt + inc > dicParam.DUNGEON_CONST.DUNGEON_CONST_FREE + dungeonBuyCnt ) {
if(dungeonCnt + inc > freeCount + dungeonBuyCnt ) {
return { status: -1, resResult: resResult(STATUS.DUNGEON_TIMES_LACK) }
}
// console.log('needRefresh', needRefresh);
await RoleModel.increaseDungeonCnt(roleId, needRefresh, inc, curTime);
return {status: 1, data: {
battleCount: dicParam.DUNGEON_CONST.DUNGEON_CONST_FREE + dungeonBuyCnt - dungeonCnt - inc,
battleCount: freeCount + dungeonBuyCnt - dungeonCnt - inc,
buyCount: dicParam.DUNGEON_CONST.DUNGEON_CONST_BUY - dungeonBuyCnt
}};
}
+13 -8
View File
@@ -26,6 +26,7 @@ import { checkTask } from '../services/taskService';
import { sendMailByContent } from './mailService';
import { RoleRankInfo } from '../domain/rank';
import { reportTAEvent } from './sdkService';
import { getVipPvpChallengeMaxCnt } from './activity/monthlyTicketService';
/**
* 返回对手三人信息
@@ -296,9 +297,10 @@ export function getLvByScore(heroScores: HeroScore[]) {
return getPLvByScore(score);
}
export function refChallengeCnt(challengeCnt: number, challengeRefTime: number, seasonEndTime: number) {
export async function refChallengeCnt(challengeCnt: number, challengeRefTime: number, seasonEndTime: number, roleId: string, vipStartTime?: number) {
let hasChanged = false;
if (challengeCnt >= PVP.PVP_CHALLENGE_COUNTS) {
let initCount = await getVipPvpChallengeMaxCnt(roleId, vipStartTime)
if (challengeCnt >= initCount) {
return { hasChanged, challengeCnt, challengeRefTime: nowSeconds() };
}
let period = PVP.PVP_CHALLENGE_NORMALTIMES * 60;
@@ -312,20 +314,22 @@ export function refChallengeCnt(challengeCnt: number, challengeRefTime: number,
challengeRefTime = challengeRefTime + period * num;
hasChanged = true;
}
challengeCnt = challengeCnt > PVP.PVP_CHALLENGE_COUNTS ? PVP.PVP_CHALLENGE_COUNTS : challengeCnt;
challengeCnt = challengeCnt > initCount ? initCount : challengeCnt;
return { hasChanged, challengeCnt, challengeRefTime };
}
export function comsumeChallengeCnt(challengeCnt: number, challengeRefTime: number, seasonEndTime: number) {
export async function comsumeChallengeCnt(challengeCnt: number, challengeRefTime: number, seasonEndTime: number, roleId: string) {
let initCount = await getVipPvpChallengeMaxCnt(roleId)
challengeCnt--;
if (challengeCnt >= PVP.PVP_CHALLENGE_COUNTS) {
if (challengeCnt >= initCount) {
return { challengeCnt, challengeRefTime };
}
if (challengeCnt == PVP.PVP_CHALLENGE_COUNTS - 1) {
if (challengeCnt == initCount - 1) {
challengeRefTime = nowSeconds();
return { challengeCnt, challengeRefTime };
}
return refChallengeCnt(challengeCnt, challengeRefTime, seasonEndTime);
return refChallengeCnt(challengeCnt, challengeRefTime, seasonEndTime, roleId);
}
export async function sendLastSeasonRewardIfNotSent(pvpDefense: PvpDefenseType) {
@@ -569,13 +573,14 @@ export async function sendPVPRewardToUser(pvpDefense: PvpDefenseType, seasonNum:
async function resetPvpScores(pvpDefense: PvpDefenseType, seasonNum: number, pvpSeasonResult: PvpSeasonResultType) {
let { roleId, attack, defense } = pvpDefense;
let { newHeroScores, newScore } = pvpSeasonResult;
let initCount = await getVipPvpChallengeMaxCnt(roleId)
let newAttack = <Attack>calLineupScore(attack, newHeroScores);
let newDefense = <Defense>calLineupScore(defense, newHeroScores);
pvpDefense = await PvpDefenseModel.updateInfoAndInclude(roleId, {
heroScores: newHeroScores, score: newScore, attack: newAttack, defense: newDefense,
seasonNum, challengeCnt: PVP.PVP_CHALLENGE_COUNTS, challengeRefTime: 0, winStreakNum: 0, isFirstEntry: true
seasonNum, challengeCnt: initCount, challengeRefTime: 0, winStreakNum: 0, isFirstEntry: true
});
return pvpDefense;
}