全局修改:topFive字段

This commit is contained in:
luying
2021-02-24 13:23:55 +08:00
parent 47c3c093f2
commit 56efab8cb7
17 changed files with 224 additions and 224 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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 });
}
//爵位

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);
}

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)};
}

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

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,

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');

View File

@@ -24,7 +24,7 @@ import { STATUS, HERO_SYSTEM_TYPE } from '@consts';
import { ITID, COUNTER } from '@consts';
import { ItemModel } from '@db/Item';
import { gameData, getHeroExpByLv } from '@pubUtils/data';
import { calPlayerCeAndSave, calculateTopFive, calEquipSeids } from '@pubUtils/playerCe';
import { calPlayerCeAndSave, calculatetopLineup, calEquipSeids } from '@pubUtils/playerCe';
import { SchoolModel } from '@db/School';
import { CeAttrNumber } from '@domain/roleField/attribute';
import { smsModel } from '@db/Sms';
@@ -517,9 +517,9 @@ export default class GMUsers extends Service {
if (!hero) continue;
await HeroModel.deleteHero(roleId, hid);
let role = await RoleModel.findByRoleId(roleId);
await calculateTopFive(role, hid, 0, null);
await calculatetopLineup(role, hid, 0, null);
await PvpDefenseModel.deleteHero(roleId, hid);
await RoleModel.updateRoleInfo(roleId, { topFive: role.topFive, topFiveCe: role.topFiveCe, ce: role.ce - hero.ce });
await RoleModel.updateRoleInfo(roleId, { topLineup: role.topLineup, topLineupCe: role.topLineupCe, ce: role.ce - hero.ce });
}
return ctx.service.utils.resResult(STATUS.SUCCESS);

View File

