59 lines
1.4 KiB
Go
59 lines
1.4 KiB
Go
package island
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.IsLandInfoReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// /获取自己的排行榜信息
|
|
func (this *apiComp) Info(session comm.IUserSession, req *pb.IsLandInfoReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
info *pb.DBIsland
|
|
heros []*pb.DBHero
|
|
cards []string
|
|
err error
|
|
)
|
|
if errdata = this.InfoCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
|
|
if info, err = this.module.model.getmodel(session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if len(info.Heroshop) == 0 {
|
|
if cards, err = this.module.hero.GetRandomCardByCardPool(session.GetUserId(), 5); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
for _, v := range cards {
|
|
info.Heroshop[v] = 0
|
|
}
|
|
this.module.model.Change(session.GetUserId(), map[string]interface{}{
|
|
"heroshop": info.Heroshop,
|
|
})
|
|
}
|
|
|
|
if heros, err = this.module.modelhero.getHeroList(session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "info", &pb.IsLandInfoResp{Info: info, Heros: heros})
|
|
return
|
|
}
|