1
This commit is contained in:
parent
254aa958b1
commit
347f9e4458
@ -51,38 +51,14 @@ type PlayerMgr interface {
|
||||
ProcessCMMsg(*cs.CsNetMsgHandler, *f5.MsgHdr)
|
||||
GetPlayerBySocket(f5.WspCliConn) Player
|
||||
GetPlayerByAccountId(string) Player
|
||||
GetOnlineStatus(string) int32
|
||||
OnSocketClose(f5.WspCliConn)
|
||||
GetPlayers() map[string]Player
|
||||
UnBindSocket(f5.WspCliConn)
|
||||
BindSocket(f5.WspCliConn, Player)
|
||||
}
|
||||
|
||||
type Friendship interface {
|
||||
IsFriendship() int32
|
||||
FriendAccountId() string
|
||||
}
|
||||
|
||||
type FriendBlackList interface {
|
||||
GetAccountId() string
|
||||
IsRemoved() int32
|
||||
}
|
||||
|
||||
type User interface {
|
||||
GetFriendships() map[string]Friendship
|
||||
GetFriendBlackList() map[string]FriendBlackList
|
||||
}
|
||||
|
||||
type FriendMgr interface {
|
||||
GetFriendByAccountId(account1Id, account2Id string) User
|
||||
AddUser(string, User)
|
||||
GetUser(string) User
|
||||
LoadUserFriendships(user User, where [][]string)
|
||||
}
|
||||
|
||||
type Guild interface {
|
||||
GetGuildId() int64
|
||||
GetMembers() map[string]GuildMember
|
||||
}
|
||||
|
||||
type GuildMember interface {
|
||||
@ -91,8 +67,6 @@ type GuildMember interface {
|
||||
|
||||
type GuildMgr interface {
|
||||
GetGuildByAccountId(string) Guild
|
||||
GetGuildIdByAccountId(string) int64
|
||||
RandomGuilds() []*Guild
|
||||
}
|
||||
|
||||
type CacheMgr interface {
|
||||
|
@ -1,92 +0,0 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"main/constant"
|
||||
"main/common"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
AccountId string
|
||||
FriendBlackList map[string]*FriendBlackList // BlockedAccountId -> FriendBlackList
|
||||
Friendships map[string]*Friendship // FriendAccountId -> Friendship
|
||||
}
|
||||
|
||||
type Friendship struct {
|
||||
FriendAccountId string // friend's account id
|
||||
IsFriendship int32 // 0 pending, 1 ok, 2 reject, 3 disband
|
||||
RequestTime int64 // send time
|
||||
}
|
||||
|
||||
// FriendBlackList 直接存列表, 黑名单上限50个
|
||||
type FriendBlackList struct {
|
||||
AccountId string
|
||||
IsRemoved int32 // default: 0, isRemoved
|
||||
}
|
||||
|
||||
func NewUser(accountId string) *User {
|
||||
user := &User{
|
||||
AccountId: accountId,
|
||||
//FriendRequest: make(map[string]*FriendRequest),
|
||||
FriendBlackList: make(map[string]*FriendBlackList),
|
||||
Friendships: make(map[string]*Friendship, constant.MaxFriendMembers),
|
||||
}
|
||||
return user
|
||||
}
|
||||
|
||||
func (u *User) GetFriendships() map[string]common.Friendship {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *User) GetFriendBlackList() map[string]common.FriendBlackList {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *User) AddFriendRequest(account2Id string, IsFriendship int32, requestTime int64) {
|
||||
friendShip := &Friendship{
|
||||
FriendAccountId: account2Id,
|
||||
IsFriendship: IsFriendship,
|
||||
RequestTime: requestTime,
|
||||
}
|
||||
u.Friendships[account2Id] = friendShip
|
||||
}
|
||||
|
||||
func (u *User) RemoveFriendRequest(account2Id string) {
|
||||
delete(u.Friendships, account2Id)
|
||||
}
|
||||
|
||||
func (u *User) RemoveFriendShip(account2Id string) {
|
||||
delete(u.Friendships, account2Id)
|
||||
}
|
||||
|
||||
func (u *User) IsInReq(FriendAccountId string) bool {
|
||||
friendRequest, exists := u.Friendships[FriendAccountId]
|
||||
return exists && friendRequest.IsFriendship == 0
|
||||
}
|
||||
|
||||
// AddBlacklist 加入黑名单
|
||||
func (u *User) AddBlacklist(b *FriendBlackList) {
|
||||
u.FriendBlackList[b.AccountId] = b
|
||||
}
|
||||
|
||||
// GetBlacklist 获取黑名单
|
||||
func (u *User) GetBlacklist(account2Id string) *FriendBlackList {
|
||||
if friendBlackList, exists := u.FriendBlackList[account2Id]; exists {
|
||||
return friendBlackList
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsInBlacklist 在黑名单中
|
||||
func (u *User) IsInBlacklist(account2Id string) bool {
|
||||
friendBlackList, exists := u.FriendBlackList[account2Id]
|
||||
return exists && friendBlackList.IsRemoved == 0
|
||||
}
|
||||
|
||||
func (u *User) RemoveBlacklist(account2Id string) {
|
||||
delete(u.FriendBlackList, account2Id)
|
||||
}
|
||||
|
||||
// GetBlacklistCount 获取黑名单
|
||||
func (u *User) GetBlacklistCount() int {
|
||||
return len(u.FriendBlackList)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user