pvp:修改等级和军功对应关系
This commit is contained in:
@@ -4,7 +4,7 @@ import Hero from '../../db/Hero';
|
||||
import { PvpDefenseType } from '../../db/PvpDefense';
|
||||
import PvpHistoryOpp from '../../db/PvpHistoryOpp';
|
||||
import { PvpSeasonResultType } from '../../db/PvpSeasonResult';
|
||||
import { getPLvByScore } from '../../pubUtils/data';
|
||||
import { getPlvAndScore } from '../../pubUtils/data';
|
||||
import { RewardInter } from '../../pubUtils/interface';
|
||||
|
||||
|
||||
@@ -43,10 +43,12 @@ export class Defense {
|
||||
@prop({ required: true })
|
||||
pLv: number; // 防守阵容的等级
|
||||
|
||||
constructor(heroes: DefenseHero[], score: number, warId: number, buff: number) {
|
||||
constructor(heroes: DefenseHero[], scores: number[], warId: number, buff: number) {
|
||||
this.heroes = heroes;
|
||||
this.score = scores.reduce((pre, cur) => pre + cur, 0);
|
||||
let {pLv, score} = getPlvAndScore(scores);
|
||||
this.pLv = pLv,
|
||||
this.score = score;
|
||||
this.pLv = getPLvByScore(score);
|
||||
this.warId = warId;
|
||||
this.buff = buff;
|
||||
}
|
||||
@@ -69,10 +71,12 @@ export class Attack {
|
||||
@prop({ required: true })
|
||||
pLv: number; // 防守阵容的等级
|
||||
|
||||
constructor(heroes: AttackHero[], score: number) {
|
||||
constructor(heroes: AttackHero[], scores: number[]) {
|
||||
this.heroes = heroes;
|
||||
this.score = scores.reduce((pre, cur) => pre + cur, 0);
|
||||
let {pLv, score} = getPlvAndScore(scores);
|
||||
this.pLv = pLv;
|
||||
this.score = score;
|
||||
this.pLv = getPLvByScore(score);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -461,6 +461,13 @@ export function getPLvByScore(score: number) {
|
||||
return lv;
|
||||
}
|
||||
|
||||
export function getPlvAndScore(scores: number[] = []) {
|
||||
if(scores.length <= 0) scores = [0];
|
||||
let maxScore = Math.max(...scores); // 等级:军功最高者的军功*6
|
||||
let score = scores.reduce((pre, cur) => pre + cur, 0);
|
||||
return { score, pLv: getPLvByScore(maxScore)};
|
||||
}
|
||||
|
||||
export function getPvpHeroRewardsByScore(score: number) {
|
||||
for (let item of gameData.pvpHeroRewards) {
|
||||
if ((item.max >= score || item.max == -1) && score >= item.min) {
|
||||
|
||||
Reference in New Issue
Block a user