抽卡:添加抽卡接口

This commit is contained in:
luying
2021-04-23 15:46:04 +08:00
parent 1f6839cafb
commit beadccf778
23 changed files with 591 additions and 85 deletions

View File

@@ -36,12 +36,13 @@ const str = readJsonFile(FILENAME.DIC_EVENT);
let arr = JSON.parse(str);
export const dicEvent = new Map<number, DicEvent>();
export const dicEventList = new Array<DicEvent>();
arr.forEach(o => {
o.winReward = parseGoodStr(o.winReward);
o.loseReward = parseGoodStr(o.loseReward);
o.suitLevel = parseSuitLevel(o.suitLevel);
o.movePointArray = parseNumberList(o.movePointArray);
dicEventList.push(o);
dicEvent.set(o.eventID, o);
});

View File

@@ -12,13 +12,13 @@ export interface DicGacha {
// 消耗的招募券
readonly cost: RewardInter[];
// 概率
readonly percent: { id: number, percent: number }[];
readonly percent: { id: number, weight: number }[];
}
const str = readJsonFile(FILENAME.DIC_GACHA);
let arr = JSON.parse(str);
export const dicGacha = new Map<number, DicGacha>();
export const dicGacha = new Map<number, DicGacha>(); // id => dic
arr.forEach(o => {
o.count = parseNumberList(o.count);
o.free = parseFree(o.free);
@@ -41,14 +41,14 @@ function parseFree(str: string) {
}
function parsePercent(str: string) {
let result = new Array<{ id: number, percent: number }>();
let result = new Array<{ id: number, weight: number }>();
if (!str) return result;
let decodeArr = decodeArrayListStr(str);
for (let [id, percent] of decodeArr) {
if (isNaN(parseInt(id)) || isNaN(parseInt(percent))) {
for (let [id, weight] of decodeArr) {
if (isNaN(parseInt(id)) || isNaN(parseInt(weight))) {
throw new Error('data table format wrong');
}
result.push({ id: parseInt(id), percent: parseInt(percent) });
result.push({ id: parseInt(id), weight: parseInt(weight) });
}
return result
}

View File

@@ -1,5 +1,5 @@
import { readJsonFile, parseNumberList } from '../util'
import { FILENAME } from '../../consts'
import { FILENAME, GACHA_CONTENT_TYPE } from '../../consts'
export interface DicGachaContent {
// 内容id
@@ -15,9 +15,14 @@ export interface DicGachaContent {
const str = readJsonFile(FILENAME.DIC_GACHA_CONTENT);
let arr = JSON.parse(str);
export const dicGachaContent = new Map<number, DicGachaContent>();
export const dicGachaContent = new Map<number, DicGachaContent>(); // id => dic
export const dicGachaContentHero = new Map<number, number>(); // quality => dic
arr.forEach(o => {
o.param = parseNumberList(o.param);
if(o.type == GACHA_CONTENT_TYPE.HERO) {
dicGachaContentHero.set(o.param[0], o.id);
}
dicGachaContent.set(o.id, o);
});
arr = undefined;

View File

@@ -27,13 +27,15 @@ export interface DicHero {
readonly baseAbilityArr:Map<number, number>;
readonly baseAbilityUpArr:Map<number, number>;
readonly initialSkin: number;
// 是否可招募
readonly recruit: boolean;
}
const str = readJsonFile(FILENAME.DIC_HERO);
let arr = JSON.parse(str);
type KeysEnum<T> = { [P in keyof Required<T>]: true };
const DicHeroKeys: KeysEnum<DicHero> = {heroId: true, name: true, quality: true, camp: true, jobid: true, skill: true, pieceId: true, initialStars: true, pieceCount: true, baseAbilityArr: true, baseAbilityUpArr: true, initialSkin: true};
const DicHeroKeys: KeysEnum<DicHero> = {heroId: true, name: true, quality: true, camp: true, jobid: true, skill: true, pieceId: true, initialStars: true, pieceCount: true, baseAbilityArr: true, baseAbilityUpArr: true, initialSkin: true, recruit: true};
export const dicMyHeroes = new Array<number>();
export const dicHero = new Map<number, DicHero>();
arr.forEach(o => {
@@ -42,7 +44,7 @@ arr.forEach(o => {
}
o.baseAbilityArr = parseBaseAbilityArr(o);
o.baseAbilityUpArr = parseBaseAbilityUpArr(o);
o.recruit = parseInt(o.recruit) == 1;
dicHero.set(o.heroId, _.pick(o, Object.keys(DicHeroKeys)));
});