fix 刷新bug,机器人属性bug

This commit is contained in:
luying
2021-01-09 14:45:23 +08:00
parent 9dfe7dda57
commit 6b64e0cb07
2 changed files with 36 additions and 21 deletions

View File

@@ -98,10 +98,9 @@ export async function refreshEnemies(role: RoleType, score: number, pLv: number)
let opp = dicPvpOpponent.values()
for(let dicOpp of opp) {
let flag = false; // 是否筛选成功
if(score > 3000) { // TODO 将这个放到const
if(score >= PVP_CONST.SCORE_LINE) { // TODO 将这个放到const
flag = await matchPlayer(oppPlayers, roleId, pLv, dicOpp);
// TODO 当前后分数段没有时,返回前一名的玩家
if(!flag) flag = await matchPlayerByRank(oppPlayers, roleId, dicOpp.id);
if(!flag) flag = await matchPlayerByRank(oppPlayers, roleId, dicOpp.id); // 当前后分数段没有时,返回前一名的玩家
if(!flag) flag = matchRobot(oppPlayers, topFiveCe, pLv, dicOpp);
} else {
flag = matchRobot(oppPlayers, topFiveCe, pLv, dicOpp);
@@ -113,7 +112,13 @@ export async function refreshEnemies(role: RoleType, score: number, pLv: number)
}
export async function matchPlayerByRank(oppPlayers: OppPlayers[], roleId: string, pos: number) {
let ridRanks = new Array<number>(); // 已经被使用了的排名
for(let { roleId: curRoleId } of oppPlayers) {
let rankLv = await getMyRank(REDIS_KEY.PVP_RANK, 0, curRoleId);
ridRanks.push(rankLv);
}
let myRank = await getMyRank(REDIS_KEY.PVP_RANK, 0, roleId);
ridRanks.push(myRank);
let oppRoleId = '';
let oppRank = 0;
if(myRank == 1) { // 第一名
@@ -127,8 +132,14 @@ export async function matchPlayerByRank(oppPlayers: OppPlayers[], roleId: string
} else {
if(pos == 1 || pos == 2) { // 刷新我前一名
oppRank = myRank - 1;
while(ridRanks.includes(oppRank)) {
oppRank --;
}
} else { // 刷新我后一名
oppRank = myRank + 1;
while(ridRanks.includes(oppRank)) {
oppRank ++;
}
}
}
let result = await getFieldByRank(REDIS_KEY.PVP_RANK, 0, oppRank);
@@ -362,7 +373,7 @@ export async function getRobotLineup(mapWarJson: DicWarJson[], curOpp: OppPlayer
if(relation == 2 && actorId > 0) { // 默认格子
let newAttribute = new CeAttrNumber();
for(let attrName in newAttribute) {
newAttribute[attrName] = Math.floor(attribute[attrName] * topFiveCe / 10000 * dicOpp.ratio);
newAttribute[attrName] = Math.floor(attribute[attrName] * reduceCe(topFiveCe) / PVP_CONST.ENEMY_CE * dicOpp.ratio);
}
newAttribute['speed'] = 0;
newAttribute['ap'] = 0;
@@ -384,24 +395,26 @@ export async function getPlayerLineup(mapWarJson: DicWarJson[], curOpp: OppPlaye
let role = <RoleType>oppDef.role;
let { globalCeAttr } = role;
for(let { actorId, hero, dataId, order } of oppDef.heroes) {
let curDicMapJson = mapWarJson.find(cur => cur.dataId == dataId);
let dicHero = gameData.hero.get(actorId);
let h = <HeroType>hero;
let { ceAttr } = h;
let newAttribute = new CeAttrNumber();
for(let attrName in newAttribute) {
let { base, ratioUp, fixUp, equipUp } = ceAttr[attrName];
let { ratioUp: ratioUp2, fixUp: fixUp2 } = globalCeAttr[attrName];
let result = base * ( 1 + ratioUp + ratioUp2) + fixUp + fixUp2 + equipUp;
newAttribute[attrName] += reduceCe(result);
if(actorId > 0) {
let curDicMapJson = mapWarJson.find(cur => cur.dataId == dataId);
let dicHero = gameData.hero.get(actorId);
let h = <HeroType>hero;
let { ceAttr } = h;
let newAttribute = new CeAttrNumber();
for(let attrName in newAttribute) {
let { base, ratioUp, fixUp, equipUp } = ceAttr[attrName];
let { ratioUp: ratioUp2, fixUp: fixUp2 } = globalCeAttr[attrName];
let result = base * ( 1 + ratioUp + ratioUp2) + fixUp + fixUp2 + equipUp;
newAttribute[attrName] += reduceCe(result);
}
newAttribute['speed'] = 0;
newAttribute['ap'] = 0;
let heroInfo = { outIndex: order, actorId, actorName: dicHero.name, skill:0, seid:'&', star: h.star, spine: 0, attribute: newAttribute, lv: h.lv };
heroes.push({
...curDicMapJson, ...heroInfo
});
}
newAttribute['speed'] = 0;
newAttribute['ap'] = 0;
let heroInfo = { outIndex: order, actorId, actorName: dicHero.name, skill:0, seid:'&', star: h.star, spine: 0, attribute: newAttribute, lv: h.lv };
heroes.push({
...curDicMapJson, ...heroInfo
});
}
return heroes
}

View File

@@ -106,6 +106,8 @@ export const DUNGEON_CONST = {
export const PVP_CONST = {
REFRESH_TIME: 5, // 每天加点刷新
SCORE_LINE: 3000, // 超过这个分数之后可以刷人类对手
ENEMY_CE: 10000 // 对手战力
}
export const EXPEDITION_CONST = {