✨ feat(活动): 节日活动-火神祭祀
This commit is contained in:
@@ -59,6 +59,8 @@ export enum ACTIVITY_TYPE {
|
||||
SHOP = 44, // 限时商店
|
||||
GUIDE_GACHA = 45, // 500抽
|
||||
POP_NOTICE = 46, // 打脸公告
|
||||
MINI_GAME = 47, // 小游戏
|
||||
FORGE = 48, // 火神祭祀
|
||||
GROUP_SHOP = 49, // 团购
|
||||
BIND_PHONE = 50, // 绑定手机号
|
||||
}
|
||||
|
||||
@@ -171,6 +171,7 @@ export const PUSH_ROUTE = {
|
||||
HERO_SKIN_CHANGE: 'onHeroSkinChange',
|
||||
HERO_UPDATE: 'onHeroUpdate',
|
||||
ITEM_UPDATE: 'onItemUpdate',
|
||||
ACTIVITY_ITEM_UPDATE: 'onActivityItemUpdate',
|
||||
JEWEL_DEL: 'onJewelDel',
|
||||
JEWEL_ADD: 'onJewelAdd',
|
||||
ARTIFACT_DEL: 'onArtifactDel',
|
||||
|
||||
@@ -98,6 +98,7 @@ export const ITEM_TABLE = {
|
||||
SKIN: 'skin',
|
||||
JEWEL: 'jewel',
|
||||
ARTIFACT: 'artifact',
|
||||
ACTIVITY_ITEM: 'activityItem',
|
||||
}
|
||||
|
||||
const itid_array = [
|
||||
@@ -153,6 +154,7 @@ const itid_array = [
|
||||
{ id: 63, name: '代金券', table: 'item', type: CONSUME_TYPE.VOUCHER },
|
||||
{ id: 64, name: '宝物', table: 'artifact' },
|
||||
{ id: 65, name: '宝物通用材料', table: 'item', type: CONSUME_TYPE.ARTIFACT_GENERAL },
|
||||
{ id: 66, name: '活动限时材料', table: 'activityItem' },
|
||||
];
|
||||
|
||||
export const ITID = new Map<number, { id: number, name: string, table: string, type?: number, isCurrency?: boolean, equipJewel?: number }>();
|
||||
|
||||
@@ -57,7 +57,7 @@ export enum FRIEND_SHIP_SELECT {
|
||||
GET_FRIEND_VALUE = 'friendValue friendLv'
|
||||
}
|
||||
|
||||
export const ENTERY_ROLE_PICK = ['roleId', 'roleName', 'serverId', 'ce', 'topLineupCe', 'coin', 'lv', 'exp', 'vLv', 'gold', 'heros', 'jewels', 'artifacts', 'consumeGoods', 'title', 'teraphs', 'showLineup', 'heads', 'head', 'frames', 'frame', 'spines', 'spine', 'hasGuild', 'guildCode', 'todayZeroPoint', 'apJson', 'skins', 'totalPay', 'guide', 'hasInit', 'renameCnt', 'totalCost', 'guildName', 'isVip', 'createTime', 'ipLocation'];
|
||||
export const ENTERY_ROLE_PICK = ['roleId', 'roleName', 'serverId', 'ce', 'topLineupCe', 'coin', 'lv', 'exp', 'vLv', 'gold', 'heros', 'jewels', 'artifacts', 'consumeGoods', 'title', 'teraphs', 'showLineup', 'heads', 'head', 'frames', 'frame', 'spines', 'spine', 'hasGuild', 'guildCode', 'todayZeroPoint', 'apJson', 'skins', 'totalPay', 'guide', 'hasInit', 'renameCnt', 'totalCost', 'guildName', 'isVip', 'createTime', 'ipLocation', 'activityItems'];
|
||||
|
||||
export enum SURVEY_SELECT {
|
||||
FIND = '-__v -_id -surveyName -roleIndex -reward -mailContent -receivedRole -createdAt -updatedAt'
|
||||
@@ -66,3 +66,7 @@ export enum SURVEY_SELECT {
|
||||
export enum ARTIFACT_SELECT {
|
||||
ENTRY = '-_id -__v -roleId -roleName -createdAt -updatedAt -status'
|
||||
}
|
||||
|
||||
export enum ACTIVITYITEM_SELECT {
|
||||
ENTRY = '-_id -__v -roleId -roleName -itemName -createdAt -updatedAt'
|
||||
}
|
||||
|
||||
@@ -1140,6 +1140,8 @@ export enum ITEM_CHANGE_REASON {
|
||||
GVG_REVIVE = 174, // gvg复活队伍
|
||||
GVG_USE_ITEM = 175, // gvg使用连弩
|
||||
ARTIFACT_LV_RETURN = 176, // 宝物继承等级返还
|
||||
ACT_FORGE_BUILD = 177, // 火神祭祀锻造
|
||||
ACT_FORGE_HELP = 178, // 火神祭祀失败补助
|
||||
}
|
||||
|
||||
export enum TA_EVENT {
|
||||
|
||||
@@ -644,6 +644,11 @@ export const STATUS = {
|
||||
ACTIVITY_BIND_ERR: { code: 50042, simStr: '清先绑定手机' },
|
||||
ACTIVITY_BIND_RECEIVED: { code: 50043, simStr: '奖励已领取过' },
|
||||
ACTIVITY_HAS_BIND: { code: 50044, simStr: '已绑定' },
|
||||
ACTIVITY_MANUAL_NOT_FOUND: { code: 50045, simStr: '图谱未找到' },
|
||||
ACTIVITY_MANUAL_DAY_LOCK: { code: 50046, simStr: '该图谱今天未解锁' },
|
||||
ACTIVITY_BUILD_COUNT: { code: 50047, simStr: '铸造次数已满' },
|
||||
ACTIVITY_BUY_CNT_MAX: { code: 50048, simStr: '该图谱购买次数已达上限' },
|
||||
ACTIVITY_MATERIAL_COUNT_NOT_ZERO: { code: 50049, simStr: '材料数量不可为0' },
|
||||
|
||||
// GM后台相关状态 60000 - 69999
|
||||
GM_ERR_PASSWORD: { code: 60001, simStr: '账号或密码错误' },
|
||||
|
||||
65
shared/db/ActivityForge.ts
Normal file
65
shared/db/ActivityForge.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
|
||||
/**
|
||||
* 火神祭祀
|
||||
*/
|
||||
|
||||
class ForgeRecord {
|
||||
@prop({ required: true })
|
||||
todayIndex: number;
|
||||
|
||||
@prop({ required: true })
|
||||
material: string;
|
||||
|
||||
@prop({ required: true })
|
||||
isSuccess: boolean;
|
||||
}
|
||||
|
||||
@index({ roleId: 1, activityId: 1 })
|
||||
|
||||
export default class Activity_Forge extends BaseModel {
|
||||
@prop({ required: true })
|
||||
serverId: number; // 服Id
|
||||
|
||||
@prop({ required: true })
|
||||
activityId: number; // 活动Id
|
||||
|
||||
@prop({ required: true })
|
||||
roundIndex: number; // 活动Id
|
||||
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
|
||||
@prop({ required: true })
|
||||
manualId: number; // 图谱id
|
||||
|
||||
@prop({ required: true })
|
||||
buildCnt: number; // 铸造次数
|
||||
|
||||
@prop({ required: true })
|
||||
buyCnt: number; // 购买次数
|
||||
|
||||
@prop({ required: true, type: ForgeRecord, _id: false })
|
||||
record: ForgeRecord[]; // 铸造记录
|
||||
|
||||
public static async findData(serverId: number, activityId: number, roundIndex: number, roleId: string) {
|
||||
let result: ActivityForgeModelType[] = await ActivityForgeModel.find({ serverId, roleId, activityId, roundIndex }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async build(serverId: number, activityId: number, roleId: string, roundIndex: number, manualId: number, record: ForgeRecord) {
|
||||
let result: ActivityForgeModelType = await ActivityForgeModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, manualId }, { $inc: { buildCnt: record.isSuccess? 1: 0 }, $push: { record } }, { new: true, upsert: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async buyCnt(serverId: number, activityId: number, roleId: string, roundIndex: number, manualId: number, count: number) {
|
||||
let result: ActivityForgeModelType = await ActivityForgeModel.findOneAndUpdate({ serverId, roleId, activityId, manualId, roundIndex }, { $inc: { buyCnt: count } }, { new: true, upsert: true }).lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const ActivityForgeModel = getModelForClass(Activity_Forge);
|
||||
|
||||
export interface ActivityForgeModelType extends Pick<DocumentType<Activity_Forge>, keyof Activity_Forge> { }
|
||||
export type ActivityForgeModelTypeParam = Partial<ActivityForgeModelType>; // 将所有字段变成可选项
|
||||
85
shared/db/ActivityItem.ts
Normal file
85
shared/db/ActivityItem.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
|
||||
import { BAG } from '../pubUtils/dicParam';
|
||||
import { nowSeconds } from '../pubUtils/timeUtil';
|
||||
|
||||
@index({ roleId: 1, id: 1 })
|
||||
@modelOptions({ schemaOptions: { id: false } })
|
||||
export default class ActivityItem extends BaseModel {
|
||||
@prop({ required: true, default: '' })
|
||||
roleId: string; // 角色 id
|
||||
@prop({ required: true, default: '' })
|
||||
roleName: string; // 角色名称
|
||||
|
||||
@prop({ required: true, default: '' })
|
||||
id: number; // 道具 id
|
||||
@prop({ required: true, default: '' })
|
||||
itemName: string; // 道具名称
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
expireTime: number; // 限时
|
||||
|
||||
@prop({ required: true })
|
||||
count: number; // 道具数量
|
||||
|
||||
|
||||
public static async findbyRole(roleId: string, select = '') {
|
||||
const items: ActivityItemType[] = await ActivityItemModel.find({ roleId, count: {$gte: 0}, expireTime: { $gte: nowSeconds() } }).select(select).lean();
|
||||
return items;
|
||||
}
|
||||
|
||||
public static async findbyRoleAndIds(roleId: string, ids: Array<number>, lean = true) {
|
||||
const items: ActivityItemType[] = await ActivityItemModel.find({ roleId, id: { $in: ids }, count: {$gte: 0}, expireTime: { $gte: nowSeconds() } }).select('id count expireTime').lean(lean);
|
||||
return items;
|
||||
}
|
||||
|
||||
public static async findbyRoleAndGid(roleId: string, id: number, lean = true) {
|
||||
const items: ActivityItemType = await ActivityItemModel.findOne({ roleId, id }).select('id count expireTime').lean(lean);
|
||||
return items;
|
||||
}
|
||||
|
||||
public static async increaseActivityItem(roleId: string, id: number, count: number, itemInfo: { roleId: string, roleName: string, id: number, itemName: string, expireTime?: number }) {
|
||||
const doc = new ActivityItemModel();
|
||||
const setOnInsert = Object.assign(doc.toJSON(), itemInfo);
|
||||
delete setOnInsert.expireTime;
|
||||
let items: ActivityItemType = await ActivityItemModel.findOneAndUpdate({ roleId, id, expireTime: { $gte: nowSeconds() } }, { $setOnInsert: setOnInsert, $inc: { count }, $set: { expireTime: itemInfo.expireTime } }, { new: true, upsert: true }).lean();
|
||||
if(items.count > BAG.BAG_GOODS_UPLIMITED) {
|
||||
items = await ActivityItemModel.findOneAndUpdate({ roleId, id, count: { $gte: BAG.BAG_GOODS_UPLIMITED }, expireTime: { $gte: nowSeconds() } }, { $set: { count: BAG.BAG_GOODS_UPLIMITED, expireTime: itemInfo.expireTime } }, { new: true }).lean();
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
public static async decreaseActivityItems(roleId: string, items: Array<{ id: number, count: number }>, lean = true) {
|
||||
let updateActivityItems = new Array<{ id: number, count: number }>(), hasError: boolean = false, result = new Array();
|
||||
for (let { id, count } of items) {
|
||||
let rec: ActivityItemType = await ActivityItemModel.findOneAndUpdate({ roleId, id, count: { $gte: count }, expireTime: { $gte: nowSeconds() } }, { $inc: { count: -1 * count } }, { new: true }).lean(lean);
|
||||
if (!!rec) {
|
||||
let index = result.findIndex(cur => cur.id == rec.id);
|
||||
if (index != -1) {
|
||||
result[index].count = rec.count;
|
||||
result[index].inc += -count;
|
||||
} else {
|
||||
result.push({ id: rec.id, count: rec.count, expireTime: rec.expireTime, inc: -count });
|
||||
}
|
||||
updateActivityItems.push({ id, count });
|
||||
} else {
|
||||
hasError = true; break;
|
||||
}
|
||||
}
|
||||
if (hasError) { // 数量不足
|
||||
for (let { id, count } of updateActivityItems) {
|
||||
await ActivityItemModel.findOneAndUpdate({ roleId, id, expireTime: { $gte: nowSeconds() } }, { $inc: { count: -count } }, { new: true }).lean(lean);
|
||||
}
|
||||
return { hasError: true }
|
||||
} else {
|
||||
return { hasError: false, result }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ActivityItemModel = getModelForClass(ActivityItem);
|
||||
|
||||
export interface ActivityItemType extends Pick<DocumentType<ActivityItem>, keyof ActivityItem> {
|
||||
id: number;
|
||||
};
|
||||
134
shared/domain/activityField/forgeField.ts
Normal file
134
shared/domain/activityField/forgeField.ts
Normal file
@@ -0,0 +1,134 @@
|
||||
// 节日活动 - 火神祭祀
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityForgeModelType } from '../../db/ActivityForge';
|
||||
import { parseGoodStr } from '../../pubUtils/util';
|
||||
import { ActivityBase } from './activityField';
|
||||
|
||||
// 后台格式
|
||||
|
||||
interface ForgeManualInDb {
|
||||
id: number; // 图谱id
|
||||
name: string; // 图谱名
|
||||
imageName: string; // 图片
|
||||
dayIndex: number; // 第几天解锁
|
||||
material: string; // 配方比例id&count
|
||||
totalMaterialCnt: number; // 最大材料数量
|
||||
quality: number; // 品质
|
||||
reward: string; // 铸造成功可获得的奖励,id&count
|
||||
freeCnt: number; // 可免费铸造次数(总)
|
||||
maxBuyCnt: number; // 最大可购买次数(总)
|
||||
}
|
||||
|
||||
interface ForgeHintInDb {
|
||||
failCnt: number;
|
||||
hintType: number; // 1-提示总额 2-提示材料多了还是少了 3-材料具体配比提示
|
||||
}
|
||||
|
||||
interface ForgeDataInDb {
|
||||
manuals: ForgeManualInDb[]; // 图谱
|
||||
consume: string; // 购买铸造次数消耗的元宝
|
||||
hint: ForgeHintInDb[]; // 失败提示法
|
||||
}
|
||||
|
||||
// 商品数据
|
||||
export class ForgeManual {
|
||||
id: number; // 图谱id
|
||||
name: string; // 图谱名
|
||||
imageName: string; // 图片
|
||||
dayIndex: number; // 第几天解锁
|
||||
material: string; // id&count,正确的配比
|
||||
reward: string; // 铸造成功可获得的奖励,id&count
|
||||
freeCnt: number; // 可免费铸造次数
|
||||
maxBuyCnt: number; // 今天可以购买的次数
|
||||
totalMaterialCnt: number; // 最大材料数量
|
||||
quality: number; // 品质
|
||||
|
||||
buildCnt: number = 0; // 已经铸造了的次数 buildCnt < freeCnt + buyCnt
|
||||
buyCnt: number = 0; // 今天已购买次数
|
||||
failCnt: number = 0; // 猜错的次数
|
||||
|
||||
hintType: number = 0; // 应该给的提示类型 1-总数提示 2-材料多了少了的提示 3-具体配比提示
|
||||
|
||||
constructor(data: ForgeManualInDb) {
|
||||
this.id = data.id;
|
||||
this.name = data.name;
|
||||
this.imageName = data.imageName;
|
||||
this.dayIndex = data.dayIndex;
|
||||
this.material = data.material;
|
||||
this.reward = data.reward;
|
||||
this.freeCnt = data.freeCnt;
|
||||
this.maxBuyCnt = data.maxBuyCnt;
|
||||
this.totalMaterialCnt = data.totalMaterialCnt;
|
||||
this.quality = data.quality;
|
||||
}
|
||||
|
||||
public setPlayerData(playerData: ActivityForgeModelType, todayIndex: number) {
|
||||
this.buildCnt = playerData.buildCnt||0;
|
||||
this.buyCnt = playerData.buyCnt||0;
|
||||
let todayFailRecord = playerData.record?.filter(cur => cur.todayIndex == todayIndex && cur.isSuccess == false)||[];
|
||||
this.failCnt = todayFailRecord.length;
|
||||
}
|
||||
|
||||
public calHintType(hintDic: ForgeHintInDb[]) {
|
||||
for(let { failCnt, hintType } of hintDic) {
|
||||
if(this.failCnt < failCnt) {
|
||||
this.hintType = hintType; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public checkMaterial(playerMaterial: { id: number, count: number }[]) {
|
||||
let configMaterial = parseGoodStr(this.material);
|
||||
for(let { id, count } of configMaterial) {
|
||||
let playerCount = playerMaterial.find(cur => cur.id == id)?.count||0;
|
||||
if(playerCount != count) return false;
|
||||
}
|
||||
for(let { id, count } of playerMaterial) {
|
||||
let configCount = configMaterial.find(cur => cur.id == id)?.count||0;
|
||||
if(configCount != count) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export class ForgeData extends ActivityBase {
|
||||
manuals: ForgeManual[] = []; // 图谱
|
||||
consume: string; // 购买铸造次数的消耗
|
||||
hint: ForgeHintInDb[];
|
||||
|
||||
constructor(activityData: ActivityModelType, createTime: number, serverTime: number) {
|
||||
super(activityData, createTime, serverTime)
|
||||
this.initData(activityData.data)
|
||||
}
|
||||
|
||||
public initData(data: string): void {
|
||||
let dataObj: ForgeDataInDb = JSON.parse(data);
|
||||
if(!dataObj) return;
|
||||
|
||||
this.hint = dataObj.hint||[];
|
||||
this.consume = dataObj.consume||'';
|
||||
for(let data of (dataObj.manuals||[])) {
|
||||
this.manuals.push(new ForgeManual(data));
|
||||
}
|
||||
}
|
||||
|
||||
public setPlayerRecords(playerData: ActivityForgeModelType[]) {
|
||||
for(let data of playerData) {
|
||||
let manual = this.manuals.find(cur => cur.id == data.manualId);
|
||||
if(manual) manual.setPlayerData(data, this.todayIndex);
|
||||
manual.calHintType(this.hint);
|
||||
}
|
||||
}
|
||||
|
||||
public findManual(id: number) {
|
||||
return this.manuals.find(cur => cur.id == id);
|
||||
}
|
||||
|
||||
public getShowResult() {
|
||||
return {
|
||||
...this.getBaseKeys(),
|
||||
manuals: this.manuals,
|
||||
consume: this.consume
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ interface RefreshShopDataInDb {
|
||||
interface RefreshShopPageInDb {
|
||||
pageIndex: number;
|
||||
viewcount: number;
|
||||
preNeedBuyCnt: number; // 添加:上一页需要购买的
|
||||
name: string;
|
||||
items: RefreshShopItemInDb[]
|
||||
}
|
||||
@@ -88,6 +89,7 @@ export class RefreshShopPage {
|
||||
pageIndex: number; // 第几页
|
||||
name: string; //名字
|
||||
viewCount: number; //随机可购买的商品个数
|
||||
preNeedBuyCnt: number; // 添加:上一页需要购买的
|
||||
items: Array<RefreshShopItem> = [];//商品列表
|
||||
constructor(data: RefreshShopPageInDb) {
|
||||
this.pageIndex = data.pageIndex;
|
||||
@@ -95,6 +97,7 @@ export class RefreshShopPage {
|
||||
for (let item of data.items) {
|
||||
this.items.push(new RefreshShopItem(item, data.pageIndex))
|
||||
}
|
||||
this.preNeedBuyCnt = data.preNeedBuyCnt;
|
||||
this.viewCount = data.viewcount ? data.viewcount : this.items.length;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,5 @@ export interface RewardParam {
|
||||
type: number;
|
||||
id: number;
|
||||
count: number;
|
||||
expireTime?: number;
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import { UserGuildType } from "../db/UserGuild";
|
||||
export interface RewardInter {
|
||||
id: number;
|
||||
count: number;
|
||||
expireTime?: number;
|
||||
}
|
||||
|
||||
export interface ItemInter {
|
||||
@@ -14,6 +15,7 @@ export interface ItemInter {
|
||||
type?: number;
|
||||
isPay?: boolean;
|
||||
hid?: number;
|
||||
expireTime?: number;
|
||||
};
|
||||
|
||||
// 百家学宫,布阵武将位置
|
||||
|
||||
@@ -251,6 +251,18 @@
|
||||
"name": "POP_NOTICE",
|
||||
"string": "打脸公告"
|
||||
},
|
||||
{
|
||||
"id": 47,
|
||||
"activityType": 47,
|
||||
"name": "MINI_GAME",
|
||||
"string": "小游戏"
|
||||
},
|
||||
{
|
||||
"id": 48,
|
||||
"activityType": 48,
|
||||
"name": "FORGE",
|
||||
"string": "火神祭祀"
|
||||
},
|
||||
{
|
||||
"id": 49,
|
||||
"activityType": 49,
|
||||
|
||||
Reference in New Issue
Block a user