修改远征创建记录逻辑

This commit is contained in:
luying
2020-11-17 10:07:59 +08:00
parent d5a5cfc270
commit 0e2f043f93
26 changed files with 2147 additions and 1150 deletions

View File

@@ -1,6 +1,6 @@
import { getHeroInfoById, getStarRatio, getHeroSkillById, getSeidById, getOlySeidByType, getGoodById } from "./gamedata";
import { ABI_TYPE, SEID_TYPE } from "../consts/abilityConst";
import { EXPRESSION } from '../consts/consts';
import { WAR_JSON_ATTRIBUTE_TYPE, EXPRESSION } from '../consts/consts';
export default class Actor {
private hid: number = 0;
@@ -14,7 +14,7 @@ export default class Actor {
private seidList:Array<any> = new Array<any>(3);
private effectList:Map<number,Array<any> > = new Map<number,Array<any> >();
constructor(hero: any) { // 从数据库拿到的hero
initHero(hero: any) { // 从数据库拿到的hero
this.hid = hero.hid;
this.lv = hero.lv;
this.oldCe = hero.ce;
@@ -258,29 +258,13 @@ export default class Actor {
calculateCE() {
// 武将
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 matk = this.getRealAbility(ABI_TYPE.ABI_MATK); console.log(this.hid, 'matk', matk);
let def = this.getRealAbility(ABI_TYPE.ABI_DEF); console.log(this.hid, 'def', def);
let mdef = this.getRealAbility(ABI_TYPE.ABI_MDEF); console.log(this.hid, 'mdef', mdef);
let agi = this.getRealAbility(ABI_TYPE.ABI_AGI); console.log(this.hid, 'agi', agi);
let speed = this.getRealAbility(ABI_TYPE.ABI_SPEED); console.log(this.hid, 'speed', speed);
let luk = this.getRealAbility(ABI_TYPE.ABI_LUK); console.log(this.hid, 'luk', luk);
let hit = this.getRealAbility(ABI_TYPE.ABI_HIT); console.log(this.hid, 'hit', hit);
let cri = this.getRealAbility(ABI_TYPE.ABI_CRI); console.log(this.hid, 'cri', cri);
let flee = this.getRealAbility(ABI_TYPE.ABI_FLEE); console.log(this.hid, 'flee', flee);
let antCri = this.getRealAbility(ABI_TYPE.ABI_ANT_CRI); console.log(this.hid, 'antCri', antCri);
let damageIncrease = this.getRealAbility(ABI_TYPE.ABI_DAMAGE_INCREASE); console.log(this.hid, 'damageIncrease', damageIncrease);
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 bloodSuck = this.getRealAbility(ABI_TYPE.ABI_BLOOD_SUCK); console.log(this.hid, 'bloodSuck', bloodSuck);
let ce = 0;
try {
ce = eval(EXPRESSION.CE);
} catch(e) {
console.error('expression wrong');
let json = {hp: 0, atk: 0, matk: 0, def: 0, mdef: 0, agi: 0, speed: 0, luk: 0, hit: 0, cri: 0, flee: 0, antCri: 0, damageIncrease: 0, damageDecrease: 0, defIngnore: 0, bloodSuck: 0};
for(let i = ABI_TYPE.ABI_HP;i < ABI_TYPE.ABI_MAX;i++){
let field = WAR_JSON_ATTRIBUTE_TYPE[i];
json[field] = this.getRealAbility(i);
}
console.log(this.hid, 'ce', ce);
let ce = this.calculateCEByExpression(json);
// 装备
for(let equip of this.equips) {
@@ -294,6 +278,18 @@ export default class Actor {
return Math.floor(ce);
}
calculateCEByExpression(json: {hp:number, atk: number, matk: number, def: number, mdef: number, agi: number, luk: number, hit: number, cri: number, flee: number, antCri: number, damageIncrease: number, damageDecrease: number, defIngnore: number, bloodSuck: number}): number {
let {hp, atk, matk, def, mdef, agi, luk, hit, cri, flee, antCri, damageIncrease, damageDecrease, defIngnore, bloodSuck } = json;
console.log(JSON.stringify({hp, atk, matk, def, mdef, agi, luk, hit, cri, flee, antCri, damageIncrease, damageDecrease, defIngnore, bloodSuck}));
let ce = 0;
try {
ce = eval(EXPRESSION.CE);
} catch(e) {
console.error('expression wrong');
}
return ce
}
}

View File

@@ -14,6 +14,7 @@ const starRatioInfo = new Map<number, number>();
const heroSkillInfo = new Map<number, any>()
const seidInfo = new Map<number, any>();
const olySeidInfo = new Map<number, any>();
const expeditionInfo = new Map<number, any> ();
function parseWarData() {
let result = null;
@@ -164,6 +165,17 @@ function parseOlySeidList() {
});
}
function parseExpedition() {
const file = 'dic_expedition';
const data = gamedata['jsons'][file] || [];
data.forEach(elem => {
if (elem && elem.id) {
expeditionInfo.set(elem.id, elem);
}
});
}
function initData (folder: string) {
if(!gamedata.hasOwnProperty(folder)) {
@@ -200,6 +212,7 @@ function parseData() {
parseHeroSkill();
parseSeidList();
parseOlySeidList();
parseExpedition();
}
initData('jsons'); // 加载一般json
@@ -282,4 +295,8 @@ export function getSeidById(id: number) {
export function getOlySeidByType(type: number) {
return olySeidInfo.get(type);
}
export function getExpeditionById(id: number) {
return expeditionInfo.get(id);
}

View File

@@ -121,7 +121,7 @@ export function decodeIdCntArrayStr(str: string, multi: number) {
// 计算当前武将战力
export async function calculateSumCE(roleId: string, type: number, param: { num?: number, heroes?: Array<number> }) {
let sum;
if(type == 1) { // 最高num人战力和
if(type == 1) { // 最高num人历史最高战力和
sum = await HeroModel.sumTopHeroCe(roleId, param.num||0);
} else if(type == 2) { // 所有人战力和
sum = await HeroModel.sumHeroCe(roleId);
@@ -329,7 +329,8 @@ export function setLocalHours(hour: number, curTime = new Date()) {
export async function updateCe(roleId: string, hero: any ) {
let {hid, ce: oldCe, historyCe} = hero;
let actor = new Actor(hero);
let actor = new Actor();
actor.initHero(hero);
let ce = actor.calculateCE();
if(ce != oldCe) {
// 更新总战力&最强五人战力
@@ -339,4 +340,4 @@ export async function updateCe(roleId: string, hero: any ) {
// 更新武将战力,历史最高战力
await HeroModel.updateCe(roleId, hid, ce, oldCe, historyCe);
}
}
}