🐞 fix(expedition battle): 永久类守护盾远征切关时保留
This commit is contained in:
@@ -256,7 +256,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 }>, enemies: Array<{ dataId: number, hp: number, ap: number }>, star: number, stars: 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 }>, enemies: Array<{ dataId: number, hp: number, ap: number }>, star: number, stars: number[] }, session: BackendSession) {
|
||||
|
||||
const { expeditionCode, battleCode, battleId, expeditionId, isSuccess, heroes = [], star, stars = [], enemies } = msg;
|
||||
let roleId = session.get('roleId');
|
||||
|
||||
@@ -51,7 +51,7 @@ export async function getExpeditionStatus(roleId: string, roleName: string, isEn
|
||||
curLv,
|
||||
expeditionWarRecord,
|
||||
pointRewards,
|
||||
heroes: heroes.map(cur => { return { "dataId": cur.seqId, "hp": cur.hp, "ap": cur.ap } }),
|
||||
heroes: heroes.map(cur => { return { "dataId": cur.seqId, "hp": cur.hp, "ap": cur.ap, "shield": cur.shield || 0} }),
|
||||
resetCnt
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,6 +274,7 @@ describe('战斗测试', function () {
|
||||
expect(hero.dataId).to.be.a('number');
|
||||
expect(hero.hp).to.be.a('number');
|
||||
expect(hero.ap).to.be.a('number');
|
||||
expect(hero.shield).to.be.a('number');
|
||||
});
|
||||
expect(res.data.resetCnt).to.be.a('number');
|
||||
done();
|
||||
@@ -331,8 +332,8 @@ describe('战斗测试', function () {
|
||||
});
|
||||
|
||||
it('远征关卡结束战斗', function (done) {
|
||||
let { expeditionId, battleId } = expeditionWarRecord;
|
||||
let heroes = paramHeroes.map(hero => { return { dataId: hero, hp: 100, ap: 100 }})
|
||||
let { expeditionId, battleId } = expeditionWarRecord;
|
||||
let heroes = paramHeroes.map(hero => { return { dataId: hero, hp: 100, ap: 100, shield: 100 }})
|
||||
pinusClient.request('battle.expeditionBattleHandler.battleEnd', {
|
||||
expeditionCode, expeditionId, battleId, battleCode, heroes, enemies: [], star: 3, stars: [], isSuccess: true
|
||||
}, (res) => {
|
||||
|
||||
@@ -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