装备穿戴战力bug
This commit is contained in:
@@ -15,7 +15,7 @@ import { EquipType } from '../db/Equip';
|
||||
import { DicRandomEffectPool } from './dictionary/DicRandomEffectPool';
|
||||
import { getGoodById } from './gamedata';
|
||||
import { SchoolModel } from '../db/School';
|
||||
import { getTeraphAttr } from '../consts/constModules/abilityConst'
|
||||
import { getTeraphAttr, HEROTARIN } from '../consts/constModules/abilityConst'
|
||||
import { PvpDefenseModel } from '../db/PvpDefense';
|
||||
const HERO_CE_RATIO = 100;
|
||||
const _ = require('underscore');
|
||||
@@ -106,7 +106,6 @@ export async function calPlayerCeAndSave(roleId: string, heros: Array<HeroType>,
|
||||
let incHeroCe = calPlayerCe(role.globalCeAttr, hero, type, args);
|
||||
|
||||
incPlayerCe += incHeroCe;
|
||||
// hero.ce += incHeroCe;
|
||||
await calculateTopFive(role, hero.hid, hero.ce); // 计算更新最强五人战力
|
||||
await HeroModel.updateHeroInfo(roleId, hero.hid, hero);
|
||||
await PvpDefenseModel.updateCe(roleId, hero.hid, hero.ce); // 更新pvp防守阵最强五人战力
|
||||
@@ -159,37 +158,11 @@ async function calculateTopFive(role: RoleType, hid: number, ce: number) {
|
||||
|
||||
// 初始战力
|
||||
export function calHeroInitIncAttr(hero: HeroType, addSeidList: Array<number>, removeSeidList: Array<number>) {
|
||||
let res1 = calHeroStarIncAttr(hero, HERO_SYSTEM_TYPE.INIT, hero.hid, [], addSeidList, removeSeidList);
|
||||
let hero1 = combineHeroCeAttr(hero, res1);
|
||||
|
||||
let res = calHeroStarIncAttr(hero, HERO_SYSTEM_TYPE.INIT, hero.hid, [], addSeidList, removeSeidList);
|
||||
let curSkin = hero.skins.find(cur => cur.enable);
|
||||
let res2 = calHeroWearSkinIncAttr(hero1, [curSkin ? curSkin.id : 0, 0], addSeidList, removeSeidList, true);
|
||||
let hero2 = combineHeroCeAttr(hero, res2);
|
||||
|
||||
calHeroJobStageUpIncAttr(hero2, [0], addSeidList, removeSeidList);
|
||||
|
||||
let result: CeAttr = {};
|
||||
combineAttrResult(result, res1);
|
||||
combineAttrResult(result, res2);
|
||||
|
||||
return res1
|
||||
}
|
||||
|
||||
function combineAttrResult(target: CeAttr, origin: CeAttr) {
|
||||
|
||||
for (let attrName in origin) {
|
||||
for (let attrKey in origin[attrName]) {
|
||||
if (!target.hasOwnProperty(attrName)) {
|
||||
target[attrName] = {};
|
||||
}
|
||||
if (!target[attrName].hasOwnProperty(attrKey)) {
|
||||
target[attrName][attrKey] = 0;
|
||||
}
|
||||
if (origin[attrName][attrKey] > target[attrName][attrKey]) {
|
||||
target[attrName][attrKey] = origin[attrName][attrKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
calHeroWearSkinIncAttr(hero, [curSkin ? curSkin.id : 0, 0], addSeidList, removeSeidList, true, res);
|
||||
calHeroJobAttr(hero, res, addSeidList, removeSeidList);
|
||||
return res;
|
||||
}
|
||||
|
||||
export function calRoleInitIncAttr(heros: HeroType[], globalCeAttr: CeAttrRole) {
|
||||
@@ -203,21 +176,6 @@ export function calRoleInitIncAttr(heros: HeroType[], globalCeAttr: CeAttrRole)
|
||||
return res;
|
||||
}
|
||||
|
||||
// 将hero的ceAttr暂时更新,不更新在originalHero本体上
|
||||
function combineHeroCeAttr(originalHero: HeroType, result: CeAttr) {
|
||||
let hero = deepCopy(originalHero);
|
||||
if (!hero.ceAttr) hero.ceAttr = new CeAttr();
|
||||
for (let attrName in result) {
|
||||
if (!result[attrName]) continue;
|
||||
if (!hero.ceAttr[attrName]) hero.ceAttr[attrName] = new CeAttrData();
|
||||
for (let attrKey in result[attrName]) {
|
||||
hero.ceAttr[attrName][attrKey] = parseInt(result[attrName][attrKey] || 0);
|
||||
}
|
||||
}
|
||||
delete hero._id;
|
||||
return hero;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param hero HeroType 武将更新后的值
|
||||
@@ -352,22 +310,44 @@ export function calHeroJobStageUpIncAttr(hero: HeroType, args: Array<number>, ad
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
export function calHeroJobAttr(hero: HeroType, res: CeAttr, addSeidList: Array<number>, removeSeidList: Array<number>) {
|
||||
let currentJob = gameData.job.get(hero.job);
|
||||
let jobGradeAndClass = getJobByGradeAndClass(currentJob.job_class, currentJob.grade - 1);
|
||||
let lastJob;
|
||||
if (!!jobGradeAndClass) {
|
||||
lastJob = gameData.job.get(jobGradeAndClass.jobid);
|
||||
}
|
||||
for (let key in HEROTARIN) {
|
||||
let attrName: string = HEROTARIN[key];
|
||||
res[attrName] = res[attrName]||{ fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp };
|
||||
if (hero.jobStage >= parseInt(key)) {
|
||||
res[attrName].fixUp += currentJob[attrName] * HERO_CE_RATIO;
|
||||
} else {
|
||||
if (lastJob)
|
||||
res[attrName].fixUp += lastJob[attrName] * HERO_CE_RATIO;
|
||||
}
|
||||
}
|
||||
calHeroJobStageUpIncAttr(hero, [0], addSeidList, removeSeidList);
|
||||
return res;
|
||||
}
|
||||
|
||||
//穿戴时装
|
||||
export function calHeroWearSkinIncAttr(hero: HeroType, args: Array<number>, addSeidList: Array<number>, removeSeidList: Array<number>, isInit = false) {
|
||||
let res: CeAttr = {};
|
||||
export function calHeroWearSkinIncAttr(hero: HeroType, args: Array<number>, addSeidList: Array<number>, removeSeidList: Array<number>, isInit = false, heroAttr?:CeAttr) {
|
||||
let res: CeAttr = heroAttr||{};
|
||||
let addSkin = gameData.fashion.get(args[0]);
|
||||
let delSkin = gameData.fashion.get(args[1]);
|
||||
let attrName: string;
|
||||
if (delSkin) {
|
||||
for (let attr of delSkin.actorAttr) {
|
||||
attrName = getAtrrNameById(attr.id);
|
||||
res[attrName] = { fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp };
|
||||
res[attrName] = res[attrName]||{ fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp };
|
||||
res[attrName].fixUp -= attr.number * HERO_CE_RATIO;
|
||||
}
|
||||
}
|
||||
for (let attr of addSkin.actorAttr) {
|
||||
attrName = getAtrrNameById(attr.id);
|
||||
res[attrName] = { fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp };
|
||||
res[attrName] = res[attrName]||{ fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp };
|
||||
res[attrName].fixUp += attr.number * HERO_CE_RATIO;
|
||||
}
|
||||
|
||||
@@ -563,7 +543,7 @@ export function calHeroEquipIncAttr(hero: HeroType) {
|
||||
let originalCe = hero.ceAttr[attrName].equipUp || 0;
|
||||
console.log('装备战力:', attrName, attrResult[attrName] * HERO_CE_RATIO, originalCe);
|
||||
res[attrName] = { fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp, equipUp: originalCe };
|
||||
res[attrName].equipUp += attrResult[attrName] * HERO_CE_RATIO - originalCe;
|
||||
res[attrName].equipUp += attrResult[attrName] - originalCe;
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
Reference in New Issue
Block a user