This commit is contained in:
meixiongfeng 2022-06-28 15:26:28 +08:00
commit f2cf68f173
17 changed files with 61 additions and 56 deletions

View File

@ -38,7 +38,7 @@ type (
//消耗卡片 //消耗卡片
ChangeCard(uId string, heroCfgId int32, count int32) (code pb.ErrorCode) ChangeCard(uId string, heroCfgId int32, count int32) (code pb.ErrorCode)
//创建新英雄 //创建新英雄
CreatHero(uid string, heroCfgId ...int32) error CreateHero(uid string, heroCfgId ...int32) error
// 获取英雄 // 获取英雄
// heroId 英雄ID // heroId 英雄ID

View File

@ -17,12 +17,12 @@ const (
Friend_SubType_Search = "search" Friend_SubType_Search = "search"
) )
type ApiComp struct { type apiComp struct {
modules.MComp_GateComp modules.MComp_GateComp
module *Friend module *Friend
} }
func (this *ApiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.MComp_GateComp.Init(service, module, comp, options) this.MComp_GateComp.Init(service, module, comp, options)
this.module = module.(*Friend) this.module = module.(*Friend)
return return

View File

@ -6,7 +6,7 @@ import (
"go_dreamfactory/utils" "go_dreamfactory/utils"
) )
func (this *ApiComp) Addblack_Check(session comm.IUserSession, req *pb.Friend_BlackAdd_Req) (chk map[string]interface{}, code comm.ErrorCode) { func (this *apiComp) Addblack_Check(session comm.IUserSession, req *pb.Friend_BlackAdd_Req) (chk map[string]interface{}, code comm.ErrorCode) {
chk = make(map[string]interface{}) chk = make(map[string]interface{})
var ( var (
err error err error
@ -15,13 +15,13 @@ func (this *ApiComp) Addblack_Check(session comm.IUserSession, req *pb.Friend_Bl
self := &pb.DB_FriendData{UId: session.GetUserId()} self := &pb.DB_FriendData{UId: session.GetUserId()}
target := &pb.DB_FriendData{UId: req.FriendId} target := &pb.DB_FriendData{UId: req.FriendId}
err = this.module.model_friend.Get(session.GetUserId(), self) err = this.module.modelFriend.Get(session.GetUserId(), self)
if self == nil || err != nil { if self == nil || err != nil {
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData} code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData}
return return
} }
err = this.module.model_friend.Get(req.FriendId, target) err = this.module.modelFriend.Get(req.FriendId, target)
if target == nil || err != nil { if target == nil || err != nil {
code = comm.ErrorCode{Code: pb.ErrorCode_FriendTargetNoData} code = comm.ErrorCode{Code: pb.ErrorCode_FriendTargetNoData}
return return
@ -58,7 +58,7 @@ func (this *ApiComp) Addblack_Check(session comm.IUserSession, req *pb.Friend_Bl
} }
//加入黑名单 //加入黑名单
func (this *ApiComp) Addblack(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_BlackAdd_Req) (code pb.ErrorCode) { func (this *apiComp) Addblack(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_BlackAdd_Req) (code pb.ErrorCode) {
var ( var (
self *pb.DB_FriendData self *pb.DB_FriendData
rsp *pb.Friend_BlackAdd_Rsp rsp *pb.Friend_BlackAdd_Rsp
@ -78,7 +78,7 @@ func (this *ApiComp) Addblack(session comm.IUserSession, chk map[string]interfac
self.BlackIds = append(self.BlackIds, req.FriendId) self.BlackIds = append(self.BlackIds, req.FriendId)
//更新黑名单 //更新黑名单
err := this.module.model_friend.Change(self.UId, map[string]interface{}{ err := this.module.modelFriend.Change(self.UId, map[string]interface{}{
"blackIds": self.BlackIds, "blackIds": self.BlackIds,
}) })
if err != nil { if err != nil {

View File

@ -6,13 +6,13 @@ import (
"go_dreamfactory/utils" "go_dreamfactory/utils"
) )
func (this *ApiComp) Agree_Check(session comm.IUserSession, req *pb.Friend_Agree_Req) (chk map[string]interface{}, code comm.ErrorCode) { func (this *apiComp) Agree_Check(session comm.IUserSession, req *pb.Friend_Agree_Req) (chk map[string]interface{}, code comm.ErrorCode) {
chk = make(map[string]interface{}) chk = make(map[string]interface{})
var err error var err error
self := &pb.DB_FriendData{UId: session.GetUserId()} self := &pb.DB_FriendData{UId: session.GetUserId()}
//获取玩家自己好友数据 //获取玩家自己好友数据
err = this.module.model_friend.Get(session.GetUserId(), self) err = this.module.modelFriend.Get(session.GetUserId(), self)
if self == nil || err != nil { if self == nil || err != nil {
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData} code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData}
return return
@ -34,7 +34,7 @@ func (this *ApiComp) Agree_Check(session comm.IUserSession, req *pb.Friend_Agree
} }
//单个/批量同意 //单个/批量同意
func (this *ApiComp) Agree(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_Agree_Req) (code pb.ErrorCode) { func (this *apiComp) Agree(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_Agree_Req) (code pb.ErrorCode) {
var ( var (
self *pb.DB_FriendData self *pb.DB_FriendData
rsp *pb.Friend_Agree_Rsp rsp *pb.Friend_Agree_Rsp
@ -71,7 +71,7 @@ func (this *ApiComp) Agree(session comm.IUserSession, chk map[string]interface{}
//双向添加:将自己加入到申请人的好友列表中 //双向添加:将自己加入到申请人的好友列表中
target := &pb.DB_FriendData{} target := &pb.DB_FriendData{}
err := this.module.model_friend.Get(userId, target) err := this.module.modelFriend.Get(userId, target)
if target == nil || err != nil { if target == nil || err != nil {
code = pb.ErrorCode_FriendTargetNoData code = pb.ErrorCode_FriendTargetNoData
@ -82,7 +82,7 @@ func (this *ApiComp) Agree(session comm.IUserSession, chk map[string]interface{}
} }
target.FriendIds = append(target.FriendIds, self.UId) target.FriendIds = append(target.FriendIds, self.UId)
} }
err = this.module.model_friend.Change(target.UId, map[string]interface{}{ err = this.module.modelFriend.Change(target.UId, map[string]interface{}{
"friendIds": target.FriendIds, "friendIds": target.FriendIds,
}) })
if err != nil { if err != nil {
@ -95,7 +95,7 @@ func (this *ApiComp) Agree(session comm.IUserSession, chk map[string]interface{}
} }
//更新 //更新
err := this.module.model_friend.Change(self.UId, map[string]interface{}{ err := this.module.modelFriend.Change(self.UId, map[string]interface{}{
"applyIds": self.ApplyIds, "applyIds": self.ApplyIds,
"friendIds": self.FriendIds, "friendIds": self.FriendIds,
}) })

View File

@ -7,21 +7,21 @@ import (
"go_dreamfactory/utils" "go_dreamfactory/utils"
) )
func (this *ApiComp) Apply_Check(session comm.IUserSession, req *pb.Friend_Apply_Req) (chk map[string]interface{}, code comm.ErrorCode) { func (this *apiComp) Apply_Check(session comm.IUserSession, req *pb.Friend_Apply_Req) (chk map[string]interface{}, code comm.ErrorCode) {
chk = make(map[string]interface{}) chk = make(map[string]interface{})
var err error var err error
self := &pb.DB_FriendData{UId: session.GetUserId()} self := &pb.DB_FriendData{UId: session.GetUserId()}
target := &pb.DB_FriendData{UId: req.FriendId} target := &pb.DB_FriendData{UId: req.FriendId}
//获取玩家自己好友数据 //获取玩家自己好友数据
err = this.module.model_friend.Get(session.GetUserId(), self) err = this.module.modelFriend.Get(session.GetUserId(), self)
if self == nil || err != nil { if self == nil || err != nil {
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData} code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData}
return return
} }
//获取好友数据 //获取好友数据
err = this.module.model_friend.Get(req.FriendId, target) err = this.module.modelFriend.Get(req.FriendId, target)
if target == nil || err != nil { if target == nil || err != nil {
code = comm.ErrorCode{Code: pb.ErrorCode_FriendTargetNoData} code = comm.ErrorCode{Code: pb.ErrorCode_FriendTargetNoData}
return return
@ -79,7 +79,7 @@ func (this *ApiComp) Apply_Check(session comm.IUserSession, req *pb.Friend_Apply
} }
//好友申请 //好友申请
func (this *ApiComp) Apply(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_Apply_Req) (code pb.ErrorCode) { func (this *apiComp) Apply(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_Apply_Req) (code pb.ErrorCode) {
var ( var (
target *pb.DB_FriendData target *pb.DB_FriendData
rsp *pb.Friend_Apply_Rsp rsp *pb.Friend_Apply_Rsp
@ -116,7 +116,7 @@ func (this *ApiComp) Apply(session comm.IUserSession, chk map[string]interface{}
} }
target.ApplyIds = append(target.ApplyIds, session.GetUserId()) target.ApplyIds = append(target.ApplyIds, session.GetUserId())
err := this.module.model_friend.Change(req.FriendId, map[string]interface{}{ err := this.module.modelFriend.Change(req.FriendId, map[string]interface{}{
"applyIds": target.ApplyIds, "applyIds": target.ApplyIds,
}) })
if err != nil { if err != nil {

View File

@ -5,10 +5,10 @@ import (
"go_dreamfactory/pb" "go_dreamfactory/pb"
) )
func (this *ApiComp) ApplyList_Check(session comm.IUserSession, req *pb.Friend_ApplyList_Req) (chk map[string]interface{}, code comm.ErrorCode) { func (this *apiComp) ApplyList_Check(session comm.IUserSession, req *pb.Friend_ApplyList_Req) (chk map[string]interface{}, code comm.ErrorCode) {
chk = make(map[string]interface{}) chk = make(map[string]interface{})
self := &pb.DB_FriendData{UId: session.GetUserId()} self := &pb.DB_FriendData{UId: session.GetUserId()}
err := this.module.model_friend.Get(session.GetUserId(), self) err := this.module.modelFriend.Get(session.GetUserId(), self)
if self == nil || err != nil { if self == nil || err != nil {
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData} code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData}
return return
@ -18,7 +18,7 @@ func (this *ApiComp) ApplyList_Check(session comm.IUserSession, req *pb.Friend_A
} }
//申请列表 //申请列表
func (this *ApiComp) ApplyList(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_ApplyList_Req) (code pb.ErrorCode) { func (this *apiComp) ApplyList(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_ApplyList_Req) (code pb.ErrorCode) {
var ( var (
self *pb.DB_FriendData self *pb.DB_FriendData
rsp *pb.Friend_ApplyList_Rsp rsp *pb.Friend_ApplyList_Rsp

View File

@ -5,10 +5,10 @@ import (
"go_dreamfactory/pb" "go_dreamfactory/pb"
) )
func (this *ApiComp) Blacklist_Check(session comm.IUserSession, req *pb.Friend_BlackList_Req) (chk map[string]interface{}, code comm.ErrorCode) { func (this *apiComp) Blacklist_Check(session comm.IUserSession, req *pb.Friend_BlackList_Req) (chk map[string]interface{}, code comm.ErrorCode) {
chk = make(map[string]interface{}) chk = make(map[string]interface{})
self := &pb.DB_FriendData{UId: session.GetUserId()} self := &pb.DB_FriendData{UId: session.GetUserId()}
err := this.module.model_friend.Get(session.GetUserId(), self) err := this.module.modelFriend.Get(session.GetUserId(), self)
if self == nil || err != nil { if self == nil || err != nil {
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData} code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData}
return return
@ -18,7 +18,7 @@ func (this *ApiComp) Blacklist_Check(session comm.IUserSession, req *pb.Friend_B
} }
//黑名单 //黑名单
func (this *ApiComp) Blacklist(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_BlackList_Req) (code pb.ErrorCode) { func (this *apiComp) Blacklist(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_BlackList_Req) (code pb.ErrorCode) {
var ( var (
self *pb.DB_FriendData self *pb.DB_FriendData
rsp *pb.Friend_BlackList_Rsp rsp *pb.Friend_BlackList_Rsp

View File

@ -5,11 +5,11 @@ import (
"go_dreamfactory/pb" "go_dreamfactory/pb"
) )
func (this *ApiComp) Del_Check(session comm.IUserSession, req *pb.Friend_Del_Req) (chk map[string]interface{}, code comm.ErrorCode) { func (this *apiComp) Del_Check(session comm.IUserSession, req *pb.Friend_Del_Req) (chk map[string]interface{}, code comm.ErrorCode) {
return return
} }
//删除好友 //删除好友
func (this *ApiComp) Del(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_Del_Req) error { func (this *apiComp) Del(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_Del_Req) error {
return nil return nil
} }

View File

@ -6,10 +6,10 @@ import (
"go_dreamfactory/utils" "go_dreamfactory/utils"
) )
func (this *ApiComp) Delblack_Check(session comm.IUserSession, req *pb.Friend_DelBlack_Req) (chk map[string]interface{}, code comm.ErrorCode) { func (this *apiComp) Delblack_Check(session comm.IUserSession, req *pb.Friend_DelBlack_Req) (chk map[string]interface{}, code comm.ErrorCode) {
chk = make(map[string]interface{}) chk = make(map[string]interface{})
self := &pb.DB_FriendData{UId: session.GetUserId()} self := &pb.DB_FriendData{UId: session.GetUserId()}
err := this.module.model_friend.Get(session.GetUserId(), self) err := this.module.modelFriend.Get(session.GetUserId(), self)
if self == nil || err != nil { if self == nil || err != nil {
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData} code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData}
return return
@ -19,7 +19,7 @@ func (this *ApiComp) Delblack_Check(session comm.IUserSession, req *pb.Friend_De
} }
//删除黑名单 //删除黑名单
func (this *ApiComp) Delblack(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_DelBlack_Req) (code pb.ErrorCode) { func (this *apiComp) Delblack(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_DelBlack_Req) (code pb.ErrorCode) {
var ( var (
self *pb.DB_FriendData self *pb.DB_FriendData
rsp *pb.Friend_DelBlack_Rsp rsp *pb.Friend_DelBlack_Rsp
@ -43,7 +43,7 @@ func (this *ApiComp) Delblack(session comm.IUserSession, chk map[string]interfac
//从黑名单列表中删除目标 //从黑名单列表中删除目标
self.BlackIds = utils.DeleteString(self.BlackIds, req.FriendId) self.BlackIds = utils.DeleteString(self.BlackIds, req.FriendId)
//更新黑名单 //更新黑名单
err := this.module.model_friend.Change(self.UId, map[string]interface{}{ err := this.module.modelFriend.Change(self.UId, map[string]interface{}{
"blackIds": self.BlackIds, "blackIds": self.BlackIds,
}) })
if err != nil { if err != nil {

View File

@ -5,10 +5,10 @@ import (
"go_dreamfactory/pb" "go_dreamfactory/pb"
) )
func (this *ApiComp) List_Check(session comm.IUserSession, req *pb.Friend_List_Req) (chk map[string]interface{}, code comm.ErrorCode) { func (this *apiComp) List_Check(session comm.IUserSession, req *pb.Friend_List_Req) (chk map[string]interface{}, code comm.ErrorCode) {
chk = make(map[string]interface{}) chk = make(map[string]interface{})
self := &pb.DB_FriendData{UId: session.GetUserId()} self := &pb.DB_FriendData{UId: session.GetUserId()}
err := this.module.model_friend.Get(session.GetUserId(), self) err := this.module.modelFriend.Get(session.GetUserId(), self)
if self == nil || err != nil { if self == nil || err != nil {
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData} code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData}
return return
@ -18,7 +18,7 @@ func (this *ApiComp) List_Check(session comm.IUserSession, req *pb.Friend_List_R
} }
//好友列表 //好友列表
func (this *ApiComp) List(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_List_Req) (code pb.ErrorCode) { func (this *apiComp) List(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_List_Req) (code pb.ErrorCode) {
var ( var (
self *pb.DB_FriendData self *pb.DB_FriendData
rsp *pb.Friend_List_Rsp rsp *pb.Friend_List_Rsp

View File

@ -6,13 +6,13 @@ import (
"go_dreamfactory/utils" "go_dreamfactory/utils"
) )
func (this *ApiComp) Refuse_Check(session comm.IUserSession, req *pb.Friend_Refuse_Req) (chk map[string]interface{}, code comm.ErrorCode) { func (this *apiComp) Refuse_Check(session comm.IUserSession, req *pb.Friend_Refuse_Req) (chk map[string]interface{}, code comm.ErrorCode) {
chk = make(map[string]interface{}) chk = make(map[string]interface{})
var err error var err error
self := &pb.DB_FriendData{UId: session.GetUserId()} self := &pb.DB_FriendData{UId: session.GetUserId()}
//获取玩家自己好友数据 //获取玩家自己好友数据
err = this.module.model_friend.Get(session.GetUserId(), self) err = this.module.modelFriend.Get(session.GetUserId(), self)
if self == nil || err != nil { if self == nil || err != nil {
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData} code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData}
return return
@ -33,7 +33,7 @@ func (this *ApiComp) Refuse_Check(session comm.IUserSession, req *pb.Friend_Refu
} }
//单个/批量拒绝 //单个/批量拒绝
func (this *ApiComp) Refuse(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_Refuse_Req) (code pb.ErrorCode) { func (this *apiComp) Refuse(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_Refuse_Req) (code pb.ErrorCode) {
//将申请人从申请列表中删除 //将申请人从申请列表中删除
var ( var (
self *pb.DB_FriendData self *pb.DB_FriendData
@ -66,7 +66,7 @@ func (this *ApiComp) Refuse(session comm.IUserSession, chk map[string]interface{
} }
//更新 //更新
if optNum > 0 { if optNum > 0 {
err := this.module.model_friend.Change(self.UId, map[string]interface{}{ err := this.module.modelFriend.Change(self.UId, map[string]interface{}{
"applyIds": self.ApplyIds, "applyIds": self.ApplyIds,
}) })
if err != nil { if err != nil {

View File

@ -5,7 +5,7 @@ import (
"go_dreamfactory/pb" "go_dreamfactory/pb"
) )
func (this *ApiComp) Search_Check(session comm.IUserSession, req *pb.Friend_Search_Req) (chk map[string]interface{}, code comm.ErrorCode) { func (this *apiComp) Search_Check(session comm.IUserSession, req *pb.Friend_Search_Req) (chk map[string]interface{}, code comm.ErrorCode) {
if req.NickName == "" { if req.NickName == "" {
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSearchNameEmpty} code = comm.ErrorCode{Code: pb.ErrorCode_FriendSearchNameEmpty}
return return
@ -14,7 +14,7 @@ func (this *ApiComp) Search_Check(session comm.IUserSession, req *pb.Friend_Sear
} }
//搜索 //搜索
func (this *ApiComp) Search(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_Search_Req) (code pb.ErrorCode) { func (this *apiComp) Search(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_Search_Req) (code pb.ErrorCode) {
var ( var (
rsp *pb.Friend_Search_Rsp rsp *pb.Friend_Search_Rsp
friend *pb.FriendBase friend *pb.FriendBase
@ -28,7 +28,7 @@ func (this *ApiComp) Search(session comm.IUserSession, chk map[string]interface{
session.SendMsg(string(this.module.GetType()), Friend_SubType_Search, rsp) session.SendMsg(string(this.module.GetType()), Friend_SubType_Search, rsp)
}() }()
user := this.module.model_friend.Frined_FindCond(req.NickName) user := this.module.modelFriend.Frined_FindCond(req.NickName)
if user != nil { if user != nil {
friend = &pb.FriendBase{ friend = &pb.FriendBase{
UserId: user.Uid, UserId: user.Uid,

View File

@ -10,8 +10,8 @@ import (
) )
const ( const (
DB_FriendTable core.SqlTable = "friend" TableFriend core.SqlTable = "friend"
DB_UserTable core.SqlTable = "user" //用户表 TableUser core.SqlTable = "user" //用户表
) )
type ModelFriend struct { type ModelFriend struct {
@ -20,13 +20,13 @@ type ModelFriend struct {
func (this *ModelFriend) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { func (this *ModelFriend) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.Model_Comp.Init(service, module, comp, options) err = this.Model_Comp.Init(service, module, comp, options)
this.TableName = "friend" this.TableName = string(TableFriend)
return return
} }
func (this *ModelFriend) Frined_FindCond(nickName string) *pb.DB_UserData { func (this *ModelFriend) Frined_FindCond(nickName string) *pb.DB_UserData {
var user *pb.DB_UserData var user *pb.DB_UserData
err := this.DB.FindOne(DB_UserTable, bson.M{ err := this.DB.FindOne(TableUser, bson.M{
"name": nickName, "name": nickName,
}).Decode(&user) }).Decode(&user)
if err != nil { if err != nil {

View File

@ -14,8 +14,8 @@ func NewModule() core.IModule {
type Friend struct { type Friend struct {
modules.ModuleBase modules.ModuleBase
friend_comp *ApiComp api *apiComp
model_friend *ModelFriend modelFriend *ModelFriend
} }
func (this *Friend) GetType() core.M_Modules { func (this *Friend) GetType() core.M_Modules {
@ -30,6 +30,6 @@ func (this *Friend) Init(service core.IService, module core.IModule, options cor
func (this *Friend) OnInstallComp() { func (this *Friend) OnInstallComp() {
this.ModuleBase.OnInstallComp() this.ModuleBase.OnInstallComp()
this.friend_comp = this.RegisterComp(new(ApiComp)).(*ApiComp) this.api = this.RegisterComp(new(apiComp)).(*apiComp)
this.model_friend = this.RegisterComp(new(ModelFriend)).(*ModelFriend) this.modelFriend = this.RegisterComp(new(ModelFriend)).(*ModelFriend)
} }

View File

@ -62,14 +62,19 @@ func (this *ModelHero) createOneHero(uid string, heroCfgId int32) error {
//创建多个指定的英雄 heroCfgIds可填入多个英雄ID //创建多个指定的英雄 heroCfgIds可填入多个英雄ID
func (this *ModelHero) createMultiHero(uid string, heroCfgIds ...int32) error { func (this *ModelHero) createMultiHero(uid string, heroCfgIds ...int32) error {
data := make(map[string]interface{}) // data := make(map[string]interface{})
for _, v := range heroCfgIds { for _, v := range heroCfgIds {
hero := this.initHero(uid, v) if err := this.createOneHero(uid, v); err != nil {
if hero != nil { return err
data[hero.Id] = hero
} }
// hero := this.initHero(uid, v)
// if hero != nil {
// data[hero.Id] = hero
// }
} }
return this.moduleHero.modelHero.AddLists(uid, data)
return nil
// return this.moduleHero.model_hero.AddLists(uid, data)
} }
//获取一个英雄 //获取一个英雄

View File

@ -40,7 +40,7 @@ func (this *Hero) OnInstallComp() {
} }
//创建新英雄 //创建新英雄
func (this *Hero) CreatHero(uid string, heroCfgId ...int32) error { func (this *Hero) CreateHero(uid string, heroCfgId ...int32) error {
return this.modelHero.createMultiHero(uid, heroCfgId...) return this.modelHero.createMultiHero(uid, heroCfgId...)
} }

View File

@ -41,7 +41,7 @@ func (this *apiComp) Create(session comm.IUserSession, result map[string]interfa
//初始化英雄卡 //初始化英雄卡
defaultHero := []int32{15001, 25001} //TODO 从配置中读取 defaultHero := []int32{15001, 25001} //TODO 从配置中读取
err = this.hero.CreatHero(session.GetUserId(), defaultHero...) err = this.hero.CreateHero(session.GetUserId(), defaultHero...)
if err != nil { if err != nil {
code = pb.ErrorCode_HeroInitCreat code = pb.ErrorCode_HeroInitCreat
return return