This commit is contained in:
wh_zcy 2023-01-31 17:20:50 +08:00
commit a0e7048039
9 changed files with 83 additions and 21 deletions

View File

@ -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
)
//数据表名定义处

View File

@ -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

View File

@ -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

View File

@ -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,

View File

@ -64,7 +64,6 @@ 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,
"buyNum": info.BuyNum,
"lastTrigger": info.LastTrigger,
"lastrtickettime": info.Lastrtickettime,

29
modules/rtimepvp/api.go Normal file
View File

@ -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
}

View File

@ -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
}

View File

@ -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]

View File

@ -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 (