🐞 fix(共鸣系统): 修改鸣主排序,修改鸣主信息展示

This commit is contained in:
zhangxk
2023-10-12 21:17:49 +08:00
parent b6e6281744
commit e4e692458b
4 changed files with 78 additions and 46 deletions

View File

@@ -617,6 +617,9 @@ export class HeroHandler {
let { hid } = msg;
if(!isNumber(hid) && !hid) return resResult(STATUS.WRONG_PARMS);
let { dbResonanceMap } = await getResonanceDataMap(roleId);
if(dbResonanceMap.has(hid)) return resResult(STATUS.RESONANCE__HID_NOT_REBIRTH);
// 武将初始,但是皮肤这里不初始
let hero = await HeroModel.findByHidAndRole(hid, roleId);
if(!hero) return resResult(STATUS.HERO_NOT_FIND);
@@ -831,6 +834,10 @@ export class HeroHandler {
const { originHid, targetHid } = msg;
let { dbResonanceMap } = await getResonanceDataMap(roleId);
if(dbResonanceMap.has(originHid) || dbResonanceMap.has(targetHid)) return resResult(STATUS.RESONANCE__HID_NOT_REBIRTH);
let dbHeros = await HeroModel.findByHidsAndRole(roleId, [originHid, targetHid]);
if (dbHeros.length != 2) return resResult(STATUS.HERO_NOT_FIND);
const heroMap = dbHeros.reduce((map, obj) => { map.set(obj.hid, obj); return map; }, new Map<number, HeroType>());

View File

@@ -164,7 +164,7 @@ export class HeroHandler {
const resonances = await refreshResonanceData(roleId, serverId, sid);
return resResult(STATUS.SUCCESS, {
curHero: { ...pick(new HeroParam(curHero), ['hid', 'seqId', 'lv', 'exp', 'job', 'jobStage', 'skinId', 'skins', 'talent', 'usedTalentPoint', 'totalTalentPoint', 'connections', 'ePlace', 'ce']) },
curHero: { isResonance: false, ...pick(new HeroParam(curHero), ['hid', 'seqId', 'lv', 'exp', 'job', 'jobStage', 'skinId', 'skins', 'talent', 'usedTalentPoint', 'totalTalentPoint', 'connections', 'ePlace', 'ce']) },
...resonances,
})
}

View File

@@ -23,7 +23,12 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
let resonanceLv = {}, resonanceJob = {}, resonanceCon = [], resonanceEquip = [], resonanceEpQuality = [], resonanceEpStar = [], resonanceJewel = [], resonanceStone = [];
let dbHeroes: HeroType[] = await HeroModel.findByRole(roleId, [{ field: 'ce', sortBy: -1 }]);
if (dbHeroes.length < LINEUP_NUM) return { resonanceDatas };
let role = await RoleModel.findByRoleId(roleId);
let topLineHeroes: HeroType[] = [];
for (let top of role.topLineup) {
topLineHeroes.push(dbHeroes.find(cur => cur.hid == top.hid));
}
if (topLineHeroes.length < LINEUP_NUM || dbHeroes.length < LINEUP_NUM) return { resonanceDatas };
let { dbResonanceMap, newPositionArr } = await getResonanceDataMap(roleId);
@@ -35,7 +40,7 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
let dbJewelMap = await getJewelDataMap(dbHeroes);
// 武将等级
let topLineHero: HeroType = sortData(dbResonanceMap, dbHeroes, RESONANCE_SORT_TYPE.LV);
let topLineHero: HeroType = sortData(dbResonanceMap, topLineHeroes, RESONANCE_SORT_TYPE.LV);
resonanceLv = { hid: topLineHero.hid, lv: topLineHero.lv };
for (let [hid] of dbResonanceMap) {
let hero = dbHeroes.find(cur => cur.hid == hid);
@@ -44,7 +49,7 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
}
// 职业(职阶、天赋)
topLineHero = sortData(dbResonanceMap, dbHeroes, RESONANCE_SORT_TYPE.JOBSTAGE);
topLineHero = sortData(dbResonanceMap, topLineHeroes, RESONANCE_SORT_TYPE.JOBSTAGE);
resonanceJob = { hid: topLineHero.hid, job: topLineHero.job, jobStage: topLineHero.jobStage };
for (let [hid] of dbResonanceMap) {
let hero = dbHeroes.find(cur => cur.hid == hid);
@@ -60,21 +65,22 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
// 羁绊1, 2, 3
for (let index = 1; index <= FRIENDSHIP_INDEX.THREE; index++) {
topLineHero = sortData(dbResonanceMap, dbHeroes, RESONANCE_SORT_TYPE.CONNECT, index);
topLineHero = sortData(dbResonanceMap, topLineHeroes, RESONANCE_SORT_TYPE.CONNECT, index);
resonanceCon.push({ hid: topLineHero.hid, index, level: topLineHero.connections[index]?.level || 0 });
const topDicShipId = gameData.friendShipByIndex.get(`${topLineHero.hid}_${index}`);
const topShipData = topLineHero.connections.find(cur => cur.shipId == topDicShipId);
if (!topShipData) continue;
for (let [hid] of dbResonanceMap) {
let hero = dbHeroes.find(cur => cur.hid == hid);
const topDicShipId = gameData.friendShipByIndex.get(`${topLineHero.hid}_${index}`);
const topShipData = topLineHero.connections.find(cur => cur.shipId == topDicShipId);
if (!topShipData) continue;
const dicShipId = gameData.friendShipByIndex.get(`${hero.hid}_${index}`)
let shipData = hero.connections.find(cur => cur.shipId == dicShipId);
if (!shipData) hero.connections.push({ shipId: dicShipId, level: topShipData.level, exp: topShipData.exp });
else {
shipData.exp = topShipData.exp;
shipData.level = topShipData.level;
}
if (!shipData) continue; //hero.connections.push({ shipId: dicShipId, level: topShipData.level, exp: topShipData.exp });
shipData.exp = topShipData.exp;
shipData.level = topShipData.level;
let tempCon = resonanceCon.find(cur => cur.index == index);
tempCon.level = topShipData.level;
}
@@ -84,13 +90,17 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
for (let id = 1; id <= EQUIP_EPLACEID.SHOE_ID; id++) {
//装备强化
topLineHero = sortData(dbResonanceMap, dbHeroes, RESONANCE_SORT_TYPE.EQUIP_LV, id);
resonanceEquip.push({ hid: topLineHero.hid, id, lv: topLineHero.ePlace.find(cur => cur.id == id)?.lv || 0 });
for (let [hid] of dbResonanceMap) {
let hero = dbHeroes.find(cur => cur.hid == hid);
const topLineHeroEplace = topLineHero.ePlace.find(cur => cur.id == id);
if (!topLineHeroEplace || !topLineHeroEplace.lv) continue;
topLineHero = sortData(dbResonanceMap, topLineHeroes, RESONANCE_SORT_TYPE.EQUIP_LV, id);
let topLineHeroEplace = topLineHero.ePlace.find(cur => cur.id == id);
resonanceEquip.push({ hid: topLineHero.hid, id, lv: 0 });
if (topLineHeroEplace)
resonanceEquip.push({ hid: topLineHero.hid, id, lv: topLineHeroEplace?.lv || 0 });
for (let [hid] of dbResonanceMap) {
if (!topLineHeroEplace || !topLineHeroEplace.lv) continue;
let hero = dbHeroes.find(cur => cur.hid == hid);
let ePlaceData = hero.ePlace.find(cur => cur.id == id);
if (!ePlaceData) {
hero.ePlace.push({ ...await getInitEplace(id, hero.skinId) });
@@ -100,55 +110,60 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
}
//装备升品
topLineHero = sortData(dbResonanceMap, dbHeroes, RESONANCE_SORT_TYPE.EQUIP_QUALITY, id);
resonanceEpQuality.push({ hid: topLineHero.hid, id, quality: topLineHero.quality, qualityStage: topLineHero.quality })
for (let [hid] of dbResonanceMap) {
let hero = dbHeroes.find(cur => cur.hid == hid);
const topLineHeroEplace = topLineHero.ePlace.find(cur => cur.id == id);
if (!topLineHeroEplace || !topLineHeroEplace.quality) continue;
topLineHero = sortData(dbResonanceMap, topLineHeroes, RESONANCE_SORT_TYPE.EQUIP_QUALITY, id);
topLineHeroEplace = topLineHero.ePlace.find(cur => cur.id == id);
resonanceEpQuality.push({ hid: topLineHero.hid, id, quality: 0, qualityStage: 0 })
if (topLineHeroEplace)
resonanceEpQuality.push({ hid: topLineHero.hid, id, quality: topLineHeroEplace?.quality || 0, qualityStage: topLineHeroEplace?.qualityStage || 0 })
for (let [hid] of dbResonanceMap) {
if (!topLineHeroEplace && !topLineHeroEplace.quality || !topLineHeroEplace.qualityStage) continue;
let hero = dbHeroes.find(cur => cur.hid == hid);
let ePlaceData = hero.ePlace.find(cur => cur.id == id);
if (!ePlaceData) {
hero.ePlace.push({ ...await getInitEplace(id, hero.skinId) });
ePlaceData = hero.ePlace.find(cur => cur.id == id);
};
ePlaceData.quality = topLineHeroEplace.quality;
ePlaceData.qualityStage = topLineHeroEplace.qualityStage;
}
//装备精练
topLineHero = sortData(dbResonanceMap, dbHeroes, RESONANCE_SORT_TYPE.EQUIP_STAR, id);
resonanceEpStar.push({ hid: topLineHero.hid, id, star: topLineHero.star, starStage: topLineHero.starStage })
for (let [hid] of dbResonanceMap) {
let hero = dbHeroes.find(cur => cur.hid == hid);
const topLineHeroEplace = topLineHero.ePlace.find(cur => cur.id == id);
if (!topLineHeroEplace || !topLineHeroEplace.star) continue;
topLineHero = sortData(dbResonanceMap, topLineHeroes, RESONANCE_SORT_TYPE.EQUIP_STAR, id);
topLineHeroEplace = topLineHero.ePlace.find(cur => cur.id == id);
resonanceEpStar.push({ hid: topLineHero.hid, id, star: 0, starStage: 0 })
if (topLineHeroEplace)
resonanceEpStar.push({ hid: topLineHero.hid, id, star: topLineHeroEplace?.star || 0, starStage: topLineHeroEplace?.starStage || 0 })
for (let [hid] of dbResonanceMap) {
if (!topLineHeroEplace || !topLineHeroEplace.star || !topLineHeroEplace.starStage) continue;
let hero = dbHeroes.find(cur => cur.hid == hid);
let ePlaceData = hero.ePlace.find(cur => cur.id == id);
if (!ePlaceData) {
hero.ePlace.push({ ...await getInitEplace(id, hero.skinId) });
ePlaceData = hero.ePlace.find(cur => cur.id == id);
};
ePlaceData.star = topLineHeroEplace.star;
ePlaceData.starStage = topLineHeroEplace.starStage;
}
//天晶
if (RESONANCE.JEWEL) {
topLineHero = sortData(dbResonanceMap, dbHeroes, RESONANCE_SORT_TYPE.JEWEL, id, dbJewelMap);
resonanceJewel.push({ hid: topLineHero.hid, id, jewel: topLineHero.ePlace.find(cur => cur.id == id)?.jewel || 0 })
topLineHero = sortData(dbResonanceMap, topLineHeroes, RESONANCE_SORT_TYPE.JEWEL, id, dbJewelMap);
topLineHeroEplace = topLineHero.ePlace.find(cur => cur.id == id);
resonanceJewel.push({ hid: topLineHero.hid, id, jewel: 0 });
if (topLineHeroEplace)
resonanceJewel.push({ hid: topLineHero.hid, id, jewel: topLineHeroEplace?.jewel || 0 });
//破,御,护,命
for (let [hid] of dbResonanceMap) {
let hero = dbHeroes.find(cur => cur.hid == hid);
const topLineHeroEplace = topLineHero.ePlace.find(cur => cur.id == id);
if (!topLineHeroEplace || !topLineHeroEplace.jewel) continue;
let hero = dbHeroes.find(cur => cur.hid == hid);
let ePlaceData = hero.ePlace.find(cur => cur.id == id);
if (!ePlaceData) {
hero.ePlace.push({ ...await getInitEplace(id, hero.skinId) });
ePlaceData = hero.ePlace.find(cur => cur.id == id);
};
ePlaceData.jewel = topLineHeroEplace.jewel;
}
}
@@ -157,23 +172,29 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
//破,御,护,命 1,2,3
resonanceStone.push({ id, stones: [] });
for (let index = 1; index <= EQUIP_STONE.THREE; index++) {
topLineHero = sortData(dbResonanceMap, dbHeroes, RESONANCE_SORT_TYPE.STONE, id, null, index);
topLineHero = sortData(dbResonanceMap, topLineHeroes, RESONANCE_SORT_TYPE.STONE, id, null, index);
const topLineHeroEplace = topLineHero.ePlace.find(cur => cur.id == id);
resonanceStone.find(cur => cur.id == id).stones.push({ hid: topLineHero.hid, id: index, stone: 0 });
if (topLineHeroEplace && topLineHeroEplace.stones) {
const topLineHeroStone = topLineHeroEplace.stones.find(cur => cur.id == index);
if (topLineHeroStone)
resonanceStone.find(cur => cur.id == id).stones.find(cur => cur.id == index).stone = topLineHeroStone.stone;
}
for (let [hid] of dbResonanceMap) {
let hero = dbHeroes.find(cur => cur.hid == hid);
const topLineHeroEplace = topLineHero.ePlace.find(cur => cur.id == id);
if (!topLineHeroEplace || !topLineHeroEplace.stones) continue;
if (!topLineHeroEplace && !topLineHeroEplace.stones) continue;
const topLineHeroStone = topLineHeroEplace.stones.find(cur => cur.id == index);
if (!topLineHeroStone || !topLineHeroStone.stone) continue;
let hero = dbHeroes.find(cur => cur.hid == hid);
let ePlaceData = hero.ePlace.find(cur => cur.id == id);
if (!ePlaceData) {
hero.ePlace.push({ ...await getInitEplace(id, hero.skinId) });
ePlaceData = hero.ePlace.find(cur => cur.id == id);
};
ePlaceData.stones.find(cur => cur.id == index).stone = topLineHeroStone.stone;
resonanceStone.find(cur => cur.id == id).stones.find(cur => cur.id == index).stone = topLineHeroStone.stone;
}
}
}

View File

@@ -846,6 +846,10 @@ export const STATUS = {
RESONANCE_NOT_PUT_POSITION: { code: 81013, simStr: '该武将未在阵中' },
RESONANCE_OFF_POSITION_FAIL: { code: 81014, simStr: '该武将下阵失败' },
RESONANCE__HID_NOT_CAN: { code: 81015, simStr: '共鸣武将不可养成' },
RESONANCE__HID_NOT_REBIRTH: { code: 81015, simStr: '共鸣武将不可重生' },
RESONANCE__HID_NOT_REBORN: { code: 81015, simStr: '共鸣武将不可传承' },