Merge branch 'feature/test'
This commit is contained in:
@@ -1007,6 +1007,7 @@ export enum ITEM_CHANGE_REASON {
|
||||
|
||||
export enum TA_EVENT {
|
||||
REGISTER = 'register', // 注册
|
||||
CREATE_ROLE = 'create_role', // 创建角色
|
||||
RECHARGE = 'recharge', // 发起充值
|
||||
RECHARGE_SUCCESS = 'recharge_success', // 充值成功
|
||||
RECHARGE_FAIL = 'recharge_fail', // 充值失败
|
||||
|
||||
@@ -22,6 +22,8 @@ export default class PvpDefense extends BaseModel {
|
||||
lineupCe: LineupCe[];
|
||||
@prop({ required: true, type: () => OppPlayer, default: [], _id: false })
|
||||
oppPlayers: OppPlayer[];
|
||||
@prop({ required: true, type: () => OppPlayer, default: [], _id: false })
|
||||
oppBeforePlayers: OppPlayer[];
|
||||
@prop({ required: true, type: () => HeroScore, default: [], _id: false })
|
||||
heroScores: HeroScore[];
|
||||
|
||||
@@ -112,7 +114,8 @@ export default class PvpDefense extends BaseModel {
|
||||
const result: PvpDefenseType = await PvpDefenseModel.findOne({ roleId })
|
||||
.populate('role', 'head frame spine topLineupCe roleId roleName lv globalCeAttr')
|
||||
.populate('heroes.hero')
|
||||
.populate('oppPlayers.oppDef', 'oppRoleId pos roleName head frame spine heads frames spines rankLv title lv pLv defCe heroes warId buff').lean({ getters: true, virtuals: true });
|
||||
.populate('oppPlayers.oppDef', 'oppRoleId pos roleName head frame spine heads frames spines rankLv title lv pLv defCe heroes warId buff')
|
||||
.populate('oppBeforePlayers.oppDef', 'oppRoleId pos roleName head frame spine heads frames spines rankLv title lv pLv defCe heroes warId buff').lean({ getters: true, virtuals: true });
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ export default class PvpHistoryOpp extends BaseModel {
|
||||
@prop({ required: true })
|
||||
oppRoleId: string; // 对手角色 id
|
||||
@prop({ required: true })
|
||||
isRobot: boolean; // 是否是机器人
|
||||
@prop({ required: true })
|
||||
roleName: string; // 角色名称
|
||||
@prop({ required: true, default: EXTERIOR.EXTERIOR_FACE })
|
||||
head: number; // 对手头像
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -427,6 +427,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 * 6)};
|
||||
}
|
||||
|
||||
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