✨ feat(重阳集会): 添加纯净召唤接口
This commit is contained in:
@@ -6,6 +6,7 @@ import { ActivityChongYangRecModel } from '../../../db/ActivityChongYangRec';
|
|||||||
import { RewardInter } from '../../../pubUtils/interface';
|
import { RewardInter } from '../../../pubUtils/interface';
|
||||||
import { stringToRewardParam } from '../../../services/activity/giftPackageService';
|
import { stringToRewardParam } from '../../../services/activity/giftPackageService';
|
||||||
import { addItems } from '../../../services/role/rewardService';
|
import { addItems } from '../../../services/role/rewardService';
|
||||||
|
import { getZeroPoint } from '../../../pubUtils/timeUtil';
|
||||||
|
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
@@ -46,7 +47,7 @@ export class ChongYangHandler {
|
|||||||
|
|
||||||
const gameCode = genCode(10);
|
const gameCode = genCode(10);
|
||||||
await ActivityChongYangRecModel.gameRecord(serverId, activityId, playerData.roundIndex, roleId, {
|
await ActivityChongYangRecModel.gameRecord(serverId, activityId, playerData.roundIndex, roleId, {
|
||||||
todayIndex: playerData.todayIndex, gameCode, time: new Date(), rewards: '', isSuccess: false, dayIndex,
|
todayIndex: playerData.todayIndex, gameCode, time: new Date(), rewards: '', isSuccess: false, dayIndex, isSkip: false
|
||||||
});
|
});
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, { activityId, gameCode });
|
return resResult(STATUS.SUCCESS, { activityId, gameCode });
|
||||||
@@ -71,20 +72,16 @@ export class ChongYangHandler {
|
|||||||
|
|
||||||
let curRecord = playerData.gameRecords.find(cur => cur.gameCode == gameCode);
|
let curRecord = playerData.gameRecords.find(cur => cur.gameCode == gameCode);
|
||||||
if (!curRecord) return resResult(STATUS.ACTIVITY_CHONGYANG_GAMECODE_NOT_FOUND);
|
if (!curRecord) return resResult(STATUS.ACTIVITY_CHONGYANG_GAMECODE_NOT_FOUND);
|
||||||
if (curRecord.isSuccess) return resResult(STATUS.ACTIVITY_CHONGYANG_GAMECODE_NOT_FOUND);
|
if (curRecord.isSuccess) return resResult(STATUS.ACTIVITY_CHONGYANG_GAMECODE_USE);
|
||||||
|
|
||||||
let rewards: string = '';
|
let playerRecord = await ActivityChongYangRecModel.gameEnd(serverId, activityId, playerData.roundIndex, roleId, gameCode, isSuccess, new Date(), scene.rewards);
|
||||||
let isReward = playerData.gameRecords.find(cur => cur.dayIndex == dayIndex && cur.isSuccess);
|
|
||||||
if (isReward == undefined) rewards = scene.rewards;
|
|
||||||
|
|
||||||
let playerRecord = await ActivityChongYangRecModel.gameEnd(serverId, activityId, playerData.roundIndex, roleId, gameCode, isSuccess, new Date(), rewards);
|
|
||||||
if (!playerRecord) return resResult(STATUS.ACTIVITY_CHONGYANG_GAMECODE_NOT_FOUND);
|
if (!playerRecord) return resResult(STATUS.ACTIVITY_CHONGYANG_GAMECODE_NOT_FOUND);
|
||||||
playerData = await getPlayerChongYangData(activityId, serverId, roleId);
|
playerData = await getPlayerChongYangData(activityId, serverId, roleId);
|
||||||
scene = playerData.sceneMap.get(dayIndex);
|
scene = playerData.sceneMap.get(dayIndex);
|
||||||
|
|
||||||
let goods: RewardInter[] = [];
|
let goods: RewardInter[] = [];
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
goods = await addItems(roleId, roleName, sid, stringToRewardParam(rewards), ITEM_CHANGE_REASON.CHONGYANG_REWARD)
|
goods = await addItems(roleId, roleName, sid, stringToRewardParam(scene.rewards), ITEM_CHANGE_REASON.CHONGYANG_REWARD)
|
||||||
}
|
}
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, {
|
return resResult(STATUS.SUCCESS, {
|
||||||
@@ -108,7 +105,7 @@ export class ChongYangHandler {
|
|||||||
if (!scene) return resResult(STATUS.ACTIVITY_MISSING);
|
if (!scene) return resResult(STATUS.ACTIVITY_MISSING);
|
||||||
|
|
||||||
// 检测购买次数
|
// 检测购买次数
|
||||||
if (scene.buyCnt >= scene.dailyBuyCnt || scene.buyCnt + count > scene.dailyBuyCnt) return resResult(STATUS.ACTIVITY_CHONGYANG_BUY_COUNT_OVER);
|
if (scene.buyCnt + count > scene.dailyBuyCnt) return resResult(STATUS.ACTIVITY_CHONGYANG_BUY_COUNT_OVER);
|
||||||
// 检测解锁
|
// 检测解锁
|
||||||
if (dayIndex > playerData.dayIndexUnlock) return resResult(STATUS.ACTIVITY_CHONGYANG_LOCK);
|
if (dayIndex > playerData.dayIndexUnlock) return resResult(STATUS.ACTIVITY_CHONGYANG_LOCK);
|
||||||
|
|
||||||
@@ -121,4 +118,45 @@ export class ChongYangHandler {
|
|||||||
|
|
||||||
return resResult(STATUS.SUCCESS, { activityId, dailyBuyCnt: scene.dailyBuyCnt, buyCnt: scene.buyCnt, });
|
return resResult(STATUS.SUCCESS, { activityId, dailyBuyCnt: scene.dailyBuyCnt, buyCnt: scene.buyCnt, });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async gameSweep(msg: { activityId: number, dayIndex: number, count: number }, session: BackendSession) {
|
||||||
|
const { activityId, dayIndex, count } = msg;
|
||||||
|
const roleId: string = session.get('roleId');
|
||||||
|
const roleName: string = session.get('roleName');
|
||||||
|
const serverId: number = session.get('serverId');
|
||||||
|
const sid: string = session.get('sid');
|
||||||
|
|
||||||
|
let playerData = await getPlayerChongYangData(activityId, serverId, roleId);
|
||||||
|
if (!playerData || !playerData.sceneMap) return resResult(STATUS.ACTIVITY_MISSING);
|
||||||
|
let scene = playerData.sceneMap.get(dayIndex);
|
||||||
|
if (!scene) return resResult(STATUS.ACTIVITY_MISSING);
|
||||||
|
|
||||||
|
// 检测挑战次数
|
||||||
|
if (scene.playCnt + count > scene.maxPlayCnt) return resResult(STATUS.ACTIVITY_CHONGYANG_NO_NUM);
|
||||||
|
// 检测解锁
|
||||||
|
if (dayIndex > playerData.dayIndexUnlock) return resResult(STATUS.ACTIVITY_CHONGYANG_LOCK);
|
||||||
|
// 检测通关
|
||||||
|
let isHasPass = playerData.gameRecords.find(cur => cur.dayIndex == dayIndex && cur.isSuccess && !cur.isSkip && (getZeroPoint()*1000 <= cur.time.getTime()));
|
||||||
|
if (!isHasPass) return resResult(STATUS.ACTIVITY_CHONGYANG_GAMESWEEP_LOCK);
|
||||||
|
|
||||||
|
let rewards: RewardInter[] = [];
|
||||||
|
for (let i = 0; i < count; i++) {
|
||||||
|
await ActivityChongYangRecModel.gameRecord(serverId, activityId, playerData.roundIndex, roleId, {
|
||||||
|
todayIndex: playerData.todayIndex, gameCode: 'sweep', time: new Date(), rewards: scene.rewards, isSuccess: true, dayIndex, isSkip: true
|
||||||
|
});
|
||||||
|
rewards.push(...stringToRewardParam(scene.rewards));
|
||||||
|
}
|
||||||
|
|
||||||
|
let goods = await addItems(roleId, roleName, sid, rewards, ITEM_CHANGE_REASON.CHONGYANG_REWARD)
|
||||||
|
|
||||||
|
playerData = await getPlayerChongYangData(activityId, serverId, roleId);
|
||||||
|
scene = playerData.sceneMap.get(dayIndex);
|
||||||
|
|
||||||
|
return resResult(STATUS.SUCCESS, {
|
||||||
|
activityId,
|
||||||
|
playCnt: scene.playCnt,
|
||||||
|
maxPlayCnt: scene.maxPlayCnt,
|
||||||
|
goods
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2313,6 +2313,11 @@ export function checkRouteParam(route: string, msg: any) {
|
|||||||
if (!checkNaturalNumbers(msg.activityId, msg.dayIndex, msg.count)) return false;
|
if (!checkNaturalNumbers(msg.activityId, msg.dayIndex, msg.count)) return false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'activity.chongyangHandler.gameSweep':
|
||||||
|
{
|
||||||
|
if (!checkNaturalNumbers(msg.activityId, msg.dayIndex, msg.count)) return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'activity.activityHandler.debugActivityMemory':
|
case 'activity.activityHandler.debugActivityMemory':
|
||||||
case 'activity.popUpShopHandler.debugPushPopUpShop':
|
case 'activity.popUpShopHandler.debugPushPopUpShop':
|
||||||
case 'activity.popUpShopHandler.debugPushPopUpInterval':
|
case 'activity.popUpShopHandler.debugPushPopUpInterval':
|
||||||
|
|||||||
@@ -711,6 +711,10 @@ export const STATUS = {
|
|||||||
ACTIVITY_CHONGYANG_LOCK: { code: 50085, simStr: '游戏层数未解锁' },
|
ACTIVITY_CHONGYANG_LOCK: { code: 50085, simStr: '游戏层数未解锁' },
|
||||||
ACTIVITY_CHONGYANG_GAMECODE_NOT_FOUND: { code: 50086, simStr: '未找到该id' },
|
ACTIVITY_CHONGYANG_GAMECODE_NOT_FOUND: { code: 50086, simStr: '未找到该id' },
|
||||||
ACTIVITY_CHONGYANG_BUY_COUNT_OVER: { code: 50087, simStr: '购买次数不足' },
|
ACTIVITY_CHONGYANG_BUY_COUNT_OVER: { code: 50087, simStr: '购买次数不足' },
|
||||||
|
ACTIVITY_CHONGYANG_GAMECODE_USE: { code: 50088, simStr: '游戏已经结算过' },
|
||||||
|
ACTIVITY_CHONGYANG_GAMESWEEP_LOCK: { code: 50088, simStr: '纯净召唤未开启' },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ export class ChongYangGameRecord {
|
|||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
isSuccess: boolean; // 是否通过
|
isSuccess: boolean; // 是否通过
|
||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
|
isSkip: boolean // 是否纯净召唤
|
||||||
|
@prop({ required: true })
|
||||||
dayIndex: number; //第几天(层)
|
dayIndex: number; //第几天(层)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export class ChongYangData extends ActivityBase {
|
|||||||
let chongyangData: ChongYangSceneDataInDb[] = JSON.parse(data);
|
let chongyangData: ChongYangSceneDataInDb[] = JSON.parse(data);
|
||||||
if (!chongyangData || chongyangData.length == 0) return;
|
if (!chongyangData || chongyangData.length == 0) return;
|
||||||
for (const obj of chongyangData) {
|
for (const obj of chongyangData) {
|
||||||
const { dayIndex, dailyFreeCnt, dailyBuyCnt } = obj;
|
const { dayIndex, dailyFreeCnt } = obj;
|
||||||
|
|
||||||
let maxFreeCnt = dailyFreeCnt;
|
let maxFreeCnt = dailyFreeCnt;
|
||||||
this.sceneMap.set(dayIndex, { ...obj, buyCnt: 0, playCnt: 0, maxPlayCnt: maxFreeCnt, isPushBuyRecord: true });
|
this.sceneMap.set(dayIndex, { ...obj, buyCnt: 0, playCnt: 0, maxPlayCnt: maxFreeCnt, isPushBuyRecord: true });
|
||||||
|
|||||||
Reference in New Issue
Block a user