修改全局配置

This commit is contained in:
zhaocy 2022-07-01 16:30:29 +08:00
parent f016a11cd4
commit 47467267b5
22 changed files with 103 additions and 102 deletions

View File

@ -36,7 +36,7 @@ var (
subType: friend.FriendSubTypeApply, subType: friend.FriendSubTypeApply,
req: &pb.FriendApplyReq{}, req: &pb.FriendApplyReq{},
rsp: &pb.FriendApplyRsp{}, rsp: &pb.FriendApplyRsp{},
enabled: true, // enabled: true,
}, { }, {
//applylist //applylist
mainType: string(comm.ModuleFriend), mainType: string(comm.ModuleFriend),
@ -60,7 +60,7 @@ var (
mainType: string(comm.ModuleFriend), mainType: string(comm.ModuleFriend),
subType: friend.FriendSubTypeAddBlack, subType: friend.FriendSubTypeAddBlack,
req: &pb.FriendBlackAddReq{ req: &pb.FriendBlackAddReq{
FriendId: "0_62bd1c804cf36044f36bff33", FriendId: "0_62be9f40f67327fb53039b70",
}, },
rsp: &pb.FriendBlackAddRsp{}, rsp: &pb.FriendBlackAddRsp{},
enabled: true, enabled: true,

View File

@ -164,7 +164,7 @@ func (r *Robot) onUserLoaded() {
//hero //hero
r.RunHero() r.RunHero()
//friend //friend
// r.RunFriend() r.RunFriend()
//pack //pack
// r.RunPack() // r.RunPack()

View File

@ -17,7 +17,7 @@ var user_builders = []*builder{
NickName: "乐谷6301", NickName: "乐谷6301",
}, },
rsp: &pb.UserCreateRsp{}, rsp: &pb.UserCreateRsp{},
enabled: true, // enabled: true,
}, { }, {
desc: "添加资源", desc: "添加资源",
mainType: string(comm.ModuleUser), mainType: string(comm.ModuleUser),
@ -27,7 +27,7 @@ var user_builders = []*builder{
Count: 100, Count: 100,
}, },
rsp: &pb.UserAddResResp{}, rsp: &pb.UserAddResResp{},
enabled: true, // enabled: true,
}, },
} }

View File

