🐞 fix(稷下学宫): 点亮法阵更新最大hp
This commit is contained in:
@@ -938,17 +938,17 @@ export async function getMaxHp(roleId: string, gameCode: string, charaId: number
|
|||||||
return Math.floor(maxHp);
|
return Math.floor(maxHp);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateMaxHp(roleId: string, gameCode: string, type: number, grade: number, updateCharasMap) {
|
export async function updateMaxHp(roleId: string, gameCode: string, type: number, grade: number, updateCharasMap?: Map<string,RougelikeCharaType[]>) {
|
||||||
let dbCharas = await RougelikeCharaModel.findByGameCode(gameCode);
|
let dbCharas = await RougelikeCharaModel.findByGameCode(gameCode);
|
||||||
if (dbCharas.length == 0) return [];
|
if (dbCharas.length == 0) return [];
|
||||||
|
|
||||||
let result: RougelikeCharaType[] = [];
|
let result: RougelikeCharaType[] = [];
|
||||||
for (let val of dbCharas) {
|
for (let val of dbCharas) {
|
||||||
if (updateCharasMap.has(val.charaCode)) {
|
if (updateCharasMap && updateCharasMap.has(val.charaCode)) {
|
||||||
val = { ...val, ...updateCharasMap.get(val.charaCode) }
|
val = { ...val, ...updateCharasMap.get(val.charaCode) }
|
||||||
}
|
}
|
||||||
let tempMaxHp = await getMaxHp(roleId, gameCode, val.charaId, type, grade);
|
let tempMaxHp = await getMaxHp(roleId, gameCode, val.charaId, type, grade);
|
||||||
if (tempMaxHp == val.maxHp && !updateCharasMap.has(val.charaCode)) continue;
|
if (tempMaxHp == val.maxHp && updateCharasMap && !updateCharasMap.has(val.charaCode)) continue;
|
||||||
val.maxHp = tempMaxHp;
|
val.maxHp = tempMaxHp;
|
||||||
result.push(val);
|
result.push(val);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ import { Circle, RougelikeTechModel, RougelikeTechType } from '../../db/Rougelik
|
|||||||
import { gameData } from '../../pubUtils/data';
|
import { gameData } from '../../pubUtils/data';
|
||||||
import { HeroModel } from '../../db/Hero';
|
import { HeroModel } from '../../db/Hero';
|
||||||
import { compareNumberArray } from '../../pubUtils/util';
|
import { compareNumberArray } from '../../pubUtils/util';
|
||||||
|
import { ROUGE_EFFECT_TYPE, ROUGE_LIKE_STATUS } from '../../consts';
|
||||||
|
import { updateMaxHp } from './rougeService';
|
||||||
|
import { RougelikeRecordModel } from '../../db/RougelikeRecord';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 首页获得的科技树数据
|
* 首页获得的科技树数据
|
||||||
@@ -42,10 +45,28 @@ async function calCircleCe(roleId: string, unlockedTech: number[], circles: Circ
|
|||||||
export async function updateEffectId(techData: RougelikeTechType) {
|
export async function updateEffectId(techData: RougelikeTechType) {
|
||||||
let effectIds = getTechEffectIdsByData(techData);
|
let effectIds = getTechEffectIdsByData(techData);
|
||||||
if(!compareNumberArray(effectIds, techData.effectIds||[])) {
|
if(!compareNumberArray(effectIds, techData.effectIds||[])) {
|
||||||
|
if (hasMaxHpUpdate(effectIds, techData.effectIds||[])) {
|
||||||
|
const dbRecord = await RougelikeRecordModel.findByRoleIdAndStatus(techData.roleId, ROUGE_LIKE_STATUS.SUCCESS)
|
||||||
|
if(dbRecord) await updateMaxHp(techData.roleId, dbRecord.gameCode, dbRecord.type, dbRecord.grade)
|
||||||
|
}
|
||||||
await RougelikeTechModel.updateEffectId(techData.roleId, effectIds);
|
await RougelikeTechModel.updateEffectId(techData.roleId, effectIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hasMaxHpUpdate(effectIds: number[], oldEffectIds: number[]) {
|
||||||
|
let newEffectIds: number[] = [];
|
||||||
|
for(let effectId of effectIds) {
|
||||||
|
if (oldEffectIds.includes(effectId)) newEffectIds.push(effectId);
|
||||||
|
}
|
||||||
|
for(let effectId of newEffectIds) {
|
||||||
|
let dicRougeEffect = gameData.rougeEffect.get(effectId);
|
||||||
|
if(dicRougeEffect && dicRougeEffect.effectType == ROUGE_EFFECT_TYPE.TECH_CHARA_MAIN_ATTR_UP) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理后单个科技点的数据
|
* 处理后单个科技点的数据
|
||||||
* @param techData
|
* @param techData
|
||||||
|
|||||||
Reference in New Issue
Block a user