上传月之秘境触发机制
This commit is contained in:
parent
50fd39e1f0
commit
e01253f69f
@ -176,4 +176,9 @@ type (
|
||||
QueryOneHeroFetter(uid string, cid string) *pb.DBHeroFetter // 通过英雄配置id 查询羁绊信息
|
||||
AddHeroFetterData(uid string, heroConfId string) // 创建一条羁绊信息
|
||||
}
|
||||
//月子秘境
|
||||
IMoonFantasy interface {
|
||||
//触发月之秘境
|
||||
Trigger(session IUserSession, source *pb.BattleReport)
|
||||
}
|
||||
)
|
||||
|
@ -21,6 +21,7 @@ func NewModule() core.IModule {
|
||||
type Battle struct {
|
||||
modules.ModuleBase
|
||||
service core.IService
|
||||
moonfantasy comm.IMoonFantasy //月之秘境模块
|
||||
api_comp *apiComp
|
||||
configure *configureComp
|
||||
modelBattle *modelBattleComp
|
||||
@ -37,6 +38,15 @@ func (this *Battle) Init(service core.IService, module core.IModule, options cor
|
||||
this.service = service
|
||||
return
|
||||
}
|
||||
func (this *Battle) Start() (err error) {
|
||||
err = this.ModuleBase.Start()
|
||||
var module core.IModule
|
||||
if module, err = this.service.GetModule(comm.ModuleMoonfantasy); err != nil {
|
||||
return
|
||||
}
|
||||
this.moonfantasy = module.(comm.IMoonFantasy)
|
||||
return
|
||||
}
|
||||
|
||||
//装备组件
|
||||
func (this *Battle) OnInstallComp() {
|
||||
@ -96,5 +106,7 @@ func (this *Battle) CreatePvbBattle(session comm.IUserSession, req *pb.BattlePVE
|
||||
|
||||
//校验战报是否成功
|
||||
func (this *Battle) CheckBattleReport(session comm.IUserSession, report *pb.BattleReport) (code pb.ErrorCode, iswin bool) {
|
||||
|
||||
this.moonfantasy.Trigger(session, report)
|
||||
return pb.ErrorCode_Success, true
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package moonfantasy
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/mgo"
|
||||
@ -9,6 +10,7 @@ import (
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"go_dreamfactory/sys/db"
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
@ -71,6 +73,78 @@ func (this *modelDreamComp) addDreamData(user *pb.UserInfo, boss *cfg.GameDreaml
|
||||
return
|
||||
}
|
||||
|
||||
//触发月之秘境
|
||||
func (this *modelDreamComp) trigger(session comm.IUserSession, source *pb.BattleReport) {
|
||||
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
|
||||
)
|
||||
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 {
|
||||
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 {
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil {
|
||||
this.module.Errorf("no found uer:%d", session.GetUserId())
|
||||
return
|
||||
}
|
||||
if umfantasy, err = this.module.modelUserMF.QueryUsermfantasy(session.GetUserId()); err != nil {
|
||||
return
|
||||
}
|
||||
if mdata, err = this.module.modelDream.addDreamData(&pb.UserInfo{Uid: user.Uid, Name: user.Name, Avatar: user.Avatar}, boss); err != nil {
|
||||
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: user.Avatar,
|
||||
Uname: user.Name,
|
||||
Slv: user.Lv,
|
||||
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
|
||||
}
|
||||
|
||||
///查询好友数据
|
||||
func (this *modelDreamComp) noticeuserfriend(stag, uid, mid string, chat *pb.DBChat) (code pb.ErrorCode) {
|
||||
var (
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"go_dreamfactory/lego/base"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
|
||||
/*
|
||||
@ -62,3 +63,8 @@ func (this *Moonfantasy) OnInstallComp() {
|
||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||
this.modelUserMF = this.RegisterComp(new(modelUserMF)).(*modelUserMF)
|
||||
}
|
||||
|
||||
//触发月之秘境
|
||||
func (this *Moonfantasy) Trigger(session comm.IUserSession, source *pb.BattleReport) {
|
||||
this.modelDream.trigger(session, source)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user