✨ feat(远征): 跨关卡保留盾
This commit is contained in:
@@ -262,7 +262,7 @@ export class ExpeditionBattleHandler {
|
|||||||
* 战斗结算
|
* 战斗结算
|
||||||
* 结算战斗奖励,更新远征状态
|
* 结算战斗奖励,更新远征状态
|
||||||
*/
|
*/
|
||||||
async battleEnd(msg: { expeditionCode: string, expeditionId: number, battleCode: string, battleId: number, isSuccess: boolean, heroes: Array<{ dataId: number, hp: number, ap: number, shield: number }>, enemies: Array<{ dataId: number, hp: number, ap: number }>, star: number, stars: number[], damageRecords: pvpEndParamInter[], round: number }, session: BackendSession) {
|
async battleEnd(msg: { expeditionCode: string, expeditionId: number, battleCode: string, battleId: number, isSuccess: boolean, heroes: Array<{ dataId: number, hp: number, ap: number, shield: number, others: string }>, enemies: Array<{ dataId: number, hp: number, ap: number }>, star: number, stars: number[], damageRecords: pvpEndParamInter[], round: number }, session: BackendSession) {
|
||||||
|
|
||||||
const { expeditionCode, battleCode, battleId, expeditionId, isSuccess, heroes = [], star, stars = [], enemies, damageRecords, round } = msg;
|
const { expeditionCode, battleCode, battleId, expeditionId, isSuccess, heroes = [], star, stars = [], enemies, damageRecords, round } = msg;
|
||||||
let roleId = session.get('roleId');
|
let roleId = session.get('roleId');
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export async function getExpeditionStatus(roleId: string, roleName: string, isEn
|
|||||||
curLv,
|
curLv,
|
||||||
expeditionWarRecord,
|
expeditionWarRecord,
|
||||||
pointRewards,
|
pointRewards,
|
||||||
heroes: heroes.map(cur => { return { "dataId": cur.seqId, "hp": cur.hp, "ap": cur.ap, "shield": cur.shield || 0} }),
|
heroes: heroes.map(cur => { return { "dataId": cur.seqId, "hp": cur.hp, "ap": cur.ap, "shield": cur.shield || 0, "others": cur.others || ''} }),
|
||||||
resetCnt
|
resetCnt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ class Heroes {
|
|||||||
ap: number; // 怒气
|
ap: number; // 怒气
|
||||||
@prop({ required: true, default: 0 })
|
@prop({ required: true, default: 0 })
|
||||||
shield: number; // 守护盾
|
shield: number; // 守护盾
|
||||||
|
@prop({ required: true, default: '' })
|
||||||
|
others: string; // 守护盾
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +43,7 @@ export default class ExpeditionRecord extends BaseModel {
|
|||||||
return result;
|
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 code = genCode(8);
|
||||||
|
|
||||||
const result: ExpeditionRecordType = await ExpeditionRecordModel.findOneAndUpdate({ expeditionCode: code }, {...params, status: 1}, { new: true, upsert: true }).lean(lean);
|
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
|
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();
|
let pushArr = new Array(), updateArr = new Array();
|
||||||
for(let hero of heroes) {
|
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);
|
let obj = oldHeroes.find(cur => cur.seqId == dataId);
|
||||||
|
|
||||||
if(!!obj) {
|
if(!!obj) {
|
||||||
updateArr.push({seqId: dataId, hp, ap, shield});
|
updateArr.push({seqId: dataId, hp, ap, shield, others});
|
||||||
} else {
|
} 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(
|
await ExpeditionRecordModel.findOneAndUpdate(
|
||||||
{expeditionCode, 'heroes.seqId': seqId },
|
{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(
|
const result: ExpeditionRecordType = await ExpeditionRecordModel.findOneAndUpdate(
|
||||||
|
|||||||
Reference in New Issue
Block a user