From 6adeda82dc5c0a23189cd554bcb8ca8ba562db63 Mon Sep 17 00:00:00 2001 From: luying Date: Thu, 19 Aug 2021 17:16:18 +0800 Subject: [PATCH] =?UTF-8?q?=E9=95=87=E5=BF=B5=E5=A1=94=EF=BC=9A=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=B4=BE=E9=81=A3=E4=BB=BB=E5=8A=A1=E6=97=A0=E5=A5=96?= =?UTF-8?q?=E5=8A=B1=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game-server/app/services/battleService.ts | 13 ++++++++----- game-server/app/services/normalBattleService.ts | 2 +- game-server/app/services/rewardService.ts | 13 +++++++++++-- shared/pubUtils/itemUtils.ts | 7 +++++++ 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/game-server/app/services/battleService.ts b/game-server/app/services/battleService.ts index 3235d33e8..be5f001d6 100644 --- a/game-server/app/services/battleService.ts +++ b/game-server/app/services/battleService.ts @@ -85,7 +85,7 @@ export async function getTasks(role: RoleType) { let { roleId, roleName, towerLv, towerTaskRefTime, towerTaskReCnt = 0 } = role; // towerLv:从1开始,下次打得层数,dicParam内的:从0开始,打过的层数 - if(towerLv - 1 <= dicParam.TOWER_SEARCH.TOWER_SEARCH_STARTLIMITED) { + if(towerLv - 1 < dicParam.TOWER_SEARCH.TOWER_SEARCH_STARTLIMITED) { return {curTasks: [], refRemainTime: 0, nextCostGold: 0} } @@ -415,16 +415,17 @@ export async function refreshTasks(towerLv: number, batchCode: string, roleId: s for(let i = 1; i <= dicParam.TOWER_SEARCH.TOWER_SEARCH_LIMITED; i++) { positions.set(i, null); } + let tasks: TowerTaskRecType[] = []; for(let task of oldTasks) { if( task.status == TOWER_TASK_STATUS.WAITING ) { positions.set(task.position, task); } else { positions.delete(task.position); ridTaskIds.push(task.taskId); + tasks.push(task); } } - let tasks: TowerTaskRecType[] = []; for(let [ position, task ] of positions) { let dicOldTask = task? gameData.towerTask.get(task.taskId): null; @@ -506,12 +507,14 @@ export function getRemainTime(curTime: Date) { return Math.floor((nextTime - curTime.getTime()) / 1000); } -export function treatTask(recs: Array, curTime: Date) { +export function treatTask(recs: Array, curTime: Date) { return recs.map(cur => { - let { heroes, batchCode, taskId, taskCode, status, completeTime } = cur; + let { heroes, batchCode, taskId, taskCode, status, completeTime, position } = cur; let getStatusResult = getTaskStatus(status, completeTime, curTime); - return { heroes, batchCode, taskId, taskCode, completeTime, ...getStatusResult } + return { position, heroes, batchCode, taskId, taskCode, completeTime, ...getStatusResult } + }).sort((a, b) => { + return a.position - b.position; }); } diff --git a/game-server/app/services/normalBattleService.ts b/game-server/app/services/normalBattleService.ts index baaed87fd..2a2629352 100644 --- a/game-server/app/services/normalBattleService.ts +++ b/game-server/app/services/normalBattleService.ts @@ -14,7 +14,7 @@ import { RScriptRecordModel } from '../db/RScriptRecord'; import { setAp } from './actionPointService'; import { resResult } from '../pubUtils/util'; -export async function roleLevelup(roleId: string, kingExp: number, session: BackendSession) { +export async function roleLevelup(roleId: string, kingExp: number = 0, session: BackendSession) { const serverId = session.get('serverId'); const sid = session.get('sid'); const funcs = session.get('funcs'); diff --git a/game-server/app/services/rewardService.ts b/game-server/app/services/rewardService.ts index bf62de304..e2db36fd1 100644 --- a/game-server/app/services/rewardService.ts +++ b/game-server/app/services/rewardService.ts @@ -7,7 +7,7 @@ import { pushCalPlayerCe, pushCalAllHeroCe, calPlayerCeAndSave } from './playerC import { ItemModel } from '../db/Item'; import { STATUS } from '../consts/statusCode'; import { pinus } from 'pinus'; -import { addEquips, addBags, addSkin, addFigure, unlockFigure as pubUnlockFigure, createHeroes as pubCreateHeroes, transPiece } from '../pubUtils/itemUtils'; +import { addEquips, addBags, addSkin, addFigure, unlockFigure as pubUnlockFigure, createHeroes as pubCreateHeroes, transPiece, getGoldObject, getCoinObject, getApObject } from '../pubUtils/itemUtils'; import { ItemInter, RewardInter, } from '../pubUtils/interface'; import { gameData } from '../pubUtils/data'; import { uniq } from 'underscore'; @@ -147,6 +147,16 @@ export async function addItems(roleId: string, roleName: string, sid: string, go pinus.app.get('channelService').pushMessageByUids('onPlayerDataChange', resResult(STATUS.SUCCESS, { gold: role.gold, coin: role.coin, ap: addAp }), uids); + if(gold.length > 0) { + let goldCount = gold.reduce((pre, cur) => { return pre + cur.count }, 0) + showItems.push(getGoldObject(goldCount)); + } + if(coin > 0) { + showItems.push(getCoinObject(coin)); + } + if(ap > 0) { + showItems.push(getApObject(ap)); + } } // 4. 皮肤处理 @@ -158,7 +168,6 @@ export async function addItems(roleId: string, roleName: string, sid: string, go for (let skinId of skins) {//皮肤推送 let result = await addSkin(roleId, roleName, skinId, false); - console.log(result) if (!!result) { showItems.push({ id: skinId, count: 1 }); figureInfos.push(result.figureInfo); diff --git a/shared/pubUtils/itemUtils.ts b/shared/pubUtils/itemUtils.ts index 95d23faed..d53f54e65 100644 --- a/shared/pubUtils/itemUtils.ts +++ b/shared/pubUtils/itemUtils.ts @@ -149,6 +149,13 @@ export function getCoinObject(count: number) { return { id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.COIN), count }; } +/** + * @description 获取体力物品 { id, count } + * @param count 体力数量 + */ + export function getApObject(count: number) { + return { id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.ACTION_POINT), count }; +} /** * @description 获取友情点物品 { id, count } * @param count 友情点数量