活动:糜家商队
This commit is contained in:
@@ -4,10 +4,12 @@ import { STATUS, ACTIVITY_RESOURCES_TYPE, ACTIVITY_TYPE, CURRENCY_BY_TYPE, CURRE
|
||||
import { SelfServiceShopData, SelfServiceShopItem, SelfServiceShopItemInfo } from '../../../domain/activityField/selfServiceShopField';
|
||||
import { addItems, handleCost } from '../../../services/rewardService';
|
||||
import { ActivitySelfServiceShopModel, ActivitySelfServiceShopModelType } from '../../../db/ActivitySelfServiceShop';
|
||||
import { ActivitySelfServiceModel, ActivitySelfServiceModelType } from '../../../db/ActivitySelfService';
|
||||
import { ActivitySelfServiceGoodsModel, ActivitySelfServiceGoodsModelType } from '../../../db/ActivitySelfServiceGoods';
|
||||
import moment = require('moment');
|
||||
import Activity, { ActivityModel, ActivityModelType } from '../../../db/Activity';
|
||||
import { addSelfServiceShopGiftReward, getActivityData, getPlayerActivityData } from '../../../services/selfServiceShopActivityService';
|
||||
import { addReward, stringToConsumeParam, stringToRewardParam } from '../../../services/giftPackageService';
|
||||
|
||||
export default function (app: Application) {
|
||||
return new SelfServiceShopHandler(app);
|
||||
@@ -17,7 +19,7 @@ export class SelfServiceShopHandler {
|
||||
constructor(private app: Application) {
|
||||
}
|
||||
|
||||
/************************自助商店****************************/
|
||||
/************************自助商店、糜家商队****************************/
|
||||
|
||||
/**
|
||||
* @description 获取自助商店数据
|
||||
@@ -62,17 +64,15 @@ export class SelfServiceShopHandler {
|
||||
}
|
||||
|
||||
let price = item.price;
|
||||
let priceType = item.priceType;
|
||||
|
||||
//检查资源
|
||||
if (priceType === ACTIVITY_RESOURCES_TYPE.GOODS) {//茶晶
|
||||
let result = await handleCost(roleId, sid, [{ id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.COIN), count: price }]);
|
||||
if (!result) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
} else if (priceType === ACTIVITY_RESOURCES_TYPE.RMB) {//RMB购买
|
||||
return resResult(STATUS.ACTIVITY_DATA_ERROR);
|
||||
if (price > 0) {//RMB购买
|
||||
return resResult(STATUS.ACTIVITY_NEED_PAY);
|
||||
}
|
||||
let result = await addSelfServiceShopGiftReward(roleId, roleName, sid, serverId, funcs, activityId, roundIndex, index, price, priceType);
|
||||
//检查资源
|
||||
let consume = stringToConsumeParam(item.consume)
|
||||
let consumeResult = await handleCost(roleId, sid, consume);
|
||||
if (!consumeResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
let result = await addSelfServiceShopGiftReward(roleId, roleName, sid, serverId, funcs, activityId, roundIndex, index);
|
||||
return resResult(STATUS.SUCCESS, Object.assign(result, {}));
|
||||
}
|
||||
|
||||
@@ -92,4 +92,43 @@ export class SelfServiceShopHandler {
|
||||
await ActivitySelfServiceGoodsModel.addGoods(activityId, roleId, roundIndex, index, cellIndex, gift, rewardIndex);
|
||||
return resResult(STATUS.SUCCESS, {});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 购买代币资源
|
||||
* @param {{ activityId: number, roundIndex: number}} msg
|
||||
* @param {BackendSession} session
|
||||
* @memberof SelfServiceShopHandler
|
||||
*/
|
||||
async buyRecources(msg: { activityId: number, roundIndex: number }, session: BackendSession) {
|
||||
const { activityId, roundIndex } = msg;
|
||||
const roleId = session.get('roleId');
|
||||
const serverId = session.get('serverId');
|
||||
const sid = session.get('sid');
|
||||
const roleName = session.get('roleName');
|
||||
const funcs: number[] = session.get('funcs');
|
||||
|
||||
let activityData: ActivityModelType = await ActivityModel.findActivity(activityId);
|
||||
let playerData = new SelfServiceShopData(activityData);
|
||||
let unitPrice = playerData.unitPrice;//购买价格
|
||||
let unitCountMax = playerData.unitCountMax;//最大购买次数
|
||||
let unitReward = playerData.unitReward;//购买获得资源
|
||||
|
||||
let playerSelfServerData = await ActivitySelfServiceModel.findData(serverId, activityId, roleId, roundIndex);
|
||||
|
||||
let buyCount = (playerSelfServerData && playerSelfServerData.unitBuyCount) ? playerSelfServerData.unitBuyCount : 0;
|
||||
if (buyCount >= unitCountMax) {
|
||||
return resResult(STATUS.ACTIVITY_MAX_COUNT);
|
||||
}
|
||||
|
||||
//检查资源
|
||||
let consume = stringToConsumeParam(unitPrice)
|
||||
let consumeResult = await handleCost(roleId, sid, consume);
|
||||
if (!consumeResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
await ActivitySelfServiceModel.addBuyRecord(serverId, activityId, roleId, roundIndex, 1);
|
||||
let rewardArray = stringToRewardParam(unitReward)
|
||||
let result = await addReward(roleId, roleName, sid, serverId, funcs, rewardArray);
|
||||
|
||||
return resResult(STATUS.SUCCESS, Object.assign(result, { unitBuyCount: buyCount + 1 }));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,9 +349,7 @@ export class HeroHandler {
|
||||
await checkTask(roleId, sid, funcs, TASK_TYPE.HERO_WAKE_UP, 1, true, {});
|
||||
await checkActivityTask(serverId, sid, funcs, roleId, TASK_TYPE.HERO_QUALITY_WAKE_UP_COUNT, 1, { quality: hero.quality });
|
||||
await checkActivityTask(serverId, sid, funcs, roleId, TASK_TYPE.HERO_WAKE_UP_COUNT, 1, { hid: hid });
|
||||
if (isWakeUp) {//觉醒升星
|
||||
await checkActivityTask(serverId, sid, funcs, roleId, TASK_TYPE.HERO_WAKE_UP_STAR_UP_COUNT, 1, { quality: dicHero.quality, colorStar: update.colorStar });
|
||||
}
|
||||
await checkActivityTask(serverId, sid, funcs, roleId, TASK_TYPE.HERO_WAKE_UP_STAR_UP_COUNT, 1, { quality: dicHero.quality, colorStar: update.colorStar });
|
||||
}
|
||||
const curHero = {
|
||||
hid,
|
||||
|
||||
@@ -15,6 +15,7 @@ import { ServerlistModel } from '../db/Serverlist';
|
||||
import { makeGrowthFund } from './growthFundService';
|
||||
import { makeLimitPackageReward } from './limitPackageService';
|
||||
import { makeShop } from './treasureHuntService';
|
||||
import { makeSelfServerShop } from './selfServiceShopActivityService';
|
||||
|
||||
|
||||
|
||||
@@ -109,6 +110,11 @@ export async function makeOrder(localOrderID: string, sid: string, orderInfo: Us
|
||||
rewardResult = await makeShop(roleId, roleInfo.roleName, sid, orderInfo.serverId, roleInfo.funcs, orderInfo.activityId, orderInfo.productID)
|
||||
break;
|
||||
}
|
||||
case ACTIVITY_TYPE.SELF_SERVICE_SHOP://自选商店-购买礼包
|
||||
{
|
||||
rewardResult = await makeSelfServerShop(roleId, roleInfo.roleName, sid, orderInfo.serverId, roleInfo.funcs, orderInfo.activityId, orderInfo.productID)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
rewardResult = STATUS.ERROR_TYPE;
|
||||
break;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { ACTIVITY_RESOURCES_TYPE, ACTIVITY_TYPE } from '../consts';
|
||||
import { ACTIVITY_RESOURCES_TYPE, ACTIVITY_TYPE, STATUS } from '../consts';
|
||||
import { ActivityModel, ActivityModelType } from '../db/Activity';
|
||||
import { ActivitySelfServiceGoodsModel, ActivitySelfServiceGoodsModelType } from '../db/ActivitySelfServiceGoods';
|
||||
import { ActivitySelfServiceShopModel, ActivitySelfServiceShopModelType } from '../db/ActivitySelfServiceShop';
|
||||
import { ActivitySelfServiceModel, ActivitySelfServiceModelType } from '../db/ActivitySelfService';
|
||||
import { ServerlistModel } from '../db/Serverlist';
|
||||
import { RewardParam } from '../domain/activityField/rewardField';
|
||||
import { SelfServiceShopData, SelfServiceShopItem } from '../domain/activityField/selfServiceShopField';
|
||||
@@ -42,9 +43,12 @@ export async function getPlayerActivityData(activityId: number, serverId: number
|
||||
let activityData: ActivityModelType = await ActivityModel.findActivity(activityId);
|
||||
let playerData = new SelfServiceShopData(activityData);
|
||||
|
||||
let playerRecords: ActivitySelfServiceShopModelType[] = await ActivitySelfServiceShopModel.findDataByPriceType(serverId, activityId, roleId, playerData.roundIndex, ACTIVITY_RESOURCES_TYPE.RMB);
|
||||
let playerRecords: ActivitySelfServiceShopModelType[] = await ActivitySelfServiceShopModel.findDataByPriceType(serverId, activityId, roleId, playerData.roundIndex);
|
||||
|
||||
playerData.setPlayerRecords(playerRecords);
|
||||
let playerSelfServerData = await ActivitySelfServiceModel.findData(serverId, activityId, roleId, playerData.roundIndex);
|
||||
let buyCount = (playerSelfServerData && playerSelfServerData.unitBuyCount) ? playerSelfServerData.unitBuyCount : 0;
|
||||
playerData.unitBuyCount = buyCount;
|
||||
|
||||
return playerData;
|
||||
}
|
||||
@@ -61,7 +65,7 @@ export async function getPlayerActivityData(activityId: number, serverId: number
|
||||
* @param {number} priceType 价格类型
|
||||
*
|
||||
*/
|
||||
export async function addSelfServiceShopGiftReward(roleId: string, roleName: string, sid: string, serverId: number, funcs: number[], activityId: number, roundIndex: number, index: number, price: number, priceType: number) {
|
||||
export async function addSelfServiceShopGiftReward(roleId: string, roleName: string, sid: string, serverId: number, funcs: number[], activityId: number, roundIndex: number, index: number) {
|
||||
let playerGoods: ActivitySelfServiceGoodsModelType[] = await ActivitySelfServiceGoodsModel.findDataByIndex(activityId, roleId, roundIndex, index);
|
||||
|
||||
let rewardArray: Array<RewardParam> = [];
|
||||
@@ -78,6 +82,49 @@ export async function addSelfServiceShopGiftReward(roleId: string, roleName: str
|
||||
}
|
||||
let result = await addReward(roleId, roleName, sid, serverId, funcs, rewardArray);
|
||||
//购买记录
|
||||
await ActivitySelfServiceShopModel.addBuyRecord(serverId, activityId, roleId, roundIndex, index, price, priceType, goodsStr);
|
||||
console.log('dddddddd', rewardArray.length, serverId, activityId, roleId, roundIndex, index, goodsStr)
|
||||
await ActivitySelfServiceShopModel.addBuyRecord(serverId, activityId, roleId, roundIndex, index, goodsStr);
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 购买自选礼包
|
||||
*
|
||||
* @param {number} serverId 区Id
|
||||
* @param {number} activityId 活动Id
|
||||
* @param {string} roleId 角色Id
|
||||
* @param {string} productID 商品ID
|
||||
*
|
||||
*/
|
||||
export async function makeSelfServerShop(roleId: string, roleName: string, sid: string, serverId: number, funcs: number[],
|
||||
activityId: number, productID: string) {
|
||||
|
||||
let activityData: ActivityModelType = await ActivityModel.findActivity(activityId);
|
||||
if (!activityData) {
|
||||
return {
|
||||
code: STATUS.ACTIVITY_MISSING,
|
||||
}
|
||||
}
|
||||
let playerData = new SelfServiceShopData(activityData);
|
||||
let item: SelfServiceShopItem = playerData.getItemByProductID(productID);
|
||||
if (!item) {
|
||||
return {
|
||||
code: STATUS.ACTIVITY_DATA_ERROR,
|
||||
}
|
||||
}
|
||||
if (item.countMax > 0) {//限制购买次数
|
||||
let playerRecords: ActivitySelfServiceShopModelType[] = await ActivitySelfServiceShopModel.findDataByIndex(serverId, activityId, roleId, playerData.roundIndex, item.index);
|
||||
if (playerRecords.length >= item.countMax) {
|
||||
return {
|
||||
code: STATUS.ACTIVITY_MAX_COUNT,
|
||||
}
|
||||
}
|
||||
}
|
||||
let result = await addSelfServiceShopGiftReward(roleId, roleName, sid, serverId, funcs, activityId, playerData.roundIndex, item.index);
|
||||
item.buyCount += 1;
|
||||
return {
|
||||
code: 0,
|
||||
data: Object.assign(result, { item })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ export enum ORDER_STATE {
|
||||
}
|
||||
|
||||
//服务器开服时间
|
||||
export const SERVER_OPEN_TIME = '2021-05-19T20:03:16.637+08:00';
|
||||
export const SERVER_OPEN_TIME = '2021-06-06T20:03:16.637+08:00';
|
||||
//玩家等级大于等于15级才能开启vip签到
|
||||
export const SIGNIN_VIP_OPEN_LIMIT = 15;
|
||||
|
||||
|
||||
@@ -626,7 +626,7 @@ export enum TASK_TYPE {
|
||||
GUILD_JOIN = 72, // 加入军团
|
||||
BATTLE_MAIN_ELITE = 73, // 精英通关
|
||||
HERO_QUALITY_TO_QUALITY_COUNT = 74,// *名武将*品升*品
|
||||
HERO_QUALITY_WAKE_UP_COUNT = 75, // *名武将*品觉醒
|
||||
HERO_QUALITY_WAKE_UP_COUNT = 75, // *名武将*品觉醒
|
||||
HERO_WAKE_UP_STAR_UP_COUNT = 76, // *名武将升至觉醒*星
|
||||
EQUIP_REFINE_LV = 77, // *件装备成功精炼到*级
|
||||
EQUIP_SUIT_JEWEL_STAGE = 78, // *次触发,一个武将满装备情况下,必须都镶嵌有相同阶的宝石(阶数大于等于x情况下都算达成)
|
||||
@@ -636,6 +636,7 @@ export enum TASK_TYPE {
|
||||
ROLE_TERAPH_STAGE_UP = 82, // 神像进阶
|
||||
EQUIP_QUALITY_COUNT = 83, // 获得*件品质的*装备
|
||||
HERO_WAKE_UP_COUNT = 84, // *名武将觉醒
|
||||
GUILD_ACTIVITY_END = 85, // 参与*军团活动到结束
|
||||
}
|
||||
|
||||
// 卡池类型
|
||||
|
||||
62
shared/db/ActivitySelfService.ts
Normal file
62
shared/db/ActivitySelfService.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
|
||||
|
||||
|
||||
export class ChallengeRecord {
|
||||
@prop({ required: true })
|
||||
count: number; //挑战次数
|
||||
@prop({ required: true })
|
||||
time: Date; // 开始统计时间
|
||||
}
|
||||
/**
|
||||
* 糜家商队活动数据
|
||||
*/
|
||||
@index({ roleId: 1 })
|
||||
|
||||
export default class Activity_Self_Service extends BaseModel {
|
||||
@prop({ required: true })
|
||||
serverId: number; // 服
|
||||
@prop({ required: true })
|
||||
activityId: number; // 活动Id
|
||||
@prop({ required: true })
|
||||
roundIndex: number; // 活动第几周期 从1开始,根据活动开始时间计算
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
@prop({ required: true })
|
||||
unitBuyCount: number; // 购买代币次数
|
||||
@prop({ required: true })
|
||||
challengeRecords: ChallengeRecord[]; //挑战记录
|
||||
|
||||
|
||||
//添加购买代币记录
|
||||
public static async addBuyRecord(serverId: number, activityId: number, roleId: string, roundIndex: number, count: number) {
|
||||
let result: ActivitySelfServiceModelType = await ActivitySelfServiceModel.findOneAndUpdate(
|
||||
{ serverId, roleId, activityId, roundIndex }, { $inc: { unitBuyCount: count } }, { upsert: true, new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//添加挑战记录
|
||||
public static async addChallengeRecord(serverId: number, activityId: number, roleId: string, roundIndex: number, count: number, time: Date) {
|
||||
let result: ActivitySelfServiceModelType = await ActivitySelfServiceModel.findOneAndUpdate(
|
||||
{ serverId, roleId, activityId, roundIndex, challengeRecords: { $elemMatch: { time } } },
|
||||
{ $inc: { "challengeRecords.$.count": count } }, { upsert: true, new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询活动数据
|
||||
public static async findData(serverId: number, activityId: number, roleId: string, roundIndex: number) {
|
||||
let result: ActivitySelfServiceModelType = await ActivitySelfServiceModel.findOne({ serverId, roleId, activityId, roundIndex }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除活动领取记录
|
||||
public static async deleteActivity(serverId: number, activityId: number, roleId: string, roundIndex: number, index: number,) {
|
||||
await ActivitySelfServiceModel.deleteMany({ serverId, roleId, activityId, index, roundIndex });
|
||||
}
|
||||
}
|
||||
|
||||
export const ActivitySelfServiceModel = getModelForClass(Activity_Self_Service);
|
||||
|
||||
export interface ActivitySelfServiceModelType extends Pick<DocumentType<Activity_Self_Service>, keyof Activity_Self_Service> { }
|
||||
export type ActivitySelfServiceModelTypeParam = Partial<ActivitySelfServiceModelType>; // 将所有字段变成可选项
|
||||
@@ -19,16 +19,12 @@ export default class Activity_Self_Service_Shop extends BaseModel {
|
||||
@prop({ required: true })
|
||||
index: number; // 第几个货架从1开始
|
||||
@prop({ required: true })
|
||||
price: number; //购买价格
|
||||
@prop({ required: true })
|
||||
priceType: number; //1.虚拟货币,2.RMB
|
||||
@prop({ required: true })
|
||||
goods: string; // 商品信息
|
||||
|
||||
//添加购买记录
|
||||
public static async addBuyRecord(serverId: number, activityId: number, roleId: string, roundIndex: number, index: number, price: number, priceType: number, goods: string) {
|
||||
public static async addBuyRecord(serverId: number, activityId: number, roleId: string, roundIndex: number, index: number, goods: string) {
|
||||
await ActivitySelfServiceShopModel.insertMany([
|
||||
{ serverId, roleId, activityId, roundIndex, index, price, priceType, goods }
|
||||
{ serverId, roleId, activityId, roundIndex, index, goods }
|
||||
])
|
||||
}
|
||||
|
||||
@@ -45,8 +41,8 @@ export default class Activity_Self_Service_Shop extends BaseModel {
|
||||
}
|
||||
|
||||
//查询购买价格类型的数据
|
||||
public static async findDataByPriceType(serverId: number, activityId: number, roleId: string, roundIndex: number, priceType: number, lean = true) {
|
||||
let result: ActivitySelfServiceShopModelType[] = await ActivitySelfServiceShopModel.find({ serverId, roleId, activityId, priceType, roundIndex }).lean(lean);
|
||||
public static async findDataByPriceType(serverId: number, activityId: number, roleId: string, roundIndex: number, lean = true) {
|
||||
let result: ActivitySelfServiceShopModelType[] = await ActivitySelfServiceShopModel.find({ serverId, roleId, activityId, roundIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import moment = require('moment');
|
||||
import { SERVER_OPEN_TIME } from '../../consts';
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivitySelfServiceShopModelType } from '../../db/ActivitySelfServiceShop';
|
||||
import { deltaDays } from '../../pubUtils/util';
|
||||
import { ActivityBase } from './activityField';
|
||||
|
||||
// 自助商店数据坑位数据
|
||||
@@ -21,7 +24,9 @@ export class SelfServiceShopItem {
|
||||
name: string; //名称
|
||||
countMax: number = 0; // 最大可购买次数 0表示无限
|
||||
price: number; //价格
|
||||
priceType: number; //价格类型 ACTIVITY_RESOURCES_TYPE 2.物品表 3.RMB
|
||||
productID: string; //商品id
|
||||
consume: string; //消耗其他资源
|
||||
|
||||
data: Array<SelfServiceShopItemInfo> = [];
|
||||
|
||||
buyCount: number = 0; //已经购买次数
|
||||
@@ -31,7 +36,8 @@ export class SelfServiceShopItem {
|
||||
this.name = cellData.name;
|
||||
this.countMax = cellData.countMax;
|
||||
this.price = cellData.price;
|
||||
this.priceType = cellData.priceType;
|
||||
this.productID = cellData.productID;
|
||||
this.consume = cellData.consume;
|
||||
this.data = [];
|
||||
for (let obj of cellData.data) {
|
||||
this.data.push(new SelfServiceShopItemInfo(obj))
|
||||
@@ -43,8 +49,22 @@ export class SelfServiceShopItem {
|
||||
export class SelfServiceShopData extends ActivityBase {
|
||||
list: Array<SelfServiceShopItem> = [];//货架
|
||||
days: number = 20;//刷新周期天数
|
||||
name: string = '';
|
||||
count: number = 1;//每天可挑战次数胜利,才会统计
|
||||
warid: string = '';//可挑战关卡
|
||||
unitPrice: string = '';//元宝购买代币价格
|
||||
unitCountMax: number = 0;//元宝购买代币最大次数
|
||||
unitReward: string = '';//购买获得代币资源
|
||||
|
||||
unitBuyCount: number = 0;//元宝购买代币次数
|
||||
roundIndex: number = 0; //第几周期 从1开始
|
||||
|
||||
public getItemByProductID(productID: string): SelfServiceShopItem {
|
||||
let listIndex = this.list.findIndex(obj => { return obj.productID == productID });
|
||||
return (listIndex != -1) ? this.list[listIndex] : null;
|
||||
}
|
||||
|
||||
|
||||
public getItem(index: number) {
|
||||
let listIndex = this.list.findIndex(obj => { return obj.index == index });
|
||||
return (listIndex != -1) ? this.list[listIndex] : null;
|
||||
@@ -59,14 +79,21 @@ export class SelfServiceShopData extends ActivityBase {
|
||||
}
|
||||
|
||||
public initData(data: string) {
|
||||
console.log('ddddddd', data)
|
||||
let dataObj = JSON.parse(data);
|
||||
this.days = dataObj.days;
|
||||
this.name = dataObj.name;
|
||||
this.count = dataObj.count;
|
||||
this.warid = dataObj.warid;
|
||||
this.unitPrice = dataObj.unitPrice;
|
||||
this.unitCountMax = dataObj.unitCountMax;
|
||||
this.unitReward = dataObj.unitReward;
|
||||
|
||||
let arr = dataObj.data;
|
||||
for (let obj of arr) {
|
||||
this.list.push(new SelfServiceShopItem(obj))
|
||||
}
|
||||
this.todayIndex = deltaDays(moment(SERVER_OPEN_TIME).startOf('d').toDate(), new Date) + 1;
|
||||
|
||||
this.roundIndex = Math.ceil(this.todayIndex / this.days);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityBase } from './activityField';
|
||||
import { TASK_TYPE } from '../../consts';
|
||||
import { ACTIVITY_TYPE, SERVER_OPEN_TIME, TASK_TYPE } from '../../consts';
|
||||
import { ActivityGrowthModelType } from '../../db/ActivityGrowth';
|
||||
import { ActivityGrowthPointModelType } from '../../db/ActivityGrowthPoint';
|
||||
import { HeroType } from '../../db/Hero';
|
||||
import { RoleModel } from '../../db/Role';
|
||||
import { splitString } from '../../pubUtils/util';
|
||||
import { deltaDays, splitString } from '../../pubUtils/util';
|
||||
import { ActivityDailyGiftsModelType } from '../../db/ActivityDailyGifts';
|
||||
import { parseResStr } from '../../pubUtils/util';
|
||||
import { ConsumeResParam } from '../activityField/consumeField';
|
||||
import { ActivityDailyChallengesModelType } from '../../db/ActivityDailyChallenges';
|
||||
import moment = require('moment');
|
||||
|
||||
// 今日挑战的每日配置数据
|
||||
export class SevenDaysDailyItem {
|
||||
@@ -318,6 +319,13 @@ export class SevenDaysData extends ActivityBase {
|
||||
this.dailyGift = new SevenDaysDailyGiftsData(objData.dailyGift)
|
||||
this.dailyChallenge = new SevenDaysDailyChallengesData(objData.dailyChallenge)
|
||||
|
||||
if (this.type === ACTIVITY_TYPE.SEVEN_DAY) {
|
||||
this.todayIndex = deltaDays(moment(SERVER_OPEN_TIME).startOf('d').toDate(), new Date) + 1;
|
||||
} else if (this.type === ACTIVITY_TYPE.FOURTEEN_DAY) {
|
||||
this.todayIndex = deltaDays(moment(SERVER_OPEN_TIME).startOf('d').toDate(), new Date) + 1 - 7;
|
||||
} else if (this.type === ACTIVITY_TYPE.COMMON_SEVEN_DAY) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
constructor(activityData: ActivityModelType) {
|
||||
|
||||
@@ -13,6 +13,7 @@ export class TreasureHuntFirstPageData {
|
||||
name: string = '';//页签名字
|
||||
index: number = 0;//下标
|
||||
reward: string = '';//奖励
|
||||
imageName: string = '';
|
||||
|
||||
isReceive: boolean = false;//是否领取
|
||||
|
||||
@@ -28,6 +29,7 @@ export class TreasureHuntFirstPageData {
|
||||
this.name = data.name;
|
||||
this.index = data.index;
|
||||
this.reward = data.reward;
|
||||
this.imageName = data.imageName;
|
||||
this.isReceive = false;
|
||||
}
|
||||
|
||||
@@ -204,6 +206,7 @@ export class TreasureHuntChallengeData {
|
||||
warid: string = '';//随机的关卡号
|
||||
fixReward: string = '';//客户端显示奖励
|
||||
jackpotReward: string = '';//客户端显示奖励
|
||||
imageName: string = '';
|
||||
|
||||
public randomGK() {
|
||||
let gkArray = splitString(this.warid, '&');
|
||||
@@ -218,6 +221,7 @@ export class TreasureHuntChallengeData {
|
||||
this.warid = data.warid;
|
||||
this.fixReward = data.fixReward;
|
||||
this.jackpotReward = data.jackpotReward;
|
||||
this.imageName = data.imageName;
|
||||
}
|
||||
|
||||
constructor(data: any) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import { ActivityBuyRecordsModel } from '../db/ActivityBuyRecords';
|
||||
import { PopUpShopData } from '../domain/activityField/popUpShopField';
|
||||
import { ActivityPopUpShopModel } from '../db/ActivityPopUpShop';
|
||||
import { ActivityPopUpShopRecordModel, ActivityPopUpShopRecordModelType } from '../db/ActivityPopUpShopRecord';
|
||||
import { SevenDaysData } from '../domain/activityField/sevenDaysField';
|
||||
import moment = require("moment");
|
||||
|
||||
|
||||
@@ -493,24 +494,120 @@ export async function accomplishTask(serverId: number, roleId: string, taskType:
|
||||
console.log('accomplishTask', roleId, taskType, count, JSON.stringify(parma))
|
||||
let pushMessage = [];
|
||||
let { activityGroupId } = await ServerlistModel.findByServerId(serverId);
|
||||
//成长活动统计
|
||||
let allActivity: ActivityModelType[] = await ActivityModel.findOpenActivityByType(activityGroupId, ACTIVITY_TYPE.TASK_GROWTH, new Date());
|
||||
// //成长活动统计
|
||||
// let allActivity: ActivityModelType[] = await ActivityModel.findOpenActivityByType(activityGroupId, ACTIVITY_TYPE.TASK_GROWTH, new Date());
|
||||
// for (let activity of allActivity) {
|
||||
// let growthActivity = new GrowthData(activity);
|
||||
// let taskArray = growthActivity.findTaskByType(taskType);
|
||||
// for (let task of taskArray) {
|
||||
// let taskRecord = await ActivityGrowthModel.findDataByCellIndex(serverId, growthActivity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType)
|
||||
// let recordData = taskRecord && taskRecord.data ? JSON.parse(taskRecord.data) : null;
|
||||
// let { addCount, record } = isComplete(roleId, task.taskType, task.taskParam, count, parma, recordData);
|
||||
// if (addCount) {
|
||||
// if (taskType == TASK_TYPE.ROLE_LV || taskType == TASK_TYPE.ROLE_TITLE || taskType == TASK_TYPE.BATTLE_TOWER_LV) {
|
||||
// let playerRecord = await ActivityGrowthModel.setTaskCount(serverId, growthActivity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType, addCount);
|
||||
// //推送
|
||||
// task.totalCount = playerRecord.totalCount;
|
||||
// task.receiveRewardCount = playerRecord.receiveRewardCount ? playerRecord.receiveRewardCount : 0;
|
||||
// pushMessage = pushMessage.concat(Object.assign(task, { activityId: growthActivity.activityId }));
|
||||
// } else {
|
||||
// let playerRecord = await ActivityGrowthModel.addTaskCount(serverId, growthActivity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType, addCount);
|
||||
// //推送
|
||||
// task.totalCount = playerRecord.totalCount;
|
||||
// task.receiveRewardCount = playerRecord.receiveRewardCount ? playerRecord.receiveRewardCount : 0;
|
||||
// pushMessage = pushMessage.concat(Object.assign(task, { activityId: growthActivity.activityId }));
|
||||
// }
|
||||
// }
|
||||
// if (record) {
|
||||
// await ActivityGrowthModel.addTaskRecord(serverId, growthActivity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType, JSON.stringify(record));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// //今日挑战统计
|
||||
// allActivity = await ActivityModel.findOpenActivityByType(activityGroupId, ACTIVITY_TYPE.TASK_DAILY_CHALLENGES, new Date());
|
||||
// for (let activity of allActivity) {
|
||||
// let growthActivity = new DailyChallengesData(activity);
|
||||
// let taskArray = growthActivity.findTaskByType(taskType, growthActivity.today());
|
||||
// for (let task of taskArray) {
|
||||
// let taskRecord = await ActivityDailyChallengesModel.findDataByCellIndex(serverId, growthActivity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType)
|
||||
// let recordData = taskRecord && taskRecord.data ? JSON.parse(taskRecord.data) : null
|
||||
// let { addCount, record } = isComplete(roleId, task.taskType, task.taskParam, count, parma, recordData);
|
||||
// if (addCount) {
|
||||
// if (taskType == TASK_TYPE.ROLE_LV || taskType == TASK_TYPE.ROLE_TITLE || taskType == TASK_TYPE.BATTLE_TOWER_LV) {
|
||||
// let playerRecord = await ActivityDailyChallengesModel.setTaskCount(serverId, growthActivity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType, addCount);
|
||||
// //推送
|
||||
// task.totalCount = playerRecord.totalCount;
|
||||
// task.receiveRewardCount = playerRecord.receiveRewardCount ? playerRecord.receiveRewardCount : 0;
|
||||
// pushMessage = pushMessage.concat(Object.assign(task, { activityId: growthActivity.activityId }));
|
||||
// } else {
|
||||
// let playerRecord = await ActivityDailyChallengesModel.addTaskCount(serverId, growthActivity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType, addCount);
|
||||
// //推送
|
||||
// task.totalCount = playerRecord.totalCount;
|
||||
// task.receiveRewardCount = playerRecord.receiveRewardCount ? playerRecord.receiveRewardCount : 0;
|
||||
// pushMessage = pushMessage.concat(Object.assign(task, { activityId: growthActivity.activityId }));
|
||||
// }
|
||||
// }
|
||||
// if (record) {
|
||||
// await ActivityGrowthModel.addTaskRecord(serverId, growthActivity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType, JSON.stringify(record));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//七天乐
|
||||
let allActivity: ActivityModelType[] = await ActivityModel.findOpenActivityByType(activityGroupId, ACTIVITY_TYPE.SEVEN_DAY, new Date());
|
||||
for (let activity of allActivity) {
|
||||
let growthActivity = new GrowthData(activity);
|
||||
let taskArray = growthActivity.findTaskByType(taskType);
|
||||
for (let task of taskArray) {
|
||||
let taskRecord = await ActivityGrowthModel.findDataByCellIndex(serverId, growthActivity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType)
|
||||
let playerData = new SevenDaysData(activity)
|
||||
//成长活动统计
|
||||
let growthActivity = playerData.growth;
|
||||
let growthTaskArray = growthActivity.findTaskByType(taskType);
|
||||
for (let task of growthTaskArray) {
|
||||
let taskRecord = await ActivityGrowthModel.findDataByCellIndex(serverId, activity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType)
|
||||
let recordData = taskRecord && taskRecord.data ? JSON.parse(taskRecord.data) : null;
|
||||
let { addCount, record } = isComplete(roleId, task.taskType, task.taskParam, count, parma, recordData);
|
||||
if (addCount) {
|
||||
if (taskType == TASK_TYPE.ROLE_LV || taskType == TASK_TYPE.ROLE_TITLE || taskType == TASK_TYPE.BATTLE_TOWER_LV) {
|
||||
await ActivityGrowthModel.setTaskCount(serverId, growthActivity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType, addCount);
|
||||
let playerRecord = await ActivityGrowthModel.setTaskCount(serverId, activity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType, addCount);
|
||||
//推送
|
||||
task.totalCount = playerRecord.totalCount;
|
||||
task.receiveRewardCount = playerRecord.receiveRewardCount ? playerRecord.receiveRewardCount : 0;
|
||||
pushMessage = pushMessage.concat(Object.assign(task, { activityId: activity.activityId, activityType: "growth" }));
|
||||
} else {
|
||||
await ActivityGrowthModel.addTaskCount(serverId, growthActivity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType, addCount);
|
||||
let playerRecord = await ActivityGrowthModel.addTaskCount(serverId, activity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType, addCount);
|
||||
//推送
|
||||
task.totalCount = playerRecord.totalCount;
|
||||
task.receiveRewardCount = playerRecord.receiveRewardCount ? playerRecord.receiveRewardCount : 0;
|
||||
pushMessage = pushMessage.concat(Object.assign(task, { activityId: activity.activityId, activityType: "growth" }));
|
||||
}
|
||||
}
|
||||
if (record) {
|
||||
await ActivityGrowthModel.addTaskRecord(serverId, growthActivity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType, JSON.stringify(record));
|
||||
await ActivityGrowthModel.addTaskRecord(serverId, activity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType, JSON.stringify(record));
|
||||
}
|
||||
}
|
||||
//今日挑战统计
|
||||
let dailyChallengeActivity = playerData.dailyChallenge;
|
||||
let dailyChallengeTaskArray = dailyChallengeActivity.findTaskByType(taskType, playerData.today());
|
||||
for (let task of dailyChallengeTaskArray) {
|
||||
let taskRecord = await ActivityDailyChallengesModel.findDataByCellIndex(serverId, activity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType)
|
||||
let recordData = taskRecord && taskRecord.data ? JSON.parse(taskRecord.data) : null
|
||||
let { addCount, record } = isComplete(roleId, task.taskType, task.taskParam, count, parma, recordData);
|
||||
if (addCount) {
|
||||
if (taskType == TASK_TYPE.ROLE_LV || taskType == TASK_TYPE.ROLE_TITLE || taskType == TASK_TYPE.BATTLE_TOWER_LV) {
|
||||
let playerRecord = await ActivityDailyChallengesModel.setTaskCount(serverId, activity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType, addCount);
|
||||
//推送
|
||||
task.totalCount = playerRecord.totalCount;
|
||||
task.receiveRewardCount = playerRecord.receiveRewardCount ? playerRecord.receiveRewardCount : 0;
|
||||
pushMessage = pushMessage.concat(Object.assign(task, { activityId: activity.activityId, activityType: "daily" }));
|
||||
} else {
|
||||
let playerRecord = await ActivityDailyChallengesModel.addTaskCount(serverId, activity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType, addCount);
|
||||
//推送
|
||||
task.totalCount = playerRecord.totalCount;
|
||||
task.receiveRewardCount = playerRecord.receiveRewardCount ? playerRecord.receiveRewardCount : 0;
|
||||
pushMessage = pushMessage.concat(Object.assign(task, { activityId: activity.activityId, activityType: "daily" }));
|
||||
}
|
||||
}
|
||||
if (record) {
|
||||
await ActivityGrowthModel.addTaskRecord(serverId, activity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType, JSON.stringify(record));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -526,9 +623,17 @@ export async function accomplishTask(serverId: number, roleId: string, taskType:
|
||||
let { addCount, record } = isComplete(roleId, task.taskType, task.taskParam, count, parma, recordData);
|
||||
if (addCount) {
|
||||
if (taskType == TASK_TYPE.ROLE_LV || taskType == TASK_TYPE.ROLE_TITLE || taskType == TASK_TYPE.BATTLE_TOWER_LV) {
|
||||
await ActivityDailyChallengesModel.setTaskCount(serverId, growthActivity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType, addCount);
|
||||
let playerRecord = await ActivityDailyChallengesModel.setTaskCount(serverId, growthActivity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType, addCount);
|
||||
//推送
|
||||
task.totalCount = playerRecord.totalCount;
|
||||
task.receiveRewardCount = playerRecord.receiveRewardCount ? playerRecord.receiveRewardCount : 0;
|
||||
pushMessage = pushMessage.concat(Object.assign(task, { activityId: growthActivity.activityId }));
|
||||
} else {
|
||||
await ActivityDailyChallengesModel.addTaskCount(serverId, growthActivity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType, addCount);
|
||||
let playerRecord = await ActivityDailyChallengesModel.addTaskCount(serverId, growthActivity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType, addCount);
|
||||
//推送
|
||||
task.totalCount = playerRecord.totalCount;
|
||||
task.receiveRewardCount = playerRecord.receiveRewardCount ? playerRecord.receiveRewardCount : 0;
|
||||
pushMessage = pushMessage.concat(Object.assign(task, { activityId: growthActivity.activityId }));
|
||||
}
|
||||
}
|
||||
if (record) {
|
||||
@@ -542,7 +647,13 @@ export async function accomplishTask(serverId: number, roleId: string, taskType:
|
||||
taskType === TASK_TYPE.HERO_QUALITY_TO_QUALITY_COUNT ||
|
||||
taskType === TASK_TYPE.HERO_QUALITY_WAKE_UP_COUNT ||
|
||||
taskType === TASK_TYPE.HERO_WAKE_UP_STAR_UP_COUNT ||
|
||||
taskType === TASK_TYPE.HERO_WAKE_UP_COUNT ||
|
||||
taskType === TASK_TYPE.HERO_QUALITY ||
|
||||
taskType === TASK_TYPE.GUILD_TRAIN_COUNT ||
|
||||
taskType === TASK_TYPE.HERO_UNLOCK ||
|
||||
taskType === TASK_TYPE.GACHA_QUALITY_COUNT ||
|
||||
taskType === TASK_TYPE.ROLE_TERAPH_STAGE_UP ||
|
||||
taskType === TASK_TYPE.EQUIP_QUALITY_COUNT ||
|
||||
|
||||
taskType === TASK_TYPE.EQUIP_STRENGTHEN ||
|
||||
taskType === TASK_TYPE.EQUIP_REFINE_LV ||
|
||||
@@ -642,345 +753,344 @@ export async function accomplishTask(serverId: number, roleId: string, taskType:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//主线成长基金
|
||||
if (taskType === TASK_TYPE.BATTLE_MAIN) {
|
||||
allActivity = await ActivityModel.findOpenActivityByTypes(activityGroupId, [ACTIVITY_TYPE.GROWTH_FUND_MAIN, ACTIVITY_TYPE.GROWTH_FUND_MAIN_VIP], new Date());
|
||||
for (let activity of allActivity) {
|
||||
let growthFundActivity = new GrowthFundData(activity);
|
||||
let playerRecords: ActivityGrowthFundModelType[] = await ActivityGrowthFundModel.findData(activity.activityId, roleId);
|
||||
growthFundActivity.setPlayerRecords(playerRecords);
|
||||
if (growthFundActivity.isVipActivity()) {//vip高阶需要购买
|
||||
let buyRecords = await ActivityBuyRecordsModel.findRecordsByActivityId(activity.activityId, roleId);
|
||||
growthFundActivity.initBuyRecords(buyRecords);
|
||||
}
|
||||
let taskArray = growthFundActivity.unLockItem(parma.warId);
|
||||
//推送
|
||||
pushMessage = pushMessage.concat(taskArray);
|
||||
}
|
||||
}
|
||||
//镇念塔成长基金getRoleOnlineInfo
|
||||
if (taskType === TASK_TYPE.BATTLE_TOWER_LV) {
|
||||
allActivity = await ActivityModel.findOpenActivityByTypes(activityGroupId, [ACTIVITY_TYPE.GROWTH_FUND_TOWER, ACTIVITY_TYPE.GROWTH_FUND_TOWER_VIP], new Date());
|
||||
for (let activity of allActivity) {
|
||||
let growthFundActivity = new GrowthFundData(activity);
|
||||
let playerRecords: ActivityGrowthFundModelType[] = await ActivityGrowthFundModel.findData(activity.activityId, roleId);
|
||||
growthFundActivity.setPlayerRecords(playerRecords);
|
||||
if (growthFundActivity.isVipActivity()) {//vip高阶需要购买
|
||||
let buyRecords = await ActivityBuyRecordsModel.findRecordsByActivityId(activity.activityId, roleId);
|
||||
growthFundActivity.initBuyRecords(buyRecords);
|
||||
}
|
||||
let taskArray = growthFundActivity.unLockItem(parma.towerLv);
|
||||
//推送
|
||||
pushMessage = pushMessage.concat(taskArray);
|
||||
}
|
||||
}
|
||||
//精英成长基金
|
||||
if (taskType === TASK_TYPE.BATTLE_MAIN_ELITE) {
|
||||
allActivity = await ActivityModel.findOpenActivityByTypes(activityGroupId, [ACTIVITY_TYPE.GROWTH_FUND_MAIN_ELITE, ACTIVITY_TYPE.GROWTH_FUND_MAIN_ELITE_VIP], new Date());
|
||||
for (let activity of allActivity) {
|
||||
let growthFundActivity = new GrowthFundData(activity);
|
||||
let playerRecords: ActivityGrowthFundModelType[] = await ActivityGrowthFundModel.findData(activity.activityId, roleId);
|
||||
growthFundActivity.setPlayerRecords(playerRecords);
|
||||
if (growthFundActivity.isVipActivity()) {//vip高阶需要购买
|
||||
let buyRecords = await ActivityBuyRecordsModel.findRecordsByActivityId(activity.activityId, roleId);
|
||||
growthFundActivity.initBuyRecords(buyRecords);
|
||||
}
|
||||
let taskArray = growthFundActivity.unLockItem(parma.mainEliteWarId);
|
||||
//推送
|
||||
pushMessage = pushMessage.concat(taskArray);
|
||||
}
|
||||
}
|
||||
|
||||
return pushMessage;
|
||||
}
|
||||
//主线成长基金
|
||||
if (taskType === TASK_TYPE.BATTLE_MAIN) {
|
||||
allActivity = await ActivityModel.findOpenActivityByTypes(activityGroupId, [ACTIVITY_TYPE.GROWTH_FUND_MAIN, ACTIVITY_TYPE.GROWTH_FUND_MAIN_VIP], new Date());
|
||||
for (let activity of allActivity) {
|
||||
let growthFundActivity = new GrowthFundData(activity);
|
||||
let playerRecords: ActivityGrowthFundModelType[] = await ActivityGrowthFundModel.findData(activity.activityId, roleId);
|
||||
growthFundActivity.setPlayerRecords(playerRecords);
|
||||
if (growthFundActivity.isVipActivity()) {//vip高阶需要购买
|
||||
let buyRecords = await ActivityBuyRecordsModel.findRecordsByActivityId(activity.activityId, roleId);
|
||||
growthFundActivity.initBuyRecords(buyRecords);
|
||||
}
|
||||
let taskArray = growthFundActivity.unLockItem(parma.warId);
|
||||
//推送
|
||||
pushMessage = pushMessage.concat(taskArray);
|
||||
}
|
||||
}
|
||||
//镇念塔成长基金getRoleOnlineInfo
|
||||
if (taskType === TASK_TYPE.BATTLE_TOWER_LV) {
|
||||
allActivity = await ActivityModel.findOpenActivityByTypes(activityGroupId, [ACTIVITY_TYPE.GROWTH_FUND_TOWER, ACTIVITY_TYPE.GROWTH_FUND_TOWER_VIP], new Date());
|
||||
for (let activity of allActivity) {
|
||||
let growthFundActivity = new GrowthFundData(activity);
|
||||
let playerRecords: ActivityGrowthFundModelType[] = await ActivityGrowthFundModel.findData(activity.activityId, roleId);
|
||||
growthFundActivity.setPlayerRecords(playerRecords);
|
||||
if (growthFundActivity.isVipActivity()) {//vip高阶需要购买
|
||||
let buyRecords = await ActivityBuyRecordsModel.findRecordsByActivityId(activity.activityId, roleId);
|
||||
growthFundActivity.initBuyRecords(buyRecords);
|
||||
}
|
||||
let taskArray = growthFundActivity.unLockItem(parma.towerLv);
|
||||
//推送
|
||||
pushMessage = pushMessage.concat(taskArray);
|
||||
}
|
||||
}
|
||||
//精英成长基金
|
||||
if (taskType === TASK_TYPE.BATTLE_MAIN_ELITE) {
|
||||
allActivity = await ActivityModel.findOpenActivityByTypes(activityGroupId, [ACTIVITY_TYPE.GROWTH_FUND_MAIN_ELITE, ACTIVITY_TYPE.GROWTH_FUND_MAIN_ELITE_VIP], new Date());
|
||||
for (let activity of allActivity) {
|
||||
let growthFundActivity = new GrowthFundData(activity);
|
||||
let playerRecords: ActivityGrowthFundModelType[] = await ActivityGrowthFundModel.findData(activity.activityId, roleId);
|
||||
growthFundActivity.setPlayerRecords(playerRecords);
|
||||
if (growthFundActivity.isVipActivity()) {//vip高阶需要购买
|
||||
let buyRecords = await ActivityBuyRecordsModel.findRecordsByActivityId(activity.activityId, roleId);
|
||||
growthFundActivity.initBuyRecords(buyRecords);
|
||||
}
|
||||
let taskArray = growthFundActivity.unLockItem(parma.mainEliteWarId);
|
||||
//推送
|
||||
pushMessage = pushMessage.concat(taskArray);
|
||||
}
|
||||
}
|
||||
return pushMessage;
|
||||
}
|
||||
/**
|
||||
* 达成任务标准
|
||||
*
|
||||
* @param {string} roleId 角色Id
|
||||
* @param {number} taskType 任务类型
|
||||
* @param {number} taskParam 任务条件数据
|
||||
* @param {number} count 数据
|
||||
* @param {number} parma 参数
|
||||
*
|
||||
*/
|
||||
|
||||
export function isComplete(roleId: string, taskType: TASK_TYPE, taskParam: string, count: number, paramObj?: any, recordData?: any): any {
|
||||
console.log('达成任务标准', roleId, taskType, taskParam, count, paramObj)
|
||||
let param = splitString(taskParam, '&');
|
||||
let addCount: number = 0; // 条件是否满足
|
||||
let record: any = null;
|
||||
switch (taskType) {
|
||||
case TASK_TYPE.ROLE_LV://重置数据
|
||||
addCount = count;
|
||||
break;
|
||||
case TASK_TYPE.GUILD_JOIN:
|
||||
addCount = count;
|
||||
break;
|
||||
case TASK_TYPE.LOGIN_SUM:
|
||||
addCount = count;
|
||||
break;
|
||||
case TASK_TYPE.HERO_NUM:
|
||||
addCount = count;
|
||||
break;
|
||||
/**
|
||||
* 达成任务标准
|
||||
*
|
||||
* @param {string} roleId 角色Id
|
||||
* @param {number} taskType 任务类型
|
||||
* @param {number} taskParam 任务条件数据
|
||||
* @param {number} count 数据
|
||||
* @param {number} parma 参数
|
||||
*
|
||||
*/
|
||||
|
||||
case TASK_TYPE.HERO_QUALITY_STAR_UP://herocount&quality&star&
|
||||
addCount = (param[1] == paramObj.quality) && (param[2] == paramObj.star) ? count : 0;
|
||||
break;
|
||||
case TASK_TYPE.HERO_QUALITY_TO_QUALITY_COUNT://herocount&quality&star& {oldQuality, quality: hero.quality}
|
||||
addCount = (param[1] == paramObj.oldQuality) && (param[2] == paramObj.quality) ? count : 0;
|
||||
break;
|
||||
case TASK_TYPE.HERO_QUALITY_WAKE_UP_COUNT://herocount&quality
|
||||
addCount = (param[1] == paramObj.quality) ? count : 0;
|
||||
break;
|
||||
case TASK_TYPE.HERO_WAKE_UP_STAR_UP_COUNT://herocount&colorStar& colorStar:彩星 1表示觉醒
|
||||
addCount = (param[1] == paramObj.colorStar) ? count : 0;
|
||||
break;
|
||||
case TASK_TYPE.HERO_STAGE_UP://herocount&star&
|
||||
addCount = (param[1] == paramObj.job) ? count : 0;
|
||||
break;
|
||||
case TASK_TYPE.EQUIP_JEWEL_STAGE://count&stage&
|
||||
addCount = (param[1] == paramObj.stage) ? count : 0;
|
||||
break;
|
||||
case TASK_TYPE.EQUIP_SUIT_JEWEL_STAGE://count&stage&
|
||||
addCount = (param[1] == paramObj.stage) ? count : 0;
|
||||
break;
|
||||
case TASK_TYPE.EQUIP_QUALITY:
|
||||
addCount = param[1] == paramObj.quality ? count : 0;
|
||||
break;
|
||||
export function isComplete(roleId: string, taskType: TASK_TYPE, taskParam: string, count: number, paramObj?: any, recordData?: any): any {
|
||||
console.log('达成任务标准', roleId, taskType, taskParam, count, paramObj)
|
||||
let param = splitString(taskParam, '&');
|
||||
let addCount: number = 0; // 条件是否满足
|
||||
let record: any = null;
|
||||
switch (taskType) {
|
||||
case TASK_TYPE.ROLE_LV://重置数据
|
||||
addCount = count;
|
||||
break;
|
||||
case TASK_TYPE.GUILD_JOIN:
|
||||
addCount = count;
|
||||
break;
|
||||
case TASK_TYPE.LOGIN_SUM:
|
||||
addCount = count;
|
||||
break;
|
||||
case TASK_TYPE.HERO_NUM:
|
||||
addCount = count;
|
||||
break;
|
||||
|
||||
case TASK_TYPE.ROLE_TITLE://重置数据
|
||||
addCount = param[0] <= count ? count : 0;
|
||||
break;
|
||||
case TASK_TYPE.GASHA:
|
||||
addCount = count;
|
||||
break;
|
||||
case TASK_TYPE.EQUIP_STRENGTHEN:
|
||||
for (let obj of paramObj) {
|
||||
// obj.hid;//英雄di
|
||||
// obj.oldLv;//栏位升级前等级
|
||||
// obj.lv;//栏位升级后等级
|
||||
// obj.id;//栏位id
|
||||
if (param[1] > obj.oldLv && param[1] <= obj.lv) {
|
||||
addCount++;
|
||||
}
|
||||
case TASK_TYPE.HERO_QUALITY_STAR_UP://herocount&quality&star&
|
||||
addCount = (param[1] == paramObj.quality) && (param[2] == paramObj.star) ? count : 0;
|
||||
break;
|
||||
case TASK_TYPE.HERO_QUALITY_TO_QUALITY_COUNT://herocount&quality&star& {oldQuality, quality: hero.quality}
|
||||
addCount = (param[1] == paramObj.oldQuality) && (param[2] == paramObj.quality) ? count : 0;
|
||||
break;
|
||||
case TASK_TYPE.HERO_QUALITY_WAKE_UP_COUNT://herocount&quality
|
||||
addCount = (param[1] == paramObj.quality) ? count : 0;
|
||||
break;
|
||||
case TASK_TYPE.HERO_WAKE_UP_STAR_UP_COUNT://herocount&colorStar& colorStar:彩星 1表示觉醒
|
||||
addCount = (param[1] == paramObj.colorStar) ? count : 0;
|
||||
break;
|
||||
case TASK_TYPE.HERO_STAGE_UP://herocount&star&
|
||||
addCount = (param[1] == paramObj.job) ? count : 0;
|
||||
break;
|
||||
case TASK_TYPE.EQUIP_JEWEL_STAGE://count&stage&
|
||||
addCount = (param[1] == paramObj.stage) ? count : 0;
|
||||
break;
|
||||
case TASK_TYPE.EQUIP_SUIT_JEWEL_STAGE://count&stage&
|
||||
addCount = (param[1] == paramObj.stage) ? count : 0;
|
||||
break;
|
||||
case TASK_TYPE.EQUIP_QUALITY:
|
||||
addCount = param[1] == paramObj.quality ? count : 0;
|
||||
break;
|
||||
|
||||
case TASK_TYPE.ROLE_TITLE://重置数据
|
||||
addCount = param[0] <= count ? count : 0;
|
||||
break;
|
||||
case TASK_TYPE.GASHA:
|
||||
addCount = count;
|
||||
break;
|
||||
case TASK_TYPE.EQUIP_STRENGTHEN:
|
||||
for (let obj of paramObj) {
|
||||
// obj.hid;//英雄di
|
||||
// obj.oldLv;//栏位升级前等级
|
||||
// obj.lv;//栏位升级后等级
|
||||
// obj.id;//栏位id
|
||||
if (param[1] > obj.oldLv && param[1] <= obj.lv) {
|
||||
addCount++;
|
||||
}
|
||||
break;
|
||||
case TASK_TYPE.EQUIP_REFINE_LV:
|
||||
addCount = (param[1] == paramObj.lv) ? count : 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case TASK_TYPE.EQUIP_REFINE_LV:
|
||||
addCount = (param[1] == paramObj.lv) ? count : 0;
|
||||
break;
|
||||
|
||||
case TASK_TYPE.BATTLE_MAIN:
|
||||
addCount = (param[1] == paramObj.warId) ? 1 : 0;
|
||||
break;
|
||||
case TASK_TYPE.EQUIP_JEWEL_SUM:
|
||||
addCount = count;
|
||||
break;
|
||||
case TASK_TYPE.GUILD_TRAIN:
|
||||
addCount = count;
|
||||
break;
|
||||
case TASK_TYPE.ROLE_SCHOOL_PUT_HERO:
|
||||
addCount = count;
|
||||
break;
|
||||
case TASK_TYPE.GUILD_ACTIVITY:
|
||||
addCount = count;
|
||||
break;
|
||||
case TASK_TYPE.EQUIP_SUM:
|
||||
addCount = count;
|
||||
break;
|
||||
case TASK_TYPE.HERO_LV://{ hid, lv}
|
||||
{
|
||||
let hid = paramObj.hid;
|
||||
let lv = paramObj.lv;
|
||||
if (lv < param[1]) {
|
||||
case TASK_TYPE.BATTLE_MAIN:
|
||||
addCount = (param[1] == paramObj.warId) ? 1 : 0;
|
||||
break;
|
||||
case TASK_TYPE.EQUIP_JEWEL_SUM:
|
||||
addCount = count;
|
||||
break;
|
||||
case TASK_TYPE.GUILD_TRAIN:
|
||||
addCount = count;
|
||||
break;
|
||||
case TASK_TYPE.ROLE_SCHOOL_PUT_HERO:
|
||||
addCount = count;
|
||||
break;
|
||||
case TASK_TYPE.GUILD_ACTIVITY:
|
||||
addCount = count;
|
||||
break;
|
||||
case TASK_TYPE.EQUIP_SUM:
|
||||
addCount = count;
|
||||
break;
|
||||
case TASK_TYPE.HERO_LV://{ hid, lv}
|
||||
{
|
||||
let hid = paramObj.hid;
|
||||
let lv = paramObj.lv;
|
||||
if (lv < param[1]) {
|
||||
break;
|
||||
}
|
||||
if (recordData) {
|
||||
record = recordData;
|
||||
if (recordData.indexOf(hid) != -1) {
|
||||
break;
|
||||
}
|
||||
if (recordData) {
|
||||
record = recordData;
|
||||
if (recordData.indexOf(hid) != -1) {
|
||||
} else {
|
||||
record = [];
|
||||
}
|
||||
|
||||
addCount = count;
|
||||
record.push(hid)
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.HERO_TRAIN_SUM://训练X次是所有武将的训练次数的总和达到要求就好了
|
||||
{
|
||||
addCount = count;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.HERO_TRAIN://X名武将训练Y次,要求单名武将训练Y次,这样的武将要有X名
|
||||
{
|
||||
let hid = paramObj.hid;
|
||||
if (recordData) {
|
||||
record = recordData;
|
||||
let oldCount = record[hid];
|
||||
if (oldCount) {
|
||||
if (oldCount < param[1] && (oldCount + count >= param[1])) {
|
||||
addCount = count;
|
||||
record[hid] = oldCount + count;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
record = [];
|
||||
}
|
||||
|
||||
addCount = count;
|
||||
record.push(hid)
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.HERO_TRAIN_SUM://训练X次是所有武将的训练次数的总和达到要求就好了
|
||||
{
|
||||
addCount = count;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.HERO_TRAIN://X名武将训练Y次,要求单名武将训练Y次,这样的武将要有X名
|
||||
{
|
||||
let hid = paramObj.hid;
|
||||
if (recordData) {
|
||||
record = recordData;
|
||||
let oldCount = record[hid];
|
||||
if (oldCount) {
|
||||
if (oldCount < param[1] && (oldCount + count >= param[1])) {
|
||||
addCount = count;
|
||||
record[hid] = oldCount + count;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
record[hid] = count;
|
||||
if (count >= param[1]) {
|
||||
addCount = count;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
record = {};
|
||||
record[hid] = count;
|
||||
if (count >= param[1]) {
|
||||
addCount = count;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.BATTLE_EXPEDITION:
|
||||
{
|
||||
addCount = count;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.BATTLE_EXPEDITION_BOX:
|
||||
{
|
||||
addCount = count;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.HERO_QUALITY:
|
||||
{
|
||||
let quality = param[1]
|
||||
let heroes = paramObj.heroes.filter(hero => { return hero.quality == quality })
|
||||
addCount = heroes.length;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.PVP_WIN_SERIES:
|
||||
{
|
||||
addCount = count;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.PVP_WIN:
|
||||
{
|
||||
addCount = count;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.BATTLE_TOWER_LV://{towerLv}
|
||||
{
|
||||
let towerLv = paramObj.towerLv;
|
||||
if (recordData) {
|
||||
if (recordData >= towerLv) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
record = towerLv;
|
||||
addCount = towerLv;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.BATTLE_MAIN_ELITE:
|
||||
{
|
||||
if (paramObj.mainEliteWarId == param[1]) {
|
||||
} else {
|
||||
record = {};
|
||||
record[hid] = count;
|
||||
if (count >= param[1]) {
|
||||
addCount = count;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.BATTLE_DUNGEON_WAR:
|
||||
{
|
||||
if (paramObj.warId == param[1]) {
|
||||
addCount = count;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.HERO_NUM:
|
||||
{
|
||||
addCount = count;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.PVP:
|
||||
{
|
||||
addCount = count;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.GUILD_TRAIN_COUNT://trainId count&wardId&
|
||||
{
|
||||
if (paramObj.trainId == param[1]) {
|
||||
addCount = count;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.HERO_UNLOCK://
|
||||
{
|
||||
let camp = param[1]
|
||||
let heroes = paramObj.dicHeroes.filter(hero => { return hero.camp == camp })
|
||||
addCount = heroes.length;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.GACHA_QUALITY_COUNT://count&quality&
|
||||
{
|
||||
let quality = param[1]
|
||||
let heroes = paramObj.heroes.filter(hero => { return hero.quality == quality })
|
||||
addCount = heroes.length;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.ROLE_TERAPH_STAGE_UP://
|
||||
{
|
||||
addCount = count;
|
||||
break;
|
||||
}
|
||||
|
||||
case TASK_TYPE.HERO_WAKE_UP_COUNT:
|
||||
{
|
||||
|
||||
let hid = paramObj.hid;
|
||||
if (recordData) {
|
||||
record = recordData;
|
||||
if (recordData.indexOf(hid) != -1) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
record = [];
|
||||
}
|
||||
|
||||
addCount = count;
|
||||
record.push(hid)
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.EQUIP_QUALITY_COUNT:
|
||||
{
|
||||
let quality = param[1]
|
||||
let equips = paramObj.equips.filter(equip => { return equip.quality == quality })
|
||||
addCount = equips.length;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
addCount = 0;
|
||||
break;
|
||||
|
||||
}
|
||||
console.log('dddddddddddd', addCount, record)
|
||||
return { addCount, record };
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建账号时临时获得可开启功能,主要用于check 主公升级任务
|
||||
* 该函数不会存储funcs,如pvp开启会在entryHandler里面再查一次funcs,那时候正式开启
|
||||
* @param dataFuncs
|
||||
* @param lv
|
||||
*/
|
||||
export async function getCreateUserFuncs(dataFuncs: number[], lv: number) {
|
||||
let addFuncs: number[] = [];
|
||||
for (let [id, dicFunSwitch] of gameData.funcsSwitch) {
|
||||
if (dataFuncs.includes(id)) continue; // 已开启过了
|
||||
|
||||
if (dicFunSwitch && lv >= dicFunSwitch.param) {
|
||||
addFuncs.push(id);
|
||||
}
|
||||
case TASK_TYPE.BATTLE_EXPEDITION:
|
||||
{
|
||||
addCount = count;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.BATTLE_EXPEDITION_BOX:
|
||||
{
|
||||
addCount = count;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.HERO_QUALITY:
|
||||
{
|
||||
let quality = param[1]
|
||||
let heroes = paramObj.heroes.filter(hero => { return hero.quality == quality })
|
||||
addCount = heroes.length;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.PVP_WIN_SERIES:
|
||||
{
|
||||
addCount = count;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.PVP_WIN:
|
||||
{
|
||||
addCount = count;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.BATTLE_TOWER_LV://{towerLv}
|
||||
{
|
||||
let towerLv = paramObj.towerLv;
|
||||
if (recordData) {
|
||||
if (recordData >= towerLv) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
record = towerLv;
|
||||
addCount = towerLv;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.BATTLE_MAIN_ELITE:
|
||||
{
|
||||
if (paramObj.mainEliteWarId == param[1]) {
|
||||
addCount = count;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.BATTLE_DUNGEON_WAR:
|
||||
{
|
||||
if (paramObj.warId == param[1]) {
|
||||
addCount = count;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.HERO_NUM:
|
||||
{
|
||||
addCount = count;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.PVP:
|
||||
{
|
||||
addCount = count;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.GUILD_TRAIN_COUNT://trainId count&wardId&
|
||||
{
|
||||
if (paramObj.trainId == param[1]) {
|
||||
addCount = count;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.HERO_UNLOCK://
|
||||
{
|
||||
let camp = param[1]
|
||||
let heroes = paramObj.dicHeroes.filter(hero => { return hero.camp == camp })
|
||||
addCount = heroes.length;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.GACHA_QUALITY_COUNT://count&quality&
|
||||
{
|
||||
let quality = param[1]
|
||||
let heroes = paramObj.heroes.filter(hero => { return hero.quality == quality })
|
||||
addCount = heroes.length;
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.ROLE_TERAPH_STAGE_UP://
|
||||
{
|
||||
addCount = count;
|
||||
break;
|
||||
}
|
||||
|
||||
case TASK_TYPE.HERO_WAKE_UP_COUNT:
|
||||
{
|
||||
|
||||
let hid = paramObj.hid;
|
||||
if (recordData) {
|
||||
record = recordData;
|
||||
if (recordData.indexOf(hid) != -1) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
record = [];
|
||||
}
|
||||
|
||||
addCount = count;
|
||||
record.push(hid)
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.EQUIP_QUALITY_COUNT:
|
||||
{
|
||||
let quality = param[1]
|
||||
let equips = paramObj.equips.filter(equip => { return equip.quality == quality })
|
||||
addCount = equips.length;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
addCount = 0;
|
||||
break;
|
||||
|
||||
}
|
||||
console.log('dddddddddddd', addCount, record)
|
||||
return { addCount, record };
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建账号时临时获得可开启功能,主要用于check 主公升级任务
|
||||
* 该函数不会存储funcs,如pvp开启会在entryHandler里面再查一次funcs,那时候正式开启
|
||||
* @param dataFuncs
|
||||
* @param lv
|
||||
*/
|
||||
export async function getCreateUserFuncs(dataFuncs: number[], lv: number) {
|
||||
let addFuncs: number[] = [];
|
||||
for (let [id, dicFunSwitch] of gameData.funcsSwitch) {
|
||||
if (dataFuncs.includes(id)) continue; // 已开启过了
|
||||
|
||||
if (dicFunSwitch && lv >= dicFunSwitch.param) {
|
||||
addFuncs.push(id);
|
||||
}
|
||||
return addFuncs;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user