diff --git a/game-server/app/services/expeditionService.ts b/game-server/app/services/expeditionService.ts index 8bcd16a54..876f6ded1 100644 --- a/game-server/app/services/expeditionService.ts +++ b/game-server/app/services/expeditionService.ts @@ -196,11 +196,12 @@ export async function matchRobots(scale: number, myCe: number, robotCe: number, enemyObj.enemyId = warJsonIndex + ''; let allCe = 0; + let dicExpeditionSubAttr = gameData.expeditionSubAttr.get(lv); for(let json of dicWarJson) { if(json.relation == 2) { const { attribute } = json; - let { attribute: newAttribute, ce } = getRobotAttribute(attribute, myCe, robotCe, scale); + let { attribute: newAttribute, ce } = getRobotAttribute(attribute, dicExpeditionSubAttr.attribute, dicExpeditionSubAttr.lv, myCe, robotCe, scale); enemyObj.enemies.push({...json, attribute: newAttribute, lv, ce}); allCe += ce; } diff --git a/game-server/app/services/pvpService.ts b/game-server/app/services/pvpService.ts index 0d66b4474..0ae0c1525 100644 --- a/game-server/app/services/pvpService.ts +++ b/game-server/app/services/pvpService.ts @@ -282,7 +282,7 @@ async function matchRobot(oppPlayers: OppPlayers[], mapWarJson: DicWarJson[], ro if (!dicHero) continue; let heroInfo = new PvpHeroInfo(); heroInfo.setRobotInfo(h, myLv, dicHero.initialStars, dicHero.quality); - let { attribute, ce } = getRobotAttribute(h.attribute, myCe, PVP_CONST.ENEMY_CE, ratio); + let { attribute, ce } = getRobotAttribute(h.attribute, [], pLv, myCe, PVP_CONST.ENEMY_CE, ratio); defCe += ce; heroInfo.setAttribute(attribute); let enemy = new PvpEnemies(warJson, heroInfo, 0, ce); @@ -513,10 +513,14 @@ export async function findPvpDefAllByRoleId(roleId: string) { * @param enemyCe 出兵表对手战力 * @param ratio 系数 */ -export function getRobotAttribute(attribute: { id: number, val: number }[], ce: number, enemyCe: number, ratio: number) { +export function getRobotAttribute(mainAttrs: { id: number, val: number }[], subAttrs: {id: number, val: number}[], lv: number, ce: number, enemyCe: number, ratio: number) { let newAttribute = new AttributeCal(); - newAttribute.setByWarJson(attribute, Math.sqrt(ce / enemyCe * ratio)); + newAttribute.setLv(lv); + newAttribute.setByWarJson(subAttrs); // 次级属性 + let subAttrCe = newAttribute.calSubAttrCeAndReduce(); + let mainAttrCe = ce > subAttrCe? ce - subAttrCe: 0; + newAttribute.setByWarJson(mainAttrs, mainAttrCe / enemyCe * ratio); let attrArr = newAttribute.getReduceAttributesToString(); let newCe = newAttribute.calCelAndReduce(); return { attribute: attrArr, ce: newCe }; diff --git a/shared/consts/constModules/sysConst.ts b/shared/consts/constModules/sysConst.ts index 70d784b39..bcd87a4e7 100644 --- a/shared/consts/constModules/sysConst.ts +++ b/shared/consts/constModules/sysConst.ts @@ -465,6 +465,7 @@ export const FILENAME = { DIC_QUENCH_QUALITY: 'dic_zyz_quench_quality', DIC_QUENCH_CONSUME: 'dic_zyz_quench_consume', DIC_HOLIDAY: 'dic_holiday', + DIC_EXPEDITION_SUB_ATTR: 'dic_expedition_subattr', } export const WAR_RELATE_TABLES = [ diff --git a/shared/db/ActivityPopUpShop.ts b/shared/db/ActivityPopUpShop.ts index b3c8ecf3b..60d7bc9cc 100644 --- a/shared/db/ActivityPopUpShop.ts +++ b/shared/db/ActivityPopUpShop.ts @@ -118,7 +118,6 @@ export default class Activity_Pop_Up_Shop extends BaseModel { //删除活动领取记录 public static async deleteActivity(serverId: number, activityId: number, roleId: string, id: number) { - console.log(serverId) let nowDate = new Date(); await ActivityPopUpShopModel.deleteMany({ roleId, activityId, id, diff --git a/shared/db/FriendShip.ts b/shared/db/FriendShip.ts index 1f87dac29..071e8b7e8 100644 --- a/shared/db/FriendShip.ts +++ b/shared/db/FriendShip.ts @@ -102,7 +102,7 @@ export default class FriendShip extends BaseModel { set: { sendHeartTime: nowSeconds() }, lt: { sendHeart: max - inc } }); - console.log(JSON.stringify(params)) + // console.log(JSON.stringify(params)) if (!params) return false; let result: FriendShipType; if(shouldRefresh) { diff --git a/shared/db/ServerMail.ts b/shared/db/ServerMail.ts index f31f7ab3c..22db4ca3f 100644 --- a/shared/db/ServerMail.ts +++ b/shared/db/ServerMail.ts @@ -75,7 +75,7 @@ export default class ServerMail extends MailTemp { { new: true } ).lean(); - console.log('*******', result) + // console.log('*******', result) return result; } diff --git a/shared/db/Serverlist.ts b/shared/db/Serverlist.ts index 04e96fc16..a4c593518 100644 --- a/shared/db/Serverlist.ts +++ b/shared/db/Serverlist.ts @@ -168,7 +168,7 @@ export default class Serverlist extends BaseModel { } public static async updateActivityGroup(id: string, pushArr: number[], pullArr: number[]) { - console.log(id, pushArr, pullArr) + // console.log(id, pushArr, pullArr) let update = {}; if(pushArr.length > 0) update['$push'] = { activityGroupId: { $each: pushArr } }; if(pullArr.length > 0) update['$pull'] = { activityGroupId: { $in: pullArr } }; diff --git a/shared/domain/roleField/attribute.ts b/shared/domain/roleField/attribute.ts index 0fa4130b4..f7aa55022 100644 --- a/shared/domain/roleField/attribute.ts +++ b/shared/domain/roleField/attribute.ts @@ -3,6 +3,7 @@ import { CeAttrDataRole } from '../../db/Role'; import { CeAttrData } from '../../db/Hero'; import { gameData } from '../../pubUtils/data'; import { decodeArrayListStr, reduceCe } from '../../pubUtils/util'; +import { ATTRIBUTE } from '../../pubUtils/dicParam'; export class AttributeCal { attrs: Map = new Map(); @@ -104,18 +105,31 @@ export class AttributeCal { } // 战力计算 - public calCe() { + // calType 1-全部 2-只算主属性 3-只算次属性 + public calCe(calType: number = 1) { let ce = gameData.ceRatio.reduce((pre, cur) => { let { type, val } = cur; if(ABI_TYPE_MAIN.includes(type)) { - return pre + val * (this.attrs.get(type)|| 0) + if(calType == 3) { + return 0 + } else { + return pre + val * (this.attrs.get(type)|| 0) + } } else { - return pre + val * (this.attrs.get(type)|| 0) * this.lv + if(calType == 2) { + return 0 + } else { + return pre + val * (this.attrs.get(type)|| 0) * this.lv / ATTRIBUTE.ATTRIBUTE_POWER_DIVISOR; + } } }, 0); return Math.floor(ce); } + public calSubAttrCeAndReduce() { + return Math.floor(this.calCe(3) / HERO_CE_RATIO / HERO_CE_RATIO); + } + public calCelAndReduce() { return Math.floor(this.calCe() / HERO_CE_RATIO / HERO_CE_RATIO); } diff --git a/shared/domain/roleField/calCe.ts b/shared/domain/roleField/calCe.ts index 9eb206ee0..46e1a1b16 100644 --- a/shared/domain/roleField/calCe.ts +++ b/shared/domain/roleField/calCe.ts @@ -197,7 +197,7 @@ export class CalHeroCe { // 添加技能增加的被动属性 function addSeidEffect(this: CalRoleCe|CalHeroCe, seidList: number[]) { - console.log('******addSeidEffect',this, seidList) + // console.log('******addSeidEffect',this, seidList) // console.log('addSeidList', addSeidList.join()) // console.log('removeSeidList', removeSeidList.join()) diff --git a/shared/pubUtils/data.ts b/shared/pubUtils/data.ts index a1594e81a..d44b113c6 100644 --- a/shared/pubUtils/data.ts +++ b/shared/pubUtils/data.ts @@ -91,6 +91,7 @@ import { dicKingExpRatio, loadKingExpRatio } from './dictionary/DicKingExpRatio' import { dicQuenchByQuality, dicQuenchRangeByQuality, dicQuenchRangeByQualityAndGrade, loadQuenchQuality } from './dictionary/DicQuenchQuality'; import { dicQuenchConsume, loadQuenchConsume } from './dictionary/DicQuenchConsume'; import { dicHoliday, loadHoliday } from './dictionary/DicHoliday'; +import { dicExpeditionSubAttr, loadExpeditionSubAttr } from './dictionary/DicExpeditionSubAttr'; export const gameData = { blurprtCompose: dicBlueprtCompose, @@ -226,7 +227,8 @@ export const gameData = { quenchByQuality: dicQuenchByQuality, equipAttributeRatio: new Map(), ceRatio: new Array<{type: number, val: number}>(), - holiday: dicHoliday + holiday: dicHoliday, + expeditionSubAttr: dicExpeditionSubAttr }; // 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据 @@ -869,6 +871,7 @@ function loadDatas() { loadQuenchConsume(); loadEquipAttributeRatio(); loadHoliday(); + loadExpeditionSubAttr(); } // 重载dicParam diff --git a/shared/pubUtils/dictionary/DicExpeditionSubAttr.ts b/shared/pubUtils/dictionary/DicExpeditionSubAttr.ts new file mode 100644 index 000000000..b727c5dd0 --- /dev/null +++ b/shared/pubUtils/dictionary/DicExpeditionSubAttr.ts @@ -0,0 +1,43 @@ +import { readFileAndParse } from '../util' +import { ABI_TYPE, FILENAME, HERO_ATTR } from '../../consts' +type KeysEnum = { [P in keyof Required]: true }; +const _ = require('lodash'); + +export interface DicExpeditionSubAttr { + // 等级 + readonly lv: number; + // 属性 + readonly attribute: {id: number, val: number}[]; +} + +const DicExpeditionSubAttrKeys: KeysEnum = { + lv: true, + attribute: true, +}; + +export const dicExpeditionSubAttr = new Map(); +export function loadExpeditionSubAttr() { + dicExpeditionSubAttr.clear(); + let l = 1; + let arr = readFileAndParse(FILENAME.DIC_EXPEDITION_SUB_ATTR); + arr.forEach(o => { + o.attribute = parseAttribute(o); + o.lv = o.level; + for(let i = l; i <= o.lv; i++) { + dicExpeditionSubAttr.set(l, _.pick(o, Object.keys(DicExpeditionSubAttrKeys))); + l++; + } + }); + arr = undefined; +} + +function parseAttribute(o) { + let attribute: {id: number, val: number}[] = []; + for(let i = ABI_TYPE.ABI_HP; i < ABI_TYPE.ABI_MAX; i++) { + let field = HERO_ATTR[i]; + if(o[field] != undefined) { + attribute.push({ id: i, val: o[field] }); + } + } + return attribute; +} \ No newline at end of file