feat(gift): 修改宝箱保底机制

This commit is contained in:
liangtongchuan
2023-02-18 18:15:34 +08:00
committed by luying
parent 321d9d15ba
commit 199677e2a4
9 changed files with 1863 additions and 1688 deletions

View File

@@ -543,6 +543,7 @@ export const FILENAME = {
DIC_GACHA_FLOOR: 'dic_zyz_gachaFloor',
DIC_GIFT_PACKAGE: 'dic_zyz_giftPackage',
DIC_GIFT_PACKAGE_PLAN: 'dic_zyz_giftPackagePlan',
DIC_GIFT_PACKAGE_FLOOR: 'dic_zyz_giftPackageFloor',
DIC_RECRUIT: 'dic_zyz_recruit',
DIC_RMB: 'dic_zyz_rmb',
DIC_ACTIVITY_TYPE: 'dic_zyz_activityType',

View File

@@ -1,8 +1,17 @@
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
export class Floor {
@prop({ required: true })
id: number; // 保底类型,对应 DicGiftPackageFloor 的 floorId
@prop({ required: true })
count: number; // 抽卡次数
@prop({ required: true })
quality: number; // 品质
}
/**
* 战斗记录接口
* 宝箱保底
*/
@index({ roleId: 1, giftPackageId: 1, floorPlanId: 1 })
@@ -12,12 +21,14 @@ export default class GiftPackageFloor extends BaseModel {
@prop({ required: true })
giftPackageId: number; // 礼包 id
@prop({ required: true })
floorPlanId: number; // 物品id
floorPlanId: number; // 礼包内容 id唯一 id
@prop({ required: true, default: 0 })
getNum: number; // 获取次数当allNum超过配置次数重置
@prop({ required: true, default: 0 })
allNum: number; // 全部次数,当超过配置次数重置
@prop({ required: true, type: Floor, default: [], _id: false })
floors: Floor[]; // 已抽卡次数
@prop({ required: true, default: 0 })
getSum: number; // 获取道具的全部次数
@prop({ required: true, default: 0 })
@@ -29,6 +40,18 @@ export default class GiftPackageFloor extends BaseModel {
return result;
}
// 根据礼包 id 查找
public static async findByGiftPackageId(roleId: string, giftPackageId: number, lean = true) {
const result: GiftPackageFloorType = await GiftPackageFloorModel.findOneAndUpdate({ roleId, giftPackageId}, {}, {new: true, upsert: true}).lean(lean);
return result;
}
// 根据礼包 id 更新
public static async updateByGiftPackageId(roleId: string, giftPackageId: number, params: {floors: Floor[], getSum: number, allSum: number}, lean = true) {
const result: GiftPackageFloorType = await GiftPackageFloorModel.findOneAndUpdate({roleId, giftPackageId}, {$set: params}, {new: true}).lean(lean);
return result;
}
public static async updateByPlanId(roleId: string, giftPackageId: number, floorPlanId: number, params: {getNum: number, allNum: number, getSum: number, allSum: number}, lean = true) {
const result: GiftPackageFloorType = await GiftPackageFloorModel.findOneAndUpdate({roleId, giftPackageId, floorPlanId}, {$set: params}).lean(lean);
return result;

View File

@@ -118,6 +118,7 @@ import { dicArtifactSeid, loadArtifactSeid } from "./dictionary/DicArtifactSeid"
import { DicArtifact } from "./dictionary/DicArtifact";
import { DicArtifactQuality } from "./dictionary/DicArtifactQuality";
import { dicGiftPackagePlan, loadGiftPackagePlan } from "./dictionary/DicGiftPackagePlan";
import { dicGiftPackageFloor, loadGiftPackageFloor } from "./dictionary/DicGiftPackageFloor";
import { dicGVGPeriod, loadGVGPeriod } from './dictionary/DicGVGPeriod';
import { dicGVGTech, loadGVGTech } from "./dictionary/DicGVGTech";
import { dicGVGItem, loadGVGItem } from "./dictionary/DicGVGItems";
@@ -246,6 +247,7 @@ export const gameData = {
heroTransPiece: new Map<number, number>(),
giftPackage: dicGiftPackage,
giftPackagePlan: dicGiftPackagePlan,
giftPackageFloor: dicGiftPackageFloor,
comBtlLvRange: new Map<number, {min: number, max: number}>(),
recruit: dicRecruit,
rmb: dicRMB,
@@ -1417,6 +1419,7 @@ function loadDatas() {
loadGachaFloor();
loadGiftPackage();
loadGiftPackagePlan();
loadGiftPackageFloor();
loadRecruit();
loadRMB();
loadActivityType();

View File

@@ -0,0 +1,23 @@
// 礼包奖励表
import { readFileAndParse } from '../util';
import { FILENAME } from '../../consts';
// 礼包保底表
export interface DicGiftPackageFloor {
// 唯一id
readonly id: number;
// 触发保底次数
readonly times: number;
// 品质(触发多保底时的优先级覆盖关系)
readonly quality: number;
}
export const dicGiftPackageFloor = new Map<number, DicGiftPackageFloor>(); // floorId => [floor]
export function loadGiftPackageFloor() {
dicGiftPackageFloor.clear();
let arr = readFileAndParse(FILENAME.DIC_GIFT_PACKAGE_FLOOR);
arr.forEach(o => {
dicGiftPackageFloor.set(o.id, o);
});
arr = undefined;
}

View File

@@ -16,10 +16,8 @@ export interface DicGiftPackagePlan {
readonly count: number;
// 权重
readonly weight: number;
// 保底 每floor必出floorCount个提前获取到次数就重置
readonly floorFrequency: number;
// 保底数量
readonly floorCount: number;
// 保底表id
readonly floorId: number;
}
type KeysEnum<T> = { [P in keyof Required<T>]: true };
@@ -30,8 +28,7 @@ const DicGiftPackagePlanKeys: KeysEnum<DicGiftPackagePlan> = {
content: true,
count: true,
weight: true,
floorFrequency: true,
floorCount: true
floorId: true,
}
export const dicGiftPackagePlan = new Map<number, DicGiftPackagePlan[]>(); // packageId => [plan]
@@ -40,14 +37,7 @@ export function loadGiftPackagePlan() {
let arr = readFileAndParse(FILENAME.DIC_GIFT_PACKAGE_PLAN);
arr.forEach(o => {
if(o.floor == '&') {
o.floorFrequency = 0;
o.floorCount = 0;
} else {
let arr = o.floor.split('&');
o.floorFrequency = isNaN(parseInt(arr[0]))? 0: parseInt(arr[0]);
o.floorCount = isNaN(parseInt(arr[1]))? 0: parseInt(arr[1]);
}
o.floorId = o.floor;
if(!dicGiftPackagePlan.has(o.giftPackageId)) {
dicGiftPackagePlan.set(o.giftPackageId, []);
}

View File

@@ -0,0 +1,12 @@
[
{
"id": 1,
"quality": 3,
"times": 40
},
{
"id": 2,
"quality": 4,
"times": 100
}
]

File diff suppressed because it is too large Load Diff