112 lines
3.6 KiB
Go
112 lines
3.6 KiB
Go
package practice
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/sys/configure"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
"time"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) LootCheck(session comm.IUserSession, req *pb.PracticeLootReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
///练功请求 蹭馆
|
|
func (this *apiComp) Loot(session comm.IUserSession, req *pb.PracticeLootReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
err error
|
|
froom *pb.DBPracticeRoom
|
|
room *pb.DBPracticeRoom
|
|
pillarconfigure *cfg.GamePandamasMzData
|
|
tconfigure *cfg.GamePandamasJxData
|
|
pconfigure *cfg.GamePandamasJxData
|
|
extra int32 = 0
|
|
)
|
|
if froom, err = this.module.modelPandata.queryUserMartialhall(req.Friend); err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
if room, err = this.module.modelPandata.queryUserMartialhall(session.GetUserId()); err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
if froom.Pillarf.Hero != "" {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
}
|
|
}
|
|
if pillarconfigure, err = this.module.configure.getGamePandamasMz(froom.Pillarf.Lv); err != nil {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
if code = this.module.ModuleHero.KungFuHero(session, req.Hero, true, req.Friend); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
if req.Teacher != "" {
|
|
if room.Knapsack[req.Teacher] == 1 { //已经被使用
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
}
|
|
return
|
|
}
|
|
room.Knapsack[req.Teacher] = 1
|
|
if tconfigure, err = this.module.configure.getGamePandamasJx(req.Teacher); err != nil {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
extra += tconfigure.Duration
|
|
froom.Pillarf.Teacher = req.Teacher
|
|
}
|
|
if req.Prop != "" {
|
|
if room.Knapsack[req.Prop] == 1 { //已经被使用
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
}
|
|
return
|
|
}
|
|
room.Knapsack[req.Prop] = 1
|
|
if pconfigure, err = this.module.configure.getGamePandamasJx(req.Teacher); err != nil {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
extra += pconfigure.Duration
|
|
froom.Pillarf.Prop = req.Prop
|
|
}
|
|
froom.Pillarf.Uid = session.GetUserId()
|
|
froom.Pillarf.Hero = req.Hero
|
|
froom.Pillarf.Start = configure.Now().Unix()
|
|
if extra >= 0 {
|
|
froom.Pillarf.End = configure.Now().Add(time.Minute * (time.Duration(pillarconfigure.PlacementDuration))).Unix()
|
|
froom.Pillarf.Expend = configure.Now().Add(time.Minute * (time.Duration(pillarconfigure.PlacementDuration + extra))).Unix()
|
|
} else {
|
|
froom.Pillarf.End = configure.Now().Add(time.Minute * (time.Duration(pillarconfigure.PlacementDuration + extra))).Unix()
|
|
froom.Pillarf.Expend = configure.Now().Add(time.Minute * (time.Duration(pillarconfigure.PlacementDuration))).Unix()
|
|
}
|
|
|
|
this.module.modelPandata.Change(req.Friend, map[string]interface{}{
|
|
"pillarf": froom.Pillarf,
|
|
})
|
|
this.module.modelPandata.Change(session.GetUserId(), map[string]interface{}{
|
|
"knapsack": room.Knapsack,
|
|
})
|
|
|
|
if _session, ok := this.module.GetUserSession(req.Friend); ok {
|
|
_session.SendMsg(string(this.module.GetType()), "rommchange", &pb.PracticeRommChangePush{Info: froom})
|
|
if err = _session.Push(); err != nil {
|
|
this.module.Errorln(err)
|
|
}
|
|
this.module.PutUserSession(_session)
|
|
} else {
|
|
this.module.PutUserSession(_session)
|
|
}
|
|
go this.module.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype184, 1))
|
|
session.SendMsg(string(this.module.GetType()), "loot", &pb.PracticeLootResp{Friend: req.Friend, Pillar: froom.Pillarf})
|
|
return
|
|
}
|