Files
ZYZ/shared/domain/roleField/friend.ts
2021-03-11 19:29:50 +08:00

118 lines
3.1 KiB
TypeScript

import { RoleType } from "../../db/Role";
import { FriendShipType } from "../../db/FriendShip";
import * as friendUtil from '../../pubUtils/friendUtil'
export class FriendParams {
roleId: string;
roleName: string;
lv: number;
head: number;
frame: number;
spine: number;
ce: number;
title: number;
serverId: number;
serverName: string;
type: number;
constructor(role: RoleType) {
this.roleId = role.roleId;
this.roleName = role.roleName;
this.lv = role.lv;
this.head = role.head;
this.frame = role.frame;
this.spine = role.spine;
this.ce = role.ce;
this.title = role.title;
}
setServerName(serverId: number, serverName: string) {
this.serverId = serverId;
this.serverName = serverName;
}
setType(type: number) {
this.type = type;
}
}
export class FriendRecommendParams extends FriendParams {
friendCnt: number = 0;
recFrdApplyCnt: number = 0;
constructor(role: RoleType) {
super(role);
if(role.friendCnt) this.friendCnt = role.friendCnt;
if(role.recFrdApplyCnt) this.recFrdApplyCnt = role.recFrdApplyCnt;
}
}
export class FriendApplyParams extends FriendParams {
applyCode: string;
friendCnt: number = 0;
constructor(applyCode: string, role: RoleType) {
super(role);
this.applyCode = applyCode;
if(role.friendCnt) this.friendCnt = role.friendCnt;
}
}
export class FriendListParam extends FriendParams {
guildName: string = "";
isOnline: boolean = false;
quitTime: number = 0;
friendValue: number = 0;
friendLv: number = 1;
canReceive: boolean = false; // 初始没人送肯定不能领取
canSend: boolean = true; // 初始可以赠送
constructor(role: RoleType, myRoleId: string, friendship: FriendShipType) {
super(role);
if(role.guildName) this.guildName = role.guildName;
this.quitTime = role.quitTime;
this.friendLv = friendship.friendLv;
this.friendValue = friendship.friendValue;
friendUtil.setCanReceiveAndCanSend.bind(this, myRoleId, friendship)();
}
setOnline(isOnline: boolean) {
this.isOnline = isOnline;
}
}
export class FriendValueListParam {
roleId: string;
friendValue: number = 0;
friendLv: number = 1;
canReceive: boolean = false;
canSend: boolean = true;
constructor(roleId: string, myRoleId: string, friendship: FriendShipType) {
this.roleId = roleId;
this.friendLv = friendship.friendLv;
this.friendValue = friendship.friendValue;
friendUtil.setCanReceiveAndCanSend.bind(this, myRoleId, friendship)();
}
}
export class BlackListParam extends FriendParams {
guildName: string = "";
isOnline: boolean = false;
quitTime: number = 0;
constructor(role: RoleType) {
super(role);
if(role.guildName) this.guildName = role.guildName;
this.quitTime = role.quitTime;
}
setOnline(isOnline: boolean) {
this.isOnline = isOnline;
}
}