fix 修复远征当前血量和最大血量无法匹配bug

This commit is contained in:
luying
2020-11-19 10:37:39 +08:00
parent f07109d11c
commit 225d55f98f
6 changed files with 55 additions and 31 deletions
+2 -1
View File
@@ -193,6 +193,7 @@ export async function calcuHangUpReward(roleId: string, speedUp = false, speedUp
} }
async function checkCond(roleId: string, heroes, type: number, param: number, cnt: number) { async function checkCond(roleId: string, heroes, type: number, param: number, cnt: number) {
let heroCnt = 0; let heroCnt = 0;
switch (type) { switch (type) {
@@ -217,7 +218,7 @@ async function checkCond(roleId: string, heroes, type: number, param: number, cn
for(let seqId of heroes) { for(let seqId of heroes) {
let {hid} = await HeroModel.findBySeqIdAndRole(seqId, roleId); let {hid} = await HeroModel.findBySeqIdAndRole(seqId, roleId);
const hInfo = getHeroInfoById(hid); const hInfo = getHeroInfoById(hid);
if (getJobInfoById(hInfo.jobid) === param) { if (getJobInfoById(hInfo.jobid).job_class === param) {
heroCnt++; heroCnt++;
} }
} }
@@ -41,6 +41,23 @@ export async function findOrCreateEnemies(roleId: string, myCe: number, expediti
} }
} }
} }
// 处理当前血量
let {enemiesCurHpAp, enemies} = expeditionWarRecord;
for(let enemy of enemies) {
let cur = {"hp": 0, "ap": 0};
console.log(enemiesCurHpAp)
let getHp = enemiesCurHpAp && enemiesCurHpAp.find(cur => cur.dataId == enemy.dataId);
if(getHp) {
cur.hp = getHp.hp;
cur.ap = getHp.ap;
} else {
cur.hp = enemy.attribute.hp;
cur.ap = 0;
}
enemy["cur"] = cur;
}
return expeditionWarRecord; return expeditionWarRecord;
} }
+7 -6
View File
@@ -45,9 +45,9 @@ export class WarReward {
let last = str.substr(str.length-1, 1); let last = str.substr(str.length-1, 1);
if(last == '&') str = str.substr(0, str.length - 1); if(last == '&') str = str.substr(0, str.length - 1);
if(str.length) { if(str.length) {
this.fixReward += '|' + reward; this.fixReward = str + '|' + reward;
} else { } else {
this.fixReward += reward; this.fixReward = str + reward;
} }
} }
@@ -56,9 +56,9 @@ export class WarReward {
let last = str.substr(str.length-1, 1); let last = str.substr(str.length-1, 1);
if(last == '&') str = str.substr(0, str.length - 1); if(last == '&') str = str.substr(0, str.length - 1);
if(str.length) { if(str.length) {
this.conditionReward += reward; this.conditionReward = str + '|' + reward;
} else { } else {
this.conditionReward += '|' + reward; this.conditionReward = str + reward;
} }
} }
@@ -67,9 +67,9 @@ export class WarReward {
let last = str.substr(str.length-1, 1); let last = str.substr(str.length-1, 1);
if(last == '&') str = str.substr(0, str.length - 1); if(last == '&') str = str.substr(0, str.length - 1);
if(str.length) { if(str.length) {
this.randomReward += reward; this.randomReward = str + '|' + reward;
} else { } else {
this.randomReward += '|' + reward; this.randomReward = str + reward;
} }
} }
@@ -127,6 +127,7 @@ export class WarReward {
// let warType = this.warInfo.warType; // let warType = this.warInfo.warType;
if(this.isSuccess) { // 成功了才给固定奖励 if(this.isSuccess) { // 成功了才给固定奖励
console.log(this.fixReward)
if(this.fixReward) this.handleFixReward(num, this.fixReward); if(this.fixReward) this.handleFixReward(num, this.fixReward);
if(this.conditionReward) this.handleConditionReward(num, this.conditionReward); if(this.conditionReward) this.handleConditionReward(num, this.conditionReward);
if(this.randomReward) await this.handleRandomReward(num, this.randomReward); if(this.randomReward) await this.handleRandomReward(num, this.randomReward);
+2 -2
View File
@@ -203,7 +203,7 @@ export const EVENT_QUIZ_NUM = 3;
export const DEFAULT_HEROES = [ 312, 314, 311, 309, 315]; export const DEFAULT_HEROES = [ 312, 314, 311, 309, 315];
export const FIX_SMS_CODE_TELS = ['18855953630', '13911134885', '15167549151', '15618654010']; export const FIX_SMS_CODE_TELS = ['18855953630', '13911134885', '15167549151', '15618654010', '15167549151'];
export const GONGSHI = { export const GONGSHI = {
"TOWER_HANG_UP_SPEED_COST": "50", "TOWER_HANG_UP_SPEED_COST": "50",
@@ -251,4 +251,4 @@ export const COM_BATTLE_ROBOT_HURT_RAND_RATE = 0.05;
// 每日情谊点上限 // 每日情谊点上限
export const COM_BATTLE_FRDCNT_MAX = 100; export const COM_BATTLE_FRDCNT_MAX = 100;
// 情谊点掉落数量 // 情谊点掉落数量
export const COM_BATTLE_FRDCNT_DROP = 10; export const COM_BATTLE_FRDCNT_DROP = 10;
+14 -9
View File
@@ -40,6 +40,15 @@ class Enemies {
} }
class EnemiesCurHPAP {
@prop({ required: true })
dataId: number; // 战场中唯一指向武将的代码
@prop({ required: true })
hp: number; // 生命
@prop({ required: true })
ap: number; // 怒气
}
/** /**
* 远征记录 * 远征记录
*/ */
@@ -64,6 +73,8 @@ export default class ExpeditionWarRecord extends BaseModel {
enemyId: string; // 敌军队伍id或玩家id enemyId: string; // 敌军队伍id或玩家id
@prop({ required: true, type: Enemies, default: [] }) @prop({ required: true, type: Enemies, default: [] })
enemies: Array<Enemies>; // 敌军数据 enemies: Array<Enemies>; // 敌军数据
@prop({ required: true, type: EnemiesCurHPAP, default: [] })
enemiesCurHpAp: Array<EnemiesCurHPAP>; // 敌军数据
@prop({ required: true, default: 0 }) @prop({ required: true, default: 0 })
ce: number; // 敌军战力 ce: number; // 敌军战力
@@ -73,14 +84,14 @@ export default class ExpeditionWarRecord extends BaseModel {
} }
public static async getRecordByCodeAndId(expeditionCode: string, expeditionId: number, lean = true) { public static async getRecordByCodeAndId(expeditionCode: string, expeditionId: number, lean = true) {
const result = await ExpeditionWarRecordModel.findOne({ expeditionCode, expeditionId }).select('expeditionId battleId battleCode battleStatus enemyFrom enemies ce').lean(lean); const result = await ExpeditionWarRecordModel.findOne({ expeditionCode, expeditionId }).select('expeditionId battleId battleCode battleStatus enemyFrom enemies enemiesCurHpAp ce').lean(lean);
return result; return result;
} }
public static async saveRecord(expeditionCode: string, expeditionId: number, params: {roleId: string, battleId: number, enemyFrom: number, enemyId: string, enemies: Array<any>, battleStatus: number}, lean = true) { public static async saveRecord(expeditionCode: string, expeditionId: number, params: {roleId: string, battleId: number, enemyFrom: number, enemyId: string, enemies: Array<any>, battleStatus: number}, lean = true) {
const doc = new ExpeditionWarRecordModel(); const doc = new ExpeditionWarRecordModel();
const update = Object.assign(doc.toJSON(), params, {expeditionCode, expeditionId}); const update = Object.assign(doc.toJSON(), params, {expeditionCode, expeditionId});
const result = await ExpeditionWarRecordModel.findOneAndUpdate({ expeditionCode, expeditionId }, update, {new: true, upsert: true}).select('expeditionId battleId battleCode battleStatus enemyFrom enemies ce').lean(lean); const result = await ExpeditionWarRecordModel.findOneAndUpdate({ expeditionCode, expeditionId }, update, {new: true, upsert: true}).select('expeditionId battleId battleCode battleStatus enemyFrom enemies enemiesCurHpAp ce').lean(lean);
return result; return result;
} }
@@ -96,15 +107,9 @@ export default class ExpeditionWarRecord extends BaseModel {
public static async updateEnemiesStatus(expeditionCode: string, expeditionId: number, battleStatus: number, enemies: Array<{dataId: number, hp: number, ap: number}>, lean = true) { public static async updateEnemiesStatus(expeditionCode: string, expeditionId: number, battleStatus: number, enemies: Array<{dataId: number, hp: number, ap: number}>, lean = true) {
for(let {dataId, hp, ap} of enemies) {
await ExpeditionWarRecordModel.findOneAndUpdate(
{expeditionCode, expeditionId, 'enemies.dataId': dataId },
{$set: {'enemies.$.attribute.hp': hp, 'enemies.$.attribute.ap': ap}}
)
}
const result = ExpeditionWarRecordModel.findOneAndUpdate( const result = ExpeditionWarRecordModel.findOneAndUpdate(
{expeditionCode, expeditionId}, {expeditionCode, expeditionId},
{$set: {battleStatus}}, {$set: {battleStatus}, enemiesCurHpAp: enemies},
{new: true} {new: true}
).lean(lean); ).lean(lean);
return result; return result;
+13 -13
View File
@@ -4,7 +4,7 @@
"dispatchJsonId": 10001, "dispatchJsonId": 10001,
"bg_img_id": 504, "bg_img_id": 504,
"script_id": 0, "script_id": 0,
"fixReward": "13005&1|17002&10|17006&2|17006&3", "fixReward": "&",
"conditionReward": "&", "conditionReward": "&",
"RandomReward": "&", "RandomReward": "&",
"warType": 8, "warType": 8,
@@ -27,7 +27,7 @@
"dispatchJsonId": 10002, "dispatchJsonId": 10002,
"bg_img_id": 504, "bg_img_id": 504,
"script_id": 0, "script_id": 0,
"fixReward": "13005&1|17002&10|17006&2|17006&3", "fixReward": "&",
"conditionReward": "&", "conditionReward": "&",
"RandomReward": "&", "RandomReward": "&",
"warType": 8, "warType": 8,
@@ -50,7 +50,7 @@
"dispatchJsonId": 10003, "dispatchJsonId": 10003,
"bg_img_id": 504, "bg_img_id": 504,
"script_id": 0, "script_id": 0,
"fixReward": "13005&1|17002&10|17006&2|17006&3", "fixReward": "&",
"conditionReward": "&", "conditionReward": "&",
"RandomReward": "&", "RandomReward": "&",
"warType": 8, "warType": 8,
@@ -73,7 +73,7 @@
"dispatchJsonId": 10004, "dispatchJsonId": 10004,
"bg_img_id": 504, "bg_img_id": 504,
"script_id": 0, "script_id": 0,
"fixReward": "13005&1|17002&10|17006&2|17006&3", "fixReward": "&",
"conditionReward": "&", "conditionReward": "&",
"RandomReward": "&", "RandomReward": "&",
"warType": 8, "warType": 8,
@@ -96,7 +96,7 @@
"dispatchJsonId": 10005, "dispatchJsonId": 10005,
"bg_img_id": 504, "bg_img_id": 504,
"script_id": 0, "script_id": 0,
"fixReward": "13010&1|17003&30|17006&20|17006&20", "fixReward": "&",
"conditionReward": "&", "conditionReward": "&",
"RandomReward": "&", "RandomReward": "&",
"warType": 8, "warType": 8,
@@ -119,7 +119,7 @@
"dispatchJsonId": 10006, "dispatchJsonId": 10006,
"bg_img_id": 504, "bg_img_id": 504,
"script_id": 0, "script_id": 0,
"fixReward": "13010&1|17003&30|17006&20|17006&20", "fixReward": "&",
"conditionReward": "&", "conditionReward": "&",
"RandomReward": "&", "RandomReward": "&",
"warType": 8, "warType": 8,
@@ -142,7 +142,7 @@
"dispatchJsonId": 10007, "dispatchJsonId": 10007,
"bg_img_id": 504, "bg_img_id": 504,
"script_id": 0, "script_id": 0,
"fixReward": "13005&1|17002&10|17006&2|17006&8", "fixReward": "&",
"conditionReward": "&", "conditionReward": "&",
"RandomReward": "&", "RandomReward": "&",
"warType": 8, "warType": 8,
@@ -165,7 +165,7 @@
"dispatchJsonId": 10008, "dispatchJsonId": 10008,
"bg_img_id": 504, "bg_img_id": 504,
"script_id": 0, "script_id": 0,
"fixReward": "13005&1|17002&10|17006&2|17006&9", "fixReward": "&",
"conditionReward": "&", "conditionReward": "&",
"RandomReward": "&", "RandomReward": "&",
"warType": 8, "warType": 8,
@@ -188,7 +188,7 @@
"dispatchJsonId": 10009, "dispatchJsonId": 10009,
"bg_img_id": 504, "bg_img_id": 504,
"script_id": 0, "script_id": 0,
"fixReward": "13005&1|17002&10|17006&2|17006&10", "fixReward": "&",
"conditionReward": "&", "conditionReward": "&",
"RandomReward": "&", "RandomReward": "&",
"warType": 8, "warType": 8,
@@ -211,7 +211,7 @@
"dispatchJsonId": 10010, "dispatchJsonId": 10010,
"bg_img_id": 504, "bg_img_id": 504,
"script_id": 0, "script_id": 0,
"fixReward": "13005&1|17002&10|17006&2|17006&11", "fixReward": "&",
"conditionReward": "&", "conditionReward": "&",
"RandomReward": "&", "RandomReward": "&",
"warType": 8, "warType": 8,
@@ -234,7 +234,7 @@
"dispatchJsonId": 10011, "dispatchJsonId": 10011,
"bg_img_id": 504, "bg_img_id": 504,
"script_id": 0, "script_id": 0,
"fixReward": "13015&1|17004&30|17006&30|17006&30", "fixReward": "&",
"conditionReward": "&", "conditionReward": "&",
"RandomReward": "&", "RandomReward": "&",
"warType": 8, "warType": 8,
@@ -257,7 +257,7 @@
"dispatchJsonId": 10012, "dispatchJsonId": 10012,
"bg_img_id": 504, "bg_img_id": 504,
"script_id": 0, "script_id": 0,
"fixReward": "13015&1|17004&30|17006&30|17006&30", "fixReward": "&",
"conditionReward": "&", "conditionReward": "&",
"RandomReward": "&", "RandomReward": "&",
"warType": 8, "warType": 8,
@@ -280,7 +280,7 @@
"dispatchJsonId": 10013, "dispatchJsonId": 10013,
"bg_img_id": 504, "bg_img_id": 504,
"script_id": 0, "script_id": 0,
"fixReward": "13015&1|17004&30|17006&30|17006&30", "fixReward": "&",
"conditionReward": "&", "conditionReward": "&",
"RandomReward": "&", "RandomReward": "&",
"warType": 8, "warType": 8,