95 lines
2.3 KiB
Go
95 lines
2.3 KiB
Go
package stonehenge
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) ActivateTalentCheck(session comm.IUserSession, req *pb.StonehengeActivateTalentReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) ActivateTalent(session comm.IUserSession, req *pb.StonehengeActivateTalentReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
info *pb.DBStonehenge
|
|
conf *cfg.GameStoneTalentData
|
|
ok bool
|
|
err error
|
|
)
|
|
if errdata = this.ActivateTalentCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
if info, err = this.module.modelStonehenge.GetStonehengeData(session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.String(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if conf, err = this.module.configure.getGameStoneTalentData(req.Node); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.String(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
for _, v := range conf.Front {
|
|
if _, ok := info.Talent[v]; !ok {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.String(),
|
|
Message: "Front no unlock",
|
|
}
|
|
return
|
|
}
|
|
}
|
|
|
|
if errdata = this.module.ConsumeRes(session, conf.CostItem, true); errdata != nil {
|
|
return
|
|
}
|
|
|
|
info.Talent[req.Node] = true
|
|
for _, v := range conf.Attribute {
|
|
info.Talentproperty[v.A] += v.N
|
|
}
|
|
ok = false
|
|
if conf.PrivilegeId != 0 {
|
|
for _, v := range info.Privilege {
|
|
if int32(v) == conf.PrivilegeId {
|
|
ok = true
|
|
break
|
|
}
|
|
}
|
|
}
|
|
if !ok {
|
|
info.Privilege = append(info.Privilege, pb.StonehengePrivilege(conf.PrivilegeId))
|
|
}
|
|
|
|
if err = this.module.modelStonehenge.Change(session.GetUserId(), map[string]interface{}{
|
|
"talent": info.Talent,
|
|
"talentproperty": info.Talentproperty,
|
|
"privilege": info.Privilege,
|
|
}); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.String(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
session.SendMsg(string(this.module.GetType()), "activatetalent", &pb.StonehengeActivateTalentResp{
|
|
Node: req.Node,
|
|
Talent: info.Talent,
|
|
Talentproperty: info.Talentproperty,
|
|
Privilege: info.Privilege,
|
|
})
|
|
return
|
|
}
|