From c6141da5a022d2619b53768106e6b816e4a515e0 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 30 Nov 2023 10:00:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=89=E6=B6=88=E9=82=80=E8=AF=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/imodule.go | 14 ++++++-------- modules/gameinvite/api_accept.go | 2 +- modules/gameinvite/api_admitdefeat.go | 10 ++++++++++ modules/gameinvite/module.go | 8 ++++++++ 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/comm/imodule.go b/comm/imodule.go index 87df73d28..324a71e9e 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -687,6 +687,12 @@ type ( IEntertainment interface { // 添加三消卡片资源 AddXxlCard(session IUserSession, cards map[string]int32, bPush bool) (errdata *pb.ErrorData) + + CreateRoom(sessions []IUserSession, rulesStr string) (roomid string, err error) + //用户离线 + UserOffline(roomid string, uid string) (err error) + //主动认输 + AdmitDefeat(roomid string, uid string) (err error) } IMoonlv interface { IBuriedUpdateNotify @@ -703,12 +709,4 @@ type ( IIsland interface { IPayDelivery } - - IMentertainment interface { // 三消 - CreateRoom(sessions []IUserSession, rulesStr string) (roomid string, err error) - //用户离线 - UserOffline(roomid string, uid string) (err error) - //主动认输 - AdmitDefeat(roomid string, uid string) (err error) - } ) diff --git a/modules/gameinvite/api_accept.go b/modules/gameinvite/api_accept.go index 8c589905f..d67dda2d8 100644 --- a/modules/gameinvite/api_accept.go +++ b/modules/gameinvite/api_accept.go @@ -152,7 +152,7 @@ func (this *apiComp) Accept(session comm.IUserSession, req *pb.GameInviteAcceptR } break case 5: // 三消类型 - if roomid, err = this.module.catchBugs.CreateRoom(sessions, req.Rules); err != nil { + if roomid, err = this.module.entertain.CreateRoom(sessions, req.Rules); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Title: pb.ErrorCode_DBError.ToString(), diff --git a/modules/gameinvite/api_admitdefeat.go b/modules/gameinvite/api_admitdefeat.go index 67003aeeb..5f0b532a0 100644 --- a/modules/gameinvite/api_admitdefeat.go +++ b/modules/gameinvite/api_admitdefeat.go @@ -56,6 +56,16 @@ func (this *apiComp) AdmitDefeat(session comm.IUserSession, req *pb.GameInviteAd return } break + case 5: + if err = this.module.entertain.AdmitDefeat(req.Roomid, session.GetUserId()); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DBError, + Title: pb.ErrorCode_DBError.ToString(), + Message: err.Error(), + } + return + } + break } session.SendMsg(string(this.module.GetType()), "admitdefeat", &pb.GameInviteAdmitDefeatResp{}) return diff --git a/modules/gameinvite/module.go b/modules/gameinvite/module.go index a6641fc94..f5a902011 100644 --- a/modules/gameinvite/module.go +++ b/modules/gameinvite/module.go @@ -19,6 +19,7 @@ type GameInvite struct { dcolor comm.IDColor caninerabbit comm.ICanineRabbit catchBugs comm.ICatchBugs + entertain comm.IEntertainment } func NewModule() core.IModule { @@ -63,6 +64,11 @@ func (this *GameInvite) Start() (err error) { return } this.catchBugs = module.(comm.ICatchBugs) + + if module, err = this.service.GetModule(comm.ModuleEntertainment); err != nil { + return + } + this.entertain = module.(comm.IEntertainment) this.service.RegisterFunctionName(string(comm.RPC_GameinviteOffline), this.trusteeship) event.RegisterGO(comm.EventUserOffline, this.Useroffline) return @@ -108,6 +114,8 @@ func (this *GameInvite) trusteeship(ctx context.Context, req *pb.RPC_GameInviteO err = this.caninerabbit.UserOffline(req.Roomid, req.Offuid) case 3: err = this.dcolor.UserOffline(req.Roomid, req.Offuid) + // case 5: // 暂不监听 + // err = this.entertain.UserOffline(req.Roomid, req.Offuid) } return }