Files
ZYZ/shared/domain/gameField/serverlist.ts
2021-03-12 14:16:32 +08:00

71 lines
2.2 KiB
TypeScript

import { ServerInfo } from '../../db/Game';
import { RoleType } from '../../db/Role';
import { getSeconds } from '../../pubUtils/timeUtil';
export class ServerParam {
id: number; // 区号
serverStr: string; // 显示的区号 S1
name: string; // 区名
host: string; // pinus地址
port: number; // pinus端口
status: number; // 状态
openTime: number; // 开服时间
serverType: string; // 分区类型 官服 测试服 开发服
constructor(server: ServerInfo) {
this.id = server.id;
this.serverStr = `S${this.id}`;
this.name = server.name;
this.host = server.host;
this.port = server.port;
this.status = server.status;
this.openTime = getSeconds(server.openTime);
this.serverType = server.serverType;
}
}
export class GroupParam {
groupId: number; // 大区号
groupName: string; // 大区名
groupStr: string; // 大区内小区编号 S1-S10
servers: ServerParam[]; // 区
constructor(server: ServerInfo) {
this.groupId = server.groupId;
this.groupName = server.groupName;
this.groupStr = `S${server.id}-S${server.id + 9}`;
this.servers = new Array<ServerParam>();
}
public pushServer(server: ServerInfo) {
let srv = new ServerParam(server);
this.servers.push(srv);
}
}
export class ServerParamWithRole extends ServerParam {
groupId: number; // 大区号
groupName: string; // 大区名
roleId: string; // 玩家账号
roleName: string; // 玩家名
head: number; // 头像
frame: number; // 相框
spine: number; // 形象
lv: number; // 等级
updatedAt: Date;
constructor(role: RoleType, server: ServerInfo) {
super(server);
this.groupId = server.groupId;
this.groupName = server.groupName;
this.roleId = role.roleId;
this.roleName = role.roleName;
this.head = role.head;
this.frame = role.frame;
this.spine = role.spine;
this.lv = role.lv;
this.updatedAt = role.updatedAt;
}
}