pvp:修复赛季相关

This commit is contained in:
luying
2021-11-02 10:16:50 +08:00
parent 15ed1f71fe
commit 4c80a22ccf
15 changed files with 178 additions and 91 deletions

View File

@@ -149,7 +149,10 @@ export default class PvpDefense extends BaseModel {
}
public static async resetScores(roleId: string, newSeasonNum: number, newScore: number, newHeroScores: HeroScore[]) {
let result: PvpDefenseType = await PvpDefenseModel.findOneAndUpdate({roleId}, {$set: { seasonNum: newSeasonNum, score: newScore, heroScores: newHeroScores, challengeCnt: PVP.PVP_CHALLENGE_COUNTS, challengeRefTime: 0, winStreakNum: 0 }}, {new: true}).lean();
let result: PvpDefenseType = await PvpDefenseModel.findOneAndUpdate({roleId}, {$set: { seasonNum: newSeasonNum, score: newScore, heroScores: newHeroScores, challengeCnt: PVP.PVP_CHALLENGE_COUNTS, challengeRefTime: 0, winStreakNum: 0 }}, {new: true})
.populate('role', 'roleId roleName head frame spine heads frames spines title lv vLv')
.populate('oppPlayers.oppDef', 'oppRoleId pos roleName head frame spine heads frames spines rankLv pLv title lv defCe heroes warId buff').lean({ getters: true, virtuals: true })
.lean();
return result;
}

View File

@@ -39,11 +39,12 @@ export default class PvpSeasonResult extends BaseModel {
newHeroScores: HeroScore[];
public static async updatePvpSeasonResult(roleId: string, seasonNum: number, update: PvpSeasonResultUpdate , lean = true) {
delete update._id;
let result: PvpSeasonResultType = await PvpSeasonResultModel.findOneAndUpdate({roleId, seasonNum}, {$set: update}, {upsert: true, new: true}).lean(lean);
return result;
}
public static async getPvpSeasonResult(roleId: string, seasonNum: number, lean = true) {
let result: PvpSeasonResultType = await PvpSeasonResultModel.findOne({ roleId, seasonNum }).lean(lean);
public static async getPvpSeasonResult(roleId: string) {
let result: PvpSeasonResultType = await PvpSeasonResultModel.findOne({ roleId, show: true }).lean();
return result;
}
}

View File

@@ -4,6 +4,8 @@ import { RoleType } from "../../db/Role";
import { WAR_TYPE } from "../../consts";
import { gameData } from "../../pubUtils/data";
import { EXTERIOR } from "../../pubUtils/dicParam";
import { HeroType } from "../../db/Hero";
import { PvpDefenseType } from "../../db/PvpDefense";
export class PlayerDetailHero {
actorId: number;
@@ -12,7 +14,8 @@ export class PlayerDetailHero {
star: number;
colorStar: number;
quality: number;
score: number;
score: number = 0;
isDefense: boolean;
setPvpHeroInfo?(hero: PvpEnemies|PvpOtherHeroes) {
this.actorId = hero.actorId;
@@ -23,6 +26,37 @@ export class PlayerDetailHero {
this.quality = hero.quality;
this.score = hero.score;
}
setByDbHero?(hero: HeroType) {
if(!hero) return;
this.actorId = hero.hid;
this.lv = hero.lv;
this.star = hero.star;
this.colorStar = hero.colorStar;
this.quality = hero.quality;
this.skinId = hero.skinId;
}
setPvpDefense?(pvpDefense: PvpDefenseType) {
if(!pvpDefense) return;
let { heroScores, defense } = pvpDefense;
let heroScore = heroScores.find(cur => cur.hid == this.actorId);
this.score = heroScore? heroScore.score: 0;
if(defense && defense.heroes) {
let h = defense.heroes.find(cur => cur.actorId == this.actorId);
if(!!h) this.isDefense = true;
} else {
this.isDefense = false;
}
}
setIsDefense?(isDefense: boolean) {
this.isDefense = isDefense;
}
}
class PlayerDetailBattle {

View File

@@ -77,7 +77,7 @@ export class Enemies extends PvpHeroInfo {
@prop({ required: false })
y: number; // 战场y坐标
@prop({ required: false })
direction: number; // 朝向
dirction: number; // 朝向
@prop({ required: false })
var: number; // 变量
@prop({ required: false })
@@ -99,7 +99,7 @@ export class Enemies extends PvpHeroInfo {
this.outIndex = heroInfo.outIndex != undefined ? heroInfo.outIndex : warjson.outIndex;
this.x = warjson.x;
this.y = warjson.y;
this.direction = warjson.direction;
this.dirction = warjson.dirction;
this.var = warjson.var;
this.lv = heroInfo.lv != undefined ? heroInfo.lv : warjson.lv;
this.hide = warjson.hide;

View File

@@ -316,6 +316,7 @@ export class KeyName {
guildCode?: string;
cityId?: number;
hid?: number;
seasonNum?: number;
constructor(key: string, param: KeyNameParam) {
this.key = key;
@@ -323,6 +324,7 @@ export class KeyName {
if(param.guildCode) this.guildCode = param.guildCode;
if(param.cityId) this.cityId = param.cityId;
if(param.hid) this.hid = param.hid;
if(param.seasonNum) this.seasonNum = param.seasonNum;
}
public getName() {
@@ -331,6 +333,7 @@ export class KeyName {
if(this.guildCode) res += `:${this.guildCode}`;
if(this.cityId) res += `:${this.cityId}`;
if(this.hid) res += `:${this.hid}`;
if(this.seasonNum) res += `:${this.seasonNum}`;
return res;
}

View File

@@ -460,6 +460,7 @@ export function getPvpHeroRewardsByScore(score: number) {
}
export function getPvpRankRewardsByRank(rankLv: number) {
if(rankLv == 0) return null
for (let item of gameData.pvpRankRewards) {
if ((item.max >= rankLv || item.max == -1) && rankLv >= item.min) {
return item;

View File

@@ -21,7 +21,7 @@ export function loadPvpRankReward() {
arr.forEach(o => {
o.reward = parseGoodStr(o.reward);
if (!dicRankMax.max||o.min > dicRankMax.max.min) {
if (!dicRankMax.max || o.min > dicRankMax.max.min) {
dicRankMax.max = o;
}
dicRankRewads.push(o);

View File

@@ -14,7 +14,7 @@ export interface DicWarJson {
// 角色属于我方/敌方/友军
readonly relation: number;
// 上阵时的方向
readonly direction: number;
readonly dirction: number;
// 客户端存入数组的顺序
readonly outIndex: number;
// x坐标