From 3c8acf03929699c271a4a52798e28f664be90d44 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Tue, 31 Jan 2023 17:06:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=9C=88=E5=AD=90=E7=A7=98?= =?UTF-8?q?=E5=A2=83=E5=BC=82=E5=B8=B8=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 1 + modules/items/modelitems.go | 1 + modules/moonfantasy/api_battle.go | 10 +++++++--- modules/moonfantasy/api_getlist.go | 11 ++++++----- modules/moonfantasy/modelUserMF.go | 3 +-- modules/rtimepvp/api.go | 29 +++++++++++++++++++++++++++++ modules/rtimepvp/module.go | 28 ++++++++++++++++++++++++++++ services/comp_gateroute.go | 19 +++++++++---------- sys/db/dbmodel.go | 2 +- 9 files changed, 83 insertions(+), 21 deletions(-) create mode 100644 modules/rtimepvp/api.go create mode 100644 modules/rtimepvp/module.go diff --git a/comm/const.go b/comm/const.go index 5ba030703..b1bcbfd38 100644 --- a/comm/const.go +++ b/comm/const.go @@ -78,6 +78,7 @@ const ( ModuleEnchant core.M_Modules = "enchant" //附魔 ModuleAutoBattle core.M_Modules = "autobattle" //自动战斗 ModuleMline core.M_Modules = "mline" //主线模块 + ModuleRTimePVP core.M_Modules = "rtimepvp" //实时pvp ) //数据表名定义处 diff --git a/modules/items/modelitems.go b/modules/items/modelitems.go index 98214e3e7..742874cfa 100644 --- a/modules/items/modelitems.go +++ b/modules/items/modelitems.go @@ -195,6 +195,7 @@ func (this *ModelItemsComp) QueryUserPackItemsAmount(uId string, itemid ...strin itmes []*pb.DB_UserItemData err error ) + if itmes, err = this.QueryUserPack(uId); err != nil { this.module.Errorf("err:%v", err) return diff --git a/modules/moonfantasy/api_battle.go b/modules/moonfantasy/api_battle.go index 45c6c9df5..e3cfb150c 100644 --- a/modules/moonfantasy/api_battle.go +++ b/modules/moonfantasy/api_battle.go @@ -81,9 +81,7 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattle // if umfantasy, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil { // cd = pb.ErrorCode_CacheReadError // } - if cd = this.module.CheckRes(session, boss.PsConsume); cd != pb.ErrorCode_Success { - return - } + // if umfantasy.Ticket < this.module.configure.GetGlobalConf().DreamlandCos { // cd = pb.ErrorCode_MoonfantasyNotEnoughbattles // } @@ -92,6 +90,12 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattle cd = pb.ErrorCode_ConfigNoFound return } + if cd = this.module.ModuleItems.RecoverTicket(session); cd != pb.ErrorCode_Success { + return + } + if cd = this.module.CheckRes(session, boss.PsConsume); cd != pb.ErrorCode_Success { + return + } if len(mdata.Join) >= int(mdata.Numup) { cd = pb.ErrorCode_MoonfantasyJoinUp diff --git a/modules/moonfantasy/api_getlist.go b/modules/moonfantasy/api_getlist.go index 9c09e2f76..a13d3626f 100644 --- a/modules/moonfantasy/api_getlist.go +++ b/modules/moonfantasy/api_getlist.go @@ -25,11 +25,12 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.MoonfantasyGetLi code = pb.ErrorCode_CacheReadError return } - this.module.modelUserMF.recoverTicket(session, info) - if err = this.module.modelUserMF.updateUserInfo(info); err != nil { - code = pb.ErrorCode_DBError - return - } + // this.module.modelUserMF.recoverTicket(session, info) + // if err = this.module.modelUserMF.updateUserInfo(info); err != nil { + // code = pb.ErrorCode_DBError + // return + // } + this.module.ModuleItems.RecoverTicket(session) mfantasys, err = this.module.modelDream.querymfantasys(session.GetUserId()) session.SendMsg(string(this.module.GetType()), "getlist", &pb.MoonfantasyGetListResp{ // BattleNum: info.Ticket, diff --git a/modules/moonfantasy/modelUserMF.go b/modules/moonfantasy/modelUserMF.go index bd4167e6c..b7373f29c 100644 --- a/modules/moonfantasy/modelUserMF.go +++ b/modules/moonfantasy/modelUserMF.go @@ -63,8 +63,7 @@ func (this *modelUserMF) queryUsermfantasy(uId string) (info *pb.DBUserMFantasy, ///保存用户竞技场信息 func (this *modelUserMF) updateUserInfo(info *pb.DBUserMFantasy) (err error) { this.Change(info.Uid, map[string]interface{}{ - "triggerNum": info.TriggerNum, - // "ticket": info.Ticket, + "triggerNum": info.TriggerNum, "buyNum": info.BuyNum, "lastTrigger": info.LastTrigger, "lastrtickettime": info.Lastrtickettime, diff --git a/modules/rtimepvp/api.go b/modules/rtimepvp/api.go new file mode 100644 index 000000000..2ea30dc96 --- /dev/null +++ b/modules/rtimepvp/api.go @@ -0,0 +1,29 @@ +package rtimepvp + +import ( + "go_dreamfactory/modules" + + "go_dreamfactory/lego/core" +) + +/* +装备模块 API +*/ +type apiComp struct { + modules.MCompGate + service core.IService + module *RTimePVP +} + +//组件初始化接口 +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.(*RTimePVP) + this.service = service + return +} + +func (this *apiComp) Start() (err error) { + err = this.MCompGate.Start() + return +} diff --git a/modules/rtimepvp/module.go b/modules/rtimepvp/module.go new file mode 100644 index 000000000..d8decae43 --- /dev/null +++ b/modules/rtimepvp/module.go @@ -0,0 +1,28 @@ +package rtimepvp + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/lego/base" + "go_dreamfactory/lego/core" + "go_dreamfactory/modules" +) + +/* +模块名:实时PVP +描述:同步战斗模块 +开发:李伟 +*/ +func NewModule() core.IModule { + m := new(RTimePVP) + return m +} + +type RTimePVP struct { + modules.ModuleBase + service base.IRPCXService +} + +//模块名 +func (this *RTimePVP) GetType() core.M_Modules { + return comm.ModuleRTimePVP +} diff --git a/services/comp_gateroute.go b/services/comp_gateroute.go index f80306a86..1f87e10f4 100644 --- a/services/comp_gateroute.go +++ b/services/comp_gateroute.go @@ -8,7 +8,6 @@ import ( "go_dreamfactory/sys/configure" "go_dreamfactory/sys/db" "reflect" - "runtime" "sync" "time" @@ -119,15 +118,15 @@ func (this *SCompGateRoute) RegisterRoute(methodName string, comp reflect.Value, //Rpc_GatewayRoute服务接口的接收函数 func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessage, reply *pb.RPCMessageReply) (err error) { method := fmt.Sprintf("%s.%s", args.MainType, args.SubType) - defer func() { //程序异常 收集异常信息传递给前端显示 - if r := recover(); r != nil { - buf := make([]byte, 4096) - l := runtime.Stack(buf, false) - reply.Code = pb.ErrorCode_Exception - reply.ErrorMessage = fmt.Sprintf("%v: %s", r, buf[:l]) - log.Errorf("[Handle Api] m:%s reply:%s", method, reply) - } - }() + // defer func() { //程序异常 收集异常信息传递给前端显示 + // if r := recover(); r != nil { + // buf := make([]byte, 4096) + // l := runtime.Stack(buf, false) + // reply.Code = pb.ErrorCode_Exception + // reply.ErrorMessage = fmt.Sprintf("%v: %s", r, buf[:l]) + // log.Errorf("[Handle Api] m:%s reply:%s", method, reply) + // } + // }() //获取用户消息处理函数 this.mrlock.RLock() msghandle, ok := this.msghandles[method] diff --git a/sys/db/dbmodel.go b/sys/db/dbmodel.go index d741b29df..9b6ebf045 100644 --- a/sys/db/dbmodel.go +++ b/sys/db/dbmodel.go @@ -441,7 +441,7 @@ func (this *DBModel) GetList(uid string, data interface{}) (err error) { buf := make([]byte, 4096) l := runtime.Stack(buf, false) err = fmt.Errorf("%v: %s", r, buf[:l]) - log.Errorf("[DB GetList] TableName:%s uid:%s", this.TableName, uid) + log.Errorf("[DB GetList] TableName:%s uid:%s err:%v", this.TableName, uid, err) } }() var (