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,
|
||||
req: &pb.FriendListReq{},
|
||||
rsp: &pb.FriendListRsp{},
|
||||
enabled: true,
|
||||
// enabled: true,
|
||||
}, {
|
||||
//blacklist
|
||||
mainType: string(comm.ModuleFriend),
|
||||
@ -36,7 +36,7 @@ var (
|
||||
subType: friend.FriendSubTypeApply,
|
||||
req: &pb.FriendApplyReq{},
|
||||
rsp: &pb.FriendApplyRsp{},
|
||||
enabled: true,
|
||||
// enabled: true,
|
||||
}, {
|
||||
//applylist
|
||||
mainType: string(comm.ModuleFriend),
|
||||
@ -60,9 +60,10 @@ var (
|
||||
mainType: string(comm.ModuleFriend),
|
||||
subType: friend.FriendSubTypeAddBlack,
|
||||
req: &pb.FriendBlackAddReq{
|
||||
FriendId: "",
|
||||
FriendId: "0_62be9f40f67327fb53039b70",
|
||||
},
|
||||
rsp: &pb.FriendBlackAddRsp{},
|
||||
rsp: &pb.FriendBlackAddRsp{},
|
||||
enabled: true,
|
||||
}, {
|
||||
//delblack
|
||||
mainType: string(comm.ModuleFriend),
|
||||
|
@ -164,7 +164,7 @@ func (r *Robot) onUserLoaded() {
|
||||
//hero
|
||||
r.RunHero()
|
||||
//friend
|
||||
// r.RunFriend()
|
||||
r.RunFriend()
|
||||
|
||||
//pack
|
||||
// r.RunPack()
|
||||
|
@ -17,7 +17,7 @@ var user_builders = []*builder{
|
||||
NickName: "乐谷6301",
|
||||
},
|
||||
rsp: &pb.UserCreateRsp{},
|
||||
enabled: true,
|
||||
// enabled: true,
|
||||
}, {
|
||||
desc: "添加资源",
|
||||
mainType: string(comm.ModuleUser),
|
||||
@ -27,7 +27,7 @@ var user_builders = []*builder{
|
||||
Count: 100,
|
||||
},
|
||||
rsp: &pb.UserAddResResp{},
|
||||
enabled: true,
|
||||
// enabled: true,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -66,9 +66,13 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
PropertyHp string = "hp" //生命
|
||||
PropertyAtk string = "atk" //攻击
|
||||
PropertyDef string = "def" //防御
|
||||
Hp string = "hp" //生命
|
||||
Atk string = "atk" //攻击
|
||||
Def string = "def" //防御
|
||||
HpPro string = "hppro" //生命附加值
|
||||
AtkPro string = "atkpro" //攻击附加值
|
||||
DefPro string = "defpro" //防御附加值
|
||||
Speed string = "speed" //速度
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -51,6 +51,7 @@ type (
|
||||
|
||||
//玩家
|
||||
IUser interface {
|
||||
GetUser(uid string) *pb.DBUser
|
||||
//查询用户属性值 例如 金币 经验
|
||||
QueryAttributeValue(uid string, attr string) (value int32)
|
||||
//添加/减少属性值
|
||||
|
@ -3,7 +3,7 @@ package dbservice
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/lego/core/cbase"
|
||||
)
|
||||
|
||||
func NewModule() core.IModule {
|
||||
@ -12,7 +12,7 @@ func NewModule() core.IModule {
|
||||
}
|
||||
|
||||
type DBService struct {
|
||||
modules.ModuleBase
|
||||
cbase.ModuleBase
|
||||
db_comp *DB_Comp
|
||||
}
|
||||
|
||||
|
@ -4,64 +4,24 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"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) {
|
||||
chk = make(map[string]interface{})
|
||||
var (
|
||||
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
|
||||
func (this *apiComp) AddblackCheck(session comm.IUserSession, req *pb.FriendBlackAddReq) (code pb.ErrorCode) {
|
||||
if req.FriendId == "" {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
//加入黑名单
|
||||
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 (
|
||||
self *pb.DBFriend
|
||||
rsp *pb.FriendBlackAddRsp
|
||||
err error
|
||||
self *pb.DBFriend
|
||||
target *pb.DBFriend
|
||||
rsp *pb.FriendBlackAddRsp
|
||||
)
|
||||
|
||||
defer func() {
|
||||
@ -72,19 +32,52 @@ func (this *apiComp) Addblack(session comm.IUserSession, chk map[string]interfac
|
||||
session.SendMsg(string(this.module.GetType()), FriendSubTypeAddBlack, rsp)
|
||||
}()
|
||||
|
||||
if v, ok := chk["self"]; ok {
|
||||
self = v.(*pb.DBFriend)
|
||||
//将目标加入黑名单
|
||||
self.BlackIds = append(self.BlackIds, req.FriendId)
|
||||
self = this.module.modelFriend.GetFriend(session.GetUserId())
|
||||
if self == nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
return
|
||||
}
|
||||
|
||||
//更新黑名单
|
||||
err := this.module.modelFriend.Change(self.UId, map[string]interface{}{
|
||||
"blackIds": self.BlackIds,
|
||||
})
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
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)
|
||||
|
||||
//更新黑名单
|
||||
err = this.module.modelFriend.Change(self.UId, map[string]interface{}{
|
||||
"blackIds": self.BlackIds,
|
||||
})
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -4,39 +4,24 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"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) {
|
||||
chk = make(map[string]interface{})
|
||||
var err error
|
||||
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
|
||||
func (this *apiComp) AgreeCheck(session comm.IUserSession, req *pb.FriendAgreeReq) (code pb.ErrorCode) {
|
||||
if len(req.FriendIds) == 0 {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
|
||||
//同意的好友
|
||||
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
|
||||
}
|
||||
|
||||
//单个/批量同意
|
||||
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 (
|
||||
err error
|
||||
self *pb.DBFriend
|
||||
target *pb.DBFriend
|
||||
rsp *pb.FriendAgreeRsp
|
||||
optNum int32
|
||||
)
|
||||
@ -52,57 +37,63 @@ 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
|
||||
} else {
|
||||
self = v.(*pb.DBFriend)
|
||||
}
|
||||
|
||||
if agreeIds, ok := chk["agreeIds"]; ok {
|
||||
//将目标加入到自己的好友列表中
|
||||
for _, userId := range agreeIds.([]string) {
|
||||
if _, ok := utils.Find(self.FriendIds, userId); !ok {
|
||||
if self.FriendIds == nil {
|
||||
self.FriendIds = []string{}
|
||||
}
|
||||
self.FriendIds = append(self.FriendIds, userId)
|
||||
}
|
||||
|
||||
//双向添加:将自己加入到申请人的好友列表中
|
||||
target := &pb.DBFriend{}
|
||||
err := this.module.modelFriend.Get(userId, target)
|
||||
if target == nil || err != nil {
|
||||
code = pb.ErrorCode_FriendTargetNoData
|
||||
//同意的好友
|
||||
agreeIds := []string{}
|
||||
for _, friendId := range req.FriendIds {
|
||||
if _, ok := utils.Find(self.FriendIds, friendId); !ok {
|
||||
//不在好友列表中就加入
|
||||
agreeIds = append(agreeIds, friendId)
|
||||
}
|
||||
}
|
||||
|
||||
//将目标加入到自己的好友列表中
|
||||
for _, userId := range agreeIds {
|
||||
if _, ok := utils.Find(self.FriendIds, userId); !ok {
|
||||
if self.FriendIds == nil {
|
||||
self.FriendIds = []string{}
|
||||
}
|
||||
if _, ok := utils.Find(target.FriendIds, self.UId); !ok {
|
||||
if target.FriendIds == nil {
|
||||
target.FriendIds = []string{}
|
||||
}
|
||||
target.FriendIds = append(target.FriendIds, self.UId)
|
||||
}
|
||||
err = this.module.modelFriend.Change(target.UId, map[string]interface{}{
|
||||
"friendIds": target.FriendIds,
|
||||
})
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
}
|
||||
|
||||
//将目标从申请列表中删除
|
||||
self.ApplyIds = utils.DeleteString(self.ApplyIds, userId)
|
||||
optNum++
|
||||
self.FriendIds = append(self.FriendIds, userId)
|
||||
}
|
||||
|
||||
//更新
|
||||
err := this.module.modelFriend.Change(self.UId, map[string]interface{}{
|
||||
"applyIds": self.ApplyIds,
|
||||
"friendIds": self.FriendIds,
|
||||
//双向添加:将自己加入到申请人的好友列表中
|
||||
target = this.module.modelFriend.GetFriend(userId)
|
||||
if target == nil {
|
||||
code = pb.ErrorCode_FriendTargetNoData
|
||||
return
|
||||
}
|
||||
if _, ok := utils.Find(target.FriendIds, self.UId); !ok {
|
||||
if target.FriendIds == nil {
|
||||
target.FriendIds = []string{}
|
||||
}
|
||||
target.FriendIds = append(target.FriendIds, self.UId)
|
||||
}
|
||||
err = this.module.modelFriend.Change(target.UId, map[string]interface{}{
|
||||
"friendIds": target.FriendIds,
|
||||
})
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
|
||||
//将目标从申请列表中删除
|
||||
self.ApplyIds = utils.DeleteString(self.ApplyIds, userId)
|
||||
optNum++
|
||||
}
|
||||
|
||||
//更新
|
||||
err = this.module.modelFriend.Change(self.UId, map[string]interface{}{
|
||||
"applyIds": self.ApplyIds,
|
||||
"friendIds": self.FriendIds,
|
||||
})
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -5,82 +5,22 @@ import (
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/pb"
|
||||
"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) {
|
||||
chk = make(map[string]interface{})
|
||||
var err error
|
||||
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
|
||||
func (this *apiComp) ApplyCheck(session comm.IUserSession, req *pb.FriendApplyReq) (code pb.ErrorCode) {
|
||||
if req.FriendId == "" {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
|
||||
//获取好友数据
|
||||
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
|
||||
}
|
||||
|
||||
//好友申请
|
||||
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 (
|
||||
err error
|
||||
self *pb.DBFriend
|
||||
target *pb.DBFriend
|
||||
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
|
||||
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())
|
||||
|
||||
err := this.module.modelFriend.Change(req.FriendId, map[string]interface{}{
|
||||
err = this.module.modelFriend.Change(req.FriendId, map[string]interface{}{
|
||||
"applyIds": target.ApplyIds,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -5,21 +5,15 @@ import (
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
|
||||
func (this *apiComp) ApplyListCheck(session comm.IUserSession, req *pb.FriendApplyListReq) (chk map[string]interface{}, code comm.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
|
||||
func (this *apiComp) ApplyListCheck(session comm.IUserSession, req *pb.FriendApplyListReq) (code pb.ErrorCode) {
|
||||
|
||||
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 (
|
||||
err error
|
||||
self *pb.DBFriend
|
||||
rsp *pb.FriendApplyListRsp
|
||||
list []*pb.FriendBase
|
||||
@ -31,17 +25,22 @@ func (this *apiComp) ApplyList(session comm.IUserSession, chk map[string]interfa
|
||||
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 = v.(*pb.DBFriend)
|
||||
for _, userId := range self.ApplyIds {
|
||||
//TODO 组装FriendBase明细数据
|
||||
list = append(list, &pb.FriendBase{
|
||||
UserId: userId,
|
||||
})
|
||||
}
|
||||
self = this.module.modelFriend.GetFriend(session.GetUserId())
|
||||
if self == nil || err != nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
return
|
||||
}
|
||||
|
||||
for _, userId := range self.ApplyIds {
|
||||
//TODO 组装FriendBase明细数据
|
||||
list = append(list, &pb.FriendBase{
|
||||
UserId: userId,
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -3,23 +3,18 @@ package friend
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"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) {
|
||||
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
|
||||
func (this *apiComp) BlacklistCheck(session comm.IUserSession, req *pb.FriendBlackListReq) (code pb.ErrorCode) {
|
||||
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 (
|
||||
err error
|
||||
self *pb.DBFriend
|
||||
rsp *pb.FriendBlackListRsp
|
||||
list []*pb.FriendBase
|
||||
@ -37,14 +32,17 @@ func (this *apiComp) Blacklist(session comm.IUserSession, chk map[string]interfa
|
||||
}
|
||||
}()
|
||||
|
||||
if v, ok := chk["self"]; ok {
|
||||
self = v.(*pb.DBFriend)
|
||||
for _, userId := range self.BlackIds {
|
||||
//TODO 完善FriendBase信息
|
||||
list = append(list, &pb.FriendBase{
|
||||
UserId: userId,
|
||||
})
|
||||
}
|
||||
self = this.module.modelFriend.GetFriend(session.GetUserId())
|
||||
if self == nil || err != nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
return
|
||||
}
|
||||
|
||||
for _, userId := range self.BlackIds {
|
||||
//TODO 完善FriendBase信息
|
||||
list = append(list, &pb.FriendBase{
|
||||
UserId: userId,
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -4,23 +4,21 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"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) {
|
||||
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
|
||||
func (this *apiComp) DelblackCheck(session comm.IUserSession, req *pb.FriendDelBlackReq) (code pb.ErrorCode) {
|
||||
if req.FriendId == "" {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
chk["self"] = self
|
||||
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 (
|
||||
err error
|
||||
self *pb.DBFriend
|
||||
rsp *pb.FriendDelBlackRsp
|
||||
)
|
||||
@ -38,18 +36,21 @@ func (this *apiComp) Delblack(session comm.IUserSession, chk map[string]interfac
|
||||
}
|
||||
}()
|
||||
|
||||
if v, ok := chk["self"]; ok {
|
||||
self = v.(*pb.DBFriend)
|
||||
//从黑名单列表中删除目标
|
||||
self.BlackIds = utils.DeleteString(self.BlackIds, req.FriendId)
|
||||
//更新黑名单
|
||||
err := this.module.modelFriend.Change(self.UId, map[string]interface{}{
|
||||
"blackIds": self.BlackIds,
|
||||
})
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
self = this.module.modelFriend.GetFriend(session.GetUserId())
|
||||
if self == nil || err != nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
return
|
||||
}
|
||||
|
||||
//从黑名单列表中删除目标
|
||||
self.BlackIds = utils.DeleteString(self.BlackIds, req.FriendId)
|
||||
//更新黑名单
|
||||
err = this.module.modelFriend.Change(self.UId, map[string]interface{}{
|
||||
"blackIds": self.BlackIds,
|
||||
})
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -3,22 +3,16 @@ package friend
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"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) {
|
||||
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
|
||||
func (this *apiComp) ListCheck(session comm.IUserSession, req *pb.FriendListReq) (code pb.ErrorCode) {
|
||||
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 (
|
||||
self *pb.DBFriend
|
||||
rsp *pb.FriendListRsp
|
||||
@ -36,13 +30,16 @@ func (this *apiComp) List(session comm.IUserSession, chk map[string]interface{},
|
||||
}
|
||||
}()
|
||||
|
||||
if v, ok := chk["self"]; ok {
|
||||
self = v.(*pb.DBFriend)
|
||||
for _, userId := range self.FriendIds {
|
||||
list = append(list, &pb.FriendBase{
|
||||
UserId: userId,
|
||||
})
|
||||
}
|
||||
self = this.module.modelFriend.GetFriend(session.GetUserId())
|
||||
if self == nil {
|
||||
code = pb.ErrorCode_FriendSelfNoData
|
||||
return
|
||||
}
|
||||
|
||||
for _, userId := range self.FriendIds {
|
||||
list = append(list, &pb.FriendBase{
|
||||
UserId: userId,
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -4,38 +4,23 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"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) {
|
||||
chk = make(map[string]interface{})
|
||||
var err error
|
||||
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
|
||||
func (this *apiComp) RefuseCheck(session comm.IUserSession, req *pb.FriendRefuseReq) (code pb.ErrorCode) {
|
||||
if len(req.FriendIds) == 0 {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
|
||||
//拒绝的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
|
||||
}
|
||||
|
||||
//单个/批量拒绝
|
||||
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 (
|
||||
err error
|
||||
self *pb.DBFriend
|
||||
rsp *pb.FriendRefuseRsp
|
||||
optNum int32
|
||||
@ -52,30 +37,36 @@ 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
|
||||
} else {
|
||||
self = v.(*pb.DBFriend)
|
||||
|
||||
if v, ok := chk["refuseIds"]; ok {
|
||||
//将申请人从申请列表中删除
|
||||
for _, userId := range v.([]string) {
|
||||
self.ApplyIds = utils.DeleteString(self.ApplyIds, userId)
|
||||
optNum++
|
||||
}
|
||||
//更新
|
||||
if optNum > 0 {
|
||||
err := this.module.modelFriend.Change(self.UId, map[string]interface{}{
|
||||
"applyIds": self.ApplyIds,
|
||||
})
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//拒绝的Ids
|
||||
refuseIds := []string{}
|
||||
for _, friendId := range req.FriendIds {
|
||||
if _, ok := utils.Find(self.ApplyIds, friendId); ok {
|
||||
refuseIds = append(refuseIds, friendId)
|
||||
}
|
||||
}
|
||||
|
||||
//将申请人从申请列表中删除
|
||||
for _, userId := range refuseIds {
|
||||
self.ApplyIds = utils.DeleteString(self.ApplyIds, userId)
|
||||
optNum++
|
||||
}
|
||||
//更新
|
||||
if optNum > 0 {
|
||||
err := this.module.modelFriend.Change(self.UId, map[string]interface{}{
|
||||
"applyIds": self.ApplyIds,
|
||||
})
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -3,9 +3,11 @@ package friend
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"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 == "" {
|
||||
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSearchNameEmpty}
|
||||
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 (
|
||||
rsp *pb.FriendSearchRsp
|
||||
friend *pb.FriendBase
|
||||
@ -25,7 +27,9 @@ func (this *apiComp) Search(session comm.IUserSession, chk map[string]interface{
|
||||
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)
|
||||
|
@ -3,6 +3,7 @@ package friend
|
||||
import (
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/lego/sys/redis"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
@ -35,3 +36,16 @@ func (this *ModelFriend) Frined_FindCond(nickName string) *pb.DBUser {
|
||||
}
|
||||
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/lego/core"
|
||||
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
func NewModule() core.IModule {
|
||||
@ -16,6 +18,7 @@ type Friend struct {
|
||||
modules.ModuleBase
|
||||
api *apiComp
|
||||
modelFriend *ModelFriend
|
||||
configure *modules.MCompConfigure
|
||||
}
|
||||
|
||||
func (this *Friend) GetType() core.M_Modules {
|
||||
@ -33,3 +36,19 @@ func (this *Friend) OnInstallComp() {
|
||||
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||
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,16 +1,14 @@
|
||||
package hero
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
)
|
||||
|
||||
type apiComp struct {
|
||||
modules.MCompGate
|
||||
service core.IService
|
||||
moduleHero *Hero
|
||||
user comm.IUser
|
||||
service core.IService
|
||||
module *Hero
|
||||
}
|
||||
|
||||
const ( //消息回复的头名称
|
||||
@ -29,7 +27,7 @@ const ( //消息回复的头名称
|
||||
//组件初始化接口
|
||||
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)
|
||||
this.moduleHero = module.(*Hero)
|
||||
this.module = module.(*Hero)
|
||||
this.service = service
|
||||
return
|
||||
}
|
||||
@ -37,12 +35,5 @@ func (this *apiComp) Init(service core.IService, module core.IModule, comp core.
|
||||
func (this *apiComp) Start() (err error) {
|
||||
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
|
||||
}
|
||||
|
@ -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 == "" {
|
||||
code.Code = pb.ErrorCode_ReqParameterError
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
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 (
|
||||
awakenData *cfg.Game_heroAwakenData
|
||||
bCheckOk bool
|
||||
@ -29,13 +29,13 @@ func (this *apiComp) Awaken(session comm.IUserSession, agrs map[string]interface
|
||||
)
|
||||
costRes = make(map[string]int32, 0)
|
||||
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 {
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
return
|
||||
}
|
||||
AwakenConfig, err1 := this.moduleHero.configure.GetHeroAwakenConfig()
|
||||
AwakenConfig, err1 := this.module.configure.GetHeroAwakenConfig()
|
||||
if err1 != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
@ -53,7 +53,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, agrs map[string]interface
|
||||
// 参数校验
|
||||
for _, v := range awakenData.Phaseneed {
|
||||
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 {
|
||||
bCheckOk = false
|
||||
break
|
||||
@ -62,7 +62,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, agrs map[string]interface
|
||||
} else if v.A == "item" { //消耗道具
|
||||
itemid, err := strconv.Atoi(v.T)
|
||||
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) {
|
||||
bCheckOk = false
|
||||
break
|
||||
@ -80,14 +80,14 @@ func (this *apiComp) Awaken(session comm.IUserSession, agrs map[string]interface
|
||||
}
|
||||
defer func() {
|
||||
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 {
|
||||
if v.A == "attr" { // 消耗玩家身上资源
|
||||
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 {
|
||||
return
|
||||
}
|
||||
@ -96,7 +96,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, agrs map[string]interface
|
||||
} else if v.A == "item" { //消耗道具
|
||||
itemid, err := strconv.Atoi(v.T)
|
||||
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 {
|
||||
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 {
|
||||
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{}
|
||||
|
||||
defer func() {
|
||||
err := session.SendMsg(string(this.moduleHero.GetType()), HeroSubTypeChouka, rsp)
|
||||
err := session.SendMsg(string(this.module.GetType()), HeroSubTypeChouka, rsp)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
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
|
||||
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
|
||||
return
|
||||
}
|
||||
|
||||
heroes, err := this.moduleHero.hero.getHeroList(session.GetUserId())
|
||||
heroes, err := this.module.hero.getHeroList(session.GetUserId())
|
||||
if err != nil {
|
||||
log.Errorf("%v", err)
|
||||
code = pb.ErrorCode_DBError
|
||||
|
@ -4,32 +4,32 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"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) {
|
||||
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
|
||||
func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.HeroInfoReq) (code pb.ErrorCode) {
|
||||
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{}
|
||||
defer func() {
|
||||
err := session.SendMsg(string(this.moduleHero.GetType()), HeroSubTypeInfo, rsp)
|
||||
err := session.SendMsg(string(this.module.GetType()), HeroSubTypeInfo, rsp)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
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 {
|
||||
rsp.Base = v.(*pb.DBHero)
|
||||
hero := this.module.hero.getOneHero(session.GetUserId(), req.HeroId)
|
||||
if hero == nil {
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
}
|
||||
|
||||
rsp.Base = hero
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -4,25 +4,27 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"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
|
||||
}
|
||||
|
||||
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{}
|
||||
|
||||
defer func() {
|
||||
err := session.SendMsg(string(this.moduleHero.GetType()), HeroSubTypeList, rsp)
|
||||
err := session.SendMsg(string(this.module.GetType()), HeroSubTypeList, rsp)
|
||||
if err != nil {
|
||||
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 {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
|
@ -5,39 +5,48 @@ import (
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/pb"
|
||||
"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 == "" {
|
||||
code.Code = pb.ErrorCode_ReqParameterError
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
}
|
||||
var (
|
||||
bCheckOk bool
|
||||
)
|
||||
bCheckOk = false
|
||||
_hero, err := this.moduleHero.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在
|
||||
if err != 0 {
|
||||
code.Code = pb.ErrorCode_HeroNoExist
|
||||
return
|
||||
}
|
||||
|
||||
/// 英雄共鸣
|
||||
func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceReq) (code pb.ErrorCode, data proto.Message) {
|
||||
|
||||
bCheckOk := true
|
||||
_hero, code := this.module.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
_costHero, err := this.moduleHero.GetHero(session.GetUserId(), req.CostObjID) // 查询消耗卡是否存在
|
||||
if err != 0 {
|
||||
code.Code = pb.ErrorCode_HeroNoExist
|
||||
defer func() {
|
||||
if code == pb.ErrorCode_Success {
|
||||
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
|
||||
}
|
||||
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 {
|
||||
code.Code = pb.ErrorCode_ConfigNoFound
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
if resonConfig.Maxnum >= _hero.ResonateNum {
|
||||
code.Code = pb.ErrorCode_HeroMaxResonate // 共鸣次数已满
|
||||
code = pb.ErrorCode_HeroMaxResonate // 共鸣次数已满
|
||||
return
|
||||
}
|
||||
|
||||
@ -45,7 +54,7 @@ func (this *apiComp) ResonanceCheck(session comm.IUserSession, req *pb.HeroReson
|
||||
for _, v := range resonConfig.Need {
|
||||
if v.A == "hero" && v.T == strconv.Itoa(int(_costHero.HeroID)) {
|
||||
if req.Amount != v.N {
|
||||
code.Code = pb.ErrorCode_ReqParameterError
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
} else {
|
||||
bCheckOk = true
|
||||
@ -54,60 +63,37 @@ func (this *apiComp) ResonanceCheck(session comm.IUserSession, req *pb.HeroReson
|
||||
}
|
||||
}
|
||||
if !bCheckOk { // 配置校验不通过
|
||||
code.Code = pb.ErrorCode_HeroNoEnough
|
||||
code = pb.ErrorCode_HeroNoEnough
|
||||
return
|
||||
}
|
||||
bCheckOk = false
|
||||
bCheckOk = true
|
||||
// 金币校验
|
||||
for _, v := range resonConfig.Need {
|
||||
if v.A == "attr" { // 查询玩家身上资源是否满足
|
||||
value := this.user.QueryAttributeValue(session.GetUserId(), v.T)
|
||||
if value >= v.N {
|
||||
bCheckOk = true // 财富校验通过
|
||||
break
|
||||
value := this.module.ModuleUser.QueryAttributeValue(session.GetUserId(), v.T)
|
||||
if value < v.N {
|
||||
code = pb.ErrorCode_ResNoEnough
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
if !bCheckOk { // 配置校验不通过
|
||||
code.Code = pb.ErrorCode_ResNoEnough
|
||||
return
|
||||
}
|
||||
result = map[string]interface{}{
|
||||
"heroObj": _hero,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
/// 英雄共鸣
|
||||
func (this *apiComp) Resonance(session comm.IUserSession, agrs map[string]interface{}, req *pb.HeroResonanceReq) (code pb.ErrorCode) {
|
||||
_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 = this.module.DelCard(req.CostObjID, req.Amount)
|
||||
if code != pb.ErrorCode_Success {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
|
||||
resonConfig, err1 := this.moduleHero.configure.GetHeroResonanceConfig(_hero.HeroID)
|
||||
resonConfig, err1 := this.module.configure.GetHeroResonanceConfig(_hero.HeroID)
|
||||
if err1 != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
for _, v := range resonConfig.Need {
|
||||
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 { // 直接删除财富
|
||||
code = this.user.AddAttributeValue(session.GetUserId(), v.T, value-v.N) // 扣除资源
|
||||
code = this.module.ModuleUser.AddAttributeValue(session.GetUserId(), v.T, value-v.N) // 扣除资源
|
||||
break
|
||||
} else {
|
||||
code = pb.ErrorCode_ResNoEnough
|
||||
@ -118,9 +104,9 @@ func (this *apiComp) Resonance(session comm.IUserSession, agrs map[string]interf
|
||||
_heroMap := map[string]interface{}{
|
||||
"resonateNum": _hero.ResonateNum + resonConfig.Energy,
|
||||
}
|
||||
err := this.moduleHero.hero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
|
||||
if err != nil {
|
||||
log.Errorf("update hero skill failed:%v", err)
|
||||
err1 = this.module.hero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
|
||||
if err1 != nil {
|
||||
log.Errorf("update hero skill failed:%v", err1)
|
||||
}
|
||||
// 返还对应初始星级的卡
|
||||
for _, v := range resonConfig.Prize {
|
||||
@ -131,12 +117,12 @@ func (this *apiComp) Resonance(session comm.IUserSession, agrs map[string]interf
|
||||
return
|
||||
}
|
||||
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) // 推送属性变化
|
||||
if err != nil {
|
||||
err1 = this.module.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||
if err1 != nil {
|
||||
log.Errorf("PushHeroProperty err!")
|
||||
}
|
||||
return
|
||||
|
@ -4,75 +4,66 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"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 == "" {
|
||||
code.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
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
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
|
||||
}
|
||||
|
||||
/// 英雄共鸣
|
||||
func (this *apiComp) ResonanceReset(session comm.IUserSession, agrs map[string]interface{}, req *pb.HeroResonanceResetReq) (code pb.ErrorCode) {
|
||||
|
||||
restResonance := agrs["resonateNum"].(int32)
|
||||
_hero := agrs["heroObj"].(*pb.DBHero)
|
||||
_costConfig := agrs["heroObj"].(cfg.Game_comAtnData)
|
||||
func (this *apiComp) ResonanceReset(session comm.IUserSession, req *pb.HeroResonanceResetReq) (code pb.ErrorCode, data proto.Message) {
|
||||
|
||||
_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() {
|
||||
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 {
|
||||
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)
|
||||
}
|
||||
_heroMap := map[string]interface{}{
|
||||
"DistributionResonate": restResonance,
|
||||
"DistributionResonate": _hero.ResonateNum * resonConfig.Energy,
|
||||
"Energy": _hero.Energy,
|
||||
}
|
||||
|
||||
err := this.moduleHero.hero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
|
||||
if err != nil {
|
||||
log.Errorf("update hero skill failed:%v", err)
|
||||
err1 = this.module.hero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
|
||||
if err1 != nil {
|
||||
log.Errorf("update hero skill failed:%v", err1)
|
||||
}
|
||||
err = this.moduleHero.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||
if err != nil {
|
||||
err1 = this.module.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||
if err1 != nil {
|
||||
log.Errorf("PushHeroProperty err!")
|
||||
}
|
||||
return
|
||||
|
@ -4,42 +4,35 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"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) {
|
||||
if req.HeroObjID == "" || req.UseEnergy <= 0 || req.UseType < 0 {
|
||||
code.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,
|
||||
func (this *apiComp) ResonanceUseEnergyCheck(session comm.IUserSession, req *pb.HeroResonanceUseEnergyReq) (code pb.ErrorCode) {
|
||||
if len(req.HeroObjID) == 0 || req.UseEnergy <= 0 || req.UseType < 0 {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, agrs map[string]interface{}, req *pb.HeroResonanceUseEnergyReq) (code pb.ErrorCode) {
|
||||
_hero := agrs["heroObj"].(*pb.DBHero)
|
||||
func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, req *pb.HeroResonanceUseEnergyReq) (code pb.ErrorCode, data proto.Message) {
|
||||
|
||||
_hero, code := this.module.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在
|
||||
defer func() {
|
||||
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 _hero == nil {
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
||||
if _hero.DistributionResonate < req.UseEnergy { // 能量点数不够
|
||||
code = pb.ErrorCode_HeroNoEnergy
|
||||
return
|
||||
}
|
||||
|
||||
_hero.Energy[req.UseType] += req.UseEnergy
|
||||
|
||||
_heroMap := map[string]interface{}{
|
||||
@ -47,14 +40,14 @@ func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, agrs map[stri
|
||||
"Energy": _hero.Energy,
|
||||
}
|
||||
|
||||
err := this.moduleHero.hero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
|
||||
if err != nil {
|
||||
err1 := this.module.hero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
|
||||
if err1 != nil {
|
||||
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) // 推送属性变化
|
||||
if err != nil {
|
||||
err1 = this.module.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||
if err1 != nil {
|
||||
log.Errorf("PushHeroProperty err!")
|
||||
}
|
||||
return
|
||||
|
@ -6,77 +6,67 @@ import (
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/pb"
|
||||
"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 == "" {
|
||||
code.Code = pb.ErrorCode_ReqParameterError
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
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
|
||||
}
|
||||
|
||||
/// 英雄技能升级
|
||||
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 (
|
||||
tmpUpSkillID map[int32]*pb.SkillData // 即将要升级的技能id
|
||||
probability map[int32]int32 // 即将升级技能的权重
|
||||
upSkillPos int32 // 升级的技能位置
|
||||
totalprobability int32 // 所有技能总权重
|
||||
tmpValue int32 // 临时对象 存放累加权重
|
||||
tagColor int32 // 目标卡品质
|
||||
costColor int32 // 消耗卡品质
|
||||
)
|
||||
tmpUpSkillID = make(map[int32]*pb.SkillData, 0)
|
||||
probability = make(map[int32]int32, 0)
|
||||
_hero := agrs["heroObj"].(*pb.DBHero)
|
||||
if _hero == nil {
|
||||
_hero, err := this.module.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在
|
||||
if err != pb.ErrorCode_Success {
|
||||
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
|
||||
}
|
||||
defer func() {
|
||||
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()
|
||||
if err != nil {
|
||||
config, err1 := this.module.configure.GetHeroSkillUpConfig()
|
||||
if err1 != nil {
|
||||
return
|
||||
}
|
||||
// 先随机一个没有升满
|
||||
@ -85,7 +75,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, agrs map[strin
|
||||
}
|
||||
|
||||
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
|
||||
tmpUpSkillID[int32(index)] = skill
|
||||
}
|
||||
@ -126,18 +116,18 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, agrs map[strin
|
||||
_heroMap := map[string]interface{}{
|
||||
"normalSkill": _hero.NormalSkill,
|
||||
}
|
||||
err = this.moduleHero.hero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
|
||||
if err != nil {
|
||||
err1 = this.module.hero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
|
||||
if err1 != nil {
|
||||
log.Errorf("update hero skill failed:%v", err)
|
||||
}
|
||||
// 扣除材料
|
||||
code = this.moduleHero.DelCard(req.CostCardObj, 1)
|
||||
if code != 0 {
|
||||
code = this.module.DelCard(req.CostCardObj, 1)
|
||||
if code != pb.ErrorCode_Success {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
err = this.moduleHero.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||
if err != nil {
|
||||
err1 = this.module.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||
if err1 != nil {
|
||||
log.Errorf("PushHeroProperty err!")
|
||||
}
|
||||
return
|
||||
|
@ -5,67 +5,79 @@ import (
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/pb"
|
||||
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) {
|
||||
if req.HeroObjID == "" {
|
||||
code.Code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
func (this *apiComp) StrengthenUpStarCheck(session comm.IUserSession, req *pb.HeroStrengthenUpStarReq) (code pb.ErrorCode) {
|
||||
if req.HeroObjID == "" || len(req.Hero) == 0 || len(req.HeroRace) == 0 {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
/// 英雄升星
|
||||
func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStrengthenUpStarReq) (code pb.ErrorCode, data proto.Message) {
|
||||
var (
|
||||
curLv int32
|
||||
target *cfg.Game_heroStarupData // 配置表目标升星英雄信息
|
||||
raceHero *pb.DBHero // 消耗的阵容英雄
|
||||
costRaceCount int32
|
||||
curGold int32
|
||||
)
|
||||
tagHero, err := this.moduleHero.GetHero(session.GetUserId(), req.HeroObjID)
|
||||
if err != 0 {
|
||||
code.Code = pb.ErrorCode_HeroNoExist
|
||||
_hero, err := this.module.GetHero(session.GetUserId(), req.HeroObjID)
|
||||
defer func() {
|
||||
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
|
||||
}
|
||||
curLv = tagHero.Lv
|
||||
log.Debugf("curLv:%d", curLv)
|
||||
// 校验指定英雄
|
||||
tagHeroConfig, err1 := this.moduleHero.configure.GetHeroStarupConfig()
|
||||
tagHeroConfig, err1 := this.module.configure.GetHeroStarupConfig()
|
||||
if err1 != nil {
|
||||
code.Code = pb.ErrorCode_ReqParameterError
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
}
|
||||
|
||||
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
|
||||
break
|
||||
}
|
||||
}
|
||||
if target == nil {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
}
|
||||
// 指定英雄消耗校验
|
||||
for _, v := range req.Hero {
|
||||
if tagHero, err := this.moduleHero.GetHero(session.GetUserId(), v.CostCardObj); err != 0 {
|
||||
code.Code = pb.ErrorCode_ReqParameterError
|
||||
if tagHero, err := this.module.GetHero(session.GetUserId(), v.CostCardObj); err != pb.ErrorCode_Success {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
} else {
|
||||
if tagHero.SameCount < v.Amount { // 校验数量
|
||||
code.Code = pb.ErrorCode_ReqParameterError
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
}
|
||||
// 校验ID
|
||||
if tagHero.HeroID != target.Needhero && tagHero.Star != target.Needherostar && tagHero.SameCount < target.Needheronum {
|
||||
code.Code = pb.ErrorCode_ReqParameterError
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
// 校验阵容英雄消耗
|
||||
for _, v := range req.HeroRace {
|
||||
if raceHero, err = this.moduleHero.GetHero(session.GetUserId(), v.CostCardObj); err != 0 {
|
||||
code.Code = pb.ErrorCode_ReqParameterError
|
||||
if raceHero, err = this.module.GetHero(session.GetUserId(), v.CostCardObj); err != pb.ErrorCode_Success {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
} else {
|
||||
// 校验阵容信息
|
||||
if raceHero.Star != target.Needracestar {
|
||||
code.Code = pb.ErrorCode_ReqParameterError
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
}
|
||||
bFind := false
|
||||
@ -76,7 +88,7 @@ func (this *apiComp) StrengthenUpStarCheck(session comm.IUserSession, req *pb.He
|
||||
}
|
||||
}
|
||||
if !bFind {
|
||||
code.Code = pb.ErrorCode_ReqParameterError
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -84,51 +96,27 @@ func (this *apiComp) StrengthenUpStarCheck(session comm.IUserSession, req *pb.He
|
||||
costRaceCount += v.Amount
|
||||
}
|
||||
if costRaceCount != target.Needracenum { // 数量不匹配
|
||||
code.Code = pb.ErrorCode_ReqParameterError
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
}
|
||||
// 金币消耗判断
|
||||
curGold = this.user.QueryAttributeValue(session.GetUserId(), "gold")
|
||||
curGold = this.module.ModuleUser.QueryAttributeValue(session.GetUserId(), "gold")
|
||||
if curGold < target.Gold { // 金币不足
|
||||
code.Code = pb.ErrorCode_GoldNoEnough
|
||||
code = pb.ErrorCode_GoldNoEnough
|
||||
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 {
|
||||
log.Errorf("cost gold failed ,count = %d", costGold)
|
||||
log.Errorf("cost gold failed ,count = %d", target.Gold)
|
||||
code = pb.ErrorCode_GoldNoEnough
|
||||
return
|
||||
}
|
||||
// 消耗指定英雄
|
||||
for _, v := range req.Hero {
|
||||
code = this.moduleHero.DelCard(v.CostCardObj, v.Amount)
|
||||
if code != 0 {
|
||||
code = this.module.DelCard(v.CostCardObj, v.Amount)
|
||||
if code != pb.ErrorCode_Success {
|
||||
code = pb.ErrorCode_DBError
|
||||
log.Errorf("del hero err card:%s,count = %d", v.CostCardObj, v.Amount)
|
||||
return
|
||||
@ -137,8 +125,8 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, agrs map[string
|
||||
|
||||
//消耗种族英雄
|
||||
for _, v := range req.HeroRace {
|
||||
code = this.moduleHero.DelCard(v.CostCardObj, v.Amount)
|
||||
if code != 0 {
|
||||
code = this.module.DelCard(v.CostCardObj, v.Amount)
|
||||
if code != pb.ErrorCode_Success {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
@ -148,13 +136,13 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, agrs map[string
|
||||
"star": _hero.Star,
|
||||
}
|
||||
// 保存数据
|
||||
err := this.moduleHero.hero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap)
|
||||
if err != nil {
|
||||
err1 = this.module.hero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap)
|
||||
if err1 != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
log.Errorf("update hero skill failed:%v", err)
|
||||
}
|
||||
err = this.moduleHero.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||
if err != nil {
|
||||
err1 = this.module.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||
if err1 != nil {
|
||||
log.Errorf("PushHeroProperty err!")
|
||||
}
|
||||
return
|
||||
|
@ -4,65 +4,72 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"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) {
|
||||
if req.HeroObjID == "" {
|
||||
code.Code = pb.ErrorCode_ReqParameterError
|
||||
func (this *apiComp) StrengthenUplvCheck(session comm.IUserSession, req *pb.HeroStrengthenUplvReq) (code pb.ErrorCode) {
|
||||
if req.HeroObjID == "" || req.ExpCardID == "" || req.Amount <= 0 {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
/// 英雄升级
|
||||
func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStrengthenUplvReq) (code pb.ErrorCode, data proto.Message) {
|
||||
|
||||
var (
|
||||
curLv int32
|
||||
curExp int32 // 当前英雄的经验
|
||||
costRes int32 // 当前需要消资源的数量
|
||||
addExp int32 // 需要增加的经验
|
||||
curGold int32
|
||||
curRes int32
|
||||
atn = map[string]interface{}{}
|
||||
)
|
||||
atn = make(map[string]interface{}, 0)
|
||||
|
||||
_hero, err := this.moduleHero.GetHero(session.GetUserId(), req.HeroObjID) // 校验升级的对象是否存在
|
||||
_hero, err := this.module.GetHero(session.GetUserId(), req.HeroObjID) // 校验升级的对象是否存在
|
||||
|
||||
if err != pb.ErrorCode_Success {
|
||||
code.Code = pb.ErrorCode_HeroNoExist
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
return
|
||||
}
|
||||
_expHero, err := this.moduleHero.GetHero(session.GetUserId(), req.ExpCardID) // 校验需要消耗经验卡牌的对象是否存在
|
||||
_expHero, err := this.module.GetHero(session.GetUserId(), req.ExpCardID) // 校验需要消耗经验卡牌的对象是否存在
|
||||
|
||||
if err != pb.ErrorCode_Success {
|
||||
code.Code = pb.ErrorCode_HeroNoExist
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
return
|
||||
}
|
||||
if req.Amount <= 0 { // 消耗数量校验
|
||||
code.Code = pb.ErrorCode_HeroNoExist
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
return
|
||||
}
|
||||
curLv = _hero.Lv
|
||||
curExp = _hero.Exp // 当前英雄的经验
|
||||
addExp = 1000
|
||||
// 查询 本次消耗会获得多少经验
|
||||
expConf := this.moduleHero.configure.GetHeroExp(_expHero.HeroID)
|
||||
expConf := this.module.configure.GetHeroExp(_expHero.HeroID)
|
||||
if expConf != nil {
|
||||
addExp = expConf.Heroexp * req.Amount
|
||||
}
|
||||
if _expHero.SameCount < req.Amount { // 消耗经验卡片数量不足
|
||||
code.Code = pb.ErrorCode_HeroNoEnough
|
||||
code = pb.ErrorCode_HeroNoEnough
|
||||
return
|
||||
}
|
||||
// 校验当前能不能升级
|
||||
|
||||
if _hero.Lv >= _hero.Star*comm.HeroStarLvRatio { // 达到最大等级
|
||||
code.Code = pb.ErrorCode_HeroMaxLv
|
||||
code = pb.ErrorCode_HeroMaxLv
|
||||
return
|
||||
}
|
||||
|
||||
var maxLv int32 // 校验等级达到上限
|
||||
maxLv = _hero.Star * comm.HeroStarLvRatio
|
||||
_data := this.moduleHero.configure.GetHeroLv(curLv)
|
||||
_data := this.module.configure.GetHeroLv(curLv)
|
||||
if _data != nil {
|
||||
if maxLv <= _hero.Lv && curExp >= _data.Heroexp[0].N { // 加经验之前校验是否达到最大等级
|
||||
code.Code = pb.ErrorCode_HeroMaxLv
|
||||
code = pb.ErrorCode_HeroMaxLv
|
||||
return
|
||||
}
|
||||
curExp += addExp // 先把经验加上
|
||||
@ -79,7 +86,7 @@ func (this *apiComp) StrengthenUplvCheck(session comm.IUserSession, req *pb.Hero
|
||||
} else { // 升级操作
|
||||
curExp -= _data.Heroexp[0].N
|
||||
curLv += 1 // 经验够了 那么等级+1
|
||||
_data = this.moduleHero.configure.GetHeroLv(curLv)
|
||||
_data = this.module.configure.GetHeroLv(curLv)
|
||||
if _data == nil { // 等级加失败了 回到原来的等级
|
||||
curLv -= 1
|
||||
break
|
||||
@ -92,76 +99,44 @@ func (this *apiComp) StrengthenUplvCheck(session comm.IUserSession, req *pb.Hero
|
||||
atn["t"] = v.T
|
||||
atn["n"] = v.N
|
||||
}
|
||||
// 金币消耗判断
|
||||
curGold = this.user.QueryAttributeValue(session.GetUserId(), atn["t"].(string))
|
||||
if curGold < costRes {
|
||||
code.Code = pb.ErrorCode_GoldNoEnough
|
||||
// 资源消耗判断
|
||||
curRes = this.module.ModuleUser.QueryAttributeValue(session.GetUserId(), atn["t"].(string))
|
||||
if curRes < costRes {
|
||||
code = pb.ErrorCode_GoldNoEnough
|
||||
}
|
||||
} else {
|
||||
code.Code = pb.ErrorCode_HeroNoExist
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
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 {
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
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)
|
||||
// 执行升级逻辑
|
||||
code = this.moduleHero.AddCardExp(session.GetUserId(), req.HeroObjID, addExp) // 加经验
|
||||
code = this.module.AddCardExp(session.GetUserId(), req.HeroObjID, addExp) // 加经验
|
||||
if code != pb.ErrorCode_Success {
|
||||
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 {
|
||||
return
|
||||
}
|
||||
// 删除经验卡
|
||||
err := this.moduleHero.hero.consumeOneHeroCard(session.GetUserId(), req.ExpCardID, req.Amount)
|
||||
if err != nil {
|
||||
err1 := this.module.hero.consumeOneHeroCard(session.GetUserId(), req.ExpCardID, req.Amount)
|
||||
if err1 != nil {
|
||||
log.Errorf("delete err failed err:%T!", err)
|
||||
return
|
||||
}
|
||||
|
||||
err = this.moduleHero.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||
if err != nil {
|
||||
err1 = this.module.hero.PushHeroProperty(session, _hero.Id) // 推送属性变化
|
||||
if err1 != nil {
|
||||
log.Errorf("PushHeroProperty err!")
|
||||
}
|
||||
return
|
||||
|
@ -162,9 +162,9 @@ func (this *ModelHero) mergeMainProperty(uid, heroId string, data map[string]int
|
||||
return
|
||||
}
|
||||
|
||||
hero.Property[comm.PropertyHp] += data[comm.PropertyHp]
|
||||
hero.Property[comm.PropertyAtk] += data[comm.PropertyAtk]
|
||||
hero.Property[comm.PropertyDef] += data[comm.PropertyDef]
|
||||
hero.Property[comm.Hp] += data[comm.Hp]
|
||||
hero.Property[comm.Atk] += data[comm.Atk]
|
||||
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 {
|
||||
return
|
||||
}
|
||||
hero.AddProperty[comm.PropertyHp] += data[comm.PropertyHp]
|
||||
hero.AddProperty[comm.PropertyAtk] += data[comm.PropertyAtk]
|
||||
hero.AddProperty[comm.PropertyDef] += data[comm.PropertyDef]
|
||||
hero.AddProperty[comm.Hp] += data[comm.Hp]
|
||||
hero.AddProperty[comm.Atk] += data[comm.Atk]
|
||||
hero.AddProperty[comm.Def] += data[comm.Def]
|
||||
}
|
||||
|
||||
//属性计算 - 暂时放在modelHero里实现
|
||||
@ -216,25 +216,25 @@ func (this *ModelHero) PropertyCompute(uid, heroId string) map[string]int32 {
|
||||
return nil
|
||||
}
|
||||
|
||||
curHp := hero.Property[comm.PropertyHp]
|
||||
curHp := hero.Property[comm.Hp]
|
||||
exprHp := fmt.Sprintf("%v + %v * %v/1000 + %v * %v",
|
||||
(curHp + lvGrow.Hp), heroLvCfg.Hp, lvGrow.Hpgrow, heroStarCfg.Hp, stargrowCfg.StarupHp)
|
||||
hp, _ := mengine.ParseAndExec(exprHp)
|
||||
|
||||
curAtk := hero.Property[comm.PropertyAtk]
|
||||
curAtk := hero.Property[comm.Atk]
|
||||
exprAtk := fmt.Sprintf("%v +%v * %v/1000 + %v * %v",
|
||||
(curAtk + lvGrow.Atk), heroLvCfg.Atk, lvGrow.Atkgrow, heroStarCfg.Atk, stargrowCfg.StarupAtk)
|
||||
atk, _ := mengine.ParseAndExec(exprAtk)
|
||||
|
||||
curDef := hero.Property[comm.PropertyDef]
|
||||
curDef := hero.Property[comm.Def]
|
||||
exprDef := fmt.Sprintf("%v +%v * %v/1000 + %v * %v",
|
||||
(curDef + lvGrow.Def), heroLvCfg.Def, lvGrow.Defgrow, heroStarCfg.Def, stargrowCfg.StarupDef)
|
||||
def, _ := mengine.ParseAndExec(exprDef)
|
||||
|
||||
return map[string]int32{
|
||||
comm.PropertyHp: int32(math.Floor(hp)),
|
||||
comm.PropertyAtk: int32(math.Floor(atk)),
|
||||
comm.PropertyDef: int32(math.Floor(def)),
|
||||
comm.Hp: int32(math.Floor(hp)),
|
||||
comm.Atk: int32(math.Floor(atk)),
|
||||
comm.Def: int32(math.Floor(def)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,15 +4,17 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"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
|
||||
}
|
||||
|
||||
// 删除邮件
|
||||
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
|
||||
mailinfo := make([]*pb.DBMailData, 0)
|
||||
defer func() {
|
||||
|
@ -3,14 +3,16 @@ package mail
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"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
|
||||
}
|
||||
|
||||
// 领取附件
|
||||
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 (
|
||||
mail *pb.DBMailData
|
||||
|
@ -4,14 +4,16 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"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
|
||||
}
|
||||
|
||||
// 查看所有邮件信息
|
||||
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
|
||||
mailinfo := make([]*pb.DBMailData, 0)
|
||||
|
@ -3,14 +3,16 @@ package mail
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"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
|
||||
}
|
||||
|
||||
// 查看某一封邮件
|
||||
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 (
|
||||
err error
|
||||
mail *pb.DBMailData
|
||||
|
@ -4,22 +4,21 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"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) {
|
||||
result = make(map[string]interface{})
|
||||
self := &pb.DBUser{}
|
||||
err := this.module.modelUser.Get(session.GetUserId(), self)
|
||||
if err != nil {
|
||||
code = comm.ErrorCode{Code: pb.ErrorCode_DBError}
|
||||
return
|
||||
func (this *apiComp) CreateCheck(session comm.IUserSession, req *pb.UserCreateReq) (code pb.ErrorCode) {
|
||||
if req.NickName == "" {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
result["self"] = self
|
||||
|
||||
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 func() {
|
||||
@ -29,12 +28,11 @@ func (this *apiComp) Create(session comm.IUserSession, result map[string]interfa
|
||||
}
|
||||
}()
|
||||
|
||||
if self, ok := result["self"]; ok {
|
||||
v := self.(*pb.DBUser)
|
||||
if v.Created {
|
||||
code = pb.ErrorCode_RoleCreated
|
||||
return
|
||||
}
|
||||
self := &pb.DBUser{}
|
||||
err = this.module.modelUser.Get(session.GetUserId(), self)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
|
||||
update := map[string]interface{}{
|
||||
@ -47,7 +45,7 @@ func (this *apiComp) Create(session comm.IUserSession, result map[string]interfa
|
||||
update["gold"] = val
|
||||
}
|
||||
|
||||
err := this.module.modelUser.Change(session.GetUserId(), update)
|
||||
err = this.module.modelUser.Change(session.GetUserId(), update)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
|
@ -9,16 +9,17 @@ import (
|
||||
"time"
|
||||
|
||||
"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) {
|
||||
result = map[string]interface{}{}
|
||||
func (this *apiComp) LoginCheck(session comm.IUserSession, req *pb.UserLoginReq) (code pb.ErrorCode) {
|
||||
|
||||
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 (
|
||||
err error
|
||||
user *pb.DBUser
|
||||
|
@ -3,20 +3,18 @@ package user
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"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) {
|
||||
result = make(map[string]interface{})
|
||||
user := this.module.modelUser.getUser(session.GetUserId())
|
||||
if user == nil {
|
||||
code = comm.ErrorCode{Code: pb.ErrorCode_UserSessionNobeing}
|
||||
return
|
||||
func (this *apiComp) AddResCheck(session comm.IUserSession, req *pb.UserAddResReq) (code pb.ErrorCode) {
|
||||
if req.ResType == "" || req.Count <= 0 {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
result["user"] = user
|
||||
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{}
|
||||
|
||||
defer func() {
|
||||
@ -26,24 +24,27 @@ func (this *apiComp) AddRes(session comm.IUserSession, result map[string]interfa
|
||||
}
|
||||
}()
|
||||
|
||||
if u, ok := result["user"]; ok {
|
||||
user := u.(*pb.DBUser)
|
||||
count := req.Count
|
||||
|
||||
switch req.ResType {
|
||||
case comm.ResGold:
|
||||
count += user.Gold
|
||||
case comm.ResExp:
|
||||
count += user.Exp
|
||||
}
|
||||
code = this.module.AddAttributeValue(session.GetUserId(), req.ResType, count)
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
||||
rsp.ResType = req.ResType
|
||||
rsp.Count = count
|
||||
user := this.module.modelUser.GetUser(session.GetUserId())
|
||||
if user == nil {
|
||||
code = pb.ErrorCode_UserSessionNobeing
|
||||
return
|
||||
}
|
||||
|
||||
count := req.Count
|
||||
|
||||
switch req.ResType {
|
||||
case comm.ResGold:
|
||||
count += user.Gold
|
||||
case comm.ResExp:
|
||||
count += user.Exp
|
||||
}
|
||||
code = this.module.AddAttributeValue(session.GetUserId(), req.ResType, count)
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
||||
rsp.ResType = req.ResType
|
||||
rsp.Count = count
|
||||
|
||||
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.Uuid = uuid.NewV4().String()
|
||||
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{}
|
||||
if err := this.Get(uid, dbUser); err != nil {
|
||||
log.Errorf("getUser err:%v", err)
|
||||
|
@ -18,7 +18,7 @@ type User struct {
|
||||
api *apiComp
|
||||
modelUser *ModelUser
|
||||
modelSession *ModelSession
|
||||
configure *configureComp
|
||||
configure *modules.MCompConfigure
|
||||
}
|
||||
|
||||
func (this *User) GetType() core.M_Modules {
|
||||
@ -36,17 +36,17 @@ func (this *User) OnInstallComp() {
|
||||
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||
this.modelUser = this.RegisterComp(new(ModelUser)).(*ModelUser)
|
||||
this.modelSession = this.RegisterComp(new(ModelSession)).(*ModelSession)
|
||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||
|
||||
}
|
||||
|
||||
//获取英雄列表
|
||||
func (this *User) GetHeroList(uid string) []*pb.DBHero {
|
||||
return nil
|
||||
func (this *User) GetUser(uid string) *pb.DBUser {
|
||||
return this.modelUser.GetUser(uid)
|
||||
}
|
||||
|
||||
//查询用户属性值 例如 金币 经验
|
||||
func (this *User) QueryAttributeValue(uid string, attr string) (value int32) {
|
||||
user := this.modelUser.getUser(uid)
|
||||
user := this.modelUser.GetUser(uid)
|
||||
if user == nil {
|
||||
return
|
||||
}
|
||||
|
@ -2,10 +2,10 @@ package web
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/modules/user"
|
||||
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/core/cbase"
|
||||
)
|
||||
|
||||
/*
|
||||
@ -19,7 +19,7 @@ func NewModule() core.IModule {
|
||||
}
|
||||
|
||||
type Web struct {
|
||||
modules.ModuleBase
|
||||
cbase.ModuleBase
|
||||
options *Options
|
||||
api_comp *Api_Comp //提供weba pi服务的组件
|
||||
modelUser *user.ModelUser
|
||||
|
Loading…
Reference in New Issue
Block a user