任务:group字段自动生成
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { Application, BackendSession, pinus, HandlerService, } from "pinus";
|
import { Application, BackendSession, pinus, HandlerService, } from "pinus";
|
||||||
import { resResult, parseGoodStr, getRandSingleEelm } from "../../../pubUtils/util";
|
import { resResult, parseGoodStr, getRandSingleEelm } from "../../../pubUtils/util";
|
||||||
import { STATUS, TASK_FUN_TYPE, SHOP_REFRESH_TYPE, KING_EXP_RATIO_TYPE } from "../../../consts";
|
import { STATUS, TASK_FUN_TYPE, SHOP_REFRESH_TYPE, KING_EXP_RATIO_TYPE, DEBUG_MAGIC_WORD } from "../../../consts";
|
||||||
import { gameData } from "../../../pubUtils/data";
|
import { gameData } from "../../../pubUtils/data";
|
||||||
import { UserTaskRecModel } from "../../../db/UserTaskRec";
|
import { UserTaskRecModel } from "../../../db/UserTaskRec";
|
||||||
import { addItems } from "../../../services/rewardService";
|
import { addItems } from "../../../services/rewardService";
|
||||||
@@ -14,6 +14,7 @@ import { ActivityTaskPointModel, ActivityTaskPointModelType } from "../../../db/
|
|||||||
import { ItemInter, RewardInter } from "../../../pubUtils/interface";
|
import { ItemInter, RewardInter } from "../../../pubUtils/interface";
|
||||||
import { RoleModel } from "../../../db/Role";
|
import { RoleModel } from "../../../db/Role";
|
||||||
import { roleLevelup } from "../../../services/normalBattleService";
|
import { roleLevelup } from "../../../services/normalBattleService";
|
||||||
|
import _ = require("underscore");
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
new HandlerService(app, {});
|
new HandlerService(app, {});
|
||||||
@@ -316,4 +317,14 @@ export class ShopHandler {
|
|||||||
type, point, weeklyPoint
|
type, point, weeklyPoint
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async debugGetDicTask(msg: { magicWord: string }, session: BackendSession) {
|
||||||
|
const { magicWord } = msg;
|
||||||
|
if (magicWord !== DEBUG_MAGIC_WORD) {
|
||||||
|
return resResult(STATUS.TOKEN_ERR);
|
||||||
|
}
|
||||||
|
console.log('******', _.isEqual([1,2], [1,2,2]))
|
||||||
|
return resResult(STATUS.SUCCESS, { tasks: [...gameData.taskType]});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+51
-1
@@ -82,7 +82,7 @@ import { dicGiftPackage, loadGiftPackage } from "./dictionary/DicGiftPackage";
|
|||||||
import { dicRecruit, loadRecruit } from './dictionary/DicRecruit';
|
import { dicRecruit, loadRecruit } from './dictionary/DicRecruit';
|
||||||
import { loadRMB, dicRMB } from './dictionary/DicRMB';
|
import { loadRMB, dicRMB } from './dictionary/DicRMB';
|
||||||
import { dicActivityType, loadActivityType } from './dictionary/DicActivityType';
|
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 { dicServerName, dicServerGroupName, loadServerName } from "./dictionary/DicServerName";
|
||||||
import { dicAp, loadAp, dicApMaxLevel } from './dictionary/DicAp';
|
import { dicAp, loadAp, dicApMaxLevel } from './dictionary/DicAp';
|
||||||
import { dicApBuy, dicApMaxBuyTimes, loadApBuy } from "./dictionary/DicApBuy";
|
import { dicApBuy, dicApMaxBuyTimes, loadApBuy } from "./dictionary/DicApBuy";
|
||||||
@@ -96,6 +96,7 @@ import { dicGuildTrainInfo, loadGuildTrainInfo } from './dictionary/DicGuildTrai
|
|||||||
import { dicPvpDifficultRatio, loadPvpDifficultRatio } from './dictionary/DicPvpDifficultRatio';
|
import { dicPvpDifficultRatio, loadPvpDifficultRatio } from './dictionary/DicPvpDifficultRatio';
|
||||||
import { dicWhiteIp, loadWhiteIp } from './dictionary/DicWhiteIp';
|
import { dicWhiteIp, loadWhiteIp } from './dictionary/DicWhiteIp';
|
||||||
import { pick } from "underscore";
|
import { pick } from "underscore";
|
||||||
|
import _ = require("underscore");
|
||||||
|
|
||||||
export const gameData = {
|
export const gameData = {
|
||||||
blurprtCompose: dicBlueprtCompose,
|
blurprtCompose: dicBlueprtCompose,
|
||||||
@@ -848,6 +849,54 @@ function parseDicParam() {
|
|||||||
loadAuctionTime();
|
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
|
// 加载json
|
||||||
function loadDatas() {
|
function loadDatas() {
|
||||||
loadHero();
|
loadHero();
|
||||||
@@ -940,6 +989,7 @@ function loadDatas() {
|
|||||||
loadGuildTrainInfo();
|
loadGuildTrainInfo();
|
||||||
loadPvpDifficultRatio();
|
loadPvpDifficultRatio();
|
||||||
loadWhiteIp();
|
loadWhiteIp();
|
||||||
|
treatTaskGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重载dicParam
|
// 重载dicParam
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ interface DicTaskBase {
|
|||||||
// 任务类型
|
// 任务类型
|
||||||
readonly taskType: number;
|
readonly taskType: number;
|
||||||
// 类型下面的分组
|
// 类型下面的分组
|
||||||
readonly group: number;
|
group: number;
|
||||||
// 任务参数
|
// 任务参数
|
||||||
readonly taskParam: number[];
|
readonly taskParam: number[];
|
||||||
// 条件
|
// 条件
|
||||||
@@ -123,6 +123,7 @@ export function loadTask() {
|
|||||||
dicPvpDailyTask.clear();
|
dicPvpDailyTask.clear();
|
||||||
|
|
||||||
const arrMainTask = readFileAndParse(FILENAME.DIC_MAIN_TASK);
|
const arrMainTask = readFileAndParse(FILENAME.DIC_MAIN_TASK);
|
||||||
|
|
||||||
arrMainTask.forEach(o => {
|
arrMainTask.forEach(o => {
|
||||||
o.taskParam = parseNumberList(o.taskParam);
|
o.taskParam = parseNumberList(o.taskParam);
|
||||||
o.taskReward = parseGoodStr(o.taskReward);
|
o.taskReward = parseGoodStr(o.taskReward);
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ export async function checkTaskWithHero(roleId: string, taskType: number, hero:
|
|||||||
pushMessage = await checkTask(roleId, taskType, 1, true, { quality: dicHero.quality, star: hero.star });
|
pushMessage = await checkTask(roleId, taskType, 1, true, { quality: dicHero.quality, star: hero.star });
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.HERO_LV) {
|
else if (taskType == TASK_TYPE.HERO_LV) {
|
||||||
pushMessage = await checkTask(roleId, taskType, 1, true, { lv: hero.lv, oldLv: args[0] });
|
pushMessage = await checkTask(roleId, taskType, 1, true, { lv: hero.lv, oldLv: args[0]||0 });
|
||||||
}
|
}
|
||||||
else if (taskType == TASK_TYPE.HERO_TRAIN) {
|
else if (taskType == TASK_TYPE.HERO_TRAIN) {
|
||||||
let dicHero = gameData.hero.get(hero.hid);
|
let dicHero = gameData.hero.get(hero.hid);
|
||||||
|
|||||||
Reference in New Issue
Block a user