战力:pvp远征匹配系数修改
This commit is contained in:
@@ -14,6 +14,7 @@ import { getRoleOnlineInfo, getAllOnlineRoles } from '../../../services/redisSer
|
|||||||
import { pushComposeOrangeHero, pushHeroQualityUpMsg, pushHeroStarMax } from '../../../services/chatService';
|
import { pushComposeOrangeHero, pushHeroQualityUpMsg, pushHeroStarMax } from '../../../services/chatService';
|
||||||
import { calculatetopLineup } from '../../../pubUtils/playerCe';
|
import { calculatetopLineup } from '../../../pubUtils/playerCe';
|
||||||
import { PvpDefenseModel } from '../../../db/PvpDefense';
|
import { PvpDefenseModel } from '../../../db/PvpDefense';
|
||||||
|
import { Attribute } from '../../../domain/roleField/attribute';
|
||||||
|
|
||||||
export default function(app: Application) {
|
export default function(app: Application) {
|
||||||
return new HeroHandler(app);
|
return new HeroHandler(app);
|
||||||
@@ -25,13 +26,40 @@ export class HeroHandler {
|
|||||||
|
|
||||||
private channelService: ChannelService = this.app.get('channelService');
|
private channelService: ChannelService = this.app.get('channelService');
|
||||||
|
|
||||||
public async test(msg: { items:Array<{id: number, count: number, seqId:number, type:number}>}, session: BackendSession) {
|
public async test(msg: { }, session: BackendSession) {
|
||||||
let roleId: string = session.get('roleId');
|
let roles = await RoleModel.find({}).lean();
|
||||||
|
for(let role of roles) {
|
||||||
|
let { roleId, attr: roleAttr, topLineup } = role;
|
||||||
|
let heros = await HeroModel.findByRole(roleId);
|
||||||
|
let sumCe = 0;
|
||||||
|
|
||||||
let role = await getRoleOnlineInfo(roleId);
|
let pvpdefense = await PvpDefenseModel.findByRoleId(roleId);
|
||||||
let list = await getAllOnlineRoles();
|
let { heroes: defHeroes } = pvpdefense;
|
||||||
return resResult(STATUS.SUCCESS, {role, list});
|
|
||||||
|
|
||||||
|
for(let hero of heros) {
|
||||||
|
let { hid, attr: heroAttr } = hero;
|
||||||
|
let attr = new Attribute();
|
||||||
|
attr.setByDbData(roleAttr, heroAttr);
|
||||||
|
let ce = attr.calCe();
|
||||||
|
await HeroModel.updateHeroInfo(roleId, hid, { ce, historyCe: ce });
|
||||||
|
sumCe += ce;
|
||||||
|
let curHero = topLineup.find(cur => cur.hid == hid);
|
||||||
|
if(curHero) curHero.ce = ce;
|
||||||
|
|
||||||
|
let curDefHero = defHeroes.find(cur => cur.actorId == hid);
|
||||||
|
if(curDefHero) curDefHero.ce = ce;
|
||||||
|
console.log(roleId, hid, ce, sumCe)
|
||||||
|
}
|
||||||
|
let topLineupCe = topLineup.reduce((pre, cur) => {
|
||||||
|
return pre + cur.ce
|
||||||
|
}, 0);
|
||||||
|
let defCe = defHeroes.reduce((pre, cur) => {
|
||||||
|
return pre + cur.ce
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
await RoleModel.updateRoleInfo(roleId, { ce: sumCe, topLineup, topLineupCe });
|
||||||
|
await PvpDefenseModel.updateInfo(roleId, { defCe, heroes: defHeroes }); // 更新pvp防守阵战力
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ! 测试接口,用来测试前清理并初始化某个武将;代码抄自:gm-server/app/service/users.ts deleteHero
|
// ! 测试接口,用来测试前清理并初始化某个武将;代码抄自:gm-server/app/service/users.ts deleteHero
|
||||||
|
|||||||
@@ -24,9 +24,11 @@ import { PvpHistoryOppModel, PvpHistoryOppType } from '../db/PvpHistoryOpp';
|
|||||||
export async function initPvpInfo(role: RoleType) {
|
export async function initPvpInfo(role: RoleType) {
|
||||||
let heroes: Array<Heroes> = [];
|
let heroes: Array<Heroes> = [];
|
||||||
//初始化最强5人阵容
|
//初始化最强5人阵容
|
||||||
|
let defCe = 0;
|
||||||
for (let i = PVP_HERO_POS.START; i <= PVP_HERO_POS.END; i++) {
|
for (let i = PVP_HERO_POS.START; i <= PVP_HERO_POS.END; i++) {
|
||||||
let index = i - PVP_HERO_POS.START;
|
let index = i - PVP_HERO_POS.START;
|
||||||
let item = role.topLineup[index];
|
let item = role.topLineup[index];
|
||||||
|
if(item) defCe += item.ce;
|
||||||
heroes.push({
|
heroes.push({
|
||||||
actorId: item?.hid||0,
|
actorId: item?.hid||0,
|
||||||
hero: item?.hero||null,
|
hero: item?.hero||null,
|
||||||
@@ -39,7 +41,7 @@ export async function initPvpInfo(role: RoleType) {
|
|||||||
let oppPlayers: Array<OppPlayers> = await refreshEnemies(role, 0, 1);
|
let oppPlayers: Array<OppPlayers> = await refreshEnemies(role, 0, 1);
|
||||||
let {seasonNum} = await SystemConfigModel.findSystemConfig();
|
let {seasonNum} = await SystemConfigModel.findSystemConfig();
|
||||||
let challengeCnt = PVP.PVP_CHALLENGE_COUNTS;
|
let challengeCnt = PVP.PVP_CHALLENGE_COUNTS;
|
||||||
let result = await PvpDefenseModel.createPvpDefense({ roleId: role.roleId, roleName: role.roleName, role: role._id, heroes, oppPlayers, defCe: role.topLineupCe, seasonNum, challengeCnt });
|
let result = await PvpDefenseModel.createPvpDefense({ roleId: role.roleId, roleName: role.roleName, role: role._id, heroes, oppPlayers, defCe, seasonNum, challengeCnt });
|
||||||
|
|
||||||
//加入排行榜
|
//加入排行榜
|
||||||
let { roleId, roleName, lv, vLv, headHid, sHid, title } = role;
|
let { roleId, roleName, lv, vLv, headHid, sHid, title } = role;
|
||||||
@@ -248,6 +250,7 @@ async function matchRobot(oppPlayers: OppPlayers[], mapWarJson: DicWarJson[], ro
|
|||||||
let robotWarjson = gameData.warJson.get(result.war_id);
|
let robotWarjson = gameData.warJson.get(result.war_id);
|
||||||
if(!robotWarjson) { /* TODO 判空处理 */ }
|
if(!robotWarjson) { /* TODO 判空处理 */ }
|
||||||
let heroes = new Array<PvpEnemies>();
|
let heroes = new Array<PvpEnemies>();
|
||||||
|
let defCe = 0;
|
||||||
for(let warJson of mapWarJson) {
|
for(let warJson of mapWarJson) {
|
||||||
if(warJson.relation == 1) continue;
|
if(warJson.relation == 1) continue;
|
||||||
let h = robotWarjson.find(cur => cur.dataId == warJson.dataId);
|
let h = robotWarjson.find(cur => cur.dataId == warJson.dataId);
|
||||||
@@ -257,6 +260,7 @@ async function matchRobot(oppPlayers: OppPlayers[], mapWarJson: DicWarJson[], ro
|
|||||||
let heroInfo = new PvpHeroInfo();
|
let heroInfo = new PvpHeroInfo();
|
||||||
heroInfo.setRobotInfo(h, myLv, dicHero.initialStars, dicHero.quality);
|
heroInfo.setRobotInfo(h, myLv, dicHero.initialStars, dicHero.quality);
|
||||||
let attribute = getRobotAttribute(h.attribute, myCe, PVP_CONST.ENEMY_CE, ratio);
|
let attribute = getRobotAttribute(h.attribute, myCe, PVP_CONST.ENEMY_CE, ratio);
|
||||||
|
defCe += attribute.ce;
|
||||||
heroInfo.setAttribute(attribute);
|
heroInfo.setAttribute(attribute);
|
||||||
let enemy = new PvpEnemies(warJson, heroInfo, 0);
|
let enemy = new PvpEnemies(warJson, heroInfo, 0);
|
||||||
heroes.push(enemy);
|
heroes.push(enemy);
|
||||||
@@ -269,7 +273,7 @@ async function matchRobot(oppPlayers: OppPlayers[], mapWarJson: DicWarJson[], ro
|
|||||||
if(hisPLv < 1) hisPLv = 1
|
if(hisPLv < 1) hisPLv = 1
|
||||||
|
|
||||||
let pvpHistoryOpp = await PvpHistoryOppModel.createPvpOpp({
|
let pvpHistoryOpp = await PvpHistoryOppModel.createPvpOpp({
|
||||||
roleId, oppRoleId, roleName, pos, defCe: Math.floor(myCe * ratio), pLv: hisPLv, lv: myLv, heroes
|
roleId, oppRoleId, roleName, pos, defCe, pLv: hisPLv, lv: myLv, heroes
|
||||||
});
|
});
|
||||||
|
|
||||||
oppPlayers.push({
|
oppPlayers.push({
|
||||||
@@ -494,9 +498,10 @@ export async function findPvpDefAllByRoleId(roleId: string) {
|
|||||||
export function getRobotAttribute(attribute: {id: number, val: number}[], ce: number, enemyCe: number, ratio: number) {
|
export function getRobotAttribute(attribute: {id: number, val: number}[], ce: number, enemyCe: number, ratio: number) {
|
||||||
|
|
||||||
let newAttribute = new Attribute();
|
let newAttribute = new Attribute();
|
||||||
newAttribute.setByWarJson(attribute, ce / enemyCe * ratio);
|
newAttribute.setByWarJson(attribute, Math.sqrt(ce / enemyCe * ratio));
|
||||||
let attrJson = newAttribute.getReduceAttributes();
|
let attrJson = newAttribute.getReduceAttributes();
|
||||||
|
let resultCe = newAttribute.calCelAndReduce();
|
||||||
|
attrJson.ce = resultCe;
|
||||||
return attrJson;
|
return attrJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -509,7 +514,8 @@ export function getPlayerAttribute(heroAttrs: CeAttrData[] = [], roleAttrs: CeAt
|
|||||||
let newAttribute = new Attribute();
|
let newAttribute = new Attribute();
|
||||||
newAttribute.setByDbData(roleAttrs, heroAttrs);
|
newAttribute.setByDbData(roleAttrs, heroAttrs);
|
||||||
let attrJson = newAttribute.getReduceAttributes();
|
let attrJson = newAttribute.getReduceAttributes();
|
||||||
|
let resultCe = newAttribute.calCelAndReduce();
|
||||||
|
attrJson.ce = resultCe;
|
||||||
return attrJson;
|
return attrJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { prop } from '@typegoose/typegoose';
|
import { prop } from '@typegoose/typegoose';
|
||||||
import { HERO_CE_RATIO, getAtrrNameById, CE_CONST, HERO_SUB_ATTR_RATIO } from '../../consts';
|
import { HERO_CE_RATIO, getAtrrNameById, CE_CONST, HERO_SUB_ATTR_RATIO, ABI_TYPE_MAIN } from '../../consts';
|
||||||
import { reduceCe } from '../../pubUtils/util';
|
import { reduceCe } from '../../pubUtils/util';
|
||||||
|
|
||||||
// hero表内属性基础格式
|
// hero表内属性基础格式
|
||||||
@@ -80,6 +80,8 @@ export class Attribute {
|
|||||||
ap: number = 0;
|
ap: number = 0;
|
||||||
@prop({ required: false })
|
@prop({ required: false })
|
||||||
damageCri: number = 0;
|
damageCri: number = 0;
|
||||||
|
@prop({ required: false })
|
||||||
|
ce?: number = 0;
|
||||||
|
|
||||||
setByDbData(roleAttrs: CeAttrDataRole[], heroAttrs: CeAttrData[]) {
|
setByDbData(roleAttrs: CeAttrDataRole[], heroAttrs: CeAttrData[]) {
|
||||||
for(let { id, fixUp: roleFix, ratioUp: roleRatio } of roleAttrs) {
|
for(let { id, fixUp: roleFix, ratioUp: roleRatio } of roleAttrs) {
|
||||||
@@ -108,7 +110,11 @@ export class Attribute {
|
|||||||
setByWarJson( attributes: {id: number, val: number}[], ratio: number = 1) {
|
setByWarJson( attributes: {id: number, val: number}[], ratio: number = 1) {
|
||||||
for(let {id, val} of attributes) {
|
for(let {id, val} of attributes) {
|
||||||
let attrName = getAtrrNameById(id);
|
let attrName = getAtrrNameById(id);
|
||||||
if(attrName in this) this[attrName] = Math.floor(val * ratio * HERO_CE_RATIO * HERO_CE_RATIO);
|
if(ABI_TYPE_MAIN.includes(id)) {
|
||||||
|
if(attrName in this) this[attrName] = Math.floor(val * ratio * HERO_CE_RATIO * HERO_CE_RATIO);
|
||||||
|
} else {
|
||||||
|
if(attrName in this) this[attrName] = Math.floor(val * HERO_CE_RATIO * HERO_CE_RATIO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user