@ -65,9 +65,13 @@ const (
) )
const ( const (
PropertyHp string = "hp" //生命 Hp string = "hp" //生命
PropertyAtk string = "atk" //攻击 Atk string = "atk" //攻击
PropertyDef string = "def" //防御 Def string = "def" //防御
HpPro string = "hppro" //生命附加值
AtkPro string = "atkpro" //攻击附加值
DefPro string = "defpro" //防御附加值
Speed string = "speed" //速度
) )
const ( const (

View File

@ -51,6 +51,7 @@ type (
//玩家 //玩家
IUser interface { IUser interface {
GetUser(uid string) *pb.DBUser
//查询用户属性值 例如 金币 经验 //查询用户属性值 例如 金币 经验
QueryAttributeValue(uid string, attr string) (value int32) QueryAttributeValue(uid string, attr string) (value int32)
//添加/减少属性值 //添加/减少属性值

View File

@ -5,7 +5,6 @@ import (
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/utils" "go_dreamfactory/utils"
"github.com/spf13/cast"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@ -13,16 +12,16 @@ func (this *apiComp) AddblackCheck(session comm.IUserSession, req *pb.FriendBlac
if req.FriendId == "" { if req.FriendId == "" {
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
} }
return return
} }
//加入黑名单 //加入黑名单
func (this *apiComp) Addblack(session comm.IUserSession, req *pb.FriendBlackAddReq) (code pb.ErrorCode, data proto.Message) { func (this *apiComp) Addblack(session comm.IUserSession, req *pb.FriendBlackAddReq) (code pb.ErrorCode, data proto.Message) {
var ( var (
err error err error
self *pb.DBFriend self *pb.DBFriend
rsp *pb.FriendBlackAddRsp target *pb.DBFriend
rsp *pb.FriendBlackAddRsp
) )
defer func() { defer func() {
@ -30,22 +29,17 @@ func (this *apiComp) Addblack(session comm.IUserSession, req *pb.FriendBlackAddR
FriendId: req.FriendId, FriendId: req.FriendId,
UserId: session.GetUserId(), UserId: session.GetUserId(),
} }
if err := session.SendMsg(string(this.module.GetType()), FriendSubTypeAddBlack, rsp); err != nil { session.SendMsg(string(this.module.GetType()), FriendSubTypeAddBlack, rsp)
code = pb.ErrorCode_SystemError
}
}() }()
self = &pb.DBFriend{UId: session.GetUserId()} self = this.module.modelFriend.GetFriend(session.GetUserId())
target := &pb.DBFriend{UId: req.FriendId} if self == nil {
err = this.module.modelFriend.Get(session.GetUserId(), self)
if self == nil || err != nil {
code = pb.ErrorCode_FriendSelfNoData code = pb.ErrorCode_FriendSelfNoData
return return
} }
err = this.module.modelFriend.Get(req.FriendId, target) target = this.module.modelFriend.GetFriend(req.FriendId)
if target == nil || err != nil { if target == nil {
code = pb.ErrorCode_FriendTargetNoData code = pb.ErrorCode_FriendTargetNoData
return return
} }
@ -67,13 +61,9 @@ func (this *apiComp) Addblack(session comm.IUserSession, req *pb.FriendBlackAddR
code = pb.ErrorCode_FriendTargetBlackYet code = pb.ErrorCode_FriendTargetBlackYet
return return
} }
blackNumMax := 0
if maxhy := this.module.configure.GetGlobalConf("max_hy"); maxhy != "" {
blackNumMax = cast.ToInt(maxhy)
}
// 判断是否黑名单人数已满 // 判断是否黑名单人数已满
if len(self.BlackIds) >= blackNumMax { if len(self.BlackIds) >= this.module.getBlackMax() {
code = pb.ErrorCode_FriendBlackMax code = pb.ErrorCode_FriendBlackMax
return return
} }

View File

@ -21,6 +21,7 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.FriendAgreeReq) (c
var ( var (
err error err error
self *pb.DBFriend self *pb.DBFriend
target *pb.DBFriend
rsp *pb.FriendAgreeRsp rsp *pb.FriendAgreeRsp
optNum int32 optNum int32
) )
@ -36,11 +37,9 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.FriendAgreeReq) (c
} }
}() }()
self = &pb.DBFriend{UId: session.GetUserId()}
//获取玩家自己好友数据 //获取玩家自己好友数据
err = this.module.modelFriend.Get(session.GetUserId(), self) self = this.module.modelFriend.GetFriend(session.GetUserId())
if self == nil || err != nil { if self == nil {
code = pb.ErrorCode_FriendSelfNoData code = pb.ErrorCode_FriendSelfNoData
return return
} }
@ -64,11 +63,10 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.FriendAgreeReq) (c
} }
//双向添加:将自己加入到申请人的好友列表中 //双向添加:将自己加入到申请人的好友列表中
target := &pb.DBFriend{} target = this.module.modelFriend.GetFriend(userId)
err := this.module.modelFriend.Get(userId, target) if target == nil {
if target == nil || err != nil {
code = pb.ErrorCode_FriendTargetNoData code = pb.ErrorCode_FriendTargetNoData
return
} }
if _, ok := utils.Find(target.FriendIds, self.UId); !ok { if _, ok := utils.Find(target.FriendIds, self.UId); !ok {
if target.FriendIds == nil { if target.FriendIds == nil {

View File

@ -43,18 +43,15 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.FriendApplyReq) (c
} }
}() }()
self = &pb.DBFriend{UId: session.GetUserId()}
target = &pb.DBFriend{UId: req.FriendId}
//获取玩家自己好友数据 //获取玩家自己好友数据
err = this.module.modelFriend.Get(session.GetUserId(), self) self = this.module.modelFriend.GetFriend(session.GetUserId())
if self == nil || err != nil { if self == nil || err != nil {
code = pb.ErrorCode_FriendSelfNoData code = pb.ErrorCode_FriendSelfNoData
return return
} }
//获取好友数据 //获取好友数据
err = this.module.modelFriend.Get(req.FriendId, target) target = this.module.modelFriend.GetFriend(req.FriendId)
if target == nil || err != nil { if target == nil || err != nil {
code = pb.ErrorCode_FriendTargetNoData code = pb.ErrorCode_FriendTargetNoData
return return
@ -67,17 +64,13 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.FriendApplyReq) (c
} }
//判断是否超过最大好友数量 //判断是否超过最大好友数量
//TODO 最大数从全局配置中获取 if len(self.FriendIds) >= this.module.getFriendMax() {
var max int = 50
total := len(self.FriendIds)
if total >= max {
code = pb.ErrorCode_FriendSelfMax code = pb.ErrorCode_FriendSelfMax
return return
} }
//判断对方是否也超过最大好友数量 //判断对方是否也超过最大好友数量
ttotal := len(target.FriendIds) if len(target.FriendIds) >= this.module.getFriendMax() {
if ttotal >= max {
code = pb.ErrorCode_FriendTargetMax code = pb.ErrorCode_FriendTargetMax
return return
} }

