pvp:结算阵容分数
This commit is contained in:
@@ -94,8 +94,8 @@ export default class PvpDefense extends BaseModel {
|
||||
|
||||
}
|
||||
|
||||
public static async updateCe(roleId: string, hid: number, defCe: number, lean = true) {
|
||||
const rec: PvpDefenseType = await PvpDefenseModel.findOneAndUpdate({ roleId, 'heroes.actorId': hid }, { $inc: { defCe } }).lean(lean);
|
||||
public static async updateCe(roleId: string, hid: number, incCe: number, lean = true) {
|
||||
const rec: PvpDefenseType = await PvpDefenseModel.findOneAndUpdate({ roleId, 'lineupCe.hid': hid }, { $inc: { ce: incCe } }).lean(lean);
|
||||
return rec
|
||||
}
|
||||
|
||||
|
||||
+57
-11
@@ -1,9 +1,13 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
import { getTimeFun } from '../pubUtils/timeUtil';
|
||||
import { genCode } from '../pubUtils/util';
|
||||
import { genCode, robotIdComBack } from '../pubUtils/util';
|
||||
import { PvpHeroInfo } from '../domain/dbGeneral';
|
||||
import { EXTERIOR } from '../pubUtils/dicParam';
|
||||
import { RoleType } from './Role';
|
||||
import { PvpHistoryOppType } from './PvpHistoryOpp';
|
||||
import { HeroType } from './Hero';
|
||||
import { pvpEndParamInter } from '../pubUtils/interface';
|
||||
|
||||
export class HeroesRecord {
|
||||
@prop({ required: true, default: 0 })
|
||||
@@ -25,20 +29,34 @@ export class HeroesRecord {
|
||||
@prop({ required: true, default: 0 })
|
||||
underDamage: number; // 承伤
|
||||
|
||||
constructor(pvpHero: PvpHeroInfo, damage: number, heal: number, underDamage: number) {
|
||||
setByPvpHeroInfo(pvpHero: PvpHeroInfo, params: pvpEndParamInter) {
|
||||
this.hid = pvpHero.actorId;
|
||||
this.skinId = pvpHero.skinId;
|
||||
this.quality = pvpHero.quality;
|
||||
this.star = pvpHero.star;
|
||||
this.colorStar = pvpHero.colorStar;
|
||||
this.lv = pvpHero.lv;
|
||||
this.damage = damage;
|
||||
this.heal = heal;
|
||||
this.underDamage = underDamage;
|
||||
this.setParams(params);
|
||||
}
|
||||
|
||||
setByHero(hero: HeroType, params: pvpEndParamInter) {
|
||||
this.hid = hero.hid;
|
||||
this.skinId = hero.skinId;
|
||||
this.quality = hero.quality;
|
||||
this.star = hero.star;
|
||||
this.colorStar = hero.colorStar;
|
||||
this.lv = hero.lv;
|
||||
this.setParams(params);
|
||||
}
|
||||
|
||||
setParams(params: pvpEndParamInter) {
|
||||
this.damage = params?.damage||0;
|
||||
this.heal = params?.heal||0;
|
||||
this.underDamage = params?.underDamage||0;
|
||||
}
|
||||
}
|
||||
|
||||
export class PlayerInfo {
|
||||
export class PvpRecordPlayerInfo {
|
||||
@prop({ required: true })
|
||||
roleId: string; // 角色 id
|
||||
@prop({ required: true })
|
||||
@@ -61,6 +79,34 @@ export class PlayerInfo {
|
||||
score: number; // 获得的总积分
|
||||
@prop({ required: true, type: HeroesRecord, default: [], _id: false })
|
||||
heroes: HeroesRecord[]; // 获得的总积分
|
||||
|
||||
setByRole(role: RoleType, heroes: HeroesRecord[], isSuccess: boolean, score: number, lv: number ) {
|
||||
this.roleId = role.roleId;
|
||||
this.roleName = role.roleName;
|
||||
this.head = role.head;
|
||||
this.frame = role.frame;
|
||||
this.spine = role.spine;
|
||||
this.title = role.title;
|
||||
this.ce = role.topLineupCe;
|
||||
this.lv = lv;
|
||||
this.isSuccess = isSuccess;
|
||||
this.score = score;
|
||||
this.heroes = heroes;
|
||||
}
|
||||
|
||||
setByHistoryOpp(oppRole: PvpHistoryOppType, oppHeroRecords: HeroesRecord[], isSuccess: boolean, score: number) {
|
||||
this.roleId = robotIdComBack(oppRole.oppRoleId);
|
||||
this.roleName = oppRole.roleName;
|
||||
this.lv = oppRole.pLv;
|
||||
this.head = oppRole.head;
|
||||
this.frame = oppRole.frame;
|
||||
this.spine = oppRole.spine;
|
||||
this.title = oppRole.title;
|
||||
this.ce = oppRole.defCe;
|
||||
this.heroes = oppHeroRecords;
|
||||
this.isSuccess = isSuccess;
|
||||
this.score = score;
|
||||
}
|
||||
}
|
||||
|
||||
@index({ code: 1 })
|
||||
@@ -77,15 +123,15 @@ export default class PvpRecord extends BaseModel {
|
||||
code: string; // code
|
||||
@prop({ required: true, default: 0 })
|
||||
warId: number; // 这一关使用的地图
|
||||
@prop({ required: true, type: PlayerInfo, default: {}, _id: false })
|
||||
attackInfo: PlayerInfo; // 攻方信息
|
||||
@prop({ required: true, type: PlayerInfo, default: {}, _id: false })
|
||||
defenseInfo: PlayerInfo; // 守方信息
|
||||
@prop({ required: true, type: PvpRecordPlayerInfo, default: {}, _id: false })
|
||||
attackInfo: PvpRecordPlayerInfo; // 攻方信息
|
||||
@prop({ required: true, type: PvpRecordPlayerInfo, default: {}, _id: false })
|
||||
defenseInfo: PvpRecordPlayerInfo; // 守方信息
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
createTime: number;
|
||||
|
||||
public static async createRec(param: { roleId1: string, roleId2: string, warId: number, attackInfo: PlayerInfo, defenseInfo: PlayerInfo, createTime: number }) {
|
||||
public static async createRec(param: { roleId1: string, roleId2: string, warId: number, attackInfo: PvpRecordPlayerInfo, defenseInfo: PvpRecordPlayerInfo, createTime: number }) {
|
||||
await this.delPvpRecords();
|
||||
let code = genCode(6);
|
||||
const result = await PvpRecordModel.findOneAndUpdate({ code }, param, { new: true, upsert: true }).lean();
|
||||
|
||||
Reference in New Issue
Block a user