Add star
This commit is contained in:
parent
299ab00b5c
commit
c8db883ac3
@ -26,8 +26,9 @@ func (cm *CacheMgr) loadUserProfile(sql string) {
|
||||
Username: q5.ToString(*rows.GetByIndex(1)),
|
||||
Avatar: q5.ToInt32(*rows.GetByIndex(2)),
|
||||
AvatarHead: q5.ToInt32(*rows.GetByIndex(3)),
|
||||
Rank: q5.ToInt32(*rows.GetByIndex(4)),
|
||||
LastLoginTime: q5.ToInt32(*rows.GetByIndex(5)),
|
||||
Star: q5.ToInt32(*rows.GetByIndex(4)),
|
||||
Rank: q5.ToInt32(*rows.GetByIndex(5)),
|
||||
LastLoginTime: q5.ToInt32(*rows.GetByIndex(6)),
|
||||
OnlineStatus: onlineStatue,
|
||||
}
|
||||
cacheMgr.SetProfile(accountId, profile)
|
||||
|
@ -10,6 +10,7 @@ type PlayerProfile struct {
|
||||
Username string // 用户名
|
||||
Avatar int32 // 头像
|
||||
AvatarHead int32 // 头像框
|
||||
Star int32 // 星星
|
||||
Rank int32 // 排位赛段位
|
||||
OnlineStatus int32 // 在线状态
|
||||
LastLoginTime int32 // 上次登录时间
|
||||
|
@ -108,20 +108,22 @@ const (
|
||||
ERR_CODE_SEARCH_NO_RESULT = 11016
|
||||
|
||||
// Guild
|
||||
ERR_CODE_GUILD_NO_EXISTS = 10001
|
||||
ERR_CODE_JOINED_GUILD = 10001
|
||||
ERR_CODE_CREATE_GUILD_FAIL = 10002
|
||||
ERR_CODE_GUILD_MEMBER_NO_EXISTS = 10001
|
||||
ERR_CODE_GUILD_MEMBER_FULL = 10001
|
||||
ERR_CODE_GUILD_PENDING_REQUEST_NO_EXISTS = 10002
|
||||
ERR_CODE_GUILD_NO_LEADER_PERM = 10002
|
||||
ERR_CODE_GUILD_BLOCKED_LEADER = 10002
|
||||
ERR_CODE_GUILD_OPERATOR_MEMBER_NO_PERM = 10002
|
||||
ERR_CODE_GUILD_DISMISS_MEMBER_NO_PERM = 10002
|
||||
ERR_CODE_GUILD_DEMOTE_MEMBER_OK = 10002
|
||||
ERR_CODE_CREATE_GUILD_DB_FAIL = 10002
|
||||
ERR_CODE_CREATE_GUILD_MEMBER_DB_FAIL = 10002
|
||||
ERR_CODE_UPDATE_GUILD_DB_FAIL = 10002
|
||||
ERR_CODE_UPDATE_GUILD_MEMBER_DB_FAIL = 10002
|
||||
ERR_CODE_UPDATE_GUILD_PENDING_REQUEST_DB_FAIL = 10002
|
||||
ERR_CODE_GUILD_NO_EXISTS = 12001
|
||||
ERR_CODE_JOINED_GUILD = 12002
|
||||
ERR_CODE_CREATE_GUILD_FAIL = 12003
|
||||
ERR_CODE_APPLY_GUILD_FAIL = 12004
|
||||
ERR_CODE_GUILD_MEMBER_NO_EXISTS = 12005
|
||||
ERR_CODE_GUILD_MEMBER_FULL = 12006
|
||||
ERR_CODE_GUILD_PENDING_REQUEST_NO_EXISTS = 12007
|
||||
ERR_CODE_GUILD_NO_LEADER_PERM = 12008
|
||||
ERR_CODE_GUILD_BLOCKED_LEADER = 12009
|
||||
ERR_CODE_GUILD_OPERATOR_MEMBER_NO_PERM = 12010
|
||||
ERR_CODE_GUILD_DISMISS_MEMBER_NO_PERM = 12011
|
||||
ERR_CODE_GUILD_DEMOTE_MEMBER_OK = 12012
|
||||
ERR_CODE_CREATE_GUILD_DB_FAIL = 12013
|
||||
ERR_CODE_CREATE_GUILD_MEMBER_DB_FAIL = 12014
|
||||
ERR_CODE_UPDATE_GUILD_DB_FAIL = 12015
|
||||
ERR_CODE_UPDATE_GUILD_MEMBER_DB_FAIL = 12016
|
||||
ERR_CODE_UPDATE_GUILD_PENDING_REQUEST_DB_FAIL = 12017
|
||||
ERR_CODE_REQUEST_PARAMS_ERROR = 12018
|
||||
)
|
||||
|
@ -71,6 +71,7 @@ type MsgHandler interface {
|
||||
CMSetName(*f5.MsgHdr, *CMSetName)
|
||||
CMSetAvatar(*f5.MsgHdr, *CMSetAvatar)
|
||||
CMSetNotice(*f5.MsgHdr, *CMSetNotice)
|
||||
CMSetJoinCond(*f5.MsgHdr, *CMSetJoinCond)
|
||||
}
|
||||
|
||||
func (this *MsgHandlerImpl) CMPing(hdr *f5.MsgHdr, msg *CMPing) {
|
||||
@ -181,6 +182,9 @@ func (this *MsgHandlerImpl) CMSetAvatar(hdr *f5.MsgHdr, msg *CMSetAvatar) {
|
||||
func (this *MsgHandlerImpl) CMSetNotice(hdr *f5.MsgHdr, msg *CMSetNotice) {
|
||||
}
|
||||
|
||||
func (this *MsgHandlerImpl) CMSetJoinCond(hdr *f5.MsgHdr, msg *CMSetJoinCond) {
|
||||
}
|
||||
|
||||
func (this *CMPing) GetNetMsgId() uint16 {
|
||||
return uint16(CMMessageIdE__CMPing)
|
||||
}
|
||||
@ -477,6 +481,14 @@ func (this *SMSetNotice) GetNetMsgId() uint16 {
|
||||
return uint16(SMMessageIdE__SMSetNotice)
|
||||
}
|
||||
|
||||
func (this *CMSetJoinCond) GetNetMsgId() uint16 {
|
||||
return uint16(CMMessageIdE__CMSetJoinCond)
|
||||
}
|
||||
|
||||
func (this *SMSetJoinCond) GetNetMsgId() uint16 {
|
||||
return uint16(SMMessageIdE__SMSetJoinCond)
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
handlers[int(CMMessageIdE__CMPing)] = &CsNetMsgHandler{
|
||||
@ -911,4 +923,16 @@ func init() {
|
||||
},
|
||||
}
|
||||
|
||||
handlers[int(CMMessageIdE__CMSetJoinCond)] = &CsNetMsgHandler{
|
||||
MsgId: int(CMMessageIdE__CMSetJoinCond),
|
||||
ParseCb: func (data []byte) interface{} {
|
||||
msg := &CMSetJoinCond{}
|
||||
proto.Unmarshal(data, msg)
|
||||
return msg
|
||||
},
|
||||
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
|
||||
handler.CMSetJoinCond(hdr, hdr.Msg.(*CMSetJoinCond))
|
||||
},
|
||||
}
|
||||
|
||||
}
|
@ -83,7 +83,7 @@ func (fm *FriendsMgr) upsertBlacklist(account1Id string, account2Id string, isRe
|
||||
}
|
||||
|
||||
func (fm *FriendsMgr) findPlayer(accountId string, cb func(err error, profile *PlayerProfile)) {
|
||||
fields := []string{"account_id", "name", "head_id", "head_frame", "rank", "last_login_time"}
|
||||
fields := []string{"account_id", "name", "head_id", "head_frame", "star_num", "rank", "last_login_time"}
|
||||
where := [][]string{
|
||||
{"account_id", accountId},
|
||||
}
|
||||
@ -109,8 +109,9 @@ func (fm *FriendsMgr) findPlayer(accountId string, cb func(err error, profile *P
|
||||
Username: q5.ToString(*rows.GetByIndex(1)),
|
||||
Avatar: q5.ToInt32(*rows.GetByIndex(2)),
|
||||
AvatarHead: q5.ToInt32(*rows.GetByIndex(3)),
|
||||
Rank: q5.ToInt32(*rows.GetByIndex(4)),
|
||||
LastLoginTime: q5.ToInt32(*rows.GetByIndex(5)),
|
||||
Star: q5.ToInt32(*rows.GetByIndex(4)),
|
||||
Rank: q5.ToInt32(*rows.GetByIndex(5)),
|
||||
LastLoginTime: q5.ToInt32(*rows.GetByIndex(6)),
|
||||
OnlineStatus: onlineStatue,
|
||||
}
|
||||
cb(nil, profile)
|
||||
@ -121,7 +122,7 @@ func (fm *FriendsMgr) findPlayer(accountId string, cb func(err error, profile *P
|
||||
}
|
||||
|
||||
func (fm *FriendsMgr) findUsersByUsername(username string, sinceId int64, cb func(err error, lastId int64, profiles []*PlayerProfile)) {
|
||||
fields := []string{"idx", "account_id", "name", "head_id", "head_frame", "rank", "last_login_time"}
|
||||
fields := []string{"idx", "account_id", "name", "head_id", "head_frame", "star_num", "rank", "last_login_time"}
|
||||
var where [][]string
|
||||
usernameLike := fmt.Sprintf("%%%s%%", username)
|
||||
likeWhere := [][]string{
|
||||
@ -158,8 +159,9 @@ func (fm *FriendsMgr) findUsersByUsername(username string, sinceId int64, cb fun
|
||||
Username: q5.ToString(*rows.GetByIndex(2)),
|
||||
Avatar: q5.ToInt32(*rows.GetByIndex(3)),
|
||||
AvatarHead: q5.ToInt32(*rows.GetByIndex(4)),
|
||||
Rank: q5.ToInt32(*rows.GetByIndex(5)),
|
||||
LastLoginTime: q5.ToInt32(*rows.GetByIndex(6)),
|
||||
Star: q5.ToInt32(*rows.GetByIndex(5)),
|
||||
Rank: q5.ToInt32(*rows.GetByIndex(6)),
|
||||
LastLoginTime: q5.ToInt32(*rows.GetByIndex(7)),
|
||||
OnlineStatus: onlineStatue,
|
||||
}
|
||||
profiles = append(profiles, profile)
|
||||
@ -276,7 +278,7 @@ func (fm *FriendsMgr) loadUserFriendships(user *User, where [][]string) {
|
||||
}
|
||||
|
||||
func (fm *FriendsMgr) loadUserProfile() {
|
||||
sql := "SELECT account_id, name, head_id, head_frame, rank, last_login_time FROM ( SELECT account1_id AS account_id, name, head_id, head_frame, rank, last_login_time FROM frienddb_dev_1.t_friend_ships AS fs JOIN gamedb2006_dev_1.t_user AS u ON fs.account1_id = u.account_id UNION SELECT account2_id AS account_id, name, head_id, head_frame, rank, last_login_time FROM frienddb_dev_1.t_friend_ships AS fs JOIN gamedb2006_dev_1.t_user AS u ON fs.account2_id = u.account_id) AS friend_info_table;"
|
||||
sql := "SELECT account_id, name, head_id, head_frame, star_num, rank, last_login_time FROM ( SELECT account1_id AS account_id, name, head_id, head_frame, star_num, rank, last_login_time FROM frienddb_dev_1.t_friend_ships AS fs JOIN gamedb2006_dev_1.t_user AS u ON fs.account1_id = u.account_id UNION SELECT account2_id AS account_id, name, head_id, head_frame, star_num, rank, last_login_time FROM frienddb_dev_1.t_friend_ships AS fs JOIN gamedb2006_dev_1.t_user AS u ON fs.account2_id = u.account_id) AS friend_info_table;"
|
||||
cacheMgr.loadUserProfile(sql)
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
|
||||
// loadGuildFromDB 加载公会成员信息
|
||||
func (gm *GuildMgr) loadUserProfile() {
|
||||
sql := "select a.account_id, a.name, a.head_id, a.head_frame, a.`rank`, a.last_login_time from gamedb2006_dev_1.t_user a,frienddb_dev_1.t_guild_members b where a.account_id = b.account_id"
|
||||
sql := "select a.account_id, a.name, a.head_id, a.head_frame, a.star_num, a.`rank`, a.last_login_time from gamedb2006_dev_1.t_user a,frienddb_dev_1.t_guild_members b where a.account_id = b.account_id"
|
||||
cacheMgr.loadUserProfile(sql)
|
||||
}
|
||||
|
||||
|
@ -162,12 +162,18 @@ func (gm *GuildMgr) ApplyToGuild(guildId int64, applicantAccountId string, cb fu
|
||||
}
|
||||
|
||||
if guild.JoinCond == JoinCondStar {
|
||||
var userStar int32 = 200
|
||||
if userStar >= guild.JoinCondValue {
|
||||
gm.JoinGuild(guild, applicantAccountId)
|
||||
cb(ERR_CODE_OK, "ApplyToGuild OK")
|
||||
profile := cacheMgr.GetPlayerProfile(applicantAccountId)
|
||||
if profile == nil {
|
||||
cb(ERR_CODE_GUILD_MEMBER_NO_EXISTS, "applicantAccountId no exists")
|
||||
return
|
||||
}
|
||||
if profile.Star < guild.JoinCondValue {
|
||||
cb(ERR_CODE_APPLY_GUILD_FAIL, "ApplyToGuild Fail, user star error")
|
||||
return
|
||||
}
|
||||
gm.JoinGuild(guild, applicantAccountId)
|
||||
cb(ERR_CODE_OK, "ApplyToGuild OK")
|
||||
return
|
||||
}
|
||||
|
||||
// IF exists, then replace it fields `isJoinGuild` is 0
|
||||
@ -736,7 +742,8 @@ func (gm *GuildMgr) CheckGuildAndPermission(operatorAccountId string) (*Guild, b
|
||||
|
||||
func (gm *GuildMgr) SetAvatar(operatorAccountId string, avatar int32, cb func(errCode int32, errMsg string)) {
|
||||
guild, ok := gm.CheckGuildAndPermission(operatorAccountId)
|
||||
if !ok {
|
||||
if !ok || guild.Avatar == avatar {
|
||||
cb(ERR_CODE_REQUEST_PARAMS_ERROR, "params is null")
|
||||
return
|
||||
}
|
||||
|
||||
@ -748,32 +755,19 @@ func (gm *GuildMgr) SetAvatar(operatorAccountId string, avatar int32, cb func(er
|
||||
cb(ERR_CODE_UPDATE_GUILD_DB_FAIL, err.Error())
|
||||
return
|
||||
}
|
||||
beforeAvatar := guild.Avatar
|
||||
guild.Avatar = avatar
|
||||
|
||||
// Add event
|
||||
prop := make(map[string]string)
|
||||
prop["guild_id"] = q5.ToString(guild.GuildId)
|
||||
prop["before_avatar"] = q5.ToString(beforeAvatar)
|
||||
prop["after_avatar"] = q5.ToString(avatar)
|
||||
prop["members_count"] = q5.ToString(guild.GetMembersCount())
|
||||
f5.GetTgLog().AddTrackLog(
|
||||
GAME_ID,
|
||||
operatorAccountId,
|
||||
"127.0.0.1",
|
||||
EVENT_SET_NOTICE,
|
||||
prop,
|
||||
)
|
||||
|
||||
cb(ERR_CODE_OK, "SetNotice OK")
|
||||
})
|
||||
}
|
||||
|
||||
func (gm *GuildMgr) SetName(operatorAccountId string, name *string, cb func(errCode int32, errMsg string)) {
|
||||
guild, ok := gm.CheckGuildAndPermission(operatorAccountId)
|
||||
if !ok {
|
||||
if !ok || name == nil || guild.Name == *name {
|
||||
cb(ERR_CODE_REQUEST_PARAMS_ERROR, "params is null")
|
||||
return
|
||||
}
|
||||
|
||||
updateFields := [][]string{
|
||||
{"name", *name},
|
||||
}
|
||||
@ -782,23 +776,8 @@ func (gm *GuildMgr) SetName(operatorAccountId string, name *string, cb func(errC
|
||||
cb(ERR_CODE_UPDATE_GUILD_DB_FAIL, err.Error())
|
||||
return
|
||||
}
|
||||
beforeName := &guild.Name
|
||||
guild.Name = *name
|
||||
|
||||
// Add event
|
||||
prop := make(map[string]string)
|
||||
prop["guild_id"] = q5.ToString(guild.GuildId)
|
||||
prop["before_name"] = *beforeName
|
||||
prop["after_name"] = *name
|
||||
prop["members_count"] = q5.ToString(guild.GetMembersCount())
|
||||
f5.GetTgLog().AddTrackLog(
|
||||
GAME_ID,
|
||||
operatorAccountId,
|
||||
"127.0.0.1",
|
||||
EVENT_SET_NOTICE,
|
||||
prop,
|
||||
)
|
||||
|
||||
cb(ERR_CODE_OK, "SetNotice OK")
|
||||
})
|
||||
}
|
||||
@ -806,9 +785,11 @@ func (gm *GuildMgr) SetName(operatorAccountId string, name *string, cb func(errC
|
||||
// SetNotice 设置公告
|
||||
func (gm *GuildMgr) SetNotice(operatorAccountId string, notice *string, cb func(errCode int32, errMsg string)) {
|
||||
guild, ok := gm.CheckGuildAndPermission(operatorAccountId)
|
||||
if !ok {
|
||||
if !ok || notice == nil || guild.Notice == *notice {
|
||||
cb(ERR_CODE_REQUEST_PARAMS_ERROR, "params is null")
|
||||
return
|
||||
}
|
||||
|
||||
updateFields := [][]string{
|
||||
{"notice", *notice},
|
||||
}
|
||||
@ -817,23 +798,7 @@ func (gm *GuildMgr) SetNotice(operatorAccountId string, notice *string, cb func(
|
||||
cb(ERR_CODE_UPDATE_GUILD_DB_FAIL, err.Error())
|
||||
return
|
||||
}
|
||||
beforeNotice := &guild.Notice
|
||||
guild.SetNotice(notice)
|
||||
|
||||
// Add event
|
||||
prop := make(map[string]string)
|
||||
prop["guild_id"] = q5.ToString(guild.GuildId)
|
||||
prop["before_notice"] = *beforeNotice
|
||||
prop["after_notice"] = *notice
|
||||
prop["members_count"] = q5.ToString(guild.GetMembersCount())
|
||||
f5.GetTgLog().AddTrackLog(
|
||||
GAME_ID,
|
||||
operatorAccountId,
|
||||
"127.0.0.1",
|
||||
EVENT_SET_NOTICE,
|
||||
prop,
|
||||
)
|
||||
|
||||
guild.Notice = *notice
|
||||
cb(ERR_CODE_OK, "SetNotice OK")
|
||||
})
|
||||
}
|
||||
@ -842,12 +807,23 @@ func (gm *GuildMgr) SetNotice(operatorAccountId string, notice *string, cb func(
|
||||
func (gm *GuildMgr) SetJoinCond(operatorAccountId string, joinCond, joinCondValue int32, cb func(errCode int32, errMsg string)) {
|
||||
guild, ok := gm.CheckGuildAndPermission(operatorAccountId)
|
||||
if !ok {
|
||||
cb(ERR_CODE_REQUEST_PARAMS_ERROR, "params is null")
|
||||
return
|
||||
}
|
||||
|
||||
updateFields := [][]string{
|
||||
{"join_cond", q5.ToString(joinCond)},
|
||||
{"join_cond_value", q5.ToString(joinCondValue)},
|
||||
{"join_cond_value", q5.ToString(0)},
|
||||
}
|
||||
if joinCond == JoinCondStar {
|
||||
updateFields = [][]string{
|
||||
{"join_cond", q5.ToString(joinCond)},
|
||||
{"join_cond_value", q5.ToString(joinCondValue)},
|
||||
}
|
||||
} else {
|
||||
joinCondValue = 0
|
||||
}
|
||||
|
||||
gm.updateGuild(guild, updateFields, func(err error) {
|
||||
if err != nil {
|
||||
cb(ERR_CODE_UPDATE_GUILD_DB_FAIL, err.Error())
|
||||
|
@ -39,8 +39,10 @@ func (this *HandlerMgr) init() {
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMDisband), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSearchGuilds), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMGuildMembersList), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSetNotice), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSetName), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSetAvatar), PLAYER_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSetJoinCond), PLAYER_HANDLER_ID)
|
||||
}
|
||||
|
||||
func (this *HandlerMgr) unInit() {
|
||||
|
@ -418,6 +418,7 @@ func (p *Player) CMApplyList(hdr *f5.MsgHdr, msg *cs.CMApplyList) {
|
||||
Username: &profile.Username,
|
||||
Avatar: &profile.Avatar,
|
||||
AvatarHead: &profile.AvatarHead,
|
||||
Star: &profile.Star,
|
||||
Rank: &profile.Rank,
|
||||
OnlineStatus: &profile.OnlineStatus,
|
||||
LastLoginTime: &profile.LastLoginTime,
|
||||
@ -684,6 +685,7 @@ func (p *Player) FillMFGuildMember(member *GuildMember) *cs.MFGuildMember {
|
||||
Username: &profile.Username,
|
||||
Avatar: &profile.Avatar,
|
||||
AvatarHead: &profile.AvatarHead,
|
||||
Star: &profile.Star,
|
||||
Rank: &profile.Rank,
|
||||
OnlineStatus: &profile.OnlineStatus,
|
||||
LastLoginTime: &profile.LastLoginTime,
|
||||
|
@ -98,6 +98,7 @@ func (this *PlayerMgr) CMLoginResult(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.Htt
|
||||
Name string `json:"name"`
|
||||
Avatar string `json:"head_id"`
|
||||
AvatarHead string `json:"head_frame"`
|
||||
Star string `json:"current_star_num"`
|
||||
Rank string `json:"rank"`
|
||||
LastLoginTime string `json:"last_login_time"`
|
||||
} `json:"info"`
|
||||
@ -127,6 +128,7 @@ func (this *PlayerMgr) CMLoginResult(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.Htt
|
||||
Username: resObj.Info.Name,
|
||||
Avatar: q5.ToInt32(resObj.Info.Avatar),
|
||||
AvatarHead: q5.ToInt32(resObj.Info.AvatarHead),
|
||||
Star: q5.ToInt32(resObj.Info.Star),
|
||||
Rank: q5.ToInt32(resObj.Info.Rank),
|
||||
OnlineStatus: OnlineStatus,
|
||||
LastLoginTime: q5.ToInt32(resObj.Info.LastLoginTime),
|
||||
|
@ -603,7 +603,7 @@ message SMSetNotice
|
||||
// 请求设置公会加入条件
|
||||
message CMSetJoinCond
|
||||
{
|
||||
optional int32 join_cond = 1; // default: 0, free:1, star: 2
|
||||
optional int32 join_cond = 1; // default: 0 Approval required , free:1, star: 2
|
||||
optional int32 join_cond_value = 2; // only cond star, value:
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user