🐞 fix(稷下学宫): 修改恢复hp时过滤hp为0的情况

This commit is contained in:
zhangxk
2023-09-09 16:06:38 +08:00
parent afe0f472eb
commit cd9b20a4ac
2 changed files with 5 additions and 2 deletions

View File

@@ -783,7 +783,8 @@ export class RougeHandler {
let updateCharas: RougelikeCharaPara[] = [];
let hpRatio = await getRecoveryExtendHp(roleId, gameCode);
for (let { gameCode, charaCode, charaId, cards, hp, maxHp = 0, ap, shield, roundSkill, apSkill } of dbCharas) {
for (let { gameCode, charaCode, charaId, cards, hp = 0, maxHp = 0, ap, shield, roundSkill, apSkill } of dbCharas) {
if (hp == 0) continue;
let beforeHp = hp;
hp = Math.floor(Math.min(hp + maxHp * ROUGELIKE.RECOVERY_RATIO / 100 + maxHp * hpRatio / 100, maxHp));
updateCharas.push({ gameCode, charaCode, hp });

View File

@@ -961,7 +961,9 @@ export async function updateMaxHp(roleId: string, gameCode: string, type: number
if (tempMaxHp == val.maxHp && updateCharasMap && !updateCharasMap.has(val.charaCode)) continue;
let preMaxHp = val.maxHp;
val.maxHp = tempMaxHp;
val.hp = Math.min(val.hp + tempMaxHp - preMaxHp, tempMaxHp);
if (val.hp > 0) {
val.hp = Math.min(val.hp + tempMaxHp - preMaxHp, tempMaxHp);
}
result.push(val);
}
await RougelikeCharaModel.bulkWriteUpdate(result);