fix bug 修复计算最强5人战力

This commit is contained in:
luying
2020-11-16 09:56:53 +08:00
parent ada3cfe849
commit d5a5cfc270
5 changed files with 12 additions and 7 deletions
@@ -66,6 +66,7 @@ export class DailyBattleHandler {
// 购买每日次数 // 购买每日次数
async buyNum(msg: { type: number, count: number }, session: BackendSession) { async buyNum(msg: { type: number, count: number }, session: BackendSession) {
let {type, count} = msg; let {type, count} = msg;
if(count < 0) return resResult(STATUS.WRONG_PARMS);
const roleId = session.get('roleId'); const roleId = session.get('roleId');
const dicDaily = getGamedata('dic_zyz_daily'); const dicDaily = getGamedata('dic_zyz_daily');
@@ -32,6 +32,7 @@ export class DungeonBattleHandler {
// 购买每日次数 // 购买每日次数
async buyNum(msg: { count: number }, session: BackendSession) { async buyNum(msg: { count: number }, session: BackendSession) {
let { count } = msg; let { count } = msg;
if(count < 0) return resResult(STATUS.WRONG_PARMS);
const roleId = session.get('roleId'); const roleId = session.get('roleId');
let { dungeonCnt = 0, dungeonBuyCnt = 0, dungeonRefTime } = await RoleModel.findByRoleId(roleId); let { dungeonCnt = 0, dungeonBuyCnt = 0, dungeonRefTime } = await RoleModel.findByRoleId(roleId);
let curTime = new Date(); let curTime = new Date();
+1 -3
View File
@@ -340,11 +340,9 @@ export default class Role extends BaseModel {
if(topFive.length < 5) { // 不满5人 if(topFive.length < 5) { // 不满5人
topFive.push({hid, ce}); topFive.push({hid, ce});
} else if(topFive.length == 5){ } else if(topFive.length == 5){
if(ce > topFive[topFive.length - 1].ce) { // 跻身最强6人 if(ce > topFive[topFive.length - 1].ce) { // 跻身最强5人
topFive.pop(); topFive.pop();
topFive.push({hid, ce}); topFive.push({hid, ce});
} else {
topFive[index].ce = ce;
} }
} else { } else {
topFive.splice(5, topFive.length - 5); topFive.splice(5, topFive.length - 5);
+8 -3
View File
@@ -1,5 +1,6 @@
import { getHeroInfoById, getStarRatio, getHeroSkillById, getSeidById, getOlySeidByType, getGoodById } from "./gamedata"; import { getHeroInfoById, getStarRatio, getHeroSkillById, getSeidById, getOlySeidByType, getGoodById } from "./gamedata";
import { ABI_TYPE, SEID_TYPE } from "../consts/abilityConst"; import { ABI_TYPE, SEID_TYPE } from "../consts/abilityConst";
import { EXPRESSION } from '../consts/consts';
export default class Actor { export default class Actor {
private hid: number = 0; private hid: number = 0;
@@ -257,7 +258,6 @@ export default class Actor {
calculateCE() { calculateCE() {
// 武将 // 武将
const ceGongshi = '1*hp+2*atk+2*matk+2*def+2*mdef+2*agi+2*luk+1*hit+1*cri+1*flee+1*antCri+1.75*damageIncrease+1.75*damageDecrease+3.5*defIngnore+3.5*bloodSuck'
let hp = this.getRealAbility(ABI_TYPE.ABI_HP); console.log(this.hid, 'hp', hp); let hp = this.getRealAbility(ABI_TYPE.ABI_HP); console.log(this.hid, 'hp', hp);
let atk = this.getRealAbility(ABI_TYPE.ABI_ATK); console.log(this.hid, 'atk', atk); let atk = this.getRealAbility(ABI_TYPE.ABI_ATK); console.log(this.hid, 'atk', atk);
let matk = this.getRealAbility(ABI_TYPE.ABI_MATK); console.log(this.hid, 'matk', matk); let matk = this.getRealAbility(ABI_TYPE.ABI_MATK); console.log(this.hid, 'matk', matk);
@@ -274,7 +274,13 @@ export default class Actor {
let damageDecrease = this.getRealAbility(ABI_TYPE.ABI_DAMAGE_DECREASE); console.log(this.hid, 'damageDecrease', damageDecrease); let damageDecrease = this.getRealAbility(ABI_TYPE.ABI_DAMAGE_DECREASE); console.log(this.hid, 'damageDecrease', damageDecrease);
let defIngnore = this.getRealAbility(ABI_TYPE.ABI_DEF_IGNORE); console.log(this.hid, 'defIngnore', defIngnore); let defIngnore = this.getRealAbility(ABI_TYPE.ABI_DEF_IGNORE); console.log(this.hid, 'defIngnore', defIngnore);
let bloodSuck = this.getRealAbility(ABI_TYPE.ABI_BLOOD_SUCK); console.log(this.hid, 'bloodSuck', bloodSuck); let bloodSuck = this.getRealAbility(ABI_TYPE.ABI_BLOOD_SUCK); console.log(this.hid, 'bloodSuck', bloodSuck);
let ce = eval(ceGongshi); console.log(this.hid, 'ce', ce); let ce = 0;
try {
ce = eval(EXPRESSION.CE);
} catch(e) {
console.error('expression wrong');
}
console.log(this.hid, 'ce', ce);
// 装备 // 装备
for(let equip of this.equips) { for(let equip of this.equips) {
@@ -285,7 +291,6 @@ export default class Actor {
} }
} }
console.log('ce2', ce)
return Math.floor(ce); return Math.floor(ce);
} }
+1 -1
View File
@@ -150,7 +150,7 @@ export default class Auth extends Service {
hid: hid, hid: hid,
hName: dicHero.name, hName: dicHero.name,
seqId, seqId,
star: dicHero.star, star: dicHero.quality,
lv: 1, lv: 1,
ce: 100 ce: 100
} }