武将:职业天赋接口
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
* 体力系统
|
||||
*/
|
||||
|
||||
import { HERO_SYSTEM_TYPE, ABI_TYPE, HERO_CE_RATIO, LINEUP_NUM } from '../consts';
|
||||
import { HERO_SYSTEM_TYPE, ABI_TYPE, HERO_CE_RATIO, LINEUP_NUM, TALENT_RELATION_TYPE } from '../consts';
|
||||
|
||||
import { cal, deepCopy, getAllAttrStage, reduceCe } from './util';
|
||||
import { HeroModel, HeroType, HeroUpdate, CeAttrData, EPlace, Stone } from '../db/Hero';
|
||||
import { HeroModel, HeroType, HeroUpdate, CeAttrData, EPlace, Stone, Talent } from '../db/Hero';
|
||||
import { RoleModel, RoleType, RoleUpdate, CeAttrDataRole } from '../db/Role';
|
||||
import { AttributeCal } from '../domain/roleField/attribute';
|
||||
import { ABI_STAGE, SEID_TYPE } from '../consts';
|
||||
@@ -20,6 +20,7 @@ import { GuildModel } from '../db/Guild';
|
||||
import { DicJob } from './dictionary/DicJob';
|
||||
import { saveCeChangeLog } from './logUtil';
|
||||
import { JewelType } from '../db/Jewel';
|
||||
import { type } from 'os';
|
||||
|
||||
// 修改并下发战力
|
||||
export async function calPlayerCeAndSave(type: number, roleId: string, originHero: HeroType, update: HeroUpdate, args?: Array<number>, params?: any) {
|
||||
@@ -161,7 +162,7 @@ export async function calPlayerCe(hero: HeroType, update: HeroUpdate, type: numb
|
||||
heroAttrs = calHeroTrainIncAttr(hero, update);
|
||||
break;
|
||||
case HERO_SYSTEM_TYPE.STAGEUP:
|
||||
heroAttrs = calHeroJobStageUpIncAttr(hero, update, addSeidList, removeSeidList);
|
||||
// heroAttrs = calHeroJobStageUpIncAttr(hero, update, addSeidList, removeSeidList);
|
||||
break;
|
||||
case HERO_SYSTEM_TYPE.SKIN:
|
||||
heroAttrs = calHeroWearSkinIncAttr(hero, update, addSeidList, removeSeidList);
|
||||
@@ -197,6 +198,9 @@ export async function calPlayerCe(hero: HeroType, update: HeroUpdate, type: numb
|
||||
case HERO_SYSTEM_TYPE.SCROLL:
|
||||
heroAttrs = calHeroCeScrollIncAttr(hero, update);
|
||||
break;
|
||||
case HERO_SYSTEM_TYPE.TALENT:
|
||||
heroAttrs = calHeroTalent(hero, update, addSeidList, removeSeidList);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -460,29 +464,29 @@ export function calHeroTrainIncAttr(originHero: HeroType, update: HeroUpdate) {
|
||||
* @param {number[]} addSeidList 用于更新被动
|
||||
* @param {number[]} removeSeidList 用于更新被动
|
||||
*/
|
||||
export function calHeroJobStageUpIncAttr(originHero: HeroType, update: HeroUpdate, addSeidList: Array<number>, removeSeidList: Array<number>) {
|
||||
let { job: oldJob, attr: heroAttrs } = originHero;
|
||||
let { job = oldJob } = update;
|
||||
// export function calHeroJobStageUpIncAttr(originHero: HeroType, update: HeroUpdate, addSeidList: Array<number>, removeSeidList: Array<number>) {
|
||||
// let { job: oldJob, attr: heroAttrs } = originHero;
|
||||
// let { job = oldJob } = update;
|
||||
|
||||
let lastJob = gameData.job.get(oldJob);
|
||||
let currentJob = gameData.job.get(job);
|
||||
let lastSeids = lastJob?.seid||new Array<number>();
|
||||
let curSeids = currentJob?.seid||new Array<number>();
|
||||
// let lastJob = gameData.job.get(oldJob);
|
||||
// let currentJob = gameData.job.get(job);
|
||||
// let lastSeids = lastJob?.seid||new Array<number>();
|
||||
// let curSeids = currentJob?.seid||new Array<number>();
|
||||
|
||||
for (let seid of curSeids) {
|
||||
let index = findIndex(lastSeids, seid);
|
||||
if (index < 0) {
|
||||
addSeidList.push(seid, 0);
|
||||
}
|
||||
}
|
||||
for (let seid of lastSeids) {
|
||||
let index = findIndex(curSeids, seid);
|
||||
if (index < 0) {
|
||||
removeSeidList.push(seid, 0);
|
||||
}
|
||||
}
|
||||
return heroAttrs;
|
||||
}
|
||||
// for (let seid of curSeids) {
|
||||
// let index = findIndex(lastSeids, seid);
|
||||
// if (index < 0) {
|
||||
// addSeidList.push(seid, 0);
|
||||
// }
|
||||
// }
|
||||
// for (let seid of lastSeids) {
|
||||
// let index = findIndex(curSeids, seid);
|
||||
// if (index < 0) {
|
||||
// removeSeidList.push(seid, 0);
|
||||
// }
|
||||
// }
|
||||
// return heroAttrs;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 初始计算兵种属性
|
||||
@@ -515,7 +519,7 @@ export function calHeroJobAttr(originHero: HeroType, hero: HeroUpdate, addSeidLi
|
||||
};
|
||||
|
||||
originHero.attr = heroAttrs;
|
||||
heroAttrs = calHeroJobStageUpIncAttr(originHero, hero, addSeidList, removeSeidList);
|
||||
// heroAttrs = calHeroJobStageUpIncAttr(originHero, hero, addSeidList, removeSeidList);
|
||||
return heroAttrs;
|
||||
}
|
||||
|
||||
@@ -552,6 +556,8 @@ export function calHeroWearSkinIncAttr(originHero: HeroType, update: HeroUpdate,
|
||||
calEquipStrengthIncAttr(originHero, update, eplaceIds);
|
||||
calEquipQualityIncAttr(originHero, update, eplaceIds);
|
||||
calEquipStarIncAttr(originHero, update, eplaceIds, addSeidList, removeSeidList);
|
||||
// 天赋点
|
||||
calHeroTalent(originHero, update, addSeidList, removeSeidList);
|
||||
|
||||
return heroAttrs;
|
||||
}
|
||||
@@ -990,6 +996,43 @@ function calHeroCeScrollIncAttr(originHero: HeroType, update: HeroUpdate) {
|
||||
return heroAttrs;
|
||||
}
|
||||
|
||||
function calHeroTalent(originHero: HeroType, update: HeroUpdate, addSeidList: number[], removeSeidList: number[]) {
|
||||
let { attr: heroAttrs, skins: oldSkins } = originHero;
|
||||
let { skins } = update;
|
||||
let oldSkin = oldSkins.find(cur => cur.enable);
|
||||
let newSkin = skins.find(cur => cur.enable);
|
||||
let oldSeids = getTalentSeid(oldSkin.talent);
|
||||
let newSeids = getTalentSeid(newSkin.talent);
|
||||
for(let seid of newSeids) addSeidList.push(seid);
|
||||
for(let seid of oldSeids) removeSeidList.push(seid);
|
||||
return heroAttrs
|
||||
}
|
||||
|
||||
function getTalentSeid(talent: Talent[]) {
|
||||
let seids = new Map<number, number[]>(); // id, seids
|
||||
for(let { id, level } of talent) {
|
||||
let dicHeroTalent = gameData.heroTalent.get(id);
|
||||
for(let { type, ids} of dicHeroTalent.relation) {
|
||||
if(type == TALENT_RELATION_TYPE.REPLACE) {
|
||||
for(let id of ids) {
|
||||
seids.delete(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(let { lv, seid } of dicHeroTalent.level) {
|
||||
if(level >= lv) {
|
||||
if(!seids.has(id)) seids.set(id, []);
|
||||
seids.get(id).push(seid);
|
||||
}
|
||||
}
|
||||
}
|
||||
let result: number[] = [];
|
||||
for(let [_, ids] of seids) {
|
||||
result.push(...ids);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 升爵位
|
||||
* @param role 角色数据
|
||||
|
||||
Reference in New Issue
Block a user