55 lines
1.7 KiB
Go
55 lines
1.7 KiB
Go
package moonfantasy
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/sys/mgo"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/sys/configure"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
"time"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) GetlistCheck(session comm.IUserSession, req *pb.MoonfantasyGetListReq) (code pb.ErrorCode) {
|
|
|
|
return
|
|
}
|
|
|
|
///获取用户秘境列表
|
|
func (this *apiComp) Getlist(session comm.IUserSession, req *pb.MoonfantasyGetListReq) (code pb.ErrorCode, data proto.Message) {
|
|
var (
|
|
err error
|
|
globalconf *cfg.GameGlobalData
|
|
umfantasy *pb.DBUserMFantasy
|
|
mfantasys []*pb.DBMoonFantasy = make([]*pb.DBMoonFantasy, 0)
|
|
)
|
|
if umfantasy, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil && err != mgo.MongodbNil {
|
|
code = pb.ErrorCode_CacheReadError
|
|
return
|
|
}
|
|
globalconf = this.module.configure.GetGlobalConf()
|
|
if time.Unix(umfantasy.LastTrigger, 0).Day() != configure.Now().Day() {
|
|
umfantasy.TriggerNum = 0
|
|
umfantasy.LastTrigger = configure.Now().Unix()
|
|
umfantasy.BuyNum = 0
|
|
if umfantasy.BattleNum < globalconf.DreamlandFightnum {
|
|
umfantasy.BattleNum = globalconf.DreamlandFightnum
|
|
}
|
|
this.module.modelUserMF.Change(session.GetUserId(), map[string]interface{}{
|
|
"triggerNum": umfantasy.TriggerNum,
|
|
"lastTrigger": umfantasy.LastTrigger,
|
|
"buyNum": umfantasy.BuyNum,
|
|
"battleNum": umfantasy.BattleNum,
|
|
})
|
|
}
|
|
mfantasys, err = this.module.modelDream.querymfantasys(session.GetUserId())
|
|
session.SendMsg(string(this.module.GetType()), "getlist", &pb.MoonfantasyGetListResp{
|
|
BattleNum: umfantasy.BattleNum,
|
|
BuyNum: umfantasy.BuyNum,
|
|
Dfantasys: mfantasys,
|
|
})
|
|
return
|
|
}
|