全局修改:topFive字段

This commit is contained in:
luying
2021-02-25 13:36:10 +08:00
parent 47c3c093f2
commit 56efab8cb7
17 changed files with 224 additions and 224 deletions
@@ -94,7 +94,7 @@ export class ComBattleHandler {
const { qualityArr, lvRange = 1 } = msg;
const roleInfo = await RoleModel.findByRoleId(roleId);
const { lv } = roleInfo;
let { topFiveCe = 1000 } = roleInfo;
let { topLineupCe = 1000 } = roleInfo;
if (comBtlLvInvalid(lv, lvRange)) {
return resResult(STATUS.COM_BATTLE_ASSIST_LV_NOT_ENOUGH);
@@ -103,7 +103,7 @@ export class ComBattleHandler {
return resResult(STATUS.COM_BLUEPRT_QUALITY_ERROR);
}
const teams = await ComBattleTeamModel.getOtherTeamByQualityAndSt(roleId, qualityArr, COM_TEAM_STATUS.DEFAULT, lvRange, topFiveCe);
const teams = await ComBattleTeamModel.getOtherTeamByQualityAndSt(roleId, qualityArr, COM_TEAM_STATUS.DEFAULT, lvRange, topLineupCe);
const team: ComBattleTeamType = await oneTeamNotInBlack(teams, roleId);
if (team && team.roleIds.length < 3 && team.status === COM_TEAM_STATUS.DEFAULT && team.roleIds.indexOf(roleId) === -1) {
return resResult(STATUS.SUCCESS, {teamCode: team.teamCode});
@@ -130,7 +130,7 @@ export class ComBattleHandler {
addUserToChannel(channel, new ChannelUser(roleId, sid));
// 创建并添加机器人
await addRobotsToTeam(comTeam, roleId, topFiveCe, lv, thiz.teamMap, thiz.teamDisTimer, channel, 2);
await addRobotsToTeam(comTeam, roleId, topLineupCe, lv, thiz.teamMap, thiz.teamDisTimer, channel, 2);
await ComBattleTeamModel.createTeam(comTeam);
thiz.teamMap.set(teamCode, comTeam);
@@ -172,14 +172,14 @@ export class ComBattleHandler {
if (!teamStatus || teamStatus.status !== COM_TEAM_STATUS.DEFAULT) return resResult(STATUS.COM_BATTLE_TEAM_INVALID);
if (teamIsFullToStart(teamStatus)) return resResult(STATUS.COM_BATTLE_MEMBER_LIMIT);
if (teamStatus.roleIds.indexOf(roleId) !== -1) return resResult(STATUS.COM_BATTLE_DUP_ENTER);
let { lv = 1, headHid = 19, topFiveCe = 0, sHid = 19 } = await Role.findByRoleId(roleId);
let { lv = 1, headHid = 19, topLineupCe = 0, sHid = 19 } = await Role.findByRoleId(roleId);
let { quality } = getGoodById(teamStatus.blueprtId);
if (lv < COM_BTL_CONST.ENABLE_LV) {
return resResult(STATUS.COM_BATTLE_LV_NOT_ENOUGH);
} else if (comBtlLvInvalid(lv, teamStatus.lvRange)) {
return resResult(STATUS.COM_BATTLE_ASSIST_LV_NOT_ENOUGH);
} else if (topFiveCe < teamStatus.ceLimit) {
} else if (topLineupCe < teamStatus.ceLimit) {
return resResult(STATUS.COM_BATTLE_CE_LIMIT);
}
@@ -189,7 +189,7 @@ export class ComBattleHandler {
// 加入队伍
if (!validToJoin(teamStatus, roleId)) return resResult(STATUS.COM_BATTLE_TEAM_INVALID);
let roleStatus = new RoleStatus(roleId, roleName, false, isFrd, headHid, sHid, topFiveCe, lv);
let roleStatus = new RoleStatus(roleId, roleName, false, isFrd, headHid, sHid, topLineupCe, lv);
const team = await ComBattleTeamModel.addRole(teamCode, roleStatus);
if (!team) {
return resResult(STATUS.COM_BATTLE_JOIN_ERR);
@@ -357,8 +357,8 @@ export class ComBattleHandler {
}
}
if (!roleSt) return;
let { topFiveCe, lv } = roleSt;
await addRobotsToTeam(curTeamStatus, roleId, topFiveCe, lv, thiz.teamMap, thiz.teamDisTimer, channel, 3 - curTeamStatus.roleIds.length);
let { topLineupCe, lv } = roleSt;
await addRobotsToTeam(curTeamStatus, roleId, topLineupCe, lv, thiz.teamMap, thiz.teamDisTimer, channel, 3 - curTeamStatus.roleIds.length);
}
}, COM_BTL_CONST.ASSIST_TIME);
return resResult(STATUS.SUCCESS);
@@ -643,11 +643,11 @@ export class FriendHandler {
let dbHeroes = await HeroModel.findByRole(oppoRoleId);
let role = await RoleModel.findByRoleId(oppoRoleId, null, true);
let { topFive, topFiveCe, towerLv } = role;
let { topLineup, topLineupCe, towerLv } = role;
let heroes = new Array<PlayerDetailHero>();
for(let {hid, lv, star, colorStar, quality } of dbHeroes) {
let hasHero = topFive.find(cur => cur.hid == hid);
let hasHero = topLineup.find(cur => cur.hid == hid);
if(hasHero) {
heroes.push({
actorId: hid, lv, star, colorStar, quality,
@@ -657,7 +657,7 @@ export class FriendHandler {
}
let rank = await getMyRank(REDIS_KEY.PVP_RANK, 0, oppoRoleId);//去redis中获取排名
result = new PlayerDetail({...role, defCe: topFiveCe, heroes});
result = new PlayerDetail({...role, defCe: topLineupCe, heroes});
result.setWarStar(role.warStar, rank, towerLv);
return resResult(STATUS.SUCCESS, result);
@@ -72,8 +72,8 @@ export class RoleHandler {
async getRoleInfo(msg: {targetRoleId: string}, session: BackendSession) {
let { targetRoleId } = msg;
let { roleId, roleName, headHid = 1, ce = 0, topFive, topFiveCe = 0 } = await RoleModel.findByRoleId(targetRoleId);
return resResult(STATUS.SUCCESS, { roleId, roleName, headHid, ce, topFive, topFiveCe });
let { roleId, roleName, headHid = 1, ce = 0, topLineup, topLineupCe = 0 } = await RoleModel.findByRoleId(targetRoleId);
return resResult(STATUS.SUCCESS, { roleId, roleName, headHid, ce, topLineup, topLineupCe });
}
//爵位
+10 -10
View File
@@ -39,7 +39,7 @@ export function getRandBlueprtId(qualityArr: number[], cnt = 1) {
return res;
}
export function getRandComBtlRobots(topFiveCe: number, ceLimit: number, lv: number, cnt: number) {
export function getRandComBtlRobots(topLineupCe: number, ceLimit: number, lv: number, cnt: number) {
let robotHeroes = getRandRobot(cnt); // 随机几个阵容
let robotInfos = []; // 随机几个机器人信息
for (let i = 0; i < cnt; i++) {
@@ -53,7 +53,7 @@ export function getRandComBtlRobots(topFiveCe: number, ceLimit: number, lv: numb
if (ceLimit) {
robotCe = getRandValueByMinMax(ceLimit * COM_BTL_CONST.ROBOT_CE_LIMIT_MIN, ceLimit * COM_BTL_CONST.ROBOT_CE_LIMIT_MAX, 0);
} else {
robotCe = getRandValue(topFiveCe || 0, COM_BTL_CONST.ROBOT_CE_RATIO, 0);
robotCe = getRandValue(topLineupCe || 0, COM_BTL_CONST.ROBOT_CE_RATIO, 0);
}
const robotLv = getRandValue(lv, COM_BTL_CONST.ROBOT_CE_RATIO, 0);
const imgHid = robot[Math.floor(Math.random() * robot.length)];
@@ -473,8 +473,8 @@ async function teammateValid(roleInfo: Partial<RoleType>, roleId: string, roleId
const isBlack = await teammateInBlackList(roleId, roleIds);
if(isBlack) return false;
let { topFiveCe } = roleInfo;
if (topFiveCe < ceLimit) return false;
let { topLineupCe } = roleInfo;
if (topLineupCe < ceLimit) return false;
return true;
}
@@ -490,12 +490,12 @@ async function teammateValid(roleInfo: Partial<RoleType>, roleId: string, roleId
*/
export async function getValidTeammateRoleSt(roleId: string, roleIds: string[], ceLimit: number, quality: number) {
let roleInfo = await RoleModel.findByRoleId(roleId);
let { roleName, headHid = 19, sHid = 19, topFiveCe, lv } = roleInfo;
let { roleName, headHid = 19, sHid = 19, topLineupCe, lv } = roleInfo;
const valid = await teammateValid(roleInfo, roleId, roleIds, ceLimit);
if (!valid) return null;
let isFrd = await getFrd(roleId, quality);
const result = new RoleStatus(roleId, roleName, false, isFrd, headHid, sHid, topFiveCe, lv);
const result = new RoleStatus(roleId, roleName, false, isFrd, headHid, sHid, topLineupCe, lv);
return result;
}
@@ -574,8 +574,8 @@ export async function hasEnoughBlueprt(roleId: string, blueprtId: number) {
*/
export function addRoleToTeam(comTeam: MemComBtlTeam, roleInfo: RoleType, isCap: boolean, isFrd: boolean) {
const { roleId, roleName, headHid = 19, sHid = 19, lv } = roleInfo;
let { topFiveCe = 1000 } = roleInfo;
const roleSt = new RoleStatus(roleId, roleName, isCap, isFrd, headHid, sHid, topFiveCe, lv);
let { topLineupCe = 1000 } = roleInfo;
const roleSt = new RoleStatus(roleId, roleName, isCap, isFrd, headHid, sHid, topLineupCe, lv);
addRoleStToTeam(comTeam, roleSt);
}
@@ -670,7 +670,7 @@ export async function addRobotsLater(comTeam: MemComBtlTeam, roleInfo: RoleType,
const teamStatus = comTeam;
const { teamCode } = teamStatus;
const { roleId, lv } = roleInfo;
let { topFiveCe = 1000 } = roleInfo;
let { topLineupCe = 1000 } = roleInfo;
if (validToJoin(teamStatus)) {
const robotCnt = 3 - teamStatus.roleIds.length;
@@ -679,7 +679,7 @@ export async function addRobotsLater(comTeam: MemComBtlTeam, roleInfo: RoleType,
setTimeout(async () => {
const curTeamStatus = teamMap.get(teamCode);
if (validToJoin(curTeamStatus)) {
await addRobotsToTeam(curTeamStatus, roleId, topFiveCe, lv, teamMap, teamDisTimer, channel, 1);
await addRobotsToTeam(curTeamStatus, roleId, topLineupCe, lv, teamMap, teamDisTimer, channel, 1);
}
}, joinTime);
}
+4 -4
View File
@@ -12,17 +12,17 @@ import { defaultHeroes } from './pvpService';
//修改并下发战力
export async function calPlayerCeAndSave(sid: string, roleId: string, heros: Array<HeroType>, type?: number, args?: Array<number>) {
let {role, pushHeros, topFiveCe} = await pubCalPlayerCeAndSave(roleId, heros, type, args);
let {role, pushHeros, topLineupCe} = await pubCalPlayerCeAndSave(roleId, heros, type, args);
//下发战力
let uids = [{ uid: roleId, sid }];
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(role.ce) , heros: pushHeros, topFiveCe: reduceCe(topFiveCe) }), uids);
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(role.ce) , heros: pushHeros, topLineupCe: reduceCe(topLineupCe) }), uids);
defaultHeroes(role);
return heros;
}
export async function calAllHeroCe(sid: string, roleId: string, type?:number, args?:Array<number>) {
let {ce, pushHeros, topFiveCe }= await reCalAllHeroCe(roleId, type, args);
let {ce, pushHeros, topLineupCe }= await reCalAllHeroCe(roleId, type, args);
let uids = [{ uid: roleId, sid }];
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(ce), heros: pushHeros, topFiveCe: reduceCe(topFiveCe) }), uids);
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(ce), heros: pushHeros, topLineupCe: reduceCe(topLineupCe) }), uids);
return {ce: reduceCe(ce)};
}
+11 -11
View File
@@ -26,7 +26,7 @@ export async function initPvpInfo(role: RoleType) {
//初始化最强5人阵容
for (let i = PVP_HERO_POS.START; i <= PVP_HERO_POS.END; i++) {
let index = i - PVP_HERO_POS.START;
let item = role.topFive[index];
let item = role.topLineup[index];
heroes.push({
actorId: item?.hid||0,
hero: item?.hero||null,
@@ -39,7 +39,7 @@ export async function initPvpInfo(role: RoleType) {
let oppPlayers: Array<OppPlayers> = await refreshEnemies(role, 0, 1);
let {seasonNum} = await SystemConfigModel.findSystemConfig();
let challengeCnt = PVP.PVP_CHALLENGE_COUNTS;
let result = await PvpDefenseModel.createPvpDefense({ roleId: role.roleId, roleName: role.roleName, role: role._id, heroes, oppPlayers, defCe: role.topFiveCe, seasonNum, challengeCnt });
let result = await PvpDefenseModel.createPvpDefense({ roleId: role.roleId, roleName: role.roleName, role: role._id, heroes, oppPlayers, defCe: role.topLineupCe, seasonNum, challengeCnt });
//加入排行榜
let { roleId, roleName, lv, vLv, headHid, sHid, title } = role;
@@ -236,7 +236,7 @@ async function generPlayerOppHis(pvpdefense: PvpDefenseType, mapWarJson: DicWarJ
async function matchRobot(oppPlayers: OppPlayers[], mapWarJson: DicWarJson[], role: RoleType, pLv: number, dicOpp: DicPvpOpponent) {
console.log('matchRobot', JSON.stringify(oppPlayers))
let { lv: myLv, topFiveCe: myCe, roleId } = role;
let { lv: myLv, topLineupCe: myCe, roleId } = role;
let { id: pos, minLv, maxLv, ratio } = dicOpp;
let range = gameData.pvpWar;
if(range.length <= 0) return false;
@@ -324,31 +324,31 @@ export async function defaultHeroes ( role:RoleType, challengeCnt?:number, chall
if (!isUpdate && !isDefaultHero) {
return;
}
let orders = [1, 2, 3, 4, 5];
role.topFive.sort(function(a, b) {
let orders = [1, 2, 3, 4, 5, 6];
role.topLineup.sort(function(a, b) {
return b.ce - a.ce;
});
heroes.sort(function(a, b) {
return b.ce - b.dataId - a.ce + a.dataId;
});
for (let hero of heroes) {
if (!!hero.order&& !!hero.hero && findIndex(role.topFive, {hid: hero.actorId}) != -1) {
if (!!hero.order&& !!hero.hero && findIndex(role.topLineup, {hid: hero.actorId}) != -1) {
let index = orders.indexOf(hero.order);
orders.splice(index, 1);
}
}
let defCe = 0;
let num = 0;
for (let i = 0; i < role.topFive.length; i++) {
let item = role.topFive[i];
for (let i = 0; i < role.topLineup.length; i++) {
let item = role.topLineup[i];
let index = findIndex(heroes, {actorId: item.hid});
if (index == -1) {
for (let j = num; j < heroes.length; j++) {
let hero = heroes[j];
if (num >= 5) {
if (num >= 6) {
break;
}
if (!!findWhere(role.topFive, {hid: hero.actorId})) {
if (!!findWhere(role.topLineup, {hid: hero.actorId})) {
continue;
}
if (!orders[0]) {
@@ -579,7 +579,7 @@ export async function generMyRecInfo(heroScores: HeroScores[], winStreakNum: num
sHid: role.sHid,
headHid: role.headHid,
title: role.title,
ce: reduceCe(role.topFiveCe),
ce: reduceCe(role.topLineupCe),
heroes: myHeroRecords,
isSuccess,
score: isSuccess ? addSumScore : 0
+1 -1
View File
@@ -25,7 +25,7 @@ module.exports = {
},
'required uInt32 ce': 1,
'repeated Hero heros': 2,
'required uInt32 topFiveCe': 3
'required uInt32 topLineupCe': 3
},
'required string msg': 1,
'required uInt32 code': 2,
+3 -3
View File
@@ -78,7 +78,7 @@ describe('寻宝创建队伍', function() {
expect(res.data.teamCode).to.be.a('string');
expect(res.data.roleStatus).to.be.an('array');
res.data.roleStatus.forEach(roleSt => {
expect(roleSt).to.have.all.keys('roleId', 'roleName', 'isCap', 'isFrd', 'headHid', 'sHid', 'topFiveCe', 'lv', 'isRobot', 'heroes', 'killed', 'totalDmg', 'frdRatio');
expect(roleSt).to.have.all.keys('roleId', 'roleName', 'isCap', 'isFrd', 'headHid', 'sHid', 'topLineupCe', 'lv', 'isRobot', 'heroes', 'killed', 'totalDmg', 'frdRatio');
});
pinusClientT.request('battle.comBattleHandler.searchTeam', searchTeamParms, (searchRes) => {
console.log('searchRes:', searchRes);
@@ -114,7 +114,7 @@ describe('寻宝创建队伍', function() {
expect(res.data.teamCode).to.be.a('string');
expect(res.data.roleStatus).to.be.an('array');
res.data.roleStatus.forEach(roleSt => {
expect(roleSt).to.have.all.keys('roleId', 'roleName', 'isCap', 'isFrd', 'headHid', 'sHid', 'topFiveCe', 'lv', 'isRobot', 'heroes', 'killed', 'totalDmg', 'frdRatio');
expect(roleSt).to.have.all.keys('roleId', 'roleName', 'isCap', 'isFrd', 'headHid', 'sHid', 'topLineupCe', 'lv', 'isRobot', 'heroes', 'killed', 'totalDmg', 'frdRatio');
});
const roleIds = res.data.roleStatus.map(roleSt => { return roleSt.roleId });
if (roleIds.indexOf(roleInfoT.roleId) === -1) {
@@ -136,7 +136,7 @@ describe('寻宝创建队伍', function() {
expect(res.data.teamCode).to.be.a('string');
expect(res.data.roleStatus).to.be.an('array');
res.data.roleStatus.forEach(roleSt => {
expect(roleSt).to.have.all.keys('roleId', 'roleName', 'isCap', 'isFrd', 'headHid', 'sHid', 'topFiveCe', 'lv', 'isRobot', 'heroes', 'killed', 'totalDmg', 'frdRatio');
expect(roleSt).to.have.all.keys('roleId', 'roleName', 'isCap', 'isFrd', 'headHid', 'sHid', 'topLineupCe', 'lv', 'isRobot', 'heroes', 'killed', 'totalDmg', 'frdRatio');
});
pinusClient.request('battle.comBattleHandler.dismiss', {teamCode: res.data.teamCode}, (dismissRes) => {
expect(dismissRes).to.be.an('object');