Files
ZYZ/shared/domain/battleField/gvgBattle.ts
T
2023-02-28 15:26:21 +08:00

60 lines
1.6 KiB
TypeScript

import GVGTeam, { GVGTeamType } from "../../db/GVGTeam";
import { nowSeconds } from "../../pubUtils/timeUtil";
// 积分点分类统计,1-3级积分点代表从小到大
export class LeagueCityPoint {
// 玩家id
roleId: string;
// 军团id
guildCode: string;
// 联军id
leagueCode: string;
// 计分点数
pointCnt1: number;
pointCnt2: number;
pointCnt3: number;
// 击杀守卫数
guardCnt1: number;
// 击杀投石车数
catapultCnt1: number;
}
// 队伍状态
export class GVGTeamMem extends GVGTeam {
isMoving: boolean;
constructor(team: GVGTeamType) {
super();
this.updateTeam(team);
}
public updateTeam(team: GVGTeamType) {
for(let key in team) {
if(key == 'lineup' || key == '_id' || key == 'createdAt' || key == 'updatedAt') continue;
this[key] = team[key];
}
this.isMoving = this.stopMoveTime > nowSeconds();
}
public setCity(cityId: number, areaId = 0, pointId = 0) {
this.cityId = cityId;
this.areaId = areaId;
this.pointId = pointId;
}
public moveToArea(areaId: number, fromAreaId: number, startMoveTime: number, stopMoveTime: number) {
this.areaId = areaId;
this.fromAreaId = fromAreaId;
this.startMoveTime = startMoveTime;
this.stopMoveTime = stopMoveTime;
}
public updateInfo(info: { leagueName?: string, roleName?: string, lv?: number }) {
if(!info) return
if(info.leagueName) this.leagueName = info.leagueName;
if(info.roleName) this.roleName = info.roleName;
if(info.lv) this.lv = info.lv;
}
}