From 259c8ab3f73ada9e320797399952698a55687186 Mon Sep 17 00:00:00 2001 From: eggmanQQQ <3671373519@qq.com> Date: Wed, 7 Aug 2024 15:35:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=20LUDO=20=E7=9A=84?= =?UTF-8?q?=E9=80=80=E6=88=BF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RoomGame/Presenter/MSRoomGamePresenter.m | 13 +++++++++++-- .../View/RoomGame/Protocol/MSRoomGameProtocol.h | 2 ++ .../View/RoomGame/View/MSTabbarRoomGameVC.h | 2 ++ .../View/RoomGame/View/MSTabbarRoomGameVC.m | 11 +++++++++++ .../Modules/YMTabbar/View/TabbarViewController.m | 16 ++++++++++++++-- 5 files changed, 40 insertions(+), 4 deletions(-) diff --git a/YuMi/Modules/YMRoom/View/RoomGame/Presenter/MSRoomGamePresenter.m b/YuMi/Modules/YMRoom/View/RoomGame/Presenter/MSRoomGamePresenter.m index f15509bd..94a68cff 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/Presenter/MSRoomGamePresenter.m +++ b/YuMi/Modules/YMRoom/View/RoomGame/Presenter/MSRoomGamePresenter.m @@ -63,11 +63,20 @@ } ///开始匹配游戏 -(void)startMatchGameWithroomId:(NSString *)roomId mgId:(NSString *)mgId gameMode:(NSString *)gameMode{ + @kWeakify(self); [Api startMatchGame:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + @kStrongify(self); [[self getView]startMatchGameSuccess]; } fail:^(NSInteger code, NSString * _Nullable msg) { - - } showLoading:YES errorToast:YES] roomId:roomId mgId:mgId gameMode:gameMode]; + if (code == 34792) { // 特殊操作,后续优化 + [TTPopup alertWithMessage:msg confirmHandler:^{ + @kStrongify(self); + [[self getView] forceExitRoom]; + } cancelHandler:^{}]; + } else { + [[self getView] showErrorToast:msg]; + } + } showLoading:YES errorToast:NO] roomId:roomId mgId:mgId gameMode:gameMode]; } ///得到房间详情 -(void)getRoomGameDetailWithRoomType:(NSString *)roomType{ diff --git a/YuMi/Modules/YMRoom/View/RoomGame/Protocol/MSRoomGameProtocol.h b/YuMi/Modules/YMRoom/View/RoomGame/Protocol/MSRoomGameProtocol.h index 41cb8c93..572b3324 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/Protocol/MSRoomGameProtocol.h +++ b/YuMi/Modules/YMRoom/View/RoomGame/Protocol/MSRoomGameProtocol.h @@ -18,6 +18,8 @@ NS_ASSUME_NONNULL_BEGIN -(void)getRoomGameConfigSuccessWithUser:(UserInfoModel *)user gameModel:(MSTabbarRoomGameModel *)gameModel; ///开始游戏 -(void)startMatchGameSuccess; +///用户选择退出房间并重新排位 +-(void)forceExitRoom; ///得到游戏详情 -(void)getRoomGameDetailsSuccessWithModel:(MSRoomGameModel *)model; ///得到金币数量 diff --git a/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.h b/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.h index 7ec3973d..93106065 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.h +++ b/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.h @@ -11,6 +11,8 @@ NS_ASSUME_NONNULL_BEGIN @interface MSTabbarRoomGameVC : MvpViewController +@property (nonatomic, copy) void(^needForceExitRoom)(void); + @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.m b/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.m index ec63889f..cc9203be 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.m +++ b/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.m @@ -119,6 +119,17 @@ } +- (void)forceExitRoom { + if (_needForceExitRoom) { + _needForceExitRoom(); + @kWeakify(self); + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + @kStrongify(self); + [self startMatchGameActionWithModel:self.chooseGameModel]; + }); + } +} + #pragma mark - MSRoomGameProtocol ///得到金币数量 diff --git a/YuMi/Modules/YMTabbar/View/TabbarViewController.m b/YuMi/Modules/YMTabbar/View/TabbarViewController.m index 1db5fcf9..44a20b8a 100644 --- a/YuMi/Modules/YMTabbar/View/TabbarViewController.m +++ b/YuMi/Modules/YMTabbar/View/TabbarViewController.m @@ -754,8 +754,20 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; // viewController = [[XPNewHomeViewController alloc] init]; viewController = [[XPHomePagingViewController alloc] init]; break; - case 1: - viewController = [[MSTabbarRoomGameVC alloc] init]; + case 1: { + @kWeakify(self); + MSTabbarRoomGameVC *vc = [[MSTabbarRoomGameVC alloc] init]; + vc.needForceExitRoom = ^{ + @kStrongify(self); + if ([XPRoomMiniManager shareManager].getRoomInfo) { + [[RtcManager instance] exitRoom]; + [[NIMSDK sharedSDK].chatroomManager exitChatroom:[NSString stringWithFormat:@"%ld", [XPRoomMiniManager shareManager].getRoomInfo.roomId] + completion:nil]; + [self.roomMineView hiddenRoomMiniView]; + } + }; + viewController = vc; + } break; case 2: viewController = [[XPMomentsViewController alloc] init];