上传月之秘境代码
This commit is contained in:
parent
248ee4ed5e
commit
366bd86cb8
@ -1,98 +1,87 @@
|
||||
package moonfantasy
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"math/big"
|
||||
"time"
|
||||
// //参数校验
|
||||
// func (this *apiComp) TriggerCheck(session comm.IUserSession, req *pb.MoonfantasyTriggerReq) (code pb.ErrorCode) {
|
||||
// return
|
||||
// }
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
// ///获取本服聊天消息记录
|
||||
// func (this *apiComp) Trigger(session comm.IUserSession, req *pb.MoonfantasyTriggerReq) (code pb.ErrorCode, data proto.Message) {
|
||||
// var (
|
||||
// user *pb.DBUser
|
||||
// umfantasy *pb.DBUserMFantasy
|
||||
// globalconf *cfg.GameGlobalData
|
||||
// uexpand *pb.DBUserExpand
|
||||
// boss *cfg.GameDreamlandBoosData
|
||||
// mdata *pb.DBMoonFantasy
|
||||
// chat *pb.DBChat
|
||||
// issucc bool
|
||||
// err error
|
||||
// )
|
||||
|
||||
//参数校验
|
||||
func (this *apiComp) TriggerCheck(session comm.IUserSession, req *pb.MoonfantasyTriggerReq) (code pb.ErrorCode) {
|
||||
return
|
||||
}
|
||||
// if code = this.TriggerCheck(session, req); code != pb.ErrorCode_Success {
|
||||
// return
|
||||
// }
|
||||
// globalconf = this.module.configure.GetGlobalConf()
|
||||
// n, _ := rand.Int(rand.Reader, big.NewInt(100))
|
||||
// if int32(n.Int64()) < globalconf.DreamlandPro {
|
||||
// issucc = true
|
||||
// } else {
|
||||
// issucc = false
|
||||
// }
|
||||
// if issucc {
|
||||
// if uexpand, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil {
|
||||
// code = pb.ErrorCode_DBError
|
||||
// this.module.Errorln(err)
|
||||
// return
|
||||
// }
|
||||
// if time.Unix(uexpand.MoonfantasyLastTrigger, 0).Day() != time.Now().Day() {
|
||||
// uexpand.MoonfantasyTriggerNum = 0
|
||||
// }
|
||||
|
||||
///获取本服聊天消息记录
|
||||
func (this *apiComp) Trigger(session comm.IUserSession, req *pb.MoonfantasyTriggerReq) (code pb.ErrorCode, data proto.Message) {
|
||||
var (
|
||||
user *pb.DBUser
|
||||
umfantasy *pb.DBUserMFantasy
|
||||
globalconf *cfg.GameGlobalData
|
||||
uexpand *pb.DBUserExpand
|
||||
boss *cfg.GameDreamlandBoosData
|
||||
mdata *pb.DBMoonFantasy
|
||||
chat *pb.DBChat
|
||||
issucc bool
|
||||
err error
|
||||
)
|
||||
// if uexpand.MoonfantasyTriggerNum >= globalconf.DreamlandTriggernum {
|
||||
// return
|
||||
// }
|
||||
|
||||
if code = this.TriggerCheck(session, req); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
globalconf = this.module.configure.GetGlobalConf()
|
||||
n, _ := rand.Int(rand.Reader, big.NewInt(100))
|
||||
if int32(n.Int64()) < globalconf.DreamlandPro {
|
||||
issucc = true
|
||||
} else {
|
||||
issucc = false
|
||||
}
|
||||
if issucc {
|
||||
if uexpand, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
if time.Unix(uexpand.MoonfantasyLastTrigger, 0).Day() != time.Now().Day() {
|
||||
uexpand.MoonfantasyTriggerNum = 0
|
||||
}
|
||||
|
||||
if uexpand.MoonfantasyTriggerNum >= globalconf.DreamlandTriggernum {
|
||||
return
|
||||
}
|
||||
|
||||
if boss, err = this.module.configure.GetMonster(); err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil {
|
||||
this.module.Errorf("no found uer:%d", session.GetUserId())
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
if umfantasy, err = this.module.modelUserMF.QueryUsermfantasy(session.GetUserId()); err != nil {
|
||||
code = pb.ErrorCode_CacheReadError
|
||||
return
|
||||
}
|
||||
if mdata, err = this.module.modelDream.addDreamData(&pb.UserInfo{Uid: user.Uid, Name: user.Name, Avatar: user.Avatar}, boss); err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
umfantasy.Mfantasys = append(umfantasy.Mfantasys, mdata.Id)
|
||||
this.module.modelUserMF.Change(session.GetUserId(), map[string]interface{}{
|
||||
"mfantasys": umfantasy.Mfantasys,
|
||||
})
|
||||
this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{
|
||||
"moonfantasyTriggerNum": uexpand.MoonfantasyTriggerNum + 1,
|
||||
"moonfantasyLastTrigger": time.Now().Unix(),
|
||||
})
|
||||
chat = &pb.DBChat{
|
||||
Ctype: pb.ChatType_Moonfantasy,
|
||||
Suid: session.GetUserId(),
|
||||
Avatar: req.Avatar,
|
||||
Uname: req.Uname,
|
||||
Slv: req.Ulv,
|
||||
Stag: session.GetServiecTag(),
|
||||
Content: mdata.Monster,
|
||||
AppendStr: mdata.Id,
|
||||
}
|
||||
this.module.modelDream.noticeuserfriend(session.GetServiecTag(), session.GetUserId(), mdata.Id, chat)
|
||||
session.SendMsg(string(this.module.GetType()), "trigger", &pb.MoonfantasyTriggerResp{Issucc: true, Mid: mdata.Id, Monster: mdata.Monster})
|
||||
} else {
|
||||
session.SendMsg(string(this.module.GetType()), "trigger", &pb.MoonfantasyTriggerResp{Issucc: false})
|
||||
}
|
||||
return
|
||||
}
|
||||
// if boss, err = this.module.configure.GetMonster(); err != nil {
|
||||
// code = pb.ErrorCode_ConfigNoFound
|
||||
// return
|
||||
// }
|
||||
// if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil {
|
||||
// this.module.Errorf("no found uer:%d", session.GetUserId())
|
||||
// code = pb.ErrorCode_DBError
|
||||
// return
|
||||
// }
|
||||
// if umfantasy, err = this.module.modelUserMF.QueryUsermfantasy(session.GetUserId()); err != nil {
|
||||
// code = pb.ErrorCode_CacheReadError
|
||||
// return
|
||||
// }
|
||||
// if mdata, err = this.module.modelDream.addDreamData(&pb.UserInfo{Uid: user.Uid, Name: user.Name, Avatar: user.Avatar}, boss); err != nil {
|
||||
// code = pb.ErrorCode_DBError
|
||||
// return
|
||||
// }
|
||||
// umfantasy.Mfantasys = append(umfantasy.Mfantasys, mdata.Id)
|
||||
// this.module.modelUserMF.Change(session.GetUserId(), map[string]interface{}{
|
||||
// "mfantasys": umfantasy.Mfantasys,
|
||||
// })
|
||||
// this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{
|
||||
// "moonfantasyTriggerNum": uexpand.MoonfantasyTriggerNum + 1,
|
||||
// "moonfantasyLastTrigger": time.Now().Unix(),
|
||||
// })
|
||||
// chat = &pb.DBChat{
|
||||
// Ctype: pb.ChatType_Moonfantasy,
|
||||
// Suid: session.GetUserId(),
|
||||
// Avatar: req.Avatar,
|
||||
// Uname: req.Uname,
|
||||
// Slv: req.Ulv,
|
||||
// Stag: session.GetServiecTag(),
|
||||
// Content: mdata.Monster,
|
||||
// AppendStr: mdata.Id,
|
||||
// }
|
||||
// this.module.modelDream.noticeuserfriend(session.GetServiecTag(), session.GetUserId(), mdata.Id, chat)
|
||||
// session.SendMsg(string(this.module.GetType()), "trigger", &pb.MoonfantasyTriggerResp{Issucc: true, Mid: mdata.Id, Monster: mdata.Monster})
|
||||
// } else {
|
||||
// session.SendMsg(string(this.module.GetType()), "trigger", &pb.MoonfantasyTriggerResp{Issucc: false})
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
|
@ -1,7 +1,6 @@
|
||||
package moonfantasy
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/mgo"
|
||||
@ -10,7 +9,6 @@ import (
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"go_dreamfactory/sys/db"
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
@ -87,12 +85,12 @@ func (this *modelDreamComp) trigger(session comm.IUserSession, source *pb.Battle
|
||||
err error
|
||||
)
|
||||
globalconf = this.module.configure.GetGlobalConf()
|
||||
n, _ := rand.Int(rand.Reader, big.NewInt(100))
|
||||
if int32(n.Int64()) < globalconf.DreamlandPro {
|
||||
issucc = true
|
||||
} else {
|
||||
issucc = false
|
||||
}
|
||||
|
||||
// if int32(n.Int64()) < globalconf.DreamlandPro {
|
||||
// issucc = true
|
||||
// } else {
|
||||
// issucc = false
|
||||
// }
|
||||
if issucc {
|
||||
if uexpand, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil {
|
||||
this.module.Errorln(err)
|
||||
|
@ -66,5 +66,6 @@ func (this *Moonfantasy) OnInstallComp() {
|
||||
|
||||
//触发月之秘境
|
||||
func (this *Moonfantasy) Trigger(session comm.IUserSession, source *pb.BattleReport) {
|
||||
// n, _ := rand.Int(rand.Reader, big.NewInt(100))
|
||||
this.modelDream.trigger(session, source)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user