View File

@ -13,6 +13,7 @@ func (this *apiComp) ApplyListCheck(session comm.IUserSession, req *pb.FriendApp
//申请列表 //申请列表
func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.FriendApplyListReq) (code pb.ErrorCode) { func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.FriendApplyListReq) (code pb.ErrorCode) {
var ( var (
err error
self *pb.DBFriend self *pb.DBFriend
rsp *pb.FriendApplyListRsp rsp *pb.FriendApplyListRsp
list []*pb.FriendBase list []*pb.FriendBase
@ -29,8 +30,7 @@ func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.FriendApplyLis
} }
}() }()
self = &pb.DBFriend{UId: session.GetUserId()} self = this.module.modelFriend.GetFriend(session.GetUserId())
err := this.module.modelFriend.Get(session.GetUserId(), self)
if self == nil || err != nil { if self == nil || err != nil {
code = pb.ErrorCode_FriendSelfNoData code = pb.ErrorCode_FriendSelfNoData
return return

View File

@ -8,13 +8,13 @@ import (
) )
func (this *apiComp) BlacklistCheck(session comm.IUserSession, req *pb.FriendBlackListReq) (code pb.ErrorCode) { func (this *apiComp) BlacklistCheck(session comm.IUserSession, req *pb.FriendBlackListReq) (code pb.ErrorCode) {
return return
} }
//黑名单 //黑名单
func (this *apiComp) Blacklist(session comm.IUserSession, req *pb.FriendBlackListReq) (code pb.ErrorCode, data proto.Message) { func (this *apiComp) Blacklist(session comm.IUserSession, req *pb.FriendBlackListReq) (code pb.ErrorCode, data proto.Message) {
var ( var (
err error
self *pb.DBFriend self *pb.DBFriend
rsp *pb.FriendBlackListRsp rsp *pb.FriendBlackListRsp
list []*pb.FriendBase list []*pb.FriendBase
@ -32,8 +32,7 @@ func (this *apiComp) Blacklist(session comm.IUserSession, req *pb.FriendBlackLis
} }
}() }()
self = &pb.DBFriend{UId: session.GetUserId()} self = this.module.modelFriend.GetFriend(session.GetUserId())
err := this.module.modelFriend.Get(session.GetUserId(), self)
if self == nil || err != nil { if self == nil || err != nil {
code = pb.ErrorCode_FriendSelfNoData code = pb.ErrorCode_FriendSelfNoData
return return

View File

@ -18,6 +18,7 @@ func (this *apiComp) DelblackCheck(session comm.IUserSession, req *pb.FriendDelB
//删除黑名单 //删除黑名单
func (this *apiComp) Delblack(session comm.IUserSession, req *pb.FriendDelBlackReq) (code pb.ErrorCode, data proto.Message) { func (this *apiComp) Delblack(session comm.IUserSession, req *pb.FriendDelBlackReq) (code pb.ErrorCode, data proto.Message) {
var ( var (
err error
self *pb.DBFriend self *pb.DBFriend
rsp *pb.FriendDelBlackRsp rsp *pb.FriendDelBlackRsp
) )
@ -35,8 +36,7 @@ func (this *apiComp) Delblack(session comm.IUserSession, req *pb.FriendDelBlackR
} }
}() }()
self = &pb.DBFriend{UId: session.GetUserId()} self = this.module.modelFriend.GetFriend(session.GetUserId())
err := this.module.modelFriend.Get(session.GetUserId(), self)
if self == nil || err != nil { if self == nil || err != nil {
code = pb.ErrorCode_FriendSelfNoData code = pb.ErrorCode_FriendSelfNoData
return return

View File

@ -8,7 +8,6 @@ import (
) )
func (this *apiComp) ListCheck(session comm.IUserSession, req *pb.FriendListReq) (code pb.ErrorCode) { func (this *apiComp) ListCheck(session comm.IUserSession, req *pb.FriendListReq) (code pb.ErrorCode) {
return return
} }
@ -31,9 +30,8 @@ func (this *apiComp) List(session comm.IUserSession, chk map[string]interface{},
} }
}() }()
self = &pb.DBFriend{UId: session.GetUserId()} self = this.module.modelFriend.GetFriend(session.GetUserId())
err := this.module.modelFriend.Get(session.GetUserId(), self) if self == nil {
if self == nil || err != nil {
code = pb.ErrorCode_FriendSelfNoData code = pb.ErrorCode_FriendSelfNoData
return return
} }

View File

@ -37,10 +37,8 @@ func (this *apiComp) Refuse(session comm.IUserSession, req *pb.FriendRefuseReq)
} }
}() }()
self = &pb.DBFriend{UId: session.GetUserId()}
//获取玩家自己好友数据 //获取玩家自己好友数据
err = this.module.modelFriend.Get(session.GetUserId(), self) self = this.module.modelFriend.GetFriend(session.GetUserId())
if self == nil || err != nil { if self == nil || err != nil {
code = pb.ErrorCode_FriendSelfNoData code = pb.ErrorCode_FriendSelfNoData
return return

View File

@ -3,9 +3,11 @@ package friend
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
) )
func (this *apiComp) SearchCheck(session comm.IUserSession, req *pb.FriendSearchReq) (chk map[string]interface{}, code comm.ErrorCode) { func (this *apiComp) SearchCheck(session comm.IUserSession, req *pb.FriendSearchReq) (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 +16,7 @@ func (this *apiComp) SearchCheck(session comm.IUserSession, req *pb.FriendSearch
} }
//搜索 //搜索
func (this *apiComp) Search(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendSearchReq) (code pb.ErrorCode) { func (this *apiComp) Search(session comm.IUserSession, req *pb.FriendSearchReq) (code pb.ErrorCode, data proto.Message) {
var ( var (
rsp *pb.FriendSearchRsp rsp *pb.FriendSearchRsp
friend *pb.FriendBase friend *pb.FriendBase
@ -25,7 +27,9 @@ func (this *apiComp) Search(session comm.IUserSession, chk map[string]interface{
Friend: friend, Friend: friend,
} }
} }
session.SendMsg(string(this.module.GetType()), FriendSubTypeSearch, rsp) if err := session.SendMsg(string(this.module.GetType()), FriendSubTypeSearch, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
}() }()
user := this.module.modelFriend.Frined_FindCond(req.NickName) user := this.module.modelFriend.Frined_FindCond(req.NickName)

View File

@ -3,6 +3,7 @@ package friend
import ( import (
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/lego/sys/redis"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
@ -35,3 +36,16 @@ func (this *ModelFriend) Frined_FindCond(nickName string) *pb.DBUser {
} }
return user return user
} }
//查询好友
func (this *ModelFriend) GetFriend(uid string) *pb.DBFriend {
friend := &pb.DBFriend{UId: uid}
if err := this.Get(uid, friend); err != nil {
if err == redis.RedisNil {
if err := this.Add(uid, friend); err != nil {
return nil
}
}
}
return friend
}

View File

@ -5,6 +5,8 @@ import (
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"github.com/spf13/cast"
) )
func NewModule() core.IModule { func NewModule() core.IModule {
@ -34,3 +36,19 @@ func (this *Friend) OnInstallComp() {
this.api = this.RegisterComp(new(apiComp)).(*apiComp) this.api = this.RegisterComp(new(apiComp)).(*apiComp)
this.modelFriend = this.RegisterComp(new(ModelFriend)).(*ModelFriend) this.modelFriend = this.RegisterComp(new(ModelFriend)).(*ModelFriend)
} }
//获取最大好友数
func (this *Friend) getFriendMax() int {
if maxHy := this.configure.GetGlobalConf("max_hy"); maxHy != "" {
return cast.ToInt(maxHy)
}
return 0
}
//获取最大黑名单数
func (this *Friend) getBlackMax() int {
if maxHy := this.configure.GetGlobalConf("max_hmd"); maxHy != "" {
return cast.ToInt(maxHy)
}
return 0
}

View File

@ -162,9 +162,9 @@ func (this *ModelHero) mergeMainProperty(uid, heroId string, data map[string]int
return return
} }
hero.Property[comm.PropertyHp] += data[comm.PropertyHp] hero.Property[comm.Hp] += data[comm.Hp]
hero.Property[comm.PropertyAtk] += data[comm.PropertyAtk] hero.Property[comm.Atk] += data[comm.Atk]
hero.Property[comm.PropertyDef] += data[comm.PropertyDef] hero.Property[comm.Def] += data[comm.Def]
} }
//合并附加属性 //合并附加属性
@ -173,9 +173,9 @@ func (this *ModelHero) mergeAddProperty(uid, heroId string, data map[string]int3
if hero == nil { if hero == nil {
return return
} }
hero.AddProperty[comm.PropertyHp] += data[comm.PropertyHp] hero.AddProperty[comm.Hp] += data[comm.Hp]
hero.AddProperty[comm.PropertyAtk] += data[comm.PropertyAtk] hero.AddProperty[comm.Atk] += data[comm.Atk]
hero.AddProperty[comm.PropertyDef] += data[comm.PropertyDef] hero.AddProperty[comm.Def] += data[comm.Def]
} }
//属性计算 - 暂时放在modelHero里实现 //属性计算 - 暂时放在modelHero里实现
@ -216,25 +216,25 @@ func (this *ModelHero) PropertyCompute(uid, heroId string) map[string]int32 {
return nil return nil
} }
curHp := hero.Property[comm.PropertyHp] curHp := hero.Property[comm.Hp]
exprHp := fmt.Sprintf("%v + %v * %v/1000 + %v * %v", exprHp := fmt.Sprintf("%v + %v * %v/1000 + %v * %v",
(curHp + lvGrow.Hp), heroLvCfg.Hp, lvGrow.Hpgrow, heroStarCfg.Hp, stargrowCfg.StarupHp) (curHp + lvGrow.Hp), heroLvCfg.Hp, lvGrow.Hpgrow, heroStarCfg.Hp, stargrowCfg.StarupHp)
hp, _ := mengine.ParseAndExec(exprHp) hp, _ := mengine.ParseAndExec(exprHp)
curAtk := hero.Property[comm.PropertyAtk] curAtk := hero.Property[comm.Atk]
exprAtk := fmt.Sprintf("%v +%v * %v/1000 + %v * %v", exprAtk := fmt.Sprintf("%v +%v * %v/1000 + %v * %v",
(curAtk + lvGrow.Atk), heroLvCfg.Atk, lvGrow.Atkgrow, heroStarCfg.Atk, stargrowCfg.StarupAtk) (curAtk + lvGrow.Atk), heroLvCfg.Atk, lvGrow.Atkgrow, heroStarCfg.Atk, stargrowCfg.StarupAtk)
atk, _ := mengine.ParseAndExec(exprAtk) atk, _ := mengine.ParseAndExec(exprAtk)
curDef := hero.Property[comm.PropertyDef] curDef := hero.Property[comm.Def]
exprDef := fmt.Sprintf("%v +%v * %v/1000 + %v * %v", exprDef := fmt.Sprintf("%v +%v * %v/1000 + %v * %v",
(curDef + lvGrow.Def), heroLvCfg.Def, lvGrow.Defgrow, heroStarCfg.Def, stargrowCfg.StarupDef) (curDef + lvGrow.Def), heroLvCfg.Def, lvGrow.Defgrow, heroStarCfg.Def, stargrowCfg.StarupDef)
def, _ := mengine.ParseAndExec(exprDef) def, _ := mengine.ParseAndExec(exprDef)
return map[string]int32{ return map[string]int32{
comm.PropertyHp: int32(math.Floor(hp)), comm.Hp: int32(math.Floor(hp)),
comm.PropertyAtk: int32(math.Floor(atk)), comm.Atk: int32(math.Floor(atk)),
comm.PropertyDef: int32(math.Floor(def)), comm.Def: int32(math.Floor(def)),
} }
} }

