武将重生:完成接口

This commit is contained in:
luying
2022-02-28 15:15:00 +08:00
parent cf920c0c80
commit bf73985623
8 changed files with 141 additions and 24 deletions

View File

@@ -61,11 +61,11 @@ export async function calPlayerCeAndSave(type: number, roleId: string, originHer
}
//全局属性加成
export async function reCalAllHeroCe(type: number, roleId: string, update: RoleUpdate, args?: Array<number>) {
export async function reCalAllHeroCe(type: number, roleId: string, update: RoleUpdate, args?: Array<number>, params?: any) {
let role = await RoleModel.findByRoleId(roleId);
let heros = await HeroModel.findByRole(roleId);
let roleAttrs = await reCalRoleAttr(type, heros, role, update, args);
let roleAttrs = await reCalRoleAttr(type, heros, role, update, args, params);
if(!roleAttrs) return {role, pushHeros: [], ce: role.ce, topLineupCe: role.topLineupCe, serverId: role.serverId, heros }; // 无加成
let pushHeros = new Array<{ hid: number, ce: number, incHeroCe: number }>();
@@ -105,7 +105,7 @@ export async function reCalAllHeroCe(type: number, roleId: string, update: RoleU
}
// 计算武将全局战力
async function reCalRoleAttr(type: number, heros: Array<HeroType>, role: RoleType, update: RoleUpdate, args: Array<number>) {
async function reCalRoleAttr(type: number, heros: Array<HeroType>, role: RoleType, update: RoleUpdate, args: Array<number>, params: any) {
let { attr: roleAttrs } = role;
switch (type) {
case HERO_SYSTEM_TYPE.ADD_SKIN:
@@ -131,6 +131,9 @@ async function reCalRoleAttr(type: number, heros: Array<HeroType>, role: RoleTyp
case HERO_SYSTEM_TYPE.TERAPH_UP:
roleAttrs = calTeraphAssistAttr(role, update, args[0]);
break;
case HERO_SYSTEM_TYPE.REBIRTH:
roleAttrs = await calHeroRebirth(role, params.originHero, params.heroUpdate);
break;
}
return roleAttrs;
@@ -1062,5 +1065,45 @@ function calTeraphAssistAttr(role: RoleType, update: RoleUpdate, id: number) {
let fixUp = (val - oldVal) * HERO_CE_RATIO;
updateRoleAttr(roleAttrs, attrId, { inc: { fixUp } });
});
return roleAttrs;
}
async function calHeroRebirth(role: RoleType, originHero: HeroType, updateHero: HeroUpdate) {
let { roleId, attr: roleAttrs } = role;
// 1. 名将谱
let dicHero = gameData.hero.get(originHero.hid);
let dicHeroScroll = getScollByStar(dicHero.quality, updateHero.star, updateHero.quality, updateHero.colorStar);
let dicPreScroll = getScollByStar(dicHero.quality, originHero.star, originHero.quality, originHero.colorStar);
if(dicHeroScroll) {
for(let [attrId, value] of dicHeroScroll.ceAttr) {
updateRoleAttr(roleAttrs, attrId, { inc: { fixUp: value * HERO_CE_RATIO } });
}
}
if(dicPreScroll) {
for(let [attrId, value] of dicPreScroll.ceAttr) {
updateRoleAttr(roleAttrs, attrId, { inc: { fixUp: -value * HERO_CE_RATIO } });
}
}
// 2. 百家学宫
let school = await SchoolModel.findByHid(roleId, originHero.hid);
if(school) {
let dicSchool = gameData.school.get(school.schoolId);
let preRate = getSchoolRateByStar(originHero.star, originHero.colorStar, originHero.quality);
let curRate = getSchoolRateByStar(updateHero.star, updateHero.colorStar, updateHero.quality);
console.log('####', updateHero.star, updateHero.colorStar, updateHero.quality)
for (let attrId of dicSchool.upAttribute) {
if(ABI_TYPE_MAIN.includes(attrId)) { // 主属性
let ratioUp = (curRate?.mainAttrAPerent||0) - (preRate?.mainAttrAPerent||0);
updateRoleAttr(roleAttrs, attrId, { inc: { ratioUp } });
} else {
let fixUp = ((curRate?.assiAttrAddValue||0) - (preRate?.assiAttrAddValue||0)) * HERO_CE_RATIO;
updateRoleAttr(roleAttrs, attrId, { inc: { fixUp } });
}
}
}
return roleAttrs;
}