From 688960b2b49616b69e2c3146df91e01818fdece2 Mon Sep 17 00:00:00 2001 From: luying Date: Mon, 18 Apr 2022 10:24:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B4=BB=E5=8A=A8=EF=BC=9A=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=BC=B9=E5=87=BA=E7=A4=BC=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game-server/app/services/activity/treasureHuntService.ts | 9 ++++++++- game-server/app/services/role/createHero.ts | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/game-server/app/services/activity/treasureHuntService.ts b/game-server/app/services/activity/treasureHuntService.ts index 33157ee2e..c0ab97d41 100644 --- a/game-server/app/services/activity/treasureHuntService.ts +++ b/game-server/app/services/activity/treasureHuntService.ts @@ -209,7 +209,11 @@ export async function getTreasureHuntData(serverId: number, roleId: string) { return { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex, activityData } } if (now > tempData.huntEndTime) {//活动过期 - let { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex } = await getNextActivityData(serverId, roleId, tempData.huntActivityId, tempData.huntEndTime, tempData.huntRoundIndex); + let data = await getNextActivityData(serverId, roleId, tempData.huntActivityId, tempData.huntEndTime, tempData.huntRoundIndex); + if(!data) { + return { activityData: null } + } + let { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex } = data; if (huntActivityId === 0) { return { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex, activityData } } @@ -278,6 +282,9 @@ async function getNextActivityData(serverId: number, roleId: string, oldHuntActi let curDate = moment(new Date()).toDate() let index = treasureHuntDataArray.findIndex(obj => { return obj && obj.activityId === oldHuntActivityId }); + if(index == -1) { + return null + } for (; index < treasureHuntDataArray.length; index++) { let data = treasureHuntDataArray[index]; let endTime = moment(huntBeginTime).add(data.day, 'd').toDate(); diff --git a/game-server/app/services/role/createHero.ts b/game-server/app/services/role/createHero.ts index c98f63acf..4dd62ef14 100644 --- a/game-server/app/services/role/createHero.ts +++ b/game-server/app/services/role/createHero.ts @@ -13,6 +13,7 @@ import { CounterModel } from "../../db/Counter"; import { calculateCes } from "../playerCeService"; import { RoleUpdate } from "../../db/Role"; import { sendMessageToUser, sendMessageToUserWithSuc } from "../pushService"; +import { checkTaskInCreateHero } from "../task/taskService"; /** * 创建多个武将 @@ -77,6 +78,7 @@ import { sendMessageToUser, sendMessageToUserWithSuc } from "../pushService"; let goods = await addItems(roleId, roleName, sid, pieces, ITEM_CHANGE_REASON.HERO_TRANSFER_PIECE); resultItems = goods; } + await checkTaskInCreateHero(serverId, roleId, sid, resultHeroes.length, resultHeroes); return { heroes: showHeroes, resultHeroes, goods: resultItems } }