55 lines
1.3 KiB
Go
55 lines
1.3 KiB
Go
package exclusive
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) UpgradeCheck(session comm.IUserSession, req *pb.ExclusiveUpgradeReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
///获取用户装备列表
|
|
func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.ExclusiveUpgradeReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
info *pb.DB_Exclusive
|
|
conf *cfg.GameExclusiveUpgradeData
|
|
err error
|
|
)
|
|
|
|
if info, err = this.module.model.getExclusivesById(session.GetUserId(), req.Oid); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if conf, err = this.module.configure.GetGameExclusiveUpgradeData(info.CId, info.Lv); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if info.Exp < conf.Needexp {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Message: "exp not enough!",
|
|
}
|
|
return
|
|
}
|
|
if errdata = this.module.ConsumeRes(session, conf.Cost, true); errdata != nil {
|
|
return
|
|
}
|
|
info.Lv++
|
|
info.Property = make(map[int32]int32)
|
|
for _, v := range conf.Attribute {
|
|
info.Property[v.A] = v.N
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "upgrade", &pb.ExclusiveUpgradeResp{Exclusives: info})
|
|
return
|
|
}
|