137 lines
3.3 KiB
Go
137 lines
3.3 KiB
Go
package combat
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) InCheck(session comm.IUserSession, req *pb.CombatInReq) (code pb.ErrorCode) {
|
|
|
|
return
|
|
}
|
|
|
|
///获取自己的排行榜信息
|
|
func (this *apiComp) In(session comm.IUserSession, req *pb.CombatInReq) (code pb.ErrorCode, data *pb.ErrorData) {
|
|
var (
|
|
info *pb.DBCombatUser
|
|
level *pb.DBCombatLevel
|
|
lvconf *cfg.GameCombatLevelData
|
|
condis []*pb.ConIProgress
|
|
pitem *pb.LevelProgressItem
|
|
push bool
|
|
ok bool
|
|
err error
|
|
)
|
|
if code = this.InCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
if info, err = this.module.modelCombat.queryInfo(session.GetUserId()); err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
|
|
if lvconf, err = this.module.configure.getCombatLevel(req.Id); err != nil {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
|
|
if level, ok = info.Level[req.Id]; !ok {
|
|
|
|
level = &pb.DBCombatLevel{
|
|
Id: req.Id,
|
|
Passmanster: make([]int32, 0),
|
|
Passdrop: make([]int32, 0),
|
|
Progress: 0,
|
|
Pass: 0,
|
|
}
|
|
pitem = &pb.LevelProgressItem{
|
|
Level: level.Id,
|
|
Pass: level.Pass,
|
|
}
|
|
if condis, err = this.module.ModuleBuried.CheckCondition(session.GetUserId(), lvconf.Maintask...); err != nil {
|
|
code = pb.ErrorCode_ExternalModule
|
|
data = &pb.ErrorData{
|
|
Title: code.ToString(),
|
|
Message: comm.NewExternalModuleErr("Buried", "CheckCondition", lvconf.Maintask).Error(),
|
|
}
|
|
return
|
|
}
|
|
ok = true
|
|
level.Passmaintask = condis
|
|
pitem.Passmaintask = condis
|
|
for _, v := range condis {
|
|
level.Progress += v.Value
|
|
if v.State != 2 {
|
|
ok = false
|
|
}
|
|
}
|
|
|
|
if ok { //
|
|
level.Pass = 1
|
|
pitem.Pass = 1
|
|
this.module.DispenseRes(session, lvconf.Award, true)
|
|
atns := make([]*pb.UserAssets, len(lvconf.Award))
|
|
for i, v := range lvconf.Award {
|
|
atns[i] = &pb.UserAssets{
|
|
A: v.A,
|
|
T: v.T,
|
|
N: v.N,
|
|
}
|
|
}
|
|
pitem.Mainaward = atns
|
|
push = true
|
|
}
|
|
|
|
if level.Pass == 1 {
|
|
if condis, err = this.module.ModuleBuried.CheckCondition(session.GetUserId(), lvconf.Subtask...); err != nil {
|
|
code = pb.ErrorCode_ExternalModule
|
|
data = &pb.ErrorData{
|
|
Title: code.ToString(),
|
|
Message: comm.NewExternalModuleErr("Buried", "CheckCondition", lvconf.Subtask).Error(),
|
|
}
|
|
return
|
|
}
|
|
level.Passpertask = condis
|
|
pitem.Passpertask = condis
|
|
ok = true
|
|
for _, v := range condis {
|
|
level.Progress += v.Value
|
|
if v.State != 2 {
|
|
ok = false
|
|
}
|
|
}
|
|
|
|
if ok { //
|
|
level.Pass = 2
|
|
pitem.Pass = 2
|
|
this.module.DispenseRes(session, lvconf.Profectaward, true)
|
|
atns := make([]*pb.UserAssets, len(lvconf.Profectaward))
|
|
for i, v := range lvconf.Profectaward {
|
|
atns[i] = &pb.UserAssets{
|
|
A: v.A,
|
|
T: v.T,
|
|
N: v.N,
|
|
}
|
|
}
|
|
pitem.Peraward = atns
|
|
push = true
|
|
}
|
|
}
|
|
|
|
info.Level[req.Id] = level
|
|
if err = this.module.modelCombat.updateInfo(info); err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "in", &pb.CombatInResp{Level: level})
|
|
if push {
|
|
pitem.Progress = level.Progress
|
|
session.SendMsg(string(this.module.GetType()), "progress", &pb.CombatProgressPush{Levels: []*pb.LevelProgressItem{pitem}})
|
|
}
|
|
|
|
return
|
|
}
|