✨ feat(远征): 跨关卡保留盾
This commit is contained in:
@@ -12,6 +12,8 @@ class Heroes {
|
||||
ap: number; // 怒气
|
||||
@prop({ required: true, default: 0 })
|
||||
shield: number; // 守护盾
|
||||
@prop({ required: true, default: '' })
|
||||
others: string; // 守护盾
|
||||
|
||||
}
|
||||
|
||||
@@ -41,7 +43,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, shield: number}>, myCe: number }, lean = true) {
|
||||
public static async createRecord(params: { roleId: string, roleName: string, heroes: Array<{seqId: number, hp: number, ap: number, shield: number, others: string }>, 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);
|
||||
@@ -59,22 +61,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, shield: number}>, lean=true) {
|
||||
public static async updateHeroStatus(expeditionCode: string, oldHeroes: Array<Heroes>, heroes: Array<{dataId: number, hp: number, ap: number, shield: number, others: string}>, lean=true) {
|
||||
let pushArr = new Array(), updateArr = new Array();
|
||||
for(let hero of heroes) {
|
||||
let {dataId, hp, ap, shield = 0} = hero;
|
||||
let {dataId, hp, ap, shield = 0, others = ""} = hero;
|
||||
let obj = oldHeroes.find(cur => cur.seqId == dataId);
|
||||
|
||||
if(!!obj) {
|
||||
updateArr.push({seqId: dataId, hp, ap, shield});
|
||||
updateArr.push({seqId: dataId, hp, ap, shield, others});
|
||||
} else {
|
||||
pushArr.push({seqId: dataId, hp, ap, shield})
|
||||
pushArr.push({seqId: dataId, hp, ap, shield, others})
|
||||
}
|
||||
}
|
||||
for(let {seqId, hp, ap, shield} of updateArr) {
|
||||
for(let {seqId, hp, ap, shield, others} of updateArr) {
|
||||
await ExpeditionRecordModel.findOneAndUpdate(
|
||||
{expeditionCode, 'heroes.seqId': seqId },
|
||||
{$set: {'heroes.$.seqId': seqId, 'heroes.$.hp': hp, 'heroes.$.ap': ap, 'heroes.$.shield': shield}}
|
||||
{$set: {'heroes.$.seqId': seqId, 'heroes.$.hp': hp, 'heroes.$.ap': ap, 'heroes.$.shield': shield, 'heroes.$.others': others}}
|
||||
)
|
||||
}
|
||||
const result: ExpeditionRecordType = await ExpeditionRecordModel.findOneAndUpdate(
|
||||
|
||||
Reference in New Issue
Block a user