31 lines
665 B
Go
31 lines
665 B
Go
package pack
|
|
|
|
import (
|
|
"context"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *Api_Comp) Useitem_Check(ctx context.Context, session comm.IUserSession, req *pb.UseItemReq) (code pb.ErrorCode) {
|
|
if !session.IsLogin() {
|
|
code = pb.ErrorCode_NoLogin
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
//使用道具
|
|
func (this *Api_Comp) Useitem(ctx context.Context, session comm.IUserSession, req *pb.UseItemReq) (err error) {
|
|
var (
|
|
code pb.ErrorCode
|
|
)
|
|
defer func() {
|
|
session.SendMsg(string(this.M.GetType()), UseItemResp, code, &pb.UseItemResp{})
|
|
}()
|
|
if code = this.Useitem_Check(ctx, session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
return
|
|
}
|