✨ feat(活动): 节日活动-火神祭祀
This commit is contained in:
@@ -23,10 +23,11 @@ import { calculateCeWithHero, calculateCeWithRole } from '../playerCeService';
|
||||
import { sendMessageToUserWithSuc } from '../pushService';
|
||||
import { filterGoods } from '../dataService';
|
||||
import { ArtifactModel, ArtifactModelType, ArtifactModelUpdate } from '../../db/Artifact';
|
||||
import { ActivityItemModel } from '../../db/ActivityItem';
|
||||
|
||||
export async function handleCost(roleId: string, sid: string, goods: Array<ItemInter>, reason: ITEM_CHANGE_REASON) {
|
||||
|
||||
let { items, jewels, gold, coin, artifacts } = sortItems(goods, HANDLE_REWARD_TYPE.COST);
|
||||
let { items, jewels, gold, coin, artifacts, activityItems } = sortItems(goods, HANDLE_REWARD_TYPE.COST);
|
||||
let jewelSeqIds = jewels.map(cur => cur.seqId);
|
||||
let resJewels: JewelType[] = [];
|
||||
let artifactSeqIds = artifacts.map(cur => cur.seqId);
|
||||
@@ -59,6 +60,13 @@ export async function handleCost(roleId: string, sid: string, goods: Array<ItemI
|
||||
sendMessageToUserWithSuc(roleId, PUSH_ROUTE.ITEM_UPDATE, { goods: result.map(cur => ({...cur, reason })) }, sid);
|
||||
saveItemChangeLog(roleId, result, reason);
|
||||
}
|
||||
//检查并修改道具
|
||||
if (activityItems.length > 0) {
|
||||
let { hasError, result } = await ActivityItemModel.decreaseActivityItems(roleId, activityItems);
|
||||
if (hasError) return false;
|
||||
sendMessageToUserWithSuc(roleId, PUSH_ROUTE.ACTIVITY_ITEM_UPDATE, { goods: result.map(cur => ({...cur, reason })) }, sid);
|
||||
saveItemChangeLog(roleId, result, reason);
|
||||
}
|
||||
|
||||
//删除装备
|
||||
if (resJewels.length > 0) {
|
||||
@@ -136,8 +144,8 @@ export async function handleCost(roleId: string, sid: string, goods: Array<ItemI
|
||||
|
||||
export async function addItems(roleId: string, roleName: string, sid: string, goods: Array<ItemInter>, reason: ITEM_CHANGE_REASON) {
|
||||
goods = filterGoods(goods, obj => obj.id, roleId, reason);
|
||||
let { items, jewels, gold, coin, ap, skins, figures, artifacts } = sortItems(goods, HANDLE_REWARD_TYPE.RECEIVE);
|
||||
let showItems: { id: number, seqId?: number, count: number, isBag?: boolean }[] = [];
|
||||
let { items, jewels, gold, coin, ap, skins, figures, artifacts, activityItems } = sortItems(goods, HANDLE_REWARD_TYPE.RECEIVE);
|
||||
let showItems: { id: number, seqId?: number, count: number, isBag?: boolean, expireTime?: number }[] = [];
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
// 1. 装备处理
|
||||
if(jewels.length > 0) {
|
||||
@@ -283,6 +291,19 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
|
||||
}
|
||||
}
|
||||
|
||||
// 7. 活动道具处理
|
||||
if(activityItems.length > 0) {
|
||||
let { items: itemInfos } = await addActivityItems(roleId, roleName, activityItems, reason);
|
||||
for (let item of activityItems) {
|
||||
showItems.push({ id: item.id, count: item.count, expireTime: item.expireTime });
|
||||
}
|
||||
//背包除去装备推送
|
||||
if (!!itemInfos.length) {
|
||||
sendMessageToUserWithSuc(roleId, PUSH_ROUTE.ACTIVITY_ITEM_UPDATE, { goods: itemInfos }, sid);
|
||||
saveItemChangeLog(roleId, itemInfos, reason);
|
||||
}
|
||||
|
||||
}
|
||||
return showItems;
|
||||
}
|
||||
|
||||
@@ -439,6 +460,21 @@ export async function addBag(roleId: string, roleName: string, data: { id: numbe
|
||||
return { id: item.id, count: item.count, inc: count, reason };
|
||||
}
|
||||
|
||||
export async function addActivityItems(roleId: string, roleName: string, datas: { id: number, count: number, expireTime?: number }[], reason: number) {
|
||||
let items: { id: number, count: number, inc: number, expireTime: number }[] = [];
|
||||
for(let data of datas) {
|
||||
let item = await addActivityItem(roleId, roleName, data, reason);
|
||||
items.push(item)
|
||||
}
|
||||
return { items }
|
||||
}
|
||||
|
||||
export async function addActivityItem(roleId: string, roleName: string, data: { id: number, count: number, expireTime?: number }, reason: number) {
|
||||
let { id, count, expireTime } = data;
|
||||
let { name: itemName, itid } = gameData.goods.get(id);
|
||||
let item = await ActivityItemModel.increaseActivityItem(roleId, id, count, { roleId, roleName, itemName, id, expireTime });
|
||||
return { id: item.id, count: item.count, inc: count, expireTime: item.expireTime, reason };
|
||||
}
|
||||
|
||||
export async function addJewels(roleId: string, roleName: string, jewels: { id: number, }[], reason: number) {
|
||||
let jewelInfo: jewelUpdate[] = [];
|
||||
|
||||
Reference in New Issue
Block a user