远征本主界面及匹配机器人
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
import { ActionPointModel } from '../../../db/ActionPoint';
|
||||
import { BattleDropModel } from '../../../db/BattleDrop';
|
||||
|
||||
import { getWarById, getGoodById } from '../../../util/gamedata';
|
||||
import { getWarById, getWarJsons } from '../../../util/gamedata';
|
||||
import { decodeStr, Reward } from '../../../util/util';
|
||||
import { ACTION_POIN, BATTLE_REWARD_TYPE, GOOD_TYPE } from '../../../consts/consts';
|
||||
import { ACTION_POIN, BATTLE_REWARD_TYPE, WAR_JSON_ATTRIBUTE_TYPE } from '../../../consts/consts';
|
||||
|
||||
export async function getAp(now: number, roleId: string) {
|
||||
let dataAp = await ActionPointModel.getAp(roleId);
|
||||
@@ -130,4 +130,46 @@ export class WarReward {
|
||||
return returnGoods;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export async function matchPlayers(scale: number, range: number, myCe: number ,enemyObj: {enemyFrom: number, enemyId: string, enemies: Array<any> }) {
|
||||
|
||||
let min = myCe * scale * (1 - range/100);
|
||||
let max = myCe * scale * (1 + range/100);
|
||||
console.log(min, max, enemyObj);
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
export async function matchRobots(scale: number, myCe: number, robotCe: number, warJsonIndex:any, role, enemyObj: {enemyFrom: number, enemyId: string, enemies: Array<any> }) {
|
||||
let {json: dicWarJson, fileName } = getWarJsons(warJsonIndex);
|
||||
if(dicWarJson) {
|
||||
enemyObj.enemyFrom = 2;
|
||||
enemyObj.enemyId = fileName;
|
||||
|
||||
let ratio = myCe / robotCe * scale; // 玩家战力/机器人初始战力*系数
|
||||
for(let enemy of dicWarJson) {
|
||||
let attribute = decodeWarJsonAttribute(enemy.attribute); // 格式:{'hp':1000, ...}
|
||||
for(let value in attribute) {
|
||||
attribute[value] *= ratio;
|
||||
}
|
||||
enemyObj.enemies.push({...enemy, attribute, lv: role.lv});
|
||||
}
|
||||
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export function decodeWarJsonAttribute(attribute) {
|
||||
let arr = decodeStr('attribute', attribute);
|
||||
let obj = {};
|
||||
for(let {id, value} of arr) {
|
||||
let field = WAR_JSON_ATTRIBUTE_TYPE[id];
|
||||
if(field) {
|
||||
obj[field] = value;
|
||||
}
|
||||
}
|
||||
return obj
|
||||
}
|
||||
Reference in New Issue
Block a user