111 lines
3.0 KiB
Go
111 lines
3.0 KiB
Go
package guildgve
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/sys/configure"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
"go_dreamfactory/utils"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) ChallengeCheck(session comm.IUserSession, req *pb.GuildGveChallengeReq) (errdata *pb.ErrorData) {
|
|
if req.Guildid == "" || req.Boosid == 0 {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
Message: req.String(),
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// 获取工会boos战信息
|
|
func (this *apiComp) Challenge(session comm.IUserSession, req *pb.GuildGveChallengeReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
member *pb.DBGuildMember
|
|
record *pb.DBBattleRecord
|
|
playerlvconf *cfg.GamePlayerlvData
|
|
conf *cfg.GameGuildBossData
|
|
err error
|
|
)
|
|
|
|
if errdata = this.ChallengeCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
|
|
if conf, err = this.module.configure.getguildbossByid(req.Boosid); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if member, err = this.module.modelGuildMember.getGuildMember(req.Guildid, session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if !utils.IsToday(member.Refreshtime) {
|
|
if playerlvconf, errdata = this.module.ModuleTools.GetPlayerlvConf(session.GetUserId()); errdata != nil {
|
|
member.Boosticket = playerlvconf.GuildBossCeiling
|
|
member.Refreshtime = configure.Now().Unix()
|
|
this.module.modelGuildMember.updateGuildMember(member)
|
|
return
|
|
}
|
|
}
|
|
// if member.Boosticket == 0 {
|
|
// errdata = &pb.ErrorData{
|
|
// Code: pb.ErrorCode_ReqParameterError,
|
|
// Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
// Message: "Boosticket not enough",
|
|
// }
|
|
// return
|
|
// }
|
|
|
|
for _, v := range req.Battle.Format {
|
|
for _, v1 := range member.Useheros {
|
|
if v != "" && v == v1 {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
Message: fmt.Sprintf("hero:%s Used !", v),
|
|
}
|
|
return
|
|
}
|
|
}
|
|
}
|
|
|
|
if errdata, record = this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
|
|
Rulesid: conf.BattleReadyID,
|
|
Ptype: pb.PlayType_moonfantasy,
|
|
Format: req.Battle,
|
|
Mformat: conf.Boss,
|
|
}); err != nil {
|
|
return
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "challenge", &pb.GuildGveChallengeResp{
|
|
Guildid: req.Guildid,
|
|
Boosid: req.Boosid,
|
|
Boosticket: member.Boosticket,
|
|
Info: &pb.BattleInfo{
|
|
Id: record.Id,
|
|
Rulesid: conf.BattleReadyID,
|
|
Btype: record.Btype,
|
|
RedCompId: record.RedCompId,
|
|
Ptype: record.Ptype,
|
|
Redflist: record.Redflist,
|
|
BlueCompId: record.BlueCompId,
|
|
Buleflist: record.Buleflist,
|
|
Tasks: record.Tasks,
|
|
},
|
|
})
|
|
return
|
|
}
|