皮肤:周边相关功能影响
This commit is contained in:
@@ -1,19 +1,17 @@
|
||||
import { STATUS } from './../../../consts/statusCode';
|
||||
import { HANG_UP_CONSTS, REDIS_KEY } from './../../../consts';
|
||||
import { TowerTaskRecModel, TowerTaskRecType } from './../../../db/TowerTaskRec';
|
||||
import { TaskHero, TowerTaskRecModel, TowerTaskRecType } from './../../../db/TowerTaskRec';
|
||||
import { HangUpSpdUpRecModel } from './../../../db/HangUpSpdUpRec';
|
||||
import { HangUpRecordModel } from './../../../db/HangUpRecord';
|
||||
import { RoleModel } from './../../../db/Role';
|
||||
import { TowerRecordModel } from './../../../db/TowerRecord';
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { resResult, shouldRefresh, genCode } from '../../../pubUtils/util';
|
||||
import { calcuHangUpReward, checkTaskConditions, checkHangUpSpdUpCnt, refreshTasks, treatTask, getRemainTime, getDoingOrWaitingTasks, getTowerStatus, getHungupRewards, getTasks, checkTaskRewards, getTowerTaskCostGold, getHangSpdUpCostGold, getManyHangSpdUpCostGold, getTaskStatus } from '../../../services/battleService';
|
||||
import { resResult, genCode } from '../../../pubUtils/util';
|
||||
import { calcuHangUpReward, checkHangUpSpdUpCnt, refreshTasks, treatTask, getRemainTime, getTowerStatus, getHungupRewards, getTasks, checkTaskRewards, getTowerTaskCostGold, getHangSpdUpCostGold, getManyHangSpdUpCostGold, getTaskStatus } from '../../../services/battleService';
|
||||
import { addItems, handleCost } from '../../../services/rewardService';
|
||||
import { checkBattleHeroes } from '../../../services/normalBattleService';
|
||||
import { getGoldObject } from '../../../pubUtils/itemUtils';
|
||||
import { Rank } from '../../../services/rankService';
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
import { ItemInter } from '../../../pubUtils/interface';
|
||||
import * as dicParam from '../../../pubUtils/dicParam';
|
||||
|
||||
export default function(app: Application) {
|
||||
@@ -154,7 +152,7 @@ export class TowerBattleHandler {
|
||||
return resResult(STATUS.SUCCESS, { curTasks: treatTask(curTasks, curTime), costGold, nextCostGold, refRemainTime});
|
||||
}
|
||||
|
||||
async sendTaskHero(msg: {batchCode: string, tasks: Array<{taskCode: string, heroes: Array<number>}>}, session: BackendSession) {
|
||||
async sendTaskHero(msg: {batchCode: string, tasks: {taskCode: string, heroes: number[]}[]}, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
|
||||
const curTime = new Date();
|
||||
@@ -162,36 +160,44 @@ export class TowerBattleHandler {
|
||||
if (!curTasks || curTasks.length == 0) {
|
||||
return resResult(STATUS.TOWER_TASK_NOT_FOUND);
|
||||
}
|
||||
let usedHeroes = [], tasks = [];
|
||||
const tasksCode = [];
|
||||
let usedHeroes: number[] = [], tasks: {taskCode:string, heroes: TaskHero[], completeTime: number}[] = [];
|
||||
const tasksCode: string[] = [];
|
||||
const taskMap = new Map<string, any>()
|
||||
curTasks.forEach(task => {
|
||||
let getStatusResult = getTaskStatus(task.status, task.completeTime, curTime);
|
||||
if(getStatusResult.status == 1) usedHeroes = usedHeroes.concat(task.heroes);
|
||||
if(getStatusResult.status == 1) {
|
||||
for(let { seqId } of task.heroes) {
|
||||
usedHeroes.push(seqId);
|
||||
}
|
||||
}
|
||||
tasksCode.push(task.taskCode);
|
||||
taskMap.set(task.taskCode, task);
|
||||
});
|
||||
for (let task of msg.tasks) {
|
||||
let curTask = taskMap.get(task.taskCode); // 数据库中,这个任务的数据
|
||||
for (let { taskCode, heroes: seqIds } of msg.tasks) {
|
||||
let curTask = taskMap.get(taskCode); // 数据库中,这个任务的数据
|
||||
if(!curTask) {
|
||||
return resResult(STATUS.TOWER_TASK_MISSING)
|
||||
}
|
||||
let taskInfo = gameData.towerTask.get(curTask.taskId);
|
||||
if (task.heroes.length !== taskInfo.actorNeeded) { // 武将数,从策划表中读取
|
||||
let dicTask = gameData.towerTask.get(curTask.taskId);
|
||||
if (seqIds.length !== dicTask.actorNeeded) { // 武将数,从策划表中读取
|
||||
return resResult(STATUS.TOWER_TASK_MAX_HERO);
|
||||
}
|
||||
let { isOK } = await checkBattleHeroes(roleId, task.heroes);
|
||||
let { isOK, heroes } = await checkBattleHeroes(roleId, seqIds);
|
||||
if(!isOK) return resResult(STATUS.BATTLE_HERO_NOT_FOUND);
|
||||
if (tasksCode.indexOf(task.taskCode) === -1) {
|
||||
if (tasksCode.indexOf(taskCode) === -1) {
|
||||
return resResult(STATUS.TOWER_TASK_CODE_NOT_FOUND);
|
||||
}
|
||||
if (usedHeroes.length > 0) { // 是否在其他任务重使用了武将
|
||||
let used = !!task.heroes.find(seqId => usedHeroes.indexOf(seqId) !== -1);
|
||||
let used = !!seqIds.find(seqId => usedHeroes.indexOf(seqId) !== -1);
|
||||
if (used) {
|
||||
return resResult(STATUS.TOWER_TASK_HERO_HAS_USED);
|
||||
}
|
||||
}
|
||||
tasks.push({...task, completeTime: taskInfo.completeTime})
|
||||
|
||||
let taskHeroes = heroes.map(hero => {
|
||||
return new TaskHero(hero);
|
||||
});
|
||||
tasks.push({ taskCode, heroes: taskHeroes, completeTime: dicTask.completeTime})
|
||||
|
||||
}
|
||||
const recs = await TowerTaskRecModel.sendHeroes(roleId, msg.batchCode, tasks, curTime,);
|
||||
@@ -225,7 +231,7 @@ export class TowerBattleHandler {
|
||||
if (!tasks || tasks.length == 0) {
|
||||
return resResult(STATUS.TOWER_TASK_NOT_FOUND);
|
||||
}
|
||||
const checkResult = await checkTaskRewards(roleId, batchCode, tasks);
|
||||
const checkResult = checkTaskRewards(batchCode, tasks);
|
||||
if (!checkResult) {
|
||||
return resResult(STATUS.TOWER_TASK_BATCH_NOT_FOUND);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user