🐞 fix(expedition battle): 永久类守护盾远征切关时保留
This commit is contained in:
@@ -10,6 +10,9 @@ class Heroes {
|
||||
hp: number; // 血量
|
||||
@prop({ required: true })
|
||||
ap: number; // 怒气
|
||||
@prop({ required: true, default: 0 })
|
||||
shield: number; // 守护盾
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,7 +41,7 @@ export default class ExpeditionRecord extends BaseModel {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async createRecord(params: { roleId: string, roleName: string, heroes: Array<{seqId: number, hp: number, ap: number}>, myCe: number }, lean = true) {
|
||||
public static async createRecord(params: { roleId: string, roleName: string, heroes: Array<{seqId: number, hp: number, ap: number, shield: number}>, myCe: number }, lean = true) {
|
||||
const code = genCode(8);
|
||||
|
||||
const result: ExpeditionRecordType = await ExpeditionRecordModel.findOneAndUpdate({ expeditionCode: code }, {...params, status: 1}, { new: true, upsert: true }).lean(lean);
|
||||
@@ -56,22 +59,22 @@ export default class ExpeditionRecord extends BaseModel {
|
||||
return result
|
||||
}
|
||||
|
||||
public static async updateHeroStatus(expeditionCode: string, oldHeroes: Array<Heroes>, heroes: Array<{dataId: number, hp: number, ap: number}>, lean=true) {
|
||||
public static async updateHeroStatus(expeditionCode: string, oldHeroes: Array<Heroes>, heroes: Array<{dataId: number, hp: number, ap: number, shield: number}>, lean=true) {
|
||||
let pushArr = new Array(), updateArr = new Array();
|
||||
for(let hero of heroes) {
|
||||
let {dataId, hp, ap} = hero;
|
||||
let {dataId, hp, ap, shield = 0} = hero;
|
||||
let obj = oldHeroes.find(cur => cur.seqId == dataId);
|
||||
|
||||
if(!!obj) {
|
||||
updateArr.push({seqId: dataId, hp, ap});
|
||||
updateArr.push({seqId: dataId, hp, ap, shield});
|
||||
} else {
|
||||
pushArr.push({seqId: dataId, hp, ap})
|
||||
pushArr.push({seqId: dataId, hp, ap, shield})
|
||||
}
|
||||
}
|
||||
for(let {seqId, hp, ap} of updateArr) {
|
||||
for(let {seqId, hp, ap, shield} of updateArr) {
|
||||
await ExpeditionRecordModel.findOneAndUpdate(
|
||||
{expeditionCode, 'heroes.seqId': seqId },
|
||||
{$set: {'heroes.$.seqId': seqId, 'heroes.$.hp': hp, 'heroes.$.ap': ap}}
|
||||
{$set: {'heroes.$.seqId': seqId, 'heroes.$.hp': hp, 'heroes.$.ap': ap, 'heroes.$.shield': shield}}
|
||||
)
|
||||
}
|
||||
const result: ExpeditionRecordType = await ExpeditionRecordModel.findOneAndUpdate(
|
||||
|
||||
Reference in New Issue
Block a user