117 lines
3.2 KiB
Go
117 lines
3.2 KiB
Go
package island
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) CompleteCheck(session comm.IUserSession, req *pb.IsLandCompleteReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// /获取自己的排行榜信息
|
|
func (this *apiComp) Complete(session comm.IUserSession, req *pb.IsLandCompleteReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
info *pb.DBIsland
|
|
conf *cfg.GamePuggsyEventData
|
|
sconf []*cfg.GamePuggsyScoreData
|
|
conf4 *cfg.GamePuggsyStarData
|
|
item *pb.DBIslandItem
|
|
award []*pb.UserAtno
|
|
ok bool
|
|
err error
|
|
)
|
|
if errdata = this.CompleteCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
|
|
if conf, err = this.module.configure.getGamePuggsyEventData(req.Level); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if info, err = this.module.model.getmodel(session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if item, ok = info.Islands[conf.NodeId]; !ok {
|
|
item = &pb.DBIslandItem{
|
|
Id: conf.NodeId,
|
|
Level: make(map[int32]int32),
|
|
}
|
|
info.Islands[conf.NodeId] = item
|
|
}
|
|
|
|
if _, ok = item.Level[req.Level]; ok {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
Message: fmt.Sprintf("level:%d done!", req.Level),
|
|
}
|
|
return
|
|
}
|
|
|
|
if conf.Type == 3 { //战斗管卡
|
|
if errdata, _ = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
|
|
return
|
|
}
|
|
if sconf, err = this.module.configure.getGamePuggsyScoreDatas(item.Level[req.Level], req.Report.Score); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
item.Level[req.Level] = req.Report.Harm
|
|
reward := []*cfg.Gameatn{}
|
|
for _, v := range sconf {
|
|
reward = append(reward, v.Reward...)
|
|
}
|
|
if errdata, award = this.module.DispenseAtno(session, reward, true); errdata != nil {
|
|
return
|
|
}
|
|
} else if conf.Type == 4 {
|
|
if conf4, err = this.module.configure.getGamePuggsyStarData(req.AwardId); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
item.Level[req.Level] = req.AwardId
|
|
if errdata, award = this.module.DispenseAtno(session, conf4.Drop, true); errdata != nil {
|
|
return
|
|
}
|
|
} else {
|
|
item.Level[req.Level] = 1
|
|
if errdata, award = this.module.DispenseAtno(session, conf.Reward, true); errdata != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
this.module.model.Change(session.GetUserId(), map[string]interface{}{
|
|
"islands": info.Islands,
|
|
})
|
|
session.SendMsg(string(this.module.GetType()), "complete", &pb.IsLandCompleteResp{Level: req.Level, Award: award})
|
|
|
|
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
|
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "IsLandCompleteReq", award)
|
|
})
|
|
return
|
|
}
|