任务:group字段自动生成
This commit is contained in:
@@ -82,7 +82,7 @@ import { dicGiftPackage, loadGiftPackage } from "./dictionary/DicGiftPackage";
|
||||
import { dicRecruit, loadRecruit } from './dictionary/DicRecruit';
|
||||
import { loadRMB, dicRMB } from './dictionary/DicRMB';
|
||||
import { dicActivityType, loadActivityType } from './dictionary/DicActivityType';
|
||||
import { dicTaskTypeDesc, loadTaskType } from './dictionary/DicTaskType';
|
||||
import { DicTaskType, dicTaskTypeDesc, loadTaskType } from './dictionary/DicTaskType';
|
||||
import { dicServerName, dicServerGroupName, loadServerName } from "./dictionary/DicServerName";
|
||||
import { dicAp, loadAp, dicApMaxLevel } from './dictionary/DicAp';
|
||||
import { dicApBuy, dicApMaxBuyTimes, loadApBuy } from "./dictionary/DicApBuy";
|
||||
@@ -96,6 +96,7 @@ import { dicGuildTrainInfo, loadGuildTrainInfo } from './dictionary/DicGuildTrai
|
||||
import { dicPvpDifficultRatio, loadPvpDifficultRatio } from './dictionary/DicPvpDifficultRatio';
|
||||
import { dicWhiteIp, loadWhiteIp } from './dictionary/DicWhiteIp';
|
||||
import { pick } from "underscore";
|
||||
import _ = require("underscore");
|
||||
|
||||
export const gameData = {
|
||||
blurprtCompose: dicBlueprtCompose,
|
||||
@@ -848,6 +849,54 @@ function parseDicParam() {
|
||||
loadAuctionTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理任务的group属性
|
||||
* group为如果两个任务,除了condition以外的其他所有taskParam都是一样的,他们的group相同
|
||||
*/
|
||||
function treatTaskGroup() {
|
||||
let taskType2Desc = new Map<number, DicTaskType>();
|
||||
for(let obj of gameData.taskTypeDesc) {
|
||||
taskType2Desc.set(obj.id, obj);
|
||||
}
|
||||
let taskByGroup = new Map<number, { params: number[], ids: number[] }[]>(); // taskType => obj
|
||||
for(let [taskType, tasks] of gameData.taskType) {
|
||||
for(let obj of tasks) {
|
||||
let dicTaskType = taskType2Desc.get(taskType);
|
||||
let index = dicTaskType.param.split('&').indexOf(dicTaskType.condition);
|
||||
console.log(index);
|
||||
let params = obj.taskParam.filter((_, i) => index != i);
|
||||
// console.log('params: ', obj.id, obj.type, obj.taskType, obj.taskParam, obj.condition, params);
|
||||
|
||||
if(!taskByGroup.has(taskType)) {
|
||||
taskByGroup.set(taskType, [{ params, ids: [obj.id]}]);
|
||||
} else {
|
||||
let arr = taskByGroup.get(taskType)||[];
|
||||
let hasGroup = arr.find(cur => {
|
||||
return _.isEqual(cur.params, params);
|
||||
});
|
||||
if(hasGroup) {
|
||||
hasGroup.ids.push(obj.id);
|
||||
} else {
|
||||
arr.push({ params, ids: [obj.id] });
|
||||
}
|
||||
taskByGroup.set(taskType, arr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(let [taskType, arr] of taskByGroup) {
|
||||
let tasks = gameData.taskType.get(taskType);
|
||||
for(let i = 0; i < arr.length; i++) {
|
||||
let group = i + 1;
|
||||
let { ids } = arr[i];
|
||||
for(let id of ids) {
|
||||
let task = tasks.find(cur => cur.id == id);
|
||||
if(task) task.group = group;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 加载json
|
||||
function loadDatas() {
|
||||
loadHero();
|
||||
@@ -940,6 +989,7 @@ function loadDatas() {
|
||||
loadGuildTrainInfo();
|
||||
loadPvpDifficultRatio();
|
||||
loadWhiteIp();
|
||||
treatTaskGroup();
|
||||
}
|
||||
|
||||
// 重载dicParam
|
||||
|
||||
Reference in New Issue
Block a user