109 lines
3.1 KiB
Go
109 lines
3.1 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) PracticeCheck(session comm.IUserSession, req *pb.PracticePracticeReq) (code pb.ErrorCode) {
|
|
|
|
return
|
|
}
|
|
|
|
///练功请求 练功
|
|
func (this *apiComp) Practice(session comm.IUserSession, req *pb.PracticePracticeReq) (code pb.ErrorCode, data *pb.ErrorData) {
|
|
var (
|
|
err error
|
|
room *pb.DBPracticeRoom
|
|
pillar *pb.DBPracticePillar
|
|
pillarconfigure *cfg.GamePandamasMzData
|
|
tconfigure *cfg.GamePandamasJxData
|
|
pconfigure *cfg.GamePandamasJxData
|
|
extra int32 = 0
|
|
filed string
|
|
)
|
|
if room, err = this.module.modelPandata.queryUserMartialhall(session.GetUserId()); err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
|
|
switch req.Index {
|
|
case 1:
|
|
pillar = room.Pillar1
|
|
filed = "pillar1"
|
|
break
|
|
case 2:
|
|
pillar = room.Pillar2
|
|
filed = "pillar2"
|
|
break
|
|
case 3:
|
|
pillar = room.Pillar3
|
|
filed = "pillar3"
|
|
break
|
|
case 4:
|
|
pillar = room.Pillarf
|
|
filed = "pillarf"
|
|
break
|
|
}
|
|
if pillar.Isunlock != 2 { //柱子未解锁
|
|
code = pb.ErrorCode_ReqParameterError
|
|
return
|
|
}
|
|
|
|
if pillarconfigure, err = this.module.configure.getGamePandamasMz(pillar.Lv); err != nil {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
|
|
if req.Teacher != "" {
|
|
if room.Knapsack[req.Teacher] == 1 { //已经被使用
|
|
code = pb.ErrorCode_ReqParameterError
|
|
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
|
|
pillar.Teacher = req.Teacher
|
|
}
|
|
if req.Prop != "" {
|
|
if room.Knapsack[req.Prop] == 1 { //已经被使用
|
|
code = pb.ErrorCode_ReqParameterError
|
|
return
|
|
}
|
|
room.Knapsack[req.Prop] = 1
|
|
if pconfigure, err = this.module.configure.getGamePandamasJx(req.Prop); err != nil {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
extra += pconfigure.Duration
|
|
pillar.Prop = req.Prop
|
|
}
|
|
pillar.Hero = req.Hero
|
|
if code = this.module.ModuleHero.KungFuHero(session, req.Hero, true, ""); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
pillar.Start = configure.Now().Unix()
|
|
if extra >= 0 {
|
|
pillar.End = configure.Now().Add(time.Minute * (time.Duration(pillarconfigure.PlacementDuration))).Unix()
|
|
pillar.Expend = configure.Now().Add(time.Minute * (time.Duration(pillarconfigure.PlacementDuration + extra))).Unix()
|
|
} else {
|
|
pillar.End = configure.Now().Add(time.Minute * (time.Duration(pillarconfigure.PlacementDuration + extra))).Unix()
|
|
pillar.Expend = configure.Now().Add(time.Minute * (time.Duration(pillarconfigure.PlacementDuration))).Unix()
|
|
}
|
|
|
|
this.module.modelPandata.Change(session.GetUserId(), map[string]interface{}{
|
|
"knapsack": room.Knapsack,
|
|
filed: pillar,
|
|
})
|
|
this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype149, 1))
|
|
session.SendMsg(string(this.module.GetType()), "practice", &pb.PracticePracticeResp{Pillar: pillar})
|
|
return
|
|
}
|