From 6be0cf17925796233cdb41d26e4a7b8129b43135 Mon Sep 17 00:00:00 2001 From: luying Date: Thu, 28 Apr 2022 17:08:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=98=E5=8A=9B=EF=BC=9A=E5=9C=B0=E7=8E=89&?= =?UTF-8?q?=E7=BE=81=E7=BB=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game-server/app/services/playerCeService.ts | 4 ++-- game-server/app/services/role/calCe.ts | 25 +++++++++++++-------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/game-server/app/services/playerCeService.ts b/game-server/app/services/playerCeService.ts index bbf3d2308..fd6281317 100644 --- a/game-server/app/services/playerCeService.ts +++ b/game-server/app/services/playerCeService.ts @@ -146,8 +146,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve case HERO_SYSTEM_TYPE.CONNECT: // 9. 羁绊 { for(let [ hid, { connections } ] of heroUpdates) { - let { shipId } = param; - calCe.setConnection(hid, shipId, connections); + calCe.setConnection(hid, connections); } break; } @@ -262,6 +261,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve for(let [hid, { ePlace = [] }] of heroUpdates) { for(let { id, stones } of ePlace) { if(ePlaceId == id) { + calCe.setStone(hid, ePlaceId, stones); calCe.setJewel(hid, id, stones, curJewel); } } diff --git a/game-server/app/services/role/calCe.ts b/game-server/app/services/role/calCe.ts index 8aa3cf065..b5e0f85ce 100644 --- a/game-server/app/services/role/calCe.ts +++ b/game-server/app/services/role/calCe.ts @@ -198,17 +198,24 @@ export class CalCe { } // 羁绊 - public setConnection(hid: number, shipId: number, connections: Connect[]) { + public setConnection(hid: number, connections: Connect[]) { this.data.clearHeroAttrByHid(hid, 'connect'); - let connect = connections.find(cur => cur.shipId == shipId); - let level = connect?.level||0; - - let currentShip = getFriendShipById(shipId, level); - if (currentShip) { - for (let { id, number: val } of currentShip.attributes) { - let heroAttr = this.data.getHeroAttrByHidAndId(hid, id); - heroAttr.connect = val; + let map = new Map(); // attrId => val; + for(let { shipId, level = 0 } of connections) { + let currentShip = getFriendShipById(shipId, level); + if (currentShip) { + for (let { id, number: val } of currentShip.attributes) { + if(!map.has(id)) { + map.set(id, val); + } else { + map.set(id, map.get(id) + val); + } + } } + } + for(let [id, val] of map) { + let heroAttr = this.data.getHeroAttrByHidAndId(hid, id); + heroAttr.connect = val; } }