@@ -1,7 +1,7 @@
export enum ROLE_SELECT {
// 初始登录数据
ENTRY = 'serverId userInfo.uid userInfo.tel userInfo.serverType ce topFiveCe teraphs roleId roleName tili lv exp gold coin vLv title hasGuild funcs eventStatus',
ENTRY = 'serverId userInfo.uid userInfo.tel userInfo.serverType ce topLineupCe teraphs roleId roleName tili lv exp gold coin vLv title hasGuild funcs eventStatus',
// 玩家列表显示基础数据
SHOW_SIMPLE = 'roleId roleName ce headHid sHid lv title job quitTime vLv guildName serverId userInfo.serverType',
// 显示申请需要的信息
@@ -11,7 +11,7 @@ export enum ROLE_SELECT {
GET_LV = 'lv',
GET_ROLE_ID = 'roleId',
GET_MY_SERVER = 'lv serverId userInfo.serverType',
COM_BATTLE = 'lv headHid sHid topFiveCe'
COM_BATTLE = 'lv headHid sHid topLineupCe'
};
export enum HERO_SELECT {

View File

@@ -33,7 +33,7 @@ export class RoleStatus {
sHid: number;
// 前五战力
@prop({ required: true, default: 0 })
topFiveCe: number;
topLineupCe: number;
// 主公等级
@prop({ required: true, default: 1 })
lv: number;
@@ -50,7 +50,7 @@ export class RoleStatus {
@prop({ required: true, default: 0 })
frdRatio: number = 0;
constructor(roleId: string, roleName: string, isCap: boolean, isFrd: boolean, headHid: number, sHid: number, topFiveCe: number, lv: number, heroes = [], isRobot = false) {
constructor(roleId: string, roleName: string, isCap: boolean, isFrd: boolean, headHid: number, sHid: number, topLineupCe: number, lv: number, heroes = [], isRobot = false) {
this.roleId = roleId;
this.roleName = roleName;
this.isCap = isCap;
@@ -58,7 +58,7 @@ export class RoleStatus {
this.isFrd = isFrd;
this.headHid = headHid;
this.sHid = sHid;
this.topFiveCe = topFiveCe;
this.topLineupCe = topLineupCe;
this.lv = lv;
this.heroes = heroes;
this.killed = [];

View File

@@ -107,7 +107,7 @@ export default class PvpDefense extends BaseModel {
public static async findByScale(roleId: string, min: number, max: number) {
const result: PvpDefenseType[] = await PvpDefenseModel.find({ roleId: { $ne: roleId }, defCe: { $lte: max, $gte: min } })
.populate('role', 'headHid sHid topFiveCe roleId roleName lv globalCeAttr')
.populate('role', 'headHid sHid topLineupCe roleId roleName lv globalCeAttr')
.populate('heroes.hero')
.sort({ updatedAt: -1 }).limit(100).lean({ getters: true });
return result;
@@ -151,7 +151,7 @@ export default class PvpDefense extends BaseModel {
public static async findByRoleIdIncludeAll(roleId: string) {
const result: PvpDefenseType = await PvpDefenseModel.findOne({ roleId })
.populate('role', 'headHid sHid topFiveCe roleId roleName lv globalCeAttr')
.populate('role', 'headHid sHid topLineupCe roleId roleName lv globalCeAttr')
.populate('heroes.hero')
.populate('oppPlayers.oppDef', 'oppRoleId pos roleName headHid sHid rankLv title lv pLv defCe heroes').lean({ getters: true });
return result;
@@ -159,7 +159,7 @@ export default class PvpDefense extends BaseModel {
public static async findByTeamLv(min: number, max: number) {
const result: PvpDefenseType[] = await PvpDefenseModel.find({ pLv: { $gte: min, $lte: max } })
.populate('role', 'headHid sHid topFiveCe roleId roleName lv globalCeAttr')
.populate('role', 'headHid sHid topLineupCe roleId roleName lv globalCeAttr')
.populate('heroes.hero')
.populate('oppPlayers.oppDef', 'oppRoleId pos roleName headHid sHid rankLv pLv title lv defCe heroes')
.lean({ getters: true });
@@ -169,7 +169,7 @@ export default class PvpDefense extends BaseModel {
public static async updateInfoAndInclude(roleId: string, update: pvpUpdateInter) {
delete update._id;
let result: PvpDefenseType = await PvpDefenseModel.findOneAndUpdate({roleId}, {$set:update}, {new: true})
.populate('role', 'headHid sHid topFiveCe roleId roleName lv')
.populate('role', 'headHid sHid topLineupCe roleId roleName lv')
.populate('oppPlayers.oppDef', 'oppRoleId pos roleName headHid sHid rankLv pLv title lv defCe heroes').lean({ getters: true });
return result;
}

View File

@@ -117,9 +117,9 @@ export default class Role extends BaseModel {
@prop({ required: true, default: new CeAttrRole(), _id: false })
globalCeAttr: CeAttrRole; // 总战力
@prop({ required: true, default: 0, set: (val: number) => val, get: (val: number) => reduceCe(val) })
topFiveCe: number; // 最强5人战力
topLineupCe: number; // 最强x人战力
@prop({ required: true, type: TopHero, default: [], _id: false })
topFive: Array<TopHero>; // 总战力
topLineup: Array<TopHero>; // 总战力
@prop({ required: true, default: 100 })
tili: number; // 体力值

View File

@@ -323,9 +323,9 @@ export function getFuncsSwitch(id:number) {
export function getPLvByScore(score: number) {
let lv = 0;
for(let {teamLv, topFiveMin, topFiveMax} of gameData.pvpTeamLevel) {
if(score >= topFiveMin) lv = teamLv;
if(score < topFiveMax) break;
for(let {teamLv, topLineupMin, topLineupMax} of gameData.pvpTeamLevel) {
if(score >= topLineupMin) lv = teamLv;
if(score < topLineupMax) break;
}
return lv;
}

View File

@@ -8,9 +8,9 @@ export interface DicPvpTeamLevel {
// 队伍等级
readonly teamLv: number;
// 最高五人军功和下限
readonly topFiveMin: number;
readonly topLineupMin: number;
// 最高五人军功和上限
readonly topFiveMax: number;
readonly topLineupMax: number;
}
const str = readJsonFile(FILENAME.DIC_PVP_TEAM_LEVEL);

View File

@@ -108,7 +108,7 @@ export async function calPlayerCeAndSave(roleId: string, heros: Array<HeroType>,
let incHeroCe = calPlayerCe(role.globalCeAttr, hero, type, args);
incPlayerCe += incHeroCe;
await calculateTopFive(role, hero.hid, hero.ce, hero._id); // 计算更新最强五人战力
await calculatetopLineup(role, hero.hid, hero.ce, hero._id); // 计算更新最强五人战力
await HeroModel.updateHeroInfo(roleId, hero.hid, hero);
await PvpDefenseModel.updateCe(roleId, hero.hid, hero.ce); // 更新pvp防守阵战力
pushHeros.push({
@@ -118,49 +118,49 @@ export async function calPlayerCeAndSave(roleId: string, heros: Array<HeroType>,
});
}
role.ce += incPlayerCe;
let { topFive, topFiveCe } = role;
await RoleModel.updateRoleInfo(roleId, { globalCeAttr: role.globalCeAttr, ce: role.ce, topFive, topFiveCe });
let { topLineup, topLineupCe } = role;
await RoleModel.updateRoleInfo(roleId, { globalCeAttr: role.globalCeAttr, ce: role.ce, topLineup, topLineupCe });
await GuildModel.updateCe(roleId, incPlayerCe);
return { pushHeros, role, topFiveCe }
return { pushHeros, role, topLineupCe }
}
export async function calculateTopFive(role: RoleType, hid: number, ce: number, heroId: string) {
let topFive = role?.topFive || new Array();
export async function calculatetopLineup(role: RoleType, hid: number, ce: number, heroId: string) {
let topLineup = role?.topLineup || new Array();
topFive.sort((a, b) => { return b.ce - a.ce }); // 0-6最大-最小
let index = topFive.findIndex(cur => cur.hid == hid);
topLineup.sort((a, b) => { return b.ce - a.ce }); // 0-6最大-最小
let index = topLineup.findIndex(cur => cur.hid == hid);
if(index != -1 && !heroId) {
let heroes = await HeroModel.getTopHero(role.roleId, 6);
topFive = heroes.map(cur => { return { hid: cur.hid, ce: cur.ce, hero: cur._id } });
topLineup = heroes.map(cur => { return { hid: cur.hid, ce: cur.ce, hero: cur._id } });
} else {
if (index == -1) { // 不在最强列表
if (topFive.length < 6) { // 不满6人
topFive.push({ hid, ce, hero: heroId });
} else if (topFive.length == 6) {
if (ce > topFive[topFive.length - 1].ce) { // 跻身最强6人
topFive.pop();
topFive.push({ hid, ce, hero: heroId });
if (topLineup.length < 6) { // 不满6人
topLineup.push({ hid, ce, hero: heroId });
} else if (topLineup.length == 6) {
if (ce > topLineup[topLineup.length - 1].ce) { // 跻身最强6人
topLineup.pop();
topLineup.push({ hid, ce, hero: heroId });
}
} else {
topFive.splice(6, topFive.length - 6);
topLineup.splice(6, topLineup.length - 6);
}
} else { // 原来就是最强6人
if (ce < topFive[topFive.length - 1].ce) { // 滑出最强
if (ce < topLineup[topLineup.length - 1].ce) { // 滑出最强
let heroes = await HeroModel.getTopHero(role.roleId, 6);
topFive = heroes.map(cur => { return { hid: cur.hid, ce: cur.ce, hero: cur._id } });
topLineup = heroes.map(cur => { return { hid: cur.hid, ce: cur.ce, hero: cur._id } });
} else {
topFive[index].ce = ce;
topLineup[index].ce = ce;
}
}
}
let topFiveCe = topFive.reduce((pre, cur) => {
let topLineupCe = topLineup.reduce((pre, cur) => {
return pre + cur.ce
}, 0);
role.topFive = topFive;
role.topFiveCe = topFiveCe;
role.topLineup = topLineup;
role.topLineupCe = topLineupCe;
return role;
}
@@ -706,7 +706,7 @@ export async function reCalAllHeroCe(roleId: string, type: number, args: Array<n
await HeroModel.updateHeroInfo(roleId, hero.hid, { ce: hero.ce });
}
role = await RoleModel.updateRoleInfo(roleId, { globalCeAttr: role.globalCeAttr, ce: role.ce });
return { pushHeros, ce: role.ce, topFiveCe: role.topFiveCe }
return { pushHeros, ce: role.ce, topLineupCe: role.topLineupCe }
}
function calHeroAddSkin(args: Array<number>, ceAttr: CeAttrRole) {

View File

@@ -2,421 +2,421 @@
{
"id": 1,
"teamLv": 1,
"topFiveMin": 0,
"topFiveMax": 500
"topLineupMin": 0,
"topLineupMax": 500
},
{
"id": 2,
"teamLv": 2,
"topFiveMin": 501,
"topFiveMax": 1020
"topLineupMin": 501,
"topLineupMax": 1020
},
{
"id": 3,
"teamLv": 3,
"topFiveMin": 1021,
"topFiveMax": 1560
"topLineupMin": 1021,
"topLineupMax": 1560
},
{
"id": 4,
"teamLv": 4,
"topFiveMin": 1561,
"topFiveMax": 2120
"topLineupMin": 1561,
"topLineupMax": 2120
},
{
"id": 5,
"teamLv": 5,
"topFiveMin": 2121,
"topFiveMax": 2700
"topLineupMin": 2121,
"topLineupMax": 2700
},
{
"id": 6,
"teamLv": 6,
"topFiveMin": 2701,
"topFiveMax": 3300
"topLineupMin": 2701,
"topLineupMax": 3300
},
{
"id": 7,
"teamLv": 7,
"topFiveMin": 3301,
"topFiveMax": 3920
"topLineupMin": 3301,
"topLineupMax": 3920
},
{
"id": 8,
"teamLv": 8,
"topFiveMin": 3921,
"topFiveMax": 4560
"topLineupMin": 3921,
"topLineupMax": 4560
},
{
"id": 9,
"teamLv": 9,
"topFiveMin": 4561,
"topFiveMax": 5220
"topLineupMin": 4561,
"topLineupMax": 5220
},
{
"id": 10,
"teamLv": 10,
"topFiveMin": 5221,
"topFiveMax": 5900
"topLineupMin": 5221,
"topLineupMax": 5900
},
{
"id": 11,
"teamLv": 11,
"topFiveMin": 5901,
"topFiveMax": 6600
"topLineupMin": 5901,
"topLineupMax": 6600
},
{
"id": 12,
"teamLv": 12,
"topFiveMin": 6601,
"topFiveMax": 7320
"topLineupMin": 6601,
"topLineupMax": 7320
},
{
"id": 13,
"teamLv": 13,
"topFiveMin": 7321,
"topFiveMax": 8060
"topLineupMin": 7321,
"topLineupMax": 8060
},
{
"id": 14,
"teamLv": 14,
"topFiveMin": 8061,
"topFiveMax": 8820
"topLineupMin": 8061,
"topLineupMax": 8820
},
{
"id": 15,
"teamLv": 15,
"topFiveMin": 8821,
"topFiveMax": 9600
"topLineupMin": 8821,
"topLineupMax": 9600
},
{
"id": 16,
"teamLv": 16,
"topFiveMin": 9601,
"topFiveMax": 10400
"topLineupMin": 9601,
"topLineupMax": 10400
},
{
"id": 17,
"teamLv": 17,
"topFiveMin": 10401,
"topFiveMax": 11220
"topLineupMin": 10401,
"topLineupMax": 11220
},
{
"id": 18,
"teamLv": 18,
"topFiveMin": 11221,
"topFiveMax": 12060
"topLineupMin": 11221,
"topLineupMax": 12060
},
{
"id": 19,
"teamLv": 19,
"topFiveMin": 12061,
"topFiveMax": 12920
"topLineupMin": 12061,
"topLineupMax": 12920
},
{
"id": 20,
"teamLv": 20,
"topFiveMin": 12921,
"topFiveMax": 13800
"topLineupMin": 12921,
"topLineupMax": 13800
},
{
"id": 21,
"teamLv": 21,
"topFiveMin": 13801,
"topFiveMax": 14700
"topLineupMin": 13801,
"topLineupMax": 14700
},
{
"id": 22,
"teamLv": 22,
"topFiveMin": 14701,
"topFiveMax": 15620
"topLineupMin": 14701,
"topLineupMax": 15620
},
{
"id": 23,
"teamLv": 23,
"topFiveMin": 15621,
"topFiveMax": 16560
"topLineupMin": 15621,
"topLineupMax": 16560
},
{
"id": 24,
"teamLv": 24,
"topFiveMin": 16501,
"topFiveMax": 17520
"topLineupMin": 16501,
"topLineupMax": 17520
},
{
"id": 25,
"teamLv": 25,
"topFiveMin": 17521,
"topFiveMax": 18500
"topLineupMin": 17521,
"topLineupMax": 18500
},
{
"id": 26,
"teamLv": 26,
"topFiveMin": 18501,
"topFiveMax": 19500
"topLineupMin": 18501,
"topLineupMax": 19500
},
{
"id": 27,
"teamLv": 27,
"topFiveMin": 19501,
"topFiveMax": 20520
"topLineupMin": 19501,
"topLineupMax": 20520
},
{
"id": 28,
"teamLv": 28,
"topFiveMin": 20521,
"topFiveMax": 21560
"topLineupMin": 20521,
"topLineupMax": 21560
},
{
"id": 29,
"teamLv": 29,
"topFiveMin": 21561,
"topFiveMax": 22620
"topLineupMin": 21561,
"topLineupMax": 22620
},
{
"id": 30,
"teamLv": 30,
"topFiveMin": 22621,
"topFiveMax": 23700
"topLineupMin": 22621,
"topLineupMax": 23700
},
{
"id": 31,
"teamLv": 31,
"topFiveMin": 23701,
"topFiveMax": 24800
"topLineupMin": 23701,
"topLineupMax": 24800
},
{
"id": 32,
"teamLv": 32,
"topFiveMin": 24801,
"topFiveMax": 25920
"topLineupMin": 24801,
"topLineupMax": 25920
},
{
"id": 33,
"teamLv": 33,
"topFiveMin": 25921,
"topFiveMax": 27060
"topLineupMin": 25921,
"topLineupMax": 27060
},
{
"id": 34,
"teamLv": 34,
"topFiveMin": 27061,
"topFiveMax": 28220
"topLineupMin": 27061,
"topLineupMax": 28220
},
{
"id": 35,
"teamLv": 35,
"topFiveMin": 28221,
"topFiveMax": 29400
"topLineupMin": 28221,
"topLineupMax": 29400
},
{
"id": 36,
"teamLv": 36,
"topFiveMin": 29401,
"topFiveMax": 30600
"topLineupMin": 29401,
"topLineupMax": 30600
},
{
"id": 37,
"teamLv": 37,
"topFiveMin": 30601,
"topFiveMax": 31820
"topLineupMin": 30601,
"topLineupMax": 31820
},
{
"id": 38,
"teamLv": 38,
"topFiveMin": 31821,
"topFiveMax": 33060
"topLineupMin": 31821,
"topLineupMax": 33060
},
{
"id": 39,
"teamLv": 39,
"topFiveMin": 33061,
"topFiveMax": 34100
"topLineupMin": 33061,
"topLineupMax": 34100
},
{
"id": 40,
"teamLv": 40,
"topFiveMin": 34321,
"topFiveMax": 35260
"topLineupMin": 34321,
"topLineupMax": 35260
},
{
"id": 41,
"teamLv": 41,
"topFiveMin": 35601,
"topFiveMax": 36900
"topLineupMin": 35601,
"topLineupMax": 36900
},
{
"id": 42,
"teamLv": 42,
"topFiveMin": 36901,
"topFiveMax": 38220
"topLineupMin": 36901,
"topLineupMax": 38220
},
{
"id": 43,
"teamLv": 43,
"topFiveMin": 38221,
"topFiveMax": 39560
"topLineupMin": 38221,
"topLineupMax": 39560
},
{
"id": 44,
"teamLv": 44,
"topFiveMin": 39561,
"topFiveMax": 40920
"topLineupMin": 39561,
"topLineupMax": 40920
},
{
"id": 45,
"teamLv": 45,
"topFiveMin": 40921,
"topFiveMax": 42300
"topLineupMin": 40921,
"topLineupMax": 42300
},
{
"id": 46,
"teamLv": 46,
"topFiveMin": 42301,
"topFiveMax": 43700
"topLineupMin": 42301,
"topLineupMax": 43700
},
{
"id": 47,
"teamLv": 47,
"topFiveMin": 43701,
"topFiveMax": 45120
"topLineupMin": 43701,
"topLineupMax": 45120
},
{
"id": 48,
"teamLv": 48,
"topFiveMin": 45121,
"topFiveMax": 46560
"topLineupMin": 45121,
"topLineupMax": 46560
},
{
"id": 49,
"teamLv": 49,
"topFiveMin": 46561,
"topFiveMax": 48020
"topLineupMin": 46561,
"topLineupMax": 48020
},
{
"id": 50,
"teamLv": 50,
"topFiveMin": 48021,
"topFiveMax": 49500
"topLineupMin": 48021,
"topLineupMax": 49500
},
{
"id": 51,
"teamLv": 51,
"topFiveMin": 49501,
"topFiveMax": 51000
"topLineupMin": 49501,
"topLineupMax": 51000
},
{
"id": 52,
"teamLv": 52,
"topFiveMin": 51001,
"topFiveMax": 52520
"topLineupMin": 51001,
"topLineupMax": 52520
},
{
"id": 53,
"teamLv": 53,
"topFiveMin": 52521,
"topFiveMax": 54060
"topLineupMin": 52521,
"topLineupMax": 54060
},
{
"id": 54,
"teamLv": 54,
"topFiveMin": 54061,
"topFiveMax": 55620
"topLineupMin": 54061,
"topLineupMax": 55620
},
{
"id": 55,
"teamLv": 55,
"topFiveMin": 55621,
"topFiveMax": 57200
"topLineupMin": 55621,
"topLineupMax": 57200
},
{
"id": 56,
"teamLv": 56,
"topFiveMin": 57201,
"topFiveMax": 58800
"topLineupMin": 57201,
"topLineupMax": 58800
},
{
"id": 57,
"teamLv": 57,
"topFiveMin": 58801,
"topFiveMax": 60420
"topLineupMin": 58801,
"topLineupMax": 60420
},
{
"id": 58,
"teamLv": 58,
"topFiveMin": 60421,
"topFiveMax": 62060
"topLineupMin": 60421,
"topLineupMax": 62060
},
{
"id": 59,
"teamLv": 59,
"topFiveMin": 62061,
"topFiveMax": 63720
"topLineupMin": 62061,
"topLineupMax": 63720
},
{
"id": 60,
"teamLv": 60,
"topFiveMin": 63721,
"topFiveMax": 65400
"topLineupMin": 63721,
"topLineupMax": 65400
},
{
"id": 61,
"teamLv": 61,
"topFiveMin": 65401,
"topFiveMax": 67100
"topLineupMin": 65401,
"topLineupMax": 67100
},
{
"id": 62,
"teamLv": 62,
"topFiveMin": 67101,
"topFiveMax": 68820
"topLineupMin": 67101,
"topLineupMax": 68820
},
{
"id": 63,
"teamLv": 63,
"topFiveMin": 68821,
"topFiveMax": 70560
"topLineupMin": 68821,
"topLineupMax": 70560
},
{
"id": 64,
"teamLv": 64,
"topFiveMin": 70561,
"topFiveMax": 72320
"topLineupMin": 70561,
"topLineupMax": 72320
},
{
"id": 65,
"teamLv": 65,
"topFiveMin": 72321,
"topFiveMax": 74100
"topLineupMin": 72321,
"topLineupMax": 74100
},
{
"id": 66,
"teamLv": 66,
"topFiveMin": 74101,
"topFiveMax": 75900
"topLineupMin": 74101,
"topLineupMax": 75900
},
{
"id": 67,
"teamLv": 67,
"topFiveMin": 75901,
"topFiveMax": 77720
"topLineupMin": 75901,
"topLineupMax": 77720
},
{
"id": 68,
"teamLv": 68,
"topFiveMin": 77721,
"topFiveMax": 79560
"topLineupMin": 77721,
"topLineupMax": 79560
},
{
"id": 69,
"teamLv": 69,
"topFiveMin": 79561,
"topFiveMax": 81420
"topLineupMin": 79561,
"topLineupMax": 81420
},
{
"id": 70,
"teamLv": 70,
"topFiveMin": 81421,
"topFiveMax": 83300
"topLineupMin": 81421,
"topLineupMax": 83300
}
]