|
|
|
@@ -15,19 +15,19 @@ import { DicRandomEffectPool } from './dictionary/DicRandomEffectPool';
|
|
|
|
|
import { SchoolModel } from '../db/School';
|
|
|
|
|
import { ABI_TYPE_MAIN, ABI_JOB_STAGE, ABI_STAGE_TO_TYPE } from '../consts/constModules/abilityConst'
|
|
|
|
|
import { PvpDefenseModel } from '../db/PvpDefense';
|
|
|
|
|
import { findIndex, uniq } from 'underscore';
|
|
|
|
|
import { findIndex } from 'underscore';
|
|
|
|
|
import { GuildModel } from '../db/Guild';
|
|
|
|
|
import { DicJob } from './dictionary/DicJob';
|
|
|
|
|
import { saveCeChangeLog } from './logUtil';
|
|
|
|
|
import { JewelModel, JewelType } from '../db/Jewel';
|
|
|
|
|
import { JewelType } from '../db/Jewel';
|
|
|
|
|
|
|
|
|
|
// 修改并下发战力
|
|
|
|
|
export async function calPlayerCeAndSave(type: number, roleId: string, originHero: HeroType, update: HeroUpdate, args?: Array<number>) {
|
|
|
|
|
export async function calPlayerCeAndSave(type: number, roleId: string, originHero: HeroType, update: HeroUpdate, args?: Array<number>, params?: any) {
|
|
|
|
|
let role = await RoleModel.findByRoleId(roleId);
|
|
|
|
|
|
|
|
|
|
let { attr: roleAttrs = [], serverId } = role;
|
|
|
|
|
|
|
|
|
|
let heroAttrs = await calPlayerCe(originHero, update, type, args); // 根据操作计算attr的增加
|
|
|
|
|
let heroAttrs = await calPlayerCe(originHero, update, type, args, params); // 根据操作计算attr的增加
|
|
|
|
|
|
|
|
|
|
let newAttr = new AttributeCal();
|
|
|
|
|
newAttr.setLv(update.lv||originHero.lv);
|
|
|
|
@@ -137,7 +137,7 @@ async function reCalRoleAttr(type: number, heros: Array<HeroType>, role: RoleTyp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 计算单个武将战力
|
|
|
|
|
export async function calPlayerCe(hero: HeroType, update: HeroUpdate, type: number, args: Array<number> = []) {
|
|
|
|
|
export async function calPlayerCe(hero: HeroType, update: HeroUpdate, type: number, args: Array<number> = [], params) {
|
|
|
|
|
let heroAttrs: CeAttrData[] = []; // {"hp": {"base": number, "fixUp": number, "ratioUp": number}}
|
|
|
|
|
|
|
|
|
|
let addSeidList = new Array<number>();
|
|
|
|
@@ -178,10 +178,13 @@ export async function calPlayerCe(hero: HeroType, update: HeroUpdate, type: numb
|
|
|
|
|
heroAttrs = calEquipStarIncAttr(hero, update, args, addSeidList, removeSeidList);
|
|
|
|
|
break;
|
|
|
|
|
case HERO_SYSTEM_TYPE.EQUIP_JEWEL:
|
|
|
|
|
heroAttrs = await calEquipPutOnOrOffJewelIncAttr(hero, update, args, addSeidList, removeSeidList);
|
|
|
|
|
heroAttrs = calEquipPutOnOrOffJewelIncAttr(hero, update, args, params, addSeidList, removeSeidList);
|
|
|
|
|
break;
|
|
|
|
|
case HERO_SYSTEM_TYPE.EQUIP_STONE:
|
|
|
|
|
heroAttrs = await calEquipPutOnOrOffStoneIncAttr(hero, update, args, addSeidList, removeSeidList);
|
|
|
|
|
heroAttrs = calEquipPutOnOrOffStoneIncAttr(hero, update, args, params, addSeidList, removeSeidList);
|
|
|
|
|
break;
|
|
|
|
|
case HERO_SYSTEM_TYPE.JEWEL_RESET_RANDSE:
|
|
|
|
|
heroAttrs = calJewelResetRandSe(hero, args, params, addSeidList, removeSeidList);
|
|
|
|
|
break;
|
|
|
|
|
case HERO_SYSTEM_TYPE.EQUIP: //
|
|
|
|
|
heroAttrs = calEquipPutOnOffIncAttr(hero, args, addSeidList, removeSeidList);
|
|
|
|
@@ -718,22 +721,21 @@ function calEquipSuitIncAttr(hid: number, oldEplace: EPlace[], newEplace: EPlace
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function calEquipPutOnOrOffJewelIncAttr(hero: HeroType, update: HeroUpdate, eplaceIds: number[], addSeidList: number[], removeSeidList: number[]) {
|
|
|
|
|
export function calEquipPutOnOrOffJewelIncAttr(hero: HeroType, update: HeroUpdate, eplaceIds: number[], params: { oldJewel: JewelType, newJewel: JewelType }, addSeidList: number[], removeSeidList: number[]) {
|
|
|
|
|
let { attr: heroAttrs, ePlace: oldEplace } = hero;
|
|
|
|
|
let { ePlace: newEplace } = update;
|
|
|
|
|
for(let eplaceId of eplaceIds) {
|
|
|
|
|
let oldEquip = oldEplace.find(cur => cur.id == eplaceId);
|
|
|
|
|
await setRandSeToSeidList(oldEquip, removeSeidList);
|
|
|
|
|
setRandSeToSeidList(params.oldJewel, oldEquip, removeSeidList);
|
|
|
|
|
let newEquip = newEplace.find(cur => cur.id == eplaceId);
|
|
|
|
|
await setRandSeToSeidList(newEquip, addSeidList);
|
|
|
|
|
setRandSeToSeidList(params.newJewel, newEquip, addSeidList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return heroAttrs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function setRandSeToSeidList(equip: EPlace, list: number[]) {
|
|
|
|
|
function setRandSeToSeidList(jewel: JewelType, equip: EPlace, list: number[]) {
|
|
|
|
|
if(equip && equip.jewel) {
|
|
|
|
|
let jewel = await JewelModel.findbySeqId(equip.jewel);
|
|
|
|
|
for(let { id, seid, rand } of jewel.randSe) {
|
|
|
|
|
if(isRandSeUnLock(jewel.id, id, equip.stones)) {
|
|
|
|
|
list.push(seid, rand);
|
|
|
|
@@ -756,16 +758,16 @@ function isRandSeUnLock(jewelId: number, randSeId: number, stones: Stone[]) {
|
|
|
|
|
return stoneCnt >= dicJewelCondition.stoneCnt && stoneLv >= dicJewelCondition.stoneLv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function calEquipPutOnOrOffStoneIncAttr(hero: HeroType, update: HeroUpdate, eplaceIds: number[], addSeidList: number[], removeSeidList: number[]) {
|
|
|
|
|
export function calEquipPutOnOrOffStoneIncAttr(hero: HeroType, update: HeroUpdate, eplaceIds: number[], params: { jewel: JewelType }, addSeidList: number[], removeSeidList: number[]) {
|
|
|
|
|
let { attr: heroAttrs, ePlace: oldEplace } = hero;
|
|
|
|
|
let { ePlace: newEplace } = update;
|
|
|
|
|
for(let eplaceId of eplaceIds) {
|
|
|
|
|
let oldEquip = oldEplace.find(cur => cur.id == eplaceId);
|
|
|
|
|
updateHeroAttrOfStone(heroAttrs, oldEquip, -1);
|
|
|
|
|
await setRandSeToSeidList(oldEquip, removeSeidList);
|
|
|
|
|
setRandSeToSeidList(params.jewel, oldEquip, removeSeidList);
|
|
|
|
|
let newEquip = newEplace.find(cur => cur.id == eplaceId);
|
|
|
|
|
updateHeroAttrOfStone(heroAttrs, newEquip, 1);
|
|
|
|
|
await setRandSeToSeidList(newEquip, addSeidList); // 地玉石阶数变化可能导致属性词条解锁变化
|
|
|
|
|
setRandSeToSeidList(params.jewel, newEquip, addSeidList); // 地玉石阶数变化可能导致属性词条解锁变化
|
|
|
|
|
}
|
|
|
|
|
return heroAttrs;
|
|
|
|
|
}
|
|
|
|
@@ -782,6 +784,16 @@ function updateHeroAttrOfStone(heroAttrs: CeAttrData[], equip: EPlace, ratio: nu
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function calJewelResetRandSe(hero: HeroType, eplaceIds: number[], params: { oldJewel: JewelType, newJewel: JewelType }, addSeidList: number[], removeSeidList: number[]) {
|
|
|
|
|
let { attr: heroAttrs, ePlace } = hero;
|
|
|
|
|
for(let eplaceId of eplaceIds) {
|
|
|
|
|
let equip = ePlace.find(cur => cur.id == eplaceId);
|
|
|
|
|
setRandSeToSeidList(params.oldJewel, equip, removeSeidList);
|
|
|
|
|
setRandSeToSeidList(params.newJewel, equip, addSeidList);
|
|
|
|
|
}
|
|
|
|
|
return heroAttrs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 穿脱, removeSeidList原来身上穿着的所有装备的seid,包括套装的
|
|
|
|
|
* @param {HeroType} hero 武将
|
|
|
|
|