✨ feat(百家争鸣):祈灵 更新至 eb9f941ae
This commit is contained in:
@@ -71,6 +71,7 @@ export enum ACTIVITY_TYPE {
|
||||
ENTERTAIN = 56, // 宴请百家
|
||||
QIXI = 57, // 七夕活动
|
||||
MID_AUTUMN = 58, // 中秋活动
|
||||
AUTHOR_GACHA = 59, //百家争鸣祈灵活动
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -653,7 +653,7 @@ export const FILENAME = {
|
||||
DIC_AUTHORS_BOOK_POINT: 'dic_zyz_authorsBookPoint',
|
||||
DIC_AUTHORS_BOOK_SUB: 'dic_zyz_authorsBookSub',
|
||||
DIC_AUTHORS_GOODID: 'dic_zyz_authorsGoodId',
|
||||
DIC_BOSS_RANK_ACTIVE_POINT:'dic_zyz_bossRank_activePoint',
|
||||
DIC_BOSS_RANK_ACTIVE_POINT: 'dic_zyz_bossRank_activePoint',
|
||||
}
|
||||
|
||||
export const WAR_RELATE_TABLES = [
|
||||
@@ -907,6 +907,7 @@ export enum GACHA_TYPE {
|
||||
ASSIGN = 3, // 指定卡池
|
||||
GUIDE = 4, // 限时
|
||||
ACTIVITY = 5, // 新武将活动
|
||||
TAUTOR=6, // 百家争鸣祈灵
|
||||
}
|
||||
|
||||
export enum GACHA_PLAN_TYPE {
|
||||
@@ -1209,6 +1210,7 @@ export enum ITEM_CHANGE_REASON {
|
||||
BUY_SPIRIT = 194, // 购买英灵
|
||||
QIXI_REWARD = 195, // 七夕活动奖励
|
||||
MID_AUTUMN_REWARD = 196, // 中秋活动奖励
|
||||
AUTHOR_GACHA_REWARD = 197, // 百家争鸣祈灵奖励
|
||||
}
|
||||
|
||||
export enum TA_EVENT {
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import { getModelForClass, prop, DocumentType, index } from "@typegoose/typegoose";
|
||||
import BaseModel from "./BaseModel";
|
||||
|
||||
|
||||
/**
|
||||
* 百家争鸣祈灵
|
||||
*/
|
||||
|
||||
@index({ serverId: 1, activityId: 1, roundIndex: 1, roleId: 1 })
|
||||
|
||||
export default class Activity_AuthorGacha_Rec extends BaseModel {
|
||||
@prop({ required: true })
|
||||
serverId: number; // 服Id
|
||||
|
||||
@prop({ required: true })
|
||||
activityId: number; // 活动Id
|
||||
|
||||
@prop({ required: true })
|
||||
roundIndex: number; // 第几轮
|
||||
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
gachaId: number;
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
gachaCnt: number; // 累计抽奖次数
|
||||
|
||||
@prop({ required: true, type: Number, default: [] })
|
||||
record: number[]; // 领取奖励标记
|
||||
|
||||
|
||||
public static async findData(serverId: number, activityId: number, roundIndex: number, roleId: string) {
|
||||
let result: ActivityAuthorGachaRecModelType = await ActivityAuthorGachaRecModel.findOne({ serverId, roleId, activityId, roundIndex }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async updateGachaCnt(serverId: number, activityId: number, roundIndex: number, roleId: string, gachaId: number, gachaCnt: number) {
|
||||
let result: ActivityAuthorGachaRecModelType = await ActivityAuthorGachaRecModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex }, { $set: { gachaId }, $inc: { gachaCnt } }, { new: true, upsert: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async record(serverId: number, activityId: number, roundIndex: number, roleId: string, record: number) {
|
||||
let result: ActivityAuthorGachaRecModelType = await ActivityAuthorGachaRecModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex }, { $push: { record } }, { new: true, upsert: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const ActivityAuthorGachaRecModel = getModelForClass(Activity_AuthorGacha_Rec);
|
||||
|
||||
export interface ActivityAuthorGachaRecModelType extends Pick<DocumentType<Activity_AuthorGacha_Rec>, keyof Activity_AuthorGacha_Rec> { }
|
||||
export type ActivityAuthorGachaRecModelTypeParam = Partial<ActivityAuthorGachaRecModelType>; // 将所有字段变成可选项
|
||||
@@ -0,0 +1,61 @@
|
||||
// 百家争鸣活动 - 祈灵
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityAuthorGachaRecModelType } from '../../db/AuthorGachaRec';
|
||||
import { ActivityBase } from './activityField';
|
||||
|
||||
// 后台格式
|
||||
interface AuthorGachaDataInDb {
|
||||
gachaId: number; // 卡池
|
||||
box: {
|
||||
count: number; // 次数
|
||||
rewards: string; // type&id&count, type: 1-武将 2-道具 3-礼包
|
||||
hasReceived?: boolean; // 是否获得
|
||||
}[];
|
||||
}
|
||||
|
||||
export class AuthorGachaData extends ActivityBase {
|
||||
gachaId: number;
|
||||
box: AuthorGachaDataInDb['box'] = [];
|
||||
|
||||
gachaCnt: number = 0;
|
||||
record: number[] = [];
|
||||
|
||||
constructor(activityData: ActivityModelType, createTime: number, serverTime: number) {
|
||||
super(activityData, createTime, serverTime)
|
||||
this.initData(activityData.data)
|
||||
}
|
||||
|
||||
public initData(data: string): void {
|
||||
let dataObj: AuthorGachaDataInDb = JSON.parse(data);
|
||||
if (!dataObj) return;
|
||||
|
||||
this.gachaId = dataObj.gachaId;
|
||||
this.box = dataObj.box;
|
||||
}
|
||||
|
||||
public setPlayerRecords(playerData: ActivityAuthorGachaRecModelType) {
|
||||
this.updatePlayerRecord(playerData);
|
||||
}
|
||||
|
||||
public updatePlayerRecord(playerData: ActivityAuthorGachaRecModelType) {
|
||||
if (!playerData) return;
|
||||
this.gachaCnt = playerData?.gachaCnt || 0;
|
||||
this.record = playerData?.record || [];
|
||||
}
|
||||
|
||||
public getShowResult() {
|
||||
let box: AuthorGachaDataInDb['box'] = [];
|
||||
for (let { count, rewards } of this.box) {
|
||||
let hasReceived = false;
|
||||
if (this.record.indexOf(count) != -1) hasReceived = true;
|
||||
box.push({ count, rewards, hasReceived })
|
||||
}
|
||||
|
||||
return {
|
||||
...this.getBaseKeys(),
|
||||
gachaId: this.gachaId,
|
||||
authorGachaCnt: this.gachaCnt,
|
||||
box,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -839,7 +839,7 @@ export function arrToMap<T>(arr: T[], getKey: (obj: T) => number|string): Map<nu
|
||||
|
||||
export function getGachaRemainFloor(gachaId: number, userFloor: Floor[]) {
|
||||
let dicGacha = gameData.gacha.get(gachaId);
|
||||
if(dicGacha.gachaType != GACHA_TYPE.NORMAL && dicGacha.gachaType != GACHA_TYPE.ACTIVITY) return 0;
|
||||
if(dicGacha.gachaType != GACHA_TYPE.NORMAL && dicGacha.gachaType != GACHA_TYPE.ACTIVITY && dicGacha.gachaType != GACHA_TYPE.TAUTOR) return 0;
|
||||
|
||||
for(let floorId of dicGacha.floor) {
|
||||
let dicGachaFloor = gameData.gachaFloor.get(floorId);
|
||||
|
||||
@@ -322,5 +322,11 @@
|
||||
"activityType": 58,
|
||||
"name": "MID_AUTUMN",
|
||||
"string": "中秋活动"
|
||||
},
|
||||
{
|
||||
"id": 59,
|
||||
"activityType": 59,
|
||||
"name": "MID_AUTUMN",
|
||||
"string": "百家争鸣活动"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user