弹出礼包:装备精炼计算方式修改
This commit is contained in:
@@ -310,7 +310,7 @@ export class EquipHandler {
|
||||
// console.log('### incEquipStarSum', incEquipStarSum)
|
||||
let { curRole } = await calculateCeWithHero(HERO_SYSTEM_TYPE.EQUIP_STAR, roleId, serverId, sid, hid, update, { ePlaceId, skinId: hero.skinId, roleIncUpdate: { equipStarSum: incEquipStarSum } });
|
||||
|
||||
await checkTaskInEquipStarUp(serverId, roleId, sid, oldEplace, newEplace, ePlaceId, hid, isUpStar, curRole.equipStarSum, count, hero.skinId);
|
||||
checkTaskInEquipStarUp(serverId, roleId, sid, oldEplace, newEplace, ePlaceId, hid, isUpStar, count, hero.skinId);
|
||||
pushEquipStarMax(roleId, roleName, serverId, hid, newEquip, isUpStar);
|
||||
|
||||
const curHero = {
|
||||
|
||||
@@ -14,6 +14,7 @@ import { getRandEelm, getRandSingleEelm } from '../../pubUtils/util';
|
||||
import { getAllOnlineRoles } from '../redisService';
|
||||
import { GachaResultIndb } from '../../domain/activityField/gachaField';
|
||||
import { gameData } from '../../pubUtils/data';
|
||||
import { ActivityPopUpShopRecModel } from '../../db/ActivityPopUpShopRec';
|
||||
|
||||
/**
|
||||
* 玩家活动数据
|
||||
@@ -98,8 +99,15 @@ export async function checkPopUpConditions(serverId: number, roleId: string, con
|
||||
if( !pkg.checkPackageCanPush(conditionType)) { // 筛选推送
|
||||
continue;
|
||||
}
|
||||
let effectTimes = await pkg.getEffectTime();
|
||||
if(conditionType == POP_UP_SHOP_CONDITION_TYPE.EQUIP_STAR) {
|
||||
let result = await ActivityPopUpShopRecModel.addRecord(serverId, activityId, roleId, pkg.id, effectTimes.effectBeginTime, effectTimes.effectEndTime, conditionType, param.equipStar);
|
||||
param.equipStarSum = result.num;
|
||||
}
|
||||
|
||||
let items = pkg.getItemsByCondition(param);
|
||||
if(items.length > 0) {
|
||||
|
||||
let map = new Map<string, PopShopItem[]>();
|
||||
for(let item of items) {
|
||||
if(!map.has(item.param)) {
|
||||
@@ -108,7 +116,6 @@ export async function checkPopUpConditions(serverId: number, roleId: string, con
|
||||
map.get(item.param).push(item);
|
||||
}
|
||||
for(let [_, items] of map) {
|
||||
let effectTimes = await pkg.getEffectTime();
|
||||
let popUpShopRec = await ActivityPopUpShopModel.createRecord({
|
||||
serverId, activityId, roleId, id: pkg.id,
|
||||
...effectTimes,
|
||||
@@ -120,12 +127,12 @@ export async function checkPopUpConditions(serverId: number, roleId: string, con
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log('##### 5', pushItems.length)
|
||||
// console.log('##### 5', pushItems.length)
|
||||
if(pushItems.length > 0) {
|
||||
pushData.push({ activityId, activityType, param: { popUpShopItems: pushItems } });
|
||||
}
|
||||
}
|
||||
console.log('##### 6', pushData.length)
|
||||
// console.log('##### 6', pushData.length)
|
||||
return await pushActivities(pushData, roleId, sid);
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import { checkPopUpCondition, checkPopUpConditionInCreateHero, checkPopUpConditi
|
||||
import { sendMessageToUserWithSuc } from '../pushService';
|
||||
import { getGoldId } from '../role/rewardService';
|
||||
import { GachaResultIndb } from '../../domain/activityField/gachaField';
|
||||
import { ActivityPopUpShopRecModel } from '../../db/ActivityPopUpShopRec';
|
||||
|
||||
export async function checkTaskWithRoles(serverId: number, roleId: string, sid: string, taskType: TASK_TYPE, roles: RoleType[]) {
|
||||
for (let role of roles) {
|
||||
@@ -269,7 +270,7 @@ export async function checkTaskInPutStone(serverId: number, roleId: string, sid:
|
||||
await task.saveAndPush(sid);
|
||||
}
|
||||
|
||||
export async function checkTaskInEquipStarUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, hid: number, isUpStar: boolean, equipStarSum: number, count: number, skinId: number) {
|
||||
export async function checkTaskInEquipStarUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, hid: number, isUpStar: boolean, count: number, skinId: number) {
|
||||
let task = new CheckTask(serverId, roleId);
|
||||
if(isUpStar) {
|
||||
let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId);
|
||||
@@ -280,7 +281,7 @@ export async function checkTaskInEquipStarUp(serverId: number, roleId: string, s
|
||||
task.setParam(TASK_TYPE.EQUIP_STAR_UP_CNT_SUM, { count });
|
||||
await task.saveAndPush(sid);
|
||||
if(isUpStar) {
|
||||
checkPopUpCondition(serverId, roleId, POP_UP_SHOP_CONDITION_TYPE.EQUIP_STAR, { equipStar: equipStarSum }, sid);
|
||||
checkPopUpCondition(serverId, roleId, POP_UP_SHOP_CONDITION_TYPE.EQUIP_STAR, { equipStar: count }, sid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
46
shared/db/ActivityPopUpShopRec.ts
Normal file
46
shared/db/ActivityPopUpShopRec.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
|
||||
/**
|
||||
* 活动系统 - 弹出商店的记录
|
||||
*/
|
||||
@index({ roleId: 1, effectBeginTime: 1, effectEndTime: 1 })
|
||||
|
||||
export default class Activity_Pop_Up_Shop_Rec extends BaseModel {
|
||||
@prop({ required: true })
|
||||
serverId: number; // 服id
|
||||
|
||||
@prop({ required: true })
|
||||
activityId: number; // 活动Id
|
||||
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
|
||||
@prop({ required: true })
|
||||
effectBeginTime: Date; // 刷新等生效开始时间
|
||||
|
||||
@prop({ required: true })
|
||||
effectEndTime: Date; // 刷新等生效结束时间
|
||||
|
||||
@prop({ required: true })
|
||||
id: number; // 礼包id
|
||||
|
||||
@prop({ required: true })
|
||||
conditionType: number; // 礼包id
|
||||
|
||||
@prop({ required: true })
|
||||
num: number; // 值
|
||||
|
||||
public static async addRecord(serverId: number, activityId: number, roleId: string, id: number, effectBeginTime: Date, effectEndTime: Date, conditionType: number, num: number) {
|
||||
let rec: ActivityPopUpShopRecModelType = await ActivityPopUpShopRecModel.findOneAndUpdate(
|
||||
{ roleId, serverId, activityId, effectBeginTime, effectEndTime, id },
|
||||
{ $inc: { num }, $setOnInsert: { conditionType } },
|
||||
{ new: true, upsert: true }).lean();
|
||||
return rec;
|
||||
}
|
||||
}
|
||||
|
||||
export const ActivityPopUpShopRecModel = getModelForClass(Activity_Pop_Up_Shop_Rec);
|
||||
|
||||
export interface ActivityPopUpShopRecModelType extends Pick<DocumentType<Activity_Pop_Up_Shop_Rec>, keyof Activity_Pop_Up_Shop_Rec> { }
|
||||
export type ActivityPopUpShopRecModelTypeParam = Partial<ActivityPopUpShopRecModelType>; // 将所有字段变成可选项
|
||||
@@ -433,7 +433,7 @@ export class PopShopItem {
|
||||
case POP_UP_SHOP_CONDITION_TYPE.PVP:
|
||||
return param.seasonWinNum >= this.conditionParam[0];
|
||||
case POP_UP_SHOP_CONDITION_TYPE.EQUIP_STAR:
|
||||
return param.equipStar >= this.conditionParam[0];
|
||||
return param.equipStarSum >= this.conditionParam[0];
|
||||
case POP_UP_SHOP_CONDITION_TYPE.AUCTION:
|
||||
return true;
|
||||
case POP_UP_SHOP_CONDITION_TYPE.TITLE:
|
||||
@@ -505,6 +505,7 @@ export interface PopUpConditionParamInter {
|
||||
warId?: number;
|
||||
seasonWinNum?: number;
|
||||
equipStar?: number;
|
||||
equipStarSum?: number;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user