1
This commit is contained in:
parent
00db6f45fc
commit
2e6e26cb30
@ -88,7 +88,7 @@ type GuildMgr interface {
|
|||||||
GetGuildByGuildName(string) Guild
|
GetGuildByGuildName(string) Guild
|
||||||
GetRecommendGuilds(string) []Guild
|
GetRecommendGuilds(string) []Guild
|
||||||
GetGuildRank() []Guild
|
GetGuildRank() []Guild
|
||||||
AsyncCreateGuild(string, int32, string, func(int32, string, string))
|
AsyncCreateGuild(string, string, int32, string, func(int32, string, string))
|
||||||
AsyncGetApplyList(int64, string, func(int32, string, int64, []string))
|
AsyncGetApplyList(int64, string, func(int32, string, int64, []string))
|
||||||
AsyncApplyJoin(string, string, func(int32, string))
|
AsyncApplyJoin(string, string, func(int32, string))
|
||||||
AsyncAcceptApply(string, string, func(int32, string))
|
AsyncAcceptApply(string, string, func(int32, string))
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"main/common"
|
"main/common"
|
||||||
"main/constant"
|
"main/constant"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"mt"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -247,7 +248,7 @@ func (this *guildMgr) asyncCreateGuildTask(task *f5.AsyncTask,
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *guildMgr) AsyncCreateGuild(accountId string, avatar int32, name string,
|
func (this *guildMgr) AsyncCreateGuild(accountId string, sessionId string, avatar int32, name string,
|
||||||
cb func(int32, string, string)) {
|
cb func(int32, string, string)) {
|
||||||
guildId := q5.ToString(f5.GetApp().NewNodeUuid())
|
guildId := q5.ToString(f5.GetApp().NewNodeUuid())
|
||||||
f5.NewLockAsyncTask([][]string{
|
f5.NewLockAsyncTask([][]string{
|
||||||
@ -257,22 +258,45 @@ func (this *guildMgr) AsyncCreateGuild(accountId string, avatar int32, name stri
|
|||||||
},
|
},
|
||||||
func (task *f5.LockAsyncTask) {
|
func (task *f5.LockAsyncTask) {
|
||||||
if len(name) <= 0 {
|
if len(name) <= 0 {
|
||||||
|
task.SetFail()
|
||||||
cb(1, "Name cantnot be empty", "")
|
cb(1, "Name cantnot be empty", "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if this.isNameTooLong(name) {
|
if this.isNameTooLong(name) {
|
||||||
|
task.SetFail()
|
||||||
cb(2, "Name is to long", "")
|
cb(2, "Name is to long", "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if this.GetGuildByAccountId(accountId) != nil {
|
if this.GetGuildByAccountId(accountId) != nil {
|
||||||
|
task.SetFail()
|
||||||
cb(3, "You already have a cube", "")
|
cb(3, "You already have a cube", "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if this.GetGuildByGuildName(name) != nil {
|
if this.GetGuildByGuildName(name) != nil {
|
||||||
|
task.SetFail()
|
||||||
cb(4, "Cube name already exists", "")
|
cb(4, "Cube name already exists", "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.asyncCreateGuildTask(task, guildId, accountId, avatar, name, cb)
|
params := map[string]string{
|
||||||
|
"c": "Bag",
|
||||||
|
"a": "createGuildConsume",
|
||||||
|
"account_id": accountId,
|
||||||
|
"session_id": sessionId,
|
||||||
|
}
|
||||||
|
url := fmt.Sprintf("%s/webapp/index.php", mt.Table.Config.GetById(0).GetGameapiUrl())
|
||||||
|
rspObj := new(common.HeadRsp)
|
||||||
|
f5.GetHttpCliMgr().SendJsStyleJsonRspRequest(
|
||||||
|
url,
|
||||||
|
params,
|
||||||
|
&rspObj,
|
||||||
|
func(rsp f5.HttpCliResponse) {
|
||||||
|
if rspObj.Errcode != 0 {
|
||||||
|
task.SetFail()
|
||||||
|
cb(4, "item not enough", "")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.asyncCreateGuildTask(task, guildId, accountId, avatar, name, cb)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,8 +4,6 @@ import (
|
|||||||
"cs"
|
"cs"
|
||||||
"q5"
|
"q5"
|
||||||
"f5"
|
"f5"
|
||||||
"fmt"
|
|
||||||
"mt"
|
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
"main/common"
|
"main/common"
|
||||||
"main/constant"
|
"main/constant"
|
||||||
@ -385,6 +383,7 @@ func (this *player) CMCreateGuild(hdr *f5.MsgHdr, msg *cs.CMCreateGuild) {
|
|||||||
rspMsg := new(cs.SMCreateGuild)
|
rspMsg := new(cs.SMCreateGuild)
|
||||||
GetGuildMgr().AsyncCreateGuild(
|
GetGuildMgr().AsyncCreateGuild(
|
||||||
this.GetAccountId(),
|
this.GetAccountId(),
|
||||||
|
this.GetSessionId(),
|
||||||
msg.GetAvatar(),
|
msg.GetAvatar(),
|
||||||
msg.GetName(),
|
msg.GetName(),
|
||||||
func (errCode int32, errMsg string, guildId string) {
|
func (errCode int32, errMsg string, guildId string) {
|
||||||
@ -409,36 +408,6 @@ func (this *player) CMCreateGuild(hdr *f5.MsgHdr, msg *cs.CMCreateGuild) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
f5.NewLockAsyncTask(
|
|
||||||
[][]string{
|
|
||||||
{constant.GUILD_NAME_LOCK_KEY, msg.GetName()},
|
|
||||||
{constant.GUILD_MEMBER_LOCK_KEY, this.GetAccountId()},
|
|
||||||
},
|
|
||||||
func (task *f5.LockAsyncTask) {
|
|
||||||
if GetGuildMgr().GetGuildByAccountId(this.GetAccountId()) != nil {
|
|
||||||
this.SendMsg(rspMsg.Err(3, "You already have a cube"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if GetGuildMgr().GetGuildByGuildName(msg.GetName()) != nil {
|
|
||||||
this.SendMsg(rspMsg.Err(4, "Cube name already exists"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
params := map[string]string{
|
|
||||||
"c": "Bag",
|
|
||||||
"a": "createGuildConsume",
|
|
||||||
"account_id": this.GetAccountId(),
|
|
||||||
"session_id": this.GetSessionId(),
|
|
||||||
}
|
|
||||||
url := fmt.Sprintf("%s/webapp/index.php", mt.Table.Config.GetById(0).GetGameapiUrl())
|
|
||||||
rspObj := new(common.HeadRsp)
|
|
||||||
f5.GetHttpCliMgr().SendJsStyleJsonRspRequest(
|
|
||||||
url,
|
|
||||||
params,
|
|
||||||
&rspObj,
|
|
||||||
func(rsp f5.HttpCliResponse) {
|
|
||||||
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *player) CMApplyToGuild(hdr *f5.MsgHdr, msg *cs.CMApplyToGuild) {
|
func (this *player) CMApplyToGuild(hdr *f5.MsgHdr, msg *cs.CMApplyToGuild) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user