Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
47ea034812
@ -15,7 +15,7 @@ var (
|
|||||||
subType: friend.FriendSubTypeList,
|
subType: friend.FriendSubTypeList,
|
||||||
req: &pb.FriendListReq{},
|
req: &pb.FriendListReq{},
|
||||||
rsp: &pb.FriendListRsp{},
|
rsp: &pb.FriendListRsp{},
|
||||||
enabled: true,
|
// enabled: true,
|
||||||
}, {
|
}, {
|
||||||
//blacklist
|
//blacklist
|
||||||
mainType: string(comm.ModuleFriend),
|
mainType: string(comm.ModuleFriend),
|
||||||
@ -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,9 +60,10 @@ var (
|
|||||||
mainType: string(comm.ModuleFriend),
|
mainType: string(comm.ModuleFriend),
|
||||||
subType: friend.FriendSubTypeAddBlack,
|
subType: friend.FriendSubTypeAddBlack,
|
||||||
req: &pb.FriendBlackAddReq{
|
req: &pb.FriendBlackAddReq{
|
||||||
FriendId: "",
|
FriendId: "0_62be9f40f67327fb53039b70",
|
||||||
},
|
},
|
||||||
rsp: &pb.FriendBlackAddRsp{},
|
rsp: &pb.FriendBlackAddRsp{},
|
||||||
|
enabled: true,
|
||||||
}, {
|
}, {
|
||||||
//delblack
|
//delblack
|
||||||
mainType: string(comm.ModuleFriend),
|
mainType: string(comm.ModuleFriend),
|
||||||
|
@ -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()
|
||||||
|
@ -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,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,9 +66,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 (
|
||||||
|
@ -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)
|
||||||
//添加/减少属性值
|
//添加/减少属性值
|
||||||
|
@ -3,7 +3,7 @@ package dbservice
|
|||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/lego/core/cbase"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewModule() core.IModule {
|
func NewModule() core.IModule {
|
||||||
@ -12,7 +12,7 @@ func NewModule() core.IModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DBService struct {
|
type DBService struct {
|
||||||
modules.ModuleBase
|
cbase.ModuleBase
|
||||||
db_comp *DB_Comp
|
db_comp *DB_Comp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,63 +4,23 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (this *apiComp) AddblackCheck(session comm.IUserSession, req *pb.FriendBlackAddReq) (chk map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) AddblackCheck(session comm.IUserSession, req *pb.FriendBlackAddReq) (code pb.ErrorCode) {
|
||||||
chk = make(map[string]interface{})
|
if req.FriendId == "" {
|
||||||
var (
|
code = pb.ErrorCode_ReqParameterError
|
||||||
err error
|
|
||||||
blackNumMax = 50 //TODO 从配置中读取
|
|
||||||
)
|
|
||||||
self := &pb.DBFriend{UId: session.GetUserId()}
|
|
||||||
target := &pb.DBFriend{UId: req.FriendId}
|
|
||||||
|
|
||||||
err = this.module.modelFriend.Get(session.GetUserId(), self)
|
|
||||||
if self == nil || err != nil {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = this.module.modelFriend.Get(req.FriendId, target)
|
|
||||||
if target == nil || err != nil {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_FriendTargetNoData}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//判断目标是否在好友列表里面
|
|
||||||
if _, ok := utils.Find(self.FriendIds, req.FriendId); ok {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_FriendYet}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//判断目标是否已经在黑名单中
|
|
||||||
if _, ok := utils.Find(self.BlackIds, req.FriendId); ok {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfBlackYet}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 判断自己是否在对方的黑名单中
|
|
||||||
if _, ok := utils.Find(target.BlackIds, self.UId); ok {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_FriendTargetBlackYet}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 判断是否黑名单人数已满
|
|
||||||
if len(self.BlackIds) >= blackNumMax {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_FriendBlackMax}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
chk["self"] = self
|
|
||||||
chk["target"] = target
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//加入黑名单
|
//加入黑名单
|
||||||
func (this *apiComp) Addblack(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendBlackAddReq) (code pb.ErrorCode) {
|
func (this *apiComp) Addblack(session comm.IUserSession, req *pb.FriendBlackAddReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
var (
|
var (
|
||||||
|
err error
|
||||||
self *pb.DBFriend
|
self *pb.DBFriend
|
||||||
|
target *pb.DBFriend
|
||||||
rsp *pb.FriendBlackAddRsp
|
rsp *pb.FriendBlackAddRsp
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -72,20 +32,53 @@ func (this *apiComp) Addblack(session comm.IUserSession, chk map[string]interfac
|
|||||||
session.SendMsg(string(this.module.GetType()), FriendSubTypeAddBlack, rsp)
|
session.SendMsg(string(this.module.GetType()), FriendSubTypeAddBlack, rsp)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if v, ok := chk["self"]; ok {
|
self = this.module.modelFriend.GetFriend(session.GetUserId())
|
||||||
self = v.(*pb.DBFriend)
|
if self == nil {
|
||||||
|
code = pb.ErrorCode_FriendSelfNoData
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
target = this.module.modelFriend.GetFriend(req.FriendId)
|
||||||
|
if target == nil {
|
||||||
|
code = pb.ErrorCode_FriendTargetNoData
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断目标是否在好友列表里面
|
||||||
|
if _, ok := utils.Find(self.FriendIds, req.FriendId); ok {
|
||||||
|
code = pb.ErrorCode_FriendYet
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断目标是否已经在黑名单中
|
||||||
|
if _, ok := utils.Find(self.BlackIds, req.FriendId); ok {
|
||||||
|
code = pb.ErrorCode_FriendSelfBlackYet
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断自己是否在对方的黑名单中
|
||||||
|
if _, ok := utils.Find(target.BlackIds, self.UId); ok {
|
||||||
|
code = pb.ErrorCode_FriendTargetBlackYet
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断是否黑名单人数已满
|
||||||
|
if len(self.BlackIds) >= this.module.getBlackMax() {
|
||||||
|
code = pb.ErrorCode_FriendBlackMax
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
//将目标加入黑名单
|
//将目标加入黑名单
|
||||||
self.BlackIds = append(self.BlackIds, req.FriendId)
|
self.BlackIds = append(self.BlackIds, req.FriendId)
|
||||||
|
|
||||||
//更新黑名单
|
//更新黑名单
|
||||||
err := this.module.modelFriend.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 {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -4,39 +4,24 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (this *apiComp) AgreeCheck(session comm.IUserSession, req *pb.FriendAgreeReq) (chk map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) AgreeCheck(session comm.IUserSession, req *pb.FriendAgreeReq) (code pb.ErrorCode) {
|
||||||
chk = make(map[string]interface{})
|
if len(req.FriendIds) == 0 {
|
||||||
var err error
|
code = pb.ErrorCode_ReqParameterError
|
||||||
self := &pb.DBFriend{UId: session.GetUserId()}
|
|
||||||
|
|
||||||
//获取玩家自己好友数据
|
|
||||||
err = this.module.modelFriend.Get(session.GetUserId(), self)
|
|
||||||
if self == nil || err != nil {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//同意的好友
|
|
||||||
agreeIds := []string{}
|
|
||||||
for _, friendId := range req.FriendIds {
|
|
||||||
if _, ok := utils.Find(self.FriendIds, friendId); !ok {
|
|
||||||
//不在好友列表中就加入
|
|
||||||
agreeIds = append(agreeIds, friendId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
chk["agreeIds"] = agreeIds
|
|
||||||
chk["self"] = self
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//单个/批量同意
|
//单个/批量同意
|
||||||
func (this *apiComp) Agree(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendAgreeReq) (code pb.ErrorCode) {
|
func (this *apiComp) Agree(session comm.IUserSession, req *pb.FriendAgreeReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
var (
|
var (
|
||||||
|
err error
|
||||||
self *pb.DBFriend
|
self *pb.DBFriend
|
||||||
|
target *pb.DBFriend
|
||||||
rsp *pb.FriendAgreeRsp
|
rsp *pb.FriendAgreeRsp
|
||||||
optNum int32
|
optNum int32
|
||||||
)
|
)
|
||||||
@ -52,16 +37,24 @@ func (this *apiComp) Agree(session comm.IUserSession, chk map[string]interface{}
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if v, ok := chk["self"]; !ok {
|
//获取玩家自己好友数据
|
||||||
code = pb.ErrorCode_FriendTargetNoData
|
self = this.module.modelFriend.GetFriend(session.GetUserId())
|
||||||
|
if self == nil {
|
||||||
|
code = pb.ErrorCode_FriendSelfNoData
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
self = v.(*pb.DBFriend)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if agreeIds, ok := chk["agreeIds"]; ok {
|
//同意的好友
|
||||||
|
agreeIds := []string{}
|
||||||
|
for _, friendId := range req.FriendIds {
|
||||||
|
if _, ok := utils.Find(self.FriendIds, friendId); !ok {
|
||||||
|
//不在好友列表中就加入
|
||||||
|
agreeIds = append(agreeIds, friendId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//将目标加入到自己的好友列表中
|
//将目标加入到自己的好友列表中
|
||||||
for _, userId := range agreeIds.([]string) {
|
for _, userId := range agreeIds {
|
||||||
if _, ok := utils.Find(self.FriendIds, userId); !ok {
|
if _, ok := utils.Find(self.FriendIds, userId); !ok {
|
||||||
if self.FriendIds == nil {
|
if self.FriendIds == nil {
|
||||||
self.FriendIds = []string{}
|
self.FriendIds = []string{}
|
||||||
@ -70,11 +63,10 @@ func (this *apiComp) Agree(session comm.IUserSession, chk map[string]interface{}
|
|||||||
}
|
}
|
||||||
|
|
||||||
//双向添加:将自己加入到申请人的好友列表中
|
//双向添加:将自己加入到申请人的好友列表中
|
||||||
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 {
|
||||||
@ -95,7 +87,7 @@ func (this *apiComp) Agree(session comm.IUserSession, chk map[string]interface{}
|
|||||||
}
|
}
|
||||||
|
|
||||||
//更新
|
//更新
|
||||||
err := this.module.modelFriend.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,
|
||||||
})
|
})
|
||||||
@ -103,7 +95,6 @@ func (this *apiComp) Agree(session comm.IUserSession, chk map[string]interface{}
|
|||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -5,82 +5,22 @@ import (
|
|||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (this *apiComp) ApplyCheck(session comm.IUserSession, req *pb.FriendApplyReq) (chk map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) ApplyCheck(session comm.IUserSession, req *pb.FriendApplyReq) (code pb.ErrorCode) {
|
||||||
chk = make(map[string]interface{})
|
if req.FriendId == "" {
|
||||||
var err error
|
code = pb.ErrorCode_ReqParameterError
|
||||||
self := &pb.DBFriend{UId: session.GetUserId()}
|
|
||||||
target := &pb.DBFriend{UId: req.FriendId}
|
|
||||||
|
|
||||||
//获取玩家自己好友数据
|
|
||||||
err = this.module.modelFriend.Get(session.GetUserId(), self)
|
|
||||||
if self == nil || err != nil {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取好友数据
|
|
||||||
err = this.module.modelFriend.Get(req.FriendId, target)
|
|
||||||
if target == nil || err != nil {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_FriendTargetNoData}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//判断是否是自己
|
|
||||||
if req.FriendId == session.GetUserId() {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_FriendNotSelf}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//判断是否超过最大好友数量
|
|
||||||
//TODO 最大数从全局配置中获取
|
|
||||||
var max int = 50
|
|
||||||
total := len(self.FriendIds)
|
|
||||||
if total >= max {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfMax}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//判断对方是否也超过最大好友数量
|
|
||||||
ttotal := len(target.FriendIds)
|
|
||||||
if ttotal >= max {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_FriendTargetMax}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//判断是否是好友
|
|
||||||
if _, ok := utils.Find(self.FriendIds, req.FriendId); ok {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_FriendYet}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//判断自己是否在目标用户的申请列表中
|
|
||||||
if _, ok := utils.Find(target.ApplyIds, self.UId); ok {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_FriendApplyYet}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//判断目标用户是否在黑名单中
|
|
||||||
if _, ok := utils.Find(self.BlackIds, req.FriendId); ok {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfBlackYet}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//判断是否在对方的黑名单中
|
|
||||||
if _, ok := utils.Find(target.BlackIds, self.UId); ok {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_FriendTargetBlackYet}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
chk["self"] = self
|
|
||||||
chk["target"] = target
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//好友申请
|
//好友申请
|
||||||
func (this *apiComp) Apply(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendApplyReq) (code pb.ErrorCode) {
|
func (this *apiComp) Apply(session comm.IUserSession, req *pb.FriendApplyReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
var (
|
var (
|
||||||
|
err error
|
||||||
|
self *pb.DBFriend
|
||||||
target *pb.DBFriend
|
target *pb.DBFriend
|
||||||
rsp *pb.FriendApplyRsp
|
rsp *pb.FriendApplyRsp
|
||||||
)
|
)
|
||||||
@ -103,11 +43,60 @@ func (this *apiComp) Apply(session comm.IUserSession, chk map[string]interface{}
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if v, ok := chk["target"]; !ok {
|
//获取玩家自己好友数据
|
||||||
|
self = this.module.modelFriend.GetFriend(session.GetUserId())
|
||||||
|
if self == nil || err != nil {
|
||||||
|
code = pb.ErrorCode_FriendSelfNoData
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取好友数据
|
||||||
|
target = this.module.modelFriend.GetFriend(req.FriendId)
|
||||||
|
if target == nil || err != nil {
|
||||||
code = pb.ErrorCode_FriendTargetNoData
|
code = pb.ErrorCode_FriendTargetNoData
|
||||||
return
|
return
|
||||||
} else {
|
}
|
||||||
target = v.(*pb.DBFriend)
|
|
||||||
|
//判断是否是自己
|
||||||
|
if req.FriendId == session.GetUserId() {
|
||||||
|
code = pb.ErrorCode_FriendNotSelf
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断是否超过最大好友数量
|
||||||
|
if len(self.FriendIds) >= this.module.getFriendMax() {
|
||||||
|
code = pb.ErrorCode_FriendSelfMax
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断对方是否也超过最大好友数量
|
||||||
|
if len(target.FriendIds) >= this.module.getFriendMax() {
|
||||||
|
code = pb.ErrorCode_FriendTargetMax
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断是否是好友
|
||||||
|
if _, ok := utils.Find(self.FriendIds, req.FriendId); ok {
|
||||||
|
code = pb.ErrorCode_FriendYet
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断自己是否在目标用户的申请列表中
|
||||||
|
if _, ok := utils.Find(target.ApplyIds, self.UId); ok {
|
||||||
|
code = pb.ErrorCode_FriendApplyYet
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断目标用户是否在黑名单中
|
||||||
|
if _, ok := utils.Find(self.BlackIds, req.FriendId); ok {
|
||||||
|
code = pb.ErrorCode_FriendSelfBlackYet
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断是否在对方的黑名单中
|
||||||
|
if _, ok := utils.Find(target.BlackIds, self.UId); ok {
|
||||||
|
code = pb.ErrorCode_FriendTargetBlackYet
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//将自己加入到目标用户的申请列表中
|
//将自己加入到目标用户的申请列表中
|
||||||
@ -116,7 +105,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.modelFriend.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 {
|
||||||
|
@ -5,21 +5,15 @@ import (
|
|||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (this *apiComp) ApplyListCheck(session comm.IUserSession, req *pb.FriendApplyListReq) (chk map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) ApplyListCheck(session comm.IUserSession, req *pb.FriendApplyListReq) (code pb.ErrorCode) {
|
||||||
chk = make(map[string]interface{})
|
|
||||||
self := &pb.DBFriend{UId: session.GetUserId()}
|
|
||||||
err := this.module.modelFriend.Get(session.GetUserId(), self)
|
|
||||||
if self == nil || err != nil {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
chk["self"] = self
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//申请列表
|
//申请列表
|
||||||
func (this *apiComp) ApplyList(session comm.IUserSession, chk map[string]interface{}, 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
|
||||||
@ -31,18 +25,23 @@ func (this *apiComp) ApplyList(session comm.IUserSession, chk map[string]interfa
|
|||||||
List: list,
|
List: list,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session.SendMsg(string(this.module.GetType()), FriendSubTypeApplyList, rsp)
|
if err := session.SendMsg(string(this.module.GetType()), FriendSubTypeApplyList, rsp); err != nil {
|
||||||
|
code = pb.ErrorCode_SystemError
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if v, ok := chk["self"]; ok {
|
self = this.module.modelFriend.GetFriend(session.GetUserId())
|
||||||
self = v.(*pb.DBFriend)
|
if self == nil || err != nil {
|
||||||
|
code = pb.ErrorCode_FriendSelfNoData
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for _, userId := range self.ApplyIds {
|
for _, userId := range self.ApplyIds {
|
||||||
//TODO 组装FriendBase明细数据
|
//TODO 组装FriendBase明细数据
|
||||||
list = append(list, &pb.FriendBase{
|
list = append(list, &pb.FriendBase{
|
||||||
UserId: userId,
|
UserId: userId,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -3,23 +3,18 @@ package friend
|
|||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (this *apiComp) BlacklistCheck(session comm.IUserSession, req *pb.FriendBlackListReq) (chk map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) BlacklistCheck(session comm.IUserSession, req *pb.FriendBlackListReq) (code pb.ErrorCode) {
|
||||||
chk = make(map[string]interface{})
|
|
||||||
self := &pb.DBFriend{UId: session.GetUserId()}
|
|
||||||
err := this.module.modelFriend.Get(session.GetUserId(), self)
|
|
||||||
if self == nil || err != nil {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
chk["self"] = self
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//黑名单
|
//黑名单
|
||||||
func (this *apiComp) Blacklist(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendBlackListReq) (code pb.ErrorCode) {
|
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
|
||||||
@ -37,15 +32,18 @@ func (this *apiComp) Blacklist(session comm.IUserSession, chk map[string]interfa
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if v, ok := chk["self"]; ok {
|
self = this.module.modelFriend.GetFriend(session.GetUserId())
|
||||||
self = v.(*pb.DBFriend)
|
if self == nil || err != nil {
|
||||||
|
code = pb.ErrorCode_FriendSelfNoData
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for _, userId := range self.BlackIds {
|
for _, userId := range self.BlackIds {
|
||||||
//TODO 完善FriendBase信息
|
//TODO 完善FriendBase信息
|
||||||
list = append(list, &pb.FriendBase{
|
list = append(list, &pb.FriendBase{
|
||||||
UserId: userId,
|
UserId: userId,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -4,23 +4,21 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (this *apiComp) DelblackCheck(session comm.IUserSession, req *pb.FriendDelBlackReq) (chk map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) DelblackCheck(session comm.IUserSession, req *pb.FriendDelBlackReq) (code pb.ErrorCode) {
|
||||||
chk = make(map[string]interface{})
|
if req.FriendId == "" {
|
||||||
self := &pb.DBFriend{UId: session.GetUserId()}
|
code = pb.ErrorCode_ReqParameterError
|
||||||
err := this.module.modelFriend.Get(session.GetUserId(), self)
|
|
||||||
if self == nil || err != nil {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
chk["self"] = self
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//删除黑名单
|
//删除黑名单
|
||||||
func (this *apiComp) Delblack(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendDelBlackReq) (code pb.ErrorCode) {
|
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
|
||||||
)
|
)
|
||||||
@ -38,19 +36,22 @@ func (this *apiComp) Delblack(session comm.IUserSession, chk map[string]interfac
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if v, ok := chk["self"]; ok {
|
self = this.module.modelFriend.GetFriend(session.GetUserId())
|
||||||
self = v.(*pb.DBFriend)
|
if self == nil || err != nil {
|
||||||
|
code = pb.ErrorCode_FriendSelfNoData
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
//从黑名单列表中删除目标
|
//从黑名单列表中删除目标
|
||||||
self.BlackIds = utils.DeleteString(self.BlackIds, req.FriendId)
|
self.BlackIds = utils.DeleteString(self.BlackIds, req.FriendId)
|
||||||
//更新黑名单
|
//更新黑名单
|
||||||
err := this.module.modelFriend.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 {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -3,22 +3,16 @@ package friend
|
|||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (this *apiComp) ListCheck(session comm.IUserSession, req *pb.FriendListReq) (chk map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) ListCheck(session comm.IUserSession, req *pb.FriendListReq) (code pb.ErrorCode) {
|
||||||
chk = make(map[string]interface{})
|
|
||||||
self := &pb.DBFriend{UId: session.GetUserId()}
|
|
||||||
err := this.module.modelFriend.Get(session.GetUserId(), self)
|
|
||||||
if self == nil || err != nil {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
chk["self"] = self
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//好友列表
|
//好友列表
|
||||||
func (this *apiComp) List(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendListReq) (code pb.ErrorCode) {
|
func (this *apiComp) List(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendListReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
var (
|
var (
|
||||||
self *pb.DBFriend
|
self *pb.DBFriend
|
||||||
rsp *pb.FriendListRsp
|
rsp *pb.FriendListRsp
|
||||||
@ -36,14 +30,17 @@ func (this *apiComp) List(session comm.IUserSession, chk map[string]interface{},
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if v, ok := chk["self"]; ok {
|
self = this.module.modelFriend.GetFriend(session.GetUserId())
|
||||||
self = v.(*pb.DBFriend)
|
if self == nil {
|
||||||
|
code = pb.ErrorCode_FriendSelfNoData
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for _, userId := range self.FriendIds {
|
for _, userId := range self.FriendIds {
|
||||||
list = append(list, &pb.FriendBase{
|
list = append(list, &pb.FriendBase{
|
||||||
UserId: userId,
|
UserId: userId,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -4,38 +4,23 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (this *apiComp) RefuseCheck(session comm.IUserSession, req *pb.FriendRefuseReq) (chk map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) RefuseCheck(session comm.IUserSession, req *pb.FriendRefuseReq) (code pb.ErrorCode) {
|
||||||
chk = make(map[string]interface{})
|
if len(req.FriendIds) == 0 {
|
||||||
var err error
|
code = pb.ErrorCode_ReqParameterError
|
||||||
self := &pb.DBFriend{UId: session.GetUserId()}
|
|
||||||
|
|
||||||
//获取玩家自己好友数据
|
|
||||||
err = this.module.modelFriend.Get(session.GetUserId(), self)
|
|
||||||
if self == nil || err != nil {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//拒绝的Ids
|
|
||||||
refuseIds := []string{}
|
|
||||||
for _, friendId := range req.FriendIds {
|
|
||||||
if _, ok := utils.Find(self.ApplyIds, friendId); ok {
|
|
||||||
refuseIds = append(refuseIds, friendId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
chk["self"] = self
|
|
||||||
chk["refuseIds"] = refuseIds
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//单个/批量拒绝
|
//单个/批量拒绝
|
||||||
func (this *apiComp) Refuse(session comm.IUserSession, chk map[string]interface{}, req *pb.FriendRefuseReq) (code pb.ErrorCode) {
|
func (this *apiComp) Refuse(session comm.IUserSession, req *pb.FriendRefuseReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
//将申请人从申请列表中删除
|
//将申请人从申请列表中删除
|
||||||
var (
|
var (
|
||||||
|
err error
|
||||||
self *pb.DBFriend
|
self *pb.DBFriend
|
||||||
rsp *pb.FriendRefuseRsp
|
rsp *pb.FriendRefuseRsp
|
||||||
optNum int32
|
optNum int32
|
||||||
@ -52,15 +37,23 @@ func (this *apiComp) Refuse(session comm.IUserSession, chk map[string]interface{
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if v, ok := chk["self"]; !ok {
|
//获取玩家自己好友数据
|
||||||
code = pb.ErrorCode_FriendTargetNoData
|
self = this.module.modelFriend.GetFriend(session.GetUserId())
|
||||||
|
if self == nil || err != nil {
|
||||||
|
code = pb.ErrorCode_FriendSelfNoData
|
||||||
return
|
return
|
||||||
} else {
|
}
|
||||||
self = v.(*pb.DBFriend)
|
|
||||||
|
//拒绝的Ids
|
||||||
|
refuseIds := []string{}
|
||||||
|
for _, friendId := range req.FriendIds {
|
||||||
|
if _, ok := utils.Find(self.ApplyIds, friendId); ok {
|
||||||
|
refuseIds = append(refuseIds, friendId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if v, ok := chk["refuseIds"]; ok {
|
|
||||||
//将申请人从申请列表中删除
|
//将申请人从申请列表中删除
|
||||||
for _, userId := range v.([]string) {
|
for _, userId := range refuseIds {
|
||||||
self.ApplyIds = utils.DeleteString(self.ApplyIds, userId)
|
self.ApplyIds = utils.DeleteString(self.ApplyIds, userId)
|
||||||
optNum++
|
optNum++
|
||||||
}
|
}
|
||||||
@ -75,7 +68,5 @@ func (this *apiComp) Refuse(session comm.IUserSession, chk map[string]interface{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
@ -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 {
|
||||||
@ -16,6 +18,7 @@ type Friend struct {
|
|||||||
modules.ModuleBase
|
modules.ModuleBase
|
||||||
api *apiComp
|
api *apiComp
|
||||||
modelFriend *ModelFriend
|
modelFriend *ModelFriend
|
||||||
|
configure *modules.MCompConfigure
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Friend) GetType() core.M_Modules {
|
func (this *Friend) GetType() core.M_Modules {
|
||||||
@ -33,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
|
||||||
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package hero
|
package hero
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
)
|
)
|
||||||
@ -9,8 +8,7 @@ import (
|
|||||||
type apiComp struct {
|
type apiComp struct {
|
||||||
modules.MCompGate
|
modules.MCompGate
|
||||||
service core.IService
|
service core.IService
|
||||||
moduleHero *Hero
|
module *Hero
|
||||||
user comm.IUser
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const ( //消息回复的头名称
|
const ( //消息回复的头名称
|
||||||
@ -29,7 +27,7 @@ const ( //消息回复的头名称
|
|||||||
//组件初始化接口
|
//组件初始化接口
|
||||||
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) {
|
||||||
err = this.MCompGate.Init(service, module, comp, options)
|
err = this.MCompGate.Init(service, module, comp, options)
|
||||||
this.moduleHero = module.(*Hero)
|
this.module = module.(*Hero)
|
||||||
this.service = service
|
this.service = service
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -37,12 +35,5 @@ func (this *apiComp) Init(service core.IService, module core.IModule, comp core.
|
|||||||
func (this *apiComp) Start() (err error) {
|
func (this *apiComp) Start() (err error) {
|
||||||
err = this.MCompGate.Start()
|
err = this.MCompGate.Start()
|
||||||
|
|
||||||
var module core.IModule
|
|
||||||
|
|
||||||
if module, err = this.service.GetModule(comm.ModuleUser); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.user = module.(comm.IUser)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
func (this *apiComp) AwakenCheck(session comm.IUserSession, req *pb.HeroAwakenReq) (code comm.ErrorCode) {
|
func (this *apiComp) AwakenCheck(session comm.IUserSession, req *pb.HeroAwakenReq) (code pb.ErrorCode) {
|
||||||
if req.HeroObjID == "" {
|
if req.HeroObjID == "" {
|
||||||
code.Code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ func (this *apiComp) AwakenCheck(session comm.IUserSession, req *pb.HeroAwakenRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 英雄觉醒
|
/// 英雄觉醒
|
||||||
func (this *apiComp) Awaken(session comm.IUserSession, agrs map[string]interface{}, req *pb.HeroAwakenReq) (code pb.ErrorCode, data proto.Message) {
|
func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
var (
|
var (
|
||||||
awakenData *cfg.Game_heroAwakenData
|
awakenData *cfg.Game_heroAwakenData
|
||||||
bCheckOk bool
|
bCheckOk bool
|
||||||
@ -29,13 +29,13 @@ func (this *apiComp) Awaken(session comm.IUserSession, agrs map[string]interface
|
|||||||
)
|
)
|
||||||
costRes = make(map[string]int32, 0)
|
costRes = make(map[string]int32, 0)
|
||||||
bCheckOk = true
|
bCheckOk = true
|
||||||
_hero, err := this.moduleHero.GetHero(session.GetUserId(), req.HeroObjID)
|
_hero, err := this.module.GetHero(session.GetUserId(), req.HeroObjID)
|
||||||
|
|
||||||
if err != pb.ErrorCode_Success {
|
if err != pb.ErrorCode_Success {
|
||||||
code = pb.ErrorCode_HeroNoExist
|
code = pb.ErrorCode_HeroNoExist
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
AwakenConfig, err1 := this.moduleHero.configure.GetHeroAwakenConfig()
|
AwakenConfig, err1 := this.module.configure.GetHeroAwakenConfig()
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
return
|
return
|
||||||
@ -53,7 +53,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, agrs map[string]interface
|
|||||||
// 参数校验
|
// 参数校验
|
||||||
for _, v := range awakenData.Phaseneed {
|
for _, v := range awakenData.Phaseneed {
|
||||||
if v.A == "attr" { // 消耗玩家身上资源
|
if v.A == "attr" { // 消耗玩家身上资源
|
||||||
curGold := this.user.QueryAttributeValue(session.GetUserId(), v.T)
|
curGold := this.module.ModuleUser.QueryAttributeValue(session.GetUserId(), v.T)
|
||||||
if curGold < v.N {
|
if curGold < v.N {
|
||||||
bCheckOk = false
|
bCheckOk = false
|
||||||
break
|
break
|
||||||
@ -62,7 +62,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, agrs map[string]interface
|
|||||||
} else if v.A == "item" { //消耗道具
|
} else if v.A == "item" { //消耗道具
|
||||||
itemid, err := strconv.Atoi(v.T)
|
itemid, err := strconv.Atoi(v.T)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
curCount := this.moduleHero.items.QueryItemAmount(nil, session.GetUserId(), int32(itemid))
|
curCount := this.module.items.QueryItemAmount(nil, session.GetUserId(), int32(itemid))
|
||||||
if curCount < uint32(v.N) {
|
if curCount < uint32(v.N) {
|
||||||
bCheckOk = false
|
bCheckOk = false
|
||||||
break
|
break
|
||||||
@ -80,14 +80,14 @@ func (this *apiComp) Awaken(session comm.IUserSession, agrs map[string]interface
|
|||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if code == pb.ErrorCode_Success {
|
if code == pb.ErrorCode_Success {
|
||||||
session.SendMsg(string(this.moduleHero.GetType()), StrengthenUplv, &pb.HeroAwakenResp{Hero: _hero})
|
session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.HeroAwakenResp{Hero: _hero})
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
for _, v := range awakenData.Phaseneed {
|
for _, v := range awakenData.Phaseneed {
|
||||||
if v.A == "attr" { // 消耗玩家身上资源
|
if v.A == "attr" { // 消耗玩家身上资源
|
||||||
if _data, ok := costRes[v.T]; ok {
|
if _data, ok := costRes[v.T]; ok {
|
||||||
code = this.user.AddAttributeValue(session.GetUserId(), v.T, _data)
|
code = this.module.ModuleUser.AddAttributeValue(session.GetUserId(), v.T, _data)
|
||||||
if code != pb.ErrorCode_Success {
|
if code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, agrs map[string]interface
|
|||||||
} else if v.A == "item" { //消耗道具
|
} else if v.A == "item" { //消耗道具
|
||||||
itemid, err := strconv.Atoi(v.T)
|
itemid, err := strconv.Atoi(v.T)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code = this.moduleHero.items.AddItem(nil, session.GetUserId(), int32(itemid), -v.N)
|
code = this.module.items.AddItem(nil, session.GetUserId(), int32(itemid), -v.N)
|
||||||
if code != pb.ErrorCode_Success {
|
if code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, agrs map[string]interface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err1 = this.moduleHero.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
err1 = this.module.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
log.Errorf("PushHeroProperty err!")
|
log.Errorf("PushHeroProperty err!")
|
||||||
}
|
}
|
||||||
|
@ -13,25 +13,25 @@ func (this *apiComp) ChoukaCheck(session comm.IUserSession, req *pb.HeroChoukaRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
//抽卡
|
//抽卡
|
||||||
func (this *apiComp) Chouka(session comm.IUserSession, result map[string]interface{}, req *pb.HeroChoukaReq) (code pb.ErrorCode) {
|
func (this *apiComp) Chouka(session comm.IUserSession, req *pb.HeroChoukaReq) (code pb.ErrorCode) {
|
||||||
rsp := &pb.HeroChoukaResp{}
|
rsp := &pb.HeroChoukaResp{}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
err := session.SendMsg(string(this.moduleHero.GetType()), HeroSubTypeChouka, rsp)
|
err := session.SendMsg(string(this.module.GetType()), HeroSubTypeChouka, rsp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code = pb.ErrorCode_SystemError
|
code = pb.ErrorCode_SystemError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
utils.TraceFunc(session.GetUserId(), string(this.moduleHero.GetType()), HeroSubTypeChouka, req, rsp)
|
utils.TraceFunc(session.GetUserId(), string(this.module.GetType()), HeroSubTypeChouka, req, rsp)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
heroCfgIds := req.HeroIds
|
heroCfgIds := req.HeroIds
|
||||||
if err := this.moduleHero.hero.createMultiHero(session.GetUserId(), heroCfgIds...); err != nil {
|
if err := this.module.hero.createMultiHero(session.GetUserId(), heroCfgIds...); err != nil {
|
||||||
code = pb.ErrorCode_HeroCreate
|
code = pb.ErrorCode_HeroCreate
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
heroes, err := this.moduleHero.hero.getHeroList(session.GetUserId())
|
heroes, err := this.module.hero.getHeroList(session.GetUserId())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("%v", err)
|
log.Errorf("%v", err)
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
|
@ -4,32 +4,32 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.HeroInfoReq) (result map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.HeroInfoReq) (code pb.ErrorCode) {
|
||||||
result = map[string]interface{}{}
|
|
||||||
hero := this.moduleHero.hero.getOneHero(session.GetUserId(), req.HeroId)
|
|
||||||
if hero == nil {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_HeroNoExist}
|
|
||||||
}
|
|
||||||
result["hero"] = hero
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *apiComp) Info(session comm.IUserSession, result map[string]interface{}, req *pb.HeroInfoReq) (code pb.ErrorCode) {
|
func (this *apiComp) Info(session comm.IUserSession, req *pb.HeroInfoReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
rsp := &pb.HeroInfoRsp{}
|
rsp := &pb.HeroInfoRsp{}
|
||||||
defer func() {
|
defer func() {
|
||||||
err := session.SendMsg(string(this.moduleHero.GetType()), HeroSubTypeInfo, rsp)
|
err := session.SendMsg(string(this.module.GetType()), HeroSubTypeInfo, rsp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code = pb.ErrorCode_SystemError
|
code = pb.ErrorCode_SystemError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
utils.TraceFunc(session.GetUserId(), string(this.moduleHero.GetType()), HeroSubTypeList, req, rsp)
|
utils.TraceFunc(session.GetUserId(), string(this.module.GetType()), HeroSubTypeList, req, rsp)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if v, ok := result["hero"]; ok {
|
hero := this.module.hero.getOneHero(session.GetUserId(), req.HeroId)
|
||||||
rsp.Base = v.(*pb.DBHero)
|
if hero == nil {
|
||||||
|
code = pb.ErrorCode_HeroNoExist
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rsp.Base = hero
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -4,25 +4,27 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
func (this *apiComp) ListCheck(session comm.IUserSession, req *pb.HeroListReq) (result map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) ListCheck(session comm.IUserSession, req *pb.HeroListReq) (code pb.ErrorCode) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *apiComp) List(session comm.IUserSession, result map[string]interface{}, req *pb.HeroListReq) (code pb.ErrorCode) {
|
func (this *apiComp) List(session comm.IUserSession, req *pb.HeroListReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
rsp := &pb.HeroListRsp{}
|
rsp := &pb.HeroListRsp{}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
err := session.SendMsg(string(this.moduleHero.GetType()), HeroSubTypeList, rsp)
|
err := session.SendMsg(string(this.module.GetType()), HeroSubTypeList, rsp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code = pb.ErrorCode_SystemError
|
code = pb.ErrorCode_SystemError
|
||||||
}
|
}
|
||||||
utils.TraceFunc(session.GetUserId(), string(this.moduleHero.GetType()), HeroSubTypeList, req, rsp)
|
utils.TraceFunc(session.GetUserId(), string(this.module.GetType()), HeroSubTypeList, req, rsp)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
list, err := this.moduleHero.hero.getHeroList(session.GetUserId())
|
list, err := this.module.hero.getHeroList(session.GetUserId())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
|
@ -5,39 +5,48 @@ import (
|
|||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
func (this *apiComp) ResonanceCheck(session comm.IUserSession, req *pb.HeroResonanceReq) (result map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) ResonanceCheck(session comm.IUserSession, req *pb.HeroResonanceReq) (code pb.ErrorCode) {
|
||||||
if req.HeroObjID == "" || req.CostObjID == "" {
|
if req.HeroObjID == "" || req.CostObjID == "" {
|
||||||
code.Code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var (
|
return
|
||||||
bCheckOk bool
|
}
|
||||||
)
|
|
||||||
bCheckOk = false
|
/// 英雄共鸣
|
||||||
_hero, err := this.moduleHero.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在
|
func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
if err != 0 {
|
|
||||||
code.Code = pb.ErrorCode_HeroNoExist
|
bCheckOk := true
|
||||||
|
_hero, code := this.module.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在
|
||||||
|
if code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_costHero, err := this.moduleHero.GetHero(session.GetUserId(), req.CostObjID) // 查询消耗卡是否存在
|
defer func() {
|
||||||
if err != 0 {
|
if code == pb.ErrorCode_Success {
|
||||||
code.Code = pb.ErrorCode_HeroNoExist
|
session.SendMsg(string(this.module.GetType()), Resonance, &pb.HeroResonanceResp{Hero: _hero})
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
_costHero, code := this.module.GetHero(session.GetUserId(), req.CostObjID) // 查询消耗卡是否存在
|
||||||
|
if code != pb.ErrorCode_Success {
|
||||||
|
code = pb.ErrorCode_HeroNoEnough
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if _costHero.SameCount < req.Amount { // 消耗卡数量不足
|
if _costHero.SameCount < req.Amount { // 消耗卡数量不足
|
||||||
code.Code = pb.ErrorCode_HeroNoEnough
|
code = pb.ErrorCode_HeroNoEnough
|
||||||
}
|
}
|
||||||
// 共鸣次数判断
|
// 共鸣次数判断
|
||||||
resonConfig, errr := this.moduleHero.configure.GetHeroResonanceConfig(_hero.HeroID)
|
resonConfig, errr := this.module.configure.GetHeroResonanceConfig(_hero.HeroID)
|
||||||
if errr != nil {
|
if errr != nil {
|
||||||
code.Code = pb.ErrorCode_ConfigNoFound
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if resonConfig.Maxnum >= _hero.ResonateNum {
|
if resonConfig.Maxnum >= _hero.ResonateNum {
|
||||||
code.Code = pb.ErrorCode_HeroMaxResonate // 共鸣次数已满
|
code = pb.ErrorCode_HeroMaxResonate // 共鸣次数已满
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +54,7 @@ func (this *apiComp) ResonanceCheck(session comm.IUserSession, req *pb.HeroReson
|
|||||||
for _, v := range resonConfig.Need {
|
for _, v := range resonConfig.Need {
|
||||||
if v.A == "hero" && v.T == strconv.Itoa(int(_costHero.HeroID)) {
|
if v.A == "hero" && v.T == strconv.Itoa(int(_costHero.HeroID)) {
|
||||||
if req.Amount != v.N {
|
if req.Amount != v.N {
|
||||||
code.Code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
bCheckOk = true
|
bCheckOk = true
|
||||||
@ -54,60 +63,37 @@ func (this *apiComp) ResonanceCheck(session comm.IUserSession, req *pb.HeroReson
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !bCheckOk { // 配置校验不通过
|
if !bCheckOk { // 配置校验不通过
|
||||||
code.Code = pb.ErrorCode_HeroNoEnough
|
code = pb.ErrorCode_HeroNoEnough
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
bCheckOk = false
|
bCheckOk = true
|
||||||
// 金币校验
|
// 金币校验
|
||||||
for _, v := range resonConfig.Need {
|
for _, v := range resonConfig.Need {
|
||||||
if v.A == "attr" { // 查询玩家身上资源是否满足
|
if v.A == "attr" { // 查询玩家身上资源是否满足
|
||||||
value := this.user.QueryAttributeValue(session.GetUserId(), v.T)
|
value := this.module.ModuleUser.QueryAttributeValue(session.GetUserId(), v.T)
|
||||||
if value >= v.N {
|
if value < v.N {
|
||||||
bCheckOk = true // 财富校验通过
|
code = pb.ErrorCode_ResNoEnough
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !bCheckOk { // 配置校验不通过
|
|
||||||
code.Code = pb.ErrorCode_ResNoEnough
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
result = map[string]interface{}{
|
|
||||||
"heroObj": _hero,
|
|
||||||
}
|
}
|
||||||
return
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// 英雄共鸣
|
code = this.module.DelCard(req.CostObjID, req.Amount)
|
||||||
func (this *apiComp) Resonance(session comm.IUserSession, agrs map[string]interface{}, req *pb.HeroResonanceReq) (code pb.ErrorCode) {
|
if code != pb.ErrorCode_Success {
|
||||||
_hero := agrs["heroObj"].(*pb.DBHero)
|
|
||||||
if _hero == nil {
|
|
||||||
code = pb.ErrorCode_HeroNoExist
|
|
||||||
log.Errorf("not find card:%s,", req.HeroObjID)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if code == pb.ErrorCode_Success {
|
|
||||||
session.SendMsg(string(this.moduleHero.GetType()), Resonance, &pb.HeroResonanceResp{Hero: _hero})
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
code = this.moduleHero.DelCard(req.CostObjID, req.Amount)
|
|
||||||
if code != 0 {
|
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
resonConfig, err1 := this.moduleHero.configure.GetHeroResonanceConfig(_hero.HeroID)
|
resonConfig, err1 := this.module.configure.GetHeroResonanceConfig(_hero.HeroID)
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range resonConfig.Need {
|
for _, v := range resonConfig.Need {
|
||||||
if v.A == "attr" { // 查询玩家身上资源是否满足
|
if v.A == "attr" { // 查询玩家身上资源是否满足
|
||||||
value := this.user.QueryAttributeValue(session.GetUserId(), v.T)
|
value := this.module.ModuleUser.QueryAttributeValue(session.GetUserId(), v.T)
|
||||||
if value >= v.N { // 直接删除财富
|
if value >= v.N { // 直接删除财富
|
||||||
code = this.user.AddAttributeValue(session.GetUserId(), v.T, value-v.N) // 扣除资源
|
code = this.module.ModuleUser.AddAttributeValue(session.GetUserId(), v.T, value-v.N) // 扣除资源
|
||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
code = pb.ErrorCode_ResNoEnough
|
code = pb.ErrorCode_ResNoEnough
|
||||||
@ -118,9 +104,9 @@ func (this *apiComp) Resonance(session comm.IUserSession, agrs map[string]interf
|
|||||||
_heroMap := map[string]interface{}{
|
_heroMap := map[string]interface{}{
|
||||||
"resonateNum": _hero.ResonateNum + resonConfig.Energy,
|
"resonateNum": _hero.ResonateNum + resonConfig.Energy,
|
||||||
}
|
}
|
||||||
err := this.moduleHero.hero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
|
err1 = this.module.hero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
|
||||||
if err != nil {
|
if err1 != nil {
|
||||||
log.Errorf("update hero skill failed:%v", err)
|
log.Errorf("update hero skill failed:%v", err1)
|
||||||
}
|
}
|
||||||
// 返还对应初始星级的卡
|
// 返还对应初始星级的卡
|
||||||
for _, v := range resonConfig.Prize {
|
for _, v := range resonConfig.Prize {
|
||||||
@ -131,12 +117,12 @@ func (this *apiComp) Resonance(session comm.IUserSession, agrs map[string]interf
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
for i := 0; i < int(v.N); i++ { // 有多少张加多少次
|
for i := 0; i < int(v.N); i++ { // 有多少张加多少次
|
||||||
this.moduleHero.hero.createOneHero(session.GetUserId(), int32(value))
|
this.module.hero.createOneHero(session.GetUserId(), int32(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err = this.moduleHero.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
err1 = this.module.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||||
if err != nil {
|
if err1 != nil {
|
||||||
log.Errorf("PushHeroProperty err!")
|
log.Errorf("PushHeroProperty err!")
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -4,75 +4,66 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
func (this *apiComp) ResonanceResetCheck(session comm.IUserSession, req *pb.HeroResonanceResetReq) (result map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) ResonanceResetCheck(session comm.IUserSession, req *pb.HeroResonanceResetReq) (code pb.ErrorCode) {
|
||||||
if req.HeroObjID == "" {
|
if req.HeroObjID == "" {
|
||||||
code.Code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
return
|
|
||||||
}
|
|
||||||
_hero, err := this.moduleHero.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在
|
|
||||||
if err != 0 {
|
|
||||||
code.Code = pb.ErrorCode_HeroNoExist
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if _hero.ResonateNum <= 0 { // 没有共鸣 不允许重置
|
|
||||||
code.Code = pb.ErrorCode_HeroNoResonate
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 共鸣次数判断
|
|
||||||
resonConfig, errr := this.moduleHero.configure.GetHeroResonanceConfig(_hero.HeroID)
|
|
||||||
if errr != nil {
|
|
||||||
code.Code = pb.ErrorCode_ConfigNoFound
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if _hero.ResonateNum*resonConfig.Energy >= _hero.DistributionResonate {
|
|
||||||
code.Code = pb.ErrorCode_HeroNotNeedResonate // 已经是重置状态
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
_costConfig, err1 := this.moduleHero.configure.GetHeroResonanceRestConfig()
|
|
||||||
if err1 != nil {
|
|
||||||
code.Code = pb.ErrorCode_ConfigNoFound // 没找到配置消耗
|
|
||||||
return
|
|
||||||
}
|
|
||||||
for _, v := range _costConfig.Var {
|
|
||||||
if v.A == "attr" {
|
|
||||||
value := this.user.QueryAttributeValue(session.GetUserId(), v.T)
|
|
||||||
if value < v.N {
|
|
||||||
code.Code = pb.ErrorCode_ResNoEnough // 资源不足
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result = map[string]interface{}{
|
|
||||||
"resonateNum": _hero.ResonateNum * resonConfig.Energy,
|
|
||||||
"heroObj": _hero,
|
|
||||||
"_costConfig": _costConfig,
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 英雄共鸣
|
/// 英雄共鸣
|
||||||
func (this *apiComp) ResonanceReset(session comm.IUserSession, agrs map[string]interface{}, req *pb.HeroResonanceResetReq) (code pb.ErrorCode) {
|
func (this *apiComp) ResonanceReset(session comm.IUserSession, req *pb.HeroResonanceResetReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
|
|
||||||
restResonance := agrs["resonateNum"].(int32)
|
|
||||||
_hero := agrs["heroObj"].(*pb.DBHero)
|
|
||||||
_costConfig := agrs["heroObj"].(cfg.Game_comAtnData)
|
|
||||||
|
|
||||||
|
_hero, code := this.module.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在
|
||||||
|
if code != pb.ErrorCode_Success {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if _hero.ResonateNum <= 0 { // 没有共鸣 不允许重置
|
||||||
|
code = pb.ErrorCode_HeroNoResonate
|
||||||
|
return
|
||||||
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if code == pb.ErrorCode_Success {
|
if code == pb.ErrorCode_Success {
|
||||||
session.SendMsg(string(this.moduleHero.GetType()), ResonanceReset, &pb.HeroResonanceResetResp{Hero: _hero, Energy: _hero.ResonateNum})
|
session.SendMsg(string(this.module.GetType()), ResonanceReset, &pb.HeroResonanceResetResp{Hero: _hero, Energy: _hero.ResonateNum})
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
// 共鸣次数判断
|
||||||
|
resonConfig, errr := this.module.configure.GetHeroResonanceConfig(_hero.HeroID)
|
||||||
|
if errr != nil {
|
||||||
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if _hero.ResonateNum*resonConfig.Energy >= _hero.DistributionResonate {
|
||||||
|
code = pb.ErrorCode_HeroNotNeedResonate // 已经是重置状态
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_costConfig, err1 := this.module.configure.GetHeroResonanceRestConfig()
|
||||||
|
if err1 != nil {
|
||||||
|
code = pb.ErrorCode_ConfigNoFound // 没找到配置消耗
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, v := range _costConfig.Var {
|
||||||
|
if v.A == "attr" {
|
||||||
|
value := this.module.ModuleUser.QueryAttributeValue(session.GetUserId(), v.T)
|
||||||
|
if value < v.N {
|
||||||
|
code = pb.ErrorCode_ResNoEnough // 资源不足
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, v := range _costConfig.Var {
|
for _, v := range _costConfig.Var {
|
||||||
if v.A == "attr" {
|
if v.A == "attr" {
|
||||||
code = this.user.AddAttributeValue(session.GetUserId(), v.T, -v.N) // 扣资源
|
code = this.module.ModuleUser.AddAttributeValue(session.GetUserId(), v.T, -v.N) // 扣资源
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,16 +71,16 @@ func (this *apiComp) ResonanceReset(session comm.IUserSession, agrs map[string]i
|
|||||||
delete(_hero.Energy, k)
|
delete(_hero.Energy, k)
|
||||||
}
|
}
|
||||||
_heroMap := map[string]interface{}{
|
_heroMap := map[string]interface{}{
|
||||||
"DistributionResonate": restResonance,
|
"DistributionResonate": _hero.ResonateNum * resonConfig.Energy,
|
||||||
"Energy": _hero.Energy,
|
"Energy": _hero.Energy,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := this.moduleHero.hero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
|
err1 = this.module.hero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
|
||||||
if err != nil {
|
if err1 != nil {
|
||||||
log.Errorf("update hero skill failed:%v", err)
|
log.Errorf("update hero skill failed:%v", err1)
|
||||||
}
|
}
|
||||||
err = this.moduleHero.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
err1 = this.module.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||||
if err != nil {
|
if err1 != nil {
|
||||||
log.Errorf("PushHeroProperty err!")
|
log.Errorf("PushHeroProperty err!")
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -4,42 +4,35 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
func (this *apiComp) ResonanceUseEnergyCheck(session comm.IUserSession, req *pb.HeroResonanceUseEnergyReq) (result map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) ResonanceUseEnergyCheck(session comm.IUserSession, req *pb.HeroResonanceUseEnergyReq) (code pb.ErrorCode) {
|
||||||
if req.HeroObjID == "" || req.UseEnergy <= 0 || req.UseType < 0 {
|
if len(req.HeroObjID) == 0 || req.UseEnergy <= 0 || req.UseType < 0 {
|
||||||
code.Code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
return
|
|
||||||
}
|
|
||||||
_hero, err := this.moduleHero.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在
|
|
||||||
if err != 0 {
|
|
||||||
code.Code = pb.ErrorCode_HeroNoExist
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if _hero.DistributionResonate < req.UseEnergy { // 能量点数不够
|
|
||||||
code.Code = pb.ErrorCode_HeroNoEnergy
|
|
||||||
return
|
|
||||||
}
|
|
||||||
result = map[string]interface{}{
|
|
||||||
"heroObj": _hero,
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, agrs map[string]interface{}, req *pb.HeroResonanceUseEnergyReq) (code pb.ErrorCode) {
|
func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, req *pb.HeroResonanceUseEnergyReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
_hero := agrs["heroObj"].(*pb.DBHero)
|
|
||||||
|
|
||||||
|
_hero, code := this.module.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在
|
||||||
defer func() {
|
defer func() {
|
||||||
if code == pb.ErrorCode_Success {
|
if code == pb.ErrorCode_Success {
|
||||||
session.SendMsg(string(this.moduleHero.GetType()), ResonanceUseEnergy, &pb.HeroResonanceUseEnergyResp{Hero: _hero})
|
session.SendMsg(string(this.module.GetType()), ResonanceUseEnergy, &pb.HeroResonanceUseEnergyResp{Hero: _hero})
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
if code != pb.ErrorCode_Success {
|
||||||
if _hero == nil {
|
|
||||||
code = pb.ErrorCode_HeroNoExist
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _hero.DistributionResonate < req.UseEnergy { // 能量点数不够
|
||||||
|
code = pb.ErrorCode_HeroNoEnergy
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
_hero.Energy[req.UseType] += req.UseEnergy
|
_hero.Energy[req.UseType] += req.UseEnergy
|
||||||
|
|
||||||
_heroMap := map[string]interface{}{
|
_heroMap := map[string]interface{}{
|
||||||
@ -47,14 +40,14 @@ func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, agrs map[stri
|
|||||||
"Energy": _hero.Energy,
|
"Energy": _hero.Energy,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := this.moduleHero.hero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
|
err1 := this.module.hero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
|
||||||
if err != nil {
|
if err1 != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
log.Errorf("update hero skill failed:%v", err)
|
log.Errorf("update hero skill failed:%v", err1)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = this.moduleHero.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
err1 = this.module.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||||
if err != nil {
|
if err1 != nil {
|
||||||
log.Errorf("PushHeroProperty err!")
|
log.Errorf("PushHeroProperty err!")
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -6,77 +6,67 @@ import (
|
|||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
func (this *apiComp) StrengthenUpSkillCheck(session comm.IUserSession, req *pb.HeroStrengthenUpSkillReq) (result map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) StrengthenUpSkillCheck(session comm.IUserSession, req *pb.HeroStrengthenUpSkillReq) (code pb.ErrorCode) {
|
||||||
if req.HeroObjID == "" || req.CostCardObj == "" {
|
if req.HeroObjID == "" || req.CostCardObj == "" {
|
||||||
code.Code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
|
||||||
tagColor int32 // 目标卡品质
|
|
||||||
costColor int32 // 消耗卡品质
|
|
||||||
)
|
|
||||||
_hero, err := this.moduleHero.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在
|
|
||||||
if err != 0 {
|
|
||||||
code.Code = pb.ErrorCode_HeroNoExist
|
|
||||||
return
|
|
||||||
}
|
|
||||||
_costHero, err := this.moduleHero.GetHero(session.GetUserId(), req.CostCardObj) // 查询消耗卡是否存在
|
|
||||||
if err != 0 {
|
|
||||||
code.Code = pb.ErrorCode_HeroNoExist
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 查询配置表 找出原始品质
|
|
||||||
tmp := this.moduleHero.configure.GetHero(_hero.HeroID)
|
|
||||||
if tmp == nil {
|
|
||||||
code.Code = pb.ErrorCode_HeroNoExist
|
|
||||||
return
|
|
||||||
}
|
|
||||||
tagColor = tmp.Color
|
|
||||||
tmp = this.moduleHero.configure.GetHero(_costHero.HeroID)
|
|
||||||
if tmp == nil {
|
|
||||||
code.Code = pb.ErrorCode_HeroNoExist
|
|
||||||
return
|
|
||||||
}
|
|
||||||
costColor = tmp.Color
|
|
||||||
if costColor != tagColor {
|
|
||||||
code.Code = pb.ErrorCode_HeroColorErr
|
|
||||||
return
|
|
||||||
}
|
|
||||||
result = map[string]interface{}{
|
|
||||||
"heroObj": _hero,
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 英雄技能升级
|
/// 英雄技能升级
|
||||||
func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, agrs map[string]interface{}, req *pb.HeroStrengthenUpSkillReq) (code pb.ErrorCode) {
|
func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroStrengthenUpSkillReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
var (
|
var (
|
||||||
tmpUpSkillID map[int32]*pb.SkillData // 即将要升级的技能id
|
tmpUpSkillID map[int32]*pb.SkillData // 即将要升级的技能id
|
||||||
probability map[int32]int32 // 即将升级技能的权重
|
probability map[int32]int32 // 即将升级技能的权重
|
||||||
upSkillPos int32 // 升级的技能位置
|
upSkillPos int32 // 升级的技能位置
|
||||||
totalprobability int32 // 所有技能总权重
|
totalprobability int32 // 所有技能总权重
|
||||||
tmpValue int32 // 临时对象 存放累加权重
|
tmpValue int32 // 临时对象 存放累加权重
|
||||||
|
tagColor int32 // 目标卡品质
|
||||||
|
costColor int32 // 消耗卡品质
|
||||||
)
|
)
|
||||||
tmpUpSkillID = make(map[int32]*pb.SkillData, 0)
|
tmpUpSkillID = make(map[int32]*pb.SkillData, 0)
|
||||||
probability = make(map[int32]int32, 0)
|
probability = make(map[int32]int32, 0)
|
||||||
_hero := agrs["heroObj"].(*pb.DBHero)
|
_hero, err := this.module.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在
|
||||||
if _hero == nil {
|
if err != pb.ErrorCode_Success {
|
||||||
code = pb.ErrorCode_HeroNoExist
|
code = pb.ErrorCode_HeroNoExist
|
||||||
log.Errorf("not find card:%s,", req.HeroObjID)
|
return
|
||||||
|
}
|
||||||
|
_costHero, err := this.module.GetHero(session.GetUserId(), req.CostCardObj) // 查询消耗卡是否存在
|
||||||
|
if err != pb.ErrorCode_Success {
|
||||||
|
code = pb.ErrorCode_HeroNoExist
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 查询配置表 找出原始品质
|
||||||
|
tmp := this.module.configure.GetHero(_hero.HeroID)
|
||||||
|
if tmp == nil {
|
||||||
|
code = pb.ErrorCode_HeroNoExist
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tagColor = tmp.Color
|
||||||
|
tmp = this.module.configure.GetHero(_costHero.HeroID)
|
||||||
|
if tmp == nil {
|
||||||
|
code = pb.ErrorCode_HeroNoExist
|
||||||
|
return
|
||||||
|
}
|
||||||
|
costColor = tmp.Color
|
||||||
|
if costColor != tagColor {
|
||||||
|
code = pb.ErrorCode_HeroColorErr
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if code == pb.ErrorCode_Success {
|
if code == pb.ErrorCode_Success {
|
||||||
session.SendMsg(string(this.moduleHero.GetType()), StrengthenUpSkill, &pb.HeroStrengthenUpSkillResp{Hero: _hero})
|
session.SendMsg(string(this.module.GetType()), StrengthenUpSkill, &pb.HeroStrengthenUpSkillResp{Hero: _hero})
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
config, err := this.moduleHero.configure.GetHeroSkillUpConfig()
|
config, err1 := this.module.configure.GetHeroSkillUpConfig()
|
||||||
if err != nil {
|
if err1 != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 先随机一个没有升满
|
// 先随机一个没有升满
|
||||||
@ -85,7 +75,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, agrs map[strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
for index, skill := range _hero.NormalSkill {
|
for index, skill := range _hero.NormalSkill {
|
||||||
skillMaxLv := this.moduleHero.configure.GetHeroSkillMaxLvConfig(uint32(skill.SkillID))
|
skillMaxLv := this.module.configure.GetHeroSkillMaxLvConfig(uint32(skill.SkillID))
|
||||||
if skill.SkillLv < skillMaxLv { // 找到没有满级的技能id
|
if skill.SkillLv < skillMaxLv { // 找到没有满级的技能id
|
||||||
tmpUpSkillID[int32(index)] = skill
|
tmpUpSkillID[int32(index)] = skill
|
||||||
}
|
}
|
||||||
@ -126,18 +116,18 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, agrs map[strin
|
|||||||
_heroMap := map[string]interface{}{
|
_heroMap := map[string]interface{}{
|
||||||
"normalSkill": _hero.NormalSkill,
|
"normalSkill": _hero.NormalSkill,
|
||||||
}
|
}
|
||||||
err = this.moduleHero.hero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
|
err1 = this.module.hero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
|
||||||
if err != nil {
|
if err1 != nil {
|
||||||
log.Errorf("update hero skill failed:%v", err)
|
log.Errorf("update hero skill failed:%v", err)
|
||||||
}
|
}
|
||||||
// 扣除材料
|
// 扣除材料
|
||||||
code = this.moduleHero.DelCard(req.CostCardObj, 1)
|
code = this.module.DelCard(req.CostCardObj, 1)
|
||||||
if code != 0 {
|
if code != pb.ErrorCode_Success {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = this.moduleHero.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
err1 = this.module.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||||
if err != nil {
|
if err1 != nil {
|
||||||
log.Errorf("PushHeroProperty err!")
|
log.Errorf("PushHeroProperty err!")
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -5,67 +5,79 @@ import (
|
|||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
func (this *apiComp) StrengthenUpStarCheck(session comm.IUserSession, req *pb.HeroStrengthenUpStarReq) (result map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) StrengthenUpStarCheck(session comm.IUserSession, req *pb.HeroStrengthenUpStarReq) (code pb.ErrorCode) {
|
||||||
if req.HeroObjID == "" {
|
if req.HeroObjID == "" || len(req.Hero) == 0 || len(req.HeroRace) == 0 {
|
||||||
code.Code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 英雄升星
|
||||||
|
func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStrengthenUpStarReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
var (
|
var (
|
||||||
curLv int32
|
|
||||||
target *cfg.Game_heroStarupData // 配置表目标升星英雄信息
|
target *cfg.Game_heroStarupData // 配置表目标升星英雄信息
|
||||||
raceHero *pb.DBHero // 消耗的阵容英雄
|
raceHero *pb.DBHero // 消耗的阵容英雄
|
||||||
costRaceCount int32
|
costRaceCount int32
|
||||||
curGold int32
|
curGold int32
|
||||||
)
|
)
|
||||||
tagHero, err := this.moduleHero.GetHero(session.GetUserId(), req.HeroObjID)
|
_hero, err := this.module.GetHero(session.GetUserId(), req.HeroObjID)
|
||||||
if err != 0 {
|
defer func() {
|
||||||
code.Code = pb.ErrorCode_HeroNoExist
|
if code == pb.ErrorCode_Success {
|
||||||
|
session.SendMsg(string(this.module.GetType()), StrengthenUpStar, &pb.HeroStrengthenUpStarResp{Hero: _hero})
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if err != pb.ErrorCode_Success {
|
||||||
|
code = pb.ErrorCode_HeroNoExist
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
curLv = tagHero.Lv
|
|
||||||
log.Debugf("curLv:%d", curLv)
|
|
||||||
// 校验指定英雄
|
// 校验指定英雄
|
||||||
tagHeroConfig, err1 := this.moduleHero.configure.GetHeroStarupConfig()
|
tagHeroConfig, err1 := this.module.configure.GetHeroStarupConfig()
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
code.Code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, value := range tagHeroConfig.GetDataList() {
|
for _, value := range tagHeroConfig.GetDataList() {
|
||||||
if tagHero.HeroID == value.Id && tagHero.Star == value.Star && tagHero.Lv == value.Maxlevel { // 找到了 满足升星条件
|
if _hero.HeroID == value.Id && _hero.Star == value.Star && _hero.Lv == value.Maxlevel { // 找到了 满足升星条件
|
||||||
target = value
|
target = value
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if target == nil {
|
||||||
|
code = pb.ErrorCode_ReqParameterError
|
||||||
|
return
|
||||||
|
}
|
||||||
// 指定英雄消耗校验
|
// 指定英雄消耗校验
|
||||||
for _, v := range req.Hero {
|
for _, v := range req.Hero {
|
||||||
if tagHero, err := this.moduleHero.GetHero(session.GetUserId(), v.CostCardObj); err != 0 {
|
if tagHero, err := this.module.GetHero(session.GetUserId(), v.CostCardObj); err != pb.ErrorCode_Success {
|
||||||
code.Code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
if tagHero.SameCount < v.Amount { // 校验数量
|
if tagHero.SameCount < v.Amount { // 校验数量
|
||||||
code.Code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 校验ID
|
// 校验ID
|
||||||
if tagHero.HeroID != target.Needhero && tagHero.Star != target.Needherostar && tagHero.SameCount < target.Needheronum {
|
if tagHero.HeroID != target.Needhero && tagHero.Star != target.Needherostar && tagHero.SameCount < target.Needheronum {
|
||||||
code.Code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 校验阵容英雄消耗
|
// 校验阵容英雄消耗
|
||||||
for _, v := range req.HeroRace {
|
for _, v := range req.HeroRace {
|
||||||
if raceHero, err = this.moduleHero.GetHero(session.GetUserId(), v.CostCardObj); err != 0 {
|
if raceHero, err = this.module.GetHero(session.GetUserId(), v.CostCardObj); err != pb.ErrorCode_Success {
|
||||||
code.Code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
// 校验阵容信息
|
// 校验阵容信息
|
||||||
if raceHero.Star != target.Needracestar {
|
if raceHero.Star != target.Needracestar {
|
||||||
code.Code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
bFind := false
|
bFind := false
|
||||||
@ -76,7 +88,7 @@ func (this *apiComp) StrengthenUpStarCheck(session comm.IUserSession, req *pb.He
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !bFind {
|
if !bFind {
|
||||||
code.Code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,51 +96,27 @@ func (this *apiComp) StrengthenUpStarCheck(session comm.IUserSession, req *pb.He
|
|||||||
costRaceCount += v.Amount
|
costRaceCount += v.Amount
|
||||||
}
|
}
|
||||||
if costRaceCount != target.Needracenum { // 数量不匹配
|
if costRaceCount != target.Needracenum { // 数量不匹配
|
||||||
code.Code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 金币消耗判断
|
// 金币消耗判断
|
||||||
curGold = this.user.QueryAttributeValue(session.GetUserId(), "gold")
|
curGold = this.module.ModuleUser.QueryAttributeValue(session.GetUserId(), "gold")
|
||||||
if curGold < target.Gold { // 金币不足
|
if curGold < target.Gold { // 金币不足
|
||||||
code.Code = pb.ErrorCode_GoldNoEnough
|
code = pb.ErrorCode_GoldNoEnough
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
result = map[string]interface{}{
|
|
||||||
"costGold": target.Gold,
|
|
||||||
"heroObj": tagHero,
|
|
||||||
"curGold": curGold,
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 英雄升星
|
|
||||||
func (this *apiComp) StrengthenUpStar(session comm.IUserSession, agrs map[string]interface{}, req *pb.HeroStrengthenUpStarReq) (code pb.ErrorCode) {
|
|
||||||
|
|
||||||
costGold := agrs["costGold"].(int32)
|
|
||||||
_hero := agrs["heroObj"].(*pb.DBHero)
|
|
||||||
curGold := agrs["curGold"].(int32)
|
|
||||||
if _hero == nil {
|
|
||||||
code = pb.ErrorCode_HeroNoExist
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if code == pb.ErrorCode_Success {
|
|
||||||
session.SendMsg(string(this.moduleHero.GetType()), StrengthenUpStar, &pb.HeroStrengthenUpStarResp{Hero: _hero})
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// 消耗道具
|
// 消耗道具
|
||||||
code = this.user.AddAttributeValue(session.GetUserId(), "gold", curGold-costGold) // 减少金币
|
code = this.module.ModuleUser.AddAttributeValue(session.GetUserId(), "gold", curGold-target.Gold) // 减少金币
|
||||||
if code != pb.ErrorCode_Success {
|
if code != pb.ErrorCode_Success {
|
||||||
log.Errorf("cost gold failed ,count = %d", costGold)
|
log.Errorf("cost gold failed ,count = %d", target.Gold)
|
||||||
code = pb.ErrorCode_GoldNoEnough
|
code = pb.ErrorCode_GoldNoEnough
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 消耗指定英雄
|
// 消耗指定英雄
|
||||||
for _, v := range req.Hero {
|
for _, v := range req.Hero {
|
||||||
code = this.moduleHero.DelCard(v.CostCardObj, v.Amount)
|
code = this.module.DelCard(v.CostCardObj, v.Amount)
|
||||||
if code != 0 {
|
if code != pb.ErrorCode_Success {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
log.Errorf("del hero err card:%s,count = %d", v.CostCardObj, v.Amount)
|
log.Errorf("del hero err card:%s,count = %d", v.CostCardObj, v.Amount)
|
||||||
return
|
return
|
||||||
@ -137,8 +125,8 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, agrs map[string
|
|||||||
|
|
||||||
//消耗种族英雄
|
//消耗种族英雄
|
||||||
for _, v := range req.HeroRace {
|
for _, v := range req.HeroRace {
|
||||||
code = this.moduleHero.DelCard(v.CostCardObj, v.Amount)
|
code = this.module.DelCard(v.CostCardObj, v.Amount)
|
||||||
if code != 0 {
|
if code != pb.ErrorCode_Success {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -148,13 +136,13 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, agrs map[string
|
|||||||
"star": _hero.Star,
|
"star": _hero.Star,
|
||||||
}
|
}
|
||||||
// 保存数据
|
// 保存数据
|
||||||
err := this.moduleHero.hero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap)
|
err1 = this.module.hero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap)
|
||||||
if err != nil {
|
if err1 != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
log.Errorf("update hero skill failed:%v", err)
|
log.Errorf("update hero skill failed:%v", err)
|
||||||
}
|
}
|
||||||
err = this.moduleHero.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
err1 = this.module.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||||
if err != nil {
|
if err1 != nil {
|
||||||
log.Errorf("PushHeroProperty err!")
|
log.Errorf("PushHeroProperty err!")
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -4,65 +4,72 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
func (this *apiComp) StrengthenUplvCheck(session comm.IUserSession, req *pb.HeroStrengthenUplvReq) (result map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) StrengthenUplvCheck(session comm.IUserSession, req *pb.HeroStrengthenUplvReq) (code pb.ErrorCode) {
|
||||||
if req.HeroObjID == "" {
|
if req.HeroObjID == "" || req.ExpCardID == "" || req.Amount <= 0 {
|
||||||
code.Code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 英雄升级
|
||||||
|
func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStrengthenUplvReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
curLv int32
|
curLv int32
|
||||||
curExp int32 // 当前英雄的经验
|
curExp int32 // 当前英雄的经验
|
||||||
costRes int32 // 当前需要消资源的数量
|
costRes int32 // 当前需要消资源的数量
|
||||||
addExp int32 // 需要增加的经验
|
addExp int32 // 需要增加的经验
|
||||||
curGold int32
|
curRes int32
|
||||||
atn = map[string]interface{}{}
|
atn = map[string]interface{}{}
|
||||||
)
|
)
|
||||||
atn = make(map[string]interface{}, 0)
|
atn = make(map[string]interface{}, 0)
|
||||||
|
_hero, err := this.module.GetHero(session.GetUserId(), req.HeroObjID) // 校验升级的对象是否存在
|
||||||
_hero, err := this.moduleHero.GetHero(session.GetUserId(), req.HeroObjID) // 校验升级的对象是否存在
|
|
||||||
|
|
||||||
if err != pb.ErrorCode_Success {
|
if err != pb.ErrorCode_Success {
|
||||||
code.Code = pb.ErrorCode_HeroNoExist
|
code = pb.ErrorCode_HeroNoExist
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_expHero, err := this.moduleHero.GetHero(session.GetUserId(), req.ExpCardID) // 校验需要消耗经验卡牌的对象是否存在
|
_expHero, err := this.module.GetHero(session.GetUserId(), req.ExpCardID) // 校验需要消耗经验卡牌的对象是否存在
|
||||||
|
|
||||||
if err != pb.ErrorCode_Success {
|
if err != pb.ErrorCode_Success {
|
||||||
code.Code = pb.ErrorCode_HeroNoExist
|
code = pb.ErrorCode_HeroNoExist
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if req.Amount <= 0 { // 消耗数量校验
|
if req.Amount <= 0 { // 消耗数量校验
|
||||||
code.Code = pb.ErrorCode_HeroNoExist
|
code = pb.ErrorCode_HeroNoExist
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
curLv = _hero.Lv
|
curLv = _hero.Lv
|
||||||
curExp = _hero.Exp // 当前英雄的经验
|
curExp = _hero.Exp // 当前英雄的经验
|
||||||
addExp = 1000
|
addExp = 1000
|
||||||
// 查询 本次消耗会获得多少经验
|
// 查询 本次消耗会获得多少经验
|
||||||
expConf := this.moduleHero.configure.GetHeroExp(_expHero.HeroID)
|
expConf := this.module.configure.GetHeroExp(_expHero.HeroID)
|
||||||
if expConf != nil {
|
if expConf != nil {
|
||||||
addExp = expConf.Heroexp * req.Amount
|
addExp = expConf.Heroexp * req.Amount
|
||||||
}
|
}
|
||||||
if _expHero.SameCount < req.Amount { // 消耗经验卡片数量不足
|
if _expHero.SameCount < req.Amount { // 消耗经验卡片数量不足
|
||||||
code.Code = pb.ErrorCode_HeroNoEnough
|
code = pb.ErrorCode_HeroNoEnough
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 校验当前能不能升级
|
// 校验当前能不能升级
|
||||||
|
|
||||||
if _hero.Lv >= _hero.Star*comm.HeroStarLvRatio { // 达到最大等级
|
if _hero.Lv >= _hero.Star*comm.HeroStarLvRatio { // 达到最大等级
|
||||||
code.Code = pb.ErrorCode_HeroMaxLv
|
code = pb.ErrorCode_HeroMaxLv
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var maxLv int32 // 校验等级达到上限
|
var maxLv int32 // 校验等级达到上限
|
||||||
maxLv = _hero.Star * comm.HeroStarLvRatio
|
maxLv = _hero.Star * comm.HeroStarLvRatio
|
||||||
_data := this.moduleHero.configure.GetHeroLv(curLv)
|
_data := this.module.configure.GetHeroLv(curLv)
|
||||||
if _data != nil {
|
if _data != nil {
|
||||||
if maxLv <= _hero.Lv && curExp >= _data.Heroexp[0].N { // 加经验之前校验是否达到最大等级
|
if maxLv <= _hero.Lv && curExp >= _data.Heroexp[0].N { // 加经验之前校验是否达到最大等级
|
||||||
code.Code = pb.ErrorCode_HeroMaxLv
|
code = pb.ErrorCode_HeroMaxLv
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
curExp += addExp // 先把经验加上
|
curExp += addExp // 先把经验加上
|
||||||
@ -79,7 +86,7 @@ func (this *apiComp) StrengthenUplvCheck(session comm.IUserSession, req *pb.Hero
|
|||||||
} else { // 升级操作
|
} else { // 升级操作
|
||||||
curExp -= _data.Heroexp[0].N
|
curExp -= _data.Heroexp[0].N
|
||||||
curLv += 1 // 经验够了 那么等级+1
|
curLv += 1 // 经验够了 那么等级+1
|
||||||
_data = this.moduleHero.configure.GetHeroLv(curLv)
|
_data = this.module.configure.GetHeroLv(curLv)
|
||||||
if _data == nil { // 等级加失败了 回到原来的等级
|
if _data == nil { // 等级加失败了 回到原来的等级
|
||||||
curLv -= 1
|
curLv -= 1
|
||||||
break
|
break
|
||||||
@ -92,76 +99,44 @@ func (this *apiComp) StrengthenUplvCheck(session comm.IUserSession, req *pb.Hero
|
|||||||
atn["t"] = v.T
|
atn["t"] = v.T
|
||||||
atn["n"] = v.N
|
atn["n"] = v.N
|
||||||
}
|
}
|
||||||
// 金币消耗判断
|
// 资源消耗判断
|
||||||
curGold = this.user.QueryAttributeValue(session.GetUserId(), atn["t"].(string))
|
curRes = this.module.ModuleUser.QueryAttributeValue(session.GetUserId(), atn["t"].(string))
|
||||||
if curGold < costRes {
|
if curRes < costRes {
|
||||||
code.Code = pb.ErrorCode_GoldNoEnough
|
code = pb.ErrorCode_GoldNoEnough
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
code.Code = pb.ErrorCode_HeroNoExist
|
code = pb.ErrorCode_HeroNoExist
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 校验金币消耗
|
|
||||||
result = map[string]interface{}{
|
|
||||||
"costRes": costRes,
|
|
||||||
"curExp": curExp,
|
|
||||||
"curLv": curLv,
|
|
||||||
"addExp": addExp,
|
|
||||||
"heroObj": _hero,
|
|
||||||
"curRes": curGold,
|
|
||||||
"atn": atn,
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 英雄升级
|
|
||||||
func (this *apiComp) StrengthenUplv(session comm.IUserSession, agrs map[string]interface{}, req *pb.HeroStrengthenUplvReq) (code pb.ErrorCode) {
|
|
||||||
var (
|
|
||||||
curLv int32
|
|
||||||
curExp int32 // 当前英雄的经验
|
|
||||||
costRes int32 // 当前需要消耗金币的数量
|
|
||||||
addExp int32 // 需要增加的经验
|
|
||||||
curRes int32
|
|
||||||
atn = map[string]interface{}{}
|
|
||||||
)
|
|
||||||
|
|
||||||
costRes = agrs["costRes"].(int32)
|
|
||||||
curLv = agrs["curLv"].(int32)
|
|
||||||
curExp = agrs["curExp"].(int32)
|
|
||||||
addExp = agrs["addExp"].(int32)
|
|
||||||
_hero := agrs["heroObj"].(*pb.DBHero)
|
|
||||||
curRes = agrs["curRes"].(int32)
|
|
||||||
atn = agrs["atn"].(map[string]interface{})
|
|
||||||
if _hero == nil {
|
if _hero == nil {
|
||||||
code = pb.ErrorCode_HeroNoExist
|
code = pb.ErrorCode_HeroNoExist
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if code == pb.ErrorCode_Success {
|
if code == pb.ErrorCode_Success {
|
||||||
session.SendMsg(string(this.moduleHero.GetType()), StrengthenUplv, &pb.HeroStrengthenUplvResp{Hero: _hero})
|
session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.HeroStrengthenUplvResp{Hero: _hero})
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
log.Debugf("升级后当前等级: %d,经验: %d,需要消耗的金币: %d,增加的经验: %d", curLv, curExp, costRes, addExp)
|
log.Debugf("升级后当前等级: %d,经验: %d,需要消耗的金币: %d,增加的经验: %d", curLv, curExp, costRes, addExp)
|
||||||
// 执行升级逻辑
|
// 执行升级逻辑
|
||||||
code = this.moduleHero.AddCardExp(session.GetUserId(), req.HeroObjID, addExp) // 加经验
|
code = this.module.AddCardExp(session.GetUserId(), req.HeroObjID, addExp) // 加经验
|
||||||
if code != pb.ErrorCode_Success {
|
if code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 消耗道具
|
// 消耗道具
|
||||||
code = this.user.AddAttributeValue(session.GetUserId(), atn["t"].(string), int32(curRes-costRes)) // 减少金币
|
code = this.module.ModuleUser.AddAttributeValue(session.GetUserId(), atn["t"].(string), int32(curRes-costRes)) // 减少金币
|
||||||
if code != pb.ErrorCode_Success {
|
if code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 删除经验卡
|
// 删除经验卡
|
||||||
err := this.moduleHero.hero.consumeOneHeroCard(session.GetUserId(), req.ExpCardID, req.Amount)
|
err1 := this.module.hero.consumeOneHeroCard(session.GetUserId(), req.ExpCardID, req.Amount)
|
||||||
if err != nil {
|
if err1 != nil {
|
||||||
log.Errorf("delete err failed err:%T!", err)
|
log.Errorf("delete err failed err:%T!", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = this.moduleHero.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
err1 = this.module.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||||
if err != nil {
|
if err1 != nil {
|
||||||
log.Errorf("PushHeroProperty err!")
|
log.Errorf("PushHeroProperty err!")
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -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)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,15 +4,17 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
func (this *apiComp) DelMailCheck(session comm.IUserSession, req *pb.MailDelMailReq) (result map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) DelMailCheck(session comm.IUserSession, req *pb.MailDelMailReq) (code pb.ErrorCode) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除邮件
|
// 删除邮件
|
||||||
func (this *apiComp) DelMail(session comm.IUserSession, agrs map[string]interface{}, req *pb.MailDelMailReq) (code pb.ErrorCode) {
|
func (this *apiComp) DelMail(session comm.IUserSession, req *pb.MailDelMailReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
var err error
|
var err error
|
||||||
mailinfo := make([]*pb.DBMailData, 0)
|
mailinfo := make([]*pb.DBMailData, 0)
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -3,14 +3,16 @@ package mail
|
|||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
|
"github.com/golang/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (this *apiComp) GetUserMailAttachmentCheck(session comm.IUserSession, req *pb.MailGetUserMailAttachmentReq) (result map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) GetUserMailAttachmentCheck(session comm.IUserSession, req *pb.MailGetUserMailAttachmentReq) (code pb.ErrorCode) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 领取附件
|
// 领取附件
|
||||||
func (this *apiComp) GetUserMailAttachment(session comm.IUserSession, agrs map[string]interface{}, req *pb.MailGetUserMailAttachmentReq) (code pb.ErrorCode) {
|
func (this *apiComp) GetUserMailAttachment(session comm.IUserSession, req *pb.MailGetUserMailAttachmentReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
mail *pb.DBMailData
|
mail *pb.DBMailData
|
||||||
|
@ -4,14 +4,16 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
|
"github.com/golang/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.MailGetListReq) (result map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.MailGetListReq) (code pb.ErrorCode) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查看所有邮件信息
|
// 查看所有邮件信息
|
||||||
func (this *apiComp) GetList(session comm.IUserSession, agrs map[string]interface{}, req *pb.MailGetListReq) (code pb.ErrorCode) {
|
func (this *apiComp) GetList(session comm.IUserSession, req *pb.MailGetListReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
mailinfo := make([]*pb.DBMailData, 0)
|
mailinfo := make([]*pb.DBMailData, 0)
|
||||||
|
@ -3,14 +3,16 @@ package mail
|
|||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
|
"github.com/golang/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (this *apiComp) ReadMailCheck(session comm.IUserSession, req *pb.MailReadMailReq) (result map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) ReadMailCheck(session comm.IUserSession, req *pb.MailReadMailReq) (code pb.ErrorCode) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查看某一封邮件
|
// 查看某一封邮件
|
||||||
func (this *apiComp) ReadMail(session comm.IUserSession, agrs map[string]interface{}, req *pb.MailReadMailReq) (code pb.ErrorCode) {
|
func (this *apiComp) ReadMail(session comm.IUserSession, req *pb.MailReadMailReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
mail *pb.DBMailData
|
mail *pb.DBMailData
|
||||||
|
@ -4,22 +4,21 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (this *apiComp) CreateCheck(session comm.IUserSession, req *pb.UserCreateReq) (result map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) CreateCheck(session comm.IUserSession, req *pb.UserCreateReq) (code pb.ErrorCode) {
|
||||||
result = make(map[string]interface{})
|
if req.NickName == "" {
|
||||||
self := &pb.DBUser{}
|
code = pb.ErrorCode_ReqParameterError
|
||||||
err := this.module.modelUser.Get(session.GetUserId(), self)
|
|
||||||
if err != nil {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_DBError}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
result["self"] = self
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//创角
|
//创角
|
||||||
func (this *apiComp) Create(session comm.IUserSession, result map[string]interface{}, req *pb.UserCreateReq) (code pb.ErrorCode) {
|
func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
|
var err error
|
||||||
defer utils.TraceFunc(session.GetUserId(), string(this.module.GetType()), UserSubTypeCreate, req, nil)
|
defer utils.TraceFunc(session.GetUserId(), string(this.module.GetType()), UserSubTypeCreate, req, nil)
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -29,13 +28,12 @@ func (this *apiComp) Create(session comm.IUserSession, result map[string]interfa
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if self, ok := result["self"]; ok {
|
self := &pb.DBUser{}
|
||||||
v := self.(*pb.DBUser)
|
err = this.module.modelUser.Get(session.GetUserId(), self)
|
||||||
if v.Created {
|
if err != nil {
|
||||||
code = pb.ErrorCode_RoleCreated
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
update := map[string]interface{}{
|
update := map[string]interface{}{
|
||||||
"name": req.NickName,
|
"name": req.NickName,
|
||||||
@ -47,7 +45,7 @@ func (this *apiComp) Create(session comm.IUserSession, result map[string]interfa
|
|||||||
update["gold"] = val
|
update["gold"] = val
|
||||||
}
|
}
|
||||||
|
|
||||||
err := this.module.modelUser.Change(session.GetUserId(), update)
|
err = this.module.modelUser.Change(session.GetUserId(), update)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
|
@ -9,16 +9,17 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
func (this *apiComp) LoginCheck(session comm.IUserSession, req *pb.UserLoginReq) (result map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) LoginCheck(session comm.IUserSession, req *pb.UserLoginReq) (code pb.ErrorCode) {
|
||||||
result = map[string]interface{}{}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//登录
|
//登录
|
||||||
func (this *apiComp) Login(session comm.IUserSession, result map[string]interface{}, req *pb.UserLoginReq) (code pb.ErrorCode) {
|
func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
user *pb.DBUser
|
user *pb.DBUser
|
||||||
|
@ -3,20 +3,18 @@ package user
|
|||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (this *apiComp) AddResCheck(session comm.IUserSession, req *pb.UserAddResReq) (result map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) AddResCheck(session comm.IUserSession, req *pb.UserAddResReq) (code pb.ErrorCode) {
|
||||||
result = make(map[string]interface{})
|
if req.ResType == "" || req.Count <= 0 {
|
||||||
user := this.module.modelUser.getUser(session.GetUserId())
|
code = pb.ErrorCode_ReqParameterError
|
||||||
if user == nil {
|
|
||||||
code = comm.ErrorCode{Code: pb.ErrorCode_UserSessionNobeing}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
result["user"] = user
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *apiComp) AddRes(session comm.IUserSession, result map[string]interface{}, req *pb.UserAddResReq) (code pb.ErrorCode) {
|
func (this *apiComp) AddRes(session comm.IUserSession, req *pb.UserAddResReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
rsp := &pb.UserAddResResp{}
|
rsp := &pb.UserAddResResp{}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -26,8 +24,12 @@ func (this *apiComp) AddRes(session comm.IUserSession, result map[string]interfa
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if u, ok := result["user"]; ok {
|
user := this.module.modelUser.GetUser(session.GetUserId())
|
||||||
user := u.(*pb.DBUser)
|
if user == nil {
|
||||||
|
code = pb.ErrorCode_UserSessionNobeing
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
count := req.Count
|
count := req.Count
|
||||||
|
|
||||||
switch req.ResType {
|
switch req.ResType {
|
||||||
@ -43,7 +45,6 @@ func (this *apiComp) AddRes(session comm.IUserSession, result map[string]interfa
|
|||||||
|
|
||||||
rsp.ResType = req.ResType
|
rsp.ResType = req.ResType
|
||||||
rsp.Count = count
|
rsp.Count = count
|
||||||
}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -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
|
|
||||||
}
|
|
@ -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)
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user