fix 合成战力
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import {Application, BackendSession, createTcpMailBox, ChannelService} from 'pinus';
|
||||
import { handleCost } from '../../../services/rewardService';
|
||||
import { calPlayerCeAndSave } from '../../../services/playerCeService';
|
||||
import { calPlayerCeAndSave, getAllAttrStage } from '../../../services/playerCeService';
|
||||
import { resResult, getItems, decodeStr } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import {HeroModel} from '../../../db/Hero';
|
||||
@@ -59,7 +59,7 @@ export class HeroHandler {
|
||||
let curHero = await HeroModel.createHero({
|
||||
roleId, serverId, roleName, hid, hName, star, quality, job
|
||||
}, false);
|
||||
await calPlayerCeAndSave(sid, roleId, [curHero], HERO_SYSTEM_TYPE.STAR);
|
||||
await calPlayerCeAndSave(sid, roleId, [curHero], HERO_SYSTEM_TYPE.STAR, getAllAttrStage());
|
||||
return resResult(STATUS.SUCCESS, {curHero});
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ export class HeroHandler {
|
||||
hero.lv = playerLv > newLv?newLv: playerLv;
|
||||
hero.exp = newExp;
|
||||
|
||||
let heros = await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.STAR);
|
||||
let heros = await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.STAR, getAllAttrStage());
|
||||
const curHero = {
|
||||
hid, lv : heros[0].lv, exp : heros[0].exp
|
||||
}
|
||||
@@ -151,7 +151,7 @@ export class HeroHandler {
|
||||
hero.star = isUpStar? oldStar + 1: oldStar;
|
||||
hero.starStage = isUpStar? ABI_STAGE.START: oldStarStage + 1;
|
||||
|
||||
let heros = await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.STAR);
|
||||
let heros = await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.STAR, [isUpStar? ABI_STAGE.END: hero.starStage]);
|
||||
const curHero = {
|
||||
hid,
|
||||
star : heros[0].star,
|
||||
@@ -196,7 +196,7 @@ export class HeroHandler {
|
||||
if(!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
hero.quality ++;
|
||||
let heros = await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.STAR);
|
||||
let heros = await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.STAR, getAllAttrStage());
|
||||
const curHero = {
|
||||
hid,
|
||||
quality : heros[0].quality
|
||||
@@ -246,7 +246,14 @@ export class HeroHandler {
|
||||
hero.colorStar = isUpStar? oldColorStar + 1: oldColorStar;
|
||||
hero.colorStarStage = isUpStar? ABI_STAGE.START: oldColorStarStage + 1;
|
||||
|
||||
let heros = await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.STAR);
|
||||
let args = new Array<number>();
|
||||
if(oldColorStarStage + 1 == ABI_STAGE.END) {
|
||||
args = getAllAttrStage();
|
||||
} else {
|
||||
args.push(isUpStar? ABI_STAGE.END: hero.colorStarStage)
|
||||
}
|
||||
|
||||
let heros = await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.STAR, args);
|
||||
const curHero = {
|
||||
hid,
|
||||
star : heros[0].star,
|
||||
|
||||
@@ -23,24 +23,22 @@ export function calPlayerCe(hero: any, type: number, args: Array<number>) {
|
||||
let removeSeidList = new Array<number>();
|
||||
|
||||
if (type == HERO_SYSTEM_TYPE.STAR) {
|
||||
reIncAttr = calHeroStarIncAttr(hero, addSeidList, removeSeidList); // 返回 计算后的值
|
||||
reIncAttr = calHeroStarIncAttr(hero, args, addSeidList, removeSeidList); // args: 升的星盘
|
||||
} else if (type == HERO_SYSTEM_TYPE.TRAIN) {
|
||||
reIncAttr = calHeroTrainIncAttr(hero);
|
||||
}
|
||||
|
||||
addSeidEffect(reIncAttr, addSeidList, removeSeidList); // 处理加值
|
||||
|
||||
if(!hero.ceAttr) hero.ceAttr = new CeAttr();
|
||||
for (let attrName in reIncAttr) {
|
||||
for (let attrName in reIncAttr) {
|
||||
let originalAttrData: CeAttrData = hero.ceAttr[attrName]||new CeAttrData();
|
||||
let oldCe = originalAttrData.fixUp * HERO_CE_RATIO + originalAttrData.base *(HERO_CE_RATIO + originalAttrData.ratioUp)
|
||||
|
||||
if(!hero.ceAttr[attrName]) hero.ceAttr[attrName] = new CeAttrData();
|
||||
for (let attrKey in reIncAttr[attrName]) {
|
||||
hero.ceAttr[attrName][attrKey] = parseInt(reIncAttr[attrName][attrKey]);
|
||||
}
|
||||
incArr[attrName] = reIncAttr[attrName].fixUp * HERO_CE_RATIO + reIncAttr[attrName].base *(HERO_CE_RATIO + reIncAttr[attrName].ratioUp) - oldCe; //计算属性
|
||||
incCe += incArr[attrName] * getAttrCeRatio[attrName];
|
||||
incCe += incArr[attrName] * getAttrCeRatio(attrName);
|
||||
}
|
||||
hero.ce += incCe;
|
||||
return incCe;
|
||||
@@ -70,44 +68,29 @@ export async function calPlayerCeAndSave(sid: string, roleId: string, heros: Arr
|
||||
return heros;
|
||||
}
|
||||
|
||||
export function calHeroStarIncAttr (hero: Hero, addSeidList: Array<number>, removeSeidList: Array<number>) {
|
||||
export function calHeroStarIncAttr (hero: Hero, args: Array<number>, addSeidList: Array<number>, removeSeidList: Array<number>) {
|
||||
let {star, starStage, quality, colorStar, colorStarStage, ceAttr} = hero;
|
||||
let res = {};
|
||||
const dicHero = getHeroInfoById(hero.hid);
|
||||
|
||||
const isWake = colorStar > 0; // 是否觉醒,只要激活了觉醒,彩星就会 > 1
|
||||
|
||||
let attrs = new Array<number>(); // 有升级的属性 1-hp 2-atk 3-def 4-mdef 5-agi 6-luk
|
||||
if(isWake) {
|
||||
if(colorStar == 1 && colorStarStage == ABI_STAGE.START) { // 当第一次觉醒时,一口气修改全部属性
|
||||
for(let stage = ABI_STAGE.START + 1; stage <= ABI_STAGE.END; stage++) {
|
||||
attrs.push(stage)
|
||||
};
|
||||
colorStar = colorStar -1; // 当第一次觉醒时,存的是1,读表的是上一行0
|
||||
} else { // 觉醒一次,相应的属性
|
||||
if(colorStarStage == ABI_STAGE.START) { // 当升一级的时候,存储会存0,但加的是6,读表读的是上一行
|
||||
colorStarStage = ABI_STAGE.END; colorStar = colorStar -1;
|
||||
}
|
||||
attrs.push(colorStarStage);
|
||||
}
|
||||
if(colorStarStage == ABI_STAGE.START) colorStar = colorStar -1;
|
||||
} else {
|
||||
if(starStage == ABI_STAGE.START) { // 当升一级的时候,存储会存0,但加的是6,读表读的是上一行
|
||||
starStage = ABI_STAGE.END; star = star -1;
|
||||
}
|
||||
attrs.push(starStage);
|
||||
if(starStage == ABI_STAGE.START) star = star -1;
|
||||
}
|
||||
const dicStar = isWake? getHeroWake(quality, colorStar): getHeroStar(quality, star); // 星级表
|
||||
|
||||
for(let stage of attrs) {
|
||||
for(let stage of args) {
|
||||
|
||||
let targetAttrId = getFieldByStage(stage, hero.job); // 转换为17维的属性id
|
||||
let targetAttrId = getFieldByStage(stage, hero.job); // 转换为17维的属性id
|
||||
let heroAttr = dicHero.baseAbilityArr[targetAttrId]; // 武将表hp等
|
||||
let heroUpAttr = dicHero.baseAbilityUpArr[targetAttrId]; // 武将表hp_up等
|
||||
|
||||
let starUp = dicStar.ceAttr.get(stage);
|
||||
let newBase = heroAttr + hero.lv * (heroUpAttr + starUp);
|
||||
let field = getAtrrNameById(targetAttrId);
|
||||
let ceAttrData: CeAttrData = ceAttr[field]; // 存表中的属性下的base,fixup,ratioup
|
||||
let ceAttrData: CeAttrData = ceAttr[field]||new CeAttrData(); // 存表中的属性下的base,fixup,ratioup
|
||||
let {ratioUp = 0, fixUp = 0} = ceAttrData;
|
||||
res[field] = { base: newBase, ratioUp, fixUp}; // base变动,增量为△base * ratio + 0
|
||||
}
|
||||
@@ -115,9 +98,17 @@ export function calHeroStarIncAttr (hero: Hero, addSeidList: Array<number>, remo
|
||||
return res;//属性增量可以是多个
|
||||
}
|
||||
|
||||
export function getAllAttrStage () {
|
||||
let attrs = new Array<number>(); // 有升级的属性 1-hp 2-atk 3-def 4-mdef 5-agi 6-luk
|
||||
for(let stage = ABI_STAGE.START + 1; stage <= ABI_STAGE.END; stage++) {
|
||||
attrs.push(stage)
|
||||
};
|
||||
return attrs;
|
||||
}
|
||||
|
||||
export function calHeroTrainIncAttr(hero: any) {
|
||||
let res = {};
|
||||
let attrName: string = getAttrNameByJobStage[hero.jobStage];
|
||||
let attrName: string = getAttrNameByJobStage(hero.jobStage);
|
||||
res[attrName] = {fixUp: hero.CeAttr[attrName].fixUp, base: hero.CeAttr[attrName].base, ratioUp: hero.CeAttr[attrName].ratioUp};
|
||||
let currentJob = getJobInfoById(hero.job);
|
||||
if (currentJob.grade > 1) {
|
||||
|
||||
@@ -128,7 +128,7 @@ export default class Hero extends BaseModel {
|
||||
const seqId = await CounterModel.getNewCounter(COUNTER.HID)||-1;
|
||||
const update = Object.assign(doc.toJSON(), heroInfo, {seqId});
|
||||
delete update._id;
|
||||
const hero = await HeroModel.findOneAndUpdate({roleId: heroInfo.roleId, hid: heroInfo.hid}, update, {upsert: true, new: true}).select('hid hName lv exp star starStage colorStar colorStarStage quality job jobStage conections favour favourLv skins equips').lean(lean);
|
||||
const hero = await HeroModel.findOneAndUpdate({roleId: heroInfo.roleId, hid: heroInfo.hid}, update, {upsert: true, new: true}).select('hid hName lv exp star starStage colorStar colorStarStage quality job jobStage conections favour favourLv skins equips ce ceAttr').lean(lean);
|
||||
return hero;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user