排行榜:修改格式
This commit is contained in:
+74
-55
@@ -6,6 +6,7 @@ import { GuildUpdateParam } from "../db/Guild";
|
||||
import { HeroType, HeroUpdate } from "../db/Hero";
|
||||
import { getSeconds } from "../pubUtils/timeUtil";
|
||||
import { prop } from "@typegoose/typegoose";
|
||||
import { pick } from "underscore";
|
||||
|
||||
// 排行榜返回玩家值
|
||||
export class RankParam {
|
||||
@@ -16,7 +17,7 @@ export class RankParam {
|
||||
lv: number = 0;
|
||||
|
||||
@prop({ required: true })
|
||||
vLv: number = 0;
|
||||
vLv?: number = 0;
|
||||
|
||||
@prop({ required: true })
|
||||
guildName: string = "";
|
||||
@@ -37,7 +38,7 @@ export class RankParam {
|
||||
ce: number = 0;
|
||||
|
||||
@prop({ required: true })
|
||||
updatedAt: number = 0;
|
||||
updatedAt?: number = 0;
|
||||
|
||||
constructor(role: RoleUpdate|RankParam, fromDb: boolean) {
|
||||
if(role.roleName) this.roleName = role.roleName;
|
||||
@@ -93,6 +94,8 @@ export class RoleRankInfo extends RankParam {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 公会排行榜返回值
|
||||
export class GuildRankParam {
|
||||
icon: number;
|
||||
@@ -107,8 +110,8 @@ export class GuildRankParam {
|
||||
head: number;
|
||||
frame: number;
|
||||
spine: number;
|
||||
|
||||
}
|
||||
};
|
||||
guildCe: number;
|
||||
|
||||
constructor(guild: GuildUpdateParam) {
|
||||
this.icon = guild.icon;
|
||||
@@ -117,6 +120,7 @@ export class GuildRankParam {
|
||||
let leader = <RoleType>guild.leader;
|
||||
let _leader = new GuildLeader(leader);
|
||||
this.leader = _leader;
|
||||
this.guildCe = guild.guildCe;
|
||||
this.memberCnt = guild.memberCnt;
|
||||
}
|
||||
}
|
||||
@@ -126,6 +130,7 @@ export class GuildRankInfo extends GuildRankParam {
|
||||
code: string;
|
||||
num: number;
|
||||
time: number;
|
||||
active?: number;
|
||||
|
||||
setInfo(rank: number, myId: myIdInter, num: number, time: number) {
|
||||
this.rank = rank;
|
||||
@@ -134,11 +139,53 @@ export class GuildRankInfo extends GuildRankParam {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
setInfo2(rank: number, myId: myIdInter, num: number, active: number, time: number) {
|
||||
this.rank = rank;
|
||||
this.code = myId.guildCode;
|
||||
this.num = num;
|
||||
this.time = time;
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
isMyInfo(myId: myIdInter) {
|
||||
return this.code == myId.guildCode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
export class RoleAndGuildRankInfo {
|
||||
rank: number;
|
||||
num: number;
|
||||
userInfo?: RankParam & { roleId: string };
|
||||
lineup?: LineupParam[];
|
||||
guildInfo?: GuildRankParam & { code: string };
|
||||
|
||||
constructor(rank: number, num: number) {
|
||||
this.rank = rank;
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
setUserInfo(role: RoleRankInfo) {
|
||||
this.userInfo = pick(role, ['roleId', 'roleName', 'head', 'frame', 'spine', 'lv', 'title', 'guildName', 'ce']);
|
||||
this.lineup = role.lineup;
|
||||
}
|
||||
|
||||
setGuildInfo(guild: GuildRankInfo) {
|
||||
this.guildInfo = pick(guild, ['code', 'icon', 'name', 'leader', 'guildCe', 'lv', 'memberCnt', 'active']);
|
||||
}
|
||||
|
||||
isMyInfo(myId: myIdInter) {
|
||||
if(this.userInfo && myId.roleId) {
|
||||
if(this.userInfo.roleId == myId.roleId) return true;
|
||||
}
|
||||
if(this.guildInfo && myId.guildCode) {
|
||||
if(this.guildInfo.code == myId.guildCode) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export class GuildLeader {
|
||||
roleId: string;
|
||||
roleName: string;
|
||||
@@ -275,6 +322,26 @@ export class KeyName {
|
||||
|
||||
export type KeyNameParam = Partial<KeyName>;
|
||||
|
||||
export class ValueConfig {
|
||||
isMain: boolean; // 最主要的排序,getRank的num字段,isInc的时候只有这个会用zinc
|
||||
name: string
|
||||
len: number; // 长度
|
||||
weight?: number; // 按顺序排之后,其他参数的len加和
|
||||
reverse: boolean = false; // 例如时间戳,需要倒转的那种
|
||||
isTimestamp: boolean = false; // 是否是时间戳
|
||||
|
||||
constructor(isMain: boolean, name: string, len: number, reverse = false, isTimestamp = false) {
|
||||
this.isMain = isMain;
|
||||
this.name = name;
|
||||
this.len = len;
|
||||
this.reverse = reverse;
|
||||
this.isTimestamp = isTimestamp;
|
||||
}
|
||||
|
||||
setWeight(weight: number) {
|
||||
this.weight = weight;
|
||||
}
|
||||
}
|
||||
|
||||
export interface myIdInter {
|
||||
roleId?: string;
|
||||
@@ -283,64 +350,16 @@ export interface myIdInter {
|
||||
}
|
||||
|
||||
// 排行榜总览左边的数据
|
||||
export class GeneralRankParamRole {
|
||||
export class GeneralRankParam {
|
||||
type: number; // 排行榜id
|
||||
roleId: string;
|
||||
roleName: string;
|
||||
head: number;
|
||||
frame: number;
|
||||
spine: number;
|
||||
lv: number;
|
||||
vLv: number;
|
||||
guildName: string;
|
||||
ce: number;
|
||||
userInfo: RankParam;
|
||||
num: number;
|
||||
received: number[];
|
||||
|
||||
constructor(type: number, rankInfo: RoleRankInfo, received?: number[]) {
|
||||
this.type = type;
|
||||
this.roleId = rankInfo.roleId;
|
||||
this.roleName = rankInfo.roleName;
|
||||
this.head = rankInfo.head;
|
||||
this.frame = rankInfo.frame;
|
||||
this.spine = rankInfo.spine;
|
||||
this.lv = rankInfo.lv;
|
||||
this.vLv = rankInfo.vLv;
|
||||
this.guildName = rankInfo.guildName;
|
||||
this.ce = rankInfo.ce;
|
||||
this.userInfo = pick(rankInfo, ['roleId', 'roleName', 'head', 'frame', 'spine', 'guildName', 'ce', 'title', 'lv']);
|
||||
this.num = rankInfo.num;
|
||||
this.received = received;
|
||||
}
|
||||
}
|
||||
|
||||
// 排行榜右边的数据
|
||||
export class GeneralRankParamBattle {
|
||||
type: number;
|
||||
roleId: string;
|
||||
roleName: string;
|
||||
guildName: string;
|
||||
hid: number = 0;
|
||||
skinId: number = 0;
|
||||
num: number;
|
||||
received: number[];
|
||||
head: number;
|
||||
frame: number;
|
||||
spine: number;
|
||||
|
||||
constructor(type: number, rankInfo: RoleRankInfo, hero: HeroUpdate, received?: number[]) {
|
||||
this.type = type;
|
||||
this.roleId = rankInfo.roleId;
|
||||
this.roleName = rankInfo.roleName;
|
||||
this.guildName = rankInfo.guildName;
|
||||
this.num = rankInfo.num;
|
||||
this.head = rankInfo.head;
|
||||
this.frame = rankInfo.frame;
|
||||
this.spine = rankInfo.spine;
|
||||
if(hero) {
|
||||
this.hid = hero.hid;
|
||||
let curSkin = hero.skins.find(cur => cur.enable);
|
||||
this.skinId = curSkin?curSkin.id: 0;
|
||||
}
|
||||
this.received = received;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user