This commit is contained in:
wh_zcy 2023-02-21 18:55:01 +08:00
commit 0adc56ddc7
8 changed files with 144 additions and 59 deletions

View File

@ -79,6 +79,7 @@ const (
ModuleAutoBattle core.M_Modules = "autobattle" //自动战斗
ModuleMline core.M_Modules = "mline" //主线模块
ModulePvp core.M_Modules = "pvp" //实时pvp
ModulePandaTakekan core.M_Modules = "pandatakekan" //熊猫武馆
)
// 数据表名定义处

View File

@ -6,6 +6,7 @@ import (
"go_dreamfactory/pb"
"sync"
"sync/atomic"
"time"
"github.com/gorilla/websocket"
"google.golang.org/protobuf/proto"
@ -15,7 +16,10 @@ import (
func newClient(addr string, mgr IClientMgr, log log.ILogger) (c *client, err error) {
c = &client{addr: addr, mgr: mgr, log: log, seq: 1, state: 1, pending: make(map[uint64]*MessageCall)}
dialer := websocket.Dialer{}
c.conn, _, err = dialer.Dial(addr, nil)
ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
if c.conn, _, err = dialer.DialContext(ctx, addr, nil); err != nil {
return
}
go c.run()
return
}

View File

@ -247,7 +247,7 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBCon
record.Redflist[0].Team[i].Ishelp = true
}
}
if ok := this.checkBattlereadyCapskill(req.Format.Leadpos, heros); ok {
if ok := this.checkBattlereadyCapskill(req.Format.Leadpos, heros); !ok {
code = pb.ErrorCode_BattleCapskillCheckFailed
return
}
@ -335,7 +335,7 @@ func (this *modelBattleComp) createpvb(session comm.IUserSession, conn *db.DBCon
record.Redflist[ii].Team[i].Ishelp = true
}
}
if ok := this.checkBattlereadyCapskill(v.Leadpos, heros); ok {
if ok := this.checkBattlereadyCapskill(v.Leadpos, heros); !ok {
code = pb.ErrorCode_BattleCapskillCheckFailed
return
}
@ -385,7 +385,7 @@ func (this *modelBattleComp) createpvp(session comm.IUserSession, conn *db.DBCon
record.Redflist[0].Team[i] = nil
}
}
if ok := this.checkBattlereadyCapskill(req.Redformat.Leadpos, req.Redformat.Format); ok {
if ok := this.checkBattlereadyCapskill(req.Redformat.Leadpos, req.Redformat.Format); !ok {
code = pb.ErrorCode_BattleCapskillCheckFailed
return
}
@ -405,7 +405,7 @@ func (this *modelBattleComp) createpvp(session comm.IUserSession, conn *db.DBCon
record.Buleflist[0].Team[i] = nil
}
}
if ok := this.checkBattlereadyCapskill(req.Buleformat.Leadpos, req.Buleformat.Format); ok {
if ok := this.checkBattlereadyCapskill(req.Buleformat.Leadpos, req.Buleformat.Format); !ok {
code = pb.ErrorCode_BattleCapskillCheckFailed
return
}
@ -446,7 +446,7 @@ func (this *modelBattleComp) creatertpvp(redmodel, bluemodel *db.DBModel, btype
record.Redflist[ii].Team[i] = nil
}
}
if ok := this.checkBattlereadyCapskill(v.Leadpos, heros); ok {
if ok := this.checkBattlereadyCapskill(v.Leadpos, heros); !ok {
code = pb.ErrorCode_BattleCapskillCheckFailed
return
}
@ -472,7 +472,7 @@ func (this *modelBattleComp) creatertpvp(redmodel, bluemodel *db.DBModel, btype
record.Buleflist[ii].Team[i] = nil
}
}
if ok := this.checkBattlereadyCapskill(v.Leadpos, heros); ok {
if ok := this.checkBattlereadyCapskill(v.Leadpos, heros); !ok {
code = pb.ErrorCode_BattleCapskillCheckFailed
return
}

View File

@ -52,7 +52,9 @@ func (this *Battle) Init(service core.IService, module core.IModule, options cor
return
}
func (this *Battle) Start() (err error) {
err = this.ModuleBase.Start()
if err = this.ModuleBase.Start(); err != nil {
return
}
var module core.IModule
if module, err = this.service.GetModule(comm.ModuleFriend); err != nil {
return

View File

@ -57,7 +57,9 @@ func (this *ModuleBase) Init(service core.IService, module core.IModule, options
//模块启动接口
func (this *ModuleBase) Start() (err error) {
err = this.ModuleBase.Start()
if err = this.ModuleBase.Start(); err != nil {
return
}
var comp core.IServiceComp
//注册远程路由
if comp, err = this.service.GetComp(comm.SC_ServiceGateRouteComp); err != nil {

View File

@ -0,0 +1,29 @@
package pandatakekan
import (
"go_dreamfactory/modules"
"go_dreamfactory/lego/core"
)
/*
API
*/
type apiComp struct {
modules.MCompGate
service core.IService
module *PandaTakekan
}
//组件初始化接口
func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.MCompGate.Init(service, module, comp, options)
this.module = module.(*PandaTakekan)
this.service = service
return
}
func (this *apiComp) Start() (err error) {
err = this.MCompGate.Start()
return
}

View File

@ -0,0 +1,49 @@
package pandatakekan
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/base"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
)
/*
模块名:熊猫武馆
描述:熊猫武馆 主系统 打桩 以及武馆相关数据管理
开发:李伟
*/
func NewModule() core.IModule {
m := new(PandaTakekan)
return m
}
type PandaTakekan struct {
modules.ModuleBase
service base.IRPCXService
api *apiComp
}
//模块名
func (this *PandaTakekan) GetType() core.M_Modules {
return comm.ModulePandaTakekan
}
//模块初始化接口 注册用户创建角色事件
func (this *PandaTakekan) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
err = this.ModuleBase.Init(service, module, options)
this.service = service.(base.IRPCXService)
return
}
func (this *PandaTakekan) Start() (err error) {
err = this.ModuleBase.Start()
return
}
//装备组件
func (this *PandaTakekan) OnInstallComp() {
this.ModuleBase.OnInstallComp()
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
}

View File

@ -71,8 +71,6 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
err = this.LoadConfigure(game_smithyatlaslv, cfg.NewGameSmithyAtlasLv)
err = this.LoadConfigure(game_smithyatlasscore, cfg.NewGameSmithyAtlasScore)
_d := this.GetSmithProficiencyConf(1)
this.module.Errorf("%v", _d)
return
}
@ -252,7 +250,7 @@ func (this *configureComp) GetSmithyStoveConf(level int32) (data *cfg.GameSmithy
// 获取图鉴信息
func (this *configureComp) GetSmithyAtlasConf(id string) (data *cfg.GameSmithyAtlasData) {
if v, err := this.GetConfigure(game_smithystove); err == nil {
if v, err := this.GetConfigure(game_smithyatlas); err == nil {
if configure, ok := v.(*cfg.GameSmithyAtlas); ok {
data = configure.Get(id)
return
@ -263,7 +261,7 @@ func (this *configureComp) GetSmithyAtlasConf(id string) (data *cfg.GameSmithyAt
}
func (this *configureComp) GetSmithyAtlasLvConf(lv int32) (data *cfg.GameSmithyAtlasLvData) {
if v, err := this.GetConfigure(game_smithystove); err == nil {
if v, err := this.GetConfigure(game_smithyatlaslv); err == nil {
if configure, ok := v.(*cfg.GameSmithyAtlasLv); ok {
data = configure.Get(lv)
return
@ -279,7 +277,7 @@ func (this *configureComp) GetSmithyAtlasScoreConf(quality int32, lv int32) (dat
// 获取图鉴分数
func (this *configureComp) LoadSmithyAtlasScoreConf() {
if v, err := this.GetConfigure(game_smithystove); err == nil {
if v, err := this.GetConfigure(game_smithyatlasscore); err == nil {
if configure, ok := v.(*cfg.GameSmithyAtlasScore); ok {
this.hlock.Lock()
defer this.hlock.Unlock()