fix 远征相应获取属性逻辑
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
|
||||
import { ExpeditionPointModel } from '../db/ExpeditionPoint';
|
||||
import Role, { RoleModel } from '../db/Role';
|
||||
import Role, { RoleModel, RoleType } from '../db/Role';
|
||||
import { PvpDefenseModel } from '../db/PvpDefense';
|
||||
|
||||
import { getWarJsons, getGamedata, getExpeditionById } from '../pubUtils/gamedata';
|
||||
@@ -8,12 +8,15 @@ import { decodeStr, resResult, setLocalHours, shouldRefresh } from '../pubUtils/
|
||||
import { EXPEDITION_CONST, HERO_CE_RATIO, getAttrCeRatio } from '../consts';
|
||||
import { getAtrrNameById} from '../consts';
|
||||
import { ExpeditionWarRecordModel } from '../db/ExpeditionWarRecord';
|
||||
import { HeroType } from '../db/Hero';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
import { getPlayerAttribute, getRobotAttribute } from './pvpService';
|
||||
|
||||
export async function findOrCreateEnemies(roleId: string, myCe: number, expeditionCode: string, expeditionId: number, battleStatus: number) {
|
||||
|
||||
let expeditionWarRecord = await ExpeditionWarRecordModel.getRecordByCodeAndId(expeditionCode, expeditionId);
|
||||
if(!expeditionWarRecord) { // 如果没有信息
|
||||
let curDicExpedition = getExpeditionById(expeditionId);
|
||||
let curDicExpedition = gameData.expedition.get(expeditionId);
|
||||
if(curDicExpedition) {
|
||||
|
||||
let enemyObj = {
|
||||
@@ -71,18 +74,34 @@ export async function matchPlayers(roleId: string, scale: number, range: number,
|
||||
let index = Math.floor(Math.random() * resultRange.length);
|
||||
let result = resultRange[index];
|
||||
let {roleId, heroes, defCe } = result;
|
||||
let role = <RoleType>result.role;
|
||||
let { globalCeAttr } = role;
|
||||
|
||||
enemyObj.enemyFrom = 1;
|
||||
enemyObj.enemyId = roleId;
|
||||
enemyObj.ce = defCe;
|
||||
|
||||
// TODO 修改获取attribute
|
||||
let heroIndex = 0;
|
||||
for(let enemy of dicWarJson) {
|
||||
if(enemy.relation == 2) {
|
||||
for(let json of dicWarJson) {
|
||||
if(json.relation == 2) {
|
||||
let hero = heroes[heroIndex];
|
||||
if(hero) {
|
||||
enemyObj.enemies.push({...enemy, ...hero});
|
||||
let h = <HeroType>hero.hero;
|
||||
let { star, lv, ceAttr } = h;
|
||||
let dicHero = gameData.hero.get(hero.actorId);
|
||||
let newAttribute = getPlayerAttribute(ceAttr, globalCeAttr);
|
||||
let heroInfo = {
|
||||
actorId: hero.actorId,
|
||||
actorName: dicHero.name,
|
||||
skill:0,
|
||||
seid:'&',
|
||||
star,
|
||||
spine: 0,
|
||||
attribute: newAttribute,
|
||||
lv
|
||||
};
|
||||
|
||||
enemyObj.enemies.push({...json, ...heroInfo});
|
||||
heroIndex ++;
|
||||
}
|
||||
}
|
||||
@@ -95,30 +114,28 @@ export async function matchPlayers(roleId: string, scale: number, range: number,
|
||||
}
|
||||
|
||||
// 匹配机器人
|
||||
export async function matchRobots(scale: number, myCe: number, robotCe: number, warJsonIndex:any, lv: number, enemyObj: {enemyFrom: number, enemyId: string, enemies: Array<any>, ce: number }) {
|
||||
let {json: dicWarJson, fileName } = getWarJsons(warJsonIndex);
|
||||
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) {
|
||||
enemyObj.enemyFrom = 2;
|
||||
enemyObj.enemyId = fileName + '';
|
||||
enemyObj.enemyId = warJsonIndex + '';
|
||||
|
||||
let allCe = 0;
|
||||
let ratio = myCe / HERO_CE_RATIO / HERO_CE_RATIO / robotCe * scale; // 玩家战力/机器人初始战力*系数
|
||||
for(let enemy of dicWarJson) {
|
||||
if(enemy.relation == 2) {
|
||||
let attribute = decodeWarJsonAttribute(enemy.attribute); // 格式:{'hp':1000, ...}
|
||||
for(let value in attribute) {
|
||||
attribute[value] *= ratio;
|
||||
attribute[value] = Math.round(attribute[value]);
|
||||
}
|
||||
for(let json of dicWarJson) {
|
||||
if(json.relation == 2) {
|
||||
const { attribute } = json;
|
||||
|
||||
let newAttribute = getRobotAttribute(attribute, myCe, robotCe, scale);
|
||||
let ce = 0;
|
||||
for(let attrName in attribute) {
|
||||
ce += attribute[attrName] * getAttrCeRatio(attrName)||0;
|
||||
for(let attrName in newAttribute) {
|
||||
ce += newAttribute[attrName] * getAttrCeRatio(attrName)||0;
|
||||
}
|
||||
enemyObj.enemies.push({...enemy, attribute, lv});
|
||||
enemyObj.enemies.push({...json, attribute: newAttribute, lv});
|
||||
allCe += ce;
|
||||
}
|
||||
}
|
||||
console.log(JSON.stringify(enemyObj.enemies))
|
||||
|
||||
enemyObj.ce = Math.floor(allCe);
|
||||
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user