战力:地玉&羁绊
This commit is contained in:
@@ -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<number, number>(); // 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user