全局修改: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

@@ -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
}
]