武将:职业训练

This commit is contained in:
luying
2021-07-07 16:45:35 +08:00
parent 50867e8878
commit f0852f653a
3 changed files with 30 additions and 19 deletions
@@ -94,6 +94,10 @@ export enum ABI_STAGE {
END = 4 END = 4
} }
export enum ABI_JOB_STAGE {
START = 0,
END = 6
}
export const ATTR = {} export const ATTR = {}
export const HERO_ATTR = { export const HERO_ATTR = {
+15 -10
View File
@@ -1,5 +1,5 @@
// 兵种表 // 兵种表
import { readFileAndParse, parseNumberList, parseGoodStr} from '../util' import { readFileAndParse, parseNumberList, parseGoodStr, decodeArrayListStr} from '../util'
import { FILENAME, ABI_STAGE } from '../../consts' import { FILENAME, ABI_STAGE } from '../../consts'
import { RewardInter } from '../interface'; import { RewardInter } from '../interface';
const _ = require('lodash'); const _ = require('lodash');
@@ -24,7 +24,7 @@ export interface DicJob {
// 升阶消耗 // 升阶消耗
readonly upGradeConsume: Array<RewardInter>; readonly upGradeConsume: Array<RewardInter>;
// 每阶升级属性 // 每阶升级属性
readonly ceAttr: Map<number, number> readonly ceAttr: Map<number, {id: number, attr: number}>
} }
@@ -43,7 +43,7 @@ export function loadJob() {
o.seid = parseNumberList(o.seid); o.seid = parseNumberList(o.seid);
o.trainingConsume = parseGoodStr(o.trainingConsume); o.trainingConsume = parseGoodStr(o.trainingConsume);
o.upGradeConsume = parseGoodStr(o.upGradeConsume); o.upGradeConsume = parseGoodStr(o.upGradeConsume);
o.ceAttr = parseCeAttr(o); o.ceAttr = parseCeAttr(o.attr);
dicJob.set(o.jobid, _.pick(o, Object.keys(DicJobKeys))); dicJob.set(o.jobid, _.pick(o, Object.keys(DicJobKeys)));
let jobClass = jobClassMaxGrades.get(o.job_class); let jobClass = jobClassMaxGrades.get(o.job_class);
if (!jobClass || jobClass.grade < o.grade) { if (!jobClass || jobClass.grade < o.grade) {
@@ -55,11 +55,16 @@ export function loadJob() {
arr = undefined; arr = undefined;
} }
function parseCeAttr(elem) { function parseCeAttr(str: string) {
let ceAttr = new Map<number, number>(); let result = new Map<number, { id: number, attr: number }>();
ceAttr.set(ABI_STAGE.HP, elem.hp); if (!str) return result;
ceAttr.set(ABI_STAGE.ATK, elem.atk); let decodeArr = decodeArrayListStr(str);
ceAttr.set(ABI_STAGE.DEF, elem.def); for (let i = 0; i < decodeArr.length; i++) {
ceAttr.set(ABI_STAGE.MDEF, elem.mdef); let [id, attr] = decodeArr[i];
return ceAttr; if (isNaN(parseInt(id)) || isNaN(parseInt(attr))) {
throw new Error('data table format wrong');
}
result.set(i, { id: parseInt(id), attr: parseFloat(attr) });
}
return result
} }
+11 -9
View File
@@ -14,7 +14,7 @@ import { DicSe } from './dictionary/DicSe';
import { EquipType } from '../db/Equip'; import { EquipType } from '../db/Equip';
import { DicRandomEffectPool } from './dictionary/DicRandomEffectPool'; import { DicRandomEffectPool } from './dictionary/DicRandomEffectPool';
import { SchoolModel } from '../db/School'; import { SchoolModel } from '../db/School';
import { ABI_TYPE_TO_STAGE, ABI_TYPE_MAIN } from '../consts/constModules/abilityConst' import { ABI_TYPE_TO_STAGE, ABI_TYPE_MAIN, ABI_JOB_STAGE } from '../consts/constModules/abilityConst'
import { PvpDefenseModel } from '../db/PvpDefense'; import { PvpDefenseModel } from '../db/PvpDefense';
import { findIndex } from 'underscore'; import { findIndex } from 'underscore';
import { GuildModel } from '../db/Guild'; import { GuildModel } from '../db/Guild';
@@ -443,16 +443,17 @@ export function calHeroTrainIncAttr(originHero: HeroType, update: HeroUpdate) {
let { attr: heroAttrs, job: oldJob, jobStage: oldJobStage } = originHero; let { attr: heroAttrs, job: oldJob, jobStage: oldJobStage } = originHero;
let { job = oldJob, jobStage = oldJobStage } = update; let { job = oldJob, jobStage = oldJobStage } = update;
let targetAttrId = ABI_TYPE_TO_STAGE.get(jobStage); // 转换为18维的属性id
let dicJob = gameData.job.get(job); let dicJob = gameData.job.get(job);
if (dicJob.grade > 1) { if (dicJob.grade > 1) {
let jobGradeAndClass = getJobByGradeAndClass(dicJob.job_class, dicJob.grade - 1); let jobGradeAndClass = getJobByGradeAndClass(dicJob.job_class, dicJob.grade - 1);
let lastJob = gameData.job.get(jobGradeAndClass.jobid); let lastJob = gameData.job.get(jobGradeAndClass.jobid);
let inc = (dicJob.ceAttr.get(jobStage) - lastJob.ceAttr.get(jobStage)) * HERO_CE_RATIO; let targetAttrId = dicJob.ceAttr.get(jobStage).id;
let inc = (dicJob.ceAttr.get(jobStage).attr - lastJob.ceAttr.get(jobStage).attr) * HERO_CE_RATIO;
updateHeroAttr(heroAttrs, targetAttrId, { inc: { fixUp: inc } }) updateHeroAttr(heroAttrs, targetAttrId, { inc: { fixUp: inc } })
} else { } else {
let inc = dicJob.ceAttr.get(jobStage) * HERO_CE_RATIO; let targetAttrId = dicJob.ceAttr.get(jobStage).id;
let inc = dicJob.ceAttr.get(jobStage).attr * HERO_CE_RATIO;
updateHeroAttr(heroAttrs, targetAttrId, { inc: { fixUp: inc } }) updateHeroAttr(heroAttrs, targetAttrId, { inc: { fixUp: inc } })
} }
return heroAttrs; return heroAttrs;
@@ -505,14 +506,15 @@ export function calHeroJobAttr(originHero: HeroType, hero: HeroUpdate, addSeidLi
lastJob = gameData.job.get(jobGradeAndClass.jobid); lastJob = gameData.job.get(jobGradeAndClass.jobid);
} }
for (let stage = ABI_STAGE.START + 1; stage <= ABI_STAGE.END; stage++) { for (let stage = ABI_JOB_STAGE.START; stage < ABI_JOB_STAGE.END; stage++) {
let targetAttrId = ABI_TYPE_TO_STAGE.get(stage);
if(hero.jobStage >= stage) { if(hero.jobStage >= stage) {
let fixUp = currentJob.ceAttr.get(stage) * HERO_CE_RATIO; let targetAttrId = currentJob.ceAttr.get(stage).id;
let fixUp = currentJob.ceAttr.get(stage).attr * HERO_CE_RATIO;
updateHeroAttr(heroAttrs, targetAttrId, { inc: { fixUp }}) updateHeroAttr(heroAttrs, targetAttrId, { inc: { fixUp }})
} else { } else {
if(lastJob) { if(lastJob) {
let fixUp = lastJob.ceAttr.get(stage) * HERO_CE_RATIO; let targetAttrId = lastJob.ceAttr.get(stage).id;
let fixUp = lastJob.ceAttr.get(stage).attr * HERO_CE_RATIO;
updateHeroAttr(heroAttrs, targetAttrId, { inc: { fixUp } }); updateHeroAttr(heroAttrs, targetAttrId, { inc: { fixUp } });
} }
} }