go_dreamfactory/modules/exclusive/api_addexp.go
2024-02-26 18:41:09 +08:00

58 lines
1.5 KiB
Go

package exclusive
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
)
//参数校验
func (this *apiComp) AddExpCheck(session comm.IUserSession, req *pb.ExclusiveAddExpReq) (errdata *pb.ErrorData) {
return
}
///获取用户装备列表
func (this *apiComp) AddExp(session comm.IUserSession, req *pb.ExclusiveAddExpReq) (errdata *pb.ErrorData) {
var (
info *pb.DB_Exclusive
conf *cfg.GameExclusiveItemData
need []*cfg.Gameatn = make([]*cfg.Gameatn, 0)
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.GetGameExclusiveItem(req.Itemid); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Message: err.Error(),
}
return
}
need = append(need, &cfg.Gameatn{
A: comm.ItemType,
T: req.Itemid,
N: req.Num,
})
if errdata = this.module.ConsumeRes(session, need, true); errdata != nil {
return
}
info.Exp += conf.Exp
if err = this.module.model.updateExclusive(session.GetUserId(), info); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Message: err.Error(),
}
return
}
this.module.equipmentsChangePush(session, []*pb.DB_Exclusive{info})
session.SendMsg(string(this.module.GetType()), "addExp", &pb.ExclusiveAddExpResp{Exclusives: info})
return
}