上传配置

This commit is contained in:
liwei1dao 2023-09-14 11:03:14 +08:00
parent d6979dd797
commit d3d4998ec7
2 changed files with 88 additions and 8 deletions

View File

@ -49,12 +49,45 @@ func (this *ModuleRobot_MainLine) Receive(robot IRobot, stype string, message pr
return
}
func (this *ModuleRobot_MainLine) OncePipeline(robot IRobot) (err error) {
var (
errdata *pb.ErrorData
)
if _, errdata = robot.SendMessage("mainline", "info", &pb.MainlineInfoReq{}); errdata != nil {
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
return
}
return
}
//机器人执行流
func (this *ModuleRobot_MainLine) DoPipeline(robot IRobot) (err error) {
var (
errdata *pb.ErrorData
heromodule *ModuleRobot_Hero
conf *cfg.GameMainStageData
heros []string
resp proto.Message
)
if conf, err = this.findcanpasslevel(); err != nil { //找到目标管卡
return
}
heromodule = robot.GetModule(comm.ModuleHero).(*ModuleRobot_Hero)
heros = heromodule.getbattlehero()
if resp, errdata = robot.SendMessage("mainline", "challenge",
&pb.MainlineChallengeReq{Level: conf.Id, Battle: &pb.BattleFormation{
Format: heros,
}}); errdata != nil {
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
return
}
if _, errdata = robot.SendMessage("mainline", "challengeover", &pb.MainlineChallengeOverReq{Level: conf.Id, Report: &pb.BattleReport{
Info: resp.(*pb.MainlineChallengeResp).Info,
WinSide: 1,
}}); errdata != nil {
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
return
}
this.info.Level[conf.Id] = 32
return
}
@ -63,10 +96,6 @@ func (this *ModuleRobot_MainLine) DoTask(robot IRobot, taskconf *cfg.GameWorldTa
var (
errdata *pb.ErrorData
)
if _, errdata = robot.SendMessage("mainline", "info", &pb.MainlineInfoReq{}); errdata != nil {
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
return
}
switch comm.TaskType(condconf.Type) {
case comm.Rtype61:
var (
@ -179,3 +208,46 @@ func (this *ModuleRobot_MainLine) getGameMainStageDatas() (confs []*cfg.GameMain
}
return
}
func (this *ModuleRobot_MainLine) findcanpasslevel() (conf *cfg.GameMainStageData, err error) {
var (
v interface{}
confs []*cfg.GameMainStageData
ok bool
)
if v, err = configure.GetConfigure(game_mainstage); err != nil {
return
} else {
for _, tempconf := range v.(*cfg.GameMainStage).GetDataList() {
if _, ok = this.info.Level[tempconf.Id]; ok { //已通关
continue
}
ok = true
//前置组判断
for _, v := range tempconf.PreviousGroupId {
confs = this.group[v]
for _, nconf := range confs {
if _, ok = this.info.Level[nconf.Id]; !ok {
ok = false
break
}
}
if !ok {
break
}
}
if !ok {
continue
}
if tempconf.Previoustage != 0 {
if _, ok = this.info.Level[tempconf.Previoustage]; !ok {
continue
}
}
conf = tempconf
return
}
err = fmt.Errorf("no fund lv")
}
return
}

View File

@ -7,6 +7,7 @@ import (
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/x/bsonx"
)
@ -30,11 +31,18 @@ func (this *modelShopComp) Init(service core.IService, module core.IModule, comp
}
//查询用户装备数据
func (this *modelShopComp) QueryUserShopData(uId string) (data *pb.DBShop, err error) {
func (this *modelShopComp) QueryUserShopData(uid string) (data *pb.DBShop, err error) {
data = &pb.DBShop{}
if err = this.Get(uId, data); err != nil && err != mgo.MongodbNil {
if err = this.Get(uid, data); err != nil && err != mgo.MongodbNil {
this.module.Errorf("err:%v", err)
}
err = nil
if err == mgo.MongodbNil { //没有数据初始化数据
data = &pb.DBShop{
Id: primitive.NewObjectID().Hex(),
Uid: uid,
}
err = this.Add(uid, data)
}
return
}