远征:修改机器人模板计算

This commit is contained in:
luying
2021-09-10 15:43:39 +08:00
parent dd70efddbe
commit a6525ef254
11 changed files with 78 additions and 13 deletions

View File

@@ -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;
}

View File

@@ -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 };

View File

@@ -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 = [

View File

@@ -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,

View File

@@ -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) {

View File

@@ -75,7 +75,7 @@ export default class ServerMail extends MailTemp {
{ new: true }
).lean();
console.log('*******', result)
// console.log('*******', result)
return result;
}

View File

@@ -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 } };

View File

@@ -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<number, number> = new Map<number, number>();
@@ -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);
}

View File

@@ -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())

View File

@@ -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<number, number>(),
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

View File

@@ -0,0 +1,43 @@
import { readFileAndParse } from '../util'
import { ABI_TYPE, FILENAME, HERO_ATTR } from '../../consts'
type KeysEnum<T> = { [P in keyof Required<T>]: true };
const _ = require('lodash');
export interface DicExpeditionSubAttr {
// 等级
readonly lv: number;
// 属性
readonly attribute: {id: number, val: number}[];
}
const DicExpeditionSubAttrKeys: KeysEnum<DicExpeditionSubAttr> = {
lv: true,
attribute: true,
};
export const dicExpeditionSubAttr = new Map<number, DicExpeditionSubAttr>();
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;
}