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