助战:神像强化暴击逻辑

This commit is contained in:
luying
2021-08-23 18:20:24 +08:00
parent 383402ee4f
commit ebfe7a4c91
5 changed files with 126 additions and 88 deletions
@@ -10,7 +10,7 @@ import { getAtrrNameById } from '../../../consts/constModules/abilityConst'
import { findIndex } from 'underscore';
import { SclResultInter, SclPosInter } from '../../../pubUtils/interface';
import { SchoolModel } from '../../../db/School';
import { checkTeraphMaterialEnough, getSchoolList } from '../../../services/roleService'
import { getTeraphStrengthenResult, getSchoolList } from '../../../services/roleService'
import { calPlayerCeAndSave, calAllHeroCe } from '../../../services/playerCeService';
import { HERO_SYSTEM_TYPE, LINEUP_NUM, ROLE_SELECT, REDIS_KEY, TASK_TYPE, DEFAULT_HEROES, DEFAULT_HERO_LV, DEFAULT_ITEMS, DEFAULT_EQUIPS, DEFAULT_GOLD, DEFAULT_COIN } from '../../../consts';
import { checkBattleHeroesByHid } from '../../../services/normalBattleService';
@@ -115,7 +115,7 @@ export class RoleHandler {
let sid: string = session.get('sid');
let funcs: number[] = session.get('funcs');
let role = await RoleModel.findByRoleId(roleId);
let role = await RoleModel.findByRoleId(roleId, 'roleId teraphs gold coin');
let teraphs = role.teraphs;
let index = findIndex(teraphs, { id });
if (index < 0)
@@ -125,20 +125,10 @@ export class RoleHandler {
if (!dicTeraph)
return resResult(STATUS.DIC_DATA_NOT_FOUND);
let attrs = new Array<number>(); // 可以强化的属性
dicTeraph.mainAttrMax.forEach((max, id) => {
let attrName = getAtrrNameById(id);
if (teraph[attrName] < max) {
attrs.push(id);
}
});
if (!attrs.length)
let { times, consumes, criAttr } = await getTeraphStrengthenResult(role, count, dicTeraph, teraph);
if (times == 0)
return resResult(STATUS.ROLE_TERAPH_NOT_STRENGTHEN);
// 随机神像中的一条属性并检查道具是否足够,以及更新teraph
let { consumes, criAttr } = checkTeraphMaterialEnough(count, attrs, dicTeraph, teraph);
let result = await handleCost(roleId, sid, consumes);
if (!result)
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);