抽卡:修改抽卡奖池逻辑
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
import { readFileAndParse, parseNumberList, parseGoodStr, decodeArrayListStr } from '../util'
|
||||
import { FILENAME } from '../../consts'
|
||||
import { FILENAME, GACHA_TYPE } from '../../consts'
|
||||
import { RewardInter } from '../interface';
|
||||
|
||||
export interface DicGacha {
|
||||
// 抽卡id
|
||||
readonly id: number;
|
||||
// 抽卡类型
|
||||
readonly gachaType: GACHA_TYPE;
|
||||
// 保底类型, dic_zyz_gachaFloor的id
|
||||
readonly floor: number[];
|
||||
// 抽卡次数 1次,10次
|
||||
readonly count: number[];
|
||||
// 免费次数
|
||||
@@ -12,12 +16,17 @@ export interface DicGacha {
|
||||
// 消耗的招募券
|
||||
readonly cost: RewardInter[];
|
||||
// 概率
|
||||
readonly percent: { id: number, weight: number }[];
|
||||
// 哪一个是大奖
|
||||
readonly floorReward: number;
|
||||
readonly percent: { planId: number, weight: number }[];
|
||||
// 是否计入任务
|
||||
readonly isTask: number;
|
||||
// 玩家抽卡次数范围
|
||||
readonly gachaCnt: { min: number, max: number };
|
||||
// 是否显示在主界面
|
||||
readonly showInMainPage: number;
|
||||
}
|
||||
|
||||
export const dicGacha = new Map<number, DicGacha>(); // id => dic
|
||||
export const dicGachaByGachaType = new Map<number, number[]>(); // gachaType => id
|
||||
export function loadGacha() {
|
||||
dicGacha.clear();
|
||||
let arr = readFileAndParse(FILENAME.DIC_GACHA);
|
||||
@@ -25,9 +34,15 @@ export function loadGacha() {
|
||||
arr.forEach(o => {
|
||||
o.count = parseNumberList(o.count);
|
||||
o.free = parseFree(o.free);
|
||||
o.floor = parseNumberList(o.floor);
|
||||
o.cost = parseGoodStr(o.cost);
|
||||
o.percent = parsePercent(o.percent);
|
||||
o.gachaCnt = parseGachaCnt(o.gachaCnt);
|
||||
dicGacha.set(o.id, o);
|
||||
if(!dicGachaByGachaType.has(o.gachaType)) {
|
||||
dicGachaByGachaType.set(o.gachaType, []);
|
||||
}
|
||||
dicGachaByGachaType.get(o.gachaType).push(o.id);
|
||||
});
|
||||
arr = undefined;
|
||||
}
|
||||
@@ -45,14 +60,19 @@ function parseFree(str: string) {
|
||||
}
|
||||
|
||||
function parsePercent(str: string) {
|
||||
let result = new Array<{ id: number, weight: number }>();
|
||||
let result = new Array<{ planId: number, weight: number }>();
|
||||
if (!str) return result;
|
||||
let decodeArr = decodeArrayListStr(str);
|
||||
for (let [id, weight] of decodeArr) {
|
||||
if (isNaN(parseInt(id)) || isNaN(parseInt(weight))) {
|
||||
for (let [planId, weight] of decodeArr) {
|
||||
if (isNaN(parseInt(planId)) || isNaN(parseInt(weight))) {
|
||||
throw new Error('data table format wrong');
|
||||
}
|
||||
result.push({ id: parseInt(id), weight: parseInt(weight) });
|
||||
result.push({ planId: parseInt(planId), weight: parseInt(weight) });
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function parseGachaCnt(str: string) {
|
||||
let arr = parseNumberList(str);
|
||||
return { min: arr[0]||0, max: arr[1]||-1 }
|
||||
}
|
||||
Reference in New Issue
Block a user