feat(gvg): 任务

This commit is contained in:
luying
2023-01-18 10:02:31 +08:00
parent aab08f7ed5
commit 6619e33995
16 changed files with 332 additions and 31 deletions

View File

@@ -126,6 +126,7 @@ import { dicGVGResourceBase, dicGVGResourceBaseByType, dicGVGResourceBaseByLv, l
import { dicGVGContributeBox, loadGVGContributeBox } from './dictionary/DicGVGContributeBox';
import { dicGVGArea, dicGVGCity, loadGVGArea } from './dictionary/DicGVGArea';
import { dicGVGCityAdd, loadGVGCityAdd } from './dictionary/DicGVGCityAdd';
import { dicGVGTask, dicGVGTaskByType, loadGVGTask } from './dictionary/DicGVGTask';
export const gameData = {
daily: dicDaily,
@@ -317,6 +318,8 @@ export const gameData = {
gvgArea: dicGVGArea,
gvgCity: dicGVGCity,
gvgCityAdd: dicGVGCityAdd,
gvgTask: dicGVGTask,
gvgTaskByType: dicGVGTaskByType,
};
// 在此提供一些原先在gamedata中提供的方法以便更方便获取gameData数据
@@ -1146,6 +1149,15 @@ function parseGVGSpFieldRatio() {
gameData.gvgSpFieldRatio.max = parseFloat(arr[0]);
}
export function getGVGTasksByType(taskType: number) {
let taskIds = gameData.gvgTaskByType.get(taskType)||[];
return taskIds.map(taskId => {
let dic = gameData.gvgTask.get(taskId);
console.log(taskId, dic)
return dic
});
}
// 初始加载
function initDatas() {
parseDicParam();
@@ -1352,6 +1364,7 @@ function loadDatas() {
loadGVGContributeBox();
loadGVGArea();
loadGVGCityAdd();
loadGVGTask();
}
// 重载dicParam

View File

@@ -0,0 +1,40 @@
// GVG任务
import { FILENAME } from '../../consts'
import { RewardInter } from '../interface';
import { parseGoodStr, parseNumberList, readFileAndParse } from '../util'
export interface DicGVGTask {
// 唯一id
id: number;
// 任务id
taskId: number;
// 任务类型
taskType: number;
// 任务参数
taskParam: number[];
// 条件
condition: number;
// 普通背包奖励
reward: RewardInter[];
// 联军背包奖励
leagueReward: RewardInter[];
}
export const dicGVGTask = new Map<number, DicGVGTask>();
export const dicGVGTaskByType = new Map<number, number[]>(); // type => []
export function loadGVGTask() {
dicGVGTask.clear();
let arr = readFileAndParse(FILENAME.DIC_GVG_TASK);
arr.forEach(o => {
o.taskParam = parseNumberList(o.taskParam);
o.reward = parseGoodStr(o.reward);
o.leagueReward = parseGoodStr(o.leagueReward);
dicGVGTask.set(o.taskId, o);
if(!dicGVGTaskByType.has(o.taskType)) {
dicGVGTaskByType.set(o.taskType, []);
}
dicGVGTaskByType.get(o.taskType)?.push(o.taskId);
});
arr = undefined;
}