活动:神州探秘活动
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||||
import { resResult } from '../../../pubUtils/util';
|
import { resResult } from '../../../pubUtils/util';
|
||||||
import { ITEM_CHANGE_REASON, STATUS, } from '../../../consts';
|
import { ITEM_CHANGE_REASON, STATUS, } from '../../../consts';
|
||||||
import { getPlayerTreasureHuntData, getTreasureHuntData, getPlayerTreasureHuntShopData, getPlayerTreasureHuntTaskData, getPlayerTreasureHuntTreasureShopData, getPlayerTreasureHuntChallengeData, getPlayerTreasureHuntFirstPageData } from '../../../services/activity/treasureHuntService';
|
import { getPlayerTreasureHuntData, getPlayerTreasureHuntShopData, getPlayerTreasureHuntTaskData, getPlayerTreasureHuntTreasureShopData, getPlayerTreasureHuntChallengeData, getPlayerTreasureHuntFirstPageData } from '../../../services/activity/treasureHuntService';
|
||||||
import { ActivityTreasureHuntShopModel } from '../../../db/ActivityTreasureHuntShop';
|
import { ActivityTreasureHuntShopModel } from '../../../db/ActivityTreasureHuntShop';
|
||||||
import { ActivityTreasureHuntTaskModel } from '../../../db/ActivityTreasureHuntTask';
|
import { ActivityTreasureHuntTaskModel } from '../../../db/ActivityTreasureHuntTask';
|
||||||
import { handleCost } from '../../../services/role/rewardService';
|
import { handleCost } from '../../../services/role/rewardService';
|
||||||
@@ -37,11 +37,7 @@ export class TreasureHuntHandler {
|
|||||||
const { activityId } = msg;
|
const { activityId } = msg;
|
||||||
const roleId = session.get('roleId');
|
const roleId = session.get('roleId');
|
||||||
const serverId = session.get('serverId');
|
const serverId = session.get('serverId');
|
||||||
let { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex, activityData } = await getTreasureHuntData(serverId, roleId);
|
let playerData = await getPlayerTreasureHuntData(activityId, serverId, roleId);
|
||||||
if (!activityData) {
|
|
||||||
return resResult(STATUS.ACTIVITY_MISSING, {});
|
|
||||||
}
|
|
||||||
let playerData = await getPlayerTreasureHuntData(activityId, serverId, roleId, huntRoundIndex, huntBeginTime, huntEndTime);
|
|
||||||
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, playerData);
|
return resResult(STATUS.SUCCESS, playerData);
|
||||||
@@ -59,16 +55,7 @@ export class TreasureHuntHandler {
|
|||||||
const sid = session.get('sid');
|
const sid = session.get('sid');
|
||||||
const roleName = session.get('roleName');
|
const roleName = session.get('roleName');
|
||||||
|
|
||||||
|
let playerData = await getPlayerTreasureHuntFirstPageData(activityId, serverId, roleId);
|
||||||
let { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex, activityData } = await getTreasureHuntData(serverId, roleId);
|
|
||||||
if (!activityData) {
|
|
||||||
return resResult(STATUS.ACTIVITY_MISSING, {});
|
|
||||||
}
|
|
||||||
if (activityId !== huntActivityId) {
|
|
||||||
return resResult(STATUS.ACTIVITY_MISSING, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
let playerData = await getPlayerTreasureHuntFirstPageData(activityId, serverId, roleId, huntRoundIndex, huntBeginTime, huntEndTime,);
|
|
||||||
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
||||||
|
|
||||||
if (playerData.firstPage.isReceive) {
|
if (playerData.firstPage.isReceive) {
|
||||||
@@ -76,7 +63,7 @@ export class TreasureHuntHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//添加领取记录
|
//添加领取记录
|
||||||
await ActivityTreasureHuntFirstPageModel.receiveReward(serverId, activityId, roleId, huntRoundIndex);
|
await ActivityTreasureHuntFirstPageModel.receiveReward(serverId, activityId, roleId, playerData.roundIndex);
|
||||||
|
|
||||||
let rewardParamArr: Array<RewardParam> = stringToRewardParam(playerData.firstPage.reward);
|
let rewardParamArr: Array<RewardParam> = stringToRewardParam(playerData.firstPage.reward);
|
||||||
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr, ITEM_CHANGE_REASON.TREASURE_HUNT_FIRST_PAGE_REWARD)
|
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr, ITEM_CHANGE_REASON.TREASURE_HUNT_FIRST_PAGE_REWARD)
|
||||||
@@ -100,16 +87,7 @@ export class TreasureHuntHandler {
|
|||||||
const sid = session.get('sid');
|
const sid = session.get('sid');
|
||||||
const roleName = session.get('roleName');
|
const roleName = session.get('roleName');
|
||||||
|
|
||||||
|
let playerData = await getPlayerTreasureHuntShopData(activityId, serverId, roleId,);
|
||||||
let { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex, activityData } = await getTreasureHuntData(serverId, roleId);
|
|
||||||
if (!activityData) {
|
|
||||||
return resResult(STATUS.ACTIVITY_MISSING, {});
|
|
||||||
}
|
|
||||||
if (activityId !== huntActivityId) {
|
|
||||||
return resResult(STATUS.ACTIVITY_MISSING, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
let playerData = await getPlayerTreasureHuntShopData(activityId, serverId, roleId, huntRoundIndex, huntBeginTime, huntEndTime,);
|
|
||||||
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
||||||
let item = playerData.shop.getItem(cellIndex);
|
let item = playerData.shop.getItem(cellIndex);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
@@ -128,7 +106,7 @@ export class TreasureHuntHandler {
|
|||||||
if (!resourceResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
if (!resourceResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||||
|
|
||||||
//添加购买记录
|
//添加购买记录
|
||||||
await ActivityTreasureHuntShopModel.buyShopRecord(activityId, roleId, huntRoundIndex, playerData.todayIndex, cellIndex);
|
await ActivityTreasureHuntShopModel.buyShopRecord(activityId, roleId, playerData.roundIndex, playerData.todayIndex, cellIndex);
|
||||||
|
|
||||||
let rewardParamArr: Array<RewardParam> = stringToRewardParam(item.reward);
|
let rewardParamArr: Array<RewardParam> = stringToRewardParam(item.reward);
|
||||||
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr, ITEM_CHANGE_REASON.TREASURE_HUNT_SHOP_BUY)
|
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr, ITEM_CHANGE_REASON.TREASURE_HUNT_SHOP_BUY)
|
||||||
@@ -152,16 +130,7 @@ export class TreasureHuntHandler {
|
|||||||
const sid = session.get('sid');
|
const sid = session.get('sid');
|
||||||
const roleName = session.get('roleName');
|
const roleName = session.get('roleName');
|
||||||
|
|
||||||
|
let playerData = await getPlayerTreasureHuntTaskData(activityId, serverId, roleId);
|
||||||
let { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex, activityData } = await getTreasureHuntData(serverId, roleId);
|
|
||||||
if (!activityData) {
|
|
||||||
return resResult(STATUS.ACTIVITY_MISSING, {});
|
|
||||||
}
|
|
||||||
if (activityId !== huntActivityId) {
|
|
||||||
return resResult(STATUS.ACTIVITY_MISSING, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
let playerData = await getPlayerTreasureHuntTaskData(activityId, serverId, roleId, huntRoundIndex, huntBeginTime, huntEndTime,);
|
|
||||||
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
||||||
let item = playerData.tasks.getItem(cellIndex);
|
let item = playerData.tasks.getItem(cellIndex);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
@@ -175,7 +144,7 @@ export class TreasureHuntHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//添加购买记录
|
//添加购买记录
|
||||||
await ActivityTreasureHuntTaskModel.receiveReward(serverId, activityId, roleId, huntRoundIndex, cellIndex, 1);
|
await ActivityTreasureHuntTaskModel.receiveReward(serverId, activityId, roleId, playerData.roundIndex, cellIndex, 1);
|
||||||
|
|
||||||
let rewardParamArr: Array<RewardParam> = stringToRewardParam(item.reward);
|
let rewardParamArr: Array<RewardParam> = stringToRewardParam(item.reward);
|
||||||
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr, ITEM_CHANGE_REASON.TREASURE_HUNT_TASK_REWARD)
|
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr, ITEM_CHANGE_REASON.TREASURE_HUNT_TASK_REWARD)
|
||||||
@@ -199,16 +168,7 @@ export class TreasureHuntHandler {
|
|||||||
const sid = session.get('sid');
|
const sid = session.get('sid');
|
||||||
const roleName = session.get('roleName');
|
const roleName = session.get('roleName');
|
||||||
|
|
||||||
|
let playerData = await getPlayerTreasureHuntChallengeData(activityId, serverId, roleId,);
|
||||||
let { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex, activityData } = await getTreasureHuntData(serverId, roleId);
|
|
||||||
if (!activityData) {
|
|
||||||
return resResult(STATUS.ACTIVITY_MISSING, {});
|
|
||||||
}
|
|
||||||
if (activityId !== huntActivityId) {
|
|
||||||
return resResult(STATUS.ACTIVITY_MISSING, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
let playerData = await getPlayerTreasureHuntChallengeData(activityId, serverId, roleId, huntRoundIndex, huntBeginTime, huntEndTime,);
|
|
||||||
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
||||||
let challengeData = playerData.challenge;
|
let challengeData = playerData.challenge;
|
||||||
//消耗资源
|
//消耗资源
|
||||||
@@ -222,7 +182,7 @@ export class TreasureHuntHandler {
|
|||||||
let warId = playerData.challenge.resultWarId;
|
let warId = playerData.challenge.resultWarId;
|
||||||
if(!warId) {
|
if(!warId) {
|
||||||
warId = playerData.challenge.randomGK();
|
warId = playerData.challenge.randomGK();
|
||||||
await ActivityTreasureHuntChallengeModel.setWarId(serverId, activityId, roleId, huntRoundIndex, warId);
|
await ActivityTreasureHuntChallengeModel.setWarId(serverId, activityId, roleId, playerData.roundIndex, warId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, Object.assign({ warId }, {
|
return resResult(STATUS.SUCCESS, Object.assign({ warId }, {
|
||||||
@@ -242,16 +202,7 @@ export class TreasureHuntHandler {
|
|||||||
const sid = session.get('sid');
|
const sid = session.get('sid');
|
||||||
const roleName = session.get('roleName');
|
const roleName = session.get('roleName');
|
||||||
|
|
||||||
|
let playerData = await getPlayerTreasureHuntTreasureShopData(activityId, serverId, roleId,);
|
||||||
let { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex, activityData } = await getTreasureHuntData(serverId, roleId);
|
|
||||||
if (!activityData) {
|
|
||||||
return resResult(STATUS.ACTIVITY_MISSING, {});
|
|
||||||
}
|
|
||||||
if (activityId !== huntActivityId) {
|
|
||||||
return resResult(STATUS.ACTIVITY_MISSING, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
let playerData = await getPlayerTreasureHuntTreasureShopData(activityId, serverId, roleId, huntRoundIndex, huntBeginTime, huntEndTime,);
|
|
||||||
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
||||||
let item = playerData.treasureShop.getItem(cellIndex);
|
let item = playerData.treasureShop.getItem(cellIndex);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
@@ -267,7 +218,7 @@ export class TreasureHuntHandler {
|
|||||||
if (!resourceResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
if (!resourceResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||||
|
|
||||||
//添加购买记录
|
//添加购买记录
|
||||||
await ActivityTreasureHuntTreasureShopModel.addRecord(activityId, roleId, huntRoundIndex, cellIndex);
|
await ActivityTreasureHuntTreasureShopModel.addRecord(activityId, roleId, playerData.roundIndex, cellIndex);
|
||||||
|
|
||||||
let rewardParamArr: Array<RewardParam> = stringToRewardParam(item.reward);
|
let rewardParamArr: Array<RewardParam> = stringToRewardParam(item.reward);
|
||||||
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr, ITEM_CHANGE_REASON.TREASURE_HUNT_SP_SHOP_BUY)
|
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr, ITEM_CHANGE_REASON.TREASURE_HUNT_SP_SHOP_BUY)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { getPlayerVipRechargeMoneyData, } from './vipRechargeMoneyService';
|
|||||||
import { getPlayerActivityData, } from './selfServiceShopActivityService';
|
import { getPlayerActivityData, } from './selfServiceShopActivityService';
|
||||||
import { ActivitySelfServiceGoodsModel } from '../../db/ActivitySelfServiceGoods';
|
import { ActivitySelfServiceGoodsModel } from '../../db/ActivitySelfServiceGoods';
|
||||||
import moment = require('moment');
|
import moment = require('moment');
|
||||||
import { getPlayerTreasureHuntData, getTreasureHuntData } from './treasureHuntService';
|
import { getPlayerTreasureHuntDataShow } from './treasureHuntService';
|
||||||
import { getPopUpShopDataShow } from './popUpShopService';
|
import { getPopUpShopDataShow } from './popUpShopService';
|
||||||
import { getPlayerSevenDaysData } from './sevenDaysService';
|
import { getPlayerSevenDaysData } from './sevenDaysService';
|
||||||
import { getPlayerDailyMealData } from './dailyMealService';
|
import { getPlayerDailyMealData } from './dailyMealService';
|
||||||
@@ -123,8 +123,7 @@ export async function getActivity(serverId: number, roleId: string, guildCode: s
|
|||||||
}
|
}
|
||||||
case ACTIVITY_TYPE.TREASURE_HUNT://寻宝骑兵活动 23
|
case ACTIVITY_TYPE.TREASURE_HUNT://寻宝骑兵活动 23
|
||||||
{
|
{
|
||||||
let { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex } = await getTreasureHuntData(serverId, roleId);
|
activityData = await getPlayerTreasureHuntDataShow(activityId, serverId, roleId);
|
||||||
activityData = await getPlayerTreasureHuntData(activityId, serverId, roleId, huntRoundIndex, huntBeginTime, huntEndTime);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ACTIVITY_TYPE.POP_UP_SHOP://弹出商店 24
|
case ACTIVITY_TYPE.POP_UP_SHOP://弹出商店 24
|
||||||
|
|||||||
@@ -1,86 +1,23 @@
|
|||||||
import moment = require('moment');
|
import { ITEM_CHANGE_REASON, STATUS, TREASURE_HUNT_DATA_TYPE } from '../../consts';
|
||||||
import { ACTIVITY_TYPE, ITEM_CHANGE_REASON, SERVER_OPEN_TIME, STATUS } from '../../consts';
|
import { ActivityTreasureHuntShopModel } from '../../db/ActivityTreasureHuntShop';
|
||||||
import { ActivityModel, ActivityModelType } from '../../db/Activity';
|
import { ActivityTreasureHuntTaskModel } from '../../db/ActivityTreasureHuntTask';
|
||||||
import { ActivityTreasureHuntShopModel, ActivityTreasureHuntShopModelType } from '../../db/ActivityTreasureHuntShop';
|
import { ActivityTreasureHuntTreasureShopModel } from '../../db/ActivityTreasureHuntTreasureShop';
|
||||||
import { ActivityTreasureHuntTaskModel, ActivityTreasureHuntTaskModelType } from '../../db/ActivityTreasureHuntTask';
|
import { ActivityTreasureHuntFirstPageModel } from '../../db/ActivityTreasureHuntFirstPage';
|
||||||
import { ActivityTreasureHuntTreasureShopModel, ActivityTreasureHuntTreasureShopModelType } from '../../db/ActivityTreasureHuntTreasureShop';
|
|
||||||
import { ActivityTreasureHuntFirstPageModel, ActivityTreasureHuntFirstPageModelType } from '../../db/ActivityTreasureHuntFirstPage';
|
|
||||||
import { ServerlistModel } from '../../db/Serverlist';
|
|
||||||
import { ServerTempModel, ServerTempModelType } from '../../db/ServerTemp';
|
|
||||||
import { TreasureHuntData } from '../../domain/activityField/treasureHuntField';
|
import { TreasureHuntData } from '../../domain/activityField/treasureHuntField';
|
||||||
import { deltaDays } from '../../pubUtils/util';
|
|
||||||
import { addReward, stringToConsumeParam, stringToRewardParam } from './giftPackageService';
|
import { addReward, stringToConsumeParam, stringToRewardParam } from './giftPackageService';
|
||||||
import { RewardParam } from '../../domain/activityField/rewardField';
|
import { RewardParam } from '../../domain/activityField/rewardField';
|
||||||
import { RoleModel } from '../../db/Role';
|
import { getActivityById, getActivityByServerId } from './activityService';
|
||||||
import { getActivitiesByType, getActivityById } from './activityService';
|
|
||||||
import { getRoleCreateTime, getServerCreateTime } from '../redisService';
|
import { getRoleCreateTime, getServerCreateTime } from '../redisService';
|
||||||
import { handleCost } from '../role/rewardService';
|
import { handleCost } from '../role/rewardService';
|
||||||
import { ActivityTreasureHuntChallengeModel } from '../../db/ActivityTreasureHuntChallenge';
|
import { ActivityTreasureHuntChallengeModel } from '../../db/ActivityTreasureHuntChallenge';
|
||||||
|
|
||||||
/**
|
export async function getPlayerTreasureHuntDataShow(activityId: number, serverId: number, roleId: string) {
|
||||||
* 获取活动数据
|
let playerData = await getPlayerTreasureHuntData(activityId, serverId, roleId);
|
||||||
*
|
if(playerData && playerData.canShow && playerData.canShow()) {
|
||||||
* @param {number} serverId 区Id
|
return playerData.getShowResult();
|
||||||
* @param {number} type 活动类型 ACTIVITY_TYPE
|
|
||||||
* @param {string} roleId 角色Id
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
export async function treasureHuntActivity(serverId: number, roleId: string) {
|
|
||||||
let { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex, activityData } = await getTreasureHuntData(serverId, roleId);
|
|
||||||
if (!activityData) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null
|
||||||
let createTime = await getRoleCreateTime(roleId);
|
|
||||||
let serverTime = await getServerCreateTime(serverId);
|
|
||||||
let playerData = new TreasureHuntData(activityData, createTime, serverTime);
|
|
||||||
playerData.beginTime = moment(huntBeginTime).valueOf();
|
|
||||||
playerData.endTime = moment(huntEndTime).valueOf();
|
|
||||||
playerData.todayIndex = deltaDays(moment(huntBeginTime).startOf('d').toDate(), new Date) + 1;;
|
|
||||||
playerData.roundIndex = huntRoundIndex;
|
|
||||||
|
|
||||||
let playerTreasureFirstPageecord: ActivityTreasureHuntFirstPageModelType = await ActivityTreasureHuntFirstPageModel.findData(serverId, activityData.activityId, roleId, huntRoundIndex);
|
|
||||||
playerData.firstPage.setPlayerFirstPageRecord(playerTreasureFirstPageecord);
|
|
||||||
let playerShopRecord: ActivityTreasureHuntShopModelType = await ActivityTreasureHuntShopModel.findTreasureData(activityData.activityId, roleId, huntRoundIndex, playerData.todayIndex);
|
|
||||||
playerData.shop.setPlayerShopRecords(playerShopRecord);
|
|
||||||
let playerTaskRecord: ActivityTreasureHuntTaskModelType[] = await ActivityTreasureHuntTaskModel.findDataByRoundIndex(serverId, activityData.activityId, roleId, huntRoundIndex);
|
|
||||||
playerData.tasks.setPlayerTaskRecords(playerTaskRecord);
|
|
||||||
let playerTreasureShopRecord: ActivityTreasureHuntTreasureShopModelType = await ActivityTreasureHuntTreasureShopModel.findData(activityData.activityId, roleId, huntRoundIndex);
|
|
||||||
playerData.treasureShop.setPlayerTreasureShopRecords(playerTreasureShopRecord);
|
|
||||||
|
|
||||||
return playerData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取活动数据
|
|
||||||
*
|
|
||||||
* @param {number} serverId 区Id
|
|
||||||
* @param {number} type 活动类型 ACTIVITY_TYPE
|
|
||||||
* @param {string} roleId 角色Id
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
export async function treasureHuntTaskActivity(serverId: number, roleId: string) {
|
|
||||||
let { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex, activityData } = await getTreasureHuntData(serverId, roleId);
|
|
||||||
if (!activityData) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
let createTime = await getRoleCreateTime(roleId);
|
|
||||||
let serverTime = await getServerCreateTime(serverId);
|
|
||||||
let playerData = new TreasureHuntData(activityData, createTime, serverTime);
|
|
||||||
playerData.beginTime = moment(huntBeginTime).valueOf();
|
|
||||||
playerData.endTime = moment(huntEndTime).valueOf();
|
|
||||||
playerData.todayIndex = deltaDays(moment(huntBeginTime).startOf('d').toDate(), new Date) + 1;;
|
|
||||||
playerData.roundIndex = huntRoundIndex;
|
|
||||||
|
|
||||||
let playerTaskRecord: ActivityTreasureHuntTaskModelType[] = await ActivityTreasureHuntTaskModel.findDataByRoundIndex(serverId, activityData.activityId, roleId, huntRoundIndex);
|
|
||||||
playerData.tasks.setPlayerTaskRecords(playerTaskRecord);
|
|
||||||
return playerData;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 玩家活动数据
|
* 玩家活动数据
|
||||||
*
|
*
|
||||||
@@ -89,234 +26,56 @@ export async function treasureHuntTaskActivity(serverId: number, roleId: string)
|
|||||||
* @param {string} roleId 角色Id
|
* @param {string} roleId 角色Id
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export async function getPlayerTreasureHuntData(activityId: number, serverId: number, roleId: string, huntRoundIndex: number, huntBeginTime: Date, huntEndTime: Date) {
|
export async function getPlayerTreasureHuntData(activityId: number, serverId: number, roleId: string, dataType: TREASURE_HUNT_DATA_TYPE = TREASURE_HUNT_DATA_TYPE.ALL) {
|
||||||
let activityData = await getActivityById(activityId);
|
let activityData = await getActivityById(activityId);
|
||||||
|
|
||||||
let createTime = await getRoleCreateTime(roleId);
|
let createTime = await getRoleCreateTime(roleId);
|
||||||
let serverTime = await getServerCreateTime(serverId);
|
let serverTime = await getServerCreateTime(serverId);
|
||||||
let playerData = new TreasureHuntData(activityData, createTime, serverTime);
|
let playerData = new TreasureHuntData(activityData, createTime, serverTime);
|
||||||
playerData.beginTime = moment(huntBeginTime).valueOf();
|
if(dataType == TREASURE_HUNT_DATA_TYPE.FIRST_PAGE || dataType == TREASURE_HUNT_DATA_TYPE.ALL) {
|
||||||
playerData.endTime = moment(huntEndTime).valueOf();
|
let playerTreasureFirstPageRecord = await ActivityTreasureHuntFirstPageModel.findData(serverId, activityId, roleId, playerData.roundIndex);
|
||||||
playerData.todayIndex = deltaDays(moment(huntBeginTime).startOf('d').toDate(), new Date) + 1;;
|
playerData.firstPage.setPlayerFirstPageRecord(playerTreasureFirstPageRecord);
|
||||||
playerData.roundIndex = huntRoundIndex;
|
}
|
||||||
|
if (dataType == TREASURE_HUNT_DATA_TYPE.SHOP || dataType == TREASURE_HUNT_DATA_TYPE.ALL) {
|
||||||
let playerTreasureFirstPageecord: ActivityTreasureHuntFirstPageModelType = await ActivityTreasureHuntFirstPageModel.findData(serverId, activityId, roleId, huntRoundIndex);
|
let playerShopRecord = await ActivityTreasureHuntShopModel.findTreasureData(activityId, roleId, playerData.roundIndex, playerData.todayIndex);
|
||||||
playerData.firstPage.setPlayerFirstPageRecord(playerTreasureFirstPageecord);
|
playerData.shop.setPlayerShopRecords(playerShopRecord);
|
||||||
let playerShopRecord: ActivityTreasureHuntShopModelType = await ActivityTreasureHuntShopModel.findTreasureData(activityId, roleId, huntRoundIndex, playerData.todayIndex);
|
}
|
||||||
playerData.shop.setPlayerShopRecords(playerShopRecord);
|
if (dataType == TREASURE_HUNT_DATA_TYPE.TASK || dataType == TREASURE_HUNT_DATA_TYPE.ALL) {
|
||||||
let playerTaskRecord: ActivityTreasureHuntTaskModelType[] = await ActivityTreasureHuntTaskModel.findDataByRoundIndex(serverId, activityId, roleId, huntRoundIndex);
|
let playerTaskRecord = await ActivityTreasureHuntTaskModel.findDataByRoundIndex(serverId, activityId, roleId, playerData.roundIndex);
|
||||||
playerData.tasks.setPlayerTaskRecords(playerTaskRecord);
|
playerData.tasks.setPlayerTaskRecords(playerTaskRecord);
|
||||||
let playerTreasureShopRecord: ActivityTreasureHuntTreasureShopModelType = await ActivityTreasureHuntTreasureShopModel.findData(activityId, roleId, huntRoundIndex);
|
}
|
||||||
playerData.treasureShop.setPlayerTreasureShopRecords(playerTreasureShopRecord);
|
if(dataType == TREASURE_HUNT_DATA_TYPE.TREASURE_SHOP || dataType == TREASURE_HUNT_DATA_TYPE.ALL) {
|
||||||
|
let playerTreasureShopRecord = await ActivityTreasureHuntTreasureShopModel.findData(activityId, roleId, playerData.roundIndex);
|
||||||
|
playerData.treasureShop.setPlayerTreasureShopRecords(playerTreasureShopRecord);
|
||||||
|
}
|
||||||
|
if(dataType == TREASURE_HUNT_DATA_TYPE.CHALLENGE || dataType == TREASURE_HUNT_DATA_TYPE.ALL) {
|
||||||
|
let playerRecord = await ActivityTreasureHuntChallengeModel.findData(serverId, activityId, roleId, playerData.roundIndex);
|
||||||
|
playerData.challenge.setChallengeRecord(playerRecord)
|
||||||
|
}
|
||||||
|
|
||||||
return playerData;
|
return playerData;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getPlayerTreasureHuntFirstPageData(activityId: number, serverId: number, roleId: string, huntRoundIndex: number, huntBeginTime: Date, huntEndTime: Date) {
|
export async function getPlayerTreasureHuntFirstPageData(activityId: number, serverId: number, roleId: string) {
|
||||||
let activityData: ActivityModelType = await getActivityById(activityId);
|
return await getPlayerTreasureHuntData(activityId, serverId, roleId, TREASURE_HUNT_DATA_TYPE.FIRST_PAGE);
|
||||||
|
|
||||||
let createTime = await getRoleCreateTime(roleId);
|
|
||||||
let serverTime = await getServerCreateTime(serverId);
|
|
||||||
let playerData = new TreasureHuntData(activityData, createTime, serverTime);
|
|
||||||
playerData.beginTime = moment(huntBeginTime).valueOf();
|
|
||||||
playerData.endTime = moment(huntEndTime).valueOf();
|
|
||||||
playerData.todayIndex = deltaDays(moment(huntBeginTime).startOf('d').toDate(), new Date) + 1;;
|
|
||||||
playerData.roundIndex = huntRoundIndex;
|
|
||||||
|
|
||||||
let playerTreasureFirstPageecord: ActivityTreasureHuntFirstPageModelType = await ActivityTreasureHuntFirstPageModel.findData(serverId, activityId, roleId, huntRoundIndex);
|
|
||||||
playerData.firstPage.setPlayerFirstPageRecord(playerTreasureFirstPageecord);
|
|
||||||
return playerData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getPlayerTreasureHuntShopData(activityId: number, serverId: number, roleId: string, huntRoundIndex: number, huntBeginTime: Date, huntEndTime: Date) {
|
export async function getPlayerTreasureHuntShopData(activityId: number, serverId: number, roleId: string) {
|
||||||
let activityData: ActivityModelType = await getActivityById(activityId);
|
return await getPlayerTreasureHuntData(activityId, serverId, roleId, TREASURE_HUNT_DATA_TYPE.SHOP);
|
||||||
|
|
||||||
let createTime = await getRoleCreateTime(roleId);
|
|
||||||
let serverTime = await getServerCreateTime(serverId);
|
|
||||||
let playerData = new TreasureHuntData(activityData, createTime, serverTime);
|
|
||||||
playerData.beginTime = moment(huntBeginTime).valueOf();
|
|
||||||
playerData.endTime = moment(huntEndTime).valueOf();
|
|
||||||
playerData.todayIndex = deltaDays(moment(huntBeginTime).startOf('d').toDate(), new Date) + 1;;
|
|
||||||
playerData.roundIndex = huntRoundIndex;
|
|
||||||
|
|
||||||
let playerShopRecord: ActivityTreasureHuntShopModelType = await ActivityTreasureHuntShopModel.findTreasureData(activityId, roleId, huntRoundIndex, playerData.todayIndex);
|
|
||||||
playerData.shop.setPlayerShopRecords(playerShopRecord);
|
|
||||||
return playerData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getPlayerTreasureHuntTaskData(activityId: number, serverId: number, roleId: string, huntRoundIndex: number, huntBeginTime: Date, huntEndTime: Date) {
|
export async function getPlayerTreasureHuntTaskData(activityId: number, serverId: number, roleId: string) {
|
||||||
let activityData: ActivityModelType = await getActivityById(activityId);
|
return await getPlayerTreasureHuntData(activityId, serverId, roleId, TREASURE_HUNT_DATA_TYPE.TREASURE_SHOP);
|
||||||
|
|
||||||
let createTime = await getRoleCreateTime(roleId);
|
|
||||||
let serverTime = await getServerCreateTime(serverId);
|
|
||||||
let playerData = new TreasureHuntData(activityData, createTime, serverTime);
|
|
||||||
playerData.beginTime = moment(huntBeginTime).valueOf();
|
|
||||||
playerData.endTime = moment(huntEndTime).valueOf();
|
|
||||||
playerData.todayIndex = deltaDays(moment(huntBeginTime).startOf('d').toDate(), new Date) + 1;;
|
|
||||||
playerData.roundIndex = huntRoundIndex;
|
|
||||||
|
|
||||||
let playerTaskRecord: ActivityTreasureHuntTaskModelType[] = await ActivityTreasureHuntTaskModel.findDataByRoundIndex(serverId, activityId, roleId, huntRoundIndex);
|
|
||||||
playerData.tasks.setPlayerTaskRecords(playerTaskRecord);
|
|
||||||
return playerData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getPlayerTreasureHuntChallengeData(activityId: number, serverId: number, roleId: string, huntRoundIndex: number, huntBeginTime: Date, huntEndTime: Date) {
|
export async function getPlayerTreasureHuntChallengeData(activityId: number, serverId: number, roleId: string) {
|
||||||
let activityData: ActivityModelType = await getActivityById(activityId);
|
return await getPlayerTreasureHuntData(activityId, serverId, roleId, TREASURE_HUNT_DATA_TYPE.CHALLENGE);
|
||||||
|
|
||||||
let createTime = await getRoleCreateTime(roleId);
|
|
||||||
let serverTime = await getServerCreateTime(serverId);
|
|
||||||
let playerData = new TreasureHuntData(activityData, createTime, serverTime);
|
|
||||||
playerData.beginTime = moment(huntBeginTime).valueOf();
|
|
||||||
playerData.endTime = moment(huntEndTime).valueOf();
|
|
||||||
playerData.todayIndex = deltaDays(moment(huntBeginTime).startOf('d').toDate(), new Date) + 1;;
|
|
||||||
playerData.roundIndex = huntRoundIndex;
|
|
||||||
|
|
||||||
let playerRecord = await ActivityTreasureHuntChallengeModel.findData(serverId, activityId, roleId, huntRoundIndex);
|
|
||||||
playerData.challenge.setChallengeRecord(playerRecord)
|
|
||||||
|
|
||||||
return playerData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getPlayerTreasureHuntTreasureShopData(activityId: number, serverId: number, roleId: string, huntRoundIndex: number, huntBeginTime: Date, huntEndTime: Date) {
|
export async function getPlayerTreasureHuntTreasureShopData(activityId: number, serverId: number, roleId: string) {
|
||||||
let activityData: ActivityModelType = await getActivityById(activityId);
|
return await getPlayerTreasureHuntData(activityId, serverId, roleId, TREASURE_HUNT_DATA_TYPE.TREASURE_SHOP);
|
||||||
|
|
||||||
let createTime = await getRoleCreateTime(roleId);
|
|
||||||
let serverTime = await getServerCreateTime(serverId);
|
|
||||||
let playerData = new TreasureHuntData(activityData, createTime, serverTime);
|
|
||||||
playerData.beginTime = moment(huntBeginTime).valueOf();
|
|
||||||
playerData.endTime = moment(huntEndTime).valueOf();
|
|
||||||
playerData.todayIndex = deltaDays(moment(huntBeginTime).startOf('d').toDate(), new Date) + 1;;
|
|
||||||
playerData.roundIndex = huntRoundIndex;
|
|
||||||
|
|
||||||
let playerTreasureShopRecord: ActivityTreasureHuntTreasureShopModelType = await ActivityTreasureHuntTreasureShopModel.findData(activityId, roleId, huntRoundIndex);
|
|
||||||
playerData.treasureShop.setPlayerTreasureShopRecords(playerTreasureShopRecord);
|
|
||||||
return playerData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取当前活动的周期等数据
|
|
||||||
export async function getTreasureHuntData(serverId: number, roleId: string) {
|
|
||||||
let tempData: ServerTempModelType = await ServerTempModel.findData(serverId);
|
|
||||||
let now = moment(new Date()).toDate();
|
|
||||||
let activityData: ActivityModelType = null; //当前活动数据
|
|
||||||
|
|
||||||
if (!tempData) {//开始新周期
|
|
||||||
let { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex } = await getNewActivityData(serverId, roleId);
|
|
||||||
if (huntActivityId === 0) {
|
|
||||||
return { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex, activityData }
|
|
||||||
}
|
|
||||||
tempData = await ServerTempModel.updateTreasureHuntData(serverId, huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex);
|
|
||||||
activityData = await getActivityById(huntActivityId);
|
|
||||||
return { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex, activityData }
|
|
||||||
}
|
|
||||||
if (now > tempData.huntEndTime) {//活动过期
|
|
||||||
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 }
|
|
||||||
}
|
|
||||||
tempData = await ServerTempModel.updateTreasureHuntData(serverId, huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex);
|
|
||||||
activityData = await getActivityById(huntActivityId);
|
|
||||||
return { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex, activityData }
|
|
||||||
}
|
|
||||||
if (!activityData) {
|
|
||||||
activityData = await getActivityById(tempData.huntActivityId);
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
huntActivityId: tempData.huntActivityId,
|
|
||||||
huntBeginTime: tempData.huntBeginTime,
|
|
||||||
huntEndTime: tempData.huntEndTime,
|
|
||||||
huntRoundIndex: tempData.huntRoundIndex,
|
|
||||||
activityData
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getNewActivityData(serverId: number, roleId: string) {
|
|
||||||
let huntActivityId: number = 0; // 寻宝骑兵-活动Id
|
|
||||||
let huntEndTime: Date = null; // 寻宝骑兵-结束时间
|
|
||||||
let huntRoundIndex: number = 0; // 寻宝骑兵-周期数
|
|
||||||
let activityArray = await getActivitiesByType(serverId, ACTIVITY_TYPE.TREASURE_HUNT);
|
|
||||||
let treasureHuntDataArray: TreasureHuntData[] = [];
|
|
||||||
let createTime = await getRoleCreateTime(roleId);
|
|
||||||
let serverTime = await getServerCreateTime(serverId);
|
|
||||||
for (let obj of activityArray) {
|
|
||||||
treasureHuntDataArray.push(new TreasureHuntData(obj, createTime, serverTime));
|
|
||||||
}
|
|
||||||
let isOver = false;
|
|
||||||
let huntBeginTime = moment(SERVER_OPEN_TIME).startOf('d').add(1, 'd').toDate();
|
|
||||||
let curDate = moment(new Date()).toDate()
|
|
||||||
while (!isOver) {
|
|
||||||
huntRoundIndex++;
|
|
||||||
for (let data of treasureHuntDataArray) {
|
|
||||||
let endTime = moment(huntBeginTime).add(data.day, 'd').toDate();
|
|
||||||
if (huntBeginTime < curDate && curDate < endTime) {
|
|
||||||
huntEndTime = moment(endTime).add(-1, 'm').toDate()
|
|
||||||
huntActivityId = data.activityId;
|
|
||||||
isOver = true;
|
|
||||||
} else {
|
|
||||||
huntBeginTime = endTime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (huntRoundIndex >= 365) {//max
|
|
||||||
isOver = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex }
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getNextActivityData(serverId: number, roleId: string, oldHuntActivityId: number, oldHuntEndTime: Date, oldHuntRoundIndex: number) {
|
|
||||||
let huntActivityId: number = 0; // 寻宝骑兵-活动Id
|
|
||||||
let huntEndTime: Date = null; // 寻宝骑兵-结束时间
|
|
||||||
let huntRoundIndex: number = oldHuntRoundIndex; // 寻宝骑兵-周期数
|
|
||||||
let activityArray = await getActivitiesByType(serverId, ACTIVITY_TYPE.TREASURE_HUNT);
|
|
||||||
let treasureHuntDataArray: TreasureHuntData[] = [];
|
|
||||||
let createTime = await getRoleCreateTime(roleId);
|
|
||||||
let serverTime = await getServerCreateTime(serverId);
|
|
||||||
for (let obj of activityArray) {
|
|
||||||
treasureHuntDataArray.push(new TreasureHuntData(obj, createTime, serverTime));
|
|
||||||
}
|
|
||||||
let isOver = false;
|
|
||||||
let huntBeginTime = moment(oldHuntEndTime).add(1, 'd').startOf('d').toDate();
|
|
||||||
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();
|
|
||||||
if (huntBeginTime < curDate && curDate < endTime) {
|
|
||||||
huntEndTime = moment(endTime).add(-1, 'm').toDate()
|
|
||||||
huntActivityId = data.activityId;
|
|
||||||
isOver = true;
|
|
||||||
} else {
|
|
||||||
huntBeginTime = endTime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!isOver) {
|
|
||||||
huntRoundIndex++;
|
|
||||||
for (let data of treasureHuntDataArray) {
|
|
||||||
let endTime = moment(huntBeginTime).add(data.day, 'd').toDate();
|
|
||||||
if (huntBeginTime < curDate && curDate < endTime) {
|
|
||||||
huntEndTime = moment(endTime).add(-1, 'm').toDate()
|
|
||||||
huntActivityId = data.activityId;
|
|
||||||
isOver = true;
|
|
||||||
} else {
|
|
||||||
huntBeginTime = endTime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (huntRoundIndex >= 365) {//max
|
|
||||||
isOver = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 购买每日物资
|
* 购买每日物资
|
||||||
*
|
*
|
||||||
@@ -329,14 +88,7 @@ async function getNextActivityData(serverId: number, roleId: string, oldHuntActi
|
|||||||
export async function makeShop(roleId: string, roleName: string, sid: string, serverId: number,
|
export async function makeShop(roleId: string, roleName: string, sid: string, serverId: number,
|
||||||
activityId: number, productID: string) {
|
activityId: number, productID: string) {
|
||||||
// let activityData: ActivityModelType = await ActivityModel.findActivity(activityId);
|
// let activityData: ActivityModelType = await ActivityModel.findActivity(activityId);
|
||||||
let { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex, activityData } = await getTreasureHuntData(serverId, roleId);
|
let playerData = await getPlayerTreasureHuntShopData(activityId, serverId, roleId,);
|
||||||
if (!activityData) {
|
|
||||||
return {
|
|
||||||
code: STATUS.ACTIVITY_MISSING,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let playerData = await getPlayerTreasureHuntShopData(activityId, serverId, roleId, huntRoundIndex, huntBeginTime, huntEndTime,);
|
|
||||||
if (!playerData) {
|
if (!playerData) {
|
||||||
return {
|
return {
|
||||||
code: STATUS.ACTIVITY_MISSING,
|
code: STATUS.ACTIVITY_MISSING,
|
||||||
@@ -358,7 +110,7 @@ export async function makeShop(roleId: string, roleName: string, sid: string, se
|
|||||||
let cellIndex = item.cellIndex;
|
let cellIndex = item.cellIndex;
|
||||||
|
|
||||||
//添加购买记录
|
//添加购买记录
|
||||||
await ActivityTreasureHuntShopModel.buyShopRecord(activityId, roleId, huntRoundIndex, playerData.todayIndex, cellIndex);
|
await ActivityTreasureHuntShopModel.buyShopRecord(activityId, roleId, playerData.roundIndex, playerData.todayIndex, cellIndex);
|
||||||
|
|
||||||
let rewardParamArr: Array<RewardParam> = stringToRewardParam(item.reward);
|
let rewardParamArr: Array<RewardParam> = stringToRewardParam(item.reward);
|
||||||
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr, ITEM_CHANGE_REASON.TREASURE_HUNT_SHOP_BUY)
|
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr, ITEM_CHANGE_REASON.TREASURE_HUNT_SHOP_BUY)
|
||||||
@@ -371,22 +123,22 @@ export async function makeShop(roleId: string, roleName: string, sid: string, se
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function treasureHuntChallengeConsume(serverId: number, roleId: string, sid: string) {
|
export async function treasureHuntChallengeConsume(serverId: number, roleId: string, sid: string) {
|
||||||
let { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex, activityData } = await getTreasureHuntData(serverId, roleId);
|
let activities = await getActivityByServerId(serverId);
|
||||||
if (!activityData) {
|
for(let { activityId } of activities) {
|
||||||
return false;
|
let playerData = await getPlayerTreasureHuntChallengeData(activityId, serverId, roleId,);
|
||||||
|
if (!playerData) return false;
|
||||||
|
|
||||||
|
if(playerData.canShow()) {
|
||||||
|
let challengeData = playerData.challenge;
|
||||||
|
//消耗资源
|
||||||
|
let consumeStr = challengeData.consume;
|
||||||
|
let consume = stringToConsumeParam(consumeStr)
|
||||||
|
let resourceResult = await handleCost(roleId, sid, consume, ITEM_CHANGE_REASON.TREASURE_HUNT_CHALLENGE);
|
||||||
|
if (!resourceResult) return false;
|
||||||
|
|
||||||
|
let warId = playerData.challenge.randomGK();
|
||||||
|
await ActivityTreasureHuntChallengeModel.setWarId(serverId, activityId, roleId, playerData.roundIndex, warId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let playerData = await getPlayerTreasureHuntChallengeData(huntActivityId, serverId, roleId, huntRoundIndex, huntBeginTime, huntEndTime,);
|
|
||||||
if (!playerData) return false;
|
|
||||||
|
|
||||||
let challengeData = playerData.challenge;
|
|
||||||
//消耗资源
|
|
||||||
let consumeStr = challengeData.consume;
|
|
||||||
let consume = stringToConsumeParam(consumeStr)
|
|
||||||
let resourceResult = await handleCost(roleId, sid, consume, ITEM_CHANGE_REASON.TREASURE_HUNT_CHALLENGE);
|
|
||||||
if (!resourceResult) return false;
|
|
||||||
|
|
||||||
let warId = playerData.challenge.randomGK();
|
|
||||||
await ActivityTreasureHuntChallengeModel.setWarId(serverId, huntActivityId, roleId, huntRoundIndex, warId);
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,6 @@ import { ActivityRefreshTaskModel } from "../../db/ActivityRefreshTask";
|
|||||||
import { ActivityThirtyDaysModel } from "../../db/ActivityThirtyDays";
|
import { ActivityThirtyDaysModel } from "../../db/ActivityThirtyDays";
|
||||||
import { ActivityTreasureHuntTaskModel } from "../../db/ActivityTreasureHuntTask";
|
import { ActivityTreasureHuntTaskModel } from "../../db/ActivityTreasureHuntTask";
|
||||||
import { RoleModel, RoleType } from "../../db/Role";
|
import { RoleModel, RoleType } from "../../db/Role";
|
||||||
import { ServerTempModel, ServerTempModelType } from "../../db/ServerTemp";
|
|
||||||
import { UserTaskRecModel } from "../../db/UserTaskRec";
|
import { UserTaskRecModel } from "../../db/UserTaskRec";
|
||||||
import { GrowthFundData } from "../../domain/activityField/growthFundField";
|
import { GrowthFundData } from "../../domain/activityField/growthFundField";
|
||||||
import { RefreshTaskData } from "../../domain/activityField/refreshTaskField";
|
import { RefreshTaskData } from "../../domain/activityField/refreshTaskField";
|
||||||
@@ -36,7 +35,6 @@ export class CheckTask {
|
|||||||
taskPushMessages: TaskListReturn[] = [];
|
taskPushMessages: TaskListReturn[] = [];
|
||||||
activityTaskPushMessages = [];
|
activityTaskPushMessages = [];
|
||||||
|
|
||||||
treasureHuntTemp: ServerTempModelType;
|
|
||||||
tasks: CheckSingleTask[] = [];
|
tasks: CheckSingleTask[] = [];
|
||||||
|
|
||||||
constructor(serverId: number, roleId: string) {
|
constructor(serverId: number, roleId: string) {
|
||||||
@@ -86,19 +84,6 @@ export class CheckTask {
|
|||||||
return this.roleCreateTime;
|
return this.roleCreateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 神州探秘活动
|
|
||||||
async getTreasureHuntTemp() {
|
|
||||||
if(this.treasureHuntTemp) return this.treasureHuntTemp;
|
|
||||||
|
|
||||||
let tempData: ServerTempModelType = await ServerTempModel.findData(this.serverId);
|
|
||||||
if (tempData) {
|
|
||||||
this.treasureHuntTemp = tempData;
|
|
||||||
return tempData
|
|
||||||
} else {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 推送
|
// 推送
|
||||||
public async pushMessage(sid?: string) {
|
public async pushMessage(sid?: string) {
|
||||||
let roleId = this.roleId;
|
let roleId = this.roleId;
|
||||||
@@ -259,20 +244,17 @@ export class CheckSingleTask {
|
|||||||
case ACTIVITY_TYPE.TREASURE_HUNT:
|
case ACTIVITY_TYPE.TREASURE_HUNT:
|
||||||
{
|
{
|
||||||
// 寻宝奇兵任务
|
// 寻宝奇兵任务
|
||||||
let tempData = await this.parent.getTreasureHuntTemp();
|
let playerData = new TreasureHuntData(activity, roleCreateTime, serverCreateTime);
|
||||||
if(tempData && tempData.huntActivityId == activityId) {
|
let taskArray = playerData.tasks.findItemByTaskType(taskType);
|
||||||
let playerData = new TreasureHuntData(activity, roleCreateTime, serverCreateTime);
|
for (let task of taskArray) {
|
||||||
let taskArray = playerData.tasks.findItemByTaskType(taskType);
|
let taskUpdateParam = await this.checkIsMatch(task.taskParamArray, async () => {
|
||||||
for (let task of taskArray) {
|
let data = await ActivityTreasureHuntTaskModel.findDataByCellIndex(serverId, activityId, roleId, playerData.roundIndex, task.cellIndex);
|
||||||
let taskUpdateParam = await this.checkIsMatch(task.taskParamArray, async () => {
|
return data?.records ?? [];
|
||||||
let data = await ActivityTreasureHuntTaskModel.findDataByCellIndex(serverId, activityId, roleId, tempData.huntRoundIndex, task.cellIndex);
|
});
|
||||||
return data?.records ?? [];
|
if(taskUpdateParam) {
|
||||||
});
|
let rec = await ActivityTreasureHuntTaskModel.setOrIncTask(serverId, activityId, roleId, playerData.roundIndex, task.cellIndex, taskType, taskUpdateParam);
|
||||||
if(taskUpdateParam) {
|
if(!rec) continue;
|
||||||
let rec = await ActivityTreasureHuntTaskModel.setOrIncTask(serverId, activityId, roleId, tempData.huntRoundIndex, task.cellIndex, taskType, taskUpdateParam);
|
this.addActivityTaskPushMessage({ ...task, totalCount: rec.totalCount, activityId });
|
||||||
if(!rec) continue;
|
|
||||||
this.addActivityTaskPushMessage({ ...task, totalCount: rec.totalCount, activityId });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -192,3 +192,12 @@ export enum POP_UP_SHOP_REFRESH_TIME_TYPE {
|
|||||||
NATURAL_MONTH = 3, // 自然月
|
NATURAL_MONTH = 3, // 自然月
|
||||||
DAYS = 4, // 从beginTime开始固定日
|
DAYS = 4, // 从beginTime开始固定日
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum TREASURE_HUNT_DATA_TYPE {
|
||||||
|
ALL = 0, // 所有
|
||||||
|
FIRST_PAGE = 1,
|
||||||
|
SHOP = 2,
|
||||||
|
TASK = 3,
|
||||||
|
CHALLENGE = 4,
|
||||||
|
TREASURE_SHOP = 5,
|
||||||
|
}
|
||||||
@@ -10,40 +10,17 @@ export default class ServerTemp extends BaseModel {
|
|||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
serverId: number; // 服Id
|
serverId: number; // 服Id
|
||||||
|
|
||||||
@prop({ required: true })
|
|
||||||
huntActivityId: number; // 寻宝骑兵-活动Id
|
|
||||||
@prop({ required: true })
|
|
||||||
huntBeginTime: Date; // 寻宝骑兵-开启时间
|
|
||||||
@prop({ required: true })
|
|
||||||
huntEndTime: Date; // 寻宝骑兵-结束时间
|
|
||||||
@prop({ required: true })
|
|
||||||
huntRoundIndex: number; // 寻宝骑兵-周期数
|
|
||||||
|
|
||||||
|
|
||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
getuiToken: string; // 个推token
|
getuiToken: string; // 个推token
|
||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
getuiTokenExpireTime: number; // 个推token过期时间
|
getuiTokenExpireTime: number; // 个推token过期时间
|
||||||
|
|
||||||
//更新寻宝猎人活动数据
|
|
||||||
public static async updateTreasureHuntData(serverId: number, huntActivityId: number, huntBeginTime: Date, huntEndTime: Date, huntRoundIndex: number) {
|
|
||||||
let result: ServerTempModelType = await ServerTempModel.findOneAndUpdate({ serverId },
|
|
||||||
{ $set: { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex } }, { upsert: true, new: true }).lean(true);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//查询当前服务器的数据
|
//查询当前服务器的数据
|
||||||
public static async findData(serverId: number) {
|
public static async findData(serverId: number) {
|
||||||
let result: ServerTempModelType = await ServerTempModel.findOne({ serverId }).lean(true);
|
let result: ServerTempModelType = await ServerTempModel.findOne({ serverId }).lean(true);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//删除活动
|
|
||||||
public static async deleteActivity(serverId: number) {
|
|
||||||
let result = await ServerTempModel.deleteMany({ serverId });
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//更新个推token数据
|
//更新个推token数据
|
||||||
public static async updateGetuiData(getuiToken: string, getuiTokenExpireTime: number) {
|
public static async updateGetuiData(getuiToken: string, getuiTokenExpireTime: number) {
|
||||||
let result: ServerTempModelType = await ServerTempModel.findOneAndUpdate({ serverId: 0 },
|
let result: ServerTempModelType = await ServerTempModel.findOneAndUpdate({ serverId: 0 },
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { random } from 'underscore';
|
import { pick, random } from 'underscore';
|
||||||
import { ActivityModelType } from '../../db/Activity';
|
import { ActivityModelType } from '../../db/Activity';
|
||||||
import { ActivityTreasureHuntShopModelType } from '../../db/ActivityTreasureHuntShop';
|
import { ActivityTreasureHuntShopModelType } from '../../db/ActivityTreasureHuntShop';
|
||||||
import { ActivityTreasureHuntTaskModelType } from '../../db/ActivityTreasureHuntTask';
|
import { ActivityTreasureHuntTaskModelType } from '../../db/ActivityTreasureHuntTask';
|
||||||
@@ -7,46 +7,125 @@ import { ActivityTreasureHuntFirstPageModelType } from '../../db/ActivityTreasur
|
|||||||
import { parseNumberList, splitString } from '../../pubUtils/util';
|
import { parseNumberList, splitString } from '../../pubUtils/util';
|
||||||
import { ActivityBase } from './activityField';
|
import { ActivityBase } from './activityField';
|
||||||
import { ActivityTreasureHuntChallengeModelTypeParam } from '../../db/ActivityTreasureHuntChallenge';
|
import { ActivityTreasureHuntChallengeModelTypeParam } from '../../db/ActivityTreasureHuntChallenge';
|
||||||
|
import { TREASURE_HUNT_DATA_TYPE } from '../../consts';
|
||||||
|
|
||||||
|
// 首页
|
||||||
|
interface TreasureHuntFirstPageInDb {
|
||||||
|
index: TREASURE_HUNT_DATA_TYPE.FIRST_PAGE;
|
||||||
|
name: string; // 页签名
|
||||||
|
reward: string; // 奖励
|
||||||
|
imageName: string; // 图片
|
||||||
|
}
|
||||||
|
|
||||||
|
// 商店
|
||||||
|
interface TreasureHuntShopItemConsumeInDb {
|
||||||
|
count: number, // 第几次
|
||||||
|
consume: string, // 消耗 type&id&count
|
||||||
|
discount: number, // 折扣
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TreasureHuntShopItemInDb {
|
||||||
|
cellIndex: number; // 第几项
|
||||||
|
name: string; // 礼包名
|
||||||
|
productID: string; // 商品id
|
||||||
|
price: number; // 价格
|
||||||
|
countMax: number; // 限购数量
|
||||||
|
discount: number; // 折扣
|
||||||
|
reward: string; // 奖励
|
||||||
|
imageName: string; // 图片
|
||||||
|
data: TreasureHuntShopItemConsumeInDb[]; // 消耗
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TreasureHuntShopInDb {
|
||||||
|
index: TREASURE_HUNT_DATA_TYPE.SHOP; // 2. 每日物资,即商店
|
||||||
|
name: string; // 页签名
|
||||||
|
data: TreasureHuntShopItemInDb[];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 任务
|
||||||
|
interface TreasureHuntTaskItemInDb {
|
||||||
|
cellIndex: number; // 第几项
|
||||||
|
name: string; // 任务名
|
||||||
|
taskType: number; // 任务类型
|
||||||
|
taskParam: string; // 任务参数
|
||||||
|
condition: number; // 条件
|
||||||
|
reward: string; // 奖励 type&id&count
|
||||||
|
fragment: number; // 前端显示 碎片数量
|
||||||
|
skip: string; // 前端用 跳转
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TreasureHuntTaskInDb {
|
||||||
|
index: TREASURE_HUNT_DATA_TYPE.TASK; // 3. 任务
|
||||||
|
name: string; // 页签名
|
||||||
|
reward: string; // 奖励 type&id&count
|
||||||
|
data: TreasureHuntTaskItemInDb[]; // 任务
|
||||||
|
}
|
||||||
|
|
||||||
|
// 关卡
|
||||||
|
interface TreasureHuntChallengeInDb {
|
||||||
|
index: TREASURE_HUNT_DATA_TYPE.CHALLENGE; // 4. 关卡
|
||||||
|
name: string; // 页签名
|
||||||
|
consume: string; // 消耗
|
||||||
|
warid: string; // 关卡
|
||||||
|
fixReward: string; // 奖励 type&id&count
|
||||||
|
jackpotReward: string; // 随机奖励
|
||||||
|
imageName: string; // 图标
|
||||||
|
}
|
||||||
|
|
||||||
|
// 高级商店
|
||||||
|
interface TreasureHuntTreasureShopItemInDb {
|
||||||
|
cellIndex: number; // 第几项
|
||||||
|
name: string; // 礼包名
|
||||||
|
reward: string; // 奖励
|
||||||
|
countMax: number; // 限购数量
|
||||||
|
imageName: string; // 图片
|
||||||
|
consume: string; // 消耗
|
||||||
|
}
|
||||||
|
interface TreasureHuntTreasureShopInDb {
|
||||||
|
index: TREASURE_HUNT_DATA_TYPE.TREASURE_SHOP; // 4. 关卡
|
||||||
|
name: string; // 页签名
|
||||||
|
data: TreasureHuntTreasureShopItemInDb[]; // 消耗
|
||||||
|
}
|
||||||
|
interface TreasureHuntInDb {
|
||||||
|
data: (TreasureHuntFirstPageInDb|TreasureHuntShopInDb|TreasureHuntTaskInDb|TreasureHuntChallengeInDb|TreasureHuntTreasureShopInDb)[];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************/
|
||||||
|
// 操作数据
|
||||||
// 进入活动首页的数据
|
// 进入活动首页的数据
|
||||||
export class TreasureHuntFirstPageData {
|
export class TreasureHuntFirstPageData {
|
||||||
name: string = '';//页签名字
|
index: number; //下标
|
||||||
index: number = 0;//下标
|
name: string; //页签名字
|
||||||
reward: string = '';//奖励
|
reward: string; //奖励
|
||||||
imageName: string = '';
|
imageName: string;
|
||||||
|
|
||||||
isReceive: boolean = false;//是否领取
|
isReceive: boolean = false;//是否领取
|
||||||
|
|
||||||
public setPlayerFirstPageRecord(record: ActivityTreasureHuntFirstPageModelType) {
|
constructor(data: TreasureHuntFirstPageInDb) {
|
||||||
this.isReceive = false;
|
this.initData(data)
|
||||||
if (!record) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.isReceive = record.isReceive ? record.isReceive : false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public initData(data: any) {
|
public initData(data: TreasureHuntFirstPageInDb) {
|
||||||
this.name = data.name;
|
this.name = data.name;
|
||||||
this.index = data.index;
|
this.index = data.index;
|
||||||
this.reward = data.reward;
|
this.reward = data.reward;
|
||||||
this.imageName = data.imageName;
|
this.imageName = data.imageName;
|
||||||
this.isReceive = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(data: any) {
|
public setPlayerFirstPageRecord(record: ActivityTreasureHuntFirstPageModelType) {
|
||||||
this.initData(data)
|
if (!record) return;
|
||||||
|
this.isReceive = !!record.isReceive;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************/
|
|
||||||
//购买价格
|
//购买价格
|
||||||
export class ConsumeData {
|
export class ConsumeData {
|
||||||
count: number; // 第几次购买,1开始
|
count: number; // 第几次购买,1开始
|
||||||
consume: string; //消耗资源 "2&31002&400"
|
consume: string; //消耗资源 "2&31002&400"
|
||||||
discount: number; // 折扣
|
discount: number; // 折扣
|
||||||
|
|
||||||
constructor(data: any) {
|
constructor(data: TreasureHuntShopItemConsumeInDb) {
|
||||||
this.count = data.count;
|
this.count = data.count;
|
||||||
this.consume = data.consume;
|
this.consume = data.consume;
|
||||||
this.discount = data.discount;
|
this.discount = data.discount;
|
||||||
@@ -63,11 +142,11 @@ export class TreasureHuntShopItem {
|
|||||||
countMax: number; //最大购买次数
|
countMax: number; //最大购买次数
|
||||||
discount: number; //折扣
|
discount: number; //折扣
|
||||||
imageName: string;
|
imageName: string;
|
||||||
consume: ConsumeData[]; //每次购买价格不同
|
consume: ConsumeData[] = []; //每次购买价格不同
|
||||||
|
|
||||||
buyCount: number = 0; //购买过的次数
|
buyCount: number = 0; //购买过的次数
|
||||||
|
|
||||||
constructor(data: any) {
|
constructor(data: TreasureHuntShopItemInDb) {
|
||||||
this.cellIndex = data.cellIndex;
|
this.cellIndex = data.cellIndex;
|
||||||
this.name = data.name;
|
this.name = data.name;
|
||||||
this.price = data.price;
|
this.price = data.price;
|
||||||
@@ -76,24 +155,41 @@ export class TreasureHuntShopItem {
|
|||||||
this.countMax = data.countMax;
|
this.countMax = data.countMax;
|
||||||
this.discount = data.discount;
|
this.discount = data.discount;
|
||||||
this.imageName = data.imageName;
|
this.imageName = data.imageName;
|
||||||
this.consume = [];
|
|
||||||
for (let obj of data.data) {
|
for (let obj of data.data) {
|
||||||
this.consume.push(new ConsumeData(obj))
|
this.consume.push(new ConsumeData(obj))
|
||||||
}
|
}
|
||||||
this.buyCount = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getConsume() {
|
public getConsume() {
|
||||||
let index = this.consume.findIndex(obj => { return obj && obj.count === this.buyCount + 1 });
|
let index = this.consume.findIndex(obj => { return obj && obj.count === this.buyCount + 1 });
|
||||||
return (index != -1) ? this.consume[index].consume : '';
|
return (index != -1) ? this.consume[index].consume : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setBuyCount(record: ActivityTreasureHuntShopModelType) {
|
||||||
|
if (!record) return;
|
||||||
|
let buyRecords = record.records.filter(obj => { return obj.id === this.cellIndex });
|
||||||
|
this.buyCount = buyRecords.length;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 商店数据
|
// 商店数据
|
||||||
export class TreasureHuntShopData {
|
export class TreasureHuntShopData {
|
||||||
index: number = 0;//下标
|
index: number; //下标
|
||||||
name: string = '';//页签名字
|
name: string; //页签名字
|
||||||
list: Array<TreasureHuntShopItem> = [];//商品
|
list: TreasureHuntShopItem[] = [];//商品
|
||||||
|
|
||||||
|
constructor(data: TreasureHuntShopInDb) {
|
||||||
|
this.initData(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
public initData(data: TreasureHuntShopInDb) {
|
||||||
|
this.index = data.index;
|
||||||
|
this.name = data.name;
|
||||||
|
let arr = data.data;
|
||||||
|
for (let obj of arr) {
|
||||||
|
this.list.push(new TreasureHuntShopItem(obj))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public findProductID(productID: string): TreasureHuntShopItem {
|
public findProductID(productID: string): TreasureHuntShopItem {
|
||||||
let index = this.list.findIndex(obj => { return obj && obj.productID === productID })
|
let index = this.list.findIndex(obj => { return obj && obj.productID === productID })
|
||||||
@@ -110,24 +206,9 @@ export class TreasureHuntShopData {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (let item of this.list) {
|
for (let item of this.list) {
|
||||||
let buyRecords = record.records.filter(obj => { return obj.id === item.cellIndex });
|
item.setBuyCount(record);
|
||||||
item.buyCount = buyRecords.length;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public initData(data: any) {
|
|
||||||
this.index = data.index;
|
|
||||||
this.name = data.name;
|
|
||||||
let arr = data.data;
|
|
||||||
for (let obj of arr) {
|
|
||||||
this.list.push(new TreasureHuntShopItem(obj))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(data: any) {
|
|
||||||
this.initData(data)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
@@ -143,45 +224,63 @@ export class TreasureHuntTaskItem {
|
|||||||
fragment: number; //碎片
|
fragment: number; //碎片
|
||||||
skip: string;
|
skip: string;
|
||||||
|
|
||||||
taskParamArray: number[]; // 任务参数
|
taskParamArray: number[] = []; // 任务参数
|
||||||
totalCount: number = 0; //任务统计
|
totalCount: number = 0; //任务统计
|
||||||
isReceive: boolean = false; //是否领取奖励
|
isReceive: boolean = false; //是否领取奖励
|
||||||
|
|
||||||
constructor(data: any) {
|
constructor(data: TreasureHuntTaskItemInDb) {
|
||||||
this.cellIndex = data.cellIndex;
|
this.cellIndex = data.cellIndex;
|
||||||
this.name = data.name;
|
this.name = data.name;
|
||||||
this.taskType = data.taskType;
|
this.taskType = data.taskType;
|
||||||
this.taskParam = data.taskParam;
|
this.taskParam = data.taskParam;
|
||||||
this.taskParamArray = parseNumberList(data.taskParamArray);
|
this.taskParamArray = parseNumberList(data.taskParam);
|
||||||
this.condition = data.condition;
|
this.condition = data.condition;
|
||||||
this.reward = data.reward;
|
this.reward = data.reward;
|
||||||
this.fragment = data.fragment;
|
this.fragment = data.fragment;
|
||||||
this.skip = data.skip;
|
this.skip = data.skip;
|
||||||
this.totalCount = 0;
|
}
|
||||||
this.isReceive = false;
|
|
||||||
|
setPlayerRecord(record: ActivityTreasureHuntTaskModelType) {
|
||||||
|
if(!record) return;
|
||||||
|
this.totalCount = record.totalCount||0;
|
||||||
|
this.isReceive = record.receiveRewardCount ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getShowResult() {
|
||||||
|
return pick(this, ['cellIndex', 'name', 'taskType', 'condition', 'reward', 'fragment', 'skip', 'totalCount', 'isReceive'])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 寻宝备战数据
|
// 寻宝备战数据
|
||||||
export class TreasureHuntTaskData {
|
export class TreasureHuntTaskData {
|
||||||
name: string = '';//页签名字
|
name: string; //页签名字
|
||||||
index: number = 0;//下标
|
index: number; //下标
|
||||||
reward: string = '';//奖励
|
reward: string; //奖励
|
||||||
fragment: number = 0;//碎片需求量
|
list: TreasureHuntTaskItem[] = [];//任务
|
||||||
list: Array<TreasureHuntTaskItem> = [];//任务
|
|
||||||
|
constructor(data: TreasureHuntTaskInDb) {
|
||||||
|
this.initData(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
public initData(data: TreasureHuntTaskInDb) {
|
||||||
|
this.name = data.name;
|
||||||
|
this.index = data.index;
|
||||||
|
this.reward = data.reward;
|
||||||
|
let arr = data.data||[];
|
||||||
|
for (let obj of arr) {
|
||||||
|
this.list.push(new TreasureHuntTaskItem(obj))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public getItem(cellIndex: number): TreasureHuntTaskItem {
|
public getItem(cellIndex: number): TreasureHuntTaskItem {
|
||||||
let index = this.list.findIndex(obj => { return obj && obj.cellIndex === cellIndex });
|
let index = this.list.findIndex(obj => { return obj && obj.cellIndex === cellIndex });
|
||||||
return (index != -1) ? this.list[index] : null
|
return (index != -1) ? this.list[index] : null
|
||||||
}
|
}
|
||||||
|
|
||||||
public setPlayerTaskRecords(record: ActivityTreasureHuntTaskModelType[]) {
|
public setPlayerTaskRecords(records: ActivityTreasureHuntTaskModelType[]) {
|
||||||
for (let item of this.list) {
|
for(let record of records) {
|
||||||
let index = record.findIndex(obj => { return obj.cellIndex === item.cellIndex });
|
let item = this.getItem(record.cellIndex);
|
||||||
if (index != -1) {
|
if(item) item.setPlayerRecord(record);
|
||||||
item.totalCount = record[index].totalCount ? record[index].totalCount : 0;
|
|
||||||
item.isReceive = record[index].receiveRewardCount ? true : false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,43 +288,32 @@ export class TreasureHuntTaskData {
|
|||||||
return this.list.filter(obj => { return obj && obj.taskType === type });
|
return this.list.filter(obj => { return obj && obj.taskType === type });
|
||||||
}
|
}
|
||||||
|
|
||||||
public initData(data: any) {
|
public getShowResult() {
|
||||||
this.name = data.name;
|
return {
|
||||||
this.index = data.index;
|
...this, list: this.list.map(item => item.getShowResult())
|
||||||
this.reward = data.reward;
|
|
||||||
this.fragment = data.fragment;
|
|
||||||
let arr = data.data;
|
|
||||||
for (let obj of arr) {
|
|
||||||
this.list.push(new TreasureHuntTaskItem(obj))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(data: any) {
|
|
||||||
this.initData(data)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
|
|
||||||
// 寻宝大冒险的数据
|
// 寻宝大冒险的数据
|
||||||
export class TreasureHuntChallengeData {
|
export class TreasureHuntChallengeData {
|
||||||
name: string = '';//页签名字
|
name: string; // 页签名字
|
||||||
index: number = 0;//下标
|
index: number; // 下标
|
||||||
consume: string = '';//消耗
|
consume: string; // 消耗
|
||||||
warid: string = '';//随机的关卡号
|
warid: string; // 随机的关卡号
|
||||||
fixReward: string = '';//客户端显示奖励
|
fixReward: string; // 客户端显示奖励
|
||||||
jackpotReward: string = '';//客户端显示奖励
|
jackpotReward: string;// 客户端显示奖励
|
||||||
imageName: string = '';
|
imageName: string;
|
||||||
|
|
||||||
resultWarId: number = 0; // 玩家随机出的关卡id
|
resultWarId: number = 0; // 玩家随机出的关卡id
|
||||||
|
|
||||||
public randomGK() {
|
constructor(data: TreasureHuntChallengeInDb) {
|
||||||
let gkArray = splitString(this.warid, '&');
|
this.initData(data)
|
||||||
let index = random(gkArray.length - 1);
|
|
||||||
return gkArray[index];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public initData(data: any) {
|
public initData(data: TreasureHuntChallengeInDb) {
|
||||||
this.name = data.name;
|
this.name = data.name;
|
||||||
this.index = data.index;
|
this.index = data.index;
|
||||||
this.consume = data.consume;
|
this.consume = data.consume;
|
||||||
@@ -235,15 +323,17 @@ export class TreasureHuntChallengeData {
|
|||||||
this.imageName = data.imageName;
|
this.imageName = data.imageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public randomGK() {
|
||||||
|
let gkArray = splitString(this.warid, '&');
|
||||||
|
let index = random(gkArray.length - 1);
|
||||||
|
return gkArray[index];
|
||||||
|
}
|
||||||
|
|
||||||
public setChallengeRecord(record: ActivityTreasureHuntChallengeModelTypeParam) {
|
public setChallengeRecord(record: ActivityTreasureHuntChallengeModelTypeParam) {
|
||||||
if(record) {
|
if(record) {
|
||||||
this.resultWarId = record.warId;
|
this.resultWarId = record.warId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(data: any) {
|
|
||||||
this.initData(data)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -252,31 +342,48 @@ export class TreasureHuntChallengeData {
|
|||||||
//天子宝库
|
//天子宝库
|
||||||
// 商品的数据
|
// 商品的数据
|
||||||
export class TreasureHuntTreasureShopItem {
|
export class TreasureHuntTreasureShopItem {
|
||||||
cellIndex: number; // 第几个,从1开始
|
cellIndex: number; // 第几个,从1开始
|
||||||
name: string; //名称
|
name: string; //名称
|
||||||
reward: string; //奖励
|
reward: string; //奖励
|
||||||
countMax: number; //最大购买次数
|
countMax: number; //最大购买次数
|
||||||
imageName: string;
|
imageName: string;
|
||||||
consume: ""; //购买价格
|
consume: string; //购买价格
|
||||||
|
|
||||||
buyCount: number = 0; //购买过的次数
|
buyCount: number = 0; //购买过的次数
|
||||||
|
|
||||||
constructor(data: any) {
|
constructor(data: TreasureHuntTreasureShopItemInDb) {
|
||||||
this.cellIndex = data.cellIndex;
|
this.cellIndex = data.cellIndex;
|
||||||
this.name = data.name;
|
this.name = data.name;
|
||||||
this.reward = data.reward;
|
this.reward = data.reward;
|
||||||
this.countMax = data.countMax;
|
this.countMax = data.countMax;
|
||||||
this.imageName = data.imageName;
|
this.imageName = data.imageName;
|
||||||
this.consume = data.consume;
|
this.consume = data.consume;
|
||||||
this.buyCount = 0;
|
}
|
||||||
|
|
||||||
|
setPlayerRecord(record: ActivityTreasureHuntTreasureShopModelType) {
|
||||||
|
let buyRecords = record.records.filter(obj => { return obj.id === this.cellIndex });
|
||||||
|
this.buyCount = buyRecords.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 天子宝库商店数据
|
// 天子宝库商店数据
|
||||||
export class TreasureHuntTreasureShopData {
|
export class TreasureHuntTreasureShopData {
|
||||||
index: number = 0;//下标
|
index: number;//下标
|
||||||
name: string = '';//页签名字
|
name: string;//页签名字
|
||||||
list: Array<TreasureHuntTreasureShopItem> = [];//商品
|
list: TreasureHuntTreasureShopItem[] = [];//商品
|
||||||
|
|
||||||
|
constructor(data: TreasureHuntTreasureShopInDb) {
|
||||||
|
this.initData(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
public initData(data: TreasureHuntTreasureShopInDb) {
|
||||||
|
this.index = data.index;
|
||||||
|
this.name = data.name;
|
||||||
|
let arr = data.data||[];
|
||||||
|
for (let obj of arr) {
|
||||||
|
this.list.push(new TreasureHuntTreasureShopItem(obj))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public getItem(cellIndex: number): TreasureHuntTreasureShopItem {
|
public getItem(cellIndex: number): TreasureHuntTreasureShopItem {
|
||||||
let index = this.list.findIndex(obj => { return obj && obj.cellIndex === cellIndex })
|
let index = this.list.findIndex(obj => { return obj && obj.cellIndex === cellIndex })
|
||||||
@@ -288,70 +395,51 @@ export class TreasureHuntTreasureShopData {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (let item of this.list) {
|
for (let item of this.list) {
|
||||||
let buyRecords = record.records.filter(obj => { return obj.id === item.cellIndex });
|
item.setPlayerRecord(record);
|
||||||
item.buyCount = buyRecords.length;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public initData(data: any) {
|
|
||||||
this.index = data.index;
|
|
||||||
this.name = data.name;
|
|
||||||
let arr = data.data;
|
|
||||||
for (let obj of arr) {
|
|
||||||
this.list.push(new TreasureHuntTreasureShopItem(obj))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(data: any) {
|
|
||||||
this.initData(data)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
|
|
||||||
// 寻宝骑兵活动数据
|
// 寻宝骑兵活动数据
|
||||||
export class TreasureHuntData extends ActivityBase {
|
export class TreasureHuntData extends ActivityBase {
|
||||||
name: string = '';//活动名字
|
|
||||||
day: string = '';//活动持续时间
|
|
||||||
// roundIndex = 0;//周期数
|
|
||||||
firstPage: TreasureHuntFirstPageData = null;//首页奖励
|
firstPage: TreasureHuntFirstPageData = null;//首页奖励
|
||||||
shop: TreasureHuntShopData = null; //每日物资
|
shop: TreasureHuntShopData = null; //每日物资
|
||||||
tasks: TreasureHuntTaskData = null; //寻宝备战
|
tasks: TreasureHuntTaskData = null; //寻宝备战
|
||||||
challenge: TreasureHuntChallengeData = null;//寻宝大冒险
|
challenge: TreasureHuntChallengeData = null;//寻宝大冒险
|
||||||
treasureShop: TreasureHuntTreasureShopData = null; //天子宝库(商店)
|
treasureShop: TreasureHuntTreasureShopData = null; //天子宝库(商店)
|
||||||
|
|
||||||
|
|
||||||
public initData(data: any) {
|
|
||||||
let dataObj = JSON.parse(data);
|
|
||||||
this.name = dataObj.name;
|
|
||||||
this.day = dataObj.day;
|
|
||||||
|
|
||||||
let arr = dataObj.data;
|
|
||||||
{
|
|
||||||
let index = arr.findIndex(obj => { return obj.index === 1 });
|
|
||||||
this.firstPage = new TreasureHuntFirstPageData(arr[index]);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
let index = arr.findIndex(obj => { return obj.index === 2 });
|
|
||||||
this.shop = new TreasureHuntShopData(arr[index]);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
let index = arr.findIndex(obj => { return obj.index === 3 });
|
|
||||||
this.tasks = new TreasureHuntTaskData(arr[index]);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
let index = arr.findIndex(obj => { return obj.index === 4 });
|
|
||||||
this.challenge = new TreasureHuntChallengeData(arr[index]);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
let index = arr.findIndex(obj => { return obj.index === 5 });
|
|
||||||
this.treasureShop = new TreasureHuntTreasureShopData(arr[index]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(activityData: ActivityModelType, createTime: number, sererTime: number) {
|
constructor(activityData: ActivityModelType, createTime: number, sererTime: number) {
|
||||||
super(activityData, createTime, sererTime);
|
super(activityData, createTime, sererTime);
|
||||||
this.initData(activityData.data)
|
this.initData(activityData.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public initData(data: string) {
|
||||||
|
let dataObj: TreasureHuntInDb = JSON.parse(data);
|
||||||
|
|
||||||
|
let arr = dataObj.data||[];
|
||||||
|
arr.forEach(data => {
|
||||||
|
switch(data.index) {
|
||||||
|
case 1:
|
||||||
|
this.firstPage = new TreasureHuntFirstPageData(data); break;
|
||||||
|
case 2:
|
||||||
|
this.shop = new TreasureHuntShopData(data); break;
|
||||||
|
case 3:
|
||||||
|
this.tasks = new TreasureHuntTaskData(data); break;
|
||||||
|
case 4:
|
||||||
|
this.challenge = new TreasureHuntChallengeData(data); break;
|
||||||
|
case 5:
|
||||||
|
this.treasureShop = new TreasureHuntTreasureShopData(data); break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public getShowResult() {
|
||||||
|
return {
|
||||||
|
...this,
|
||||||
|
tasks: this.tasks.getShowResult()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ export default class Sdk extends Service {
|
|||||||
return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.ROLE_NOT_FOUND, '');
|
return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.ROLE_NOT_FOUND, '');
|
||||||
}
|
}
|
||||||
ctx.service.utils.log('DEBUG', `[${ctx.request.url}] [${ctx.logcode}] pay37Callback check role ok`);
|
ctx.service.utils.log('DEBUG', `[${ctx.request.url}] [${ctx.logcode}] pay37Callback check role ok`);
|
||||||
if(role.serverId != params.sid) {
|
if(role.serverId != parseInt(`${params.sid}`)) {
|
||||||
return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.SERVER_NOT_FOUND, '');
|
return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.SERVER_NOT_FOUND, '');
|
||||||
}
|
}
|
||||||
ctx.service.utils.log('DEBUG', `[${ctx.request.url}] [${ctx.logcode}] pay37Callback check server ok`);
|
ctx.service.utils.log('DEBUG', `[${ctx.request.url}] [${ctx.logcode}] pay37Callback check server ok`);
|
||||||
|
|||||||
Reference in New Issue
Block a user