寻宝助战匹配简单机器人
This commit is contained in:
@@ -5,7 +5,7 @@ import { HANG_UP_CONSTS, TOWER_TASK_CONST, REDIS_KEY } from './../consts/consts'
|
||||
import { BattleRecordModel } from './../db/BattleRecord';
|
||||
import { TowerRecordModel } from './../db/TowerRecord';
|
||||
import { RoleModel } from './../db/Role';
|
||||
import { getHeroInfoById, getJobInfoById, getTowerDataByLv, getTaskById, getGamedata } from "../pubUtils/gamedata"
|
||||
import { getHeroInfoById, getJobInfoById, getTowerDataByLv, getTaskById, getGamedata, getRandExpedition, getWarById, getWarJsons } from "../pubUtils/gamedata"
|
||||
import { decodeArrayStr, shouldRefresh, resResult, decodeStr, cal, getRandomWithWeight, getRefTime, decodeStrSingle, genCode } from '../pubUtils/util';
|
||||
import { handleFixedReward } from './rewardService';
|
||||
import { STATUS } from '../consts/statusCode';
|
||||
@@ -347,4 +347,30 @@ export async function getTasksReward(roleId: string, curTime: Date) {
|
||||
}
|
||||
}
|
||||
return goods
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取随机机器人数据
|
||||
* @param cnt 机器人数量
|
||||
* @param withAttr 是否返回属性,false: 仅返回阵容
|
||||
*/
|
||||
export function getRandRobot(cnt = 1, withAttr = false) {
|
||||
let setInfo = getRandExpedition(cnt);
|
||||
if (!setInfo || setInfo.length !== cnt) return null;
|
||||
|
||||
let robots = [];
|
||||
for (let info of setInfo) {
|
||||
if (!info || !info.warId) continue;
|
||||
const warInfo = getWarJsons(info.warId).json;
|
||||
if (!warInfo || !warInfo.length) continue;
|
||||
|
||||
let heroes = [];
|
||||
for(let hero of warInfo) {
|
||||
if (hero && hero.relation === 2 && hero.actorId) {
|
||||
heroes.push(hero.actorId);
|
||||
}
|
||||
}
|
||||
robots.push(heroes);
|
||||
}
|
||||
return robots;
|
||||
}
|
||||
18
game-server/app/services/comBattleService.ts
Normal file
18
game-server/app/services/comBattleService.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { getBluePrtByQuality } from "../pubUtils/gamedata";
|
||||
import { getRandEelm } from "../pubUtils/util";
|
||||
|
||||
/**
|
||||
* 在给定的品质列表中随机返回一定数量的藏宝图Id
|
||||
* @param qualityArr 品质数组,在所有给定品质的藏宝图中筛选1
|
||||
* @param cnt 返回藏宝图数量
|
||||
*/
|
||||
export async function getRandBlueprtId(qualityArr: Array<number>, cnt = 1) {
|
||||
if (!qualityArr || !qualityArr.length) return null;
|
||||
let blueprtIdArr = [];
|
||||
for (let q of qualityArr) {
|
||||
blueprtIdArr = blueprtIdArr.concat(getBluePrtByQuality(q));
|
||||
}
|
||||
if (blueprtIdArr.length === 0) return null;
|
||||
const res = getRandEelm(blueprtIdArr, cnt);
|
||||
return res;
|
||||
}
|
||||
Reference in New Issue
Block a user