弹出礼包:pvp改为挑战次数

This commit is contained in:
luying
2022-07-09 10:12:58 +08:00
parent 4962055782
commit c1eceaeba5
7 changed files with 20 additions and 11 deletions

View File

@@ -131,7 +131,7 @@ export class PopUpShopHandler {
newLv: param||100,
quality: param||3,
warId: param||128,
score: param||10,
seasonWinNum: param||10,
equipStar: param||10
});

View File

@@ -276,7 +276,7 @@ export class PvpHandler {
let myRank = await r.getMyRank({ roleId });
result.setMyRank(myRank);
await checkTaskInPvpEnd(serverId, roleId, sid, isSuccess, pvpDefense.heroScores, pvpDefense.score);
await checkTaskInPvpEnd(serverId, roleId, sid, isSuccess, pvpDefense.heroScores, pvpDefense.seasonWinNum);
if(hisWinStreakNum < pvpDefense.hisWinStreakNum) {
await unlockFigure(sid, roleId, [{ type: FIGURE_UNLOCK_CONDITION.PVP_WIN_SERIES, paramWinStreakNum: pvpDefense.hisWinStreakNum }]);
}

View File

@@ -108,9 +108,10 @@ export async function checkPopUpConditions(serverId: number, roleId: string, con
map.get(item.param).push(item);
}
for(let [_, items] of map) {
let effectTimes = await pkg.getEffectTime();
let popUpShopRec = await ActivityPopUpShopModel.createRecord({
serverId, activityId, roleId, id: pkg.id,
...pkg.getEffectTime(),
...effectTimes,
items: items.map(item => new PopUpShopItem(item))
});
let result = pkg.pushPackage(popUpShopRec);

View File

@@ -314,7 +314,7 @@ export async function getParamStr(activity: ActivityModelType, productID: string
} else {
let popUpShopRec = await ActivityPopUpShopModel.createRecord({
serverId, activityId: activity.activityId, roleId, id: pkg.id,
...pkg.getEffectTime(),
...await pkg.getEffectTime(),
items: pkg.items.map(item => new PopUpShopItem(item))
});
param['code'] = popUpShopRec.code;

View File

@@ -208,14 +208,14 @@ export async function checkTaskInComBattleEnd(roleStatus: RoleStatus[], capId: s
}
}
export async function checkTaskInPvpEnd(serverId: number, roleId: string, sid: string, isSuccess: boolean, heroScores: HeroScores[], score: number) {
export async function checkTaskInPvpEnd(serverId: number, roleId: string, sid: string, isSuccess: boolean, heroScores: HeroScores[], seasonWinNum: number) {
let task = new CheckTask(serverId, roleId);
task.setParam(TASK_TYPE.PVP_WIN, { isSuccess });
task.setParam(TASK_TYPE.PVP_WIN_SERIES, { isSuccess });
task.setParam(TASK_TYPE.PVP_HERO_SCORE, { heroScores });
await task.saveAndPush(sid);
if(score) {
checkPopUpCondition(serverId, roleId, POP_UP_SHOP_CONDITION_TYPE.PVP, { score }, sid);
if(seasonWinNum) {
checkPopUpCondition(serverId, roleId, POP_UP_SHOP_CONDITION_TYPE.PVP, { seasonWinNum }, sid);
}
}

View File

@@ -200,6 +200,7 @@ export enum POP_UP_SHOP_REFRESH_TIME_TYPE {
NATURAL_WEEK = 2, // 自然周
NATURAL_MONTH = 3, // 自然月
DAYS = 4, // 从beginTime开始固定日
PVP = 5, // pvp赛季
}
export enum TREASURE_HUNT_DATA_TYPE {

View File

@@ -6,6 +6,8 @@ import { RewardInter } from "../../pubUtils/interface";
import { parseNumberList } from "../../pubUtils/util";
import { stringWithTypeToRewardInter } from "../../pubUtils/roleUtil";
import { ActivityBase } from './activityField';
import { PVPConfigModel } from "../../db/SystemConfig";
import { nowSeconds } from "../../pubUtils/timeUtil";
// 数据库格式
interface PopUpShopDataInDb {
@@ -20,7 +22,7 @@ interface PopUpShopPackageInDb {
items: PopUpShopItemInDb[]; // 礼包
duration: number; // 礼包弹出之后,持续时间,单位小时
keyItem: PopUpShopKeyItemIbDb[]; // 关键资源限制refreshDay内可以获得Y个
refreshTimeType: number; // 刷新时间类型0-不复现 1-自然日 2-自然周 3-自然月 4-从beginTime开始固定天
refreshTimeType: number; // 刷新时间类型0-不复现 1-自然日 2-自然周 3-自然月 4-从beginTime开始固定天 5-按pvp赛季
refreshDay: number; // 上面刷新时间的具体天数refreshTimeType=0-3都不会使用这个参数refreshTimeType=4时这个表示固定几天
pushCnt: number; // 在自然日cd之内总推送次数不复现的填0不限制这个使用其他限制的填-1如passCnt填次数的时候这里填-1
passCnt: number; // 弹出了没有购买多少次之后不再推送默认填0
@@ -282,7 +284,7 @@ export class PopUpShopPackage {
return items;
}
public getEffectTime() {
public async getEffectTime() {
let now = new Date();
let beginTime = now;
let endTime = moment(now).add(this.duration, 'h').toDate();
@@ -310,6 +312,11 @@ export class PopUpShopPackage {
effectBeginTime = moment(this.parent.beginTime).startOf('d').add(n * this.refreshDay, 'd').add(REFRESH_TIME, 'h').toDate();
effectEndTime = moment(this.parent.beginTime).startOf('d').add((n + 1) * this.refreshDay, 'd').add(REFRESH_TIME, 'h').toDate();
break;
case POP_UP_SHOP_REFRESH_TIME_TYPE.PVP:
let pvpConfig = await PVPConfigModel.findCurPVPConfig();
effectBeginTime = new Date((pvpConfig?.seasonStartTime??nowSeconds()) * 1000);
effectEndTime = new Date((pvpConfig?.seasonEndTime??nowSeconds()) * 1000);
break;
}
return {
@@ -412,7 +419,7 @@ export class PopShopItem {
case POP_UP_SHOP_CONDITION_TYPE.MAIN_BATTLE:
return param.warId == this.conditionParam[0];
case POP_UP_SHOP_CONDITION_TYPE.PVP:
return param.score >= this.conditionParam[0];
return param.seasonWinNum >= this.conditionParam[0];
case POP_UP_SHOP_CONDITION_TYPE.EQUIP_STAR:
return param.equipStar >= this.conditionParam[0];
case POP_UP_SHOP_CONDITION_TYPE.AUCTION:
@@ -480,7 +487,7 @@ export interface PopUpConditionParamInter {
newLv?: number;
quality?: number;
warId?: number;
score?: number;
seasonWinNum?: number;
equipStar?: number;
}