活动:寻宝骑兵-每日物资
This commit is contained in:
@@ -36,15 +36,29 @@ export async function treasureHuntActivity(serverId: number, roleId: string) {
|
||||
*/
|
||||
export async function getPlayerTreasureHuntData(activityId: number, serverId: number, roleId: string, huntRoundIndex: number, huntBeginTime: Date, huntEndTime: Date) {
|
||||
let activityData: ActivityModelType = await ActivityModel.findActivity(serverId, activityId, true);
|
||||
let dayIndex = 0;
|
||||
let playerRecord: ActivityTreasureHuntShopModelType = await ActivityTreasureHuntShopModel.findTreasureData(serverId, activityId, roleId, huntRoundIndex, dayIndex);
|
||||
|
||||
let playerData = new TreasureHuntData(activityData);
|
||||
playerData.beginTime = moment(huntBeginTime).valueOf();
|
||||
playerData.endTime = moment(huntEndTime).valueOf();
|
||||
playerData.todayIndex = deltaDays(huntBeginTime, new Date) + 1;;
|
||||
playerData.roundIndex = huntRoundIndex;
|
||||
// playerData.setPlayerRecords(playerRecord);
|
||||
|
||||
let playerShopRecord: ActivityTreasureHuntShopModelType = await ActivityTreasureHuntShopModel.findTreasureData(serverId, activityId, roleId, huntRoundIndex, playerData.todayIndex);
|
||||
playerData.shop.setPlayerRecords(playerShopRecord);
|
||||
return playerData;
|
||||
}
|
||||
|
||||
export async function getPlayerTreasureHuntShopData(activityId: number, serverId: number, roleId: string, huntRoundIndex: number, huntBeginTime: Date, huntEndTime: Date) {
|
||||
let activityData: ActivityModelType = await ActivityModel.findActivity(serverId, activityId, true);
|
||||
|
||||
let playerData = new TreasureHuntData(activityData);
|
||||
playerData.beginTime = moment(huntBeginTime).valueOf();
|
||||
playerData.endTime = moment(huntEndTime).valueOf();
|
||||
playerData.todayIndex = deltaDays(huntBeginTime, new Date) + 1;;
|
||||
playerData.roundIndex = huntRoundIndex;
|
||||
|
||||
let playerShopRecord: ActivityTreasureHuntShopModelType = await ActivityTreasureHuntShopModel.findTreasureData(serverId, activityId, roleId, huntRoundIndex, playerData.todayIndex);
|
||||
playerData.shop.setPlayerRecords(playerShopRecord);
|
||||
return playerData;
|
||||
}
|
||||
|
||||
@@ -56,12 +70,18 @@ export async function getTreasureHuntData(serverId: number) {
|
||||
|
||||
if (!tempData) {//开始新周期
|
||||
let { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex } = await getNewActivityData(serverId);
|
||||
if (huntActivityId === 0) {
|
||||
return { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex, activityData }
|
||||
}
|
||||
tempData = await ServerTempModel.updateTreasureHuntData(serverId, huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex);
|
||||
activityData = await ActivityModel.findActivity(serverId, huntActivityId, true);
|
||||
return { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex, activityData }
|
||||
}
|
||||
if (now > tempData.huntEndTime) {//活动过期
|
||||
let { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex } = await getNextActivityData(serverId, tempData.huntActivityId, tempData.huntEndTime, tempData.huntRoundIndex);
|
||||
if (huntActivityId === 0) {
|
||||
return { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex, activityData }
|
||||
}
|
||||
tempData = await ServerTempModel.updateTreasureHuntData(serverId, huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex);
|
||||
activityData = await ActivityModel.findActivity(serverId, huntActivityId, true);
|
||||
return { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex, activityData }
|
||||
|
||||
Reference in New Issue
Block a user