远征:fix 远征机器人战力

This commit is contained in:
luying
2021-03-08 16:53:02 +08:00
parent 9773b8d69e
commit 07a9c74145

View File

@@ -12,6 +12,14 @@ import { HeroType } from '../db/Hero';
import { gameData } from '../pubUtils/data';
import { getPlayerAttribute, getRobotAttribute } from './pvpService';
/**
* 根据存下的战力获取当前远征关卡的对手
* @param roleId 我的id
* @param myCe 存在expeditionRecord内的战力缩过
* @param expeditionCode 远征批次id
* @param expeditionId 该关卡id
* @param battleStatus 该关卡的挑战状态
*/
export async function findOrCreateEnemies(roleId: string, myCe: number, expeditionCode: string, expeditionId: number, battleStatus: number) {
let expeditionWarRecord = await ExpeditionWarRecordModel.getRecordByCodeAndId(expeditionCode, expeditionId);
@@ -62,7 +70,15 @@ export async function findOrCreateEnemies(roleId: string, myCe: number, expediti
return expeditionWarRecord;
}
// 匹配玩家
/**
* 远征关卡匹配玩家
* @param roleId 我的id
* @param scale 己方战力和对方战力比
* @param range 浮动范围
* @param myCe 己方战力(已缩小)
* @param warJsonIndex 模板出兵表id
* @param enemyObj 返回的敌军数据
*/
export async function matchPlayers(roleId: string, scale: number, range: number, myCe: number, warJsonIndex:any, enemyObj: {enemyFrom: number, enemyId: string, enemies: Array<any>, ce: number }) {
let {json: dicWarJson } = getWarJsons(warJsonIndex);
@@ -113,7 +129,15 @@ export async function matchPlayers(roleId: string, scale: number, range: number,
}
}
// 匹配机器人
/**
* 匹配远征机器人
* @param scale 己方战力和出兵表配置战力比
* @param myCe 己方战力(已缩小)
* @param robotCe 机器人战力10000相当于已缩小战力
* @param warJsonIndex 模板出兵表id
* @param lv 我的主公等级
* @param enemyObj 返回的敌军数据
*/
export async function matchRobots(scale: number, myCe: number, robotCe: number, warJsonIndex: number, lv: number, enemyObj: {enemyFrom: number, enemyId: string, enemies: Array<any>, ce: number }) {
let dicWarJson = gameData.warJson.get(warJsonIndex);
if(dicWarJson) {
@@ -121,13 +145,12 @@ export async function matchRobots(scale: number, myCe: number, robotCe: number,
enemyObj.enemyId = warJsonIndex + '';
let allCe = 0;
let ratio = myCe / HERO_CE_RATIO / HERO_CE_RATIO / robotCe * scale; // 玩家战力/机器人初始战力*系数
for(let json of dicWarJson) {
if(json.relation == 2) {
const { attribute } = json;
let newAttribute = getRobotAttribute(attribute, myCe, robotCe, scale);
let ce = newAttribute.calCelAndReduce();
let ce = newAttribute.calCe();
enemyObj.enemies.push({...json, attribute: newAttribute, lv});
allCe += ce;
}