自动战斗
This commit is contained in:
parent
28b684a112
commit
7f57b8521a
@ -158,8 +158,8 @@ const (
|
|||||||
TableLinestory = "linestory"
|
TableLinestory = "linestory"
|
||||||
|
|
||||||
TableFetterstory = "fetterstory"
|
TableFetterstory = "fetterstory"
|
||||||
TableLibrary = "library"
|
TableLibrary = "library"
|
||||||
TableFetter = "herofetter"
|
TableFetter = "herofetter"
|
||||||
|
|
||||||
TableCrossSession = "crosssession"
|
TableCrossSession = "crosssession"
|
||||||
|
|
||||||
@ -208,6 +208,9 @@ const (
|
|||||||
|
|
||||||
TableEnchantRank = "enchantRank"
|
TableEnchantRank = "enchantRank"
|
||||||
TableEnchant = "enchant"
|
TableEnchant = "enchant"
|
||||||
|
|
||||||
|
// 自动战斗
|
||||||
|
TableAuto = "autoBattle"
|
||||||
)
|
)
|
||||||
|
|
||||||
//RPC服务接口定义处
|
//RPC服务接口定义处
|
||||||
|
49
modules/auto/api.go
Normal file
49
modules/auto/api.go
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package autoBattle
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/modules"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
HuntingGetListResp = "getlist"
|
||||||
|
HuntingChallengeResp = "challenge"
|
||||||
|
HuntingChallengeOverResp = "challengeover"
|
||||||
|
HuntingSkillLvResp = "skilllv"
|
||||||
|
HuntingGetRewardResp = "getreward"
|
||||||
|
HuntingBuyResp = "buy"
|
||||||
|
HuntingRankListResp = "ranklist"
|
||||||
|
)
|
||||||
|
|
||||||
|
type apiComp struct {
|
||||||
|
modules.MCompGate
|
||||||
|
service core.IService
|
||||||
|
configure *configureComp
|
||||||
|
module *AutoBattle
|
||||||
|
friend comm.IFriend
|
||||||
|
chat comm.IChat
|
||||||
|
}
|
||||||
|
|
||||||
|
//组件初始化接口
|
||||||
|
func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
|
err = this.MCompGate.Init(service, module, comp, options)
|
||||||
|
this.module = module.(*AutoBattle)
|
||||||
|
|
||||||
|
this.service = service
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *apiComp) Start() (err error) {
|
||||||
|
err = this.MCompGate.Start()
|
||||||
|
var module core.IModule
|
||||||
|
if module, err = this.service.GetModule(comm.ModuleFriend); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.friend = module.(comm.IFriend)
|
||||||
|
if module, err = this.service.GetModule(comm.ModuleChat); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.chat = module.(comm.IChat)
|
||||||
|
return
|
||||||
|
}
|
22
modules/auto/api_buy.go
Normal file
22
modules/auto/api_buy.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package autoBattle
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
//参数校验
|
||||||
|
func (this *apiComp) BuyCheck(session comm.IUserSession, req *pb.HuntingBuyReq) (code pb.ErrorCode) {
|
||||||
|
if req.Count <= 0 {
|
||||||
|
code = pb.ErrorCode_ReqParameterError
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *apiComp) Buy(session comm.IUserSession, req *pb.HuntingBuyReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
23
modules/auto/api_challenge.go
Normal file
23
modules/auto/api_challenge.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package autoBattle
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
//参数校验
|
||||||
|
func (this *apiComp) ChallengeCheck(session comm.IUserSession, req *pb.HuntingChallengeReq) (code pb.ErrorCode) {
|
||||||
|
if req.BossType <= 0 && req.Difficulty > 0 {
|
||||||
|
code = pb.ErrorCode_ReqParameterError
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
///挑战主线关卡
|
||||||
|
func (this *apiComp) Challenge(session comm.IUserSession, req *pb.HuntingChallengeReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
23
modules/auto/api_challengeover.go
Normal file
23
modules/auto/api_challengeover.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package autoBattle
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
//参数校验
|
||||||
|
func (this *apiComp) ChallengeOverCheck(session comm.IUserSession, req *pb.HuntingChallengeOverReq) (code pb.ErrorCode) {
|
||||||
|
if req.BossType <= 0 && req.Difficulty > 0 {
|
||||||
|
code = pb.ErrorCode_ReqParameterError
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
///挑战主线关卡
|
||||||
|
func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingChallengeOverReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
19
modules/auto/api_getlist.go
Normal file
19
modules/auto/api_getlist.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package autoBattle
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
//参数校验
|
||||||
|
func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.HuntingGetListReq) (code pb.ErrorCode) {
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *apiComp) GetList(session comm.IUserSession, req *pb.HuntingGetListReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
39
modules/auto/comp_configure.go
Normal file
39
modules/auto/comp_configure.go
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package autoBattle
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/lego/sys/log"
|
||||||
|
"go_dreamfactory/modules"
|
||||||
|
"go_dreamfactory/sys/configure"
|
||||||
|
)
|
||||||
|
|
||||||
|
const ()
|
||||||
|
|
||||||
|
///配置管理基础组件
|
||||||
|
type configureComp struct {
|
||||||
|
modules.MCompConfigure
|
||||||
|
}
|
||||||
|
|
||||||
|
//组件初始化接口
|
||||||
|
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
|
err = this.MCompConfigure.Init(service, module, comp, options)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//加载多个配置文件
|
||||||
|
func (this *configureComp) LoadMultiConfigure(confs map[string]interface{}) (err error) {
|
||||||
|
for k, v := range confs {
|
||||||
|
err = configure.RegisterConfigure(k, v, nil)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("配置文件:%s解析失败!", k)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//读取配置数据
|
||||||
|
func (this *configureComp) GetConfigure(name string) (v interface{}, err error) {
|
||||||
|
return configure.GetConfigure(name)
|
||||||
|
}
|
43
modules/auto/model_auto.go
Normal file
43
modules/auto/model_auto.go
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package autoBattle
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/modules"
|
||||||
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
|
"go.mongodb.org/mongo-driver/x/bsonx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type modelAutoBattle struct {
|
||||||
|
modules.MCompModel
|
||||||
|
module *AutoBattle
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *modelAutoBattle) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
|
this.TableName = string(comm.TableAuto)
|
||||||
|
err = this.MCompModel.Init(service, module, comp, options)
|
||||||
|
this.module = module.(*AutoBattle)
|
||||||
|
// uid 创建索引
|
||||||
|
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
||||||
|
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *modelAutoBattle) modifyAutoBattleDataByObjId(uid string, id string, data map[string]interface{}) error {
|
||||||
|
err := this.ChangeList(uid, id, data)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取列表信息
|
||||||
|
func (this *modelAutoBattle) getAutoBattleList(uid string) (result *pb.DBAutoBattle, err error) {
|
||||||
|
result = &pb.DBAutoBattle{}
|
||||||
|
if err = this.Get(uid, result); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = nil
|
||||||
|
return result, err
|
||||||
|
}
|
63
modules/auto/module.go
Normal file
63
modules/auto/module.go
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
package autoBattle
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/modules"
|
||||||
|
"go_dreamfactory/pb"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AutoBattle struct {
|
||||||
|
modules.ModuleBase
|
||||||
|
modelAutoBattle *modelAutoBattle
|
||||||
|
api *apiComp
|
||||||
|
configure *configureComp
|
||||||
|
battle comm.IBattle
|
||||||
|
service core.IService
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewModule() core.IModule {
|
||||||
|
return &AutoBattle{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *AutoBattle) GetType() core.M_Modules {
|
||||||
|
return comm.ModuleHunting
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *AutoBattle) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
||||||
|
err = this.ModuleBase.Init(service, module, options)
|
||||||
|
this.service = service
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *AutoBattle) Start() (err error) {
|
||||||
|
err = this.ModuleBase.Start()
|
||||||
|
var module core.IModule
|
||||||
|
if module, err = this.service.GetModule(comm.ModuleBattle); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.battle = module.(comm.IBattle)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *AutoBattle) OnInstallComp() {
|
||||||
|
this.ModuleBase.OnInstallComp()
|
||||||
|
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||||
|
|
||||||
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 接口信息
|
||||||
|
func (this *AutoBattle) ModifyAutoData(uid string, id string, data map[string]interface{}) (code pb.ErrorCode) {
|
||||||
|
err := this.modelAutoBattle.modifyAutoBattleDataByObjId(uid, id, data)
|
||||||
|
if err != nil {
|
||||||
|
code = pb.ErrorCode_DBError
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *AutoBattle) CheckUserBaseHuntingInfo(uid string) (data []*pb.DBHuntingRank) {
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user