✨ feat(诸子列传): 添加功能
This commit is contained in:
@@ -136,6 +136,10 @@ import { DicGVGVestigePlayerRank, dicGVGVestigePlayerRank, loadGVGVestigePlayerR
|
||||
import { dicGVGAreaPoint, loadGVGAreaPoint, dicGVGPointsByAreaId } from "./dictionary/DicGVGAreaPoint";
|
||||
import { DicGVGBattleRankReward, dicGVGBattleRankReward, loadGVGBattleRankReward } from './dictionary/DicGVGBattleRankReward';
|
||||
import { dicPushMessage, loadPushMessage } from './dictionary/DicPushMessage';
|
||||
import { dicAuthorsBookGoodId, loadAuthorsBookGoodId } from "./dictionary/DicAuthorsBookGoodId";
|
||||
import { dicAuthorsBookMaxProgress, dicAuthorsBookSubs, dicAuthorsBookSubStar, loadAuthorsBookSub } from "./dictionary/DicAuthorsBookSub";
|
||||
import { dicAuthorsBookPoint, loadAuthorsBookPoint } from "./dictionary/DicAuthorsBookPoint";
|
||||
import { dicAuthorsBook, loadAuthorsBook } from './dictionary/DicAuthorsBook';
|
||||
|
||||
export const gameData = {
|
||||
daily: dicDaily,
|
||||
@@ -346,7 +350,13 @@ export const gameData = {
|
||||
gvgReviveGold: new Map<number|'max', number>(),
|
||||
dicPushMessage: dicPushMessage,
|
||||
guildQuitCd: new Array<{day: number, minute: number}>(),
|
||||
trainIdByIndex: dicTrainIdByIndex
|
||||
trainIdByIndex: dicTrainIdByIndex,
|
||||
spirit: dicAuthorsBookGoodId,
|
||||
authorBook: dicAuthorsBook,
|
||||
authorBookSubStar: dicAuthorsBookSubStar,
|
||||
authorBookSubs: dicAuthorsBookSubs,
|
||||
authorBookPoint: dicAuthorsBookPoint,
|
||||
authorBookMaxProgress: dicAuthorsBookMaxProgress
|
||||
};
|
||||
|
||||
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
|
||||
@@ -786,6 +796,10 @@ export function getRaceEventItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
export function getDicAuthorBookSub(bookId: number, subId: number, star: number) {
|
||||
return gameData.authorBookSubStar.get(`${bookId}_${subId}_${star}`);
|
||||
}
|
||||
|
||||
// export function getRaceEventItems(members: WoodenHorseMember[], items: { id: number, total: number, max: number }[]) {
|
||||
// let result = new Array<RewardInter>();
|
||||
// for (let { id, min, max } of items) {
|
||||
@@ -1645,6 +1659,14 @@ function loadDatas(type?: string) {
|
||||
loadGVGBattleRankReward();
|
||||
if(type == undefined || type == 'loadPushMessage')
|
||||
loadPushMessage();
|
||||
if(type == undefined || type == 'loadAuthorsBookGoodId')
|
||||
loadAuthorsBookGoodId();
|
||||
if(type == undefined || type == 'loadAuthorsBookSub')
|
||||
loadAuthorsBookSub();
|
||||
if(type == undefined || type == 'loadAuthorsBookPoint')
|
||||
loadAuthorsBookPoint();
|
||||
if(type == undefined || type == 'loadAuthorsBook')
|
||||
loadAuthorsBook();
|
||||
|
||||
console.log('loadDatas type: ', type||'all');
|
||||
}
|
||||
|
||||
46
shared/pubUtils/dictionary/DicAuthorsBook.ts
Normal file
46
shared/pubUtils/dictionary/DicAuthorsBook.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
// 列传内的条目
|
||||
import {decodeArrayListStr, readFileAndParse} from '../util'
|
||||
import { FILENAME } from '../../consts'
|
||||
const _ = require('lodash');
|
||||
|
||||
export interface DicAuthorsBook {
|
||||
// 列传id
|
||||
readonly id: number;
|
||||
// 限制条件
|
||||
readonly limit: { type: number, bookId?: number, value: number }[];
|
||||
}
|
||||
|
||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||
const DicAuthorsBookKeys: KeysEnum<DicAuthorsBook> = {
|
||||
id: true,
|
||||
limit: true,
|
||||
}
|
||||
|
||||
export const dicAuthorsBook = new Map<number, DicAuthorsBook>();
|
||||
export function loadAuthorsBook() {
|
||||
dicAuthorsBook.clear();
|
||||
let arr = readFileAndParse(FILENAME.DIC_AUTHORS_BOOK);
|
||||
|
||||
arr.forEach(o => {
|
||||
o.limit = parseLimit(o.limit);
|
||||
dicAuthorsBook.set(o.id, _.pick(o, Object.keys(DicAuthorsBookKeys)));
|
||||
});
|
||||
arr = undefined;
|
||||
}
|
||||
|
||||
function parseLimit(str: string) {
|
||||
let result: { type: number, bookId?: number, value: number }[] = [];
|
||||
if (!str) return result;
|
||||
let decodeArr = decodeArrayListStr(str);
|
||||
for (let [ str1, str2, str3 ] of decodeArr) {
|
||||
if (isNaN(parseInt(str1)) || isNaN(parseInt(str2)) || (str3 && isNaN(parseInt(str3)))) {
|
||||
throw new Error('data table format wrong');
|
||||
}
|
||||
if(str3) {
|
||||
result.push({ type: parseInt(str1), bookId: parseInt(str2), value: parseInt(str3) });
|
||||
} else {
|
||||
result.push({ type: parseInt(str1), value: parseInt(str2) });
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
28
shared/pubUtils/dictionary/DicAuthorsBookGoodId.ts
Normal file
28
shared/pubUtils/dictionary/DicAuthorsBookGoodId.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
// 英灵对应的物品表
|
||||
import { parseGoodStr, readFileAndParse } from '../util'
|
||||
import { FILENAME } from '../../consts'
|
||||
import { RewardInter } from '../interface';
|
||||
|
||||
export interface DicAuthorsBookGoodId {
|
||||
// id
|
||||
readonly id: number;
|
||||
// 对应物品表id
|
||||
readonly goodId: number;
|
||||
// 分解可得
|
||||
readonly decomposeItem: RewardInter[];
|
||||
// 英灵替换
|
||||
readonly composeItem: RewardInter[];
|
||||
}
|
||||
|
||||
export const dicAuthorsBookGoodId = new Map<number, DicAuthorsBookGoodId>();
|
||||
export function loadAuthorsBookGoodId() {
|
||||
dicAuthorsBookGoodId.clear();
|
||||
let arr = readFileAndParse(FILENAME.DIC_AUTHORS_GOODID);
|
||||
|
||||
arr.forEach(o => {
|
||||
o.decomposeItem = parseGoodStr(o.decomposeItem);
|
||||
o.composeItem = parseGoodStr(o.composeItem)
|
||||
dicAuthorsBookGoodId.set(o.goodId, o);
|
||||
});
|
||||
arr = undefined;
|
||||
}
|
||||
38
shared/pubUtils/dictionary/DicAuthorsBookPoint.ts
Normal file
38
shared/pubUtils/dictionary/DicAuthorsBookPoint.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
// 列传的进度节点
|
||||
import {decodeArrayListStr, readFileAndParse} from '../util'
|
||||
import { FILENAME } from '../../consts'
|
||||
|
||||
export interface DicAuthorsBookPoint {
|
||||
// 列传
|
||||
readonly bookId: number;
|
||||
// 进度节点
|
||||
readonly value: number;
|
||||
// 到这个节点可得的属性
|
||||
readonly attr: { id: number, val: number }[]
|
||||
}
|
||||
|
||||
export const dicAuthorsBookPoint = new Map<number, DicAuthorsBookPoint[]>();
|
||||
export function loadAuthorsBookPoint() {
|
||||
dicAuthorsBookPoint.clear();
|
||||
let arr = readFileAndParse(FILENAME.DIC_AUTHORS_BOOK_POINT);
|
||||
|
||||
arr.forEach(o => {
|
||||
o.attr = parseAttribute(o.attr);
|
||||
if(!dicAuthorsBookPoint.has(o.id)) dicAuthorsBookPoint.set(o.id, []);
|
||||
dicAuthorsBookPoint.get(o.id)?.push(o);
|
||||
});
|
||||
arr = undefined;
|
||||
}
|
||||
|
||||
function parseAttribute(str: string) {
|
||||
let result = new Array<{ id: number, val: number }>();
|
||||
if (!str) return result;
|
||||
let decodeArr = decodeArrayListStr(str);
|
||||
for (let [id, val] of decodeArr) {
|
||||
if (isNaN(parseInt(id)) || isNaN(parseInt(val))) {
|
||||
throw new Error('data table format wrong');
|
||||
}
|
||||
result.push({ id: parseInt(id), val: parseInt(val) });
|
||||
}
|
||||
return result
|
||||
}
|
||||
71
shared/pubUtils/dictionary/DicAuthorsBookSub.ts
Normal file
71
shared/pubUtils/dictionary/DicAuthorsBookSub.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
// 列传内的条目
|
||||
import {decodeArrayListStr, parseNumberList, readFileAndParse} from '../util'
|
||||
import { FILENAME } from '../../consts'
|
||||
import { RewardInter } from '../interface';
|
||||
const _ = require('lodash');
|
||||
|
||||
export interface DicAuthorsBookSub {
|
||||
// 列传id
|
||||
readonly bookId: number;
|
||||
// 条目id
|
||||
readonly subId: number;
|
||||
// 星级
|
||||
readonly star: number;
|
||||
// 星级
|
||||
readonly maxStar: number;
|
||||
// 所需的英灵
|
||||
readonly spirits: RewardInter[];
|
||||
// 每升一颗星可以获得的进度
|
||||
readonly value: number;
|
||||
// 到这个节点可得的属性
|
||||
readonly attr: { id: number, val: number }[]
|
||||
}
|
||||
|
||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||
const DicAuthorsBookSubKeys: KeysEnum<DicAuthorsBookSub> = {
|
||||
bookId: true,
|
||||
subId: true,
|
||||
star: true,
|
||||
maxStar: true,
|
||||
spirits: true,
|
||||
value: true,
|
||||
attr: true,
|
||||
}
|
||||
|
||||
export const dicAuthorsBookSubStar = new Map<string, DicAuthorsBookSub>();
|
||||
export const dicAuthorsBookSubs = new Map<number, number[]>();
|
||||
export const dicAuthorsBookMaxProgress = new Map<number, number>(); // bookId => maxProgress
|
||||
export function loadAuthorsBookSub() {
|
||||
dicAuthorsBookSubStar.clear();
|
||||
dicAuthorsBookSubs.clear();
|
||||
dicAuthorsBookMaxProgress.clear();
|
||||
let arr = readFileAndParse(FILENAME.DIC_AUTHORS_BOOK_SUB);
|
||||
arr.forEach(o => {
|
||||
o.attr = parseAttribute(o.attr);
|
||||
o.spirits = parseSpirit(o.goodsId);
|
||||
dicAuthorsBookSubStar.set(`${o.bookId}_${o.subId}_${o.star}`, _.pick(o, Object.keys(DicAuthorsBookSubKeys)));
|
||||
if(!dicAuthorsBookSubs.has(o.bookId)) dicAuthorsBookSubs.set(o.bookId, []);
|
||||
if(dicAuthorsBookSubs.get(o.bookId).indexOf(o.subId) == -1) dicAuthorsBookSubs.get(o.bookId).push(o.subId);
|
||||
if(!dicAuthorsBookMaxProgress.has(o.bookId)) dicAuthorsBookMaxProgress.set(o.bookId, 0);
|
||||
dicAuthorsBookMaxProgress.set(o.bookId, dicAuthorsBookMaxProgress.get(o.bookId) + o.value);
|
||||
});
|
||||
arr = undefined;
|
||||
}
|
||||
|
||||
function parseAttribute(str: string) {
|
||||
let result = new Array<{ id: number, val: number }>();
|
||||
if (!str) return result;
|
||||
let decodeArr = decodeArrayListStr(str);
|
||||
for (let [id, val] of decodeArr) {
|
||||
if (isNaN(parseInt(id)) || isNaN(parseInt(val))) {
|
||||
throw new Error('data table format wrong');
|
||||
}
|
||||
result.push({ id: parseInt(id), val: parseInt(val) });
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function parseSpirit(str: string): RewardInter[] {
|
||||
let arr = parseNumberList(str);
|
||||
return arr.map(id => ({ id, count: 1 }));
|
||||
}
|
||||
Reference in New Issue
Block a user