View File

@ -24,7 +24,7 @@ func (this *apiComp) AddRes(session comm.IUserSession, req *pb.UserAddResReq) (c
} }
}() }()
user := this.module.modelUser.getUser(session.GetUserId()) user := this.module.modelUser.GetUser(session.GetUserId())
if user == nil { if user == nil {
code = pb.ErrorCode_UserSessionNobeing code = pb.ErrorCode_UserSessionNobeing
return return

View File

@ -1,16 +0,0 @@
package user
import (
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
)
type configureComp struct {
modules.MCompConfigure
}
//组件初始化接口
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.ModuleCompBase.Init(service, module, comp, options)
return
}

View File

@ -44,11 +44,11 @@ func (this *ModelUser) User_Create(user *pb.DBUser) (err error) {
user.Uid = fmt.Sprintf("%d_%s", user.Sid, _id) user.Uid = fmt.Sprintf("%d_%s", user.Sid, _id)
user.Uuid = uuid.NewV4().String() user.Uuid = uuid.NewV4().String()
user.Ctime = time.Now().Unix() user.Ctime = time.Now().Unix()
return this.Add(user.Uid,user) return this.Add(user.Uid, user)
} }
//获取用户 //获取用户
func (this *ModelUser) getUser(uid string) *pb.DBUser { func (this *ModelUser) GetUser(uid string) *pb.DBUser {
dbUser := &pb.DBUser{} dbUser := &pb.DBUser{}
if err := this.Get(uid, dbUser); err != nil { if err := this.Get(uid, dbUser); err != nil {
log.Errorf("getUser err:%v", err) log.Errorf("getUser err:%v", err)

View File

@ -18,7 +18,7 @@ type User struct {
api *apiComp api *apiComp
modelUser *ModelUser modelUser *ModelUser
modelSession *ModelSession modelSession *ModelSession
configure *configureComp configure *modules.MCompConfigure
} }
func (this *User) GetType() core.M_Modules { func (this *User) GetType() core.M_Modules {
@ -36,17 +36,17 @@ func (this *User) OnInstallComp() {
this.api = this.RegisterComp(new(apiComp)).(*apiComp) this.api = this.RegisterComp(new(apiComp)).(*apiComp)
this.modelUser = this.RegisterComp(new(ModelUser)).(*ModelUser) this.modelUser = this.RegisterComp(new(ModelUser)).(*ModelUser)
this.modelSession = this.RegisterComp(new(ModelSession)).(*ModelSession) this.modelSession = this.RegisterComp(new(ModelSession)).(*ModelSession)
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
} }
//获取英雄列表 //获取英雄列表
func (this *User) GetHeroList(uid string) []*pb.DBHero { func (this *User) GetUser(uid string) *pb.DBUser {
return nil return this.modelUser.GetUser(uid)
} }
//查询用户属性值 例如 金币 经验 //查询用户属性值 例如 金币 经验
func (this *User) QueryAttributeValue(uid string, attr string) (value int32) { func (this *User) QueryAttributeValue(uid string, attr string) (value int32) {
user := this.modelUser.getUser(uid) user := this.modelUser.GetUser(uid)
if user == nil { if user == nil {
return return
} }

View File

@ -2,10 +2,10 @@ package web
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/modules"
"go_dreamfactory/modules/user" "go_dreamfactory/modules/user"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase"
) )
/* /*
@ -19,7 +19,7 @@ func NewModule() core.IModule {
} }
type Web struct { type Web struct {
modules.ModuleBase cbase.ModuleBase
options *Options options *Options
api_comp *Api_Comp //提供weba pi服务的组件 api_comp *Api_Comp //提供weba pi服务的组件
modelUser *user.ModelUser modelUser *user.ModelUser